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
72 lines
1.5 KiB
#include <stddef.h>
|
|
#include <stdio.h>
|
|
|
|
#include "base/config_service.hpp"
|
|
#include "base/device_info.hpp"
|
|
#include "spi.h"
|
|
#include "usart.h"
|
|
#include "zsdk/modbus/modbus_block_host.hpp"
|
|
#include "zsdk/pxx_pressure_sensor_driver/pxx_pressure_sensor_bus.hpp"
|
|
#include "zsdk/tmc/ztmc5130.hpp"
|
|
#include "zsdk/zsdk.hpp"
|
|
|
|
void hardware_init();
|
|
|
|
namespace iflytop {
|
|
class Hardware {
|
|
public:
|
|
ZGPIO m_evaporation_bin_water_sensor; // 蒸发仓水浸
|
|
ZGPIO m_device_bottom_water_sensor; // 设备底部水浸
|
|
|
|
ZSPI m_motor_spi; // SPI
|
|
TMC5130 m_motor[2]; // 蠕动泵控制
|
|
|
|
ZGPIO triLight_R;
|
|
ZGPIO triLight_G;
|
|
ZGPIO triLight_B;
|
|
ZGPIO triLight_BEEP;
|
|
|
|
ModbusBlockHost m_modbusBlockHost; //
|
|
PXXPressureSensorBus m_pressureSensorBus; // PXX压力传感器总线
|
|
|
|
public:
|
|
static Hardware& ins() {
|
|
static Hardware ins;
|
|
return ins;
|
|
}
|
|
|
|
void init();
|
|
|
|
int32_t motorNum() { return ZARRAY_SIZE(m_motor); }
|
|
TMC5130* motor(int32_t index) {
|
|
if (index < ZARRAY_SIZE(m_motor)) {
|
|
return &m_motor[index];
|
|
}
|
|
return nullptr;
|
|
}
|
|
PXXPressureSensorBus* pressureSensorBus() { return &m_pressureSensorBus; }
|
|
|
|
void setRGB(int32_t r, int32_t g, int32_t b, int32_t beep) {
|
|
if (r > 0)
|
|
triLight_R.write(1);
|
|
else
|
|
triLight_R.write(0);
|
|
|
|
if (g > 0)
|
|
triLight_G.write(1);
|
|
else
|
|
triLight_G.write(0);
|
|
|
|
if (b > 0)
|
|
triLight_B.write(1);
|
|
else
|
|
triLight_B.write(0);
|
|
|
|
if (beep > 0)
|
|
triLight_BEEP.write(1);
|
|
else
|
|
triLight_BEEP.write(0);
|
|
}
|
|
};
|
|
|
|
} // namespace iflytop
|