Skip to content

Commit

Permalink
Flarm alarm display time after alarm went off made configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
iltis42 committed May 16, 2024
1 parent acab3d2 commit 4bb4e1a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions main/SetupMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,10 @@ void SetupMenu::options_menu_create_flarm( MenuEntry *top ){
flarmv->setHelp( "Maximum audio volume of FLARM alarm warning");
top->addEntry( flarmv );

SetupMenuValFloat * flarmt = new SetupMenuValFloat( "Alarm Timeout", "sec", 1, 15, 1, 0, false, &flarm_alarm_time );
flarmt->setHelp( "The time FLARM alarm warning keeps displayed after alarm went off");
top->addEntry( flarmt );

SetupMenuSelect * flarms = new SetupMenuSelect( "FLARM Simulation", RST_NONE, 0, true, &flarm_sim, false, true );
flarms->setHelp( "Simulate an airplane crossing from left to right with different alarm levels and vertical distance 5 seconds after pressed (exits setup!)");
flarms->addEntry( "Disable");
Expand Down
1 change: 1 addition & 0 deletions main/SetupNG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ SetupNG<float> stall_speed( "STALL_SPEED", 70, true, SYNC_FROM_MASTER, PERSIST
SetupNG<int> flarm_warning( "FLARM_LEVEL", 1 );
SetupNG<int> flarm_sim( "FLARM_SIM", 0 );
SetupNG<float> flarm_volume( "FLARM_VOL", 100 );
SetupNG<float> flarm_alarm_time( "FLARM_ALM", 5 );
SetupNG<int> flap_sensor( "FLAP_SENS", 0, RST_NONE, SYNC_FROM_MASTER, PERSISTENT, flap_act);
SetupNG<float> flap_pos_max("FL_POS_M", +2, true, SYNC_FROM_MASTER, PERSISTENT, flap_act);
SetupNG<float> flap_neg_max("FL_NEG_M", -2, true, SYNC_FROM_MASTER, PERSISTENT, flap_act);
Expand Down
2 changes: 2 additions & 0 deletions main/SetupNG.h
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,7 @@ extern SetupNG<int> stall_warning;
extern SetupNG<float> stall_speed;
extern SetupNG<int> flarm_warning;
extern SetupNG<float> flarm_volume;
extern SetupNG<float> flarm_alarm_time;
extern SetupNG<int> flarm_sim;
extern SetupNG<int> flap_sensor;
extern SetupNG<float> flap_pos_max;
Expand Down Expand Up @@ -683,6 +684,7 @@ extern uint8_t g_col_background;
extern uint8_t g_col_highlight;
extern SetupNG<int> logging;


extern float last_volume; // is this used?

void change_ballast();
Expand Down
8 changes: 3 additions & 5 deletions main/sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ float stall_alarm_off_kmh=0;
uint16_t stall_alarm_off_holddown=0;

int count=0;
int flarm_alarm_holdtime=0;
unsigned long int flarm_alarm_holdtime=0;
int the_can_mode = CAN_MODE_MASTER;
int active_screen = 0; // 0 = Vario

Expand Down Expand Up @@ -310,11 +310,11 @@ void drawDisplay(void *pvParameters){
gflags.flarmWarning = true;
delay(100);
display->clear();
flarm_alarm_holdtime = 250;
}
flarm_alarm_holdtime = millis()+flarm_alarm_time.get()*1000;
}
else{
if( gflags.flarmWarning && (flarm_alarm_holdtime == 0) ){
if( gflags.flarmWarning && (millis() > flarm_alarm_holdtime) ){
gflags.flarmWarning = false;
display->clear();
Audio::alarm( false );
Expand Down Expand Up @@ -374,8 +374,6 @@ void drawDisplay(void *pvParameters){
}
}
}
if( flarm_alarm_holdtime )
flarm_alarm_holdtime--;
vTaskDelay(20/portTICK_PERIOD_MS);
if( uxTaskGetStackHighWaterMark( dpid ) < 512 )
ESP_LOGW(FNAME,"Warning drawDisplay stack low: %d bytes", uxTaskGetStackHighWaterMark( dpid ) );
Expand Down

0 comments on commit 4bb4e1a

Please sign in to comment.