You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.7 KiB

3 months ago
  1. #pragma once
  2. #include <stdint.h>
  3. #include <functional>
  4. #include "appevent_type.hpp"
  5. extern "C" {
  6. #include "uicontroler/tjc/tjc_base_type.h"
  7. #include "app_protocols/ble_through/ble_proto.h"
  8. }
  9. /**
  10. *
  11. * @ע
  12. * ׶󣬷ջ
  13. */
  14. // typedef struct {
  15. // } AppEvent;
  16. struct AcidStateChangeEvent {
  17. enum AcidStatChangeEventType subtype;
  18. // ����
  19. uint8_t addCh;
  20. float addChVal;
  21. // ʹ��
  22. float useVal[4];
  23. };
  24. typedef struct AcidStateChangeEvent AcidStateChangeEvent_t;
  25. typedef enum AcidStatChangeEventType AcidStatChangeEventType_t;
  26. class AppEvent {
  27. public:
  28. AppEventType_t type;
  29. std::function<void()> onfnc = nullptr;
  30. const char* onfncmask = nullptr;
  31. private:
  32. uint8_t buf[30];
  33. UIEvent* uieventpointer = nullptr;
  34. public:
  35. AppEvent() {
  36. static_assert(sizeof(buf) >= sizeof(AcidStateChangeEvent_t), "buf size must be larger than AcidStateChangeEvent_t");
  37. memset(buf, 0, sizeof(buf));
  38. }
  39. public:
  40. int getBufSize() { return sizeof(buf); }
  41. void setPageChangeTo(int32_t page) { *(int32_t*)buf = page; }
  42. int32_t getPageChangeTo() { return *(int32_t*)buf; }
  43. void setHeartInfo(uint8_t *heart_info) { memcpy(buf, heart_info, sizeof(zble_heart_t)); }
  44. uint8_t* getHeartInfo() { return (uint8_t *)buf; }
  45. void setStateDisplayInfo(const char* info) { strncpy((char*)buf, info, sizeof(buf)); }
  46. char* getStateDisplayInfo() { return (char*)buf; }
  47. UIEvent* getUIEvent() { return uieventpointer; }
  48. void setUIEvent(UIEvent* event) { uieventpointer = event; }
  49. AcidStateChangeEvent_t* getAcidStateChangeEvent() { return (AcidStateChangeEvent_t*)buf; }
  50. void setOnFnc(std::function<void()> fnc) { onfnc = fnc; }
  51. };