基质喷涂
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.

132 lines
2.5 KiB

  1. #pragma once
  2. #include "can_control/can_controller.h"
  3. #include "LED/pump_controller.h"
  4. #include "LED/air_valve.h"
  5. #include "LED/three_way_valve.h"
  6. #include "LED/high_voltage_pack.h"
  7. #include "LED/laser_control.h"
  8. #include "zgpio.hpp"
  9. #include "appcfg.h"
  10. #include "stm32components.hpp"
  11. #include "uart_control/uart_control.h"
  12. namespace iflytop {
  13. class ID {
  14. public:
  15. ZGPIO ID0;
  16. ZGPIO ID1;
  17. ZGPIO ID2;
  18. ZGPIO ID3;
  19. ZGPIO ID4;
  20. };
  21. class AppHardware {
  22. private:
  23. /* data */
  24. public:
  25. ZGPIO MOTO_POWER_EN;
  26. ZGPIO MOTO1_CSN;
  27. ZGPIO MOTO2_CSN;
  28. ZGPIO MOTO3_CSN;
  29. ZGPIO MOTO4_CSN;
  30. ZGPIO MOTO1_DRV_ENN;
  31. ZGPIO MOTO2_DRV_ENN;
  32. ZGPIO MOTO3_DRV_ENN;
  33. ZGPIO MOTO4_DRV_ENN;
  34. ZGPIO MOTOR1_REF_L;
  35. ZGPIO MOTOR1_REF_R;
  36. ZGPIO MOTOR2_REF_L;
  37. ZGPIO MOTOR2_REF_R;
  38. ZGPIO MOTOR3_REF_L;
  39. ZGPIO MOTOR3_REF_R;
  40. ZGPIO MOTOR4_REF_L;
  41. ZGPIO MOTOR4_REF_R;
  42. TMC51X0 MOTO1;
  43. TMC51X0 MOTO2;
  44. TMC51X0 MOTO3;
  45. // TMC51X0 MOTO4;
  46. ID id;
  47. ZGPIO IO_OUT1;
  48. ZGPIO IO_OUT2;
  49. ZGPIO BLE_CONNECTED_STATE;
  50. UART_HandleTypeDef* tjcUart;
  51. ZGPIO TJC_UART_CH_SEL;
  52. ZGPIO TJC_UART_CH_EN;
  53. UART_HandleTypeDef* remoteContolerUart;
  54. #if CAN_MODULE_ENABLE
  55. CanController can0Controller; // CAN 收发控制
  56. #endif
  57. UartControl uart_control;
  58. AirValve valve_controller; // 阀门控制
  59. ThreeWayValve three_way_valve; // 三通阀控制
  60. PumpController pump_controller; // 电机泵
  61. HighVoltagePack high_voltage_pack; // 注射泵
  62. LaserControl laser_control; // 激光
  63. bool hardwareInitedOK = false;
  64. static AppHardware* ins() {
  65. static AppHardware instance;
  66. return &instance;
  67. }
  68. AppHardware();
  69. void initialize();
  70. TMC51X0* getPump(int32_t index) {
  71. if (index == 0) return &MOTO1;
  72. if (index == 1) return &MOTO2;
  73. if (index == 2) return &MOTO3;
  74. ZASSERT(false);
  75. return nullptr;
  76. }
  77. bool isHardInitOk();
  78. void SystemPowerOn();
  79. void SystemPowerOff(bool is_force = false);
  80. void setTJCScreenInDownloadMode();
  81. void setE_Stop(bool isE_Stop);
  82. bool isE_Stop();
  83. void toggleLaunched();
  84. bool isLaunched();
  85. bool isStarted();
  86. void setFlowSpeed(uint16_t flowSpeed);
  87. void setHumidity(int16_t humidity);
  88. void setTemp(int16_t temp);
  89. uint16_t getFlowSpeed();
  90. int16_t getHumidity();
  91. int16_t getTemp();
  92. private:
  93. bool isLaunched_ { false };
  94. bool isE_Stop_ { false };
  95. bool isStarted_;
  96. osMutexId_t mutex_; // 锁
  97. uint16_t flowSpeed_; // 流速
  98. int16_t humidity_; // 湿度
  99. int16_t temp_; // 温度
  100. };
  101. } // namespace iflytop