Add read-only pointer accessor for previously read moisture value

This commit is contained in:
2025-10-05 22:21:21 +02:00
parent 6c48ebb65f
commit 74aab766fc
3 changed files with 26 additions and 3 deletions
+6 -1
View File
@@ -40,12 +40,17 @@ static void setup(void) {
watchdogs();
}
static uint16_t lastMoistureVal = 0;
// Encapsulate lastMoistureVal to read later from twi
const uint16_t *moisturePtr(void) { return &lastMoistureVal; }
int main(void) {
setup();
while(true) {
if (readSensors) {
uint16_t result = moistureRead();
lastMoistureVal = moistureRead();
// nested if: (result outside range (see config.h)) {waterPlant()}
}