diff --git a/src/commands.c b/src/commands.c index 0608257..a1053ad 100644 --- a/src/commands.c +++ b/src/commands.c @@ -3,7 +3,8 @@ #include #include -#include "include/commands.h" +#include "commands.h" +#include "pins.h" cmd_t command = { .buf = {0}, @@ -48,8 +49,8 @@ void cmd_handle(cmd_t *command) if (0 == strcmp(tok1, "set")) cmd_handle_set(tok2, tok3); - if (0 == strcmp(tok1, "switch")) - cmd_handle_switch(); + if (0 == strcmp(tok1, "switch") || 0 == strcmp(tok1, "sw")) + cmd_handle_switch(tok2, tok3); } void cmd_handle_set(char *op1, char *op2) @@ -93,12 +94,50 @@ void cmd_handle_set(char *op1, char *op2) } } -void cmd_handle_switch(void) +void cmd_handle_switch(char *op1, char *op2) { - int state = 0; + if (0 == strcmp(op1, "pd6")) { + if (0 == strcmp(op2, "on")) + setPin(&PORTD, PD6); + else if (0 == strcmp(op2, "off")) + unsetPin(&PORTD, PD6); + else + togglePin(&PORTD, PD6); + } - PORTD ^= (1<1) { - _delay_us(1); + _delay_ms(5); PORTB &= ~(1<