doc: clarify how EasyMotor gets put into idle mode master
authorBdale Garbee <bdale@gag.com>
Tue, 25 Jun 2024 18:11:31 +0000 (12:11 -0600)
committerBdale Garbee <bdale@gag.com>
Tue, 25 Jun 2024 18:11:31 +0000 (12:11 -0600)
14 files changed:
altoslib/AltosCalData.java
altoslib/AltosEepromRecordSet.java
altosui/AltosGraphUI.java
doc/motortest-operation.inc
doc/system-operation.inc
doc/telelaunch-acknowledgements.inc
src/drivers/ao_lco.h
src/drivers/ao_lco_bits.c
src/kernel/ao_radio_cmac.c
src/kernel/ao_radio_cmac.h
src/telelco-v3.0/Makefile
src/telelco-v3.0/ao_lco_v3.c
src/telelco-v3.0/ao_pins.h
src/telelco-v3.0/ao_telelco.c

index c90534a924e4159ea62cc0a1db5575e8493a67d0..53e3b8fb6c4bbb271db9c6af215e3e9ddbaca48b 100644 (file)
@@ -202,9 +202,12 @@ public class AltosCalData {
        public void set_tick(int tick) {
                if (tick != AltosLib.MISSING) {
                        if (prev_tick != AltosLib.MISSING) {
-                               while (tick < prev_tick - 1000) {
+                               while (tick < prev_tick - 32767) {
                                        tick += 65536;
                                }
+                               while (tick > prev_tick + 32767) {
+                                       tick -= 65536;
+                               }
                        }
                        if (first_tick == AltosLib.MISSING)
                                first_tick = tick;
index 8f3fa4590e43bcecd060b1d287bf09490a7a23db..f0819a8108d9c5212697524a2290609eac0508e1 100644 (file)
@@ -138,6 +138,8 @@ public class AltosEepromRecordSet implements AltosRecordSet {
                        } else {
                                while (t < tick - 32767)
                                        t += 65536;
+                               while (t > tick + 32767)
+                                       t -= 65536;
                                tick = t;
                        }
                        record.wide_tick = tick;
index 8f52728bf13cfe1ea9d6c5e95a0e104d341e3440..47ba3d4275d0ca3f04a7913e680b7e9aaf2985e9 100644 (file)
@@ -140,7 +140,7 @@ public class AltosGraphUI extends AltosUIFrame implements AltosFontListener, Alt
                if (config_data != null) {
                        configTable = new AltosFlightConfigTable(config_data);
                        pane.add("Configuration", configTable);
-                       if (config_data.npyro > 0) {
+                       if (config_data.npyro > 0 && config_data.npyro != AltosLib.MISSING) {
                                pyroTable = new AltosFlightPyroTable(config_data.pyros, config_data.npyro);
                                pane.add("Pyros", pyroTable);
                        }
index 6371ae04c49301f62ad1d72824e25aadb1032a2f..958a0cad66a668782a09b74b901c24639bc5b193 100644 (file)
@@ -5,12 +5,16 @@
        checklist after the rocket is installed on a launch rail.
 
        The board will beep out a Morse code “P” every few seconds
-       indicating that it's in pad mode and ready to detect launch.
-       Once launch is detected, the board logs pressure and acceleration
-       data 100 times per second throughout the flight.
+       indicating that it's in pad mode and ready to detect the start of
+       the motor burn.  Recording starts when chamber pressure rises by
+       at least 50psi, then the board logs pressure and acceleration
+       data 100 times per second until chamber pressure goes low again and
+       remains stable for at least 10 seconds.
 
-       After flight, AltosUI can be used to download the flight data,
-       view a quick graph of acceleration and pressure with pan and
+       After flight, attach a USB data cable to the board before powering
+       it on so that it goes in to 'idle mode'.  Then AltosUI can be used 
+       to download the flight data, view a quick graph of acceleration and 
+       pressure with pan and
        zoom capabilities, then export it to a comma separated values 
        (CSV) file. Such a file can easily be loaded into a spreadsheet 
-       for analysis.
+       for analysis. 
index 888e3891c6479941bba2276c6719e1cba5d6016a..656ed8e42a756a1bbfab56699a8e026821fe765e 100644 (file)
                have an
                accelerometer we can use to determine orientation, “idle” mode
                is selected if the board is connected via USB to a computer,
-               otherwise the board enters “flight” mode.
+               otherwise the board enters “flight” mode.  This is also how
+               EasyMotor works, since even though it has an accelerometer,
+               it detects the motor burn it is meant to record by detecting\ e\ 1          a rise in chamber pressure, and board orientation doesn't 
+               matter.
                ifdef::telemini[]
                TeleMini
                selects “idle” mode if it receives a command packet
index 4a0f06ab9d35f09b7aba1a2c707acd511d783677..d4bd897a2cba7107ac5181b557a05dc5f6d91294 100644 (file)
@@ -1,7 +1,8 @@
 [dedication]
 == Acknowledgments
 
-       Our profound thanks to Terry Lee for major contributions to making 
+       Our profound thanks to Terry Lee (TRA #10206, NAR #3284) for major
+        contributions to making
        the TeleLaunch system something we could actually package and sell!
 
        Tripoli Colorado, Oregon Rocketry, New River Valley Rocketry, and 
index 176f83837898e48366f28ce19f66e18f2af7880b..47d587bb046f9076564ac57186a374a1bc7cb378 100644 (file)
@@ -47,35 +47,45 @@ extern uint8_t      ao_lco_firing;          /* fire button pressed */
 extern struct ao_pad_query     ao_pad_query;   /* Last received QUERY from pad */
 
 #ifdef AO_LCO_DRAG_RACE_BOX
-#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
+# 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 */
-# ifdef AO_LCO_HAS_INFO
-#  define AO_LCO_INFO          -3
+# ifdef AO_LCO_HAS_CONTRAST
+#  define AO_LCO_CONTRAST      -2
 #  ifndef AO_LCO_BOX_FIRST
-#   define AO_LCO_BOX_FIRST AO_LCO_INFO
+#   define AO_LCO_BOX_FIRST    AO_LCO_CONTRAST
 #  endif
 # endif
-# ifdef AO_LCO_HAS_BACKLIGHT
-#   define AO_LCO_BACKLIGHT    -2
-#   ifndef AO_LCO_BOX_FIRST
-#    define AO_LCO_BOX_FIRST AO_LCO_BACKLIGHT
-#   endif
+# ifdef AO_LCO_HAS_BACKLIGHT_UI
+#  define AO_LCO_BACKLIGHT     -1
+#  ifndef AO_LCO_BOX_FIRST
+#   define AO_LCO_BOX_FIRST    AO_LCO_BACKLIGHT
+#  endif
 # endif
-# ifdef AO_LCO_HAS_CONTRAST
-#  define AO_LCO_CONTRAST      -1
+# if AO_LCO_HAS_LCO_INFO
+#  define AO_LCO_LCO_INFO      0               /* Box number to show LCO info */
 #  ifndef AO_LCO_BOX_FIRST
-#   define AO_LCO_BOX_FIRST    AO_LCO_CONTRAST
+#   define AO_LCO_BOX_FIRST    AO_LCO_LCO_INFO
+#  endif
+# else
+#  define AO_LCO_LCO_VOLTAGE   -1
+#  ifndef AO_LCO_BOX_FIRST
+#   define AO_LCO_BOX_FIRST    AO_LCO_LCO_VOLTAGE
 #  endif
 # endif
 # ifndef AO_LCO_BOX_FIRST
-#  define AO_LCO_BOX_FIRST     AO_LCO_LCO_VOLTAGE
+#  define AO_LCO_BOX_FIRST     1
 # endif
 #endif
-#define AO_LCO_PAD_VOLTAGE     0               /* Pad number to show box voltage */
-#define AO_LCO_PAD_RSSI                -1              /* Pad number to show box RSSI */
-#define AO_LCO_PAD_FIRST       AO_LCO_PAD_RSSI
+
+#ifdef AO_LCO_HAS_PAD_INFO
+# define AO_LCO_PAD_INFO       0               /* Pad number to show box info */
+# define AO_LCO_PAD_FIRST      AO_LCO_PAD_INFO
+#else
+# define AO_LCO_PAD_VOLTAGE    0               /* Pad number to show box voltage */
+# define AO_LCO_PAD_RSSI       -1              /* Pad number to show box RSSI */
+# define AO_LCO_PAD_FIRST      AO_LCO_PAD_RSSI
+#endif
 
 static inline bool
 ao_lco_box_pseudo(int16_t box)
@@ -97,8 +107,8 @@ ao_lco_box_pseudo(int16_t box)
        case AO_LCO_BACKLIGHT:
                return true;
 #endif
-#ifdef AO_LCO_INFO
-       case AO_LCO_INFO:
+#ifdef AO_LCO_LCO_INFO
+       case AO_LCO_LCO_INFO:
                return true;
 #endif
        default:
@@ -110,10 +120,18 @@ static inline bool
 ao_lco_pad_pseudo(int8_t pad)
 {
        switch (pad) {
+#ifdef AO_LCO_PAD_VOLTAGE
        case AO_LCO_PAD_VOLTAGE:
                return true;
+#endif
+#ifdef AO_LCO_PAD_RSSI
        case AO_LCO_PAD_RSSI:
                return true;
+#endif
+#ifdef AO_LCO_PAD_INFO
+       case AO_LCO_PAD_INFO:
+               return true;
+#endif
        default:
                return false;
        }
index 8f51d98392c13c06dd77cae278e7c62df8cd9699..0d922d6e85d340339ca3f5c9da1f1a24b37e2403 100644 (file)
@@ -200,9 +200,9 @@ ao_lco_update(void)
                        if (!ao_lco_pad_pseudo(ao_lco_pad))
                                ao_lco_set_pad(ao_lco_pad_first(ao_lco_box));
                }
-               if (ao_lco_pad_pseudo(ao_lco_pad))
-                       ao_lco_show();
        }
+       if (ao_lco_pad_pseudo(ao_lco_pad))
+               ao_lco_show();
 }
 
 uint8_t        ao_lco_box_mask[AO_LCO_MASK_SIZE(AO_PAD_MAX_BOXES)];
@@ -273,7 +273,7 @@ ao_lco_step_pad(int8_t dir)
                break;
        }
 #endif
-#ifdef AO_LCO_HAS_BACKLIGHT
+#ifdef AO_LCO_HAS_BACKLIGHT_UI
        case AO_LCO_BACKLIGHT: {
                int32_t backlight = ao_lco_get_backlight();
 
@@ -289,8 +289,8 @@ ao_lco_step_pad(int8_t dir)
                break;
        }
 #endif
-#ifdef AO_LCO_HAS_INFO
-       case AO_LCO_INFO: {
+#if AO_LCO_HAS_LCO_INFO
+       case AO_LCO_LCO_INFO: {
 #if AO_LCO_MIN_INFO_PAGE < AO_LCO_MAX_INFO_PAGE
                int32_t info_page = ao_lco_get_info_page();
 
index 5f09344af8915dd273b4ab044ca95fdc5a1df49d..b7aceef6792cc4646eb069917c1f348752c1ead0 100644 (file)
@@ -76,6 +76,8 @@ radio_cmac_send(uint8_t len)
  * Receive and validate an incoming packet
  */
 
+int8_t ao_radio_cmac_last_rssi;
+
 static int8_t
 radio_cmac_recv(uint8_t len, AO_TICK_TYPE timeout) 
 {
@@ -92,6 +94,8 @@ radio_cmac_recv(uint8_t len, AO_TICK_TYPE timeout)
                return AO_RADIO_CMAC_TIMEOUT;
        }
 
+       ao_radio_cmac_last_rssi = ao_radio_rssi;
+
        if (!(cmac_data[len + AO_CMAC_KEY_LEN +1] & AO_RADIO_STATUS_CRC_OK))
                return AO_RADIO_CMAC_CRC_ERROR;
 
index 2977cd3e69960076b5fef9e5eac53891bae586f5..1bea8a03479e71f0a10ce1ae53a9608d30633696 100644 (file)
@@ -24,7 +24,7 @@
 #define AO_CMAC_KEY_LEN                AO_AES_LEN
 #define AO_CMAC_MAX_LEN                (128 - AO_CMAC_KEY_LEN)
 
-extern int8_t ao_radio_cmac_rssi;
+extern int8_t ao_radio_cmac_rssi, ao_radio_cmac_last_rssi;
 
 int8_t
 ao_radio_cmac_send(void *packet, uint8_t len);
index 2531374b620ca1f1dd0cd7b60f460870f52b5fd1..fae076adfe5ccffc3ed1d0b2e50e2f2acb419df4 100644 (file)
@@ -48,7 +48,8 @@ ALTOS_SRC = \
        ao_timer.c \
        ao_mutex.c \
        ao_freq.c \
-       ao_adc_single_stm.c \
+       ao_adc_stm.c \
+       ao_data.c \
        ao_dma_stm.c \
        ao_spi_stm.c \
        ao_beep_stm.c \
index 96aa81591f918f1cf35adf66e296f74a5ae4834f..2f4c1dbed26830dd27ab9a4a67c09092fd01db6c 100644 (file)
@@ -24,6 +24,7 @@
 #include <ao_st7565.h>
 #include <ao_adc_single.h>
 #include <ao_pwm.h>
+#include <limits.h>
 
 #define WIDTH  AO_ST7565_WIDTH
 #define HEIGHT AO_ST7565_HEIGHT
@@ -89,8 +90,9 @@ static const struct ao_transform show_transform = {
 #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 INFO_FONT      TINY_FONT
+#define INFO_START_Y   ((int16_t) (INFO_FONT.ascent + 2))
+#define INFO_STEP_Y    ((int16_t) (INFO_FONT.ascent + 2))
 
 #define AO_LCO_DRAG_RACE_START_TIME    AO_SEC_TO_TICKS(5)
 #define AO_LCO_DRAG_RACE_STOP_TIME     AO_SEC_TO_TICKS(2)
@@ -105,6 +107,9 @@ static uint8_t      ao_lco_event_debug;
 
 static uint8_t ao_lco_display_mutex;
 
+static uint8_t         ao_sample_data;
+static struct ao_data  ao_data_cur;
+
 static void
 _ao_center_text(int16_t x, int16_t y, const struct ao_font *font, const char *str)
 {
@@ -133,28 +138,12 @@ _ao_lco_show_box(int16_t box)
 }
 
 static void
-_ao_lco_show_voltage(uint16_t decivolts, const char *label)
+_ao_format_voltage(char *str, size_t size, uint16_t decivolts)
 {
-       char    str[7];
-
-       PRINTD("voltage %d\n", decivolts);
-       _ao_center_text(WIDTH/2, LABEL_Y, &SMALL_FONT, label);
-       snprintf(str, sizeof(str), "%d.%d", decivolts / 10, decivolts % 10);
-       _ao_center_text(WIDTH/2, VALUE_Y, &BIG_FONT, str);
-}
-
-static void
-_ao_lco_batt_voltage(void)
-{
-       struct ao_adc   packet;
-       int16_t         decivolt;
-
-       ao_adc_single_get(&packet);
-       decivolt = ao_battery_decivolt(packet.v_batt);
-       _ao_lco_show_voltage((uint16_t) decivolt, "LCO Battery");
-       ao_st7565_update(&fb);
+       snprintf(str, size, "%d.%d", decivolts / 10, decivolts % 10);
 }
 
+#if AO_LCO_HAS_CONTRAST
 static void
 _ao_lco_show_contrast(void)
 {
@@ -167,7 +156,9 @@ _ao_lco_show_contrast(void)
        snprintf(buf, sizeof(buf), "%d %%", brightness * 100 / AO_LCO_MAX_CONTRAST);
        _ao_center_text(WIDTH/2, CONTRAST_VALUE_Y, &SMALL_FONT, buf);
 }
+#endif
 
+#if AO_LCO_HAS_BACKLIGHT_UI
 static void
 _ao_lco_show_backlight(void)
 {
@@ -180,6 +171,7 @@ _ao_lco_show_backlight(void)
        snprintf(buf, sizeof(buf), "%ld %%", backlight * 100 / AO_LCO_MAX_BACKLIGHT);
        _ao_center_text(WIDTH/2, BACKLIGHT_VALUE_Y, &SMALL_FONT, buf);
 }
+#endif
 
 static int16_t info_y;
 
@@ -191,17 +183,25 @@ _ao_lco_info(const char *format, ...)
        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);
+       ao_text(&fb, &INFO_FONT, 0, info_y, buf, AO_BLACK, AO_COPY);
        info_y += INFO_STEP_Y;
 }
 
 static void
-_ao_lco_show_info(void)
+_ao_lco_show_lco_info(void)
 {
-       info_y = INFO_START_Y;
+       char            battery[7];
+       int16_t         decivolt;
+
        ao_logo_poly(&fb, &show_transform, AO_BLACK, AO_COPY);
+
+       decivolt = ao_battery_decivolt(ao_data_cur.adc.v_batt);
+       _ao_format_voltage(battery, sizeof(battery), (uint16_t) decivolt);
+
+       info_y = INFO_START_Y;
        _ao_lco_info("%s", ao_product);
        _ao_lco_info("Serial: %d", ao_serial_number);
+       _ao_lco_info("Battery: %sV", battery);
        _ao_lco_info("Version: %s", ao_version);
        _ao_lco_info("Callsign: %s", ao_config.callsign);
        _ao_lco_info("Frequency: %ld.%03d",
@@ -209,28 +209,115 @@ _ao_lco_show_info(void)
                     (int) (ao_config.frequency % 1000));
 }
 
+static uint8_t
+popcount(uint32_t value)
+{
+       uint8_t count = 0;
+       while(value != 0) {
+               count += value & 1;
+               value >>= 1;
+       }
+       return count;
+}
+
+static void
+_ao_lco_show_pad_info(void)
+{
+       char    pad_battery[7];
+
+       ao_logo_poly(&fb, &show_transform, AO_BLACK, AO_COPY);
+       info_y = INFO_START_Y;
+       _ao_lco_info("Bank: %d", ao_lco_box);
+       if (!(ao_lco_valid[ao_lco_box] & AO_LCO_VALID_LAST)) {
+               _ao_lco_info("Contact lost");
+               _ao_lco_info("Last RSSI: %ddBm", ao_radio_cmac_last_rssi);
+       } else {
+               _ao_lco_info("Total pads: %d", popcount(ao_pad_query.channels));
+               _ao_lco_info("RSSI: %ddBm", ao_radio_cmac_rssi);
+               _ao_format_voltage(pad_battery, sizeof(pad_battery), ao_pad_query.battery);
+               _ao_lco_info("Battery: %sV", pad_battery);
+               _ao_lco_info("Arming switch: %s", ao_pad_query.arm_status ? "On" : "Off");
+       }
+}
+
+#define AO_LCO_DIM_BACKLIGHT   (AO_LCO_MIN_BACKLIGHT + 3 * AO_LCO_BACKLIGHT_STEP)
+#define AO_AUTO_BACKLIGHT_RANGE        (AO_LCO_MAX_BACKLIGHT - AO_LCO_DIM_BACKLIGHT)
+#define AO_AUTO_BACKLIGHT_GAP  AO_ADC_MAX / 6
+
+static struct {
+       int16_t v_als;
+       int32_t backlight;
+} ao_lco_backlight_map[] = {
+       { .v_als = AO_ADC_MAX / 6, .backlight = AO_LCO_DIM_BACKLIGHT },
+       { .v_als = AO_ADC_MAX / 3, .backlight = (AO_LCO_MAX_BACKLIGHT - AO_LCO_MIN_BACKLIGHT) / 2 },
+       { .v_als = AO_ADC_MAX / 2, .backlight = AO_LCO_MAX_BACKLIGHT },
+       { .v_als = AO_ADC_MAX * 3 / 4,  .backlight = 0 },
+};
+
+#define NUM_BACKLIGHT_MAP sizeof(ao_lco_backlight_map)/sizeof(ao_lco_backlight_map[0])
+
+static unsigned ao_backlight_prev = NUM_BACKLIGHT_MAP - 1;
+
 static void
-_ao_lco_show_rssi(void)
+ao_auto_backlight(int16_t als_min, int16_t als_max)
 {
-       char label[20];
-       int16_t width;
-       snprintf(label, sizeof(label), "Bank %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);
+       unsigned ao_backlight;
+
+       PRINTD("ao_auto_backlight min %d max %d\n", als_min, als_max);
+       ao_backlight = ao_backlight_prev;
+       while (als_min > ao_lco_backlight_map[ao_backlight].v_als + AO_AUTO_BACKLIGHT_GAP) {
+               if (ao_backlight == NUM_BACKLIGHT_MAP - 1)
+                       break;
+               ao_backlight++;
+       }
+       while (als_max < ao_lco_backlight_map[ao_backlight].v_als - AO_AUTO_BACKLIGHT_GAP) {
+               if (ao_backlight == 0)
+                       return;
+               ao_backlight--;
+       }
+       if (ao_backlight != ao_backlight_prev)
+       {
+               PRINTD("   set backlight to %ld\n", ao_lco_backlight_map[ao_backlight].backlight);
+               ao_lco_set_backlight(ao_lco_backlight_map[ao_backlight].backlight);
+               ao_backlight_prev = ao_backlight;
+       }
 }
 
+#define AO_LCO_BACKLIGHT_INTERVAL      AO_SEC_TO_TICKS(2)
+
 static void
-_ao_lco_show_pad_battery(void)
+ao_lco_data(void)
 {
-       char label[20];
-       snprintf(label, sizeof(label), "Bank %d Battery", ao_lco_box);
-       _ao_lco_show_voltage(ao_pad_query.battery, label);
+       AO_TICK_TYPE    backlight_tick = ao_time() + AO_LCO_BACKLIGHT_INTERVAL;
+       AO_TICK_TYPE    now;
+       int16_t         als_min = INT16_MAX;
+       int16_t         als_max = INT16_MIN;
+
+       ao_timer_set_adc_interval(AO_MS_TO_TICKS(100));
+       for (;;) {
+               ao_sleep((void *) &ao_data_head);
+
+               while (ao_sample_data != ao_data_head) {
+                       struct ao_data *ao_data;
+
+                       /* Capture a sample */
+                       ao_data = (struct ao_data *) &ao_data_ring[ao_sample_data];
+
+                       ao_data_cur = *ao_data;
+                       if (ao_data_cur.adc.v_als < als_min)
+                               als_min = ao_data_cur.adc.v_als;
+                       if (ao_data_cur.adc.v_als > als_max)
+                               als_max = ao_data_cur.adc.v_als;
+                       ao_sample_data = ao_data_ring_next(ao_sample_data);
+               }
+               now = ao_time();
+               if ((AO_TICK_SIGNED) (backlight_tick - now) < 0) {
+                       backlight_tick = now + AO_LCO_BACKLIGHT_INTERVAL;
+                       ao_auto_backlight(als_min, als_max);
+                       als_min = INT16_MAX;
+                       als_max = INT16_MIN;
+               }
+       }
 }
 
 void
@@ -239,25 +326,23 @@ 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;
+#if AO_LCO_HAS_CONTRAST
        case AO_LCO_CONTRAST:
                _ao_lco_show_contrast();
                break;
+#endif
+#if AO_LCO_HAS_BACKLIGHT_UI
        case AO_LCO_BACKLIGHT:
                _ao_lco_show_backlight();
                break;
-       case AO_LCO_INFO:
-               _ao_lco_show_info();
+#endif
+       case AO_LCO_LCO_INFO:
+               _ao_lco_show_lco_info();
                break;
        default:
                switch (ao_lco_pad) {
-               case AO_LCO_PAD_RSSI:
-                       _ao_lco_show_rssi();
-                       break;
-               case AO_LCO_PAD_VOLTAGE:
-                       _ao_lco_show_pad_battery();
+               case AO_LCO_PAD_INFO:
+                       _ao_lco_show_pad_info();
                        break;
                default:
                        _ao_lco_show_pad(ao_lco_pad);
@@ -293,6 +378,7 @@ ao_lco_set_select(void)
 }
 
 
+#if AO_LCO_HAS_CONTRAST
 void
 ao_lco_set_contrast(int32_t contrast)
 {
@@ -304,7 +390,9 @@ ao_lco_get_contrast(void)
 {
        return (int32_t) ao_st7565_get_brightness();
 }
+#endif
 
+#if AO_LCO_HAS_BACKLIGHT
 static uint16_t ao_backlight;
 
 void
@@ -319,6 +407,7 @@ ao_lco_get_backlight(void)
 {
        return (int32_t) ao_backlight;
 }
+#endif
 
 static struct ao_task  ao_lco_drag_task;
 
@@ -421,6 +510,7 @@ ao_lco_display_test(void)
 
 static struct ao_task ao_lco_input_task;
 static struct ao_task ao_lco_monitor_task;
+static struct ao_task ao_lco_data_task;
 static struct ao_task ao_lco_arm_warn_task;
 static struct ao_task ao_lco_igniter_status_task;
 
@@ -518,6 +608,7 @@ void
 ao_lco_init(void)
 {
        ao_add_task(&ao_lco_monitor_task, ao_lco_main, "lco monitor");
+       ao_add_task(&ao_lco_data_task, ao_lco_data, "lco data");
 #if DEBUG
        ao_cmd_register(&ao_lco_cmds[0]);
 #endif
index e286cae6eceacc97c1ad571441faeb64ae0637af..b1af364fca3b9ee219fc23110e38b9be007b7718 100644 (file)
 #define AO_BUTTON_0            1
 
 #define AO_BUTTON_DRAG_SELECT  1
-#define AO_BUTTON_1_PORT       &stm_gpioc
-#define AO_BUTTON_1            0
+#define AO_BUTTON_1_PORT       &stm_gpiod
+#define AO_BUTTON_1            2
 
 #define AO_BUTTON_SPARE1               2
 #define AO_BUTTON_2_PORT       &stm_gpiob
 
 /* ADC */
 
-struct ao_adc {
-       int16_t         v_batt;
-};
-
-#define AO_ADC_DUMP(p) \
-       printf("batt: %5d\n", (p)->v_batt)
+#define AO_DATA_RING           8
 
-#define HAS_ADC_SINGLE         1
+#define HAS_ADC                        1
 #define HAS_ADC_TEMP           0
 #define HAS_BATTERY_REPORT     1
 
@@ -277,12 +272,33 @@ struct ao_adc {
 #define AO_ADC_V_BATT_PORT     (&stm_gpioa)
 #define AO_ADC_V_BATT_PIN      2
 
+#define AO_ADC_V_ALS           10
+#define AO_ADC_V_ALS_PORT      (&stm_gpioc)
+#define AO_ADC_V_ALS_PIN       0
+
 #define AO_ADC_PIN0_PORT       AO_ADC_V_BATT_PORT
 #define AO_ADC_PIN0_PIN                AO_ADC_V_BATT_PIN
 
+#define AO_ADC_PIN1_PORT       AO_ADC_V_ALS_PORT
+#define AO_ADC_PIN1_PIN                AO_ADC_V_ALS_PIN
+
 #define AO_ADC_SQ1             AO_ADC_V_BATT
+#define AO_ADC_SQ2             AO_ADC_V_ALS
 
-#define AO_NUM_ADC             1
+#define AO_NUM_ADC             2
+
+struct ao_adc {
+       union {
+               struct {
+                       int16_t         v_batt;
+                       int16_t         v_als;
+               };
+               int16_t v_vals[AO_NUM_ADC];
+       };
+};
+
+#define AO_ADC_DUMP(p) \
+       printf("batt: %5d als %5d\n", (p)->adc.v_batt, (p)->adc.v_als)
 
 /*
  * Voltage divider on ADC battery sampler
@@ -296,20 +312,23 @@ struct ao_adc {
 #define AO_ADC_REFERENCE_DV    33
 
 #define AO_LCO_SEARCH_API
-#define AO_LCO_HAS_CONTRAST    1
-#define AO_LCO_MIN_CONTRAST    0
-#define AO_LCO_MAX_CONTRAST    63
-#define AO_LCO_CONTRAST_STEP   1
+
+//#define AO_LCO_HAS_CONTRAST  1
+//#define AO_LCO_MIN_CONTRAST  0
+//#define AO_LCO_MAX_CONTRAST  63
+//#define AO_LCO_CONTRAST_STEP 1
 
 #define AO_LCO_HAS_BACKLIGHT   1
 #define AO_LCO_MIN_BACKLIGHT   0
 #define AO_LCO_MAX_BACKLIGHT   65535
 #define AO_LCO_BACKLIGHT_STEP  771
 
-#define AO_LCO_HAS_INFO                1
+#define AO_LCO_HAS_LCO_INFO    1
 #define AO_LCO_MIN_INFO_PAGE   0
 #define AO_LCO_MAX_INFO_PAGE   0
 
+#define AO_LCO_HAS_PAD_INFO    1
+
 /*
  * LCD Backlight via PWM.
  *
index a8d740a9243db32ab8423c97874eb7c921f9b108..6293edd3878bdcc1bd807c8642f63b6bd96d7dd2 100644 (file)
@@ -44,7 +44,7 @@ main(void)
        ao_spi_init();
        ao_dma_init();
        ao_exti_init();
-       ao_adc_single_init();
+       ao_adc_init();
 
        ao_beep_init();
        ao_pwm_init();