From a0a4d0c2c192df1722aa3db522912f009c0bd75d Mon Sep 17 00:00:00 2001 From: Gregor Riepl Date: Mon, 18 Jan 2021 12:48:26 +0100 Subject: [PATCH] Implement stop action --- README.md | 2 +- poweriface/firmware/main.c | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1236aeb..3c6de2c 100644 --- a/README.md +++ b/README.md @@ -139,4 +139,4 @@ This is the list of supported message IDs: |------------|------------|------------|--------------|------------|-------------------------|-------------| | 0x10 | feedback | any | yes | 2 | 0b00000KJI 0bHGFEDCBA | Feedback module status report (A..E = end switch D..H, F..J = empty switch D..H, K = reset switch, 0 = off, 1 = on) | | 0x11 | poweriface | any | yes | 2 | 0bHHHHHHHH 0bLLLLLLLL | Power module status report (0xHHLL are the contents of the 16-bit shift register) | -| 0x21 | controller | poweriface | no | 1 | 0b00000MMM | Start dispensing from slot M (0-4) | +| 0x21 | controller | poweriface | no | 1 | 0b00000MMM | Start dispensing from slot M (1-5) or stop all dispensers (M = 0) | diff --git a/poweriface/firmware/main.c b/poweriface/firmware/main.c index 5cfcab5..eba790e 100644 --- a/poweriface/firmware/main.c +++ b/poweriface/firmware/main.c @@ -113,8 +113,11 @@ static void send_status() { } static void fire_relay(uint8_t num) { - if (num < 5) { - uint16_t out = 0x0080 >> num; + if (num == 0) { + bang(0); + strobe(); + } else if (num <= 5) { + uint16_t out = 0x0080 >> (num - 1); bang(out); strobe(); } @@ -133,6 +136,7 @@ static void loop() { } case 0x21: if (msg.length == 1) { + // stop (d0 = 0) or fire relay (d0 = 1..5) fire_relay(msg.data[0]); // also send out the current status send_status();