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.

91 lines
2.3 KiB

1 year ago
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stdint.h>
  4. #include "board/board.h"
  5. typedef enum {
  6. kplod_connected_event = 0, // ���������¼�
  7. kplod_disconnected_event, // �����Ͽ��¼�
  8. kplod_connecting_event, // �����������¼�
  9. kbattery_start_charge_event, // �����¼�
  10. kbattery_end_charge_event, // ���������¼�
  11. kevent_tmr_scheduler_event, // ��ʱ�������¼�
  12. kevent_capture_256data_event, // �������ݻص�
  13. kevent_capture_little_data_block_event, // ���β������ݻص�
  14. } app_event_type_t;
  15. typedef struct {
  16. uint16_t data;
  17. } one_frame_data_t;
  18. typedef struct {
  19. app_event_type_t eventType;
  20. union {
  21. uint32_t plod_connected_accumulation_time; // ���������ۼ�ʱ��
  22. uint8_t* capture_data_cache; // ʵʱ�������ݣ����ݳ���Ϊ256�ֽ�
  23. struct {
  24. uint32_t frameIndex;
  25. one_frame_data_t data[LITTLE_DATA_BLOCK_FRAME_NUM];
  26. } little_data_block;
  27. } val;
  28. } app_event_t;
  29. typedef enum {
  30. // ����
  31. kdevice_state_standby = 0,
  32. // ����
  33. kdevice_state_poweron,
  34. // ��ҳ
  35. kdevice_state_home,
  36. // ��ʾ�û����־�ֹ
  37. kdevice_state_keep_still,
  38. // �ɼ���
  39. kdevice_state_sampling,
  40. // �ɼ�����
  41. kdevice_state_sampling_complete,
  42. // �ɼ��쳣
  43. kdevice_state_sampling_error,
  44. // ������
  45. kdevice_state_charging,
  46. } device_state_t;
  47. static const char* device_state_to_str(device_state_t ds) {
  48. switch (ds) {
  49. case kdevice_state_standby:
  50. return "standby";
  51. case kdevice_state_poweron:
  52. return "poweron";
  53. case kdevice_state_home:
  54. return "home";
  55. case kdevice_state_keep_still:
  56. return "keep_still";
  57. case kdevice_state_sampling:
  58. return "sampling";
  59. case kdevice_state_sampling_complete:
  60. return "sampling_complete";
  61. case kdevice_state_sampling_error:
  62. return "sampling_error";
  63. case kdevice_state_charging:
  64. return "charging";
  65. default:
  66. return "unknow";
  67. }
  68. }
  69. void app_event_process_cb(void* p_event_data, uint16_t event_size);
  70. void ds_change_to_state(device_state_t state);
  71. uint32_t ds_cur_state_haspassed_ms();
  72. device_state_t ds_now_state();
  73. typedef struct {
  74. bool is_over30s;
  75. } sample_capture_state_t;
  76. sample_capture_state_t* sample_capture_state_get();
  77. void sample_capture_state_reset();
  78. void sample_capture_state_set_is_over30s(bool over30s);