diff --git a/dts/bindings/pwm-servo.yaml b/dts/bindings/pwm-servo.yaml new file mode 100644 index 0000000..40638c8 --- /dev/null +++ b/dts/bindings/pwm-servo.yaml @@ -0,0 +1,24 @@ +# Copyright (c) 2022 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +description: PWM-driven servo motor. + +compatible: "pwm-servo" + +include: base.yaml + +properties: + pwms: + required: true + type: phandle-array + description: PWM specifier driving the servo motor. + + min-pulse: + required: true + type: int + description: Minimum pulse width (nanoseconds). + + max-pulse: + required: true + type: int + description: Maximum pulse width (nanoseconds). diff --git a/include/ntc.hpp b/include/ntc.hpp index c337534..3e2630d 100644 --- a/include/ntc.hpp +++ b/include/ntc.hpp @@ -3,6 +3,7 @@ #include #include #include +#include #include namespace ther { @@ -15,16 +16,22 @@ public: bool found = false; sensor_value max_val{}; - for (const auto *dev : s_devices) { + for (size_t i = 0; i < NTC_COUNT; ++i) { + const auto *dev = s_devices[i]; + if (0 != sensor_sample_fetch(dev)) { + printk("[ntc] #%zu ERR fetch\n", i + 1); continue; } sensor_value val{}; if (0 != sensor_channel_get(dev, SENSOR_CHAN_AMBIENT_TEMP, &val)) { + printk("[ntc] #%zu ERR channel_get\n", i + 1); continue; } + printk("[ntc]#%zu = %d.%d°C\n", i + 1, val.val1, val.val2); + if (!found || val.val1 > max_val.val1 || (val.val1 == max_val.val1 && val.val2 > max_val.val2)) { max_val = val; @@ -40,6 +47,8 @@ public: } private: + static constexpr size_t NTC_COUNT = 8; + inline static const device *s_devices[] = { DEVICE_DT_GET(DT_NODELABEL(pole_ntc1)), DEVICE_DT_GET(DT_NODELABEL(pole_ntc2)), diff --git a/src/main.cpp b/src/main.cpp index 07dfe35..4a681fd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,6 +26,7 @@ auto GetmaxTemp() -> std::optional { if (0 == sensor_sample_fetch_chan(infrared, SENSOR_CHAN_AMBIENT_TEMP)) { if (0 == sensor_channel_get(infrared, SENSOR_CHAN_AMBIENT_TEMP, &ir_val)) { + printk("[ir] = %d.%d°C\n", ir_val.val1, ir_val.val2); if (!found || ir_val.val1 > max_val.val1 || (ir_val.val1 == max_val.val1 && ir_val.val2 > max_val.val2)) { max_val = ir_val; @@ -40,11 +41,10 @@ auto GetmaxTemp() -> std::optional { } // namespace auto main(void) -> int { using namespace std::chrono_literals; - printk("app on board %s", CONFIG_BOARD); + printk("app on board %s\n", CONFIG_BOARD); // auto wdt = app::WatchDogConfig{}; StatusLed::Flash(1s); ther::Com::Init(); - // ther::HeatingPad::Start(); ther::HeatingPad::Start(sensor_value{42, 0}); sensor_trigger tri{.type = SENSOR_TRIG_DATA_READY, .chan = SENSOR_CHAN_AMBIENT_TEMP}; @@ -56,8 +56,7 @@ auto main(void) -> int { if (auto v = GetmaxTemp(); v.has_value()) { ther::Com::Send(v.value()); } + k_sleep(K_MSEC(20)); } - // wdt.Feed(); - k_sleep(K_MSEC(20)); return 0; }