Skip to content
Open
Show file tree
Hide file tree
Changes from 6 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"
]
}
5 changes: 2 additions & 3 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,15 +2,14 @@
#include "io_sevenSeg.hpp"
#include "app_canAlerts.hpp"
#include "util_retry.hpp"

#include <algorithm>
#include <cassert>

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 }
Expand Down
89 changes: 89 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,89 @@
#include "app_screens.hpp"
#include "io_sevenSeg.hpp"
#include "util_retry.hpp"
#include "app_canRx.hpp"
#include <algorithm>
#include <cassert>

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 }
};

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 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();

// 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_inv_error != prev_fr)

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 display the error for one tick, then ignore it

{
screen_buf[0] = io::seven_seg::f;
screen_buf[1] = io::seven_seg::r;
const uint16_t error_code = INVFR_ErrorInfo_get();
uint16_t divisor = 10000u;
for (uint16_t i = 2; i < 7; i++, divisor /= 10u)
{
screen_buf[i] = io::seven_seg::digit_to_segment(static_cast<uint8_t>((error_code / divisor) % 10u));
}
prev_fr = error_code;
}
else if (rr_inv_error && rr_inv_error != prev_rr)
{
screen_buf[0] = io::seven_seg::r;
screen_buf[1] = io::seven_seg::r;
const uint16_t error_code = INVRR_ErrorInfo_get();
uint16_t divisor = 10000u;
for (uint16_t i = 2; i < 7; i++, divisor /= 10u)
{
screen_buf[i] = io::seven_seg::digit_to_segment(static_cast<uint8_t>((error_code / divisor) % 10u));
}
prev_rr = error_code;
}
else if (fl_inv_error && fl_inv_error != prev_fl)
{
screen_buf[0] = io::seven_seg::f;
screen_buf[1] = io::seven_seg::l;
const uint16_t error_code = INVFL_ErrorInfo_get();
uint16_t divisor = 10000u;
for (uint16_t i = 2; i < 7; i++, divisor /= 10u)
{
screen_buf[i] = io::seven_seg::digit_to_segment(static_cast<uint8_t>((error_code / divisor) % 10u));
}
prev_fl = error_code;
}
else if (rl_inv_error && rl_inv_error != prev_rl)
{
screen_buf[0] = io::seven_seg::r;
screen_buf[1] = io::seven_seg::l;
const uint16_t error_code = INVRL_ErrorInfo_get();
uint16_t divisor = 10000u;
for (uint16_t i = 2; i < 7; i++, divisor /= 10u)
{
screen_buf[i] = io::seven_seg::digit_to_segment(static_cast<uint8_t>((error_code / divisor) % 10u));
}
prev_rl = error_code;
}
const auto screen_write_result = util::retry([&] { return io::seven_seg::write(screen_buf); }, 3);
assert(screen_write_result.has_value());
}

constexpr app::screens::Screen app::screens::inv_error_screen = {
[] {},
[] {},
update,
};
57 changes: 31 additions & 26 deletions firmware/hexray/CRIT/src/app/screens/app_screens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,35 @@
namespace app::screens
{
/************************* Global Variables ***************************/
inline constexpr size_t NUM_DEVICE_SCREENS = 3u;
inline constexpr size_t NUM_DEVICE_SCREENS = 4u;
inline constexpr size_t LV_MAX = 3u;
inline constexpr size_t HV_MAX = 3u;
static size_t current_screen = 0;

static std::array<const Screen *, NUM_DEVICE_SCREENS> drive_screens = { {
&shdn_screen,
&brightness_screen,
&drive_modes_screen,
} };
static std::array<const Screen *, NUM_DEVICE_SCREENS> drive_screens = { { &shdn_screen, &brightness_screen,
&drive_modes_screen, &inv_error_screen } };

static size_t screen_count()
{
switch (can_rx::VC_State_get())
{
case can_utils::VCState::VC_DRIVE_WARNING_STATE:
case can_utils::VCState::VC_FAULT_STATE:
case can_utils::VCState::VC_INVERTER_FAULT_HANDELER:
// disable rotary
return 0;
case can_utils::VCState::VC_PCM_ON_STATE:
case can_utils::VCState::VC_HV_INIT_STATE:
case can_utils::VCState::VC_INVERTER_ON_STATE:
case can_utils::VCState::VC_BMS_ON_STATE:
case can_utils::VCState::VC_INIT_STATE:
default:
return LV_MAX;
case can_utils::VCState::VC_HV_ON_STATE:
case can_utils::VCState::VC_DRIVE_STATE:
return HV_MAX;
}
}

/*********************** Function Definitions ***************************/
void init()
Expand All @@ -28,26 +47,10 @@ void init()
[]
{
// transition to next
size_t max_screens;
switch (can_rx::VC_State_get())
const size_t max_screens = screen_count();
if (max_screens == 0)
{
case can_utils::VCState::VC_DRIVE_WARNING_STATE:
case can_utils::VCState::VC_FAULT_STATE:
case can_utils::VCState::VC_INVERTER_FAULT_HANDELER:
// disable rotary
return;
case can_utils::VCState::VC_PCM_ON_STATE:
case can_utils::VCState::VC_HV_INIT_STATE:
case can_utils::VCState::VC_INVERTER_ON_STATE:
case can_utils::VCState::VC_BMS_ON_STATE:
case can_utils::VCState::VC_INIT_STATE:
default:
max_screens = LV_MAX;
break;
case can_utils::VCState::VC_HV_ON_STATE:
case can_utils::VCState::VC_DRIVE_STATE:
max_screens = HV_MAX;
break;
return;
}
current_screen = (current_screen + 1) % max_screens;
});
Expand All @@ -63,9 +66,11 @@ void tick()
{
case can_utils::VCState::VC_DRIVE_WARNING_STATE:
case can_utils::VCState::VC_FAULT_STATE:
case can_utils::VCState::VC_INVERTER_FAULT_HANDELER:
alerts_screen.update();
return;
case can_utils::VCState::VC_INVERTER_FAULT_HANDELER:
inv_error_screen.update();
return;
case can_utils::VCState::VC_INIT_STATE:
case can_utils::VCState::VC_INVERTER_ON_STATE:
case can_utils::VCState::VC_PCM_ON_STATE:
Expand Down
1 change: 1 addition & 0 deletions firmware/hexray/CRIT/src/app/screens/app_screens.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ extern const Screen shdn_screen;
extern const Screen alerts_screen;
extern const Screen brightness_screen;
extern const Screen drive_modes_screen;
extern const Screen inv_error_screen;

/**
* @brief Initalize all screens, and starting init screen.
Expand Down
Loading