some vibecoded fixes

This commit is contained in:
2026-01-29 14:28:56 +01:00
parent 2e6aa91f01
commit c5a15269c3
5 changed files with 319 additions and 85 deletions
+31 -24
View File
@@ -57,8 +57,9 @@ uint32_t saved_imaged[2][16][16] =
}
};
void setPixel(unsigned short x, unsigned short y, uint32_t color)
void setPixel(short x, short y, uint32_t color)
{
if (x < 0 || y < 0) return;
if (x % 2 == 1)
{
y = PANEL_PIXEL_COUNT - 1 - y;
@@ -66,8 +67,9 @@ void setPixel(unsigned short x, unsigned short y, uint32_t color)
pixels.setPixelColor(y + (x * PANEL_PIXEL_COUNT), color);
}
uint32_t getPixelColor(unsigned short x, unsigned short y)
uint32_t getPixelColor(short x, short y)
{
if (x < 0 || y < 0) return 0;
if (x % 2 == 1)
{
y = PANEL_PIXEL_COUNT - 1 - y;
@@ -75,7 +77,7 @@ uint32_t getPixelColor(unsigned short x, unsigned short y)
return pixels.getPixelColor(y + (x * PANEL_PIXEL_COUNT));
}
void drawImageFromSaved(unsigned short offset_x, unsigned short offset_y, unsigned char i)
void drawImageFromSaved(short offset_x, short offset_y, unsigned char i)
{
for (int row = 0; row < 16; row++)
{
@@ -86,8 +88,8 @@ void drawImageFromSaved(unsigned short offset_x, unsigned short offset_y, unsign
{
continue;
}
unsigned short pixel_x = col + offset_x;
unsigned short pixel_y = row + offset_y;
short pixel_x = col + offset_x;
short pixel_y = row + offset_y;
if (pixel_x >= 0 && pixel_x < NUMPIXELS &&
pixel_y >= 0 && pixel_y < NUMPIXELS)
@@ -98,45 +100,50 @@ void drawImageFromSaved(unsigned short offset_x, unsigned short offset_y, unsign
}
}
void drawCharacter(const bool (*character)[5], unsigned char height, unsigned char width, uint32_t color, Cursor (*used_cursor))
void drawCharacterPart(const bool* character_row, unsigned char height, uint32_t color, short start_x, short start_y)
{
for (unsigned char row = 0; row < 7; row++)
for (unsigned char col = 0; col < height; col++)
{
for (unsigned char col = 0; col < 5; col++)
if (character_row[col])
{
if (character[row][col])
{
unsigned short pixel_x = col + used_cursor->x;
unsigned short pixel_y = row + used_cursor->y;
short pixel_x = col + start_x;
short pixel_y = start_y;
if (pixel_x <= PANEL_MAX_X &&
pixel_y <= PANEL_MAX_Y)
{
setPixel(pixel_x, pixel_y, color);
}
if (pixel_x >= 0 && pixel_x <= PANEL_MAX_X &&
pixel_y >= 0 && pixel_y <= PANEL_MAX_Y)
{
setPixel(pixel_x, pixel_y, color);
}
}
}
}
void drawCharacter(const bool (*character)[5], unsigned char height, unsigned char width, uint32_t color, Cursor (*used_cursor))
{
for (unsigned char row = 0; row < height; row++)
{
drawCharacterPart(character[row], width, color, used_cursor->x, row + used_cursor->y);
}
used_cursor->x += width + 1;
}
void fillPixels(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, uint32_t color)
void fillPixels(short x1, short y1, short x2, short y2, uint32_t color)
{
if (x1 > x2)
{
unsigned short tmp = x1; x1 = x2; x2 = tmp;
short tmp = x1; x1 = x2; x2 = tmp;
}
if (y1 > y2)
{
unsigned short tmp = y1; y1 = y2; y2 = tmp;
short tmp = y1; y1 = y2; y2 = tmp;
}
unsigned short width = (unsigned short)(x2 - x1 + 1);
unsigned short height = (unsigned short)(y2 - y1 + 1);
short width = (short)(x2 - x1 + 1);
short height = (short)(y2 - y1 + 1);
for (unsigned short i = 0; i < height; i++)
for (short i = 0; i < height; i++)
{
for (unsigned short j = 0; j < width; j++)
for (short j = 0; j < width; j++)
{
setPixel(x1 + j, y1 + i, color);
}