scope_scene_setup.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #include "../scope_app_i.h"
  2. #include "../helpers/scope_types.h"
  3. void scope_scene_setup_widget_callback(
  4. GuiButtonType result,
  5. InputType type,
  6. void* context) {
  7. ScopeApp* app = context;
  8. if(type == InputTypeShort) {
  9. view_dispatcher_send_custom_event(app->view_dispatcher, result);
  10. }
  11. }
  12. static void timeperiod_cb(VariableItem* item) {
  13. UNUSED(item);
  14. ScopeApp* app = variable_item_get_context(item);
  15. furi_assert(app);
  16. uint8_t index = variable_item_get_current_value_index(item);
  17. variable_item_set_current_value_text(item, time_list[index].str);
  18. app->time = time_list[index].time;
  19. }
  20. void scope_scene_setup_on_enter(void* context) {
  21. ScopeApp* app = context;
  22. VariableItemList* var_item_list = app->variable_item_list;
  23. VariableItem* item;
  24. item = variable_item_list_add(
  25. var_item_list,
  26. "Time period",
  27. COUNT_OF(time_list),
  28. timeperiod_cb,
  29. app);
  30. for (uint32_t i = 0; i < COUNT_OF(time_list); i++){
  31. if(time_list[i].time == app->time){
  32. variable_item_set_current_value_index(item, i);
  33. variable_item_set_current_value_text(item, time_list[i].str);
  34. break;
  35. }
  36. }
  37. view_dispatcher_switch_to_view(app->view_dispatcher, ScopeViewVariableItemList);
  38. }
  39. bool scope_scene_setup_on_event(void* context, SceneManagerEvent event) {
  40. ScopeApp* app = context;
  41. bool consumed = false;
  42. UNUSED(app);
  43. UNUSED(event);
  44. return consumed;
  45. }
  46. void scope_scene_setup_on_exit(void* context) {
  47. ScopeApp* app = context;
  48. variable_item_list_reset(app->variable_item_list);
  49. // Clear views
  50. widget_reset(app->widget);
  51. }