last leds flahses wierdly

This commit is contained in:
2026-02-04 09:41:32 +01:00
parent 0903121e61
commit 5b82e5a41e
5 changed files with 101 additions and 28 deletions
+4 -3
View File
@@ -4,13 +4,14 @@
#define PANEL_PIXEL_COUNT 16
#define PANEL_COUNT 3
#define NUMPIXELS PANEL_PIXEL_COUNT*PANEL_PIXEL_COUNT*PANEL_COUNT
#define PANEL_MAX_X PANEL_PIXEL_COUNT * PANEL_COUNT - 1
#define PANEL_MAX_Y PANEL_PIXEL_COUNT - 1
#define DISPLAY_MAX_X PANEL_PIXEL_COUNT * PANEL_COUNT - 1
#define DISPLAY_MAX_Y PANEL_PIXEL_COUNT - 1
#define TEXT_MAX_LENGTH 64
#define MAX_TEXT_NODES_COUNT 4
#define MAX_IMAGES_SAVED 2
#define SMALL_TEXT_HEIGHT 7
#define SMALL_TEXT_WIDTH 5
#define MEDIUM_TEXT_HEIGHT 7
#define MEDIUM_TEXT_WIDTH 5
+58 -5
View File
@@ -17,6 +17,50 @@ TextNode text_nodes[MAX_TEXT_NODES_COUNT];
Cursor cursor;
short ever_created_text_nodes = 0;
Image saved_images[MAX_IMAGES_SAVED] = {
{
{
// Row 0
{{255,0,0}, {255,0,0}, {255,0,0}, {255,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,255,0}, {0,255,0}, {0,255,0}, {0,255,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,255}, {0,0,255}, {0,0,255}, {0,0,255}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {255,255,0}, {255,255,0}, {255,255,0}, {255,255,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {255,0,255}, {255,0,255}, {255,0,255}, {255,0,255}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,255,255}, {0,255,255}, {0,255,255}, {0,255,255}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
// Row 1
{{255,0,0}, {255,0,0}, {255,0,0}, {255,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,255,0}, {0,255,0}, {0,255,0}, {0,255,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,255}, {0,0,255}, {0,0,255}, {0,0,255}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {255,255,0}, {255,255,0}, {255,255,0}, {255,255,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {255,0,255}, {255,0,255}, {255,0,255}, {255,0,255}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,255,255}, {0,255,255}, {0,255,255}, {0,255,255}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
// Row 2
{{255,0,0}, {255,0,0}, {255,0,0}, {255,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,255,0}, {0,255,0}, {0,255,0}, {0,255,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,255}, {0,0,255}, {0,0,255}, {0,0,255}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {255,255,0}, {255,255,0}, {255,255,0}, {255,255,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {255,0,255}, {255,0,255}, {255,0,255}, {255,0,255}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,255,255}, {0,255,255}, {0,255,255}, {0,255,255}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
// Row 3
{{255,0,0}, {255,0,0}, {255,0,0}, {255,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,255,0}, {0,255,0}, {0,255,0}, {0,255,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,255}, {0,0,255}, {0,0,255}, {0,0,255}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {255,255,0}, {255,255,0}, {255,255,0}, {255,255,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {255,0,255}, {255,0,255}, {255,0,255}, {255,0,255}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,255,255}, {0,255,255}, {0,255,255}, {0,255,255}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
// Row 4
{{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
// Row 5
{{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
// Row 6
{{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
// Row 7
{{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}},
// Row 8
{{255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}},
// Row 9
{{255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}},
// Row 10
{{255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}},
// Row 11
{{255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}, {255,255,255}},
// Row 12
{{128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}},
// Row 13
{{128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}},
// Row 14
{{128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}},
// Row 15
{{128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}, {128,128,128}}
},
48, // width
16 // height
},
{}
};
short getTextNodeY2(TextNode *node)
{
return node->pos_y + node->characterSize.height - 1;
@@ -100,7 +144,7 @@ void scrollAllScrollableTexts(bool split_scroll_mode = false)
}
else
{
if (x1 > PANEL_MAX_X)
if (x1 > DISPLAY_MAX_X)
{
text_nodes[i].is_deleted = true;
continue;
@@ -125,6 +169,18 @@ void scrollAllScrollableTexts(bool split_scroll_mode = false)
}
}
void drawImageFromMemoryByIndex(unsigned char image_index, short pos_x, short pos_y)
{
Image* img = &saved_images[image_index];
for (unsigned char y = 0; y < img->height; y++)
{
for (unsigned char x = 0; x < img->width; x++)
{
setPixel(x + pos_x, y + pos_y, pixels.Color(img->pixels[y][x].r, img->pixels[y][x].g, img->pixels[y][x].b));
}
}
}
void setup()
{
Serial.begin(115200);
@@ -146,10 +202,7 @@ void loop()
handle_server();
if (text_nodes[0].is_deleted && text_nodes[2].is_deleted)
{
cursor.x = PANEL_MAX_X + 1;
addNewTextNode("color", 0xFF121212, true);
addNewTextNode("ful ", 0xFF000036, true);
addNewTextNode("test", 0xFF121212, true);
drawImageFromMemoryByIndex(0,0,0);
}
scrollAllScrollableTexts();
pixels.show();
+12 -12
View File
@@ -108,8 +108,8 @@ void drawCharacterPart(const bool* character_row, unsigned char height, uint32_t
short pixel_x = col + start_x;
short pixel_y = start_y;
if (pixel_x >= 0 && pixel_x <= PANEL_MAX_X &&
pixel_y >= 0 && pixel_y <= PANEL_MAX_Y)
if (pixel_x >= 0 && pixel_x <= DISPLAY_MAX_X &&
pixel_y >= 0 && pixel_y <= DISPLAY_MAX_Y)
{
setPixel(pixel_x, pixel_y, color);
}
@@ -170,7 +170,7 @@ void shiftGivenRectangleLeft(short x1, short y1, short x2, short y2, unsigned ch
for (short i = 0; i < height; i++)
{
short y = y1 + i;
if (y < 0 || y > PANEL_MAX_Y) continue;
if (y < 0 || y > DISPLAY_MAX_Y) continue;
for (short j = 0; j < width; j++)
{
@@ -178,20 +178,20 @@ void shiftGivenRectangleLeft(short x1, short y1, short x2, short y2, unsigned ch
short dest_x = src_x - shift_by;
uint32_t color = 0;
if (src_x >= 0 && src_x <= PANEL_MAX_X) {
if (src_x >= 0 && src_x <= DISPLAY_MAX_X) {
color = getPixelColor(src_x, y);
}
if (dest_x >= 0 && dest_x <= PANEL_MAX_X) {
if (dest_x >= 0 && dest_x <= DISPLAY_MAX_X) {
setPixel(dest_x, y, color);
}
}
}
// Clear the trailing edge that was shifted from
for (short y = y1; y <= y2; y++) {
if (y < 0 || y > PANEL_MAX_Y) continue;
if (y < 0 || y > DISPLAY_MAX_Y) continue;
for (short x = x2 - shift_by + 1; x <= x2; x++) {
if (x >= 0 && x <= PANEL_MAX_X) {
if (x >= 0 && x <= DISPLAY_MAX_X) {
setPixel(x, y, 0);
}
}
@@ -219,7 +219,7 @@ void shiftGivenRectangleRight(short x1, short y1, short x2, short y2, unsigned c
for (short i = 0; i < height; i++)
{
short y = y1 + i;
if (y < 0 || y > PANEL_MAX_Y) continue;
if (y < 0 || y > DISPLAY_MAX_Y) continue;
for (short j = width - 1; j >= 0; j--)
{
@@ -227,20 +227,20 @@ void shiftGivenRectangleRight(short x1, short y1, short x2, short y2, unsigned c
short dest_x = src_x + shift_by;
uint32_t color = 0;
if (src_x >= 0 && src_x <= PANEL_MAX_X) {
if (src_x >= 0 && src_x <= DISPLAY_MAX_X) {
color = getPixelColor(src_x, y);
}
if (dest_x >= 0 && dest_x <= PANEL_MAX_X) {
if (dest_x >= 0 && dest_x <= DISPLAY_MAX_X) {
setPixel(dest_x, y, color);
}
}
}
// Clear the trailing edge that was shifted from
for (short y = y1; y <= y2; y++) {
if (y < 0 || y > PANEL_MAX_Y) continue;
if (y < 0 || y > DISPLAY_MAX_Y) continue;
for (short x = x1; x < x1 + shift_by; x++) {
if (x >= 0 && x <= PANEL_MAX_X) {
if (x >= 0 && x <= DISPLAY_MAX_X) {
setPixel(x, y, 0);
}
}
+13 -8
View File
@@ -40,30 +40,35 @@ void handleUpload()
}
// Save the new image to the next slot
if (saved_images_count < 11)
{ // Ensure we don't overflow (max index is 11)
saved_images_count++;
if (saved_images_count >= MAX_IMAGES_SAVED) {
saved_images_count = 0;
}
// Copy new_image data to saved_imaged array
// Copy new_image data to saved_images array
for (int r = 0; r < 16; r++)
{
for (int c = 0; c < 16; c++)
{
saved_imaged[saved_images_count][r][c] = new_image[r][c].color;
uint32_t color = new_image[r][c].color;
RGB rgb = {(unsigned char)((color >> 16) & 0xFF), (unsigned char)((color >> 8) & 0xFF), (unsigned char)(color & 0xFF)};
saved_images[saved_images_count].pixels[r][c] = rgb;
}
}
saved_images[saved_images_count].width = 16;
saved_images[saved_images_count].height = 16;
pixels.clear();
drawImageFromSaved(0, 0, saved_images_count);
drawImageFromMemoryByIndex(saved_images_count, 0, 0);
pixels.show();
server.send(200, "text/plain", "OK");
saved_images_count++;
}
void handleShowSaved()
{
pixels.clear();
drawImageFromSaved(0, 0, 0);
drawImageFromMemoryByIndex(0, 0, 0);
pixels.show();
server.send(200, "text/plain", "OK");
}
+14
View File
@@ -39,5 +39,19 @@ struct TextNode
TextNode() : color(0), pos_x(0), pos_y(0), character_count(0), scroll_slowness(0), scroll_progress(0), characterSize({7,5}), is_deleted(true), is_scrolling() {}
};
struct RGB
{
unsigned char r;
unsigned char g;
unsigned char b;
};
struct Image
{
RGB pixels[PANEL_PIXEL_COUNT][DISPLAY_MAX_X + 1];
unsigned short width;
unsigned short height;
};
#endif // STRUCTS_H