pinball0.cxx 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. #include <furi.h>
  2. #include <notification/notification.h>
  3. #include <cstring>
  4. #include "pinball0.h"
  5. #include "table.h"
  6. #include "notifications.h"
  7. #include "settings.h"
  8. /* generated by fbt from .png files in images folder */
  9. #include <pinball0_icons.h>
  10. // Gravity should be lower than 9.8 m/s^2 since the ball is on
  11. // an angled table. We could calc this and derive the actual
  12. // vertical vector based on the angle of the table yadda yadda yadda
  13. #define GRAVITY 3.0f // 9.8f
  14. #define PHYSICS_SUB_STEPS 5
  15. #define GAME_FPS 30
  16. #define MANUAL_ADJUSTMENT 20
  17. #define IDLE_TIMEOUT 120 * 1000 // 120 seconds * 1000 ticks/sec
  18. void solve(PinballApp* pb, float dt) {
  19. Table* table = pb->table;
  20. float sub_dt = dt / PHYSICS_SUB_STEPS;
  21. for(int ss = 0; ss < PHYSICS_SUB_STEPS; ss++) {
  22. // apply gravity (and any other forces?)
  23. // FURI_LOG_I(TAG, "Applying gravity");
  24. if(table->balls_released) {
  25. float bump_amt = 1.0f;
  26. if(pb->keys[InputKeyUp]) {
  27. bump_amt = -1.04f;
  28. }
  29. for(auto& b : table->balls) {
  30. // We multiply GRAVITY by dt since gravity is based on seconds
  31. b.accelerate(Vec2(0, GRAVITY * bump_amt * sub_dt));
  32. }
  33. }
  34. // apply collisions (among moving objects)
  35. // only needed for multi-ball! - is this true? what about flippers...
  36. for(size_t b1 = 0; b1 < table->balls.size(); b1++) {
  37. for(size_t b2 = b1 + 1; b2 < table->balls.size(); b2++) {
  38. if(b1 != b2) {
  39. auto& ball1 = table->balls[b1];
  40. auto& ball2 = table->balls[b2];
  41. Vec2 axis = ball1.p - ball2.p;
  42. float dist2 = axis.mag2();
  43. float dist = sqrtf(dist2);
  44. float rr = ball1.r + ball2.r;
  45. if(dist < rr) {
  46. Vec2 v1 = ball1.p - ball1.prev_p;
  47. Vec2 v2 = ball2.p - ball2.prev_p;
  48. float factor = (dist - rr) / dist;
  49. ball1.p -= axis * factor * 0.5f;
  50. ball2.p -= axis * factor * 0.5f;
  51. float damping = 1.01f;
  52. float f1 = (damping * (axis.x * v1.x + axis.y * v1.y)) / dist2;
  53. float f2 = (damping * (axis.x * v2.x + axis.y * v2.y)) / dist2;
  54. v1.x += f2 * axis.x - f1 * axis.x;
  55. v2.x += f1 * axis.x - f2 * axis.x;
  56. v1.y += f2 * axis.y - f1 * axis.y;
  57. v2.y += f1 * axis.y - f2 * axis.y;
  58. ball1.prev_p = ball1.p - v1;
  59. ball2.prev_p = ball2.p - v2;
  60. }
  61. }
  62. }
  63. }
  64. // collisions with static objects and flippers
  65. for(auto& b : table->balls) {
  66. for(auto& o : table->objects) {
  67. if(o->physical && o->collide(b)) {
  68. if(o->notification) {
  69. (*o->notification)(pb);
  70. }
  71. table->score.value += o->score;
  72. o->reset_animation();
  73. continue;
  74. }
  75. }
  76. for(auto& f : table->flippers) {
  77. if(f.collide(b)) {
  78. if(f.notification) {
  79. (*f.notification)(pb);
  80. }
  81. table->score.value += f.score;
  82. continue;
  83. }
  84. }
  85. }
  86. // update positions - of balls AND flippers
  87. if(table->balls_released) {
  88. for(auto& b : table->balls) {
  89. b.update(sub_dt);
  90. }
  91. }
  92. for(auto& f : table->flippers) {
  93. f.update(sub_dt);
  94. }
  95. }
  96. // Did any balls fall off the table?
  97. if(table->balls.size()) {
  98. auto num_in_play = table->balls.size();
  99. auto i = table->balls.begin();
  100. while(i != table->balls.end()) {
  101. if(i->p.y > 1280 + 100) {
  102. FURI_LOG_I(TAG, "ball off table!");
  103. i = table->balls.erase(i);
  104. num_in_play--;
  105. notify_lost_life(pb);
  106. } else {
  107. ++i;
  108. }
  109. }
  110. if(num_in_play == 0) {
  111. table->balls_released = false;
  112. table->lives.value--;
  113. if(table->lives.value > 0) {
  114. // Reset our ball to it's starting position
  115. table->balls = table->balls_initial;
  116. } else {
  117. table->game_over = true;
  118. }
  119. }
  120. }
  121. }
  122. void pinball_app_init(PinballApp* pb) {
  123. furi_assert(pb);
  124. pb->storage = (Storage*)furi_record_open(RECORD_STORAGE);
  125. pb->notify = (NotificationApp*)furi_record_open(RECORD_NOTIFICATION);
  126. notify_init();
  127. pb->table = NULL;
  128. pb->tick = 0;
  129. pb->gameStarted = false;
  130. pb->game_mode = GM_TableSelect;
  131. pb->keys[InputKeyUp] = false;
  132. pb->keys[InputKeyDown] = false;
  133. pb->keys[InputKeyRight] = false;
  134. pb->keys[InputKeyLeft] = false;
  135. pinball_load_settings(pb);
  136. }
  137. static void pinball_draw_callback(Canvas* const canvas, void* ctx) {
  138. furi_assert(ctx);
  139. PinballApp* pb = (PinballApp*)ctx;
  140. furi_mutex_acquire(pb->mutex, FuriWaitForever);
  141. // What are we drawing? table select / menu or the actual game?
  142. switch(pb->game_mode) {
  143. case GM_TableSelect: {
  144. canvas_draw_icon(canvas, 0, 0, &I_pinball0_logo); // our sweet logo
  145. // draw the list of table names: display it as a carousel - where the list repeats
  146. // and the currently selected item is always in the middle, surrounded by pinballs
  147. const TableList& list = pb->table_list;
  148. int32_t y = 25;
  149. auto half_way = list.display_size / 2;
  150. for(auto i = 0; i < list.display_size; i++) {
  151. int index =
  152. (list.selected - half_way + i + list.menu_items.size()) % list.menu_items.size();
  153. const auto& menu_item = list.menu_items[index];
  154. canvas_draw_str_aligned(
  155. canvas,
  156. LCD_WIDTH / 2,
  157. y,
  158. AlignCenter,
  159. AlignTop,
  160. furi_string_get_cstr(menu_item.name));
  161. if(i == half_way) {
  162. canvas_draw_disc(canvas, 8, y + 3, 2);
  163. canvas_draw_disc(canvas, 56, y + 3, 2);
  164. }
  165. y += 12;
  166. }
  167. pb->table->draw(canvas);
  168. } break;
  169. case GM_Playing:
  170. pb->table->draw(canvas);
  171. break;
  172. case GM_GameOver: {
  173. pb->table->draw(canvas);
  174. const int32_t y = 56;
  175. const size_t interval = 40;
  176. const float theta = (float)((pb->tick % interval) / (interval * 1.0f)) * (float)(M_PI * 2);
  177. const float sin_theta_4 = sinf(theta) * 4;
  178. const int border = 3;
  179. canvas_set_color(canvas, ColorWhite);
  180. canvas_draw_box(
  181. canvas, 16 - border, y + sin_theta_4 - border, 32 + border * 2, 16 + border * 2);
  182. canvas_set_color(canvas, ColorBlack);
  183. canvas_draw_icon(canvas, 16, y + sin_theta_4, &I_Arcade_G);
  184. canvas_draw_icon(canvas, 24, y + sin_theta_4, &I_Arcade_A);
  185. canvas_draw_icon(canvas, 32, y + sin_theta_4, &I_Arcade_M);
  186. canvas_draw_icon(canvas, 40, y + sin_theta_4, &I_Arcade_E);
  187. canvas_draw_icon(canvas, 16, y + sin_theta_4 + 8, &I_Arcade_O);
  188. canvas_draw_icon(canvas, 24, y + sin_theta_4 + 8, &I_Arcade_V);
  189. canvas_draw_icon(canvas, 32, y + sin_theta_4 + 8, &I_Arcade_E);
  190. canvas_draw_icon(canvas, 40, y + sin_theta_4 + 8, &I_Arcade_R);
  191. } break;
  192. case GM_Error: {
  193. // pb->text contains error message
  194. canvas_draw_icon(canvas, 0, 10, &I_Arcade_E);
  195. canvas_draw_icon(canvas, 8, 10, &I_Arcade_R);
  196. canvas_draw_icon(canvas, 16, 10, &I_Arcade_R);
  197. canvas_draw_icon(canvas, 24, 10, &I_Arcade_O);
  198. canvas_draw_icon(canvas, 32, 10, &I_Arcade_R);
  199. int x = 10;
  200. int y = 30;
  201. // split the string on \n and display each line
  202. // strtok is disabled - whyyy
  203. char buf[256];
  204. strncpy(buf, pb->text, 256);
  205. char* str = buf;
  206. char* p = buf;
  207. bool at_end = false;
  208. while(str != NULL) {
  209. while(p && *p != '\n' && *p != '\0')
  210. p++;
  211. if(p && *p == '\0') at_end = true;
  212. *p = '\0';
  213. canvas_draw_str_aligned(canvas, x, y, AlignLeft, AlignTop, str);
  214. if(at_end) {
  215. str = NULL;
  216. break;
  217. }
  218. str = p + 1;
  219. p = str;
  220. y += 12;
  221. }
  222. pb->table->draw(canvas);
  223. } break;
  224. case GM_Settings: {
  225. // TODO: like... do better here. maybe vector of settings strings, etc
  226. canvas_draw_str_aligned(canvas, 2, 10, AlignLeft, AlignTop, "SETTINGS");
  227. int x = 55;
  228. int y = 30;
  229. canvas_draw_str_aligned(canvas, 10, y, AlignLeft, AlignTop, "Sound");
  230. canvas_draw_circle(canvas, x, y + 3, 4);
  231. if(pb->settings.sound_enabled) {
  232. canvas_draw_disc(canvas, x, y + 3, 2);
  233. }
  234. if(pb->settings.selected_setting == 0) {
  235. canvas_draw_triangle(canvas, 2, y + 3, 8, 5, CanvasDirectionLeftToRight);
  236. }
  237. y += 12;
  238. canvas_draw_str_aligned(canvas, 10, y, AlignLeft, AlignTop, "LED");
  239. canvas_draw_circle(canvas, x, y + 3, 4);
  240. if(pb->settings.led_enabled) {
  241. canvas_draw_disc(canvas, x, y + 3, 2);
  242. }
  243. if(pb->settings.selected_setting == 1) {
  244. canvas_draw_triangle(canvas, 2, y + 3, 8, 5, CanvasDirectionLeftToRight);
  245. }
  246. y += 12;
  247. canvas_draw_str_aligned(canvas, 10, y, AlignLeft, AlignTop, "Vibrate");
  248. canvas_draw_circle(canvas, x, y + 3, 4);
  249. if(pb->settings.vibrate_enabled) {
  250. canvas_draw_disc(canvas, x, y + 3, 2);
  251. }
  252. if(pb->settings.selected_setting == 2) {
  253. canvas_draw_triangle(canvas, 2, y + 3, 8, 5, CanvasDirectionLeftToRight);
  254. }
  255. y += 12;
  256. canvas_draw_str_aligned(canvas, 10, y, AlignLeft, AlignTop, "Debug");
  257. canvas_draw_circle(canvas, x, y + 3, 4);
  258. if(pb->settings.debug_mode) {
  259. canvas_draw_disc(canvas, x, y + 3, 2);
  260. }
  261. if(pb->settings.selected_setting == 3) {
  262. canvas_draw_triangle(canvas, 2, y + 3, 8, 5, CanvasDirectionLeftToRight);
  263. }
  264. // About information
  265. canvas_draw_str_aligned(canvas, 2, 88, AlignLeft, AlignTop, "Pinball0 " VERSION);
  266. canvas_draw_str_aligned(canvas, 2, 98, AlignLeft, AlignTop, "github.com/");
  267. canvas_draw_str_aligned(canvas, 2, 108, AlignLeft, AlignTop, " rdefeo/");
  268. canvas_draw_str_aligned(canvas, 2, 118, AlignLeft, AlignTop, " pinball0");
  269. pb->table->draw(canvas);
  270. } break;
  271. default:
  272. FURI_LOG_E(TAG, "Unknown Game Mode");
  273. break;
  274. }
  275. furi_mutex_release(pb->mutex);
  276. }
  277. static void pinball_input_callback(InputEvent* input_event, void* ctx) {
  278. furi_assert(ctx);
  279. FuriMessageQueue* event_queue = (FuriMessageQueue*)ctx;
  280. PinballEvent event = {.type = EventTypeKey, .input = *input_event};
  281. furi_message_queue_put(event_queue, &event, FuriWaitForever);
  282. }
  283. PinballApp::~PinballApp() {
  284. furi_mutex_free(mutex);
  285. delete table;
  286. notify_free();
  287. }
  288. extern "C" int32_t pinball0_app(void* p) {
  289. UNUSED(p);
  290. PinballApp* app = (PinballApp*)new PinballApp;
  291. app->mutex = furi_mutex_alloc(FuriMutexTypeNormal);
  292. if(!app->mutex) {
  293. FURI_LOG_E(TAG, "Cannot create mutex!");
  294. delete app;
  295. return 0;
  296. }
  297. pinball_app_init(app);
  298. // read the list of tables from storage
  299. table_table_list_init(app);
  300. // load the table select table
  301. table_load_table(app, 0);
  302. FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PinballEvent));
  303. furi_timer_set_thread_priority(FuriTimerThreadPriorityElevated);
  304. ViewPort* view_port = view_port_alloc();
  305. view_port_set_orientation(view_port, ViewPortOrientationVertical);
  306. view_port_draw_callback_set(view_port, pinball_draw_callback, app);
  307. view_port_input_callback_set(view_port, pinball_input_callback, event_queue);
  308. // Open the GUI and register view_port
  309. Gui* gui = (Gui*)furi_record_open(RECORD_GUI);
  310. gui_add_view_port(gui, view_port, GuiLayerFullscreen);
  311. notification_message(app->notify, &sequence_display_backlight_enforce_on);
  312. // TODO: Dolphin deed actions
  313. // dolphin_deed(DolphinDeedPluginGameStart);
  314. app->processing = true;
  315. float dt = 0.0f;
  316. uint32_t last_frame_time = furi_get_tick();
  317. app->idle_start = last_frame_time;
  318. // I'm not thrilled with this event loop - kinda messy but it'll do for now
  319. PinballEvent event;
  320. while(app->processing) {
  321. FuriStatus event_status = furi_message_queue_get(event_queue, &event, 10);
  322. furi_mutex_acquire(app->mutex, FuriWaitForever);
  323. if(event_status == FuriStatusOk) {
  324. if(event.type == EventTypeKey) {
  325. if(event.input.type == InputTypePress || event.input.type == InputTypeLong ||
  326. event.input.type == InputTypeRepeat) {
  327. switch(event.input.key) {
  328. case InputKeyBack:
  329. if(app->game_mode == GM_Playing || app->game_mode == GM_GameOver ||
  330. app->game_mode == GM_Error || app->game_mode == GM_Settings) {
  331. if(app->game_mode == GM_Settings) {
  332. pinball_save_settings(app);
  333. }
  334. app->game_mode = GM_TableSelect;
  335. table_load_table(app, TABLE_SELECT);
  336. } else if(app->game_mode == GM_TableSelect) {
  337. app->processing = false;
  338. }
  339. break;
  340. case InputKeyRight: {
  341. app->keys[InputKeyRight] = true;
  342. if(app->settings.debug_mode && app->table->balls_released == false) {
  343. app->table->balls[0].p.x += MANUAL_ADJUSTMENT;
  344. app->table->balls[0].prev_p.x += MANUAL_ADJUSTMENT;
  345. }
  346. bool flipper_pressed = false;
  347. for(auto& f : app->table->flippers) {
  348. if(f.side == Flipper::RIGHT) {
  349. f.powered = true;
  350. flipper_pressed = true;
  351. }
  352. }
  353. if(flipper_pressed) {
  354. notify_flipper(app);
  355. }
  356. } break;
  357. case InputKeyLeft: {
  358. app->keys[InputKeyLeft] = true;
  359. if(app->settings.debug_mode && app->table->balls_released == false) {
  360. app->table->balls[0].p.x -= MANUAL_ADJUSTMENT;
  361. app->table->balls[0].prev_p.x -= MANUAL_ADJUSTMENT;
  362. }
  363. bool flipper_pressed = false;
  364. for(auto& f : app->table->flippers) {
  365. if(f.side == Flipper::LEFT) {
  366. f.powered = true;
  367. if(f.rotation != f.max_rotation) {
  368. flipper_pressed = true;
  369. }
  370. }
  371. }
  372. if(flipper_pressed) {
  373. notify_flipper(app);
  374. }
  375. } break;
  376. case InputKeyUp:
  377. switch(app->game_mode) {
  378. case GM_Playing:
  379. if(event.input.type == InputTypePress) {
  380. // we only set the key if it's a 'press' to ensure
  381. // a single table "bump"
  382. app->keys[InputKeyUp] = true;
  383. notify_table_bump(app);
  384. }
  385. if(app->settings.debug_mode && app->table->balls_released == false) {
  386. app->table->balls[0].p.y -= MANUAL_ADJUSTMENT;
  387. app->table->balls[0].prev_p.y -= MANUAL_ADJUSTMENT;
  388. }
  389. break;
  390. case GM_TableSelect:
  391. app->table_list.selected = (app->table_list.selected - 1 +
  392. app->table_list.menu_items.size()) %
  393. app->table_list.menu_items.size();
  394. break;
  395. case GM_Settings:
  396. if(app->settings.selected_setting > 0) {
  397. app->settings.selected_setting--;
  398. }
  399. break;
  400. default:
  401. break;
  402. }
  403. break;
  404. case InputKeyDown:
  405. switch(app->game_mode) {
  406. case GM_Playing:
  407. app->keys[InputKeyDown] = true;
  408. if(app->settings.debug_mode && app->table->balls_released == false) {
  409. app->table->balls[0].p.y += MANUAL_ADJUSTMENT;
  410. app->table->balls[0].prev_p.y += MANUAL_ADJUSTMENT;
  411. }
  412. break;
  413. case GM_TableSelect:
  414. app->table_list.selected = (app->table_list.selected + 1 +
  415. app->table_list.menu_items.size()) %
  416. app->table_list.menu_items.size();
  417. // notify_game_over(app);
  418. break;
  419. case GM_Settings:
  420. if(app->settings.selected_setting < app->settings.max_settings - 1) {
  421. app->settings.selected_setting++;
  422. }
  423. break;
  424. default:
  425. break;
  426. }
  427. break;
  428. case InputKeyOk:
  429. switch(app->game_mode) {
  430. case GM_Playing:
  431. if(!app->table->balls_released) {
  432. app->gameStarted = true;
  433. app->table->balls_released = true;
  434. notify_ball_released(app);
  435. }
  436. break;
  437. case GM_TableSelect: {
  438. size_t sel = app->table_list.selected;
  439. if(sel == app->table_list.menu_items.size() - 1) {
  440. app->game_mode = GM_Settings;
  441. table_load_table(app, TABLE_SETTINGS);
  442. } else if(!table_load_table(app, sel + TABLE_INDEX_OFFSET)) {
  443. app->game_mode = GM_Error;
  444. table_load_table(app, TABLE_ERROR);
  445. notify_error_message(app);
  446. } else {
  447. app->game_mode = GM_Playing;
  448. }
  449. } break;
  450. case GM_Settings:
  451. switch(app->settings.selected_setting) {
  452. case 0:
  453. app->settings.sound_enabled = !app->settings.sound_enabled;
  454. break;
  455. case 1:
  456. app->settings.led_enabled = !app->settings.led_enabled;
  457. break;
  458. case 2:
  459. app->settings.vibrate_enabled = !app->settings.vibrate_enabled;
  460. break;
  461. case 3:
  462. app->settings.debug_mode = !app->settings.debug_mode;
  463. break;
  464. default:
  465. break;
  466. }
  467. break;
  468. default:
  469. break;
  470. }
  471. break;
  472. default:
  473. break;
  474. }
  475. } else if(event.input.type == InputTypeRelease) {
  476. switch(event.input.key) {
  477. case InputKeyLeft: {
  478. app->keys[InputKeyLeft] = false;
  479. for(auto& f : app->table->flippers) {
  480. if(f.side == Flipper::LEFT) {
  481. f.powered = false;
  482. }
  483. }
  484. break;
  485. }
  486. case InputKeyRight: {
  487. app->keys[InputKeyRight] = false;
  488. for(auto& f : app->table->flippers) {
  489. if(f.side == Flipper::RIGHT) {
  490. f.powered = false;
  491. }
  492. }
  493. break;
  494. }
  495. case InputKeyUp:
  496. app->keys[InputKeyUp] = false;
  497. break;
  498. case InputKeyDown:
  499. app->keys[InputKeyDown] = false;
  500. // TODO: release plunger?
  501. break;
  502. default:
  503. break;
  504. }
  505. }
  506. // a key was pressed, reset idle counter
  507. app->idle_start = furi_get_tick();
  508. }
  509. }
  510. solve(app, dt);
  511. for(auto& o : app->table->objects) {
  512. o->step_animation();
  513. }
  514. // check game state
  515. // if(app->game_mode == GM_Playing && app->table->lives.value == 0) {
  516. if(app->game_mode != GM_GameOver && app->table->game_over) {
  517. FURI_LOG_W(TAG, "GAME OVER!");
  518. app->game_mode = GM_GameOver;
  519. notify_game_over(app);
  520. }
  521. // no keys pressed - we should clear all input keys?
  522. view_port_update(view_port);
  523. furi_mutex_release(app->mutex);
  524. // game timing + idle check
  525. uint32_t current_tick = furi_get_tick();
  526. if(current_tick - app->idle_start >= IDLE_TIMEOUT) {
  527. FURI_LOG_W(TAG, "Idle timeout! Exiting Pinball0...");
  528. app->processing = false;
  529. break;
  530. }
  531. uint32_t time_lapsed = current_tick - last_frame_time;
  532. dt = time_lapsed / 1000.0f;
  533. while(dt < 1.0f / GAME_FPS) {
  534. time_lapsed = furi_get_tick() - last_frame_time;
  535. dt = time_lapsed / 1000.0f;
  536. }
  537. app->tick++;
  538. last_frame_time = furi_get_tick();
  539. }
  540. // general cleanup
  541. notification_message(app->notify, &sequence_display_backlight_enforce_auto);
  542. notification_message(app->notify, &sequence_reset_rgb);
  543. view_port_enabled_set(view_port, false);
  544. gui_remove_view_port(gui, view_port);
  545. furi_record_close(RECORD_GUI);
  546. furi_record_close(RECORD_STORAGE);
  547. furi_record_close(RECORD_NOTIFICATION);
  548. view_port_free(view_port);
  549. furi_message_queue_free(event_queue);
  550. delete app;
  551. furi_timer_set_thread_priority(FuriTimerThreadPriorityNormal);
  552. return 0;
  553. }