2020-08-16 02:03:43 +08:00
|
|
|
/*
|
|
|
|
* "Cmd.h" was added in Version 2.0 by John Price (WA2FZW)
|
|
|
|
*
|
|
|
|
* This file contains definitions and function prototypes associated with
|
|
|
|
* the "Cmd.cpp" module.
|
|
|
|
*
|
|
|
|
* In Version 2.0 of the software, all of the serial input command handling
|
|
|
|
* was removed from the main program sile into these modules.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _CMD_H_
|
|
|
|
#define _CMD_H_ // Prevent double inclusion
|
|
|
|
|
2020-08-16 02:50:26 +08:00
|
|
|
#include "simpleSA.h" // General program definitions
|
2020-08-17 05:24:08 +08:00
|
|
|
#include "pE4302.h" // Class definition for thePE4302 attenuator
|
|
|
|
#include "si4432.h" // Class definition for the Si4432 transceiver
|
2020-08-16 02:03:43 +08:00
|
|
|
#include "preferences.h" // For saving the "setting" structure
|
|
|
|
#include <SPI.h>
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* These are numerical values which define the message being processed. We could just
|
|
|
|
* work off the ASCII string, but translating the strings to a numerical value makes
|
|
|
|
* the processing a bit easier and also keeps open the possibility of using more tha
|
|
|
|
* one ASCII string to implement a give command.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define MSG_NONE 0 // Unrecognized command
|
|
|
|
#define MSG_START 1 // Set sweep start frequency
|
|
|
|
#define MSG_STOP 2 // Set sweep stop frequency
|
|
|
|
#define MSG_CENTER 3 // Set sweep center frequency
|
|
|
|
#define MSG_SPAN 4 // Set sweep range
|
|
|
|
#define MSG_FOCUS 5 // Center frequency with narrow sweep
|
|
|
|
#define MSG_DRIVE 6 // Set transmitter (LO) output level
|
|
|
|
#define MSG_VFO_FREQ 7 // Set the frequency for the selected VFO
|
|
|
|
#define MSG_ATTEN 8 // Set the PE4301 attenuation
|
|
|
|
#define MSG_HELP 9 // Display the command menu
|
|
|
|
#define MSG_STEPS 10 // Set or get number of sweep points (not used)
|
|
|
|
#define MSG_DELAY 11 // Set or get delay time between sweep readings
|
|
|
|
#define MSG_VFO 12 // Set or get the currently selected VFO
|
|
|
|
#define MSG_RBW 13 // Set or get the current resolution bandwidth
|
|
|
|
#define MSG_REG_DUMP 14 // Print register values for the selected VFO
|
|
|
|
#define MSG_RSSI 15 // Show RSSI values
|
|
|
|
#define MSG_QUIT 16 // Stop RSSI readings
|
|
|
|
#define MSG_SET_REG 17 // Set or get the value of a specifix register for the selected VFO
|
|
|
|
#define MSG_SAVE 18 // Save scan configuration
|
|
|
|
#define MSG_RECALL 19 // Recall saved scan configuration
|
|
|
|
#define MSG_GPIO2 20 // Set transmitter GPIO2 reference frequency
|
|
|
|
#define MSG_TUNE 21 // Tune selected Si4432 (VFO)
|
|
|
|
#define MSG_CONFIG 22 // Save "config" structure
|
|
|
|
#define MSG_ACT_PWR 23 // Calibrate the observed power level
|
|
|
|
#define MSG_IF_FREQ 24 // Set the IF frequency
|
|
|
|
#define MSG_TRACES 25 // Turn things on the display on or off
|
|
|
|
#define MSG_PREAMP 26 // Set the receiver preamp gain
|
|
|
|
#define MSG_GRID 27 // Set the dB value for top line of the grid
|
|
|
|
#define MSG_SCALE 28 // Set the dB/horizontal line for the grid
|
|
|
|
#define MSG_PAUSE 29 // Pause (or resume) the sweep
|
|
|
|
#define MSG_SWEEPLO 30 // Set Analyse low range mode
|
|
|
|
#define MSG_SIGLO 31 // Signal generate low range mode
|
|
|
|
#define MSG_IF_SWEEP 32 // Set IF Sweep mode
|
|
|
|
#define MSG_MARKER 33 // Configure Markers
|
|
|
|
#define MSG_SPUR 34 // Set Spur reduction on or off
|
|
|
|
#define MSG_WIFI_UPDATE 35 // Set WiFi update target time in us
|
|
|
|
#define MSG_WIFI_POINTS 36 // Set WiFi chunk size
|
|
|
|
#define MSG_WEBSKT_INTERVAL 37 // Set interval between checking websocket for events if no client connected
|
|
|
|
#define MSG_SG_RX_DRIVE 38 // Set Signal Generator RX (IF) Drive level - don't go above the 10dBm rating of the SAW filters
|
|
|
|
#define MSG_SG_LO_DRIVE 39 // Set Signal Generator LO Drive level - limited by mixer/attenuators fitted
|
|
|
|
#define MSG_TG_IF_DRIVE 40 // Set Tracking Generator RX (IF) Drive level - don't go above the 10dBm rating of the SAW filters
|
|
|
|
#define MSG_TG_LO_DRIVE 41 // Set Tracking Generator LO Drive level - limited by mixer/attenuators fitted
|
|
|
|
#define MSG_IFSIGNAL 42 // Set frequency of injected signal for IF Sweep
|
|
|
|
#define MSG_TGOFFSET 43 // Offset TG IF frequency from SA IF
|
|
|
|
#define MSG_BANDSCOPE 44 // Set Bandscope Mode
|
|
|
|
#define MSG_IFSWEEP 45 // Set IF Sweep Mode
|
2020-08-21 05:27:55 +08:00
|
|
|
#define MSG_OFFDELAY 46 // Adjust offset tuning delay time before taking reading
|
|
|
|
#define MSG_WFMIN 47 // set the min level for the waterfall colours
|
|
|
|
#define MSG_WFGAIN 48 // set the gain for waterfall colouring
|
2020-08-22 05:02:22 +08:00
|
|
|
#define MSG_RX_SWEEP 49 // Set the RX Sweep Mode
|
|
|
|
#define MSG_RXSIGNAL 50 // Set frequency of injected signal for IF Sweep
|
2020-09-03 06:22:08 +08:00
|
|
|
#define MSG_EXTGAIN 51 // Set external gain or attenuation
|
2020-09-29 05:44:47 +08:00
|
|
|
#define MSG_SGON 52 // Turn Signal Generator output on
|
|
|
|
#define MSG_SGOFF 53 // Turn Signal Generator output off
|
2020-10-04 06:17:19 +08:00
|
|
|
#define MSG_SGFREQ 54 // Set Signal Generator Frequency
|
2020-09-29 05:44:47 +08:00
|
|
|
#define MSG_TGON 55 // Turn Tracking Generator output on
|
|
|
|
#define MSG_TGOFF 56 // Turn Tracking Generator output off
|
|
|
|
#define MSG_TGFREQ 57 // Set Track Gen frequency for sig gen mode
|
|
|
|
#define MSG_TGSIG 58 // Set Track Gen sig gen mode
|
2020-08-22 05:02:22 +08:00
|
|
|
|
2020-08-21 05:27:55 +08:00
|
|
|
#define MSG_COLOURTEST 99 // test of waterfall colours - remove this when done!
|
|
|
|
|
2020-08-16 02:03:43 +08:00
|
|
|
|
|
|
|
typedef struct // Keeps everything together
|
|
|
|
{
|
|
|
|
char Name[20]; // ASCII Command string
|
|
|
|
uint8_t ID; // The internal message number
|
|
|
|
} msg_t;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This "enum" is used by the "SetSweepCenter" function to designate whether we want a
|
|
|
|
* "WIDE" span when setting the normal center frequency, or a "NARROW" span when setting
|
|
|
|
* a focus frequency.
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum { WIDE, NARROW };
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function prototypes for the help menu display and main command processing:
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ShowMenu (); // Displays the command menu
|
|
|
|
|
|
|
|
bool CheckCommand (); // Checks for a new command
|
|
|
|
bool ParseCommand ( char* inBuff ); // Separate command and data
|
|
|
|
bool ProcessCommand ( uint8_t command, char* dataBuff );
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function prototypes for general support functions:
|
|
|
|
*/
|
|
|
|
|
|
|
|
uint32_t ParseFrequency ( char* freqString ); // Handles various frequency input formats
|
|
|
|
int32_t ParseSignedFrequency ( char* freqString ); // Handles various frequency input formats
|
|
|
|
char* FormatFrequency ( uint32_t freq ); // Neatly formats frequencies for output
|
|
|
|
char* FormatSignedFrequency ( int32_t freq ); // Neatly formats signed frequencies for output
|
|
|
|
char* DisplayFrequency ( uint32_t freq ); // Neatly formats frequencies for sig gen display
|
|
|
|
|
|
|
|
uint16_t xtoi ( char* hexString ); // Converts hexadecimal strings into integers
|
|
|
|
bool isHex ( char c ); // Tests if a character is a hexadecimal digit
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* These functions all support the main command processing functions and are used to
|
|
|
|
* set the values of things either in the appropriate internal variables and/or in
|
|
|
|
* the PE4302 or Si4432 modules themselves.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void SetRefOutput ( int freq ); // Sets the GPIO2 frequency for the LO
|
|
|
|
|
|
|
|
void SetRefLevel ( int ref ); // Sets the decibel level for the top line of the graph
|
|
|
|
void SetPowerGrid ( int g ); // Sets the dB/vertical divison on the grid
|
|
|
|
|
|
|
|
void SetGenerate ( int8_t g ); // Puts the unit into or out of signal generator mode
|
|
|
|
|
|
|
|
bool SetIFFrequency ( int32_t f ); // Sets the IF frequency
|
|
|
|
|
|
|
|
void SetLoDrive ( uint8_t level ); // Sets LO Si4432 output level
|
2020-09-29 05:44:47 +08:00
|
|
|
void SetSGState (uint16_t s);
|
2020-10-04 06:17:19 +08:00
|
|
|
bool SetSGFreq ( uint32_t freq); // set signal generator frequency - returns false if invalid
|
2020-08-16 02:03:43 +08:00
|
|
|
void SetSGLoDrive ( uint8_t level );
|
|
|
|
void SetSGRxDrive ( uint8_t level );
|
2020-10-04 06:17:19 +08:00
|
|
|
void SetSGPower ( int16_t dBm ); // Set signal generator attenuator and drive levels
|
2020-08-16 02:03:43 +08:00
|
|
|
|
|
|
|
void SetTracking ( int8_t m ); // set tracking generator mode
|
|
|
|
void SetTGLoDrive ( uint8_t level ); // set tracking generator drive
|
|
|
|
void SetTGIfDrive ( uint8_t level );
|
|
|
|
bool SetTGOffset ( int32_t offset); // set tracking generator offset - returns false if invalid
|
2020-09-29 05:44:47 +08:00
|
|
|
bool SetTGFreq ( int32_t freq); // set tracking generator freq for sig gen mode - returns false if invalid
|
2020-08-16 02:03:43 +08:00
|
|
|
int32_t GetTGOffset (void );
|
2020-09-03 06:22:08 +08:00
|
|
|
void SetTGPower ( int16_t dBm ); // Set TG attenuator and drive levels
|
2020-08-16 02:03:43 +08:00
|
|
|
|
|
|
|
void SetAttenuation ( int a ); // Sets the PE4302 attenuation
|
|
|
|
|
2020-09-03 06:22:08 +08:00
|
|
|
void SetExtGain ( double a ); // Sets the external gain or attenuation
|
|
|
|
double GetExtGain (void );
|
|
|
|
|
2020-08-16 02:03:43 +08:00
|
|
|
void SetStorage ( void ); // Saves the results of a scan
|
|
|
|
void SetClearStorage ( void ); // Logically erases the saved scan
|
|
|
|
void SetSubtractStorage(void); // Sets the "setting.SubtractStorage" flag
|
|
|
|
|
|
|
|
void RequestSetPowerLevel ( float o ); // Power level calibration
|
2020-09-05 06:54:52 +08:00
|
|
|
void SetPowerLevel ( double o ); // ???
|
2020-08-16 02:03:43 +08:00
|
|
|
|
|
|
|
void SetRBW ( int v ); // Sets the resolution bandwidth
|
|
|
|
|
|
|
|
void SetSpur (int v ); // Turns spurious signal supression on or off
|
|
|
|
|
|
|
|
void SetAverage ( int v ); // Sets the number of readings to average
|
|
|
|
|
|
|
|
void SetPreampGain ( uint8_t gain ); // Set and get the receiver preamp gain
|
|
|
|
uint8_t GetPreampGain ( bool* agc, uint8_t* reg );
|
|
|
|
|
|
|
|
void SetSweepStart ( uint32_t freq ); // Added in Version 2.3
|
|
|
|
uint32_t GetSweepStart ( void );
|
|
|
|
|
2020-08-21 19:33:06 +08:00
|
|
|
void SetSweepStop ( uint32_t freq ); // Added in Version 2.3
|
2020-08-16 02:03:43 +08:00
|
|
|
uint32_t GetSweepStop ( void );
|
|
|
|
|
|
|
|
void SetBandscopeStart ( uint32_t freq ); // Added in Version 3.0f
|
|
|
|
uint32_t GetBandscopeStart ( void );
|
|
|
|
|
2020-08-21 19:33:06 +08:00
|
|
|
void SetBandscopeSpan ( uint32_t freq ); // Added in Version 3.0f
|
2020-08-16 02:03:43 +08:00
|
|
|
uint32_t GetBandscopeSpan ( void );
|
|
|
|
|
2020-08-21 19:33:06 +08:00
|
|
|
void SetBandscopeRBW ( int v ); // Sets the resolution bandwidth
|
|
|
|
|
|
|
|
void SetBandscopeLevel ( int ref ); // Sets the decibel level for the top line of the graph
|
|
|
|
|
2020-08-22 05:02:22 +08:00
|
|
|
void SetIFsweepStart ( uint32_t freq ); // Added in Version 3.0c
|
|
|
|
uint32_t GetIFsweepStart ( void );
|
|
|
|
|
2020-08-21 19:33:06 +08:00
|
|
|
void SetIFsweepStop ( uint32_t freq ); // Added in Version 3.0c
|
2020-08-16 02:03:43 +08:00
|
|
|
uint32_t GetIFsweepStop ( void );
|
|
|
|
|
|
|
|
void SetIFsweepSigFreq ( uint32_t freq ); // Added in Version 3.0c
|
|
|
|
uint32_t GetIFsweepSigFreq ( void );
|
|
|
|
|
2020-08-22 05:02:22 +08:00
|
|
|
void SetRXsweepStart ( uint32_t freq );
|
|
|
|
uint32_t GetRXsweepStart ( void );
|
|
|
|
|
|
|
|
void SetRXsweepStop ( uint32_t freq );
|
|
|
|
uint32_t GetRXsweepStop ( void );
|
|
|
|
|
|
|
|
void SetRXsweepSpan ( uint32_t freq );
|
|
|
|
uint32_t GetRXsweepSpan ( void );
|
|
|
|
|
|
|
|
void SetRXsweepSigFreq ( uint32_t freq );
|
|
|
|
uint32_t GetRXsweepSigFreq ( void );
|
|
|
|
|
2020-08-16 02:03:43 +08:00
|
|
|
void SetSweepCenter ( uint32_t freq, uint8_t span );
|
|
|
|
uint32_t GetSweepCenter ( void );
|
|
|
|
|
|
|
|
void SetSweepSpan ( uint32_t spanRange );
|
|
|
|
uint32_t GetSweepSpan ( void );
|
|
|
|
|
|
|
|
void SetFreq ( int vfo, uint32_t freq );
|
|
|
|
|
|
|
|
bool UpdateMarker ( uint8_t mkr, char action );
|
|
|
|
|
2020-08-21 05:27:55 +08:00
|
|
|
void SetWFMin (int16_t level);
|
|
|
|
void SetWFGain (float gain);
|
|
|
|
|
|
|
|
|
2020-08-16 02:03:43 +08:00
|
|
|
#endif // End of "Cmd.h"
|