From f19d487349a9746fbb44c85d08e5550cb66d6190 Mon Sep 17 00:00:00 2001 From: Guillaume Chevillot Date: Fri, 7 Mar 2008 16:42:15 +0100 Subject: - We can now send a command to have a PWM above 50%, let's go to the highway... - Remove of a not needed cast --- analog/motor-power-avr/src/main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'analog/motor-power-avr/src/main.c') diff --git a/analog/motor-power-avr/src/main.c b/analog/motor-power-avr/src/main.c index 38941011..ce76fe43 100644 --- a/analog/motor-power-avr/src/main.c +++ b/analog/motor-power-avr/src/main.c @@ -154,7 +154,7 @@ main_loop (void) void proto_callback (uint8_t cmd, uint8_t size, uint8_t *args) { -#define c(cmd, size) ((uint16_t)cmd << 8 | size) +#define c(cmd, size) (cmd << 8 | size) switch (c (cmd, size)) { case c ('z', 0): @@ -171,17 +171,17 @@ proto_callback (uint8_t cmd, uint8_t size, uint8_t *args) case c ('l', 1): /* Set pwm value for _L_ side. - * - 0x80: -max on duty cycle (direction = 0) + * - 0x7F: -max on duty cycle (direction = 0) * - 0x00: 0% on duty cycle (brake state) * - 0xFF: max on duty cylcle (direction = 1) */ cmd_L_ = (int8_t) args[0]; if (cmd_L_ >= 0) { - start_motor_L_(cmd_L_ , 0); + start_motor_L_ ((cmd_L_ << 1) , 0); } else { - start_motor_L_ (-cmd_L_ , 1); + start_motor_L_ (((-cmd_L_) << 1), 1); } break; @@ -192,17 +192,17 @@ proto_callback (uint8_t cmd, uint8_t size, uint8_t *args) case c ('r', 1): /* Set pwm value for _R_ side. - * - 0x80: -max on duty cycle (direction = 0) + * - 0x7F: -max on duty cycle (direction = 0) * - 0x00: 0% on duty cycle (brake state) * - 0xFF: max on duty cylcle (direction = 1) */ cmd_R_ = (int8_t) args[0]; if (cmd_R_ >= 0) { - start_motor_R_(cmd_R_ , 0); + start_motor_L_ ((cmd_L_ << 1) , 0); } else { - start_motor_R_ (-cmd_R_ , 1); + start_motor_L_ (((-cmd_L_) << 1), 1); } break; -- cgit v1.2.3