From: Olivier Matz Date: Tue, 15 Oct 2013 20:24:08 +0000 (+0200) Subject: introoduce spi_servo_dump() X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=bf003cd191abeafb1c31a7a24aa573b7a20e527e;p=protos%2Fxbee-avr.git introoduce spi_servo_dump() --- diff --git a/commands.c b/commands.c index ce85088..c9d415f 100644 --- a/commands.c +++ b/commands.c @@ -1313,7 +1313,6 @@ struct cmd_servo_result { static void cmd_servo_parsed(void * parsed_result, void *data) { struct cmd_servo_result *res = parsed_result; - uint8_t i; (void)data; @@ -1335,11 +1334,7 @@ static void cmd_servo_parsed(void * parsed_result, void *data) spi_servo_set_ppm(!!res->val); } else if (!strcmp_P(res->arg1, PSTR("show"))) { - for (i = 0; i < 6; i++) - printf_P(PSTR("%d: %d\r\n"), i, spi_servo_get(i)); - printf_P(PSTR("bypass=%d ppm=%d\n"), - spi_servo_get_bypass(), spi_servo_get_ppm()); - printf_P(PSTR("\r\n")); + spi_servo_dump(); } } @@ -1444,10 +1439,9 @@ static void cmd_test_spi_parsed(void * parsed_result, void *data) spi_servo_set(i, val); wait_ms(wait_time); - - for (i = 0; i < 6; i++) - printf_P(PSTR("%d: %d\r\n"), i, spi_servo_get(i)); - printf_P(PSTR("\r\n")); + printf_P(PSTR("%4.4d %4.4d %4.4d %4.4d %4.4d %4.4d\r\n"), + spi_servo_get(0), spi_servo_get(1), spi_servo_get(2), + spi_servo_get(3), spi_servo_get(4), spi_servo_get(5)); } printf_P(PSTR("bypass mode, with spi commands in background\r\n")); @@ -1470,10 +1464,9 @@ static void cmd_test_spi_parsed(void * parsed_result, void *data) spi_servo_set(i, val); wait_ms(wait_time); - - for (i = 0; i < 6; i++) - printf_P(PSTR("%d: %d\r\n"), i, spi_servo_get(i)); - printf_P(PSTR("\r\n")); + printf_P(PSTR("%4.4d %4.4d %4.4d %4.4d %4.4d %4.4d\r\n"), + spi_servo_get(0), spi_servo_get(1), spi_servo_get(2), + spi_servo_get(3), spi_servo_get(4), spi_servo_get(5)); } printf_P(PSTR("PPM to servo\r\n")); diff --git a/spi_servo.c b/spi_servo.c index c4fe318..4b0d241 100644 --- a/spi_servo.c +++ b/spi_servo.c @@ -255,3 +255,14 @@ void spi_servo_set_ppm(uint8_t enable) spi_servo_tx.cmd_mask |= (1 << N_SERVO); IRQ_UNLOCK(flags); } + +void spi_servo_dump(void) +{ + uint8_t i; + + for (i = 0; i < N_SERVO; i++) + printf_P(PSTR("%d: rx=%4.4d tx=%4.4d\r\n"), i, + spi_servo_get(i), spi_servo_tx.servo[i]); + printf_P(PSTR("bypass=%d ppm=%d\n"), + spi_servo_get_bypass(), spi_servo_get_ppm()); +} diff --git a/spi_servo.h b/spi_servo.h index 895df3a..95449c5 100644 --- a/spi_servo.h +++ b/spi_servo.h @@ -7,3 +7,4 @@ void spi_servo_set_bypass(uint8_t enable); void spi_servo_set_ppm(uint8_t enable); uint8_t spi_servo_get_bypass(void); uint8_t spi_servo_get_ppm(void); +void spi_servo_dump(void);