From cfbf3675f0276f73d3d95cbbcc7bc8d54e00f550 Mon Sep 17 00:00:00 2001 From: true Date: Sat, 4 Nov 2023 12:35:20 -0700 Subject: [PATCH] =?UTF-8?q?Added=20na=C3=AFve=20text=20border=20routine?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b5e62c4..a683c2f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -23,9 +23,10 @@ const char name[] = "Your Name"; #define DISP_DC 5 #define TEXT_SIZE 5 +#define BORDER_COLOR DARKGREY #define ROT_SIZE 70 -#define LETTER_SPACING 1898 // user-configurable +#define LETTER_SPACING 1942 // user-configurable Arduino_DataBus *bus = new Arduino_RPiPicoSPI(DISP_DC, DISP_NSS, SPI0_SCK, SPI0_MOSI, SPI0_MISO, spi0); @@ -76,19 +77,56 @@ void rotate_letter(uint8_t idx, int16_t rot, int16_t out_x, int16_t out_y, uint1 uint16_t src_pxl; uint16_t bgcolor = CYAN; + uint8_t is_color; + // clear the rotation buffer drot->fillScreen(CYAN); // print the letter to the center of the rotation buffer - drot->setCursor(0, TEXT_SIZE * 10); + drot->setCursor(1, (TEXT_SIZE * 10)); drot->setTextColor(color); drot->print(name[idx]); - x_width = drot->getCursorX() - TEXT_SIZE; + x_width = drot->getCursorX() - TEXT_SIZE + 1; - // framebuffers + // framebuffer pointers src = drot->getFramebuffer(); dst = dout->getFramebuffer(); + // naive bordering + for (y = 0; y < ROT_SIZE; y++) { + is_color = 0; + for (x = 0; x < x_width; x++) { + if (is_color) { + if (src[x + (y * ROT_SIZE)] != color) { + is_color = 0; + src[x + (y * ROT_SIZE)] = BORDER_COLOR; + } + } else { + if (src[x + (y * ROT_SIZE)] == color) { + is_color = 1; + src[x + (y * ROT_SIZE) - 1] = BORDER_COLOR; + } + } + } + } + + for (x = 0; x < x_width; x++) { + is_color = 0; + for (y = 0; y < ROT_SIZE; y++) { + if (is_color) { + if (src[x + (y * ROT_SIZE)] != color) { + is_color = 0; + src[x + (y * ROT_SIZE)] = BORDER_COLOR; + } + } else { + if (src[x + (y * ROT_SIZE)] == color) { + is_color = 1; + src[x + (y * ROT_SIZE) - ROT_SIZE] = BORDER_COLOR; + } + } + } + } + // position start_x = out_x + 120; start_y = out_y + 120; @@ -176,6 +214,7 @@ void bg_rainbow_circles(uint8_t saturation) // hsv.h %= 1536; // hsv2rgb_8b(hue, 255, 128, &rgb.r, &rgb.g, &rgb.b); // dout->fillScreen(dout->color565(rgb.r, rgb.g, rgb.b)); + dout->fillScreen(BLACK); // draw some circles hue = hsv.h; @@ -218,7 +257,8 @@ void loop() // rainbow circles program bg_rainbow_circles(200); - texthue_180degree(); + // texthue_180degree(); + rgb.r = rgb.g = rgb.b = 0; // small hue shift with larger saturation shifts circles // bg_huesatcycle_circles();