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

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