updates
This commit is contained in:
+56
@@ -69,6 +69,8 @@
|
|||||||
#define MY_RIC 1234567UL
|
#define MY_RIC 1234567UL
|
||||||
#define OLED_IDLE_OFF_MS 60000U
|
#define OLED_IDLE_OFF_MS 60000U
|
||||||
#define OWN_PAGE_ALERT_MS 3000U
|
#define OWN_PAGE_ALERT_MS 3000U
|
||||||
|
#define RX_DISPLAY_FLASHES 4U
|
||||||
|
#define RX_DISPLAY_FLASH_MS 120U
|
||||||
|
|
||||||
/* Enable after wiring BAT+ through a divider to GPIO2 and BAT- to GND. */
|
/* Enable after wiring BAT+ through a divider to GPIO2 and BAT- to GND. */
|
||||||
#define BATTERY_MONITOR_ENABLE 0
|
#define BATTERY_MONITOR_ENABLE 0
|
||||||
@@ -98,6 +100,11 @@ static unsigned display_baud;
|
|||||||
static uint32_t radio_frequency_hz = RF_FREQ_HZ;
|
static uint32_t radio_frequency_hz = RF_FREQ_HZ;
|
||||||
static bool oled_is_on = true;
|
static bool oled_is_on = true;
|
||||||
static TickType_t ui_last_activity;
|
static TickType_t ui_last_activity;
|
||||||
|
static bool oled_inverted;
|
||||||
|
static unsigned rx_flash_toggles;
|
||||||
|
static TickType_t rx_flash_next_toggle;
|
||||||
|
static bool hold_cue_visible;
|
||||||
|
static uint8_t hold_cue_button;
|
||||||
|
|
||||||
#if BATTERY_MONITOR_ENABLE
|
#if BATTERY_MONITOR_ENABLE
|
||||||
static bool battery_voltage_valid;
|
static bool battery_voltage_valid;
|
||||||
@@ -372,6 +379,14 @@ static void oled_power_off(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void oled_set_inverted(bool inverted)
|
||||||
|
{
|
||||||
|
if (oled_inverted == inverted)
|
||||||
|
return;
|
||||||
|
oled_cmd(inverted ? 0xA7 : 0xA6);
|
||||||
|
oled_inverted = inverted;
|
||||||
|
}
|
||||||
|
|
||||||
static void oled_data(const uint8_t *data, size_t len)
|
static void oled_data(const uint8_t *data, size_t len)
|
||||||
{
|
{
|
||||||
gpio_set_level(PIN_OLED_DC, 1);
|
gpio_set_level(PIN_OLED_DC, 1);
|
||||||
@@ -892,6 +907,12 @@ static void ui_render(void)
|
|||||||
ui_draw_tune();
|
ui_draw_tune();
|
||||||
else
|
else
|
||||||
ui_draw_live();
|
ui_draw_live();
|
||||||
|
if (hold_cue_visible) {
|
||||||
|
memset(&fb[7U * 128U], 0, 128U);
|
||||||
|
oled_text(0, 56, hold_cue_button == BUTTON_BOOT
|
||||||
|
? "RELEASE TO CONTINUE"
|
||||||
|
: "RELEASE TO SELECT");
|
||||||
|
}
|
||||||
oled_flush();
|
oled_flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1052,8 +1073,20 @@ static void ui_poll_button(void)
|
|||||||
button->pressed_at = now;
|
button->pressed_at = now;
|
||||||
} else if (level != 0 && button->down) {
|
} else if (level != 0 && button->down) {
|
||||||
button->down = false;
|
button->down = false;
|
||||||
|
if (hold_cue_visible && hold_cue_button == i) {
|
||||||
|
hold_cue_visible = false;
|
||||||
|
ui_render();
|
||||||
|
}
|
||||||
bool long_press = now - button->pressed_at >= pdMS_TO_TICKS(700);
|
bool long_press = now - button->pressed_at >= pdMS_TO_TICKS(700);
|
||||||
ui_handle_button((ui_button_id_t)i, long_press);
|
ui_handle_button((ui_button_id_t)i, long_press);
|
||||||
|
} else if (level == 0 && button->down &&
|
||||||
|
(i == BUTTON_BOOT || i == BUTTON_SELECT) &&
|
||||||
|
!hold_cue_visible &&
|
||||||
|
now - button->pressed_at >= pdMS_TO_TICKS(700)) {
|
||||||
|
hold_cue_visible = true;
|
||||||
|
hold_cue_button = (uint8_t)i;
|
||||||
|
ui_note_activity();
|
||||||
|
ui_render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1073,6 +1106,27 @@ static void ui_start_own_page_alert(void)
|
|||||||
alert_led_on = false;
|
alert_led_on = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ui_start_display_flash(void)
|
||||||
|
{
|
||||||
|
if (!oled_is_on)
|
||||||
|
oled_power_on();
|
||||||
|
oled_set_inverted(true);
|
||||||
|
rx_flash_toggles = RX_DISPLAY_FLASHES;
|
||||||
|
rx_flash_next_toggle = xTaskGetTickCount() +
|
||||||
|
pdMS_TO_TICKS(RX_DISPLAY_FLASH_MS);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ui_update_display_flash(void)
|
||||||
|
{
|
||||||
|
TickType_t now = xTaskGetTickCount();
|
||||||
|
if (!rx_flash_toggles || (int32_t)(now - rx_flash_next_toggle) < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
oled_set_inverted(!oled_inverted);
|
||||||
|
rx_flash_toggles--;
|
||||||
|
rx_flash_next_toggle = now + pdMS_TO_TICKS(RX_DISPLAY_FLASH_MS);
|
||||||
|
}
|
||||||
|
|
||||||
static void ui_update_alert(void)
|
static void ui_update_alert(void)
|
||||||
{
|
{
|
||||||
TickType_t now = xTaskGetTickCount();
|
TickType_t now = xTaskGetTickCount();
|
||||||
@@ -1343,6 +1397,7 @@ static void decode_codeword(uint32_t raw, unsigned slot)
|
|||||||
if (live_page) {
|
if (live_page) {
|
||||||
ui_screen = UI_LIVE;
|
ui_screen = UI_LIVE;
|
||||||
ui_note_activity();
|
ui_note_activity();
|
||||||
|
ui_start_display_flash();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (monitor_mode || current_ric == MY_RIC) {
|
if (monitor_mode || current_ric == MY_RIC) {
|
||||||
@@ -1573,6 +1628,7 @@ void app_main(void)
|
|||||||
|
|
||||||
ui_poll_button();
|
ui_poll_button();
|
||||||
ui_update_alert();
|
ui_update_alert();
|
||||||
|
ui_update_display_flash();
|
||||||
ui_idle_power_down();
|
ui_idle_power_down();
|
||||||
|
|
||||||
if (xTaskGetTickCount() - last_battery_read >= pdMS_TO_TICKS(5000)) {
|
if (xTaskGetTickCount() - last_battery_read >= pdMS_TO_TICKS(5000)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user