uhf_scene_settings.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "../uhf_app_i.h"
  2. #include "../uhf_module.h"
  3. void uhf_settings_set_module_baudrate(VariableItem* item) {
  4. UNUSED(item);
  5. }
  6. void uhf_scene_settings_on_enter(void* ctx) {
  7. UHFApp* uhf_app = ctx;
  8. VariableItem* item;
  9. uint8_t value_index = 0;
  10. M100Module* uhf_module = uhf_app->worker->module;
  11. item = variable_item_list_add(
  12. uhf_app->variable_item_list,
  13. "Baud Rate:",
  14. sizeof(BAUD_RATES),
  15. uhf_settings_set_module_baudrate,
  16. uhf_module);
  17. scene_manager_set_scene_state(uhf_app->scene_manager, UHFSceneSettings, (uint32_t)item);
  18. variable_item_set_current_value_index(item, value_index);
  19. char text_buf[10] = {0};
  20. snprintf(text_buf, sizeof(text_buf), "%d", uhf_module->baudrate);
  21. variable_item_set_current_value_text(item, text_buf);
  22. view_dispatcher_switch_to_view(uhf_app->view_dispatcher, UHFViewMenu);
  23. }
  24. bool uhf_scene_settings_on_event(void* ctx, SceneManagerEvent event) {
  25. UHFApp* uhf_app = ctx;
  26. bool consumed = false;
  27. if(event.type == SceneManagerEventTypeCustom) {
  28. if(event.event == UHFCustomEventSceneSettingLock) {
  29. scene_manager_previous_scene(uhf_app->scene_manager);
  30. consumed = true;
  31. }
  32. }
  33. return consumed;
  34. }
  35. void uhf_scene_settings_on_exit(void* ctx) {
  36. UHFApp* uhf_app = ctx;
  37. submenu_reset(uhf_app->submenu);
  38. }