notification.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #pragma once
  2. #include "stdint.h"
  3. #include "stdbool.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. typedef struct NotificationApp NotificationApp;
  8. typedef struct {
  9. float frequency;
  10. float pwm;
  11. } NotificationMessageDataSound;
  12. typedef struct {
  13. uint8_t value;
  14. } NotificationMessageDataLed;
  15. typedef struct {
  16. bool on;
  17. } NotificationMessageDataVibro;
  18. typedef struct {
  19. uint32_t length;
  20. } NotificationMessageDataDelay;
  21. typedef union {
  22. NotificationMessageDataSound sound;
  23. NotificationMessageDataLed led;
  24. NotificationMessageDataVibro vibro;
  25. NotificationMessageDataDelay delay;
  26. } NotificationMessageData;
  27. typedef enum {
  28. NotificationMessageTypeVibro,
  29. NotificationMessageTypeSoundOn,
  30. NotificationMessageTypeSoundOff,
  31. NotificationMessageTypeLedRed,
  32. NotificationMessageTypeLedGreen,
  33. NotificationMessageTypeLedBlue,
  34. NotificationMessageTypeDelay,
  35. NotificationMessageTypeLedDisplay,
  36. NotificationMessageTypeDoNotReset,
  37. } NotificationMessageType;
  38. typedef struct {
  39. NotificationMessageType type;
  40. NotificationMessageData data;
  41. } NotificationMessage;
  42. typedef const NotificationMessage* NotificationSequence[];
  43. void notification_message(NotificationApp* app, const NotificationSequence* sequence);
  44. void notification_message_block(NotificationApp* app, const NotificationSequence* sequence);
  45. /**
  46. * @brief Send internal (apply to permanent layer) notification message. Think twice before use.
  47. *
  48. * @param app notification record content
  49. * @param sequence notification sequence
  50. */
  51. void notification_internal_message(NotificationApp* app, const NotificationSequence* sequence);
  52. /**
  53. * @brief Send internal (apply to permanent layer) notification message and wait for notification end. Think twice before use.
  54. *
  55. * @param app notification record content
  56. * @param sequence notification sequence
  57. */
  58. void notification_internal_message_block(
  59. NotificationApp* app,
  60. const NotificationSequence* sequence);
  61. #ifdef __cplusplus
  62. }
  63. #endif