mirror of
https://github.com/RfidResearchGroup/ChameleonUltra.git
synced 2026-05-12 11:22:59 -07:00
Added button action to show battery level
This commit is contained in:
@@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
|
||||
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
|
||||
|
||||
## [unreleased][unreleased]
|
||||
- Added button action to show battery level (@doegox)
|
||||
- Added GUI Page docs (@GameTec-live)
|
||||
- Changed CLI threads polling into blocking reads, to reduce CPU usage (@doegox)
|
||||
- Added support for timestamped comments in CLI via `rem`, `;`, `%` or `#` (@doegox)
|
||||
|
||||
@@ -532,6 +532,35 @@ static void cycle_slot(bool dec) {
|
||||
set_slot_light_color(color_new);
|
||||
}
|
||||
|
||||
static void show_battery(void) {
|
||||
uint32_t *led_pins = hw_get_led_array();
|
||||
// if still in the first 4s after boot, blink red while waiting for battery info
|
||||
while (percentage_batt_lvl == 0) {
|
||||
for (int i = 0; i < RGB_LIST_NUM; i++) {
|
||||
nrf_gpio_pin_clear(led_pins[i]);
|
||||
}
|
||||
bsp_delay_ms(100);
|
||||
set_slot_light_color(RGB_RED);
|
||||
for (int i = 0; i < RGB_LIST_NUM; i++) {
|
||||
nrf_gpio_pin_set(led_pins[i]);
|
||||
}
|
||||
bsp_delay_ms(100);
|
||||
}
|
||||
// ok we have data, show level with cyan LEDs
|
||||
for (int i = 0; i < RGB_LIST_NUM; i++) {
|
||||
nrf_gpio_pin_clear(led_pins[i]);
|
||||
}
|
||||
set_slot_light_color(RGB_CYAN);
|
||||
uint8_t nleds = (percentage_batt_lvl * 2) / 25; // 0->7 (8 for 100% but this is ignored)
|
||||
for (int i = 0; i < RGB_LIST_NUM; i++) {
|
||||
if (i <= nleds) {
|
||||
nrf_gpio_pin_set(led_pins[i]);
|
||||
bsp_delay_ms(50);
|
||||
}
|
||||
}
|
||||
// nothing special to finish, we wait for sleep or slot change
|
||||
}
|
||||
|
||||
#if defined(PROJECT_CHAMELEON_ULTRA)
|
||||
|
||||
static void offline_status_blink_color(uint8_t blink_color) {
|
||||
@@ -689,6 +718,9 @@ static void run_button_function_by_settings(settings_button_function_t sbf) {
|
||||
break;
|
||||
#endif
|
||||
|
||||
case SettingsButtonShowBattery:
|
||||
show_battery();
|
||||
|
||||
default:
|
||||
NRF_LOG_ERROR("Unsupported button function")
|
||||
break;
|
||||
|
||||
@@ -25,6 +25,7 @@ typedef enum {
|
||||
SettingsButtonCycleSlotDec = 2U,
|
||||
// Read the UID card number immediately after pressing, continue searching, and simulate immediately after reading the card
|
||||
SettingsButtonCloneIcUid = 3U,
|
||||
SettingsButtonShowBattery = 4U,
|
||||
} settings_button_function_t;
|
||||
|
||||
typedef struct ALIGN_U32 {
|
||||
|
||||
@@ -377,6 +377,7 @@ class ButtonPressFunction(enum.IntEnum):
|
||||
SettingsButtonCycleSlot = 1
|
||||
SettingsButtonCycleSlotDec = 2
|
||||
SettingsButtonCloneIcUid = 3
|
||||
SettingsButtonShowBattery = 4
|
||||
|
||||
@staticmethod
|
||||
def list():
|
||||
@@ -391,6 +392,8 @@ class ButtonPressFunction(enum.IntEnum):
|
||||
return "Cycle Slot Dec"
|
||||
elif self == ButtonPressFunction.SettingsButtonCloneIcUid:
|
||||
return "Quickly Copy Ic Uid"
|
||||
elif self == ButtonPressFunction.SettingsButtonShowBattery:
|
||||
return "Show Battery Level"
|
||||
return "None"
|
||||
|
||||
@staticmethod
|
||||
@@ -408,6 +411,8 @@ class ButtonPressFunction(enum.IntEnum):
|
||||
elif self == ButtonPressFunction.SettingsButtonCloneIcUid:
|
||||
return ("Read the UID card number immediately after pressing, continue searching," +
|
||||
"and simulate immediately after reading the card")
|
||||
elif self == ButtonPressFunction.SettingsButtonShowBattery:
|
||||
return ("Lights up slot LEDs according to battery level")
|
||||
return "Unknown"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user