scope_scene_run.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. #include <furi.h>
  2. #include <furi_hal.h>
  3. #include <furi_hal_resources.h>
  4. #include <gui/gui.h>
  5. #include <gui/view_dispatcher.h>
  6. #include <gui/scene_manager.h>
  7. #include <gui/modules/submenu.h>
  8. #include <gui/modules/variable_item_list.h>
  9. #include <gui/modules/widget.h>
  10. #include <notification/notification_messages.h>
  11. #include "stm32wbxx_hal.h"
  12. #include "stm32wbxx_hal_tim.h"
  13. #include "stm32wbxx_nucleo.h"
  14. #include "stm32wbxx_hal_adc.h"
  15. #include "../scope_app_i.h"
  16. #define DIGITAL_SCALE_12BITS ((uint32_t) 0xFFF)
  17. #define ADC_CONVERTED_DATA_BUFFER_SIZE ((uint32_t) 128)
  18. #define VAR_CONVERTED_DATA_INIT_VALUE (DIGITAL_SCALE_12BITS + 1)
  19. #define VAR_CONVERTED_DATA_INIT_VALUE_16BITS (0xFFFF + 1U)
  20. #define __ADC_CALC_DATA_VOLTAGE(__VREFANALOG_VOLTAGE__, __ADC_DATA__) \
  21. ((__ADC_DATA__) * (__VREFANALOG_VOLTAGE__) / DIGITAL_SCALE_12BITS)
  22. #define VDDA_APPLI ((uint32_t)3300)
  23. // ramVector found from - https://community.nxp.com/t5/i-MX-Processors/Relocate-vector-table-to-ITCM/m-p/1302304
  24. // the aligned aspect is key!
  25. #define TABLE_SIZE 79
  26. uint32_t ramVector[TABLE_SIZE+1] __attribute__((aligned(512)));
  27. const uint32_t AHBPrescTable[16UL] = {1UL, 3UL, 5UL, 1UL, 1UL, 6UL, 10UL, 32UL, 2UL, 4UL, 8UL, 16UL, 64UL, 128UL, 256UL, 512UL};
  28. const uint32_t APBPrescTable[8UL] = {0UL, 0UL, 0UL, 0UL, 1UL, 2UL, 3UL, 4UL};
  29. const uint32_t MSIRangeTable[16UL] = {100000UL, 200000UL, 400000UL, 800000UL, 1000000UL, 2000000UL, \
  30. 4000000UL, 8000000UL, 16000000UL, 24000000UL, 32000000UL, 48000000UL, 0UL, 0UL, 0UL, 0UL}; /* 0UL values are incorrect cases */
  31. char * time; // Current time period text
  32. double freq; // Current samplerate
  33. uint8_t pause=0; // Whether we want to pause output or not
  34. enum measureenum type; // Type of measurement we are performing
  35. int toggle = 0; // Used for toggling output GPIO, only used in testing
  36. void Error_Handler()
  37. {
  38. while (1) {
  39. }
  40. }
  41. static ADC_HandleTypeDef hadc1;
  42. static DMA_HandleTypeDef hdma_adc1;
  43. static TIM_HandleTypeDef htim2;
  44. __IO uint16_t aADCxConvertedData[ADC_CONVERTED_DATA_BUFFER_SIZE]; // Array that ADC data is copied to, via DMA
  45. __IO uint16_t aADCxConvertedData_Voltage_mVoltA[ADC_CONVERTED_DATA_BUFFER_SIZE]; // Data is converted to range from 0 to 3300
  46. __IO uint16_t aADCxConvertedData_Voltage_mVoltB[ADC_CONVERTED_DATA_BUFFER_SIZE]; // Data is converted to range from 0 to 3300
  47. __IO uint8_t ubDmaTransferStatus = 2; // DMA transfer status
  48. __IO uint16_t *mvoltWrite = &aADCxConvertedData_Voltage_mVoltA[0]; // Pointer to area we write converted voltage data to
  49. __IO uint16_t *mvoltDisplay = &aADCxConvertedData_Voltage_mVoltB[0]; // Pointer to area of memory we display
  50. void HAL_ADC_MspInit(ADC_HandleTypeDef * hadc)
  51. {
  52. GPIO_InitTypeDef GPIO_InitStruct = { 0 };
  53. if (hadc->Instance == ADC1) {
  54. __HAL_RCC_ADC_CLK_ENABLE();
  55. __HAL_RCC_GPIOC_CLK_ENABLE();
  56. GPIO_InitStruct.Pin = GPIO_PIN_0;
  57. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  58. GPIO_InitStruct.Pull = GPIO_NOPULL;
  59. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  60. hdma_adc1.Instance = DMA1_Channel1;
  61. hdma_adc1.Init.Request = DMA_REQUEST_ADC1;
  62. hdma_adc1.Init.Direction = DMA_PERIPH_TO_MEMORY;
  63. hdma_adc1.Init.PeriphInc = DMA_PINC_DISABLE;
  64. hdma_adc1.Init.MemInc = DMA_MINC_ENABLE;
  65. hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
  66. hdma_adc1.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
  67. hdma_adc1.Init.Mode = DMA_CIRCULAR;
  68. hdma_adc1.Init.Priority = DMA_PRIORITY_LOW;
  69. if (HAL_DMA_Init(&hdma_adc1) != HAL_OK) {
  70. Error_Handler();
  71. }
  72. __HAL_LINKDMA(hadc, DMA_Handle, hdma_adc1);
  73. HAL_NVIC_SetPriority(ADC1_IRQn, 15, 0);
  74. HAL_NVIC_EnableIRQ(ADC1_IRQn);
  75. }
  76. }
  77. void HAL_ADC_MspDeInit(ADC_HandleTypeDef * hadc)
  78. {
  79. if (hadc->Instance == ADC1) {
  80. __HAL_RCC_ADC_CLK_DISABLE();
  81. HAL_GPIO_DeInit(GPIOC, GPIO_PIN_0);
  82. HAL_DMA_DeInit(hadc->DMA_Handle);
  83. HAL_NVIC_DisableIRQ(ADC1_IRQn);
  84. }
  85. }
  86. void HAL_TIM_Base_MspInit(TIM_HandleTypeDef * htim_base)
  87. {
  88. if (htim_base->Instance == TIM2) {
  89. __HAL_RCC_TIM2_CLK_ENABLE();
  90. HAL_NVIC_SetPriority(TIM2_IRQn, 15, 0);
  91. HAL_NVIC_EnableIRQ(TIM2_IRQn);
  92. }
  93. }
  94. void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef * htim_base)
  95. {
  96. if (htim_base->Instance == TIM2) {
  97. __HAL_RCC_TIM2_CLK_DISABLE();
  98. HAL_NVIC_DisableIRQ(TIM2_IRQn);
  99. }
  100. }
  101. void DMA1_Channel1_IRQHandler(void)
  102. {
  103. HAL_DMA_IRQHandler(&hdma_adc1);
  104. }
  105. void ADC1_IRQHandler(void)
  106. {
  107. HAL_ADC_IRQHandler(&hadc1);
  108. }
  109. void TIM2_IRQHandler(void)
  110. {
  111. HAL_TIM_IRQHandler(&htim2);
  112. }
  113. // Setup ADC1 to be triggered by timer2
  114. static void MX_ADC1_Init(void)
  115. {
  116. ADC_ChannelConfTypeDef sConfig = { 0 };
  117. hadc1.Instance = ADC1;
  118. hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;
  119. hadc1.Init.Resolution = ADC_RESOLUTION_12B;
  120. hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
  121. hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE;
  122. hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
  123. hadc1.Init.LowPowerAutoWait = DISABLE;
  124. hadc1.Init.ContinuousConvMode = DISABLE;
  125. hadc1.Init.NbrOfConversion = 1;
  126. hadc1.Init.DiscontinuousConvMode = DISABLE;
  127. hadc1.Init.ExternalTrigConv = ADC_EXTERNALTRIG_T2_TRGO;
  128. hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_RISING;
  129. hadc1.Init.DMAContinuousRequests = ENABLE;
  130. hadc1.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN;
  131. hadc1.Init.OversamplingMode = DISABLE;
  132. if (HAL_ADC_Init(&hadc1) != HAL_OK) {
  133. Error_Handler();
  134. }
  135. sConfig.Channel = ADC_CHANNEL_1;
  136. sConfig.Rank = ADC_REGULAR_RANK_1;
  137. sConfig.SamplingTime = ADC_SAMPLETIME_2CYCLE_5;
  138. sConfig.SingleDiff = ADC_SINGLE_ENDED;
  139. sConfig.OffsetNumber = ADC_OFFSET_NONE;
  140. sConfig.Offset = 0;
  141. if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) {
  142. Error_Handler();
  143. }
  144. }
  145. // Only used in testing, for toggling GPIO pin, to measure timer frequency
  146. void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
  147. {
  148. if (htim->Instance == TIM2){
  149. toggle ^= 1;
  150. furi_hal_gpio_write(&gpio_ext_pa7, toggle);
  151. }
  152. }
  153. // Init timer2
  154. static void MX_TIM2_Init(uint32_t period)
  155. {
  156. TIM_ClockConfigTypeDef sClockSourceConfig = { 0 };
  157. TIM_MasterConfigTypeDef sMasterConfig = { 0 };
  158. htim2.Instance = TIM2;
  159. htim2.Init.Prescaler = 1;
  160. htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
  161. htim2.Init.Period = period;
  162. htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
  163. htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
  164. if (HAL_TIM_Base_Init(&htim2) != HAL_OK) {
  165. Error_Handler();
  166. }
  167. sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
  168. if (HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig) != HAL_OK) {
  169. Error_Handler();
  170. }
  171. sMasterConfig.MasterOutputTrigger = TIM_TRGO_UPDATE;
  172. sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
  173. if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK) {
  174. Error_Handler();
  175. }
  176. }
  177. static void MX_DMA_Init(void)
  178. {
  179. __HAL_RCC_DMAMUX1_CLK_ENABLE();
  180. __HAL_RCC_DMA1_CLK_ENABLE();
  181. HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 15, 0);
  182. HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn);
  183. }
  184. static void MX_GPIO_Init(void)
  185. {
  186. __HAL_RCC_GPIOC_CLK_ENABLE();
  187. }
  188. // Swap pointer addresses, used for double buffer
  189. void swap(__IO uint16_t **a, __IO uint16_t **b){
  190. __IO uint16_t *tmp;
  191. tmp = *a;
  192. *a = *b;
  193. *b = tmp;
  194. }
  195. // Write end half of DMA buffer to converted output
  196. void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef * hadc)
  197. {
  198. UNUSED(hadc);
  199. uint32_t tmp_index = 0;
  200. for (tmp_index = (ADC_CONVERTED_DATA_BUFFER_SIZE / 2); tmp_index < ADC_CONVERTED_DATA_BUFFER_SIZE; tmp_index++) {
  201. mvoltWrite[tmp_index] = __ADC_CALC_DATA_VOLTAGE(VDDA_APPLI, aADCxConvertedData[tmp_index]);
  202. }
  203. ubDmaTransferStatus = 1;
  204. // Swap double buffer, so new data can be displayed, provided we're not paused
  205. if(!pause)
  206. swap(&mvoltWrite, &mvoltDisplay);
  207. }
  208. // Write first half of DMA buffer to converted output
  209. void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef * hadc)
  210. {
  211. UNUSED(hadc);
  212. uint32_t tmp_index = 0;
  213. for (tmp_index = 0; tmp_index < (ADC_CONVERTED_DATA_BUFFER_SIZE / 2); tmp_index++) {
  214. mvoltWrite[tmp_index] = __ADC_CALC_DATA_VOLTAGE(VDDA_APPLI, aADCxConvertedData[tmp_index]);
  215. }
  216. ubDmaTransferStatus = 0;
  217. }
  218. void HAL_ADC_ErrorCallback(ADC_HandleTypeDef * hadc)
  219. {
  220. UNUSED(hadc);
  221. Error_Handler();
  222. }
  223. // Used to draw to display
  224. static void app_draw_callback(Canvas * canvas, void *ctx)
  225. {
  226. UNUSED(ctx);
  227. int16_t index[ADC_CONVERTED_DATA_BUFFER_SIZE];
  228. float data[ADC_CONVERTED_DATA_BUFFER_SIZE];
  229. float crossings[ADC_CONVERTED_DATA_BUFFER_SIZE];
  230. float max = 0.0;
  231. float min = 33000.0;
  232. int count = 0;
  233. char buf1[50];
  234. // Calculate voltage measurements
  235. for(uint32_t x = 0; x < ADC_CONVERTED_DATA_BUFFER_SIZE; x++){
  236. if(mvoltDisplay[x] < min)
  237. min = mvoltDisplay[x];
  238. if(mvoltDisplay[x] > max)
  239. max = mvoltDisplay[x];
  240. }
  241. max /= 1000;
  242. min /= 1000;
  243. switch(type){
  244. case m_time:
  245. {
  246. // Display current time period
  247. snprintf(buf1, 50, "Time: %s", time);
  248. canvas_draw_str(canvas, 10, 10, buf1);
  249. // Shift waveform across a virtual 0 line, so it crosses 0
  250. for(uint32_t x = 0; x < ADC_CONVERTED_DATA_BUFFER_SIZE; x++){
  251. index[x] = -1;
  252. crossings[x] = -1.0;
  253. data[x] = ((float)mvoltDisplay[x] / 1000) - min;
  254. data[x] = ((2 / (max - min)) * data[x]) - 1;
  255. }
  256. // Find points at which waveform crosses virtual 0 line
  257. for(uint32_t x = 1; x < ADC_CONVERTED_DATA_BUFFER_SIZE; x++){
  258. if(data[x] >= 0 && data[x-1] < 0){
  259. index[count++] = x - 1;
  260. }
  261. }
  262. count=0;
  263. // Linear interpolation to find zero crossings
  264. // see https://gist.github.com/endolith/255291 for Python version
  265. for(uint32_t x = 0; x < ADC_CONVERTED_DATA_BUFFER_SIZE; x++){
  266. if(index[x] == -1)
  267. break;
  268. crossings[count++] = (float)index[x] - data[index[x]] / (data[index[x]+1] - data[index[x]]);
  269. }
  270. float avg = 0.0;
  271. float countv = 0.0;
  272. for(uint32_t x = 0; x < ADC_CONVERTED_DATA_BUFFER_SIZE; x++){
  273. if(x + 1 >= ADC_CONVERTED_DATA_BUFFER_SIZE)
  274. break;
  275. if(crossings[x] == -1 || crossings[x+1] == -1)
  276. break;
  277. avg += crossings[x+1] - crossings[x];
  278. countv += 1;
  279. }
  280. avg /= countv;
  281. // Display frequency of waveform
  282. snprintf(buf1, 50, "Freq: %.1f Hz", (double)((float)freq / avg));
  283. canvas_draw_str(canvas, 10, 20, buf1);
  284. }
  285. break;
  286. case m_voltage:
  287. {
  288. // Display max, min, peak-to-peak voltages
  289. snprintf(buf1, 50, "Max: %.2fV", (double)max);
  290. canvas_draw_str(canvas, 10, 10, buf1);
  291. snprintf(buf1, 50, "Min: %.2fV", (double)min);
  292. canvas_draw_str(canvas, 10, 20, buf1);
  293. snprintf(buf1, 50, "Vpp: %.2fV", (double)(max - min));
  294. canvas_draw_str(canvas, 10, 30, buf1);
  295. }
  296. break;
  297. default:
  298. break;
  299. }
  300. // Draw lines between each data point
  301. for(uint32_t x = 1; x < ADC_CONVERTED_DATA_BUFFER_SIZE; x++){
  302. uint32_t prev = 64 - (mvoltDisplay[x-1] / (VDDA_APPLI / 64));
  303. uint32_t cur = 64 - (mvoltDisplay[x] / (VDDA_APPLI / 64));
  304. canvas_draw_line(canvas, x - 1, prev, x, cur);
  305. }
  306. // Draw graph lines
  307. canvas_draw_line(canvas, 0, 0, 0, 63);
  308. canvas_draw_line(canvas, 0, 63, 128, 63);
  309. }
  310. static void app_input_callback(InputEvent * input_event, void *ctx)
  311. {
  312. furi_assert(ctx);
  313. FuriMessageQueue *event_queue = ctx;
  314. furi_message_queue_put(event_queue, input_event, FuriWaitForever);
  315. }
  316. void scope_scene_run_widget_callback(
  317. GuiButtonType result,
  318. InputType type,
  319. void* context) {
  320. ScopeApp* app = context;
  321. if(type == InputTypeShort) {
  322. view_dispatcher_send_custom_event(app->view_dispatcher, result);
  323. }
  324. }
  325. void scope_scene_run_on_enter(void* context) {
  326. ScopeApp* app = context;
  327. // Find string representation of time period we're using
  328. for (uint32_t i = 0; i < COUNT_OF(time_list); i++){
  329. if(time_list[i].time == app->time){
  330. time = time_list[i].str;
  331. break;
  332. }
  333. }
  334. // Currently un-paused
  335. pause = 0;
  336. // What type of measurement are we performing
  337. type = app->measurement;
  338. // Test purposes
  339. //furi_hal_gpio_write(&gpio_ext_pa7, false);
  340. //furi_hal_gpio_init( &gpio_ext_pa7, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh);
  341. // Copy vector table, modify to use our own IRQ handlers
  342. __disable_irq();
  343. memcpy(ramVector, (uint32_t*)(FLASH_BASE | SCB->VTOR), sizeof(uint32_t) * TABLE_SIZE);
  344. SCB->VTOR = (uint32_t)ramVector;
  345. ramVector[27] = (uint32_t)DMA1_Channel1_IRQHandler;
  346. ramVector[34] = (uint32_t)ADC1_IRQHandler;
  347. ramVector[44] = (uint32_t)TIM2_IRQHandler;
  348. __enable_irq();
  349. // Found this recommended by https://www.freertos.org/RTOS-Cortex-M3-M4.html
  350. // although we're using after RTOS started
  351. HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
  352. FuriMessageQueue *event_queue = furi_message_queue_alloc(8, sizeof(InputEvent));
  353. uint32_t tmp_index_adc_converted_data = 0;
  354. MX_GPIO_Init();
  355. MX_DMA_Init();
  356. // Hack -- PCLK1 - seems to be twice what is reported? Not sure how?
  357. uint32_t period = (uint32_t)((double)(HAL_RCC_GetPCLK1Freq() * 2) * app->time);
  358. freq = 1 / app->time;
  359. MX_TIM2_Init(period);
  360. // Set VREFBUF, as vref isn't connected to 3.3V itself in the flipper zero
  361. VREFBUF->CSR |= VREFBUF_CSR_ENVR;
  362. VREFBUF->CSR &= ~VREFBUF_CSR_HIZ;
  363. VREFBUF->CSR |= VREFBUF_CSR_VRS;
  364. while (!(VREFBUF->CSR & VREFBUF_CSR_VRR)) {
  365. };
  366. MX_ADC1_Init();
  367. // Setup initial values from ADC
  368. for (tmp_index_adc_converted_data = 0;
  369. tmp_index_adc_converted_data < ADC_CONVERTED_DATA_BUFFER_SIZE;
  370. tmp_index_adc_converted_data++) {
  371. aADCxConvertedData[tmp_index_adc_converted_data] = VAR_CONVERTED_DATA_INIT_VALUE;
  372. aADCxConvertedData_Voltage_mVoltA[tmp_index_adc_converted_data] = 0;
  373. aADCxConvertedData_Voltage_mVoltB[tmp_index_adc_converted_data] = 0;
  374. }
  375. if (HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED) != HAL_OK) {
  376. Error_Handler();
  377. }
  378. // Use to generate interrupt to toggle GPIO for testing
  379. //if (HAL_TIM_Base_Start_IT(&htim2) != HAL_OK) {
  380. if (HAL_TIM_Base_Start(&htim2) != HAL_OK) {
  381. Error_Handler();
  382. }
  383. // Start DMA transfer
  384. if (HAL_ADC_Start_DMA(&hadc1, (uint32_t *) aADCxConvertedData, ADC_CONVERTED_DATA_BUFFER_SIZE) != HAL_OK) {
  385. Error_Handler();
  386. }
  387. ViewPort *view_port = view_port_alloc();
  388. view_port_draw_callback_set(view_port, app_draw_callback, view_port);
  389. view_port_input_callback_set(view_port, app_input_callback, event_queue);
  390. // Register view port in GUI
  391. Gui *gui = furi_record_open(RECORD_GUI);
  392. gui_add_view_port(gui, view_port, GuiLayerFullscreen);
  393. InputEvent event;
  394. bool running = true;
  395. while (running) {
  396. if (furi_message_queue_get(event_queue, &event, 100) == FuriStatusOk) {
  397. if ((event.type == InputTypePress) || (event.type == InputTypeRepeat)) {
  398. switch (event.key) {
  399. case InputKeyLeft:
  400. break;
  401. case InputKeyRight:
  402. break;
  403. case InputKeyUp:
  404. break;
  405. case InputKeyDown:
  406. break;
  407. case InputKeyOk:
  408. pause ^= 1;
  409. break;
  410. default:
  411. running = false;
  412. break;
  413. }
  414. }
  415. }
  416. view_port_update(view_port);
  417. }
  418. // Stop DMA and switch back to original vector table
  419. HAL_ADC_Stop_DMA (&hadc1);
  420. __disable_irq();
  421. SCB->VTOR = 0;
  422. __enable_irq();
  423. view_port_enabled_set(view_port, false);
  424. gui_remove_view_port(gui, view_port);
  425. view_port_free(view_port);
  426. // Switch back to original scene
  427. furi_record_close(RECORD_GUI);
  428. scene_manager_previous_scene(app->scene_manager);
  429. submenu_set_selected_item(app->submenu, 0);
  430. }
  431. bool scope_scene_run_on_event(void* context, SceneManagerEvent event) {
  432. ScopeApp* app = context;
  433. bool consumed = false;
  434. UNUSED(app);
  435. UNUSED(event);
  436. return consumed;
  437. }
  438. void scope_scene_run_on_exit(void* context) {
  439. ScopeApp* app = context;
  440. // Clear views
  441. widget_reset(app->widget);
  442. }