Skip to content

Commit

Permalink
Working on repeat
Browse files Browse the repository at this point in the history
  • Loading branch information
revision29 committed Oct 15, 2023
1 parent 20906cd commit 714af79
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/remotecontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void RemoteControl::handle()
return;
}
}
lastResult = result;
//lastResult = result;

auto &effectManager = g_ptrSystem->EffectManager();

Expand All @@ -112,6 +112,27 @@ void RemoteControl::handle()
//debugV("We have a matching keycode 0x%08X \n", result);
auto index = std::distance(myRemoteController.buttons.begin(), keyCodeMatch);
RemoteButton thisButton = myRemoteController.buttons[index];

if (result == lastResult)
{
static uint lastRepeatTime = millis();
static auto kMinRepeatms = (thisButton.buttonAction == BRIGHTNESS_DOWN || thisButton.buttonAction == BRIGHTNESS_UP) ? 150 : 250;
//We do not want to set the kMinRepeatms to 0 because some remotes send a code more than once and also there might be refelctive surfaces that will cause the signal to be recieved more than once in rapid succession.
//250 will allow 4 units brightness changes over one second. That will be about 3 seconds to fully ramp the brightnss up or down
if (millis() - lastRepeatTime > kMinRepeatms)
{
debugV("Remote Repeat; lastResult == %08x, elapsed = %lu\n", lastResult, millis()-lastRepeatTime);
lastRepeatTime = millis();
}
else
{
return;
}

}
lastResult = result;


auto &myEffect = effectManager.GetCurrentEffect();

switch (thisButton.buttonAction){
Expand Down

0 comments on commit 714af79

Please sign in to comment.