Adding directly settable commands (instead of volume up/down, set volume to xx)
This commit is contained in:
@@ -263,58 +263,12 @@ unsigned long Hex2Dec(uint8_t *p, int dig);
|
||||
void GetAndSendCustomMessage();
|
||||
void GetAndSendOSDMessage();
|
||||
|
||||
void EmitRuntimeHelp();
|
||||
|
||||
bool UserExitRequested = false;
|
||||
bool SystemExitRequested = false;
|
||||
|
||||
typedef struct {
|
||||
const char *pMsg;
|
||||
uint16_t MsgLen;
|
||||
} Message_T;
|
||||
|
||||
typedef struct {
|
||||
const char Char;
|
||||
const char *pDescription;
|
||||
Message_T TxMsg;
|
||||
} UserCmd_T;
|
||||
|
||||
// Runtime commands from the keyboard to send to the AVR
|
||||
//
|
||||
const UserCmd_T UserCommands[] = {
|
||||
{ 'R', "Ready", {"\x11" "000" "\x03", 5 } },
|
||||
//{ 'P', "Power On", {"\x02" "07A1D" "\x03", 7} },
|
||||
//{ 'p', "Power Off", {"\x02" "07A1E" "\x03", 7} },
|
||||
{ '1', "Zone 1 On", {"\x02" "07E7E" "\x03", 7} },
|
||||
{ '!', "Zone 1 Standby", {"\x02" "07E7F" "\x03", 7} },
|
||||
{ '2', "Zone 2 On", {"\x02" "07EBA" "\x03", 7} },
|
||||
{ '@', "Zone 2 Standby", {"\x02" "07EBB" "\x03", 7} },
|
||||
{ '3', "Zone 3 On", {"\x02" "07AED" "\x03", 7} },
|
||||
{ '#', "Zone 3 Standby", {"\x02" "07AEE" "\x03", 7} },
|
||||
{ 'V', "Vol 1 Up", {"\x02" "07A1A" "\x03", 7} },
|
||||
{ 'v', "Vol 1 Down", {"\x02" "07A1B" "\x03", 7} },
|
||||
{ 'M', "Vol 1 Mute", {"\x02" "07EA2" "\x03", 7} },
|
||||
{ 'm', "Vol 1 UnMute", {"\x02" "07EA3" "\x03", 7} },
|
||||
{ 'O', "OSD Test Message", },
|
||||
{ 'T', "Tuning freq rqst", {"\x02" "22000" "\x03", 7} },
|
||||
{ 'Y', "Zone 1 Vol rqst", {"\x02" "22001" "\x03", 7} },
|
||||
{ 'y', "Zone 2 Vol rqst", {"\x02" "22002" "\x03", 7} },
|
||||
{ 'U', "Zone 1 Input rqst", {"\x02" "22003" "\x03", 7} },
|
||||
{ 'u', "Zone 2 Input rqst", {"\x02" "22004" "\x03", 7} },
|
||||
{ 'I', "Zone 3 Vol rqst", {"\x02" "22005" "\x03", 7} },
|
||||
{ 'i', "Zone 3 Input rqst", {"\x02" "22006" "\x03", 7} },
|
||||
//{ 'J', "Dual Mono - Main", {"\x02" "07E93" "\x03", 7} },
|
||||
//{ 'K', "Dual Mono - Sub", {"\x02" "07E94" "\x03", 7} },
|
||||
//{ 'L', "Dual Mono - All", {"\x02" "07E95" "\x03", 7} },
|
||||
{ ':', "Custom Message" },
|
||||
{ '/', "Show All" },
|
||||
{ '?', "Help on runtime commands" },
|
||||
{ 'S', "Set RTS" },
|
||||
{ 's', "Clear RTS" },
|
||||
{ '\x1B', "Quit App" },
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
//uint8_t type; // 0 to 4, and 0xFF for don't care
|
||||
//uint8_t guard; // 0 to 2, and 0xFF for don't care
|
||||
uint8_t rCmd;
|
||||
uint8_t configOffset; // offset into the Config DT0 - DT155 array, or 0xFF for no action
|
||||
uint8_t numToTransfer; // number of bytes to transfer into the Config array, or 0 for no action
|
||||
@@ -323,24 +277,6 @@ typedef struct {
|
||||
const char *(*fncValueToText)(uint8_t rDat);
|
||||
} MessageHandler_T;
|
||||
|
||||
void UserCommandsSanityCheck() {
|
||||
uint8_t usedKey[256] = { 0 };
|
||||
bool fail = false;
|
||||
|
||||
size_t numCommands = sizeof(UserCommands) / sizeof(UserCmd_T);
|
||||
for (size_t i = 0; i < numCommands; i++) {
|
||||
usedKey[UserCommands[i].Char]++;
|
||||
if (usedKey[UserCommands[i].Char] > 1) {
|
||||
printf("UserCommandsSanityCheck: Command key %c used more than once\n", UserCommands[i].Char);
|
||||
fail = true;
|
||||
}
|
||||
}
|
||||
if (fail) {
|
||||
printf("***** UserCommandsSanityCheck: Errors found in UserCommands table\n");
|
||||
exit(EXIT_InternalSanityCheckFail);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int CS_KeyHit() {
|
||||
int h = _kbhit();
|
||||
@@ -401,37 +337,59 @@ void EmitSpinner() {
|
||||
if (x == 8) x = 0;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
const char *pMsg;
|
||||
uint16_t MsgLen;
|
||||
} Message_T;
|
||||
|
||||
void EmitRuntimeHelp() {
|
||||
for (int i = 0; i < sizeof(UserCommands) / sizeof(UserCmd_T); i++) {
|
||||
char tinyBuf[6];
|
||||
if (isprint(UserCommands[i].Char)) {
|
||||
sprintf_s(tinyBuf, sizeof(tinyBuf), "%c", UserCommands[i].Char);
|
||||
} else if (UserCommands[i].Char == '\x1B') {
|
||||
sprintf_s(tinyBuf, sizeof(tinyBuf), "%s", "<esc>");
|
||||
} else if (UserCommands[i].Char < ' ') {
|
||||
sprintf_s(tinyBuf, sizeof(tinyBuf), "^%c", UserCommands[i].Char + 64);
|
||||
} else {
|
||||
sprintf_s(tinyBuf, sizeof(tinyBuf), "0x%02X", (unsigned char)UserCommands[i].Char);
|
||||
}
|
||||
char buf[MAXTEXTLEN];
|
||||
sprintf_s(buf, MAXTEXTLEN, " %5s %-25s", tinyBuf, UserCommands[i].pDescription);
|
||||
Console_AdvanceToNextLineIfNotRoomFor((short)strlen(buf), 1);
|
||||
Console_Write(buf);
|
||||
}
|
||||
if (avrPort.IsOpen()) {
|
||||
Console_ScrollBottomRegion();
|
||||
Console_SetCursor(0, -1);
|
||||
printf(" Com Status: RTS: %-3s ", avrPort.Get_RTS_State() ? "ON" : "OFF");
|
||||
printf("DTR: %-3s ", avrPort.Get_DTR_State() ? "ON" : "OFF");
|
||||
printf("CTS: %-3s ", avrPort.Get_CTS_State() ? "ON" : "OFF");
|
||||
printf("DSR: %-3s ", avrPort.Get_DSR_State() ? "ON" : "OFF");
|
||||
printf("RI: %-3s", avrPort.Get_RI_State() ? "ON" : "OFF");
|
||||
Console_ScrollBottomRegion();
|
||||
Console_SetCursor(0, -1);
|
||||
}
|
||||
}
|
||||
typedef struct {
|
||||
const char Char;
|
||||
const char *pDescription;
|
||||
Message_T TxMsg;
|
||||
} UserCmd_T;
|
||||
|
||||
// Runtime commands from the keyboard to send to the AVR
|
||||
//
|
||||
// [ESC]
|
||||
// [1!] [2@] [3#] 4 5 6 7 8 9 0 - =
|
||||
// qQ wW eE r[R] t[T] [yY] [uU] [iI] o[O] [pP] [{ ]} \|
|
||||
// aA [sS] dD f[F] gG hH jJ kK lL ;[:] '"
|
||||
// zZ xX cC [vV] bB nN [mM] ,< .> [/?]
|
||||
//
|
||||
const UserCmd_T UserCommands[] = {
|
||||
{ 'R', "Ready", {"\x11" "000" "\x03", 5 } },
|
||||
{ 'P', "Power On", },
|
||||
{ 'p', "Power Off", },
|
||||
{ '1', "Zone 1 On", {"\x02" "07E7E" "\x03", 7} },
|
||||
{ '!', "Zone 1 Standby", {"\x02" "07E7F" "\x03", 7} },
|
||||
{ '2', "Zone 2 On", {"\x02" "07EBA" "\x03", 7} },
|
||||
{ '@', "Zone 2 Standby", {"\x02" "07EBB" "\x03", 7} },
|
||||
{ '3', "Zone 3 On", {"\x02" "07AED" "\x03", 7} },
|
||||
{ '#', "Zone 3 Standby", {"\x02" "07AEE" "\x03", 7} },
|
||||
{ 'V', "Vol 1 Up", {"\x02" "07A1A" "\x03", 7} },
|
||||
{ 'v', "Vol 1 Down", {"\x02" "07A1B" "\x03", 7} },
|
||||
{ 'M', "Vol 1 Mute", {"\x02" "07EA2" "\x03", 7} },
|
||||
{ 'm', "Vol 1 UnMute", {"\x02" "07EA3" "\x03", 7} },
|
||||
{ 'O', "OSD Test Message", },
|
||||
{ 'T', "Tuning freq rqst", {"\x02" "22000" "\x03", 7} },
|
||||
{ 'Y', "Zone 1 Vol rqst", {"\x02" "22001" "\x03", 7} },
|
||||
{ 'y', "Zone 2 Vol rqst", {"\x02" "22002" "\x03", 7} },
|
||||
{ 'U', "Zone 1 Input rqst", {"\x02" "22003" "\x03", 7} },
|
||||
{ 'u', "Zone 2 Input rqst", {"\x02" "22004" "\x03", 7} },
|
||||
{ 'I', "Zone 3 Vol rqst", {"\x02" "22005" "\x03", 7} },
|
||||
{ 'i', "Zone 3 Input rqst", {"\x02" "22006" "\x03", 7} },
|
||||
{ 'F', "Factory Reset", {"\x13" "\x7F\x7F\x7F" "\x03", 5} },
|
||||
|
||||
//{ 'J', "Dual Mono - Main", {"\x02" "07E93" "\x03", 7} },
|
||||
//{ 'K', "Dual Mono - Sub", {"\x02" "07E94" "\x03", 7} },
|
||||
//{ 'L', "Dual Mono - All", {"\x02" "07E95" "\x03", 7} },
|
||||
{ ':', "Custom Message" },
|
||||
{ '/', "Show All" },
|
||||
{ '?', "Help on runtime commands" },
|
||||
{ 'S', "Set RTS" },
|
||||
{ 's', "Clear RTS" },
|
||||
{ '\x1B', "Quit App" },
|
||||
};
|
||||
|
||||
void ProcessKeyboard(void) {
|
||||
static uint32_t spin = 0;
|
||||
@@ -497,6 +455,55 @@ void ProcessKeyboard(void) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void UserCommandsSanityCheck() {
|
||||
uint8_t usedKey[256] = { 0 };
|
||||
bool fail = false;
|
||||
|
||||
size_t numCommands = sizeof(UserCommands) / sizeof(UserCmd_T);
|
||||
for (size_t i = 0; i < numCommands; i++) {
|
||||
usedKey[UserCommands[i].Char]++;
|
||||
if (usedKey[UserCommands[i].Char] > 1) {
|
||||
printf("UserCommandsSanityCheck: Command key %c used more than once\n", UserCommands[i].Char);
|
||||
fail = true;
|
||||
}
|
||||
}
|
||||
if (fail) {
|
||||
printf("***** UserCommandsSanityCheck: Errors found in UserCommands table\n");
|
||||
exit(EXIT_InternalSanityCheckFail);
|
||||
}
|
||||
}
|
||||
|
||||
void EmitRuntimeHelp() {
|
||||
for (int i = 0; i < sizeof(UserCommands) / sizeof(UserCmd_T); i++) {
|
||||
char tinyBuf[6];
|
||||
if (isprint(UserCommands[i].Char)) {
|
||||
sprintf_s(tinyBuf, sizeof(tinyBuf), "%c", UserCommands[i].Char);
|
||||
} else if (UserCommands[i].Char == '\x1B') {
|
||||
sprintf_s(tinyBuf, sizeof(tinyBuf), "%s", "<esc>");
|
||||
} else if (UserCommands[i].Char < ' ') {
|
||||
sprintf_s(tinyBuf, sizeof(tinyBuf), "^%c", UserCommands[i].Char + 64);
|
||||
} else {
|
||||
sprintf_s(tinyBuf, sizeof(tinyBuf), "0x%02X", (unsigned char)UserCommands[i].Char);
|
||||
}
|
||||
char buf[MAXTEXTLEN];
|
||||
sprintf_s(buf, MAXTEXTLEN, " %5s %-25s", tinyBuf, UserCommands[i].pDescription);
|
||||
Console_AdvanceToNextLineIfNotRoomFor((short)strlen(buf), 1);
|
||||
Console_Write(buf);
|
||||
}
|
||||
if (avrPort.IsOpen()) {
|
||||
Console_ScrollBottomRegion();
|
||||
Console_SetCursor(0, -1);
|
||||
printf(" Com Status: RTS: %-3s ", avrPort.Get_RTS_State() ? "ON" : "OFF");
|
||||
printf("DTR: %-3s ", avrPort.Get_DTR_State() ? "ON" : "OFF");
|
||||
printf("CTS: %-3s ", avrPort.Get_CTS_State() ? "ON" : "OFF");
|
||||
printf("DSR: %-3s ", avrPort.Get_DSR_State() ? "ON" : "OFF");
|
||||
printf("RI: %-3s", avrPort.Get_RI_State() ? "ON" : "OFF");
|
||||
Console_ScrollBottomRegion();
|
||||
Console_SetCursor(0, -1);
|
||||
}
|
||||
}
|
||||
|
||||
void HexUppercase(char *p) {
|
||||
const char *hex = "0123456789ABCDEF";
|
||||
while (*p) {
|
||||
@@ -604,11 +611,12 @@ void EmitCommandLineHelp() {
|
||||
printf(" Options:\n");
|
||||
printf(" -SerialPort=X[,yyyy] Set to Com port X to baud rate yyyy.\n");
|
||||
printf(" Defaults baud is %d\n", avrBaud);
|
||||
printf(" -Command=S,F,V Execute a command and exit (based on the numeric values):\n");
|
||||
printf(" S - Subsystem\n");
|
||||
printf(" F - Function\n");
|
||||
printf(" V - Value\n");
|
||||
printf(" Use the -ExportInfo command to see the values.\n");
|
||||
printf(" -Command=S,F,O[,V] Execute a command and exit (based on the numeric values):\n");
|
||||
printf(" S - Subsystem,\n");
|
||||
printf(" F - Function,\n");
|
||||
printf(" O - Operation,\n");
|
||||
printf(" V - Value used by only certain command.\n");
|
||||
printf(" Use the -ExportInfo command to see the Command List.\n");
|
||||
printf(" NOTE: Program will auto-exit after performing the command,\n");
|
||||
printf(" or after 5 seconds without obvious success.\n");
|
||||
printf(" -Verbose Shows progress during -Command operation.\n");
|
||||
@@ -663,7 +671,7 @@ int __cdecl main(int argc, char *argv[]) {
|
||||
short consoleScrollHeight = 30;
|
||||
short consoleLeft = 15;
|
||||
short consoleTop = 15;
|
||||
int CommandToExecute[3] = { -1, -1, -1 };
|
||||
int CommandToExecute[4] = { -1, -1, -1, -1 };
|
||||
|
||||
// MessageHandlerSanityCheck(); // If the table is bad, we exit here
|
||||
GetProgName(argv[0]);
|
||||
@@ -681,6 +689,8 @@ int __cdecl main(int argc, char *argv[]) {
|
||||
avrBaud = param2;
|
||||
} else if (3 == sscanf_s(argv[i], "-Command=%d,%d,%d", &CommandToExecute[0], &CommandToExecute[1], &CommandToExecute[2])) {
|
||||
// After the port is open, execute this and exit
|
||||
} else if (4 == sscanf_s(argv[i], "-Command=%d,%d,%d,%d", &CommandToExecute[0], &CommandToExecute[1], &CommandToExecute[2], &CommandToExecute[3])) {
|
||||
// After the port is open, execute this and exit
|
||||
} else if (0 == strcmp(argv[i], "-Verbose")) {
|
||||
verboseMode = true;
|
||||
} else if (0 == strcmp(argv[i], "-ExportInfo")) {
|
||||
@@ -732,7 +742,7 @@ int __cdecl main(int argc, char *argv[]) {
|
||||
state = avr->Tick(nowTime);
|
||||
} while (((nowTime - refTime) < 5000) && (state != AVRInterface::stReady));
|
||||
} else {
|
||||
printf("%u\n", elapsedTime);
|
||||
// printf("%u\n", elapsedTime);
|
||||
}
|
||||
DetachSerialPort();
|
||||
exit(EXIT_OK);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LocalDebuggerCommandArguments>-SerialPort=2 -ExportInfo</LocalDebuggerCommandArguments>
|
||||
<LocalDebuggerCommandArguments>-SerialPort=2 -Command=0,1,4</LocalDebuggerCommandArguments>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -506,20 +506,22 @@ const char *ProgramName(uint8_t val) {
|
||||
// db = 0.5634 x - 112.11
|
||||
// for values 200 to 255
|
||||
// db = 0.5 x - 99.5
|
||||
// Single Linear
|
||||
// Single Linear according to the manual
|
||||
// db = 0.5574 x - 111.45
|
||||
// Single Linear according to the on-screen display of Volume
|
||||
// db = 0.5 x - 99.5
|
||||
//
|
||||
const char *VolumeDB(uint8_t val) {
|
||||
static char buf[16];
|
||||
float m, b;
|
||||
|
||||
if (val < 200) {
|
||||
m = 0.5634f;
|
||||
b = -112.11f;
|
||||
} else {
|
||||
//if (val < 200) {
|
||||
// m = 0.5634f;
|
||||
// b = -112.11f;
|
||||
//} else {
|
||||
m = 0.5f;
|
||||
b = -99.5f;
|
||||
}
|
||||
//}
|
||||
float db = m * val + b;
|
||||
sprintf_s(buf, sizeof(buf), "%+3.1f db", db);
|
||||
return buf;
|
||||
|
||||
@@ -276,7 +276,7 @@ AVRInterface::AVRState_T AVRInterface::Tick(uint32_t now_ms) {
|
||||
default:
|
||||
case AVRState_T::stPoweringUp:
|
||||
readyResponsReceived = false;
|
||||
AVRCommand(subMain, fncReady, eOn);
|
||||
AVRCommand(sysCommand, fncReady, eOn);
|
||||
(*ReportInformation)(mtInfo, "Send Ready");
|
||||
sentAtTime_ms = now_ms;
|
||||
readyTries++;
|
||||
@@ -648,7 +648,48 @@ typedef const struct {
|
||||
} MessageTable_T;
|
||||
|
||||
MessageTable_T MessageTable[] = {
|
||||
{ AVRSubsys::subMain, AVRFunc::fncReady, AVRInterface::eOn, "\x11" "000" "\x03", 5 },
|
||||
// System Commands
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncReady, AVRInterface::eOn, "\x11" "000" "\x03", 5 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncReportEnable, AVRInterface::eOn, "\x02" "20000" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncReportEnable, AVRInterface::eOff, "\x02" "20001" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncReportDelay, AVRInterface::e0ms, "\x02" "20100" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncReportDelay, AVRInterface::e50ms, "\x02" "20101" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncReportDelay, AVRInterface::e100ms, "\x02" "20102" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncReportDelay, AVRInterface::e150ms, "\x02" "20103" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncReportDelay, AVRInterface::e200ms, "\x02" "20104" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncReportDelay, AVRInterface::e250ms, "\x02" "20105" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncReportDelay, AVRInterface::e300ms, "\x02" "20106" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncReportDelay, AVRInterface::e350ms, "\x02" "20107" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncReportDelay, AVRInterface::e400ms, "\x02" "20108" "\x03", 7 },
|
||||
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncRequest, AVRInterface::eTuningFreq, "\x02" "22000" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncRequest, AVRInterface::eMainVolDB, "\x02" "22001" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncRequest, AVRInterface::eZone2VolDB, "\x02" "22002" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncRequest, AVRInterface::eInputName, "\x02" "22003" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncRequest, AVRInterface::eZone2InputName, "\x02" "22004" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncRequest, AVRInterface::eZoneXVolDB, "\x02" "22005" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncRequest, AVRInterface::eZoneXInputName, "\x02" "22006" "\x03", 7 },
|
||||
|
||||
// System Commands with variable data
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncSetValue, AVRInterface::eMasterVol, "\x02" "230xx" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncSetValue, AVRInterface::eZone2Vol, "\x02" "231xx" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncSetValue, AVRInterface::eMainLRBal, "\x02" "232xx" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncSetValue, AVRInterface::eMainLevel, "\x02" "233xx" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncSetValue, AVRInterface::eZone3Vol, "\x02" "234xx" "\x03", 7 },
|
||||
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncSetValue, AVRInterface::eMainLevelR, "\x02" "240xx" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncSetValue, AVRInterface::eMainLevelL, "\x02" "241xx" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncSetValue, AVRInterface::eCenterLevel, "\x02" "242xx" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncSetValue, AVRInterface::eRearR, "\x02" "243xx" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncSetValue, AVRInterface::eRearL, "\x02" "244xx" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncSetValue, AVRInterface::eFrontR, "\x02" "245xx" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncSetValue, AVRInterface::eFrontL, "\x02" "246xx" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncSetValue, AVRInterface::eSurBackR, "\x02" "247xx" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncSetValue, AVRInterface::eSurBackL, "\x02" "248xx" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncSetValue, AVRInterface::eSwfr1, "\x02" "249xx" "\x03", 7 },
|
||||
{ AVRSubsys::sysCommand, AVRFunc::fncSetValue, AVRInterface::eSwfr2, "\x02" "24Axx" "\x03", 7 },
|
||||
|
||||
// Operation Commands
|
||||
{ AVRSubsys::subMain, AVRFunc::fncPower, AVRInterface::eOn, "\x02" "07A1D" "\x03", 7 },
|
||||
{ AVRSubsys::subMain, AVRFunc::fncPower, AVRInterface::eOff, "\x02" "07A1E" "\x03", 7 },
|
||||
{ AVRSubsys::subMain, AVRFunc::fncVolume, AVRInterface::eUp, "\x02" "07A1A" "\x03", 7 },
|
||||
@@ -876,12 +917,28 @@ MessageTable_T MessageTable[] = {
|
||||
|
||||
bool AVRInterface::AVRCommand(AVRInterface::AVRSubsystem_T subsystem,
|
||||
AVRInterface::AVRFunction_E function,
|
||||
AVRArg_T arg) {
|
||||
AVRArg_T arg, uint8_t variableData) {
|
||||
bool found = false;
|
||||
for (int i = 0; i < sizeof(MessageTable) / sizeof(MessageTable_T); i++) {
|
||||
if (MessageTable[i].subsystem == subsystem && MessageTable[i].function == function and MessageTable[i].arg == arg) {
|
||||
found = true;
|
||||
ProcessSerialQueue(MessageTable[i].Message, MessageTable[i].MessageLen);
|
||||
const char *p = strchr(MessageTable[i].Message, 'x');
|
||||
if (p) {
|
||||
char hexBuf[3] = "";
|
||||
char *bigBuf = (char *)malloc(MessageTable[i].MessageLen + 1);
|
||||
if (bigBuf) {
|
||||
sprintf_s(hexBuf, 3, "%0X", variableData);
|
||||
memcpy(bigBuf, MessageTable[i].Message, MessageTable[i].MessageLen);
|
||||
p = strchr(bigBuf, 'x');
|
||||
memcpy((void *)p, hexBuf, 2);
|
||||
ProcessSerialQueue(bigBuf, MessageTable[i].MessageLen);
|
||||
free(bigBuf);
|
||||
} else {
|
||||
(*ReportInformation)(mtInfo, "***** Memory allocation failed!");
|
||||
}
|
||||
} else {
|
||||
ProcessSerialQueue(MessageTable[i].Message, MessageTable[i].MessageLen);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -900,6 +957,7 @@ void AVRInterface::ExportInformation() {
|
||||
const char *helpText;
|
||||
} ValuePurpose_T;
|
||||
const ValuePurpose_T subsysList[] = {
|
||||
{ sysCommand, "System Command" },
|
||||
{ subMain, "Main Subsystem" },
|
||||
{ subRadio, "Radio Control" },
|
||||
{ subAudio, "Audio Control" },
|
||||
@@ -909,6 +967,11 @@ void AVRInterface::ExportInformation() {
|
||||
};
|
||||
const ValuePurpose_T funcList[] = {
|
||||
{ fncReady, "Ready Check" },
|
||||
{ fncReportEnable, "Report Enable" },
|
||||
{ fncReportDelay, "Report Delay" },
|
||||
{ fncRequest, "Report Request" },
|
||||
{ fncSetValue, "Set Function Value" },
|
||||
|
||||
{ fncPower, "Power" },
|
||||
{ fncVolume, "Volume" },
|
||||
{ fncMute, "Mute" },
|
||||
@@ -1046,6 +1109,38 @@ void AVRInterface::ExportInformation() {
|
||||
{ eDualMain, "Dual Main" },
|
||||
{ eDualSub, "Dual Sub" },
|
||||
{ eDualAll, "Dual All" },
|
||||
|
||||
{ e0ms, "0 ms" },
|
||||
{ e50ms, "50 ms" },
|
||||
{ e100ms, "100 ms" },
|
||||
{ e150ms, "150 ms" },
|
||||
{ e200ms, "200 ms" },
|
||||
{ e250ms, "250 ms" },
|
||||
{ e300ms, "300 ms" },
|
||||
{ e350ms, "350 ms" },
|
||||
{ e400ms, "400 ms" },
|
||||
{ eTuningFreq, "Tuning Frequency" },
|
||||
{ eMainVolDB, "Main Volume" },
|
||||
{ eZone2VolDB, "Zone 2 Volume" },
|
||||
{ eInputName, "Zone 1 Input Name" },
|
||||
{ eZone2InputName, "Zone 2 Input Name" },
|
||||
{ eZoneXVolDB, "Zone X Volume" },
|
||||
{ eZoneXInputName, "Zone X Input Name" },
|
||||
|
||||
{ eMainLevelR, "Main Level R" },
|
||||
{ eMainLevelL, "Main Level L" },
|
||||
{ eCenterLevel, "Center Level" },
|
||||
{ eRearR, "Rear Level R" },
|
||||
{ eRearL, "Rear Level L" },
|
||||
{ eFrontR, "Front Level R" },
|
||||
{ eFrontL, "Front Level L" },
|
||||
{ eSurBackR, "Surround Back R" },
|
||||
{ eSurBackL, "Surround Back L" },
|
||||
{ eSwfr1, "Subwoofer 1" },
|
||||
{ eSwfr2, "Subwoofer 2" },
|
||||
|
||||
|
||||
{ e0ms, "0 ms" },
|
||||
};
|
||||
ReportInformation(mtInfo, "");
|
||||
ReportInformation(mtInfo, "AVR Command Line Control uses 3 numeric parameters:");
|
||||
|
||||
@@ -47,7 +47,8 @@ public:
|
||||
bool Initialize();
|
||||
|
||||
typedef enum {
|
||||
subMain, //
|
||||
sysCommand, // even with power off
|
||||
subMain, // after power is on
|
||||
subRadio,
|
||||
subAudio,
|
||||
subZone1,
|
||||
@@ -87,6 +88,10 @@ public:
|
||||
fncDC1OnOff,
|
||||
fncDC2OnOff,
|
||||
fncReady,
|
||||
fncReportEnable,
|
||||
fncReportDelay,
|
||||
fncRequest,
|
||||
fncSetValue,
|
||||
fncFunctionCount
|
||||
} AVRFunction_E;
|
||||
|
||||
@@ -196,6 +201,41 @@ public:
|
||||
eDualMain, //
|
||||
eDualSub,
|
||||
eDualAll,
|
||||
|
||||
e0ms,
|
||||
e50ms,
|
||||
e100ms,
|
||||
e150ms,
|
||||
e200ms,
|
||||
e250ms,
|
||||
e300ms,
|
||||
e350ms,
|
||||
e400ms,
|
||||
eTuningFreq,
|
||||
eMainVolDB,
|
||||
eZone2VolDB,
|
||||
eInputName,
|
||||
eZone2InputName,
|
||||
eZoneXVolDB,
|
||||
eZoneXInputName,
|
||||
eMasterVol,
|
||||
eZone2Vol,
|
||||
eMainLRBal,
|
||||
eMainLevel,
|
||||
eZone3Vol,
|
||||
|
||||
eMainLevelR,
|
||||
eMainLevelL,
|
||||
eCenterLevel,
|
||||
eRearR,
|
||||
eRearL,
|
||||
eFrontR,
|
||||
eFrontL,
|
||||
eSurBackR,
|
||||
eSurBackL,
|
||||
eSwfr1,
|
||||
eSwfr2,
|
||||
|
||||
eARGCount
|
||||
} AVRArg_T;
|
||||
|
||||
@@ -208,10 +248,12 @@ public:
|
||||
/// @param[in] subsystem: Main | Zone 1 | Zone 2 | Zone 3
|
||||
/// @param[in] function : Power, Speaker, Volume, etc.
|
||||
/// @param[in] arg: on/off, etc.
|
||||
/// @param[in] variableData is for those functions where it needs to integrate variable value, such as setting the volume directly
|
||||
/// @return
|
||||
bool AVRCommand(AVRSubsystem_T subsystem,
|
||||
AVRFunction_E function,
|
||||
AVRArg_T arg);
|
||||
AVRArg_T arg,
|
||||
uint8_t variableData = 0);
|
||||
|
||||
|
||||
/// @brief AVRMessageType_T
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user