From 3556cdedb32f0b033fde5d7912e2b53250d86296 Mon Sep 17 00:00:00 2001 From: MarcelineVPQ Date: Sun, 24 May 2026 12:36:40 -0600 Subject: [PATCH] feat(oled): invert the stick box on L3/R3 click (Status screen) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The two analog-stick boxes on the Status screen had no L3/R3 (stick-click) indicator. Add a rect_invert() helper and XOR-invert the whole box on click so it flashes inverse — the position dot inverts with it (black dot on a white box). Bits 0x40 (L3) / 0x80 (R3) on interrupt_in_data[8]. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/oled.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/oled.cpp b/src/oled.cpp index 7b35d94..c2e39e9 100644 --- a/src/oled.cpp +++ b/src/oled.cpp @@ -273,6 +273,16 @@ void rect_filled(int x, int y, int w, int h) { px(x + i, y + j, true); } +// XOR-invert every pixel in a region (used to flash a control "pressed"). +void rect_invert(int x, int y, int w, int h) { + for (int j = 0; j < h; j++) + for (int i = 0; i < w; i++) { + const int xx = x + i, yy = y + j; + if (xx < 0 || xx >= kW || yy < 0 || yy >= kH) continue; + fb[yy * kRowBytes + (xx / 8)] ^= 1 << (7 - (xx % 8)); + } +} + void draw_char(int x, int y, char c) { if (c < 0x20 || c > 0x7E) return; const uint8_t *g = kFont5x7[c - 0x20]; @@ -694,11 +704,15 @@ __attribute__((noinline)) void render_screen() { int lx = (kContentX + 2) + (interrupt_in_data[0] * 27) / 255; int ly = 32 + (interrupt_in_data[1] * 27) / 255; rect_filled(lx - 1, ly - 1, 3, 3); + // L3 (left stick click) — invert the whole box as a pressed indicator. + if (interrupt_in_data[8] & 0x40) rect_invert(kContentX, 30, 32, 32); rect_outline(96, 30, 32, 32); int rx = 98 + (interrupt_in_data[2] * 27) / 255; int ry = 32 + (interrupt_in_data[3] * 27) / 255; rect_filled(rx - 1, ry - 1, 3, 3); + // R3 (right stick click) — invert the whole box. + if (interrupt_in_data[8] & 0x80) rect_invert(96, 30, 32, 32); // L2/R2 analog trigger bars (vertical, fill from bottom). L2 sits // just right of the shifted left stick box.