Refactor commands

Refactor commands
This commit is contained in:
Theo Arends 2019-08-11 15:18:11 +02:00
parent 01ca5f5cfb
commit 305cb8fd7e
4 changed files with 178 additions and 206 deletions

View File

@ -32,6 +32,10 @@
#define D_JSON_RF_PULSE "Pulse"
#define D_JSON_RF_REPEAT "Repeat"
const char kRfSendCommands[] PROGMEM = D_CMND_RFSEND;
void (* const RfSendCommand[])(void) PROGMEM = { &CmndRfSend };
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
@ -87,78 +91,72 @@ void RfInit(void)
* Commands
\*********************************************************************************************/
bool RfSendCommand(void)
void CmndRfSend(void)
{
bool serviced = true;
bool error = false;
if (!strcasecmp_P(XdrvMailbox.topic, PSTR(D_CMND_RFSEND))) {
if (XdrvMailbox.data_len) {
unsigned long data = 0;
unsigned int bits = 24;
int protocol = 1;
int repeat = 10;
int pulse = 350;
if (XdrvMailbox.data_len) {
unsigned long data = 0;
unsigned int bits = 24;
int protocol = 1;
int repeat = 10;
int pulse = 350;
char dataBufUc[XdrvMailbox.data_len];
UpperCase(dataBufUc, XdrvMailbox.data);
StaticJsonBuffer<150> jsonBuf; // ArduinoJSON entry used to calculate jsonBuf: JSON_OBJECT_SIZE(5) + 40 = 134
JsonObject &root = jsonBuf.parseObject(dataBufUc);
if (root.success()) {
// RFsend {"data":0x501014,"bits":24,"protocol":1,"repeat":10,"pulse":350}
char parm_uc[10];
data = strtoul(root[UpperCase_P(parm_uc, PSTR(D_JSON_RF_DATA))], nullptr, 0); // Allow decimal (5246996) and hexadecimal (0x501014) input
bits = root[UpperCase_P(parm_uc, PSTR(D_JSON_RF_BITS))];
protocol = root[UpperCase_P(parm_uc, PSTR(D_JSON_RF_PROTOCOL))];
repeat = root[UpperCase_P(parm_uc, PSTR(D_JSON_RF_REPEAT))];
pulse = root[UpperCase_P(parm_uc, PSTR(D_JSON_RF_PULSE))];
} else {
// RFsend data, bits, protocol, repeat, pulse
char *p;
uint8_t i = 0;
for (char *str = strtok_r(XdrvMailbox.data, ", ", &p); str && i < 5; str = strtok_r(nullptr, ", ", &p)) {
switch (i++) {
case 0:
data = strtoul(str, nullptr, 0); // Allow decimal (5246996) and hexadecimal (0x501014) input
break;
case 1:
bits = atoi(str);
break;
case 2:
protocol = atoi(str);
break;
case 3:
repeat = atoi(str);
break;
case 4:
pulse = atoi(str);
}
char dataBufUc[XdrvMailbox.data_len];
UpperCase(dataBufUc, XdrvMailbox.data);
StaticJsonBuffer<150> jsonBuf; // ArduinoJSON entry used to calculate jsonBuf: JSON_OBJECT_SIZE(5) + 40 = 134
JsonObject &root = jsonBuf.parseObject(dataBufUc);
if (root.success()) {
// RFsend {"data":0x501014,"bits":24,"protocol":1,"repeat":10,"pulse":350}
char parm_uc[10];
data = strtoul(root[UpperCase_P(parm_uc, PSTR(D_JSON_RF_DATA))], nullptr, 0); // Allow decimal (5246996) and hexadecimal (0x501014) input
bits = root[UpperCase_P(parm_uc, PSTR(D_JSON_RF_BITS))];
protocol = root[UpperCase_P(parm_uc, PSTR(D_JSON_RF_PROTOCOL))];
repeat = root[UpperCase_P(parm_uc, PSTR(D_JSON_RF_REPEAT))];
pulse = root[UpperCase_P(parm_uc, PSTR(D_JSON_RF_PULSE))];
} else {
// RFsend data, bits, protocol, repeat, pulse
char *p;
uint8_t i = 0;
for (char *str = strtok_r(XdrvMailbox.data, ", ", &p); str && i < 5; str = strtok_r(nullptr, ", ", &p)) {
switch (i++) {
case 0:
data = strtoul(str, nullptr, 0); // Allow decimal (5246996) and hexadecimal (0x501014) input
break;
case 1:
bits = atoi(str);
break;
case 2:
protocol = atoi(str);
break;
case 3:
repeat = atoi(str);
break;
case 4:
pulse = atoi(str);
}
}
}
if (!protocol) { protocol = 1; }
mySwitch.setProtocol(protocol);
if (!pulse) { pulse = 350; } // Default pulse length for protocol 1
mySwitch.setPulseLength(pulse);
if (!repeat) { repeat = 10; } // Default at init
mySwitch.setRepeatTransmit(repeat);
if (!bits) { bits = 24; } // Default 24 bits
if (data) {
mySwitch.send(data, bits);
Response_P(PSTR("{\"" D_CMND_RFSEND "\":\"" D_JSON_DONE "\"}"));
} else {
error = true;
}
if (!protocol) { protocol = 1; }
mySwitch.setProtocol(protocol);
if (!pulse) { pulse = 350; } // Default pulse length for protocol 1
mySwitch.setPulseLength(pulse);
if (!repeat) { repeat = 10; } // Default at init
mySwitch.setRepeatTransmit(repeat);
if (!bits) { bits = 24; } // Default 24 bits
if (data) {
mySwitch.send(data, bits);
ResponseCmndDone();
} else {
error = true;
}
if (error) {
Response_P(PSTR("{\"" D_CMND_RFSEND "\":\"" D_JSON_NO " " D_JSON_RF_DATA ", " D_JSON_RF_BITS ", " D_JSON_RF_PROTOCOL ", " D_JSON_RF_REPEAT " " D_JSON_OR " " D_JSON_RF_PULSE "\"}"));
}
} else {
error = true;
}
if (error) {
Response_P(PSTR("{\"" D_CMND_RFSEND "\":\"" D_JSON_NO " " D_JSON_RF_DATA ", " D_JSON_RF_BITS ", " D_JSON_RF_PROTOCOL ", " D_JSON_RF_REPEAT " " D_JSON_OR " " D_JSON_RF_PULSE "\"}"));
}
else serviced = false; // Unknown command
return serviced;
}
/*********************************************************************************************\
@ -171,9 +169,6 @@ bool Xdrv17(uint8_t function)
if ((pin[GPIO_RFSEND] < 99) || (pin[GPIO_RFRECV] < 99)) {
switch (function) {
case FUNC_INIT:
RfInit();
break;
case FUNC_EVERY_50_MSECOND:
if (pin[GPIO_RFRECV] < 99) {
RfReceiveCheck();
@ -181,9 +176,12 @@ bool Xdrv17(uint8_t function)
break;
case FUNC_COMMAND:
if (pin[GPIO_RFSEND] < 99) {
result = RfSendCommand();
result = DecodeCommand(kRfSendCommands, RfSendCommand);
}
break;
case FUNC_INIT:
RfInit();
break;
}
}
return result;

View File

@ -30,6 +30,10 @@ const uint8_t kIFan02Speed[MAX_FAN_SPEED] = { 0x00, 0x01, 0x03, 0x05 };
const uint8_t kIFan03Speed[MAX_FAN_SPEED +2] = { 0x00, 0x01, 0x03, 0x04, 0x05, 0x06 };
const uint8_t kIFan03Sequence[MAX_FAN_SPEED][MAX_FAN_SPEED] = {{0, 2, 2, 2}, {0, 1, 2, 4}, {1, 1, 2, 5}, {4, 4, 5, 3}};
const char kSonoffIfanCommands[] PROGMEM = D_CMND_FANSPEED;
void (* const SonoffIfanCommand[])(void) PROGMEM = { &CmndFanspeed };
uint8_t ifan_fanspeed_timer = 0;
uint8_t ifan_fanspeed_goal = 0;
bool ifan_receive_flag = false;
@ -184,35 +188,22 @@ bool SonoffIfanSerialInput(void)
* Commands
\*********************************************************************************************/
enum SonoffIfanCommands { CMND_FANSPEED };
const char kSonoffIfanCommands[] PROGMEM = D_CMND_FANSPEED;
bool SonoffIfanCommand(void)
void CmndFanspeed(void)
{
bool serviced = true;
int command_code = GetCommandCode(XdrvMailbox.command, CMDSZ, XdrvMailbox.topic, kSonoffIfanCommands);
if (-1 == command_code) {
serviced = false; // Unknown command
if (XdrvMailbox.data_len > 0) {
if ('-' == XdrvMailbox.data[0]) {
XdrvMailbox.payload = (int16_t)GetFanspeed() -1;
if (XdrvMailbox.payload < 0) { XdrvMailbox.payload = MAX_FAN_SPEED -1; }
}
else if ('+' == XdrvMailbox.data[0]) {
XdrvMailbox.payload = GetFanspeed() +1;
if (XdrvMailbox.payload > MAX_FAN_SPEED -1) { XdrvMailbox.payload = 0; }
}
}
else if (CMND_FANSPEED == command_code) {
if (XdrvMailbox.data_len > 0) {
if ('-' == XdrvMailbox.data[0]) {
XdrvMailbox.payload = (int16_t)GetFanspeed() -1;
if (XdrvMailbox.payload < 0) { XdrvMailbox.payload = MAX_FAN_SPEED -1; }
}
else if ('+' == XdrvMailbox.data[0]) {
XdrvMailbox.payload = GetFanspeed() +1;
if (XdrvMailbox.payload > MAX_FAN_SPEED -1) { XdrvMailbox.payload = 0; }
}
}
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload < MAX_FAN_SPEED)) {
SonoffIFanSetFanspeed(XdrvMailbox.payload, true);
}
ResponseCmndNumber(GetFanspeed());
} else serviced = false; // Unknown command
return serviced;
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload < MAX_FAN_SPEED)) {
SonoffIFanSetFanspeed(XdrvMailbox.payload, true);
}
ResponseCmndNumber(GetFanspeed());
}
/*********************************************************************************************/
@ -262,7 +253,7 @@ bool Xdrv22(uint8_t function)
result = SonoffIfanSerialInput();
break;
case FUNC_COMMAND:
result = SonoffIfanCommand();
result = DecodeCommand(kSonoffIfanCommands, SonoffIfanCommand);
break;
case FUNC_MODULE_INIT:
result = SonoffIfanInit();

View File

@ -24,6 +24,10 @@
#define XSNS_01 1
const char kCounterCommands[] PROGMEM = D_CMND_COUNTER "|" D_CMND_COUNTERTYPE "|" D_CMND_COUNTERDEBOUNCE ;
void (* const CounterCommand[])(void) PROGMEM = { &CmndCounter, &CmndCounterType, &CmndCounterDebounce };
unsigned long last_counter_timer[MAX_COUNTERS]; // Last counter time in micro seconds
#ifndef ARDUINO_ESP8266_RELEASE_2_3_0 // Fix core 2.5.x ISR not in IRAM Exception
@ -93,17 +97,10 @@ void CounterInit(void)
}
}
#ifdef USE_WEBSERVER
const char HTTP_SNS_COUNTER[] PROGMEM =
"{s}" D_COUNTER "%d{m}%s%s{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
#endif // USE_WEBSERVER
void CounterShow(bool json)
{
char stemp[10];
bool header = false;
uint8_t dsxflg = 0;
uint8_t header = 0;
for (uint32_t i = 0; i < MAX_COUNTERS; i++) {
if (pin[GPIO_CNTR1 +i] < 99) {
char counter[33];
@ -117,11 +114,9 @@ void CounterShow(bool json)
if (json) {
if (!header) {
ResponseAppend_P(PSTR(",\"COUNTER\":{"));
stemp[0] = '\0';
}
header++;
ResponseAppend_P(PSTR("%s\"C%d\":%s"), stemp, i +1, counter);
strlcpy(stemp, ",", sizeof(stemp));
ResponseAppend_P(PSTR("%s\"C%d\":%s"), (header)?",":"", i +1, counter);
header = true;
#ifdef USE_DOMOTICZ
if ((0 == tele_period) && (1 == dsxflg)) {
DomoticzSensor(DZ_COUNT, RtcSettings.pulse_counter[i]);
@ -130,7 +125,8 @@ void CounterShow(bool json)
#endif // USE_DOMOTICZ
#ifdef USE_WEBSERVER
} else {
WSContentSend_PD(HTTP_SNS_COUNTER, i +1, counter, (bitRead(Settings.pulse_counter_type, i)) ? " " D_UNIT_SECOND : "");
WSContentSend_PD(PSTR("{s}" D_COUNTER "%d{m}%s%s{e}"),
i +1, counter, (bitRead(Settings.pulse_counter_type, i)) ? " " D_UNIT_SECOND : "");
#endif // USE_WEBSERVER
}
}
@ -138,10 +134,8 @@ void CounterShow(bool json)
RtcSettings.pulse_counter[i] = 0xFFFFFFFF; // Set Timer to max in case of no more interrupts due to stall of measured device
}
}
if (json) {
if (header) {
ResponseJsonEnd();
}
if (header) {
ResponseJsonEnd();
}
}
@ -149,47 +143,40 @@ void CounterShow(bool json)
* Commands
\*********************************************************************************************/
enum CounterCommands { CMND_COUNTER, CMND_COUNTERTYPE, CMND_COUNTERDEBOUNCE };
const char kCounterCommands[] PROGMEM = D_CMND_COUNTER "|" D_CMND_COUNTERTYPE "|" D_CMND_COUNTERDEBOUNCE ;
bool CounterCommand(void)
void CmndCounter(void)
{
bool serviced = true;
int command_code = GetCommandCode(XdrvMailbox.command, CMDSZ, XdrvMailbox.topic, kCounterCommands);
if (CMND_COUNTER == command_code) {
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= MAX_COUNTERS)) {
if ((XdrvMailbox.data_len > 0) && (pin[GPIO_CNTR1 + XdrvMailbox.index -1] < 99)) {
if ((XdrvMailbox.data[0] == '-') || (XdrvMailbox.data[0] == '+')) {
RtcSettings.pulse_counter[XdrvMailbox.index -1] += XdrvMailbox.payload;
Settings.pulse_counter[XdrvMailbox.index -1] += XdrvMailbox.payload;
} else {
RtcSettings.pulse_counter[XdrvMailbox.index -1] = XdrvMailbox.payload;
Settings.pulse_counter[XdrvMailbox.index -1] = XdrvMailbox.payload;
}
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= MAX_COUNTERS)) {
if ((XdrvMailbox.data_len > 0) && (pin[GPIO_CNTR1 + XdrvMailbox.index -1] < 99)) {
if ((XdrvMailbox.data[0] == '-') || (XdrvMailbox.data[0] == '+')) {
RtcSettings.pulse_counter[XdrvMailbox.index -1] += XdrvMailbox.payload;
Settings.pulse_counter[XdrvMailbox.index -1] += XdrvMailbox.payload;
} else {
RtcSettings.pulse_counter[XdrvMailbox.index -1] = XdrvMailbox.payload;
Settings.pulse_counter[XdrvMailbox.index -1] = XdrvMailbox.payload;
}
Response_P(S_JSON_COMMAND_INDEX_LVALUE, XdrvMailbox.command, XdrvMailbox.index, RtcSettings.pulse_counter[XdrvMailbox.index -1]);
}
Response_P(S_JSON_COMMAND_INDEX_LVALUE, XdrvMailbox.command, XdrvMailbox.index, RtcSettings.pulse_counter[XdrvMailbox.index -1]);
}
else if (CMND_COUNTERTYPE == command_code) {
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= MAX_COUNTERS)) {
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 1) && (pin[GPIO_CNTR1 + XdrvMailbox.index -1] < 99)) {
bitWrite(Settings.pulse_counter_type, XdrvMailbox.index -1, XdrvMailbox.payload &1);
RtcSettings.pulse_counter[XdrvMailbox.index -1] = 0;
Settings.pulse_counter[XdrvMailbox.index -1] = 0;
}
ResponseCmndIdxNumber(bitRead(Settings.pulse_counter_type, XdrvMailbox.index -1));
}
}
else if (CMND_COUNTERDEBOUNCE == command_code) {
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload < 32001)) {
Settings.pulse_counter_debounce = XdrvMailbox.payload;
}
ResponseCmndNumber(Settings.pulse_counter_debounce);
}
else serviced = false; // Unknown command
}
return serviced;
void CmndCounterType(void)
{
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= MAX_COUNTERS)) {
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 1) && (pin[GPIO_CNTR1 + XdrvMailbox.index -1] < 99)) {
bitWrite(Settings.pulse_counter_type, XdrvMailbox.index -1, XdrvMailbox.payload &1);
RtcSettings.pulse_counter[XdrvMailbox.index -1] = 0;
Settings.pulse_counter[XdrvMailbox.index -1] = 0;
}
ResponseCmndIdxNumber(bitRead(Settings.pulse_counter_type, XdrvMailbox.index -1));
}
}
void CmndCounterDebounce(void)
{
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload < 32001)) {
Settings.pulse_counter_debounce = XdrvMailbox.payload;
}
ResponseCmndNumber(Settings.pulse_counter_debounce);
}
/*********************************************************************************************\
@ -201,9 +188,6 @@ bool Xsns01(uint8_t function)
bool result = false;
switch (function) {
case FUNC_INIT:
CounterInit();
break;
case FUNC_JSON_APPEND:
CounterShow(1);
break;
@ -217,7 +201,10 @@ bool Xsns01(uint8_t function)
CounterSaveState();
break;
case FUNC_COMMAND:
result = CounterCommand();
result = DecodeCommand(kCounterCommands, CounterCommand);
break;
case FUNC_INIT:
CounterInit();
break;
}
return result;

View File

@ -183,73 +183,69 @@ void AdcShow(bool json)
\*********************************************************************************************/
#define D_CMND_ADCPARAM "AdcParam"
enum AdcCommands { CMND_ADC, CMND_ADCS, CMND_ADCPARAM };
const char kAdcCommands[] PROGMEM = D_CMND_ADC "|" D_CMND_ADCS "|" D_CMND_ADCPARAM;
bool AdcCommand(void)
void (* const AdcCommand[])(void) PROGMEM = { &CmndAdc, &CmndAdcs, &CmndAdcParam };
void CmndAdc(void)
{
char command[CMDSZ];
bool serviced = true;
if (ValidAdc() && (XdrvMailbox.payload >= 0) && (XdrvMailbox.payload < ADC0_END)) {
Settings.my_adc0 = XdrvMailbox.payload;
restart_flag = 2;
}
char stemp1[TOPSZ];
Response_P(PSTR("{\"" D_CMND_ADC "0\":\"%d (%s)\"}"), Settings.my_adc0, GetTextIndexed(stemp1, sizeof(stemp1), Settings.my_adc0, kAdc0Names));
}
int command_code = GetCommandCode(command, sizeof(command), XdrvMailbox.topic, kAdcCommands);
if (CMND_ADC == command_code) {
if (ValidAdc() && (XdrvMailbox.payload >= 0) && (XdrvMailbox.payload < ADC0_END)) {
Settings.my_adc0 = XdrvMailbox.payload;
restart_flag = 2;
void CmndAdcs(void)
{
Response_P(PSTR("{\"" D_CMND_ADCS "\":["));
bool jsflg = false;
char stemp1[TOPSZ];
for (uint32_t i = 0; i < ADC0_END; i++) {
if (jsflg) {
ResponseAppend_P(PSTR(","));
}
char stemp1[TOPSZ];
Response_P(PSTR("{\"" D_CMND_ADC "0\":\"%d (%s)\"}"), Settings.my_adc0, GetTextIndexed(stemp1, sizeof(stemp1), Settings.my_adc0, kAdc0Names));
jsflg = true;
ResponseAppend_P(PSTR("\"%d (%s)\""), i, GetTextIndexed(stemp1, sizeof(stemp1), i, kAdc0Names));
}
else if (CMND_ADCS == command_code) {
Response_P(PSTR("{\"" D_CMND_ADCS "\":["));
bool jsflg = false;
char stemp1[TOPSZ];
for (uint32_t i = 0; i < ADC0_END; i++) {
if (jsflg) {
ResponseAppend_P(PSTR(","));
}
jsflg = true;
ResponseAppend_P(PSTR("\"%d (%s)\""), i, GetTextIndexed(stemp1, sizeof(stemp1), i, kAdc0Names));
}
ResponseAppend_P(PSTR("]}"));
}
else if (CMND_ADCPARAM == command_code) {
if (XdrvMailbox.data_len) {
if ((ADC0_TEMP == XdrvMailbox.payload) || (ADC0_LIGHT == XdrvMailbox.payload)) {
ResponseAppend_P(PSTR("]}"));
}
void CmndAdcParam(void)
{
if (XdrvMailbox.data_len) {
if ((ADC0_TEMP == XdrvMailbox.payload) || (ADC0_LIGHT == XdrvMailbox.payload)) {
// if ((XdrvMailbox.payload == my_adc0) && ((ADC0_TEMP == my_adc0) || (ADC0_LIGHT == my_adc0))) {
if (strstr(XdrvMailbox.data, ",") != nullptr) { // Process parameter entry
char sub_string[XdrvMailbox.data_len +1];
// AdcParam 2, 32000, 10000, 3350
// AdcParam 3, 10000, 12518931, -1.405
Settings.adc_param_type = XdrvMailbox.payload;
if (strstr(XdrvMailbox.data, ",") != nullptr) { // Process parameter entry
char sub_string[XdrvMailbox.data_len +1];
// AdcParam 2, 32000, 10000, 3350
// AdcParam 3, 10000, 12518931, -1.405
Settings.adc_param_type = XdrvMailbox.payload;
// Settings.adc_param_type = my_adc0;
Settings.adc_param1 = strtol(subStr(sub_string, XdrvMailbox.data, ",", 2), nullptr, 10);
Settings.adc_param2 = strtol(subStr(sub_string, XdrvMailbox.data, ",", 3), nullptr, 10);
Settings.adc_param3 = (int)(CharToFloat(subStr(sub_string, XdrvMailbox.data, ",", 4)) * 10000);
} else { // Set default values based on current adc type
// AdcParam 2
// AdcParam 3
Settings.adc_param_type = 0;
AdcInit();
}
Settings.adc_param1 = strtol(subStr(sub_string, XdrvMailbox.data, ",", 2), nullptr, 10);
Settings.adc_param2 = strtol(subStr(sub_string, XdrvMailbox.data, ",", 3), nullptr, 10);
Settings.adc_param3 = (int)(CharToFloat(subStr(sub_string, XdrvMailbox.data, ",", 4)) * 10000);
} else { // Set default values based on current adc type
// AdcParam 2
// AdcParam 3
Settings.adc_param_type = 0;
AdcInit();
}
}
// AdcParam
int value = Settings.adc_param3;
uint8_t precision;
for (precision = 4; precision > 0; precision--) {
if (value % 10) { break; }
value /= 10;
}
char param3[33];
dtostrfd(((double)Settings.adc_param3)/10000, precision, param3);
Response_P(PSTR("{\"" D_CMND_ADCPARAM "\":[%d,%d,%d,%s]}"),
Settings.adc_param_type, Settings.adc_param1, Settings.adc_param2, param3);
}
else serviced = false; // Unknown command
return serviced;
// AdcParam
int value = Settings.adc_param3;
uint8_t precision;
for (precision = 4; precision > 0; precision--) {
if (value % 10) { break; }
value /= 10;
}
char param3[33];
dtostrfd(((double)Settings.adc_param3)/10000, precision, param3);
Response_P(PSTR("{\"" D_CMND_ADCPARAM "\":[%d,%d,%d,%s]}"),
Settings.adc_param_type, Settings.adc_param1, Settings.adc_param2, param3);
}
/*********************************************************************************************\
@ -262,7 +258,7 @@ bool Xsns02(uint8_t function)
switch (function) {
case FUNC_COMMAND:
result = AdcCommand();
result = DecodeCommand(kAdcCommands, AdcCommand);
break;
default:
if ((ADC0_INPUT == my_adc0) || (ADC0_TEMP == my_adc0) || (ADC0_LIGHT == my_adc0)) {