mine_sweeper_led.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #include "mine_sweeper_led.h"
  2. #include "../minesweeper.h"
  3. void mine_sweeper_led_set_rgb(void* context, int red, int green, int blue) {
  4. MineSweeperApp* app = context;
  5. NotificationMessage notification_led_message_1;
  6. notification_led_message_1.type = NotificationMessageTypeLedRed;
  7. NotificationMessage notification_led_message_2;
  8. notification_led_message_2.type = NotificationMessageTypeLedGreen;
  9. NotificationMessage notification_led_message_3;
  10. notification_led_message_3.type = NotificationMessageTypeLedBlue;
  11. notification_led_message_1.data.led.value = red;
  12. notification_led_message_2.data.led.value = green;
  13. notification_led_message_3.data.led.value = blue;
  14. const NotificationSequence notification_sequence = {
  15. &notification_led_message_1,
  16. &notification_led_message_2,
  17. &notification_led_message_3,
  18. &message_do_not_reset,
  19. NULL,
  20. };
  21. notification_message(app->notification, &notification_sequence);
  22. furi_thread_flags_wait(
  23. 0, FuriFlagWaitAny, 10); //Delay, prevent removal from RAM before LED value set
  24. }
  25. void mine_sweeper_led_blink_red(void* context) {
  26. furi_assert(context);
  27. MineSweeperApp* app = context;
  28. notification_message(app->notification, &sequence_blink_red_100);
  29. furi_thread_flags_wait(
  30. 0, FuriFlagWaitAny, 10); //Delay, prevent removal from RAM before LED value set
  31. }
  32. void mine_sweeper_led_blink_magenta(void* context) {
  33. furi_assert(context);
  34. MineSweeperApp* app = context;
  35. notification_message(app->notification, &sequence_blink_magenta_100);
  36. furi_thread_flags_wait(
  37. 0, FuriFlagWaitAny, 10); //Delay, prevent removal from RAM before LED value set
  38. }
  39. void mine_sweeper_led_blink_cyan(void* context) {
  40. furi_assert(context);
  41. MineSweeperApp* app = context;
  42. notification_message(app->notification, &sequence_blink_cyan_100);
  43. furi_thread_flags_wait(
  44. 0, FuriFlagWaitAny, 10); //Delay, prevent removal from RAM before LED value set
  45. }
  46. void mine_sweeper_led_reset(void* context) {
  47. MineSweeperApp* app = context;
  48. notification_message(app->notification, &sequence_reset_red);
  49. notification_message(app->notification, &sequence_reset_green);
  50. notification_message(app->notification, &sequence_reset_blue);
  51. furi_thread_flags_wait(
  52. 0, FuriFlagWaitAny, 300); //Delay, prevent removal from RAM before LED value set
  53. }