scope_scene_setup.c 1.8 KB

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