Permalink
Browse files

Alter joystick to start slow but speed up the longer you move it. Thi…

…s makes the interface much easier to use but still allows percise work.
  • Loading branch information...
dulsi committed Jun 16, 2018
1 parent e92a337 commit bd68b3037f1e9fc2c9bcb8977b6dfdbb97993e5a
Showing with 14 additions and 5 deletions.
  1. +14 −5 colormonster.ino
@@ -22,11 +22,12 @@ SdFile dataFile;
#define STATE_PAINTZOOM 1
#define BUTTON_COOLDOWN 5
#define JOYSTICK_COOLDOWN 3
#define JOYSTICK_COOLDOWNSTART 4
int state = 0;
int buttonCoolDown = 0;
int joystickCoolDown = 0;
int joystickCoolDownStart = JOYSTICK_COOLDOWNSTART;
class ColorMonster
{
@@ -90,25 +91,33 @@ void Painter::update()
}
else
{
if (joyDir == 0)
joystickCoolDownStart = JOYSTICK_COOLDOWNSTART;
else
{
if (joystickCoolDownStart > 0)
joystickCoolDownStart--;
buttonCoolDown = 0;
}
if ((joyDir & TAJoystickUp) && (py > 0))
{
py--;
joystickCoolDown = JOYSTICK_COOLDOWN;
joystickCoolDown = joystickCoolDownStart;
}
else if ((joyDir & TAJoystickDown) && (py < 63))
{
py++;
joystickCoolDown = JOYSTICK_COOLDOWN;
joystickCoolDown = joystickCoolDownStart;
}
if ((joyDir & TAJoystickLeft) && (px > 0))
{
px--;
joystickCoolDown = JOYSTICK_COOLDOWN;
joystickCoolDown = joystickCoolDownStart;
}
else if ((joyDir & TAJoystickRight) && (px < 95))
{
px++;
joystickCoolDown = JOYSTICK_COOLDOWN;
joystickCoolDown = joystickCoolDownStart;
}
}
if (buttonCoolDown > 0)

0 comments on commit bd68b30

Please sign in to comment.