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.

92 lines
2.3 KiB

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