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 "../../CAN_IDs.h"
6#include "enum_utils.hpp"
7
11void create_left_wheel_msg(std::array<uint8_t, 5> &msg, double value) {
12 value /= WHEEL_PRECISION; // take precision off to send integer value
13 if (value < 0) value = 0;
14
15 msg[0] = LEFT_WHEEL_MSG;
16 // Copy the bytes of the double value to msg[1] to msg[4]
17 for (int i = 0; i < 4; i++)
18 msg[i + 1] = static_cast<int>(value) >> (8 * i); // shift 8(byte) to msb each time
19}
20
21inline std::array<uint8_t, 8> create_debug_message_1(const SystemData& system_data, uint8_t state, uint8_t state_checkup) {
22 return {
23 DBG_LOG_MSG,
36 (system_data.hardware_data_.asms_on_ & 0x01) << 7 |
39 (state_checkup & 0x0F),
40 (to_underlying(system_data.mission_) & 0x0F) | ((state & 0x0F) << 4)
41 };
42}
43
bool checkWithoutReset() const
Checks if the interval has passed without resetting the timer.
Definition metro.h:115
std::array< uint8_t, 8 > create_debug_message_1(const SystemData &system_data, uint8_t state, uint8_t state_checkup)
Definition utils.hpp:21
void create_left_wheel_msg(std::array< uint8_t, 5 > &msg, double value)
Function to create left wheel msg.
Definition utils.hpp:11
std::array< uint8_t, 7 > create_debug_message_2(const SystemData &system_data)
Definition utils.hpp:44
constexpr auto to_underlying(Enum e) noexcept
Definition enum_utils.hpp:4
SystemData system_data
Definition main.cpp:11
int _hydraulic_line_pressure
bool pneumatic_line_pressure_
bool pneumatic_line_pressure_2_
bool pneumatic_line_pressure_1_
Metro releaseEbsTimestamp
The whole model of the system: holds all the data necessary.
Mission mission_
R2DLogics r2d_logics_
FailureDetection failure_detection_
HardwareData hardware_data_
CAN_message_t msg