altos/telelco-v3: Add logo to 'info' page
[fw/altos] / src / telelco-v3.0 / ao_lco_v3.c
index c991ae6e4822af80fe479b90fe955f657bb32704..2055701b7eb48f7c1a5b27b45d67a6909e7195c3 100644 (file)
@@ -44,6 +44,11 @@ static const struct ao_transform logo_transform = {
        .y_scale = 48, .y_off = 0,
 };
 
+static const struct ao_transform show_transform = {
+       .x_scale = 36, .x_off = 100,
+       .y_scale = 36, .y_off = 0,
+};
+
 #define BIG_FONT BitstreamVeraSans_Roman_58_font
 #define VOLT_FONT BitstreamVeraSans_Roman_58_font
 #define SMALL_FONT BitstreamVeraSans_Roman_12_font
@@ -70,12 +75,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 +159,34 @@ _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_logo_poly(&fb, &show_transform, AO_BLACK, AO_COPY);
+       _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 +202,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");