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.

79 lines
2.0 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 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. #include <stddef.h>
  2. #include <stdio.h>
  3. #include "base/config_service.hpp"
  4. #include "base/device_info.hpp"
  5. #include "usart.h"
  6. #include "zsdk/hmp110/hmp110.hpp"
  7. #include "zsdk/hpp272/hpp272.hpp"
  8. #include "zsdk/modbus/modbus_block_host.hpp"
  9. #include "zsdk/pxx_pressure_sensor_driver/pxx_pressure_sensor_bus.hpp"
  10. #include "zsdk/tmc/ztmc5130.hpp"
  11. #include "zsdk/zadc.hpp"
  12. #include "zsdk/zsdk.hpp"
  13. void hardware_init();
  14. namespace iflytop {
  15. typedef enum {
  16. kdisconnected,
  17. kconnected,
  18. kerror,
  19. } light_state_t;
  20. class Hardware {
  21. public:
  22. #ifdef H2O2_SENSOR_TYPE_HMP110
  23. ModbusBlockHost m_H2o2Sensor_ModbusBlockHost; //
  24. ZADC m_H2o2Sensor_H2O2Adc; // H2O2传感器控制
  25. HMP110 m_H2o2Sensor_HMP110; // H2O2传感器
  26. int32_t m_h2o2sensor_detectId = -1;
  27. #endif
  28. #ifdef H2O2_SENSOR_TYPE_HPP272
  29. ModbusBlockHost m_H2o2Sensor_ModbusBlockHost; //
  30. HPP272 m_H2o2Sensor_HPP272; // H2O2传感器
  31. int32_t m_h2o2sensor_detectId = -1;
  32. #endif
  33. ZGPIO m_alarmLightR;
  34. ZGPIO m_alarmLightG;
  35. ZGPIO m_alarmLightY;
  36. ZGPIO m_switch_group0; // 拨码开关
  37. ZGPIO m_switch_group1; // 拨码开关
  38. ZGPIO m_switch_group2; // 拨码开关
  39. ZGPIO m_switch_group3; // 拨码开关
  40. ZGPIO m_switch_group4; // 拨码开关
  41. ZGPIO id_from_machine; // 消毒机上的开关
  42. light_state_t m_alarmLightState = kdisconnected;
  43. public:
  44. static Hardware& ins() {
  45. static Hardware ins;
  46. return ins;
  47. }
  48. void init();
  49. int32_t readSwitchGroup();
  50. void setAlarmLight(bool r, bool g, bool y);
  51. void setAlarmLight(light_state_t state);
  52. bool h2o2_sensor_is_online();
  53. int32_t h2o2_sensor_read_calibration_date(int32_t* year, int32_t* month, int32_t* day);
  54. int32_t h2o2_sensor_read_sub_ic_errorcode();
  55. int32_t h2o2_sensor_read_sub_ic_reg(int32_t add, uint16_t* val, size_t len);
  56. int32_t h2o2_sensor_data(report_h2o2_data_t* sensorData);
  57. public:
  58. void onH2O2CaptureThread();
  59. void onAlarmLightThread();
  60. };
  61. } // namespace iflytop