-
-
Notifications
You must be signed in to change notification settings - Fork 23
adding inv error to crit screen #2100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 6 commits
d1c41e9
e47ee34
076717d
ac259d0
06f5a59
68fee8a
cd1c202
8564ab8
6f6d934
a4fd70e
276559d
c6b681d
e4871d9
138e172
6614eec
808eb54
753444f
bcac262
c0b34d9
4b12b69
91b4b18
39ff472
8593eab
d12ad09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great changes