Hello,
I have tried to utilize the enum function to label the values that need to be handled via array like so:
int ParameterReadAddress[27] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1C, 0x1D};
int ParameterReadValue[27];
enum ParameterReadName {
OutputFrequency,
CommandedFrequency,
OutputVoltage,
DCBusVoltage,
DriveStatus,
Fault1Code,
Fault2Code,
Fault3Code,
ProcessDisplay,
ControlSource,
ContrlInStatus,
DigInStatus,
ControlSWVer,
DriveType,
ElapsedRunTime,
TestpointData,
AnalogIn0to10V,
OutputPower,
OutputPowerFctr,
DriveTemp,
CounterStatus,
TimerStatus,
StpLogicStatus,
TorqueCurrent
};
Later on, I try to call this:
void CheckFlag() {
StartFlag = 1;
if (ParameterReadValue[ParameterReadName OutputFrequency] > 30) {
StartFlag = 0;
}
}
This is not working and throwing the error:
Arduino: 1.8.13 (Windows Store 1.8.42.0) (Windows 10), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"
VFD_Control:346:44: error: expected primary-expression before 'OutputFrequency'
if (ParameterReadValue[ParameterReadName OutputFrequency] > 30) {
^~~~~~~~~~~~~~~
VFD_Control:346:44: error: expected ']' before 'OutputFrequency'
VFD_Control:346:44: error: expected ')' before 'OutputFrequency'
VFD_Control:346:59: error: expected primary-expression before ']' token
if (ParameterReadValue[ParameterReadName OutputFrequency] > 30) {
^
exit status 1
expected primary-expression before 'OutputFrequency'
I have tried following examples of the enum function, but this it clearly not working. Does anyone have any advice on how to properly use the enum, or if I'm missing something?
Thank you in advance,
JPM