Adding directly settable commands (instead of volume up/down, set volume to xx)

This commit is contained in:
2026-01-30 17:20:57 -06:00
parent 87ece7eb14
commit 936f71b737
6 changed files with 264 additions and 115 deletions

View File

@@ -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:");