|
|
@ -4,14 +4,15 @@ |
|
|
|
#include "app_io.h" |
|
|
|
#include "app_io.h" |
|
|
|
#include "lcd.h" |
|
|
|
#include "lcd.h" |
|
|
|
|
|
|
|
|
|
|
|
static bool valve1, valve2, valve3, valve4; |
|
|
|
static int cur_valve = 0; |
|
|
|
|
|
|
|
|
|
|
|
void screen_manual_control(GuiEvent event) |
|
|
|
void screen_manual_control(GuiEvent event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
int num = 0; |
|
|
|
switch (event) { |
|
|
|
switch (event) { |
|
|
|
case GUI_EVENT_SCREEN_INIT: |
|
|
|
case GUI_EVENT_SCREEN_INIT: |
|
|
|
open_valve(0); // make sure all are closed
|
|
|
|
open_valve(0); // make sure all are closed
|
|
|
|
valve1 = valve2 = valve3 = valve4 = false; |
|
|
|
cur_valve = 0; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case GUI_EVENT_PAINT: |
|
|
|
case GUI_EVENT_PAINT: |
|
|
@ -21,10 +22,10 @@ void screen_manual_control(GuiEvent event) |
|
|
|
//LcdBuffer_SetCursor(&lcd, 2, 0, CURSOR_BOTH);
|
|
|
|
//LcdBuffer_SetCursor(&lcd, 2, 0, CURSOR_BOTH);
|
|
|
|
|
|
|
|
|
|
|
|
snprintf(sbuf, sbuf_len, " %s %s %s %s ", |
|
|
|
snprintf(sbuf, sbuf_len, " %s %s %s %s ", |
|
|
|
valve1 ? "█1█" : " 1 ", |
|
|
|
(cur_valve == 1) ? "█1█" : " 1 ", |
|
|
|
valve2 ? "█2█" : " 2 ", |
|
|
|
(cur_valve == 2) ? "█2█" : " 2 ", |
|
|
|
valve3 ? "█3█" : " 3 ", |
|
|
|
(cur_valve == 3) ? "█3█" : " 3 ", |
|
|
|
valve4 ? "█4█" : " 4 "); |
|
|
|
(cur_valve == 4) ? "█4█" : " 4 "); |
|
|
|
LcdBuffer_Write(&lcd, 2, 0, sbuf); |
|
|
|
LcdBuffer_Write(&lcd, 2, 0, sbuf); |
|
|
|
|
|
|
|
|
|
|
|
LcdBuffer_Write(&lcd, 3, 0, "🅳Konec"); |
|
|
|
LcdBuffer_Write(&lcd, 3, 0, "🅳Konec"); |
|
|
@ -36,32 +37,23 @@ void screen_manual_control(GuiEvent event) |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case GUI_EVENT_KEY_0: |
|
|
|
case GUI_EVENT_KEY_0: |
|
|
|
valve1 = valve2 = valve3 = valve4 = false; |
|
|
|
cur_valve = 0; |
|
|
|
open_valve(0); |
|
|
|
open_valve(0); |
|
|
|
request_paint(); |
|
|
|
request_paint(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case GUI_EVENT_KEY_1: |
|
|
|
case GUI_EVENT_KEY_1: |
|
|
|
valve1 = !valve1; |
|
|
|
|
|
|
|
set_one_relay(1, valve1); |
|
|
|
|
|
|
|
request_paint(); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case GUI_EVENT_KEY_2: |
|
|
|
case GUI_EVENT_KEY_2: |
|
|
|
valve2 = !valve2; |
|
|
|
|
|
|
|
set_one_relay(2, valve2); |
|
|
|
|
|
|
|
request_paint(); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case GUI_EVENT_KEY_3: |
|
|
|
case GUI_EVENT_KEY_3: |
|
|
|
valve3 = !valve3; |
|
|
|
|
|
|
|
set_one_relay(3, valve3); |
|
|
|
|
|
|
|
request_paint(); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case GUI_EVENT_KEY_4: |
|
|
|
case GUI_EVENT_KEY_4: |
|
|
|
valve4 = !valve4; |
|
|
|
num = (int) (event - '0'); |
|
|
|
set_one_relay(4, valve4); |
|
|
|
if (cur_valve == num) { |
|
|
|
|
|
|
|
cur_valve = 0; |
|
|
|
|
|
|
|
open_valve(0); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
cur_valve = num; |
|
|
|
|
|
|
|
open_valve(num); |
|
|
|
|
|
|
|
} |
|
|
|
request_paint(); |
|
|
|
request_paint(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|