Skip to content

Commit

Permalink
fix dronecan bidirection input range
Browse files Browse the repository at this point in the history
  • Loading branch information
Huibean committed Jan 24, 2025
1 parent 9f6fc6d commit 6c9fb2a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Src/DroneCAN/DroneCAN.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,9 +629,9 @@ static void handle_RawCommand(CanardInstance *ins, CanardRxTransfer *transfer)
} else if (eepromBuffer.bi_direction) {
const float scaled_value = input_can * (1000.0 / 8192);
if (scaled_value >= 0) {
this_input = (uint16_t)(47 + scaled_value);
this_input = (uint16_t)(1047 + scaled_value);
} else {
this_input = (uint16_t)(47 + (1000 - scaled_value));
this_input = (uint16_t)(47 + scaled_value * -1);
}
} else if (input_can > 0) {
const float scaled_value = input_can * (2000.0 / 8192);
Expand Down

0 comments on commit 6c9fb2a

Please sign in to comment.