altos: Fix up stm32f103-nucleo 'lco' demo mode
authorKeith Packard <keithp@keithp.com>
Thu, 16 Mar 2023 17:24:36 +0000 (10:24 -0700)
committerKeith Packard <keithp@keithp.com>
Thu, 1 Feb 2024 01:50:19 +0000 (17:50 -0800)
Adjust some layout now that I've got a real screen to play with.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/stm32f103-nucleo/ao_pins.h
src/stm32f103-nucleo/hello.c

index f57c0a94fdd6de902a78f58ecc3e47e5b46b629d..8062d7f2a35e1745ea6d9e5a8ac61e1e1434e484 100644 (file)
@@ -68,4 +68,4 @@
 #define AO_ST7565_SPI_BUS      AO_SPI_1_PA5_PA6_PA7
 #define AO_ST7565_WIDTH                128
 #define AO_ST7565_HEIGHT       64
-#define AO_ST7565_BIAS         AO_ST7565_LCD_BIAS_1_9
+#define AO_ST7565_BIAS         ST7565_LCD_BIAS_1_9
index 6ecfc8730af0a92ea6096d076c076067e7b05892..ed4e895fc20b6dfb2757924ed920c55f4d9c0896 100644 (file)
@@ -125,7 +125,7 @@ prev_box(void)
 #endif
 
 static const struct ao_transform logo_transform = {
-       .x_scale = 48, .x_off = 0,
+       .x_scale = 48, .x_off = 2,
        .y_scale = 48, .y_off = 0,
 };
 
@@ -136,23 +136,24 @@ static const struct ao_transform logo_transform = {
 #define LOGO_FONT BenguiatGothicStd_Bold_26_font
 
 #define LABEL_Y                (int16_t) (SMALL_FONT.ascent)
-#define VALUE_Y                (int16_t) (LABEL_Y + BIG_FONT.ascent + 3)
+#define VALUE_Y                (int16_t) (LABEL_Y + BIG_FONT.ascent + 5)
 #define BOX_X          2
 #define PAD_X          90
 #define BOX_LABEL_X    30
 #define VOLT_LABEL_X   25
 #define RSSI_LABEL_X   15
 #define PAD_LABEL_X    95
-#define SEP_X          (PAD_X - 10)
+#define SEP_X          (PAD_X - 8)
 #define SCAN_X         (WIDTH - 100) / 2
-#define SCAN_Y         49
-#define SCAN_HEIGHT    4
+#define SCAN_Y         50
+#define SCAN_HEIGHT    3
 #define FOUND_Y                63
+#define FOUND_X                6
 #define FOUND_WIDTH    17
 #define MAX_VALID      (WIDTH / FOUND_WIDTH)
 
-static int16_t box_number = 1;
-static int16_t pad_number = 1;
+static int16_t box_number = 88;
+static int16_t pad_number = 8;
 
 static void
 ao_st7565_poly(void)
@@ -166,9 +167,9 @@ ao_st7565_poly(void)
 
        for (scan_number = 0; scan_number < 100; scan_number++) {
                ao_rect(&fb, 0, 0, WIDTH, HEIGHT, AO_WHITE, AO_COPY);
-               ao_logo(&fb, &logo_transform, &LOGO_FONT, 0x00000000, AO_COPY);
+               ao_logo(&fb, &logo_transform, &LOGO_FONT, AO_BLACK, AO_COPY);
                if (scan_number) {
-                       ao_rect(&fb, SCAN_X, SCAN_Y, (int16_t) scan_number, SCAN_HEIGHT, 0x00000000, AO_COPY);
+                       ao_rect(&fb, SCAN_X, SCAN_Y, (int16_t) scan_number, SCAN_HEIGHT, AO_BLACK, AO_COPY);
                        b = 0;
                        v = 0;
                        last_box = 0;
@@ -184,7 +185,8 @@ ao_st7565_poly(void)
                        for (; i <= scan_number; i++) {
                                if (valid_box(i)) {
                                        sprintf(str, "%02d%s", i, i == last_box ? "" : ",");
-                                       ao_text(&fb, &TINY_FONT, 0 + FOUND_WIDTH * b, FOUND_Y, str, 0x00000000, AO_COPY);
+                                       ao_text(&fb, &TINY_FONT, (int16_t) (FOUND_X + FOUND_WIDTH * b),
+                                               FOUND_Y, str, AO_BLACK, AO_COPY);
                                        b++;
                                }
                        }
@@ -196,31 +198,31 @@ ao_st7565_poly(void)
        switch (box_number) {
        case 0:
                sprintf(str, "%4.1f", lco_volts);
-               ao_text(&fb, &VOLT_FONT, BOX_X, VALUE_Y, str, 0x00000000, AO_COPY);
-               ao_text(&fb, &SMALL_FONT, VOLT_LABEL_X, LABEL_Y, "LCO Battery", 0x00000000, AO_COPY);
+               ao_text(&fb, &VOLT_FONT, BOX_X, VALUE_Y, str, AO_BLACK, AO_COPY);
+               ao_text(&fb, &SMALL_FONT, VOLT_LABEL_X, LABEL_Y, "LCO Battery", AO_BLACK, AO_COPY);
                break;
        default:
                switch (pad_number) {
                case -1:
                        sprintf(str, "%4.1f", pad_volts);
-                       ao_text(&fb, &VOLT_FONT, BOX_X, VALUE_Y, str, 0x00000000, AO_COPY);
-                       ao_text(&fb, &SMALL_FONT, VOLT_LABEL_X, LABEL_Y, "Pad Battery", 0x00000000, AO_COPY);
+                       ao_text(&fb, &VOLT_FONT, BOX_X, VALUE_Y, str, AO_BLACK, AO_COPY);
+                       ao_text(&fb, &SMALL_FONT, VOLT_LABEL_X, LABEL_Y, "Pad Battery", AO_BLACK, AO_COPY);
                        break;
                case 0:
                        sprintf(str, "%4d", rssi);
-                       ao_text(&fb, &VOLT_FONT, BOX_X, VALUE_Y, str, 0x00000000, AO_COPY);
-                       ao_text(&fb, &SMALL_FONT, RSSI_LABEL_X, LABEL_Y, "Signal Strength", 0x00000000, AO_COPY);
+                       ao_text(&fb, &VOLT_FONT, BOX_X, VALUE_Y, str, AO_BLACK, AO_COPY);
+                       ao_text(&fb, &SMALL_FONT, RSSI_LABEL_X, LABEL_Y, "Signal Strength", AO_BLACK, AO_COPY);
                        break;
                default:
                        sprintf(str, "%02d", box_number);
-                       ao_text(&fb, &BIG_FONT, BOX_X, VALUE_Y, str, 0x00000000, AO_COPY);
-                       ao_text(&fb, &SMALL_FONT, BOX_LABEL_X, LABEL_Y, "Box", 0x00000000, AO_COPY);
+                       ao_text(&fb, &BIG_FONT, BOX_X, VALUE_Y, str, AO_BLACK, AO_COPY);
+                       ao_text(&fb, &SMALL_FONT, BOX_LABEL_X, LABEL_Y, "Box", AO_BLACK, AO_COPY);
 
                        sprintf(str, "%d", pad_number);
-                       ao_text(&fb, &BIG_FONT, PAD_X, VALUE_Y, str, 0x00000000, AO_COPY);
-                       ao_text(&fb, &SMALL_FONT, PAD_LABEL_X, LABEL_Y, "Pad", 0x00000000, AO_COPY);
+                       ao_text(&fb, &BIG_FONT, PAD_X, VALUE_Y, str, AO_BLACK, AO_COPY);
+                       ao_text(&fb, &SMALL_FONT, PAD_LABEL_X, LABEL_Y, "Pad", AO_BLACK, AO_COPY);
 
-                       ao_rect(&fb, SEP_X, 0, 2, HEIGHT, 0x00000000, AO_COPY);
+                       ao_rect(&fb, SEP_X, 0, 2, HEIGHT, AO_BLACK, AO_COPY);
                }
                break;
        }