Skip to content

Commit

Permalink
Update og3 library, logging tweaks (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
chl33 authored Oct 19, 2024
1 parent 41b7869 commit 1fa4bcb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
20 changes: 11 additions & 9 deletions lib/watering/watering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ void Watering::loop() {
} else if (m_moisture.readingIsFailed()) {
setState(kStateDisabled, 1, "failed reading moisture sensor");
} else if (m_moisture.filteredValue() < kMinPlausibleMoisture) {
log()->logf("Moisture sensor reading is too low (%.1f < %.1f).", m_moisture.filteredValue(),
kMinPlausibleMoisture);
log()->logf("plant%d: Moisture sensor reading is too low (%.1f < %.1f).", m_index,
m_moisture.filteredValue(), kMinPlausibleMoisture);
setState(kStateDisabled, 1, "moisture level implausibly low");
} else {
// Check whether to turn on the pump.
Expand Down Expand Up @@ -348,11 +348,11 @@ void Watering::loop() {

void Watering::setState(State state, unsigned msec, const char* msg) {
if (m_state.value() != state) {
log()->logf("%s -> %s in %d.%03d: %s.", s_state_names[m_state.value()], s_state_names[state],
msec / 1000, msec % 1000, msg);
log()->logf("plant%u: %s -> %s in %d.%03d: %s.", m_index, s_state_names[m_state.value()],
s_state_names[state], msec / 1000, msec % 1000, msg);
} else {
log()->debugf("%s -> %s in %d.%03d: %s.", s_state_names[m_state.value()], s_state_names[state],
msec / 1000, msec % 1000, msg);
log()->debugf("plant%u: %s -> %s in %d.%03d: %s.", m_index, s_state_names[m_state.value()],
s_state_names[state], msec / 1000, msec % 1000, msg);
}
m_state = state;
m_next_update_msec = millis() + static_cast<unsigned long>(msec);
Expand All @@ -361,11 +361,13 @@ void Watering::setState(State state, unsigned msec, const char* msg) {
void Watering::_fullTest() {
// test
m_moisture.read(millis());
log()->logf("Moisture: %s: %d, %.1f", m_moisture.readingIsFailed() ? "NOT OK" : "OK",
m_moisture.rawCounts(), m_moisture.filteredValue());
log()->logf("plant%u: moisture: %s: %d, %.1f", m_index,
m_moisture.readingIsFailed() ? "NOT OK" : "OK", m_moisture.rawCounts(),
m_moisture.filteredValue());
if (m_reservoir_check) {
m_reservoir_check->read();
log()->logf("WaterLevel %s", m_reservoir_check->floatIsFloating() ? "OK" : "LOW");
log()->logf("plant%u: waterLevel %s", m_index,
m_reservoir_check->floatIsFloating() ? "OK" : "LOW");
}
m_mode_led.on();
delay(100);
Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ build_type = release
; ~/Projects2/Plant133/lib/watering
lib_deps =
watering
og3@^0.2.0
og3@^0.2.2
og3x-oled@^0.2.0
og3x-shtc3@^0.2.0
adafruit/Adafruit BusIO
Expand Down
8 changes: 4 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "watering.h"

#define SW_VERSION "0.7.2"
#define SW_VERSION "0.7.3"

namespace {

Expand All @@ -42,14 +42,14 @@ og3::HAApp s_app(
og3::HAApp::Options(kManufacturer, kModel,
og3::WifiApp::Options()
.withSoftwareName(kSoftware)
.withDefaultDeviceName("plantl33")
.withDefaultDeviceName("plant133")
.withOta(og3::OtaManager::Options(OTA_PASSWORD))
#if defined(LOG_UDP) && defined(LOG_UDP_ADDRESS)
.withApp(og3::App::Options().withLogType(og3::App::LogType::kUdp))
.withUdpLogHost(IPAddress(IPAddress(LOG_UDP_ADDRESS)))
#else
// kNone
.withApp(og3::App::Options().withLogType(og3::App::LogType::kSerial))
// .withApp(og3::App::Options().withLogType(og3::App::LogType::kSerial))
.withApp(og3::App::Options().withLogType(og3::App::LogType::kNone))
#endif
));

Expand Down

0 comments on commit 1fa4bcb

Please sign in to comment.