There you go again!
I have only a few increments of time here, so:
One:
Now that doBank and doDown have legitimate actions given the realMode, the <whatevs> here
// bankUp();
// bankDown();
if (realMode == READ) {
if (doBank) {
// whatevs
}
if (doDown) {
// whatevs
}
}
if (realMode == WRITE) {
if (doBank) {
// whatevs
}
if (doDown) {
}
// whatevs
}
should really be moved into place in the one switch/case so the logic is entirely
what mode are we in + what button got pressed = some action to take maybe changing the mode as part of that action.
Two:
Just curious why the pended mechanism was commented out here:
case SAVED :
// lcdDwellTime = now; // transient message. time or user activity moves to the pended screen
It means that screen whistles by, no one will see it.
Three:
The There you go again! was for kludging the keyboard column with a switch. I won't share her reaction. At least it isn't a relay. ![]()
Keep the keyboard doing its job - telling you which key got pressed. Use logic to adjust it if you are in some kind of alternate mode, like if a real keyboard you had the control key pressed, perhaps like this:
// define a shift button or switch input up top
const byte shiftKey = 2;
// and
// in setup
pinMode(shiftKey, INPUT_PULLUP); // wire middle and one end between pin and GND
// then here account for the shift or alternate function
char key = keypad.getKey();
if (!key)
key = NOKEY;
else {
key -= 'a';
if (digitalRead(2) == HIGH)
key += cols; // bump 0..N - 1 to N..2N -1, here 0..7 becomes 8..15
}
As I said, a well-written sketch can tolerate a certain amount of "hey, if I just do this here, that over there will work like I want it to". So defer, delay and avoid spending that capital until absolutely necessary. Here it is entirely avoidable, and doing isn't even a hack - shiftig the keypad returned number at the only point where you read it is 100 percent legit.
Four:
There are a few paintLCD() calls and I think the ACK blinker launch call that are scattered. They can (we did it) and should be moved into the loop() realMode switch/case. Not sure what name to give that, let's just call it keeping things that do different stuff more all like in one place, and let the little helper functions just do what they need to, viz:
if (key != NOKEY) {
memory(currentBank * bankSize + numberOfPedals * key, key); // theAddr, theLED
paintLCD(SAVED, theLED); // let her know (transient screen)
blinkAnAck(theLED); // kick start the ACK blinker
realMode = READ; // (pended screen)
paintLCD(RUN, 0, 101);
}
Last:
Start getting aggressive about removing stuff that was found to be in error, or is obsolete. Leave things if you need to remember how they were, but this kinda thing
if (doSave) {
// dumbBitchLCD();
paintLCD(DUMBBITCH);
is where I mean lose it, it is of no further interest. If only so that searching in N hundred lines of code you won't be tripping over things like that - you may have seen in some commented stuff I mangle a word so it is readable but not findable, and also this was why I made okDelay(), so a case-sensitive search for delay() will only find actual uses of a real, not-OK delay. Of which there should, in the end be but one... found in okDelay().
And you must be the judge, when you introduce delay() anywhere, that it is indeed OK.
BTW - outta time, I'll look L8R, but have you changed away the hardware so there are no longer any single-coil latching relays?
a7
