notification.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. NotificationMessageTypeDoNotReset,
  43. NotificationMessageTypeForceSpeakerVolumeSetting,
  44. NotificationMessageTypeForceVibroSetting,
  45. NotificationMessageTypeForceDisplayBrightnessSetting,
  46. } NotificationMessageType;
  47. typedef struct {
  48. NotificationMessageType type;
  49. NotificationMessageData data;
  50. } NotificationMessage;
  51. typedef const NotificationMessage* NotificationSequence[];
  52. void notification_message(NotificationApp* app, const NotificationSequence* sequence);
  53. void notification_message_block(NotificationApp* app, const NotificationSequence* sequence);
  54. /**
  55. * @brief Send internal (apply to permanent layer) notification message. Think twice before use.
  56. *
  57. * @param app notification record content
  58. * @param sequence notification sequence
  59. */
  60. void notification_internal_message(NotificationApp* app, const NotificationSequence* sequence);
  61. /**
  62. * @brief Send internal (apply to permanent layer) notification message and wait for notification end. Think twice before use.
  63. *
  64. * @param app notification record content
  65. * @param sequence notification sequence
  66. */
  67. void notification_internal_message_block(
  68. NotificationApp* app,
  69. const NotificationSequence* sequence);
  70. #ifdef __cplusplus
  71. }
  72. #endif