Add support for .ini file,

Add support for extended messages (advanced protocol),
Add handy command lines for Power, Volume in db, and Mute.
This commit is contained in:
2026-01-31 14:39:37 -06:00
parent 936f71b737
commit 49edca0238
8 changed files with 368 additions and 195 deletions

View File

@@ -1,9 +1,7 @@
//
// The AVR Interface object and interaction methods
//
//
#ifdef _DEBUG
#include <stdio.h>
#endif
#include <memory.h>
#include <string.h>
#include <malloc.h>
@@ -480,6 +478,7 @@ bool AVRInterface::ProcessSerialQueue(const void *msg, uint16_t len) {
}
retVal = true;
}
state = stAwaitingResponse;
}
return retVal;
}
@@ -950,7 +949,9 @@ bool AVRInterface::AVRCommand(AVRInterface::AVRSubsystem_T subsystem,
return true;
}
void AVRInterface::ExportInformation() {
void AVRInterface::ExportInformation(AVRInterface::AVRSubsystem_T subsystem,
AVRInterface::AVRFunction_E function,
AVRArg_T arg) {
char buf[LONGESTTEXT] = "";
typedef struct {
uint16_t value;
@@ -1127,6 +1128,12 @@ void AVRInterface::ExportInformation() {
{ eZoneXVolDB, "Zone X Volume" },
{ eZoneXInputName, "Zone X Input Name" },
{ eMasterVol, "Master Volume" },
{ eZone2Vol, "Zone 2 Volume" },
{ eMainLRBal, "Left-Right Balance" },
{ eMainLevel, "Main Level" },
{ eZone3Vol, "Zone 3 Volume" },
{ eMainLevelR, "Main Level R" },
{ eMainLevelL, "Main Level L" },
{ eCenterLevel, "Center Level" },
@@ -1160,10 +1167,23 @@ void AVRInterface::ExportInformation() {
);
ReportInformation(mtInfo, buf);
AVRSubsystem_T refSub = subSubsystemCount;
AVRSubsystem_T refSub = subsystemCount;
AVRFunction_E refFnc = fncFunctionCount;
const char *pSubsystemText = NULL, *pFunctionText = NULL, *pValueText = NULL;
for (int i = 0; i < sizeof(MessageTable) / sizeof(MessageTable_T); i++) {
// Subsystem scan or filter
//
if (subsystem != subsystemCount && subsystem != MessageTable[i].subsystem) {
continue;
}
if (function != fncFunctionCount && function != MessageTable[i].function) {
continue;
}
if (arg != eARGCount && arg != MessageTable[i].arg) {
continue;
}
if (refSub != MessageTable[i].subsystem) {
refSub = MessageTable[i].subsystem;
for (int j = 0; j < sizeof(subsysList) / sizeof(ValuePurpose_T); j++) {
@@ -1177,6 +1197,9 @@ void AVRInterface::ExportInformation() {
} else {
pSubsystemText = "";
}
//
// function choices
//
if (refFnc != MessageTable[i].function) {
refFnc = MessageTable[i].function;
for (int j = 0; j < sizeof(funcList) / sizeof(ValuePurpose_T); j++) {
@@ -1190,7 +1213,9 @@ void AVRInterface::ExportInformation() {
} else {
pFunctionText = "";
}
// @TODO Probably all the enum values must be merged into one big enum list for this to work.
//
// argument choices
//
for (int j = 0; j < sizeof(valueList) / sizeof(ValuePurpose_T); j++) {
if (valueList[j].value == MessageTable[i].arg) {
pValueText = valueList[j].helpText;
@@ -1224,6 +1249,23 @@ const char *AVRInterface::MessageToText(const char *p, size_t len) {
return privateBuffer;
}
//
// Single Linear according to the on-screen display of Volume
// db = 0.5 x - 99.5
// therefore:
// db + 99.5 = 0.5 x
// 0.5 x == db + 99.5
// x = 2 * (db + 99.5)
//
uint8_t AVRInterface::VolumeDBtoAPIValue(float db) {
if (db >= -80.0f && db <= +16.5f) {
return (uint8_t)(2 * (db + 99.5));
} else {
return (0); // mute
}
}
/// ReportAllStatus
///
/// This emits (via a callback) all the status, in DT0 to DT137 order.
@@ -1246,14 +1288,14 @@ void AVRInterface::ReportAllStatus() {
PCMessage("Busy", 1, &p, BusyToText);
PCMessage("Power", 1, &p, OffOnText);
if (avrStatus.configValid) {
PCMessage("Input", 1, &p, InputText);
PCMessage("Zone 1 Input", 1, &p, InputText);
PCMessage("6 ch", 1, &p, OffOnText);
PCMessage("Inp mode", 1, &p, InputModeText);
PCMessage("Mute", 1, &p, OffOnText);
PCMessage("Zone 2", 1, &p, InputText);
PCMessage("Mute 2", 1, &p, OffOnText);
PCMessage("Zone 2 Input", 1, &p, InputText);
PCMessage("Zone 2 Mute", 1, &p, OffOnText);
PCMessage("Volume", 2, &p, VolumeDB);
PCMessage("Volume 2", 2, &p, VolumeDB);
PCMessage("Zone 2 Volume", 2, &p, VolumeDB);
PCMessage("Prog", 2, &p, ProgramName);
PCMessage("Effect", 1, &p, OffOnText);
PCMessage("6.1/es status", 1, &p, OffMatrixDiscreteAutoText);
@@ -1328,9 +1370,9 @@ void AVRInterface::ReportAllStatus() {
PCMessage("Lvl 6 Ch F L", 2, &p, M10P10dbText);
PCMessage("Lvl 6 Ch F R", 2, &p, M10P10dbText);
PCMessage("Lvl 6 Ch swfr", 2, &p, M20P0dbText );
PCMessage("Zone 3 Inp", 1, &p, PlaybackToText);
PCMessage("Zone 3 Input", 1, &p, PlaybackToText);
PCMessage("Zone 3 Mute", 1, &p, OffOnText);
PCMessage("Zone 3 Vol", 2, &p, VolumeDB);
PCMessage("Zone 3 Volume", 2, &p, VolumeDB);
PCMessage("?????", 1, &p);
PCMessage("MultiCh Select", 1, &p, SixEightText);
PCMessage("MultiCh Surround", 1, &p, SurrMainText);