notification.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 struct {
  22. float speaker_volume;
  23. bool vibro;
  24. float display_brightness;
  25. } NotificationMessageDataForcedSettings;
  26. typedef union {
  27. NotificationMessageDataSound sound;
  28. NotificationMessageDataLed led;
  29. NotificationMessageDataVibro vibro;
  30. NotificationMessageDataDelay delay;
  31. NotificationMessageDataForcedSettings forced_settings;
  32. } NotificationMessageData;
  33. typedef enum {
  34. NotificationMessageTypeVibro,
  35. NotificationMessageTypeSoundOn,
  36. NotificationMessageTypeSoundOff,
  37. NotificationMessageTypeLedRed,
  38. NotificationMessageTypeLedGreen,
  39. NotificationMessageTypeLedBlue,
  40. NotificationMessageTypeDelay,
  41. NotificationMessageTypeLedDisplay,
  42. NotificationMessageTypeLedDisplayLock,
  43. NotificationMessageTypeLedDisplayUnlock,
  44. NotificationMessageTypeDoNotReset,
  45. NotificationMessageTypeForceSpeakerVolumeSetting,
  46. NotificationMessageTypeForceVibroSetting,
  47. NotificationMessageTypeForceDisplayBrightnessSetting,
  48. } NotificationMessageType;
  49. typedef struct {
  50. NotificationMessageType type;
  51. NotificationMessageData data;
  52. } NotificationMessage;
  53. typedef const NotificationMessage* NotificationSequence[];
  54. void notification_message(NotificationApp* app, const NotificationSequence* sequence);
  55. void notification_message_block(NotificationApp* app, const NotificationSequence* sequence);
  56. /**
  57. * @brief Send internal (apply to permanent layer) notification message. Think twice before use.
  58. *
  59. * @param app notification record content
  60. * @param sequence notification sequence
  61. */
  62. void notification_internal_message(NotificationApp* app, const NotificationSequence* sequence);
  63. /**
  64. * @brief Send internal (apply to permanent layer) notification message and wait for notification end. Think twice before use.
  65. *
  66. * @param app notification record content
  67. * @param sequence notification sequence
  68. */
  69. void notification_internal_message_block(
  70. NotificationApp* app,
  71. const NotificationSequence* sequence);
  72. #ifdef __cplusplus
  73. }
  74. #endif