Display previous roll below roll counter

This commit is contained in:
Frederik Walk 2023-12-29 20:57:56 +01:00
parent bf94a1effb
commit c41af9c82d
4 changed files with 13 additions and 5 deletions

View File

@ -20,7 +20,8 @@ struct InputState {
};
Pad don_left, ka_left, don_right, ka_right;
uint16_t roll_counter;
uint16_t current_roll;
uint16_t previous_roll;
};
struct Controller {

View File

@ -58,8 +58,10 @@ void Display::drawIdleScreen() {
ssd1306_draw_line(&m_display, 0, 10, 128, 10);
// Roll counter
auto roll_str = std::to_string(m_input_state.drum.roll_counter) + " Roll";
auto roll_str = std::to_string(m_input_state.drum.current_roll) + " Roll";
auto prev_roll_str = "Last " + std::to_string(m_input_state.drum.previous_roll);
ssd1306_draw_string(&m_display, (127 - (roll_str.length() * 12)) / 2, 20, 2, roll_str.c_str());
ssd1306_draw_string(&m_display, (127 - (prev_roll_str.length() * 6)) / 2, 40, 1, prev_roll_str.c_str());
// Player "LEDs"
if (m_player_id != 0) {

View File

@ -102,9 +102,13 @@ void Drum::updateRollCounter(Utils::InputState &input_state) {
static bool last_ka_left_state = false;
static bool last_ka_right_state = false;
static uint16_t roll_count = 0;
static uint16_t previous_roll = 0;
uint32_t now = to_ms_since_boot(get_absolute_time());
if ((now - last_hit_time) > m_config.roll_counter_timeout_ms) {
if (roll_count > 1) {
previous_roll = roll_count;
}
roll_count = 0;
}
@ -130,7 +134,8 @@ void Drum::updateRollCounter(Utils::InputState &input_state) {
last_ka_left_state = input_state.drum.ka_left.triggered;
last_ka_right_state = input_state.drum.ka_right.triggered;
input_state.drum.roll_counter = roll_count;
input_state.drum.current_roll = roll_count;
input_state.drum.previous_roll = previous_roll;
}
void Drum::updateInputState(Utils::InputState &input_state) {

View File

@ -6,7 +6,7 @@
namespace Doncon::Utils {
InputState::InputState()
: drum({{false, 0}, {false, 0}, {false, 0}, {false, 0}, 0}),
: drum({{false, 0}, {false, 0}, {false, 0}, {false, 0}, 0, 0}),
controller(
{{false, false, false, false}, {false, false, false, false, false, false, false, false, false, false}}),
m_switch_report({}), m_ps3_report({}), m_ps4_report({}), m_keyboard_report({}),
@ -328,7 +328,7 @@ usb_report_t InputState::getDebugReport() {
}
void InputState::releaseAll() {
drum = {{false, 0}, {false, 0}, {false, 0}, {false, 0}, 0};
drum = {{false, 0}, {false, 0}, {false, 0}, {false, 0}, 0, 0};
controller = {{false, false, false, false}, {false, false, false, false, false, false, false, false, false, false}};
}