scope_scene_run.c 17 KB

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