scope_scene_setup.c 2.3 KB

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