// Tuesday 5 July 2022:
// Thu 14 Sep 2023 1344 revisited.
// Experimental code for Switch/Case structure.
// Much faster than my existing method. (Not sure what that means?)
#include <Toggle.h>
const byte folderPin = 6; // Orig A5
byte folderCode;
Toggle folder(folderPin); // Assign folder as folderPin for library
void setup()
{
Serial.begin(115200);
folder.begin(folderPin); // Button being used to start extra folders
pinMode(2, OUTPUT); // TEMPORARY
}
void loop()
{
folder.poll(); // check status
folderCode = folder.pressCode(1); // debug: (1) on, () off
actionCases();
}
void actionCases()
{
switch (folderCode)
{
case 0xF1:
Serial.print(F("code = "));
Serial.println(folderCode);
Serial.println(F("1 brief press made"));
// Some other action, e.g. start playing a music folder
delay(1);
break;
case 0xF2:
Serial.print(F("code = "));
Serial.println(folderCode);
Serial.println(F("2 brief presses made"));
// Some other action, e.g. start playing a music folder
digitalWrite(2, HIGH); // Temporary
break;
default:
// Serial.println("folderCode was none of the above");
break;
}
}