telelco-v3.0: Add info page
authorKeith Packard <keithp@keithp.com>
Sun, 28 Jan 2024 00:35:33 +0000 (16:35 -0800)
committerKeith Packard <keithp@keithp.com>
Thu, 1 Feb 2024 01:50:19 +0000 (17:50 -0800)
Show model, version, serial, call and freq

Signed-off-by: Keith Packard <keithp@keithp.com>
src/drivers/ao_lco.h
src/drivers/ao_lco_bits.c
src/telelco-v3.0/ao_lco_v3.c
src/telelco-v3.0/ao_pins.h

index 42f4e6d845a2ad0a798f683e796f4211aa5a4045..f931872b5b0ac14fcb61a35d2b7b2dc3fbc181fa 100644 (file)
@@ -50,7 +50,13 @@ extern struct ao_pad_query   ao_pad_query;   /* Last received QUERY from pad */
 #define AO_LCO_BOX_DRAG                0               /* Box number to enable drag race mode (old LCO bits) */
 #define AO_LCO_BOX_FIRST       AO_LCO_BOX_DRAG
 #else
-#define AO_LCO_LCO_VOLTAGE     0               /* Box number to show LCO voltage */
+# define AO_LCO_LCO_VOLTAGE    0               /* Box number to show LCO voltage */
+# ifdef AO_LCO_HAS_INFO
+#  define AO_LCO_INFO          -3
+#  ifndef AO_LCO_BOX_FIRST
+#   define AO_LCO_BOX_FIRST AO_LCO_INFO
+#  endif
+# endif
 # ifdef AO_LCO_HAS_BACKLIGHT
 #   define AO_LCO_BACKLIGHT    -2
 #   ifndef AO_LCO_BOX_FIRST
@@ -88,6 +94,10 @@ ao_lco_box_pseudo(int16_t box)
 #ifdef AO_LCO_BACKLIGHT
        case AO_LCO_BACKLIGHT:
                return true;
+#endif
+#ifdef AO_LCO_INFO
+       case AO_LCO_INFO:
+               return true;
 #endif
        default:
                return false;
index 7dd63615dcce880fcef42b87c985abd457ca23de..b574437d9e6517acccc666febeea71fac8e8c826 100644 (file)
@@ -252,8 +252,9 @@ ao_lco_step_pad(int8_t dir)
 {
        int16_t new_pad;
 
+       switch (ao_lco_box) {
 #ifdef AO_LCO_HAS_CONTRAST
-       if (ao_lco_box == AO_LCO_CONTRAST) {
+       case AO_LCO_CONTRAST: {
                int32_t contrast = ao_lco_get_contrast();
 
                contrast = (contrast + AO_LCO_CONTRAST_STEP - 1) / AO_LCO_CONTRAST_STEP;
@@ -264,10 +265,11 @@ ao_lco_step_pad(int8_t dir)
                if (contrast > AO_LCO_MAX_CONTRAST)
                        contrast = AO_LCO_MAX_CONTRAST;
                ao_lco_set_contrast(contrast);
+               break;
        }
 #endif
 #ifdef AO_LCO_HAS_BACKLIGHT
-       if (ao_lco_box == AO_LCO_BACKLIGHT) {
+       case AO_LCO_BACKLIGHT: {
                int32_t backlight = ao_lco_get_backlight();
 
                backlight = (backlight + AO_LCO_BACKLIGHT_STEP - 1) / AO_LCO_BACKLIGHT_STEP;
@@ -278,20 +280,39 @@ ao_lco_step_pad(int8_t dir)
                if (backlight > AO_LCO_MAX_BACKLIGHT)
                        backlight = AO_LCO_MAX_BACKLIGHT;
                ao_lco_set_backlight(backlight);
+               break;
        }
 #endif
-       new_pad = (int16_t) ao_lco_pad;
-       do {
-               new_pad += dir;
-               if (new_pad > AO_PAD_MAX_CHANNELS)
-                       new_pad = AO_LCO_PAD_VOLTAGE;
-               if (new_pad < 0)
-                       new_pad = AO_PAD_MAX_CHANNELS;
-               if (new_pad == ao_lco_pad)
-                       break;
-       } while (!ao_lco_pad_present(ao_lco_box, (uint8_t) new_pad));
-       PRINTD("New pad %d\n", new_pad);
-       ao_lco_set_pad((uint8_t) new_pad);
+#ifdef AO_LCO_HAS_INFO
+       case AO_LCO_INFO: {
+#if AO_LCO_MIN_INFO_PAGE < AO_LCO_MAX_INFO_PAGE
+               int32_t info_page = ao_lco_get_info_page();
+
+               info += dir;
+               if (info_page < AO_LCO_MIN_INFO_PAGE)
+                       info_page = AO_LCO_MIN_INFO_PAGE;
+               if (info_page > AO_LCO_MAX_INFO_PAGE)
+                       info_page = AO_LCO_MAX_INFO_PAGE;
+               ao_lco_set_info_page();
+#endif
+               break;
+       }
+#endif
+       default:
+               new_pad = (int16_t) ao_lco_pad;
+               do {
+                       new_pad += dir;
+                       if (new_pad > AO_PAD_MAX_CHANNELS)
+                               new_pad = AO_LCO_PAD_VOLTAGE;
+                       if (new_pad < 0)
+                               new_pad = AO_PAD_MAX_CHANNELS;
+                       if (new_pad == ao_lco_pad)
+                               break;
+               } while (!ao_lco_pad_present(ao_lco_box, (uint8_t) new_pad));
+               PRINTD("New pad %d\n", new_pad);
+               ao_lco_set_pad((uint8_t) new_pad);
+               break;
+       }
 }
 
 uint8_t
index c991ae6e4822af80fe479b90fe955f657bb32704..e1a6dcad29de15ff289f822878d4471e93e05076 100644 (file)
@@ -70,12 +70,13 @@ static const struct ao_transform logo_transform = {
 #define CONTRAST_X     (WIDTH - CONTRAST_WIDTH) / 2
 #define CONTRAST_Y     20
 #define CONTRAST_HEIGHT        20
-
 #define BACKLIGHT_LABEL_X      37
 #define BACKLIGHT_WIDTH        100
 #define BACKLIGHT_X    (WIDTH - BACKLIGHT_WIDTH) / 2
 #define BACKLIGHT_Y    20
 #define BACKLIGHT_HEIGHT       20
+#define INFO_START_Y   ((int16_t) (SMALL_FONT.ascent + 2))
+#define INFO_STEP_Y    ((int16_t) (SMALL_FONT.ascent + 3))
 
 #define AO_LCO_DRAG_RACE_START_TIME    AO_SEC_TO_TICKS(5)
 #define AO_LCO_DRAG_RACE_STOP_TIME     AO_SEC_TO_TICKS(2)
@@ -153,6 +154,33 @@ _ao_lco_show_backlight(void)
        ao_rect(&fb, BACKLIGHT_X, BACKLIGHT_Y, value, BACKLIGHT_HEIGHT, AO_BLACK, AO_COPY);
 }
 
+static int16_t info_y;
+
+static void
+_ao_lco_info(const char *format, ...)
+{
+       va_list a;
+       char    buf[20];
+       va_start(a, format);
+       vsnprintf(buf, sizeof(buf), format, a);
+       va_end(a);
+       ao_text(&fb, &SMALL_FONT, 0, info_y, buf, AO_BLACK, AO_COPY);
+       info_y += INFO_STEP_Y;
+}
+
+static void
+_ao_lco_show_info(void)
+{
+       info_y = INFO_START_Y;
+       _ao_lco_info("%s", ao_product);
+       _ao_lco_info("Version: %s", ao_version);
+       _ao_lco_info("Serial: %d", ao_serial_number);
+       _ao_lco_info("Callsign: %s", ao_config.callsign);
+       _ao_lco_info("Frequency: %ld.%03d",
+                    ao_config.frequency / 1000,
+                    (int) (ao_config.frequency % 1000));
+}
+
 void
 ao_lco_show(void)
 {
@@ -168,6 +196,9 @@ ao_lco_show(void)
        case AO_LCO_BACKLIGHT:
                _ao_lco_show_backlight();
                break;
+       case AO_LCO_INFO:
+               _ao_lco_show_info();
+               break;
        default:
                if (ao_lco_pad == AO_LCO_PAD_VOLTAGE) {
                        _ao_lco_show_voltage(ao_pad_query.battery, "Pad battery");
index 7a7ffae2acff8e78f565dc386dd15513133b7a0d..e286cae6eceacc97c1ad571441faeb64ae0637af 100644 (file)
@@ -306,6 +306,10 @@ struct ao_adc {
 #define AO_LCO_MAX_BACKLIGHT   65535
 #define AO_LCO_BACKLIGHT_STEP  771
 
+#define AO_LCO_HAS_INFO                1
+#define AO_LCO_MIN_INFO_PAGE   0
+#define AO_LCO_MAX_INFO_PAGE   0
+
 /*
  * LCD Backlight via PWM.
  *