diff --git a/.cproject b/.cproject
index 0940674..1eb10ee 100644
--- a/.cproject
+++ b/.cproject
@@ -30,7 +30,7 @@
-
+
@@ -66,12 +66,12 @@
-
+
-
+
-
-
+
+
diff --git a/usrc/app_main.cpp b/usrc/app_main.cpp
index 49c1442..8e1c6df 100644
--- a/usrc/app_main.cpp
+++ b/usrc/app_main.cpp
@@ -12,6 +12,7 @@
//
#include "base/protocol_processer_mgr.hpp"
#include "protocol_processer_impl/public_cmd_processer.hpp"
+#include "version.hpp"
//
#define TAG "main"
diff --git a/usrc/module/heater_controller.cpp b/usrc/module/heater_controller.cpp
new file mode 100644
index 0000000..50865f4
--- /dev/null
+++ b/usrc/module/heater_controller.cpp
@@ -0,0 +1,67 @@
+#include "heater_controller.hpp"
+
+#include "base/appdep.hpp"
+using namespace iflytop;
+using namespace transmit_disfection_protocol;
+
+void HeaterController::initialize(Pin_t ctrlGpio, ADC_HandleTypeDef* iadc, uint32_t ich, ADC_HandleTypeDef* tadc, uint32_t tch) {
+ m_ctrlGpio.initAsOutput(ctrlGpio, kxs_gpio_nopull, true, false);
+ m_iAdc.initialize("heater-idac", iadc, ich);
+ m_tempAdc.initialize("heater-tadc", iadc, tch);
+ m_isInitialized = true;
+ AppPeriodTaskMgr::ins()->regTask("Heater-ADC", [this]() { periodTask(); }, 1000);
+
+ BIND_FN(HeaterController, this, fn_heater_ctrl);
+ BIND_FN(HeaterController, this, fn_heater_ctrl_safe_valve);
+ BIND_FN(HeaterController, this, fn_heater_read_ei);
+ BIND_FN(HeaterController, this, fn_heater_read_temperature_data);
+ BIND_FN(HeaterController, this, fn_heater_read_ei_adc_raw);
+ BIND_FN(HeaterController, this, fn_heater_read_temperature_data_adc_raw);
+ BIND_FN(HeaterController, this, fn_heater_is_open);
+}
+
+bool HeaterController::isInitialized() { return m_isInitialized; }
+
+void HeaterController::heater_ctrl(int32_t val) { m_ctrlGpio.write(val); }
+void HeaterController::heater_ctrl_safe_valve(int32_t val) {}
+int32_t HeaterController::heater_read_temperature_data() { return heaterAdc2Temp(m_tempAdc.getCacheVal()); }
+int32_t HeaterController::heater_read_ei() { return hearterAdcToCurrent(m_iAdc.getCacheVal()); }
+int32_t HeaterController::heater_read_iadc() { return m_iAdc.getCacheVal(); }
+int32_t HeaterController::heater_read_tadc() { return m_tempAdc.getCacheVal(); }
+
+// PP
+void HeaterController::fn_heater_ctrl(ProcessContext* cxt) { //
+ heater_ctrl(GET_PARAM(0));
+ zcanbus_send_ack(cxt->packet, NULL, 0);
+}
+void HeaterController::fn_heater_ctrl_safe_valve(ProcessContext* cxt) { //
+ heater_ctrl_safe_valve(GET_PARAM(0));
+ zcanbus_send_ack(cxt->packet, NULL, 0);
+}
+void HeaterController::fn_heater_read_ei(ProcessContext* cxt) { //
+ auto val = heater_read_ei();
+ zcanbus_send_ack(cxt->packet, (uint8_t*)&val, sizeof(val));
+}
+void HeaterController::fn_heater_read_temperature_data(ProcessContext* cxt) { //
+ auto val = heater_read_temperature_data();
+
+ zcanbus_send_ack(cxt->packet, (uint8_t*)&val, sizeof(val));
+}
+
+void HeaterController::fn_heater_read_ei_adc_raw(ProcessContext* cxt) { //
+ auto val = m_iAdc.getCacheVal();
+ zcanbus_send_ack(cxt->packet, (uint8_t*)&val, sizeof(val));
+}
+
+void HeaterController::fn_heater_read_temperature_data_adc_raw(ProcessContext* cxt) { //
+ auto val = m_tempAdc.getCacheVal();
+ zcanbus_send_ack(cxt->packet, (uint8_t*)&val, sizeof(val));
+}
+void HeaterController::fn_heater_is_open(ProcessContext* cxt) { //
+ zcanbus_send_ack(cxt->packet, m_ctrlGpio.read());
+}
+
+void HeaterController::periodTask() {
+ m_iAdc.updateAdcValToCache();
+ m_tempAdc.updateAdcValToCache();
+}
diff --git a/usrc/module/heater_controller.hpp b/usrc/module/heater_controller.hpp
index 192d6ba..0fb0469 100644
--- a/usrc/module/heater_controller.hpp
+++ b/usrc/module/heater_controller.hpp
@@ -11,67 +11,29 @@ class HeaterController {
bool m_isInitialized = false;
public:
- void initialize(Pin_t ctrlGpio, ADC_HandleTypeDef* iadc, uint32_t ich, ADC_HandleTypeDef* tadc, uint32_t tch) {
- m_ctrlGpio.initAsOutput(ctrlGpio, kxs_gpio_nopull, true, false);
- m_iAdc.initialize("heater-idac", iadc, ich);
- m_tempAdc.initialize("heater-tadc", iadc, tch);
- m_isInitialized = true;
- AppPeriodTaskMgr::ins()->regTask("Heater-ADC", [this]() { periodTask(); }, 1000);
+ void initialize(Pin_t ctrlGpio, ADC_HandleTypeDef* iadc, uint32_t ich, ADC_HandleTypeDef* tadc, uint32_t tch);
- BIND_FN(HeaterController, this, fn_heater_ctrl);
- BIND_FN(HeaterController, this, fn_heater_ctrl_safe_valve);
- BIND_FN(HeaterController, this, fn_heater_read_ei);
- BIND_FN(HeaterController, this, fn_heater_read_temperature_data);
- BIND_FN(HeaterController, this, fn_heater_read_ei_adc_raw);
- BIND_FN(HeaterController, this, fn_heater_read_temperature_data_adc_raw);
- BIND_FN(HeaterController, this, fn_heater_is_open);
- }
+ bool isInitialized();
- bool isInitialized() { return m_isInitialized; }
-
- void heater_ctrl(int32_t val) { m_ctrlGpio.write(val); }
- void heater_ctrl_safe_valve(int32_t val) {}
- int32_t heater_read_temperature_data() { return heaterAdc2Temp(m_tempAdc.getCacheVal()); }
- int32_t heater_read_ei() { return hearterAdcToCurrent(m_iAdc.getCacheVal()); }
- int32_t heater_read_iadc() { return m_iAdc.getCacheVal(); }
- int32_t heater_read_tadc() { return m_tempAdc.getCacheVal(); }
+ void heater_ctrl(int32_t val);
+ void heater_ctrl_safe_valve(int32_t val);
+ int32_t heater_read_temperature_data();
+ int32_t heater_read_ei();
+ int32_t heater_read_iadc();
+ int32_t heater_read_tadc();
// PP
- void fn_heater_ctrl(ProcessContext* cxt) { //
- heater_ctrl(GET_PARAM(0));
- zcanbus_send_ack(cxt->packet, NULL, 0);
- }
- void fn_heater_ctrl_safe_valve(ProcessContext* cxt) { //
- heater_ctrl_safe_valve(GET_PARAM(0));
- zcanbus_send_ack(cxt->packet, NULL, 0);
- }
- void fn_heater_read_ei(ProcessContext* cxt) { //
- auto val = heater_read_ei();
- zcanbus_send_ack(cxt->packet, (uint8_t*)&val, sizeof(val));
- }
- void fn_heater_read_temperature_data(ProcessContext* cxt) { //
- auto val = heater_read_temperature_data();
-
- zcanbus_send_ack(cxt->packet, (uint8_t*)&val, sizeof(val));
- }
+ void fn_heater_ctrl(ProcessContext* cxt);
+ void fn_heater_ctrl_safe_valve(ProcessContext* cxt);
+ void fn_heater_read_ei(ProcessContext* cxt);
+ void fn_heater_read_temperature_data(ProcessContext* cxt);
- void fn_heater_read_ei_adc_raw(ProcessContext* cxt) { //
- auto val = m_iAdc.getCacheVal();
- zcanbus_send_ack(cxt->packet, (uint8_t*)&val, sizeof(val));
- }
+ void fn_heater_read_ei_adc_raw(ProcessContext* cxt);
- void fn_heater_read_temperature_data_adc_raw(ProcessContext* cxt) { //
- auto val = m_tempAdc.getCacheVal();
- zcanbus_send_ack(cxt->packet, (uint8_t*)&val, sizeof(val));
- }
- void fn_heater_is_open(ProcessContext* cxt) { //
- zcanbus_send_ack(cxt->packet, m_ctrlGpio.read());
- }
+ void fn_heater_read_temperature_data_adc_raw(ProcessContext* cxt);
+ void fn_heater_is_open(ProcessContext* cxt);
private:
- void periodTask() {
- m_iAdc.updateAdcValToCache();
- m_tempAdc.updateAdcValToCache();
- }
+ void periodTask();
};
} // namespace iflytop
diff --git a/usrc/module/pxxpsbus.cpp b/usrc/module/pxxpsbus.cpp
new file mode 100644
index 0000000..868a318
--- /dev/null
+++ b/usrc/module/pxxpsbus.cpp
@@ -0,0 +1,91 @@
+#include "pxxpsbus.hpp"
+using namespace iflytop;
+using namespace transmit_disfection_protocol;
+
+void PXXPSBus::initialize(UART_HandleTypeDef* huart) {
+ psbus.init(huart);
+ m_isInitialized = true;
+
+ osTimerDef(reportTimer, onTimer);
+ reportTimerId = osTimerCreate(osTimer(reportTimer), osTimerPeriodic, this);
+
+ BIND_FN(PXXPSBus, this, fn_psbus_read_data);
+ BIND_FN(PXXPSBus, this, fn_psbus_scan);
+ BIND_FN(PXXPSBus, this, fn_psbus_start_report);
+ BIND_FN(PXXPSBus, this, fn_psbus_stop_report);
+}
+bool PXXPSBus::isInitialized() { return m_isInitialized; }
+
+void PXXPSBus::fn_psbus_read_data(ProcessContext* cxt) {
+ CHECK_PARAM_LEN(PRAAM_LEN(), 1);
+ int32_t index = GET_PARAM(0);
+
+ int16_t val = 0;
+ int32_t reportVal = 0;
+ bool suc = psbus.readData(index, &val);
+
+ reportVal = val;
+
+ if (suc) {
+ zcanbus_send_ack(cxt->packet, (uint8_t*)&reportVal, sizeof(reportVal));
+ } else {
+ zcanbus_send_errorack(cxt->packet, kerr_subdevice_offline);
+ }
+}
+void PXXPSBus::fn_psbus_scan(ProcessContext* cxt) {
+ auto* sensors = psbus.sensors;
+ int numSensor = psbus.sensorNum;
+
+ static ack_psbus_scan_t result;
+ memset(&result, 0, sizeof(result));
+ static_assert(ZARRAY_SIZE(result.sensor) == ZARRAY_SIZE(psbus.sensors));
+ result.numOnlineId = numSensor;
+ for (int i = 0; i < PXX_PRESSURE_SENSOR_NUM; i++) {
+ if (sensors[i].online) {
+ result.sensor[i].ptype = sensors[i].type;
+ result.sensor[i].subid = sensors[i].id;
+ result.sensor[i].isOnline = 1;
+ result.sensor[i].precision = sensors[i].p100_sensor_info.precision;
+ result.sensor[i].uint = sensors[i].p100_sensor_info.pressure_unit;
+ result.sensor[i].zero = sensors[i].p100_sensor_info.zero_point;
+ result.sensor[i].full = sensors[i].p100_sensor_info.range_full_point;
+ }
+ }
+ zcanbus_send_ack(cxt->packet, (uint8_t*)&result, sizeof(result));
+}
+
+void PXXPSBus::fn_psbus_start_report(ProcessContext* cxt) {
+ int period = GET_PARAM(0);
+ if (period < 100) period = 100;
+ osTimerStop(reportTimerId);
+ osTimerStart(reportTimerId, period);
+ zcanbus_send_ack(cxt->packet, nullptr, 0);
+}
+
+void PXXPSBus::fn_psbus_stop_report(ProcessContext* cxt) {
+ osTimerStop(reportTimerId);
+ zcanbus_send_ack(cxt->packet, nullptr, 0);
+}
+
+void PXXPSBus::onTimer(const void* tid) {
+ PXXPSBus* bus = (PXXPSBus*)pvTimerGetTimerID((TimerHandle_t)tid);
+ bus->onTimer();
+}
+void PXXPSBus::onTimer() {
+ int16_t val = 0;
+
+ static uint8_t report_buf[100];
+ report_pressure_data_t* reportData = (report_pressure_data_t*)report_buf;
+
+ reportData->sensorDataNum = 0;
+ for (int i = 0; i < PXX_PRESSURE_SENSOR_NUM; i++) {
+ if (psbus.sensors[i].online) {
+ psbus.readData(i, &val);
+ reportData->data[reportData->sensorDataNum].subid = psbus.sensors[i].id;
+ reportData->data[reportData->sensorDataNum].pressureVal = val;
+ reportData->sensorDataNum++;
+ }
+ }
+ zcanbus_send_report(kreport_pressure_data, (uint8_t*)reportData, //
+ sizeof(*reportData) + sizeof(reportData->data[0]) * reportData->sensorDataNum, 30);
+}
diff --git a/usrc/module/pxxpsbus.hpp b/usrc/module/pxxpsbus.hpp
index 20bd042..1193e98 100644
--- a/usrc/module/pxxpsbus.hpp
+++ b/usrc/module/pxxpsbus.hpp
@@ -9,94 +9,19 @@ class PXXPSBus {
osTimerId reportTimerId; // 压力传感器数值上报
public:
- void initialize(UART_HandleTypeDef* huart) {
- psbus.init(huart);
- m_isInitialized = true;
-
- osTimerDef(reportTimer, onTimer);
- reportTimerId = osTimerCreate(osTimer(reportTimer), osTimerPeriodic, this);
-
- BIND_FN(PXXPSBus, this, fn_psbus_read_data);
- BIND_FN(PXXPSBus, this, fn_psbus_scan);
- BIND_FN(PXXPSBus, this, fn_psbus_start_report);
- BIND_FN(PXXPSBus, this, fn_psbus_stop_report);
- }
- bool isInitialized() { return m_isInitialized; }
+ void initialize(UART_HandleTypeDef* huart);
+ bool isInitialized();
private:
- void fn_psbus_read_data(ProcessContext* cxt) {
- CHECK_PARAM_LEN(PRAAM_LEN(), 1);
- int32_t index = GET_PARAM(0);
-
- int16_t val = 0;
- int32_t reportVal = 0;
- bool suc = psbus.readData(index, &val);
-
- reportVal = val;
+ void fn_psbus_read_data(ProcessContext* cxt);
+ void fn_psbus_scan(ProcessContext* cxt);
- if (suc) {
- zcanbus_send_ack(cxt->packet, (uint8_t*)&reportVal, sizeof(reportVal));
- } else {
- zcanbus_send_errorack(cxt->packet, kerr_subdevice_offline);
- }
- }
- void fn_psbus_scan(ProcessContext* cxt) {
- auto* sensors = psbus.sensors;
- int numSensor = psbus.sensorNum;
+ void fn_psbus_start_report(ProcessContext* cxt);
- static ack_psbus_scan_t result;
- memset(&result, 0, sizeof(result));
- static_assert(ZARRAY_SIZE(result.sensor) == ZARRAY_SIZE(psbus.sensors));
- result.numOnlineId = numSensor;
- for (int i = 0; i < PXX_PRESSURE_SENSOR_NUM; i++) {
- if (sensors[i].online) {
- result.sensor[i].ptype = sensors[i].type;
- result.sensor[i].subid = sensors[i].id;
- result.sensor[i].isOnline = 1;
- result.sensor[i].precision = sensors[i].p100_sensor_info.precision;
- result.sensor[i].uint = sensors[i].p100_sensor_info.pressure_unit;
- result.sensor[i].zero = sensors[i].p100_sensor_info.zero_point;
- result.sensor[i].full = sensors[i].p100_sensor_info.range_full_point;
- }
- }
- zcanbus_send_ack(cxt->packet, (uint8_t*)&result, sizeof(result));
- }
-
- void fn_psbus_start_report(ProcessContext* cxt) {
- int period = GET_PARAM(0);
- if (period < 100) period = 100;
- osTimerStop(reportTimerId);
- osTimerStart(reportTimerId, period);
- zcanbus_send_ack(cxt->packet, nullptr, 0);
- }
-
- void fn_psbus_stop_report(ProcessContext* cxt) {
- osTimerStop(reportTimerId);
- zcanbus_send_ack(cxt->packet, nullptr, 0);
- }
+ void fn_psbus_stop_report(ProcessContext* cxt);
public:
- static void onTimer(const void* tid) {
- PXXPSBus* bus = (PXXPSBus*)pvTimerGetTimerID((TimerHandle_t)tid);
- bus->onTimer();
- }
- void onTimer() {
- int16_t val = 0;
-
- static uint8_t report_buf[100];
- report_pressure_data_t* reportData = (report_pressure_data_t*)report_buf;
-
- reportData->sensorDataNum = 0;
- for (int i = 0; i < PXX_PRESSURE_SENSOR_NUM; i++) {
- if (psbus.sensors[i].online) {
- psbus.readData(i, &val);
- reportData->data[reportData->sensorDataNum].subid = psbus.sensors[i].id;
- reportData->data[reportData->sensorDataNum].pressureVal = val;
- reportData->sensorDataNum++;
- }
- }
- zcanbus_send_report(kreport_pressure_data, (uint8_t*)reportData, //
- sizeof(*reportData) + sizeof(reportData->data[0]) * reportData->sensorDataNum, 30);
- }
+ static void onTimer(const void* tid);
+ void onTimer();
};
} // namespace iflytop
\ No newline at end of file
diff --git a/usrc/module/warning_light_driver.cpp b/usrc/module/warning_light_driver.cpp
new file mode 100644
index 0000000..34dfe53
--- /dev/null
+++ b/usrc/module/warning_light_driver.cpp
@@ -0,0 +1,61 @@
+#include "warning_light_driver.hpp"
+
+#include "base/appdep.hpp"
+
+using namespace iflytop;
+using namespace transmit_disfection_protocol;
+
+void WarningLightDriver::initialize(Pin_t r, Pin_t g, Pin_t b, Pin_t beep) {
+ triLight_R.initAsOutput(r, kxs_gpio_nopull, false, false);
+ triLight_G.initAsOutput(g, kxs_gpio_nopull, false, false);
+ triLight_B.initAsOutput(b, kxs_gpio_nopull, false, false);
+ triLight_BEEP.initAsOutput(beep, kxs_gpio_nopull, false, false);
+ m_isInitialized = true;
+ BIND_FN(WarningLightDriver, this, fn_triple_warning_light_ctl);
+ BIND_FN(WarningLightDriver, this, fn_triple_warning_light_read_state);
+}
+bool WarningLightDriver::isInitialized() { return m_isInitialized; }
+
+void WarningLightDriver::setRGBW(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);
+}
+
+void WarningLightDriver::fn_triple_warning_light_ctl(ProcessContext* cxt) {
+ CHECK_PARAM_LEN(PRAAM_LEN(), 4);
+
+ int32_t r = GET_PARAM(0);
+ int32_t g = GET_PARAM(1);
+ int32_t b = GET_PARAM(2);
+ int32_t warning = GET_PARAM(3);
+
+ ZLOGI("WarningLightDriver", "triple_warning_light_ctl: r:%d g:%d b:%d warning:%d", r, g, b, warning);
+ setRGBW(r, g, b, warning);
+ zcanbus_send_ack(cxt->packet, NULL, 0);
+}
+// kfn_triple_warning_light_read_state
+void WarningLightDriver::fn_triple_warning_light_read_state(ProcessContext* cxt) {
+ int32_t data[4] = {0};
+ data[0] = triLight_R.read();
+ data[1] = triLight_G.read();
+ data[2] = triLight_B.read();
+ data[3] = triLight_BEEP.read();
+ zcanbus_send_ack(cxt->packet, (uint8_t*)&data, sizeof(data));
+}
\ No newline at end of file
diff --git a/usrc/module/warning_light_driver.hpp b/usrc/module/warning_light_driver.hpp
index f1e1222..d83e187 100644
--- a/usrc/module/warning_light_driver.hpp
+++ b/usrc/module/warning_light_driver.hpp
@@ -12,60 +12,13 @@ class WarningLightDriver {
bool m_isInitialized = false;
public:
- void initialize(Pin_t r, Pin_t g, Pin_t b, Pin_t beep) {
- triLight_R.initAsOutput(r, kxs_gpio_nopull, false, false);
- triLight_G.initAsOutput(g, kxs_gpio_nopull, false, false);
- triLight_B.initAsOutput(b, kxs_gpio_nopull, false, false);
- triLight_BEEP.initAsOutput(beep, kxs_gpio_nopull, false, false);
- m_isInitialized = true;
- BIND_FN(WarningLightDriver, this, fn_triple_warning_light_ctl);
- BIND_FN(WarningLightDriver, this, fn_triple_warning_light_read_state);
- }
- bool isInitialized() { return m_isInitialized; }
+ void initialize(Pin_t r, Pin_t g, Pin_t b, Pin_t beep);
+ bool isInitialized();
- void setRGBW(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);
- }
+ void setRGBW(int32_t r, int32_t g, int32_t b, int32_t beep);
private:
- void fn_triple_warning_light_ctl(ProcessContext* cxt) {
- CHECK_PARAM_LEN(PRAAM_LEN(), 4);
-
- int32_t r = GET_PARAM(0);
- int32_t g = GET_PARAM(1);
- int32_t b = GET_PARAM(2);
- int32_t warning = GET_PARAM(3);
-
- ZLOGI("WarningLightDriver", "triple_warning_light_ctl: r:%d g:%d b:%d warning:%d", r, g, b, warning);
- setRGBW(r, g, b, warning);
- zcanbus_send_ack(cxt->packet, NULL, 0);
- }
- // kfn_triple_warning_light_read_state
- void fn_triple_warning_light_read_state(ProcessContext* cxt) {
- int32_t data[4] = {0};
- data[0] = triLight_R.read();
- data[1] = triLight_G.read();
- data[2] = triLight_B.read();
- data[3] = triLight_BEEP.read();
- zcanbus_send_ack(cxt->packet, (uint8_t*)&data, sizeof(data));
- }
+ void fn_triple_warning_light_ctl(ProcessContext* cxt);
+ void fn_triple_warning_light_read_state(ProcessContext* cxt);
};
} // namespace iflytop
\ No newline at end of file
diff --git a/usrc/module/water_sensor_mgr.cpp b/usrc/module/water_sensor_mgr.cpp
new file mode 100644
index 0000000..29602fc
--- /dev/null
+++ b/usrc/module/water_sensor_mgr.cpp
@@ -0,0 +1,22 @@
+#include "water_sensor_mgr.hpp"
+
+#include "base/appdep.hpp"
+
+using namespace iflytop;
+using namespace transmit_disfection_protocol;
+
+void WaterSensorMgr::initialize(Pin_t evaporationBinWSPin, Pin_t deviceBottomWSPin) {
+ evaporationBinWS.initAsInput(evaporationBinWSPin, kxs_gpio_nopull, kxs_gpio_no_irq, true /*mirror*/);
+ deviceBottomWS.initAsInput(deviceBottomWSPin, kxs_gpio_nopull, kxs_gpio_no_irq, true /*mirror*/);
+ m_isInitialized = true;
+}
+bool WaterSensorMgr::isInitialized() { return m_isInitialized; }
+
+void WaterSensorMgr::fn_evaporation_tank_water_sensor_read_state(ProcessContext* cxt) {
+ int32_t val = evaporationBinWS.read();
+ zcanbus_send_ack(cxt->packet, (uint8_t*)&val, sizeof(val));
+}
+void WaterSensorMgr::fn_device_bottom_water_sensor_read_state(ProcessContext* cxt) {
+ int32_t val = deviceBottomWS.read();
+ zcanbus_send_ack(cxt->packet, (uint8_t*)&val, sizeof(val));
+}
diff --git a/usrc/module/water_sensor_mgr.hpp b/usrc/module/water_sensor_mgr.hpp
index 7aaabd6..acf1335 100644
--- a/usrc/module/water_sensor_mgr.hpp
+++ b/usrc/module/water_sensor_mgr.hpp
@@ -10,20 +10,10 @@ class WaterSensorMgr {
bool m_isInitialized = false;
public:
- void initialize(Pin_t evaporationBinWSPin, Pin_t deviceBottomWSPin) {
- evaporationBinWS.initAsInput(evaporationBinWSPin, kxs_gpio_nopull, kxs_gpio_no_irq, true /*mirror*/);
- deviceBottomWS.initAsInput(deviceBottomWSPin, kxs_gpio_nopull, kxs_gpio_no_irq, true /*mirror*/);
- m_isInitialized = true;
- }
- bool isInitialized() { return m_isInitialized; }
+ void initialize(Pin_t evaporationBinWSPin, Pin_t deviceBottomWSPin);
+ bool isInitialized();
- void fn_evaporation_tank_water_sensor_read_state(ProcessContext* cxt) {
- int32_t val = evaporationBinWS.read();
- zcanbus_send_ack(cxt->packet, (uint8_t*)&val, sizeof(val));
- }
- void fn_device_bottom_water_sensor_read_state(ProcessContext* cxt) {
- int32_t val = deviceBottomWS.read();
- zcanbus_send_ack(cxt->packet, (uint8_t*)&val, sizeof(val));
- }
+ void fn_evaporation_tank_water_sensor_read_state(ProcessContext* cxt);
+ void fn_device_bottom_water_sensor_read_state(ProcessContext* cxt);
};
} // namespace iflytop
\ No newline at end of file