X-Git-Url: https://git.realraum.at/?a=blobdiff_plain;f=firmware%2Ftuer.pde;h=6c966a25b5d35390b440966b3dfe8485ce11a8e5;hb=a3b81ec5089fbd974fff0f711c093c2033b1615a;hp=c404b74f82a57e4b7a544dcdecb4aac4bdce79b0;hpb=40a91b04f102cebd67f17a4c6258cd9c0010c228;p=svn42.git diff --git a/firmware/tuer.pde b/firmware/tuer.pde index c404b74..6c966a2 100644 --- a/firmware/tuer.pde +++ b/firmware/tuer.pde @@ -38,6 +38,7 @@ int debounce_cnt = 0; #define CMD_OPEN 'o' #define CMD_CLOSE 'c' +#define CMD_TOGGLE 't' #define CMD_STATUS 's' #define CMD_RESET 'r' @@ -359,6 +360,12 @@ ISR(TIMER1_COMPA_vect) stop_timer(); reset_stepper(); current_state = IDLE; + Serial.print("Status: "); + if(is_opened()) + Serial.print("opened"); + else if(is_closed()) + Serial.print("closed"); + Serial.println(", idle"); return; } else if(current_state == ERROR) { @@ -519,7 +526,7 @@ void loop() char command = Serial.read(); if(current_state == ERROR && command != CMD_RESET) { - Serial.println("Error: last open/close operation took to long!"); + Serial.println("Error: last open/close operation took too long!"); } else if (command == CMD_RESET) { reset_after_error(); @@ -548,16 +555,27 @@ void loop() else Serial.println("Error: Operation in progress"); } + else if (command == CMD_TOGGLE) { + if(current_state == IDLE) { + if(is_closed()) + start_open(); + else + start_close(); + Serial.println("Ok"); + } + else + Serial.println("Error: Operation in progress"); + } else if (command == CMD_STATUS) print_status(); else Serial.println("Error: unknown command"); } - if(manual_open() && !is_opened() && current_state == IDLE) { + if(manual_open() && !is_opened() && (current_state == IDLE || current_state == ERROR)) { Serial.println("open forced manually"); start_open(); } - if(manual_close() && !is_closed() && current_state == IDLE) { + if(manual_close() && !is_closed() && (current_state == IDLE || current_state == ERROR)) { Serial.println("close forced manually"); start_close(); }