scope_scene_setup.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. ScopeApp* app = variable_item_get_context(item);
  14. furi_assert(app);
  15. uint8_t index = variable_item_get_current_value_index(item);
  16. variable_item_set_current_value_text(item, time_list[index].str);
  17. app->time = time_list[index].time;
  18. }
  19. static void measurement_cb(VariableItem* item) {
  20. ScopeApp* app = variable_item_get_context(item);
  21. furi_assert(app);
  22. uint8_t index = variable_item_get_current_value_index(item);
  23. variable_item_set_current_value_text(item, measurement_list[index].str);
  24. app->measurement = measurement_list[index].type;
  25. }
  26. void scope_scene_setup_on_enter(void* context) {
  27. ScopeApp* app = context;
  28. VariableItemList* var_item_list = app->variable_item_list;
  29. VariableItem* item;
  30. item = variable_item_list_add(
  31. var_item_list,
  32. "Time period",
  33. COUNT_OF(time_list),
  34. timeperiod_cb,
  35. app);
  36. for (uint32_t i = 0; i < COUNT_OF(time_list); i++){
  37. if(time_list[i].time == app->time){
  38. variable_item_set_current_value_index(item, i);
  39. variable_item_set_current_value_text(item, time_list[i].str);
  40. break;
  41. }
  42. }
  43. item = variable_item_list_add(
  44. var_item_list,
  45. "Measurement",
  46. COUNT_OF(measurement_list),
  47. measurement_cb,
  48. app);
  49. for (uint32_t i = 0; i < COUNT_OF(measurement_list); i++){
  50. if(measurement_list[i].type == app->measurement){
  51. variable_item_set_current_value_index(item, i);
  52. variable_item_set_current_value_text(item, measurement_list[i].str);
  53. break;
  54. }
  55. }
  56. view_dispatcher_switch_to_view(app->view_dispatcher, ScopeViewVariableItemList);
  57. }
  58. bool scope_scene_setup_on_event(void* context, SceneManagerEvent event) {
  59. ScopeApp* app = context;
  60. bool consumed = false;
  61. UNUSED(app);
  62. UNUSED(event);
  63. return consumed;
  64. }
  65. void scope_scene_setup_on_exit(void* context) {
  66. ScopeApp* app = context;
  67. variable_item_list_reset(app->variable_item_list);
  68. // Clear views
  69. widget_reset(app->widget);
  70. }