全司美特-单片机程序
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.

71 lines
1.5 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. #include <stddef.h>
  2. #include <stdio.h>
  3. #include "base/config_service.hpp"
  4. #include "base/device_info.hpp"
  5. #include "zstm32/zstm32.hpp"
  6. #include "zsdk/modbus/modbus_block_host.hpp"
  7. #include "zsdk/pxx_pressure_sensor_driver/pxx_pressure_sensor_bus.hpp"
  8. #include "zsdk/tmc/ztmc5130.hpp"
  9. #include "zsdk/zsdk.hpp"
  10. void hardware_init();
  11. namespace iflytop {
  12. class Hardware {
  13. public:
  14. ZGPIO m_evaporation_bin_water_sensor; // 蒸发仓水浸
  15. ZGPIO m_device_bottom_water_sensor; // 设备底部水浸
  16. ZSPI m_motor_spi; // SPI
  17. TMC5130 m_motor[2]; // 蠕动泵控制
  18. ZGPIO triLight_R;
  19. ZGPIO triLight_G;
  20. ZGPIO triLight_B;
  21. ZGPIO triLight_BEEP;
  22. ModbusBlockHost m_modbusBlockHost; //
  23. PXXPressureSensorBus m_pressureSensorBus; // PXX压力传感器总线
  24. public:
  25. static Hardware& ins() {
  26. static Hardware ins;
  27. return ins;
  28. }
  29. void init();
  30. int32_t motorNum() { return ZARRAY_SIZE(m_motor); }
  31. TMC5130* motor(int32_t index) {
  32. if (index < ZARRAY_SIZE(m_motor)) {
  33. return &m_motor[index];
  34. }
  35. return nullptr;
  36. }
  37. PXXPressureSensorBus* pressureSensorBus() { return &m_pressureSensorBus; }
  38. void setRGB(int32_t r, int32_t g, int32_t b, int32_t beep) {
  39. if (r > 0)
  40. triLight_R.write(1);
  41. else
  42. triLight_R.write(0);
  43. if (g > 0)
  44. triLight_G.write(1);
  45. else
  46. triLight_G.write(0);
  47. if (b > 0)
  48. triLight_B.write(1);
  49. else
  50. triLight_B.write(0);
  51. if (beep > 0)
  52. triLight_BEEP.write(1);
  53. else
  54. triLight_BEEP.write(0);
  55. }
  56. };
  57. } // namespace iflytop