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