diff --git a/SigLo.ino b/SigLo.ino index 1c35242..9dd1788 100644 --- a/SigLo.ino +++ b/SigLo.ino @@ -125,6 +125,7 @@ void doSigGenLow () { static uint32_t oldIF; // to store the current IF static uint16_t oldSigGenOutputOn; + float p; // temporary variable for slider percent uint16_t t_x = 0, t_y = 0; // To store the touch coordinates @@ -133,6 +134,10 @@ void doSigGenLow () showUpDownButtons = 1; #endif + if (changedSetting) { + att.SetAtten(sigGenSetting.Calibration - sigGenSetting.Power); + } + boolean changedSetting = false; // Get current touch state and coordinates @@ -253,13 +258,15 @@ void doSigGenLow () // Check if slider touched if ( sliderPressed( pressed, t_x, t_y) ) { - float p = sliderPercent( t_x ); // position of slider in % + p = sliderPercent( t_x ); // position of slider in % float pwr = p * (ATTENUATOR_RANGE)/100.0 + sigGenSetting.Calibration - ATTENUATOR_RANGE; drawSlider ( SLIDER_X, SLIDER_Y, p, pwr, "dBm" ); - att.SetAtten ( ( 100.0 - p ) / 100.0 * ATTENUATOR_RANGE ); // set attenuator to give required output sigGenSetting.Power = pwr; changedSetting = true; + } else { + p = ( sigGenSetting.Power - (sigGenSetting.Calibration - ATTENUATOR_RANGE) ) * 100.0 / ATTENUATOR_RANGE; + drawSlider ( SLIDER_X, SLIDER_Y, p, sigGenSetting.Power, "dBm" ); } diff --git a/cmd.cpp b/cmd.cpp index ee3eabb..8f6f8d6 100644 --- a/cmd.cpp +++ b/cmd.cpp @@ -186,6 +186,7 @@ extern uint8_t dBmToRSSI ( double dBm ); { "EXTGAIN", MSG_EXTGAIN }, // External gain or attenuation { "SGON", MSG_SGON }, // turn on signal generator output { "SGOFF", MSG_SGOFF }, // turn off signal generator output + { "SGFREQ", MSG_SGFREQ }, // Set Signal Generator Frequency { "TRACKON", MSG_TGON }, // turn on tracking generator output { "TRACKOFF", MSG_TGOFF }, // turn off tracking generator output { "TRACKSIG", MSG_TGSIG }, // turn off tracking generator output @@ -804,6 +805,18 @@ uint8_t reg69; // Ditto SetSGState(0); return true; + case MSG_SGFREQ: + if ( dataLen != 0 ) // Frequency specified? + { + freq1 = ParseFrequency ( dataBuff ); // Yes, get new frequency + SetSGFreq (freq1); + } + Serial.printf ( "Signal Generator frequency: %i\n", FormatFrequency ( sigGenSetting.Frequency )); + return true; + + + + /* * The "SGLODRIVE" command sets the local oscillator "drive" level in signal generator mode. */ @@ -2365,6 +2378,7 @@ void RequestSetPowerLevel ( float o ) /* * "SetPowerLevel" + * Adjusts displayed power to match the actual input signal power - calibration function */ void SetPowerLevel ( double o ) @@ -2508,12 +2522,18 @@ int oldLevel = setting.Drive; * Settings are saved when leaving the mode * parameter is in Hz */ -void SetSGFreq (uint32_t f) +bool SetSGFreq (uint32_t f) { if ( ( f >= MIN_SIGLO_FREQ ) && ( f <= MAX_SIGLO_FREQ ) ) + { sigGenSetting.Frequency = f; + return true; + } + else + return false; } + /* * Sig gen state is not saved - always want to start in off state */ @@ -2593,6 +2613,20 @@ int oldLevel = sigGenSetting.RX_Drive; } +void SetSGPower ( int16_t dBm ) +{ + // Add algorithm to set attenuator and IF drive level + // initially limit to just set attenuator + + if ( dBm > sigGenSetting.Calibration ) + dBm = sigGenSetting.Calibration; + if ( dBm < sigGenSetting.Calibration - ATTENUATOR_RANGE ) + dBm = sigGenSetting.Calibration - ATTENUATOR_RANGE; + + sigGenSetting.Power = dBm; + changedSetting = true; +} + #ifdef SI_TG_LO_CS /* * "SetTGLoDrive" sets the transmitter max output level for the tracking generator. @@ -2709,7 +2743,7 @@ int32_t GetTGOffset ( ) } /* - * Set the IF frequency - M0WID addition + * Set the Track Gen frequency - M0WID addition */ bool SetTGFreq ( int32_t freq ) diff --git a/cmd.h b/cmd.h index 90bff9b..7ee44f3 100644 --- a/cmd.h +++ b/cmd.h @@ -80,7 +80,7 @@ #define MSG_EXTGAIN 51 // Set external gain or attenuation #define MSG_SGON 52 // Turn Signal Generator output on #define MSG_SGOFF 53 // Turn Signal Generator output off -#define MSG_SG_FREQ 54 // Set Signal Generator Frequency +#define MSG_SGFREQ 54 // Set Signal Generator Frequency #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 @@ -147,8 +147,10 @@ bool SetIFFrequency ( int32_t f ); // Sets the IF frequency void SetLoDrive ( uint8_t level ); // Sets LO Si4432 output level void SetSGState (uint16_t s); +bool SetSGFreq ( uint32_t freq); // set signal generator frequency - returns false if invalid void SetSGLoDrive ( uint8_t level ); void SetSGRxDrive ( uint8_t level ); +void SetSGPower ( int16_t dBm ); // Set signal generator attenuator and drive levels void SetTracking ( int8_t m ); // set tracking generator mode void SetTGLoDrive ( uint8_t level ); // set tracking generator drive diff --git a/data/index.html b/data/index.html index f8469a5..6cc665f 100644 --- a/data/index.html +++ b/data/index.html @@ -50,26 +50,42 @@