summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Buesch <m@bues.ch>2015-02-18 19:01:36 +0100
committerMichael Buesch <m@bues.ch>2015-02-18 19:01:36 +0100
commit97fb4acb2e9c66c0c4d1ec1553c3cfa000d1293d (patch)
tree463a733a92c5e35b4ec20f2df08aed2c0570570d
parentf2246437360217aee4f4c2ed7e1242a916a1bb59 (diff)
downloadmoistcontrol-97fb4acb2e9c66c0c4d1ec1553c3cfa000d1293d.tar.xz
moistcontrol-97fb4acb2e9c66c0c4d1ec1553c3cfa000d1293d.zip
Add a button to force start measurement
Signed-off-by: Michael Buesch <m@bues.ch>
-rw-r--r--firmware/controller.c15
-rw-r--r--firmware/controller.h3
-rw-r--r--firmware/main.c4
-rwxr-xr-xhost/moistcontrol-gui2
-rw-r--r--host/pymoistcontrol/messages.py7
-rw-r--r--host/pymoistcontrol/potwidgets.py16
6 files changed, 40 insertions, 7 deletions
diff --git a/firmware/controller.c b/firmware/controller.c
index fb8f311..e356514 100644
--- a/firmware/controller.c
+++ b/firmware/controller.c
@@ -799,23 +799,36 @@ void controller_update_pot_rem_state(uint8_t pot_number,
* force_stop_watering_mask: A bitmask of pots to force-stop watering on.
* valve_manual_mask: A bitmask of pots to enable manual valve control on.
* valve_manual_state: A bitmask of manual-mode valve states.
+ * force_start_measurement_mask: A bitmask of pots to force-start measurement on.
*/
void controller_manual_mode(uint8_t force_stop_watering_mask,
uint8_t valve_manual_mask,
- uint8_t valve_manual_state)
+ uint8_t valve_manual_state,
+ uint8_t force_start_measurement_mask)
{
struct flowerpot *pot;
+ const struct flowerpot_config *config;
uint8_t i, mask;
for (i = 0, mask = 1; i < MAX_NR_FLOWERPOTS; i++, mask <<= 1) {
pot = &cont.pots[i];
+ config = pot_config(pot);
if ((force_stop_watering_mask & mask) &&
pot->state.is_watering)
pot_stop_watering(pot);
+
pot->valve_manual_en = !!(valve_manual_mask & mask);
pot->valve_manual_state = !!(valve_manual_state & mask);
valve_state_commit(pot);
+
+ if (force_start_measurement_mask & mask) {
+ /* Force measurement state, if enabled and idle. */
+ if (pot->state.state_id == POT_IDLE &&
+ (config->flags & POT_FLG_ENABLED) &&
+ !(pot->rem_state.flags & POT_REMFLG_WDTRIGGER))
+ pot_state_enter(pot, POT_START_MEASUREMENT);
+ }
}
}
diff --git a/firmware/controller.h b/firmware/controller.h
index e6cff42..70c9bfb 100644
--- a/firmware/controller.h
+++ b/firmware/controller.h
@@ -127,7 +127,8 @@ void controller_update_pot_rem_state(uint8_t pot_number,
void controller_manual_mode(uint8_t force_stop_watering_mask,
uint8_t valve_manual_mask,
- uint8_t valve_manual_state);
+ uint8_t valve_manual_state,
+ uint8_t force_start_measurement_mask);
void controller_freeze(bool freeze);
diff --git a/firmware/main.c b/firmware/main.c
index 5d780d0..37cf50f 100644
--- a/firmware/main.c
+++ b/firmware/main.c
@@ -116,6 +116,7 @@ struct msg_payload {
uint8_t valve_manual_mask;
uint8_t valve_manual_state;
uint8_t flags;
+ uint8_t force_start_measurement_mask;
} _packed manual_mode;
/* Global controller state. */
@@ -300,7 +301,8 @@ bool comm_handle_rx_message(const struct comm_message *msg,
controller_manual_mode(pl->manual_mode.force_stop_watering_mask,
pl->manual_mode.valve_manual_mask,
- pl->manual_mode.valve_manual_state);
+ pl->manual_mode.valve_manual_state,
+ pl->manual_mode.force_start_measurement_mask);
if (pl->manual_mode.flags & MANFLG_FREEZE_CHANGE)
controller_freeze(!!(pl->manual_mode.flags & MANFLG_FREEZE_ENABLE));
diff --git a/host/moistcontrol-gui b/host/moistcontrol-gui
index be94b59..76335ed 100755
--- a/host/moistcontrol-gui
+++ b/host/moistcontrol-gui
@@ -159,6 +159,8 @@ class MainWidget(QWidget):
if pot.forceOpenValveActive():
msg.valve_manual_mask |= 1 << i
msg.valve_manual_state |= 1 << i
+ if pot.forceStartMeasActive():
+ msg.force_start_measurement_mask |= 1 << i
self.serial.send(msg)
except SerialError as e:
self.__handleCommError(e)
diff --git a/host/pymoistcontrol/messages.py b/host/pymoistcontrol/messages.py
index d23e4a3..a286fd3 100644
--- a/host/pymoistcontrol/messages.py
+++ b/host/pymoistcontrol/messages.py
@@ -460,11 +460,13 @@ class MsgManMode(Message):
force_stop_watering_mask = 0,
valve_manual_mask = 0,
valve_manual_state = 0,
- flags = 0):
+ flags = 0,
+ force_start_measurement_mask = 0):
self.force_stop_watering_mask = force_stop_watering_mask
self.valve_manual_mask = valve_manual_mask
self.valve_manual_state = valve_manual_state
self.flags = flags
+ self.force_start_measurement_mask = force_start_measurement_mask
Message.__init__(self)
def getType(self):
@@ -475,7 +477,8 @@ class MsgManMode(Message):
self.force_stop_watering_mask & 0xFF,
self.valve_manual_mask & 0xFF,
self.valve_manual_state & 0xFF,
- self.flags & 0xFF, ])
+ self.flags & 0xFF,
+ self.force_start_measurement_mask, ])
class MsgManModeFetch(Message):
def __init__(self):
diff --git a/host/pymoistcontrol/potwidgets.py b/host/pymoistcontrol/potwidgets.py
index f6d1790..e06ae57 100644
--- a/host/pymoistcontrol/potwidgets.py
+++ b/host/pymoistcontrol/potwidgets.py
@@ -151,10 +151,14 @@ class PotWidget(QWidget):
self.layout().addLayout(hbox, y, 1)
y += 1
+ label = QLabel("Force:", self)
+ self.layout().addWidget(label, y, 0)
hbox = QHBoxLayout()
- self.forceOpenButton = QPushButton("Force-open valve", self)
+ self.forceOpenButton = QPushButton("&Open valve", self)
hbox.addWidget(self.forceOpenButton)
- self.forceStopWateringButton = QPushButton("Force-stop watering", self)
+ self.forceStartMeasurement = QPushButton("&Trigger measurement", self)
+ hbox.addWidget(self.forceStartMeasurement)
+ self.forceStopWateringButton = QPushButton("&Stop watering", self)
self.forceStopWateringButton.setEnabled(False)
hbox.addWidget(self.forceStopWateringButton)
self.layout().addLayout(hbox, y, 1)
@@ -210,6 +214,7 @@ class PotWidget(QWidget):
self.endTime.timeChanged.connect(self.__endTimeChanged)
self.forceOpenButton.pressed.connect(self.__forceOpenPressed)
self.forceOpenButton.released.connect(self.__forceOpenReleased)
+ self.forceStartMeasurement.pressed.connect(self.__forceStartMeasPressed)
self.forceStopWateringButton.pressed.connect(self.__forceStopWaterPressed)
self.advancedCheckBox.stateChanged.connect(self.__advancedChanged)
@@ -225,6 +230,9 @@ class PotWidget(QWidget):
def forceOpenValveActive(self):
return self.forceOpenButton.isDown()
+ def forceStartMeasActive(self):
+ return self.forceStartMeasurement.isDown()
+
def forceStopWateringActive(self):
return self.forceStopWateringButton.isDown()
@@ -330,6 +338,10 @@ class PotWidget(QWidget):
if not self.ignoreChanges:
self.manModeChanged.emit()
+ def __forceStartMeasPressed(self):
+ if not self.ignoreChanges:
+ self.manModeChanged.emit()
+
def __forceStopWaterPressed(self):
if not self.ignoreChanges:
self.manModeChanged.emit()
bues.ch cgit interface