forked from EmbeddedTeam/app_photomagnetic
Add debug logging and fix minor issues
Add printk debug statements to NTC temperature sensor reading and IR temperature sensor reading. Change NTC loop to use index-based iteration. Fix missing newline in boot message. Remove unused watchdog and commented-out code.
This commit is contained in:
+10
-1
@@ -3,6 +3,7 @@
|
||||
#include <cmath>
|
||||
#include <zephyr/device.h>
|
||||
#include <zephyr/drivers/sensor.h>
|
||||
#include <zephyr/sys/printk.h>
|
||||
#include <zpp/result.hpp>
|
||||
|
||||
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)),
|
||||
|
||||
Reference in New Issue
Block a user