machine-mode: getsupplyswitch

Example:
    SEND ::getsupplyswitch:1395[]
    REVC ::supplyswitch[5V]
    REVC :🆗1395
This commit is contained in:
Niklas Cathor 2024-01-06 10:18:17 +01:00
parent e4f1517214
commit 8c425c441c
3 changed files with 15 additions and 3 deletions

View File

@ -22,7 +22,7 @@ ArduinoJson::DynamicJsonDocument machineModeJson(8000);
enum machineModeInstruction lastReceivedInstruction = unknown;
char machineModeInstructionString[NUMBEROFINSTRUCTIONS][20] = {"unknown", "netlist", "getnetlist", "bridgelist", "getbridgelist", "lightnode", "lightnet", "getmeasurement", "gpio", "uart", "arduinoflash", "setnetcolor", "setnodecolor", "setsupplyswitch"};
char machineModeInstructionString[NUMBEROFINSTRUCTIONS][20] = {"unknown", "netlist", "getnetlist", "bridgelist", "getbridgelist", "lightnode", "lightnet", "getmeasurement", "gpio", "uart", "arduinoflash", "setnetcolor", "setnodecolor", "setsupplyswitch", "getsupplyswitch"};
enum machineModeInstruction parseMachineInstructions(int *sequenceNumber)
{
@ -495,6 +495,12 @@ void lightUpNodesFromInputBuffer(void)
}
}
void printSupplySwitch(int supplySwitchPos) {
const char *positionString[] = { "3.3V", "5V", "8V" };
Serial.print("::supplyswitch[");
Serial.print(positionString[supplySwitchPos]);
Serial.println("]");
}
int setSupplySwitch(void)
{

View File

@ -1,7 +1,7 @@
#ifndef MACHINECOMMANDS_H
#define MACHINECOMMANDS_H
#define NUMBEROFINSTRUCTIONS 15
#define NUMBEROFINSTRUCTIONS 16
enum machineModeInstruction
{
@ -18,7 +18,8 @@ enum machineModeInstruction
arduinoflash,
setnetcolor,
setnodecolor,
setsupplyswitch
setsupplyswitch,
getsupplyswitch
};
extern char inputBuffer[INPUTBUFFERLENGTH];
@ -39,6 +40,7 @@ void lightUpNodesFromInputBuffer(void);
void lightUpNetsFromInputBuffer(void);
void printSupplySwitch(int supplySwitchPos);
int setSupplySwitch(void);
void listNetsMachine(void);

View File

@ -543,6 +543,10 @@ void machineMode(void) // read in commands in machine readable format
showLEDsCore2 = 1;
break;
case getsupplyswitch:
printSupplySwitch(supplySwitchPosition);
break;
// case gpio:
// break;