Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 1460 → Rev 1461

/branches/V0.76g-acid/servoboard/uart.c
10,6 → 10,7
uint8_t rx_buffer[RX_BUFFER_SZ];
//uint8_t tx_buffer[TX_BUFFER_SZ];
uint8_t rx_pos, tx_pos;
uint8_t current_servo = 0;
 
void uart_init() {
 
36,6 → 37,20
 
uint8_t i = UDR;
 
if (i == '+') {
if (pwm_neutral_position[current_servo - 1] < 255) {
pwm_neutral_position[current_servo - 1]++;
}
printf("SERVO %d VALUE %d\n", current_servo, pwm_neutral_position[current_servo - 1]);
return;
} else if (i == '-') {
if (pwm_neutral_position[current_servo - 1] > 0) {
pwm_neutral_position[current_servo - 1]--;
}
printf("SERVO %d VALUE %d\n", current_servo, pwm_neutral_position[current_servo - 1]);
return;
}
 
uart_putchar(i);
 
if (i == '\r') {
53,6 → 68,7
" n = neutral position (0-255)\n"
" l = lower limit (0-255)\n"
" u = upper limit (0-255)\n"
"CUR n Set current servo. + = increase, - = decrease value\n"
"LOAD Load settings from eeprom\n"
"SAVE Write settings to eeprom\n");
} else if (!strcasecmp(rx_buffer, "DISPLAY")) {
77,8 → 93,21
eeprom_init();
} else if (!strcasecmp(rx_buffer, "SAVE")) {
eeprom_write();
// } else if (!strncasecmp(rx_buffer, "INC ", 4)) {
// } else if (!strncasecmp(rx_buffer, "DEC ", 4)) {
} else if (!strncasecmp(rx_buffer, "CUR ", 4)) {
char *s, *t;
s = strtok_r(rx_buffer, " ", &t);
if (s) {
s = strtok_r(NULL, "", &t);
if (s) {
i = atoi(s) + 1;
if (i >= 1 && i <= 6) {
current_servo = i;
printf("CURRENT SERVO %d\n", i);
} else {
printf("Invalid servo\n");
}
}
}
} else if (!strncasecmp(rx_buffer, "SET ", 4)) {
char *s, *t;
uint8_t servo;
96,7 → 125,7
s = strtok_r(NULL, ",", &t);
if (s) {
l = atoi(s);
s = strtok_r(NULL, ",", &t);
s = strtok_r(NULL, "", &t);
if (s) {
h = atoi(s);
} else {
104,6 → 133,7
}
}
pwm_limit[servo] = (h << 8) | l;
pwm_check_active();
i = servo;
printf("SERVO %d, NEUTRAL %d, LIMIT %d-%d\n",
(i + 1),