.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
#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 BOX_LABEL_X 26
+#define VALUE_LABEL_X 64
#define RSSI_LABEL_X 15
#define PAD_LABEL_X 95
#define SEP_X (PAD_X - 8)
#define CONTRAST_X (WIDTH - CONTRAST_WIDTH) / 2
#define CONTRAST_Y 20
#define CONTRAST_HEIGHT 20
-
+#define CONTRAST_VALUE_X 64
+#define CONTRAST_VALUE_Y (CONTRAST_Y + CONTRAST_HEIGHT + SMALL_FONT.ascent + 3)
#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 BACKLIGHT_VALUE_X 64
+#define BACKLIGHT_VALUE_Y (BACKLIGHT_Y + BACKLIGHT_HEIGHT + SMALL_FONT.ascent + 3)
+#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)
static uint8_t ao_lco_display_mutex;
static void
-_ao_lco_show_pad(uint8_t pad)
+_ao_lco_show_pad(int8_t pad)
{
char str[5];
_ao_lco_show_voltage(uint16_t decivolts, const char *label)
{
char str[7];
+ int16_t width;
PRINTD("voltage %d\n", decivolts);
snprintf(str, sizeof(str), "%2d.%d", decivolts / 10, decivolts % 10);
ao_text(&fb, &VOLT_FONT, BOX_X, VALUE_Y, str, AO_BLACK, AO_COPY);
- ao_text(&fb, &SMALL_FONT, VOLT_LABEL_X, LABEL_Y, label, AO_BLACK, AO_COPY);
+ width = ao_text_width(&SMALL_FONT, label);
+ ao_text(&fb, &SMALL_FONT, VALUE_LABEL_X - width/2, LABEL_Y, label, AO_BLACK, AO_COPY);
}
static void
ao_adc_single_get(&packet);
decivolt = ao_battery_decivolt(packet.v_batt);
- _ao_lco_show_voltage((uint16_t) decivolt, "LCO battery");
+ _ao_lco_show_voltage((uint16_t) decivolt, "LCO Battery");
ao_st7565_update(&fb);
}
static void
_ao_lco_show_contrast(void)
{
+ 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));
+}
+
+static void
+_ao_lco_show_rssi(void)
+{
+ char label[20];
+ int16_t width;
+ snprintf(label, sizeof(label), "Box %d RSSI", ao_lco_box);
+ width = ao_text_width(&SMALL_FONT, label);
+ ao_text(&fb, &SMALL_FONT, VALUE_LABEL_X - width / 2, LABEL_Y, label, AO_BLACK, AO_COPY);
+ if (!(ao_lco_valid[ao_lco_box] & AO_LCO_VALID_LAST))
+ strcpy(label, "---");
+ else
+ snprintf(label, sizeof(label), "%d", ao_radio_cmac_rssi);
+ width = ao_text_width(&VOLT_FONT, label);
+ ao_text(&fb, &VOLT_FONT, VALUE_LABEL_X - width / 2, VALUE_Y, label, AO_BLACK, AO_COPY);
+}
+
+static void
+_ao_lco_show_pad_battery(void)
+{
+ char label[20];
+ snprintf(label, sizeof(label), "Box %d Battery", ao_lco_box);
+ _ao_lco_show_voltage(ao_pad_query.battery, label);
}
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");
- } else {
+ switch (ao_lco_pad) {
+ case AO_LCO_PAD_RSSI:
+ _ao_lco_show_rssi();
+ break;
+ case AO_LCO_PAD_VOLTAGE:
+ _ao_lco_show_pad_battery();
+ break;
+ default:
_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);