Skip to content

Commit

Permalink
Try to implement key hold
Browse files Browse the repository at this point in the history
  • Loading branch information
daltona committed Sep 23, 2013
1 parent 8abc308 commit cdf383a
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions pedalboard.ino
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,7 @@ save_data (int key)
buttons_config[key - 1] = cc_data;
}

void keypadevent(KeypadEvent evt) {
byte kpadState = keypad.getState();
Serial.print("State: ");Serial.println(kpadState);

Serial.print("KEY: ");Serial.println((int)evt);


}
void keypadevent(KeypadEvent evt);


void
Expand Down Expand Up @@ -289,17 +282,39 @@ run_menu (int key)
return current_menu (key);
}


byte keyState;
byte currentKey;

void keypadevent(KeypadEvent evt) {
keyState = keypad.getState();
currentKey = evt;
Serial.print("State: ");Serial.println(keyState);
Serial.print("KEY: ");Serial.println((int)evt);
}


int
getKey ()
{
static int8_t oldkey = -1;
char key = keypad.getKey ();

if (key != 0) {
currentKey = key;
Serial.println (key);
return key;
}

if (keyState == RELEASED) {
keyState = -1;
return currentKey;
} else if (keyState == HOLD) {
if (currentKey == 15) {
keyState = -1;
return MENU_ENTER;
}
}

key = lcd.get_key (); // read the value from the sensor & convert into key press

if (key != oldkey) {
Expand Down Expand Up @@ -349,6 +364,8 @@ void
loop ()
{
static int state = STATE_RUN;


int key = getKey ();

if (key != -1) {
Expand Down

0 comments on commit cdf383a

Please sign in to comment.