diff --git a/ledy.ino b/ledy.ino index 69bf395..599faab 100644 --- a/ledy.ino +++ b/ledy.ino @@ -5,7 +5,7 @@ #include "config.h" #include "index.h" #include "fonts.h" -#include "lowLevel.ino" +#include "lowLevel.h" #ifdef __AVR__ #include // Required for 16 MHz Adafruit Trinket @@ -20,7 +20,7 @@ void setup() pixels.begin(); pixels.clear(); - + drawCharacter(font7x5['A' - '!'], 7, 5, 0x00010101, &cursor1); pixels.show(); start_server(); } diff --git a/lowLevel.h b/lowLevel.h new file mode 100644 index 0000000..6ec5f90 --- /dev/null +++ b/lowLevel.h @@ -0,0 +1,22 @@ +#ifndef LOWLEVEL_H +#define LOWLEVEL_H + +#include +#include "config.h" +#include "structs.h" + +extern Adafruit_NeoPixel pixels; +extern unsigned char saved_images_count; +extern Cursor cursor1; +extern uint32_t saved_imaged[2][16][16]; + +// Function declarations +void setPixel(unsigned short x, unsigned short y, uint32_t color); +uint32_t getPixelColor(unsigned short x, unsigned short y); +void drawImageFromSaved(unsigned short offset_x, unsigned short offset_y, unsigned char i); +void drawCharacter(const bool (*character)[5], unsigned char height, unsigned char width, uint32_t color, Cursor (*used_cursor)); +void fillPixels(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, uint32_t color); +void shiftGivenRectangle(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, unsigned char shift_by); + +#endif // LOWLEVEL_H + diff --git a/lowLevel.ino b/lowLevel.ino index 586dc02..c495692 100644 --- a/lowLevel.ino +++ b/lowLevel.ino @@ -1,8 +1,6 @@ -#include "config.h" -#include "structs.h" +#include "lowLevel.h" unsigned char saved_images_count = 0; - Cursor cursor1; uint32_t saved_imaged[2][16][16] = @@ -90,8 +88,8 @@ void drawImageFromSaved(unsigned short offset_x, unsigned short offset_y, unsign } unsigned short pixel_x = col + offset_x; unsigned short pixel_y = row + offset_y; - - if (pixel_x >= 0 && pixel_x < NUMPIXELS && + + if (pixel_x >= 0 && pixel_x < NUMPIXELS && pixel_y >= 0 && pixel_y < NUMPIXELS) { setPixel(pixel_x, pixel_y, px_color); @@ -108,10 +106,10 @@ void drawCharacter(const bool (*character)[5], unsigned char height, unsigned ch { if (character[row][col]) { - unsigned short pixel_x = col + used_cursor.x; - unsigned short pixel_y = row + used_cursor.y; - - if (pixel_x >= 0 && pixel_x < NUMPIXELS && + unsigned short pixel_x = col + used_cursor->x; + unsigned short pixel_y = row + used_cursor->y; + + if (pixel_x >= 0 && pixel_x < NUMPIXELS && pixel_y >= 0 && pixel_y < NUMPIXELS) { setPixel(pixel_x, pixel_y, color); @@ -119,7 +117,7 @@ void drawCharacter(const bool (*character)[5], unsigned char height, unsigned ch } } } - used_cursor.x += width + 1; + used_cursor->x += width + 1; } void fillPixels(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, uint32_t color) @@ -171,4 +169,6 @@ void shiftGivenRectangle(unsigned short x1, unsigned short y1, unsigned short x2 setPixel(x1 + j, y1 + i, 0x00000000); } } -} \ No newline at end of file +} + + diff --git a/structs.h b/structs.h index cebb202..4307f43 100644 --- a/structs.h +++ b/structs.h @@ -1,3 +1,6 @@ +#ifndef STRUCTS_H +#define STRUCTS_H + #include "config.h" struct Cursor @@ -32,3 +35,6 @@ struct Text Text() : color(0), pos_x(0), pos_y(0), character_count(0), characterSize({7,5}), deleted(true) {} }; + +#endif // STRUCTS_H +