summaryrefslogtreecommitdiffstats
path: root/pressure_control/firmware/main.c
diff options
context:
space:
mode:
authormb <mb@frink.(none)>2009-04-18 17:06:54 +0200
committermb <mb@frink.(none)>2009-04-18 17:06:54 +0200
commit42077af0734b747c5e2311b3b7186537b72cecdb (patch)
tree48fdfac1bec9e6fe775e3771f1aa13372eb14e40 /pressure_control/firmware/main.c
parent3797d749f174d3bcf04d921c23e076fd7d592335 (diff)
downloadcnc-42077af0734b747c5e2311b3b7186537b72cecdb.tar.xz
cnc-42077af0734b747c5e2311b3b7186537b72cecdb.zip
Turn off the device, if the control tool is shutdown
Signed-off-by: mb <mb@frink.(none)>
Diffstat (limited to 'pressure_control/firmware/main.c')
-rw-r--r--pressure_control/firmware/main.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/pressure_control/firmware/main.c b/pressure_control/firmware/main.c
index d2d849d..a82a503 100644
--- a/pressure_control/firmware/main.c
+++ b/pressure_control/firmware/main.c
@@ -179,6 +179,16 @@ static void print_banner(void)
print_sram(str);
}
+void prepare_turn_on(void)
+{
+ state.device_enabled = 1;
+}
+
+void prepare_shutdown(void)
+{
+ state.device_enabled = 0;
+}
+
int main(void)
{
uint8_t mcucsr;
@@ -217,18 +227,24 @@ int main(void)
remote_notify_restart();
while (1) {
mb();
- if (state.sensor_trigger_cnt == 0) {
- /* It's time for triggering another sensor measurement. */
- state.sensor_trigger_cnt = -1;
- mb();
- sensor_trigger_read();
- }
- if (state.needs_checking) {
- check_pressure();
- /* Trigger another measurement in 25 milliseconds. */
- state.sensor_trigger_cnt = 25;
+ if (state.device_enabled) {
+ if (state.sensor_trigger_cnt == 0) {
+ /* It's time for triggering another
+ * sensor measurement. */
+ state.sensor_trigger_cnt = -1;
+ mb();
+ sensor_trigger_read();
+ }
+ if (state.needs_checking) {
+ check_pressure();
+ /* Trigger another measurement in
+ * a few milliseconds. */
+ state.sensor_trigger_cnt = 35;
+ state.needs_checking = 0;
+ mb();
+ }
+ } else {
state.needs_checking = 0;
- mb();
}
remote_work();
wdt_reset();
bues.ch cgit interface