+ char buf[8];
+ uint8_t brightness = ao_st7565_get_brightness();
+ int16_t contrast = (int16_t) (brightness * CONTRAST_WIDTH / AO_LCO_MAX_CONTRAST);
+ int16_t width;
+
+ ao_text(&fb, &SMALL_FONT, CONTRAST_LABEL_X, LABEL_Y, "Contrast", AO_BLACK, AO_COPY);
+ ao_rect(&fb, CONTRAST_X, CONTRAST_Y, contrast, CONTRAST_HEIGHT, AO_BLACK, AO_COPY);
+ /* this "knows" that CONTRAST_WIDTH == 100 */
+ snprintf(buf, sizeof(buf), "%d %%", contrast);
+ width = ao_text_width(&SMALL_FONT, buf);
+ ao_text(&fb, &SMALL_FONT, BACKLIGHT_VALUE_X - width / 2, BACKLIGHT_VALUE_Y, buf, AO_BLACK, AO_COPY);
+}
+
+static void
+_ao_lco_show_backlight(void)
+{
+ char buf[8];
+ int32_t backlight = ao_lco_get_backlight();
+ int16_t value = (int16_t) (backlight * BACKLIGHT_WIDTH / AO_LCO_MAX_BACKLIGHT);
+ int16_t width;
+
+ ao_text(&fb, &SMALL_FONT, BACKLIGHT_LABEL_X, LABEL_Y, "Backlight", AO_BLACK, AO_COPY);
+ ao_rect(&fb, BACKLIGHT_X, BACKLIGHT_Y, value, BACKLIGHT_HEIGHT, AO_BLACK, AO_COPY);
+ /* this "knows" that BACKLIGHT_WIDTH == 100 */
+ snprintf(buf, sizeof(buf), "%d %%", value);
+ width = ao_text_width(&SMALL_FONT, buf);
+ ao_text(&fb, &SMALL_FONT, BACKLIGHT_VALUE_X - width / 2, BACKLIGHT_VALUE_Y, buf, 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)
+{
+ ao_mutex_get(&ao_lco_display_mutex);
+ ao_rect(&fb, 0, 0, WIDTH, HEIGHT, AO_WHITE, AO_COPY);
+ switch (ao_lco_box) {
+ case AO_LCO_LCO_VOLTAGE:
+ _ao_lco_batt_voltage();
+ break;
+ case AO_LCO_CONTRAST:
+ _ao_lco_show_contrast();
+ break;
+ 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");
+ } else {
+ _ao_lco_show_pad(ao_lco_pad);
+ _ao_lco_show_box(ao_lco_box);
+ ao_rect(&fb, SEP_X, 0, 2, HEIGHT, AO_BLACK, AO_COPY);
+ }
+ break;
+ }
+ ao_st7565_update(&fb);
+ ao_mutex_put(&ao_lco_display_mutex);