Formula Student Electronics & Software
The code for the embedded software
Loading...
Searching...
No Matches
utils.hpp
Go to the documentation of this file.
1
2
#include <Arduino.h>
3
#include "
comm/communicatorSettings.hpp
"
4
8
void
create_left_wheel_msg
(uint8_t *
msg
,
double
value) {
9
value /=
WHEEL_PRECISION
;
// take precision off to send integer value
10
if
(value < 0) value = 0;
11
12
msg
[0] =
LEFT_WHEEL_MSG
;
13
// Copy the bytes of the double value to msg[1] to msg[4]
14
for
(
int
i = 0; i < 4; i++)
15
msg
[i + 1] =
static_cast<
int
>
(value) >> (8*i);
// shift 8(byte) to msb each time
16
}
communicatorSettings.hpp
LEFT_WHEEL_MSG
constexpr auto LEFT_WHEEL_MSG
Definition
communicatorSettings.hpp:39
WHEEL_PRECISION
constexpr auto WHEEL_PRECISION
Definition
communicatorSettings.hpp:23
msg
CAN_message_t msg
Definition
test_callbacks.cpp:17
create_left_wheel_msg
void create_left_wheel_msg(uint8_t *msg, double value)
Function to create left wheel msg.
Definition
utils.hpp:8
master
include
comm
utils.hpp
Generated by
1.9.8