Complete with the OO changes. Also, added more built-in help information.

This commit is contained in:
2026-01-29 16:50:53 -06:00
parent 0d41768fe7
commit 87ece7eb14
6 changed files with 759 additions and 975 deletions

View File

@@ -10,6 +10,27 @@ public:
~AVRInterface();
/// @brief internal operating states of the AVR interface
typedef enum {
stPoweringUp, ///<! powering up
stAwaitingReadyResponse, ///<! waiting for the special ready response
stInitializing, ///<! initializing
stRetryInitializing, ///<! retrying initialization
stReady, ///<! ready for commands
stAwaitingResponse, ///<! waiting for a response to a command
stFailed, ///<! failed to establish contact
stMaxStates ///<! maximum states
} AVRState_T;
/// @brief Call this periodically so timed activities can be handled.
///
/// Every 1 or even 50 to 100 msec is ok.
///
/// @param[in] milliseconds since the program started
/// @returns the current state of the AVR interface
///
AVRState_T Tick(uint32_t millisec);
/// @brief When the system receives something from the device, give it to this function to handle it
/// @param buffer
/// @param len
@@ -17,14 +38,6 @@ public:
///
bool HandleMessage(const uint8_t *buffer, uint16_t len);
/// @brief Call this periodically so timed activities can be handled.
///
/// Every 1 or even 50 to 100 msec is ok.
///
/// @param millisec
///
void Tick(uint32_t millisec);
/// @brief Initialize the AVR interface and issue the ready command.
///
/// This is temporarily blocking since nothing else should run until ready
@@ -33,81 +46,80 @@ public:
///
bool Initialize();
/// @brief determine if the device is ready
///
/// @return true if ready
///
bool IsOnline();
typedef enum {
subMain, //
subRadio,
subAudio,
subZone1,
subZone2,
subZone3,
subSubsystemCount
} AVRSubsystem_T;
typedef enum {
eOn = 0,
fncPower,
fncVolume,
fncMute,
fncVolumeMemory,
fncVolumeRecall,
fncSpeakerAOnOff,
fncSpeakerBOnOff,
fncSpeakerBZone,
fncZone2SpeakerOnOff,
fncNightModeOnOff,
fncEffect,
fncDSPSoundScape,
fncInput,
fncRadioBand,
fncRadioTune,
fncRadioPresetPage,
fncRadioPresetNumber,
fncRadioPresetMemory,
fncRadioPresetRecall,
fncSleep,
fncOSD,
fnc6ChInput,
fncEx_EsOnOff,
fncInputMode,
fncDualMono,
fncDC1TrigControl,
fncDC2TrigControl,
fncDC1OnOff,
fncDC2OnOff,
fncReady,
fncFunctionCount
} AVRFunction_E;
typedef enum {
eOn = 0, //
eOff,
eStandby
} AVROnOff_E;
typedef enum {
eUp,
eStandby,
eUp, //
eDown,
} AVRUpDown_E;
typedef enum {
eMuteOn,
eMuteOff
} AVRMute_E;
typedef enum {
eOSDOff,
eOSDShort,
eOSDFull
} AVROSDScreen_E;
typedef enum {
eSleepOff,
eSleep120,
eSleep90,
eSleep60,
eSleep30
} AVRSleep_E;
typedef enum {
eOnMatrix,
eESESOff,
eAuto,
eDiscrete
} AVREX_ES_E;
typedef enum {
eEffectOn,
eStereo
} AVREffect_E;
typedef enum {
eFM,
eAM
} AVRTunerBand_E;
typedef enum {
e1,
e2,
e3,
e4,
e5,
e6,
e7,
e8
} AVRPresetNum_E;
typedef enum {
eA,
eMuteOn, //
eMuteOff,
eFM, //
eAM,
eA, //
eB,
eC,
eD,
eE,
eF
} AVRPresetPage_E;
typedef enum {
ePhono,
eF,
e1, //
e2,
e3,
e4,
e5,
e6,
e7,
e8,
eSleepOff, //
eSleep120,
eSleep90,
eSleep60,
eSleep30,
ePhono, //
eCD,
eTuner,
eCDR,
@@ -120,18 +132,21 @@ public:
eVCR2_DVR,
eVCR3,
eV_Aux,
} AVRInput_E;
typedef enum {
eMain,
eOSDOff, //
eOSDShort,
eOSDFull,
eOnMatrix, //
eESESOff,
eAuto,
eDiscrete, //
eEffectOn,
eStereo,
eMain, //
eZone1,
eZone2,
eZone3,
eZoneOR
} AVRSubsystem_E;
typedef enum {
Hall_A,
eZoneOR,
Hall_A, //
Hall_B,
Hall_C,
Hall_USA,
@@ -171,89 +186,19 @@ public:
THX_Ultra_PL,
THX_Music,
THX_Ultra_PL2,
THX_Ultra_NEO6
} AVRDSPProg_E;
typedef enum {
eInpAuto,
THX_Ultra_NEO6,
eInpAuto, //
eDD_RF,
eDTS,
eDigital,
eAnalog,
eAAC
} AVRInputMode_E;
typedef enum {
eDualMain,
eAAC,
eDualMain, //
eDualSub,
eDualAll
} AVRDualMono_E;
eDualAll,
eARGCount
} AVRArg_T;
typedef enum {
fncPower,
fncVolume,
fncMute,
fncVolumeMemory,
fncVolumeRecall,
fncSpeakerAOnOff,
fncSpeakerBOnOff,
fncSpeakerBZone,
fncZone2SpeakerOnOff,
fncNightModeOnOff,
fncEffect,
fncInput,
fncRadioBand,
fncRadioTune,
fncRadioPresetPage,
fncRadioPresetNumber,
fncRadioPresetMemory,
fncRadioPresetRecall,
fncDSPProgram,
fncSleep,
fncOSD,
fnc6ChInput,
fncEx_EsOnOff,
fncInputMode,
fncDualMono,
fncDC1TrigControl,
fncDC2TrigControl,
fncDC1OnOff,
fncDC2OnOff,
} AVRFunction_E;
typedef union {
AVROnOff_E onOff;
AVRUpDown_E volume;
AVRMute_E mute;
AVRPresetPage_E volumeMemory;
AVRPresetPage_E volumeRecall;
AVROnOff_E speakerA;
AVROnOff_E speakerB;
AVRSubsystem_E speakerBZone;
AVROnOff_E zone2Speaker;
AVROnOff_E nightMode;
AVRInput_E input;
AVRTunerBand_E band;
AVRUpDown_E tune;
AVRPresetPage_E presetPage;
AVRPresetNum_E presetNumber;
AVRPresetPage_E presetMemory;
AVRPresetPage_E presetRecall;
AVRDSPProg_E program;
AVRSleep_E sleep;
AVROSDScreen_E osd;
AVROnOff_E sixChInput;
AVREX_ES_E ex_es;
AVRInputMode_E inputMode;
AVRDualMono_E dualMono;
AVRSubsystem_E dc1TrigControl;
AVRSubsystem_E dc2TrigControl;
AVROnOff_E dc1OnOff;
AVROnOff_E dc2OnOff;
char *pMessage;
} AVRArgument_UX;
typedef uint32_t AVRArg_T;
/// @brief The single command path to control the AVR
///
@@ -264,16 +209,10 @@ public:
/// @param[in] function : Power, Speaker, Volume, etc.
/// @param[in] arg: on/off, etc.
/// @return
bool AVRCommand(AVRInterface::AVRSubsystem_E subsystem,
AVRInterface::AVRFunction_E function,
bool AVRCommand(AVRSubsystem_T subsystem,
AVRFunction_E function,
AVRArg_T arg);
/// @brief Send the power command
/// @param cmd
/// @return true
///
bool Power(AVROnOff_E cmd);
bool VolumeButton(AVRUpDown_E cmd);
/// @brief AVRMessageType_T
///
@@ -331,18 +270,15 @@ public:
///
bool AVRSendOSDMessage(const char *msg);
/// ExportInformation
///
/// @brief Export all the numeric data to support a command line control option
///
void ExportInformation();
private:
uint32_t sentAtTime_ms;
typedef enum {
stPoweringUp,
stAwaitingReadyResponse,
stInitializing,
stRetryInitializing,
stReady,
stAwaitingResponse,
stMaxStates
} AVRState_T;
AVRState_T state = stPoweringUp;
AVRState_T oldState = stMaxStates;
@@ -549,7 +485,7 @@ private:
void PCMessage(const char *msg, int len, uint8_t **src, const char *(fncHelper)(uint8_t val) = NULL);
bool ProcessReportResponse(const uint8_t *szBuffer, uint32_t len);
void MessageReport(const char *prefix, const void *buf, size_t len = 0);
const char *MessageToText(const char *msg, size_t len);
bool CheckTheChecksum(const uint8_t *szBuffer, uint32_t num);
uint16_t Hex2Dec(const uint8_t *p, int dig);