notification.h 2.5 KB

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