+#ifdef AO_SEGMENT_MAP
+#if AO_LCD_PER_DIGIT
+static const struct ao_lcd_map {
+ uint8_t com, seg;
+} ao_lcd_map[AO_LCD_DIGITS * AO_LCD_SEGMENTS] = AO_SEGMENT_MAP;
+#else
+static const uint8_t ao_lcd_map[] = AO_SEGMENT_MAP;
+#endif
+#endif
+
+void
+ao_lcd_set(uint8_t digit, uint8_t segment, uint8_t value)
+{
+ uint8_t n;
+ uint8_t com, seg;
+
+#ifdef AO_SEGMENT_MAP
+#if AO_LCD_PER_DIGIT
+ n = digit * AO_LCD_SEGMENTS + segment;
+ com = ao_lcd_map[n].com;
+ seg = ao_lcd_map[n].seg;
+#else
+ com = digit;
+ seg = ao_lcd_map[segment];
+#endif
+#else
+ com = digit;
+ seg = segment;
+#endif
+ if (com >= NCOM)
+ com = NCOM-1;
+ if (seg >= NSEG)
+ seg = NSEG-1;
+
+#if LCD_DEBUG
+ printf ("digit %d segment %d -> com %d seg %d\n", digit, segment, com, seg);
+#endif
+ n = (seg >> 5) & 1;
+ if (value)
+ stm_lcd.ram[com * 2 + n] |= (1 << (seg & 0x1f));
+ else
+ stm_lcd.ram[com * 2 + n] &= ~(1 << (seg & 0x1f));
+}
+
+#if LCD_DEBUG