This commit is contained in:
2026-01-28 09:04:46 +01:00
parent e85e3a4a8c
commit f0376ea7f6
4 changed files with 41 additions and 13 deletions
+2 -2
View File
@@ -5,7 +5,7 @@
#include "config.h"
#include "index.h"
#include "fonts.h"
#include "lowLevel.ino"
#include "lowLevel.h"
#ifdef __AVR__
#include <avr/power.h> // 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();
}
+22
View File
@@ -0,0 +1,22 @@
#ifndef LOWLEVEL_H
#define LOWLEVEL_H
#include <Adafruit_NeoPixel.h>
#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
+11 -11
View File
@@ -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);
}
}
}
}
+6
View File
@@ -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