Skip to content

Commit

Permalink
Startup beep with configuration option to turn the beep on or off.
Browse files Browse the repository at this point in the history
  • Loading branch information
qvasic committed Jun 29, 2024
1 parent 84fdd30 commit 455bf19
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/core/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ int main(int argc, char *argv[]) {
// Head alarm
head_alarm_init();

if (g_setting.power.beep_on_power)
{
beep_dur(BEEP_SHORT);
}

// 10. Execute main loop
g_init_done = 1;
for (;;) {
Expand Down
2 changes: 2 additions & 0 deletions src/core/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const setting_t g_setting_defaults = {
.osd_display_mode = SETTING_POWER_OSD_DISPLAY_MODE_TOTAL,
.power_ana = false,
.calibration_offset = 0,
.beep_on_power = false
},
.record = {
.mode_manual = false,
Expand Down Expand Up @@ -384,6 +385,7 @@ void settings_load(void) {
g_setting.power.osd_display_mode = ini_getl("power", "osd_display_mode", g_setting_defaults.power.osd_display_mode, SETTING_INI);
g_setting.power.power_ana = ini_getl("power", "power_ana_rx", g_setting_defaults.power.power_ana, SETTING_INI);
g_setting.power.calibration_offset = ini_getl("power", "calibration_offset", g_setting_defaults.power.calibration_offset, SETTING_INI);
g_setting.power.beep_on_power = settings_get_bool("power", "beep_on_power", false);

// record
g_setting.record.mode_manual = settings_get_bool("record", "mode_manual", g_setting_defaults.record.mode_manual);
Expand Down
1 change: 1 addition & 0 deletions src/core/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ typedef struct {
setting_power_osd_display_mode_t osd_display_mode;
bool power_ana;
int calibration_offset;
bool beep_on_power;
} setting_power_t;

typedef enum {
Expand Down
11 changes: 11 additions & 0 deletions src/ui/page_power.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ enum {
ROW_CALIBRATION_OFFSET,
ROW_OSD_DISPLAY_MODE,
ROW_WARN_TYPE,
ROW_POWER_BEEP,
ROW_POWER_ANA,
ROW_BACK,

Expand All @@ -40,6 +41,7 @@ static slider_group_t slider_group_cell_count;
static slider_group_t slider_group_calibration_offset;
static btn_group_t btn_group_osd_display_mode;
static btn_group_t btn_group_warn_type;
static btn_group_t btn_group_power_on_beep;
static btn_group_t btn_group_power_ana;

static slider_group_t* selected_slider_group = NULL;
Expand Down Expand Up @@ -122,6 +124,7 @@ static lv_obj_t *page_power_create(lv_obj_t *parent, panel_arr_t *arr) {
create_slider_item(&slider_group_calibration_offset, cont, "Voltage Calibration", 0, g_setting.power.calibration_offset, ROW_CALIBRATION_OFFSET);
create_btn_group_item(&btn_group_osd_display_mode, cont, 2, "Display Mode", "Total", "Cell Avg.", "", "", ROW_OSD_DISPLAY_MODE);
create_btn_group_item(&btn_group_warn_type, cont, 3, "Warning Type", "Beep", "Visual", "Both", "", ROW_WARN_TYPE);
create_btn_group_item(&btn_group_power_on_beep, cont, 2, "Beep on Power", "Off", "On", "", "", ROW_POWER_BEEP);

// Batch 2 goggles only
if (getHwRevision() >= HW_REV_2) {
Expand Down Expand Up @@ -152,6 +155,7 @@ static lv_obj_t *page_power_create(lv_obj_t *parent, panel_arr_t *arr) {
lv_slider_set_value(slider_group_calibration_offset.slider, g_setting.power.calibration_offset, LV_ANIM_OFF);
btn_group_set_sel(&btn_group_osd_display_mode, g_setting.power.osd_display_mode);
btn_group_set_sel(&btn_group_warn_type, g_setting.power.warning_type);
btn_group_set_sel(&btn_group_power_on_beep, g_setting.power.beep_on_power ? 1 : 0);
btn_group_set_sel(&btn_group_power_ana, g_setting.power.power_ana);

page_power_update_cell_count();
Expand Down Expand Up @@ -322,11 +326,18 @@ static void page_power_on_click(uint8_t key, int sel) {
break;

case ROW_WARN_TYPE:
LOGI("Change warn type");
btn_group_toggle_sel(&btn_group_warn_type);
g_setting.power.warning_type = btn_group_get_sel(&btn_group_warn_type);
ini_putl("power", "warning_type", g_setting.power.warning_type, SETTING_INI);
break;

case ROW_POWER_BEEP:
btn_group_toggle_sel(&btn_group_power_on_beep);
g_setting.power.beep_on_power = (btn_group_get_sel(&btn_group_power_on_beep) != 0);
settings_put_bool("power", "beep_on_power", g_setting.power.beep_on_power);
break;

case ROW_POWER_ANA:
// Batch 2 goggles only
if (getHwRevision() >= HW_REV_2) {
Expand Down

0 comments on commit 455bf19

Please sign in to comment.