some vibecode fixed something

This commit is contained in:
2026-01-29 11:37:29 +01:00
parent 0edafd918c
commit 01992ca864
3 changed files with 61 additions and 17 deletions
+57 -15
View File
@@ -109,8 +109,8 @@ void drawCharacter(const bool (*character)[5], unsigned char height, unsigned ch
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)
if (pixel_x <= PANEL_MAX_X &&
pixel_y <= PANEL_MAX_Y)
{
setPixel(pixel_x, pixel_y, color);
}
@@ -151,27 +151,48 @@ void shiftGivenRectangleLeft(short x1, short y1, short x2, short y2, unsigned ch
}
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);
for (unsigned short i = 0; i < height; i++)
for (short i = 0; i < height; i++)
{
for (unsigned short j = 0; j < width + shift_by; j++)
short y = y1 + i;
if (y < 0 || y > PANEL_MAX_Y) continue;
for (short j = 0; j < width; j++)
{
setPixel(x1 + j - shift_by, y1 + i, getPixelColor(x1 + j, y1 + i));
setPixel(x1 + j, y1 + i, 0x00000000);
short src_x = x1 + j;
short dest_x = src_x - shift_by;
uint32_t color = 0;
if (src_x >= 0 && src_x <= PANEL_MAX_X) {
color = getPixelColor(src_x, y);
}
if (dest_x >= 0 && dest_x <= PANEL_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;
for (short x = x2 - shift_by + 1; x <= x2; x++) {
if (x >= 0 && x <= PANEL_MAX_X) {
setPixel(x, y, 0);
}
}
}
}
void shiftGivenRectangleRight(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, unsigned char shift_by)
void shiftGivenRectangleRight(short x1, short y1, short x2, short y2, unsigned char shift_by)
{
if (!shift_by)
{
@@ -179,22 +200,43 @@ void shiftGivenRectangleRight(unsigned short x1, unsigned short y1, unsigned sh
}
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);
for (unsigned short i = 0; i < height; i++)
for (short i = 0; i < height; i++)
{
for (short j = width + shift_by - 1; j >= 0; j--)
short y = y1 + i;
if (y < 0 || y > PANEL_MAX_Y) continue;
for (short j = width - 1; j >= 0; j--)
{
setPixel(x1 + j, y1 + i, getPixelColor(x1 + j - shift_by, y1 + i));
setPixel(x1 + j - shift_by, y1 + i, 0x00000000);
short src_x = x1 + j;
short dest_x = src_x + shift_by;
uint32_t color = 0;
if (src_x >= 0 && src_x <= PANEL_MAX_X) {
color = getPixelColor(src_x, y);
}
if (dest_x >= 0 && dest_x <= PANEL_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;
for (short x = x1; x < x1 + shift_by; x++) {
if (x >= 0 && x <= PANEL_MAX_X) {
setPixel(x, y, 0);
}
}
}
}