blahlicus / animus-family

keyboard firmware family for arduino compatible atmega u series microcontrollers
Apache License 2.0
76 stars 21 forks source link

Animus 3 - double presses #32

Closed BlackCapCoder closed 5 years ago

BlackCapCoder commented 5 years ago

This may or may not the the same issue as #30.

I am getting a lot of double presses on the right half of my diverge 4, but not on the left. I have tested with the refresh rate set all the way up to 80, and the problem is still present, which leaves me doubtful that this is a debounce issue.

For reference, with a standard qwerty layout and the refresh rate set to 17 on the left half and 50 on the right, I typed "lorem" a bunch of times:

lorem lorem llorem lorem loorem llorem lorem lorem loorem lorem loorem lorem lorem
lorem lorem lorem lorem lorem lorem llorem llorem lorem lorem lorem loorem lorem lorem
lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem
lorem lorem lorem lorem loorem lorem lorem lorem lorem lorem lorem lorem lorem lorem
lorem lorem loorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem
lorem lorem lorem lorem lorem lorem loorem loorem lorem lorem loorem lorem lorem lorem

l and o are the only letters to be duplicated, both of which are on the right half of the keyboard. It is also curious that I always get double presses, never 3 or more which you would expect with debounce.

BlackCapCoder commented 5 years ago

Nevermind- it's debounce and a duplicate of #30. I guess the difference between my left and right half are just slight variations in hardware; The m key is never duplicated in my example, despite being on the right side of the keyboard.

Anyways, adding the elseif part at the bottom here fixed the issue for me, with a refresh delay of 10:

if (Global.KeyState[j][i] == HIGH) // if key is down
{
  if (Global.KeyStateCoolDown[j][i] == 0) // if key was not recently released
  {
    PressCoords(j, i);
    Global.LayerState[j][i] = Global.TempLayer;
    PrePress(PersMem.GetKeyData(j, i, Global.TempLayer), PersMem.GetKeyType(j, i, Global.TempLayer));
    PressKey(PersMem.GetKeyData(j, i, Global.TempLayer), PersMem.GetKeyType(j, i, Global.TempLayer));
    Global.KeyStateCoolDown[j][i] = 255;
  } else if (Global.KeyStateCoolDown[j][i] != 255) {
    Global.KeyStateCoolDown[j][i] = Global.RefreshDelay;
  }
}