Implement stop action

This commit is contained in:
Gregor Riepl 2021-01-18 12:48:26 +01:00
parent 99cb7bc033
commit a0a4d0c2c1
2 changed files with 7 additions and 3 deletions

View file

@ -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) | | 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) | | 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) |

View file

@ -113,8 +113,11 @@ static void send_status() {
} }
static void fire_relay(uint8_t num) { static void fire_relay(uint8_t num) {
if (num < 5) { if (num == 0) {
uint16_t out = 0x0080 >> num; bang(0);
strobe();
} else if (num <= 5) {
uint16_t out = 0x0080 >> (num - 1);
bang(out); bang(out);
strobe(); strobe();
} }
@ -133,6 +136,7 @@ static void loop() {
} }
case 0x21: case 0x21:
if (msg.length == 1) { if (msg.length == 1) {
// stop (d0 = 0) or fire relay (d0 = 1..5)
fire_relay(msg.data[0]); fire_relay(msg.data[0]);
// also send out the current status // also send out the current status
send_status(); send_status();