Integrate all the progress into master #6

Merged
jaby merged 595 commits from ToolBox into main 2025-01-01 13:17:44 +00:00
1 changed files with 7 additions and 10 deletions
Showing only changes of commit 2b371dc473 - Show all commits

View File

@ -13,7 +13,7 @@ namespace ScreenCenter {
struct ButtonWatcher {
enum struct State {
WentDown,
DownFor25000ms,
DownFor2500ms,
Unkown
};
@ -26,19 +26,16 @@ namespace ScreenCenter {
State check(GenericButton button) {
const auto controller = Periphery::get_primary_controller_as<Periphery::GenericController>();
if(controller.button.went_down(button)) {
if(!controller.button.was_down(button)) {
this->timer.reset();
return State::WentDown;
}
if(controller.button.was_down(button)) {
if(this->timer.is_expired_for(2500_ms)) {
return State::DownFor25000ms;
if(controller.button.went_down(button)) {
return State::WentDown;
}
}
else {
this->timer.reset();
if(this->timer.is_expired_for(2500_ms)) {
return State::DownFor2500ms;
}
return State::Unkown;
}
@ -96,7 +93,7 @@ namespace ScreenCenter {
static const auto handle_button = [](ButtonWatcher& button_state, GenericButton button, int16_t &dst, const int16_t mlp) {
switch(button_state.check(button)) {
case ButtonWatcher::State::WentDown:
case ButtonWatcher::State::DownFor25000ms:
case ButtonWatcher::State::DownFor2500ms:
dst += (1*mlp);
break;
}