Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion can_bus/hexray/CRIT/CRIT_rx.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
"DAM_Vitals",
"VC_GlobalShdnNodeStatus",
"BMS_LatchStatus",
"BMS_TractiveSystem"
"BMS_TractiveSystem",
"INVFL_FLInverterInfo1",
"INVFR_FRInverterInfo1",
"INVRL_RLInverterInfo1",
"INVRR_RRInverterInfo1",
"INVFL_FLInverterInfo2",
"INVFR_FRInverterInfo2",
"INVRL_RLInverterInfo2",
"INVRR_RRInverterInfo2"
]
}
22 changes: 7 additions & 15 deletions firmware/hexray/CRIT/src/app/screens/app_screen_alert.cpp

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great changes

Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,29 @@
#include "io_sevenSeg.hpp"
#include "app_canAlerts.hpp"
#include "util_retry.hpp"

#include <algorithm>
#include <cassert>
#include <cstdio>

static int alert_index = 0;
static uint8_t alert_count = 0;

static void update()
static void update()
{
std::array<io::seven_seg::digit, io::seven_seg::DIGITS> screen_buf{
{ io::seven_seg::a, io::seven_seg::l, io::seven_seg::t, io::seven_seg::dot, io::seven_seg::dot,
io::seven_seg::dot, io::seven_seg::dot, io::seven_seg::dot, io::seven_seg::dot }
};
char screen_buf[io::seven_seg::DIGITS];

std::array<app::can_alerts::Alert_Info, 20> buf{};

if (const uint8_t fault_count = app::can_alerts::FaultInfo(buf); fault_count > 0)
{
alert_count = fault_count;
screen_buf[3] = io::seven_seg::f;
screen_buf[4] = io::seven_seg::l;
screen_buf[5] = io::seven_seg::t;
alert_count = fault_count;
snprintf(screen_buf, io::seven_seg::DIGITS, "altflt");
// todo fault code
goto write;
}
if (const uint8_t warning_count = app::can_alerts::WarningInfo(buf); warning_count > 0)
{
alert_count = warning_count;
screen_buf[3] = io::seven_seg::u;
screen_buf[4] = io::seven_seg::r;
screen_buf[5] = io::seven_seg::n;
alert_count = warning_count;
snprintf(screen_buf, io::seven_seg::DIGITS, "altwrn");
// todo warning code
goto write;
}
Expand Down
15 changes: 8 additions & 7 deletions firmware/hexray/CRIT/src/app/screens/app_screen_brightness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
#include "io_sevenSeg.hpp"

#include <algorithm>
#include <array>

void static update()
{ // render brightness
std::array<io::seven_seg::digit, io::seven_seg::DIGITS> screen_buf{
{ io::seven_seg::dot, io::seven_seg::dot, io::seven_seg::dot, io::seven_seg::b, io::seven_seg::r,
io::seven_seg::i, io::seven_seg::g, io::seven_seg::h, io::seven_seg::t }
};
screen_buf[0] = io::seven_seg::digit_to_segment(app::brightness / 100 % 10);
screen_buf[1] = io::seven_seg::digit_to_segment(app::brightness / 10 % 10);
screen_buf[2] = io::seven_seg::digit_to_segment(app::brightness / 1 % 10);
// std::array<char, io::seven_seg::DIGITS> screen_buf{ { ' ', ' ', ' ', 'b', 'r', 'i', 'g', 'h', 't' } };
// screen_buf[0] = static_cast<char>('0' + ((app::brightness / 100) % 10));
// screen_buf[1] = static_cast<char>('0' + ((app::brightness / 10) % 10));
// screen_buf[2] = static_cast<char>('0' + (app::brightness % 10));
char screen_buf[io::seven_seg::DIGITS];
snprintf(screen_buf, sizeof(screen_buf) + 1, "%3ubright", app::brightness);

LOG_IF_ERR(io::seven_seg::write(screen_buf));
}

Expand Down
31 changes: 6 additions & 25 deletions firmware/hexray/CRIT/src/app/screens/app_screen_driveModes.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
// #include <string.h>
#include <cstdint>
#include "app_screens.hpp"
#include "app_canUtils.hpp"
#include "io_sevenSeg.hpp"

#include <cstdint>
#include <cstring>
// #include "app_screen_defines.hpp"
// #include "app_canTx.h"
// #include "app_canRx.h"
// #include "io_shift_register.h"
// #include "app_canUtils.h"
//

static auto drive_mode = app::can_utils::DriveMode::VANILLA;
static constexpr uint8_t DRIVE_MODE_COUNT = static_cast<size_t>(app::can_utils::DriveMode::COUNT);

Expand All @@ -27,30 +21,17 @@ static void drive_mode_cw()

static void drive_mode_update()
{
// const uint8_t max_cell_temp = static_cast<uint8_t>(app_canRx_BMS_MaxCellTemp_get());
// uint8_t data_buffer[DIG] = { 0 };
std::array<io::seven_seg::digit, io::seven_seg::DIGITS> data_buffer{};
// memset(&data_buffer[0], SEG_PATTERN_DP, (sizeof(uint8_t) * SEVEN_SEG_DATA_LENGTH));

// data_buffer[3] = digit_to_segment(max_cell_temp / 100);
// data_buffer[4] = digit_to_segment((max_cell_temp / 10) % 10);
// data_buffer[5] = digit_to_segment(max_cell_temp % 10);

char data_buffer[io::seven_seg::DIGITS];
switch (drive_mode)
{
case app::can_utils::DriveMode::VANILLA:
data_buffer[0] = io::seven_seg::v;
data_buffer[1] = io::seven_seg::a;
data_buffer[2] = io::seven_seg::n;
snprintf(data_buffer, io::seven_seg::DIGITS + 1, "van");
break;
case app::can_utils::DriveMode::LAUNCH:
data_buffer[0] = io::seven_seg::l;
data_buffer[1] = io::seven_seg::a;
data_buffer[2] = io::seven_seg::u;
snprintf(data_buffer, io::seven_seg::DIGITS + 1, "lau");
break;
case app::can_utils::DriveMode::TV:
data_buffer[0] = io::seven_seg::t;
data_buffer[1] = io::seven_seg::v;
snprintf(data_buffer, io::seven_seg::DIGITS + 1, "tv");
break;
case app::can_utils::DriveMode::COUNT:
default:
Expand Down
78 changes: 78 additions & 0 deletions firmware/hexray/CRIT/src/app/screens/app_screen_invError.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#include "app_screens.hpp"
#include "io_sevenSeg.hpp"
#include "util_retry.hpp"
#include "app_canRx.hpp"
#include <cassert>

using namespace app::can_rx;

static char screen_buf[io::seven_seg::DIGITS + 1];

static uint16_t prev_fr = 0u;
static uint16_t prev_rr = 0u;
static uint16_t prev_fl = 0u;
static uint16_t prev_rl = 0u;

static void write_error_code(const char pos1, const char pos2, const uint16_t error_code)
{
screen_buf[0] = pos1;
screen_buf[1] = pos2;

snprintf(&screen_buf[2], 6, "%05u", static_cast<unsigned>(error_code));
screen_buf[7] = '\0';
screen_buf[8] = '\0';
}

static void update()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will not work, because the moment fr is set to something it will auto override everything else. please keep track of the errorcode/errored inverter in one variable

{
const bool fl_inv_error = INVFL_bError_get();
const bool fr_inv_error = INVFR_bError_get();
const bool rl_inv_error = INVRL_bError_get();
const bool rr_inv_error = INVRR_bError_get();
const uint16_t fr_error_code = INVFR_ErrorInfo_get();
const uint16_t rr_error_code = INVRR_ErrorInfo_get();
const uint16_t fl_error_code = INVFL_ErrorInfo_get();
const uint16_t rl_error_code = INVRL_ErrorInfo_get();

// priority of error codes is based on which wheels travel longer dist:
// 1. fr
// 2. rr
// 3. fl
// 4. rl
// If higher priority error code is on we'll just keep that on first two segs are the
// inverter last 5 the code from CAN

if (fr_inv_error && fr_error_code != prev_fr)
{
write_error_code('f', 'r', fr_error_code);
prev_fr = fr_error_code;
}
else if (rr_inv_error && rr_error_code != prev_rr)
{
write_error_code('r', 'r', rr_error_code);
prev_rr = rr_error_code;
}
else if (fl_inv_error && fl_error_code != prev_fl)
{
write_error_code('f', 'l', fl_error_code);
prev_fl = fl_error_code;
}
else if (rl_inv_error && rl_error_code != prev_rl)
{
write_error_code('r', 'l', rl_error_code);
prev_rl = rl_error_code;
}

const auto screen_write_result = util::retry(
[]() -> result<void> {
return io::seven_seg::write(std::span<char, io::seven_seg::DIGITS>{ screen_buf, 9 });
},
3);
assert(screen_write_result.has_value());
}

constexpr app::screens::Screen app::screens::inv_error_screen = {
[] {},
[] {},
update,
};
Loading
Loading