// Tuesday 5 July 2022:
// Experimental code for Switch/Case structure.
// Presumably ALL cases are actioned, albeit the earlier ones
// for very brief durations? (As with my own method.)
// Much faster than my existing method.
#include <Toggle.h>
const byte folderPin = 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(); // debug: (1) on, () off
if (folderCode != 0)
{
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 neither of those two");
// break;
}
}