void gui_set_audio_vol_cb(float val) { gui_switch_task(GUI_SET_AUDIO); eeprom_busy_wait(); uint8_t tmp = val; eeprom_update_byte(&config.audio_profile.volume, tmp); fc.audio_volume = tmp; }
void gui_set_display_contrast_cb(float val) { gui_switch_task(GUI_SET_DISPLAY); eeprom_busy_wait(); lcd_contrast = val; eeprom_update_byte(&config.gui.contrast, lcd_contrast); gui_change_disp_cfg(); }
void gui_set_display_brightness_cb(float val) { gui_switch_task(GUI_SET_DISPLAY); eeprom_busy_wait(); lcd_brightness = val; eeprom_update_byte(&config.gui.brightness, lcd_brightness); gui_trigger_backlight(); }
void gui_set_debug_reset_fc(uint8_t ret) { if (ret == GUI_DIALOG_YES) { cfg_reset_factory_test(); } else gui_switch_task(GUI_SET_DEBUG); }
void gui_set_debug_delete_fc(uint8_t ret) { if (ret == GUI_DIALOG_YES) { assert(f_unlink(DEBUG_FILE) == FR_OK); } gui_switch_task(GUI_SET_DEBUG); }
void gui_set_autostart_timeout_cb(float val) { uint8_t tmp = val; eeprom_busy_wait(); eeprom_update_byte(&config_ee.autostart.timeout, tmp); config.autostart.timeout = tmp; gui_switch_task(GUI_SET_AUTOSTART); }
void gui_set_weaklift_val_cb(float val) { uint16_t tmp = val * 10; config.vario.weak_lift = tmp; eeprom_busy_wait(); eeprom_update_byte(&config_ee.vario.weak_lift, config.vario.weak_lift); gui_switch_task(GUI_SET_WEEKLIFT); }
void gui_set_autostart_land_threshold_cb(float val) { uint8_t tmp = val; eeprom_busy_wait(); eeprom_update_byte(&config_ee.autostart.land_sensititvity, tmp); config.autostart.land_sensititvity = tmp; gui_switch_task(GUI_SET_AUTOSTART); }
void gui_set_audio_action(uint8_t index) { switch(index) { case(0): gui_value_conf_P(PSTR("General volume"), GUI_VAL_VOLUME, PSTR("%0.0f %%"), fc.audio_volume, 0, 100, 5, gui_set_audio_vol_cb); gui_switch_task(GUI_SET_VAL); break; } }
void gui_list_action() { if (gui_list_index[gui_task] == gui_list_size - 1) { gui_list_set_index(gui_task, 0); gui_switch_task(gui_list_back); } else gui_list_act_f(gui_list_index[gui_task]); }
void gui_set_logger_glider_id_cb(uint8_t ret, char * buff) { if (ret == GUI_TEXT_OK) { strcpy((char *)config.logger.glider_id, buff); eeprom_update_block((void *)config.logger.glider_id, (void *)config_ee.logger.glider_id, LOG_TEXT_LEN); } gui_switch_task(GUI_SET_LOGGER); }
void gui_set_weaklift_freq_cb(float val) { uint16_t tmp = val; config.audio_profile.weak_lift_freq = tmp; eeprom_busy_wait(); eeprom_update_word(&config_ee.audio_profile.weak_lift_freq, config.audio_profile.weak_lift_freq); gui_switch_task(GUI_SET_WEEKLIFT); }
void gui_set_system_auto_power_off_cb(float ret) { uint8_t val = ret; config.system.auto_power_off = val; eeprom_busy_wait(); eeprom_update_byte(&config_ee.system.auto_power_off, config.system.auto_power_off); gui_switch_task(GUI_SET_SYSTEM); }
void gui_set_vario_action(uint8_t index) { switch(index) { case(0): gui_value_conf_P(PSTR("Lift threshold"), GUI_VAL_NUMBER, PSTR("%0.1f m/s"), fc.audio_lift / 100.0, fc.audio_sink / 100.0, 2, 0.1, gui_set_vario_lift_cb); gui_switch_task(GUI_SET_VAL); break; case(1): gui_value_conf_P(PSTR("Sink threshold"), GUI_VAL_NUMBER, PSTR("%0.1f m/s"), fc.audio_sink / 100.0, -10, fc.audio_lift / 100.0, 0.1, gui_set_vario_sink_cb); gui_switch_task(GUI_SET_VAL); break; case(2): gui_showmessage_P(PSTR("Not implemented")); break; case(3): fc.audio_fluid = !fc.audio_fluid; eeprom_busy_wait(); eeprom_update_byte(&config.audio_profile.fluid, fc.audio_fluid); break; case(4): gui_value_conf_P(PSTR("Digital vario int."), GUI_VAL_NUMBER, PSTR("%0.1f sec"), set_vario_digital, 0, 30, 0.1, gui_set_vario_dig_int_cb); gui_switch_task(GUI_SET_VAL); break; case(5): gui_value_conf_P(PSTR("Average vario int."), GUI_VAL_NUMBER, PSTR("%0.1f sec"), set_vario_avg, 0, 90, 0.1, gui_set_vario_avg_int_cb); gui_switch_task(GUI_SET_VAL); break; case(6): fc.vario_flags ^= VARIO_UNITS_I; eeprom_busy_wait(); eeprom_update_byte(&config.vario.flags, fc.vario_flags); break; } }
void gui_set_vario_avg_int_cb(float val) { gui_switch_task(GUI_SET_VARIO); eeprom_busy_wait(); eeprom_write_float(&config.vario.avg_vario_dampening, val); if (val == 0) fc.avg_vario_dampening = 1; else fc.avg_vario_dampening = 1.0 / 100.0 / val; }
void gui_set_logger_action(uint8_t index) { switch(index) { case(0): config.logger.enabled = !config.logger.enabled; eeprom_busy_wait(); eeprom_update_byte(&config_ee.logger.enabled, config.logger.enabled); break; case(1): if (fc.logger_state == LOGGER_ACTIVE) { gui_showmessage_P(PSTR("Cannot change\nin flight!")); return; } config.logger.format = (config.logger.format + 1) % NUMBER_OF_FORMATS; eeprom_busy_wait(); eeprom_update_byte(&config_ee.logger.format, config.logger.format); break; case(2): gui_switch_task(GUI_SET_AUTOSTART); break; case(3): gui_text_conf((char *)config.logger.pilot, LOG_TEXT_LEN, gui_set_logger_pilot_cb); gui_switch_task(GUI_TEXT); break; case(4): gui_text_conf((char *)config.logger.glider_type, LOG_TEXT_LEN, gui_set_logger_glider_type_cb); gui_switch_task(GUI_TEXT); break; case(5): gui_text_conf((char *)config.logger.glider_id, LOG_TEXT_LEN, gui_set_logger_glider_id_cb); gui_switch_task(GUI_TEXT); break; } }
void gui_set_layout_irqh(uint8_t type, uint8_t * buff) { switch(type) { case(TASK_IRQ_BUTTON_L): if (*buff == BE_CLICK) { if (set_layout_type > 0) set_layout_type -= 1; else set_layout_type = NUMBER_OF_LAYOUTS - 1; } break; case(TASK_IRQ_BUTTON_R): if (*buff == BE_CLICK) { set_layout_type = (set_layout_type + 1) % NUMBER_OF_LAYOUTS; } break; case(TASK_IRQ_BUTTON_M): if (*buff == BE_CLICK) { pages[active_page].type = set_layout_type; //store to EE eeprom_busy_wait(); eeprom_update_byte(&config.gui.pages[active_page].type, set_layout_type); gui_switch_task(GUI_LAYOUTS); } if (*buff == BE_LONG) { //escape gui_switch_task(GUI_LAYOUTS); } break; } }
void gui_set_autoset_config_action(uint8_t index) { switch (index) { case (0): gui_value_conf_P(PSTR("Circling avg."), GUI_VAL_NUMBER, PSTR("%0.0f sec"), config.gui.page_circling_average, 5, 60, 1, gui_set_autoset_config_circling_avg_cb); gui_switch_task(GUI_SET_VAL); break; case (1): gui_value_conf_P(PSTR("Circling thold."), GUI_VAL_NUMBER, PSTR("%0.0f deg/s"), config.gui.page_cirlcing_thold, 2, 30, 1, gui_set_autoset_config_circling_thold_cb); gui_switch_task(GUI_SET_VAL); break; case (2): gui_value_conf_P(PSTR("Acro thold."), GUI_VAL_NUMBER, PSTR("%0.1f m/s"), config.gui.page_acro_thold / 10.0, -10, 0, 0.5, gui_set_autoset_config_acro_thold_cb); gui_switch_task(GUI_SET_VAL); break; } }
void gui_set_display_action(uint8_t index) { switch(index) { case(0): gui_value_conf_P(PSTR("Contrast"), GUI_VAL_CONTRAST, PSTR(""), lcd_contrast, 0, GUI_CONTRAST_STEPS, 1, gui_set_display_contrast_cb); gui_switch_task(GUI_SET_VAL); break; case(1): gui_value_conf_P(PSTR("Backlight"), GUI_VAL_BRIGTHNES, PSTR(""), lcd_brightness, 0, 100, 20, gui_set_display_brightness_cb); gui_switch_task(GUI_SET_VAL); break; case(2): gui_value_conf_P(PSTR("Backlight timeout"), GUI_VAL_NUMBER, PSTR("%1.0f sec"), lcd_brightness_timeout, 0, 30, 1, gui_set_display_brightness_timeout_cb); gui_switch_task(GUI_SET_VAL); break; case(3): lcd_flags = lcd_flags ^ CFG_DISP_INVERT; eeprom_busy_wait(); eeprom_update_byte(&config.gui.disp_flags, lcd_flags); gui_change_disp_cfg(); break; case(4): lcd_flags = lcd_flags ^ CFG_DISP_FLIP; eeprom_busy_wait(); eeprom_update_byte(&config.gui.disp_flags, lcd_flags); disp.SetFlip(lcd_flags & CFG_DISP_FLIP); break; case(5): lcd_flags = lcd_flags ^ CFG_DISP_ANIM; eeprom_busy_wait(); eeprom_update_byte(&config.gui.disp_flags, lcd_flags); break; } }
void gui_set_weaklift_action(uint8_t index) { switch (index) { case(0): config.vario.weak_lift_enabled = !config.vario.weak_lift_enabled; eeprom_busy_wait(); eeprom_update_byte(&config_ee.vario.weak_lift_enabled, config.vario.weak_lift_enabled); break; case(1): gui_value_conf_P(PSTR("Threshold"), GUI_VAL_NUMBER, PSTR("%1.0f"), config.vario.weak_lift / 10, 1, 20, 1, gui_set_weaklift_val_cb); gui_switch_task(GUI_SET_VAL); break; case(2): gui_value_conf_P(PSTR("Buzzer frequency"), GUI_VAL_NUMBER, PSTR("%1.0f Hz"), config.audio_profile.weak_lift_freq, 10, 2000, 10, gui_set_weaklift_freq_cb); gui_switch_task(GUI_SET_VAL); break; } }
void gui_set_layouts_pages_cb(float val) { uint8_t tmp = val; config.gui.number_of_pages = tmp; eeprom_busy_wait(); eeprom_update_byte(&config_ee.gui.number_of_pages, tmp); if (active_page >= tmp) active_page = 0; gui_switch_task(GUI_LAYOUTS); }
void gui_settings_action(uint8_t index) { switch (index) { case (0): gui_switch_task(GUI_SET_VARIO); break; case (1): gui_switch_task(GUI_SET_ALTIMETERS); break; case (2): gui_switch_task(GUI_SET_LOGGER); break; case (3): gui_filemanager_set_dir((char *) LOG_DIR_ABS); gui_filemanager_level = 0; gui_filemanager_set_tasks(GUI_FLIGHTDETAIL, GUI_SETTINGS); gui_switch_task(GUI_FILEMANAGER); break; case (4): gui_switch_task(GUI_HOME); break; case (5): gui_switch_task(GUI_SET_GPS); break; case (6): gui_switch_task(GUI_SET_BLUETOOTH); break; case (7): gui_switch_task(GUI_SET_SYSTEM); break; case (8): gui_switch_task(GUI_SET_DEBUG); break; } }
void gui_set_time_action(uint8_t index) { switch(index) { case(0): gui_value_conf_P(PSTR("Time"), GUI_VAL_TIME, PSTR(""), 0, 0, 0, 1, gui_set_time_time_cb); gui_switch_task(GUI_SET_VAL); break; case(1): gui_value_conf_P(PSTR("Date"), GUI_VAL_DATE, PSTR(""), 0, 0, 0, 1, gui_set_time_time_cb); gui_switch_task(GUI_SET_VAL); break; case(2): gui_value_conf_P(PSTR("Time zone"), GUI_VAL_NUMBER, PSTR("UTC %+0.1f"), config.system.time_zone / 2.0, -12, 12, 0.5, gui_set_time_timezone_cb); gui_switch_task(GUI_SET_VAL); break; case(3): config.system.time_flags ^= TIME_DST; if (config.system.time_flags & TIME_DST) config.system.time_zone = config.system.time_zone + 2; else config.system.time_zone = config.system.time_zone - 2; eeprom_busy_wait(); eeprom_update_block((void *)&config.system.time_zone, (void *)&config.system.time_zone, sizeof(int8_t)); eeprom_update_byte(&config_ee.system.time_flags, config.system.time_flags); break; case(4): config.system.time_flags ^= TIME_SYNC; eeprom_busy_wait(); eeprom_update_byte(&config_ee.system.time_flags, config.system.time_flags); break; } }
void fc_landing() { gui_dialog_set_P(PSTR("Landing"), PSTR(""), GUI_STYLE_STATS, fc_landing_cb); fc_landing_old_gui_task = gui_task; gui_switch_task(GUI_DIALOG); fc.flight_state = FLIGHT_LAND; fc.flight_timer = task_get_ms_tick() - fc.flight_timer; audio_off(); logger_stop(); }
void gui_set_debug_action(uint8_t index) { switch(index) { // case(3): // gui_dialog_set_P(PSTR("Confirmation"), PSTR("Do you want to\nreset Factory\ntest?"), GUI_STYLE_YESNO, gui_set_debug_reset_fc); // gui_switch_task(GUI_DIALOG); // break; case(2): battery_update(); break; case(4): if (config.system.debug_log == DEBUG_MAGIC_ON) config.system.debug_log = 0; else config.system.debug_log = DEBUG_MAGIC_ON; eeprom_busy_wait(); eeprom_update_byte(&config_ee.system.debug_log, config.system.debug_log); break; case(5): gui_dialog_set_P(PSTR("Confirmation"), PSTR("Clear\ndebug.log?"), GUI_STYLE_YESNO, gui_set_debug_delete_fc); gui_switch_task(GUI_DIALOG); break; case(6): config.system.debug_gps = !config.system.debug_gps; eeprom_busy_wait(); eeprom_update_byte(&config_ee.system.debug_gps, config.system.debug_gps); break; case(8): config.system.record_screen = !config.system.record_screen; eeprom_busy_wait(); eeprom_update_byte(&config_ee.system.record_screen, config.system.record_screen); break; } }
void gui_set_altimeter_gps_alt(uint8_t ret) { if (ret == GUI_DIALOG_YES) { if (fc.gps_data.valid) { uint8_t a_type = set_alt_flags & 0b11000000; if (a_type == ALT_ABS_QNH1) { config.altitude.QNH1 = fc_alt_to_qnh(fc.gps_data.altitude, fc.vario.pressure); fc_manual_alt0_change(fc.gps_data.altitude); } if (a_type == ALT_ABS_QNH2) { config.altitude.QNH2 = fc_alt_to_qnh(fc.gps_data.altitude, fc.vario.pressure); } if (a_type == ALT_DIFF) { uint8_t a_index = set_alt_flags & 0b00001111; int16_t p_alt; if (a_index == 0) p_alt = fc.altitude1; else p_alt = fc.altitudes[a_index - 1]; config.altitude.altimeter[set_alt_index - 1].delta = fc.gps_data.altitude - p_alt; } } } gui_switch_task(GUI_SET_ALTIMETER); }
void gui_set_gps_action(uint8_t index) { uint8_t tmp; switch(index) { case(0): config.system.use_gps = !config.system.use_gps; eeprom_busy_wait(); eeprom_update_byte(&config_ee.system.use_gps, config.system.use_gps); if (config.system.use_gps) gps_start(); else gps_stop(); break; case(1): if (!config.system.use_gps) gui_showmessage_P(PSTR("Enable GPS first")); else gui_switch_task(GUI_SET_GPS_DETAIL); break; case(2): if (config.system.use_gps) { if (fc.gps_data.fix_cnt > GPS_FIX_TIME_SYNC) fc_sync_gps_time(); else gui_showmessage_P(PSTR("Wait for GPS")); } else gui_showmessage_P(PSTR("Enable GPS first")); break; case(3): if (config.system.use_gps) { if (fc.gps_data.fix_cnt > GPS_FIX_TIME_SYNC) fc_sync_gps_time(); else gui_showmessage_P(PSTR("Wait for GPS")); } else gui_showmessage_P(PSTR("Enable GPS first")); break; case(4): tmp = (config.system.gps_format_flags & GPS_SPD_MASK) >> 0; tmp = (tmp + 1) % 4; config.system.gps_format_flags = (config.system.gps_format_flags & ~GPS_SPD_MASK) | (tmp << 0); eeprom_busy_wait(); eeprom_update_byte(&config_ee.system.gps_format_flags, config.system.gps_format_flags); break; case(5): tmp = (config.system.gps_format_flags & GPS_FORMAT_MASK) >> 2; tmp = (tmp + 1) % 3; config.system.gps_format_flags = (config.system.gps_format_flags & ~GPS_FORMAT_MASK) | (tmp << 2); eeprom_busy_wait(); eeprom_update_byte(&config_ee.system.gps_format_flags, config.system.gps_format_flags); break; } }
void gui_list_draw() { char tmp_text[64]; char tmp_sub_text[32]; uint8_t flags; disp.LoadFont(F_TEXT_M); uint8_t t_h = disp.GetTextHeight(); int16_t y = gui_list_y_offset; int8_t height; int16_t total_height = 0; uint8_t sub_height; //emulate middle click if (button_in_reset(B_MIDDLE)) { if (task_get_ms_tick() - gui_list_middle_hold > BUTTON_LONG) { gui_switch_task(gui_list_back); if (config.gui.menu_audio_flags & CFG_AUDIO_MENU_BUTTONS && gui_buttons_override == false) seq_start(&snd_menu_exit, config.gui.menu_volume); } } else gui_list_middle_hold = task_get_ms_tick(); for (uint8_t i = 0; i < gui_list_size; i++) { height = 1 + t_h; flags = 0; if (i < gui_list_size - 1) { gui_list_gen_f(i, tmp_text, &flags, tmp_sub_text); } else { strcpy_P(tmp_text, PSTR("back")); flags = GUI_LIST_BACK; } uint8_t x_val = 5; switch(flags & GUI_LIST_T_MASK) { case(GUI_LIST_FOLDER): x_val = 5; break; case(GUI_LIST_BACK): x_val = 2; break; } if ((flags & GUI_LIST_T_MASK) == GUI_LIST_SUB_TEXT) { sub_height = disp.GetTextHeight(); height += sub_height; } if (gui_list_index[gui_task] == i) { if (y < 0) gui_list_y_offset = -total_height; if (y > GUI_DISP_HEIGHT - height) gui_list_y_offset = -total_height + GUI_DISP_HEIGHT - height; } if (y > GUI_DISP_HEIGHT) continue; disp.GotoXY(x_val, y + 1); fprintf_P(lcd_out, PSTR("%s"), tmp_text); //sub text if ((flags & GUI_LIST_T_MASK) == GUI_LIST_SUB_TEXT) gui_raligh_text(tmp_sub_text, GUI_DISP_WIDTH - 3, y + t_h + 1); //tick if ((flags & GUI_LIST_T_MASK) == GUI_LIST_CHECK_OFF || (flags & GUI_LIST_T_MASK) == GUI_LIST_CHECK_ON) { disp.DrawRectangle(GUI_DISP_WIDTH - 9, y + 1, GUI_DISP_WIDTH - 3, y + 7, 1, 0); if ((flags & GUI_LIST_T_MASK) == GUI_LIST_CHECK_ON) { disp.DrawLine(GUI_DISP_WIDTH - 8, y + 5, GUI_DISP_WIDTH - 7, y + 6, 1); disp.DrawLine(GUI_DISP_WIDTH - 6, y + 5, GUI_DISP_WIDTH - 4, y + 3, 1); } } if (flags & GUI_LIST_DISABLED) { for (uint8_t cx = 0; cx < GUI_DISP_WIDTH - 1; cx++) for (uint8_t cy = y + cx % 2 + 1; cy < y + t_h; cy += 2) disp.PutPixel(cx, cy, 0); } if (gui_list_index[gui_task] == i) { disp.Invert(0, y, GUI_DISP_WIDTH - 1, y + height - 1); disp.PutPixel(0, y, 0); disp.PutPixel(GUI_DISP_WIDTH - 1, y, 0); disp.PutPixel(GUI_DISP_WIDTH - 1, y + height - 1, 0); disp.PutPixel(0, y + height - 1, 0); } y += height; total_height += height; } }
void gui_set_time_time_cb(float val) { gui_switch_task(GUI_SET_TIME); }
void fc_landing_cb(uint8_t ret) { gui_switch_task(fc_landing_old_gui_task); }