From ab03435f5536c622d9d18227f32f3ca10b488a21 Mon Sep 17 00:00:00 2001 From: M0WID Date: Mon, 7 Sep 2020 23:31:06 +0100 Subject: [PATCH 1/8] First commit Needs web page for Sig gen mode and mechanism to load new page on certain modes --- data/index.html | 55 +++++++++++++++++++++++++++++++++++----------- data/index2.html | 6 ++--- data/refresh.png | Bin 0 -> 655 bytes data/styles.css | 16 ++++++++++++++ simpleSA.h | 2 +- simpleSA.ino | 2 +- simpleSA_wifi.cpp | 49 +++++++++++++++++++++++++++++++++++++---- simpleSA_wifi.h | 19 +++++++++------- 8 files changed, 119 insertions(+), 30 deletions(-) create mode 100644 data/refresh.png diff --git a/data/index.html b/data/index.html index 9bc51c1..94f0144 100644 --- a/data/index.html +++ b/data/index.html @@ -55,7 +55,20 @@
-

Sweep

+
+ + +
@@ -114,6 +127,7 @@
+ dB @@ -270,6 +284,8 @@ + + + + + +
+ + + + +
+
+
+
+ +
+ +
+ + +
+
+ + + MHz +
+
+ + + MHz +
+
+
+ + + MHz +
+
+ + + + MHz +
+ +
+ +
+
+ + + kHz +
+
+
+ + + kHz +
+ +
+
+ + + dB + + + + dB +
+
+
+ + + MHz +
+
+
+
+ + +
+
+
+
+ + + + + dBm +
+
+
+
+
+ + + + + ms +
+
+
+
+ + + + + +
+
+ + + +
+

Settings

+
+ + + dB +
+
+ + + dBm +
+
+
+ + + dBm +
+
+ + + dB +
+
+ + + MHz +
+
+ + +
+ +
+ +
+ + + + + +
+
+
+
+
+
Host: + + + +
+
Status: + +
+
Pings: + +
+
Refresh Interval: + +
+
+
+ + +
+
+ + + + diff --git a/simpleSA.ino b/simpleSA.ino index 2294603..ef7d584 100644 --- a/simpleSA.ino +++ b/simpleSA.ino @@ -504,7 +504,7 @@ uint16_t spacing = 10000; bool paused = false; -bool sigGenOutputOn = false; +uint16_t sigGenOutputOn = false; uint32_t oldFreq; // to store the current Signal Generator frequency /* @@ -672,6 +672,7 @@ bool fsStatus = false; // True if SPIFFS loads ok // If the tracking generator IF SI4432 is defined, then check to see if it is connected tgIF_OK = false; + #ifdef SI_TG_IF_CS // pinMode (SI_TG_IF_CS, INPUT); //Start off in input mode, no pullup // delay(2); @@ -709,6 +710,7 @@ bool fsStatus = false; // True if SPIFFS loads ok // If the tracking generator LO SI4432 is defined, then check to see if it is connected tgLO_OK = false; + #ifdef SI_TG_LO_CS // pinMode (SI_TG_LO_CS, INPUT); //Start off in input mode, no pullup // delay(2); @@ -730,7 +732,9 @@ bool fsStatus = false; // True if SPIFFS loads ok // pinMode (SI_TG_LO_CS, OUTPUT); // digitalWrite(SI_TG_LO_CS, HIGH); // make sure it doesn't get selected // } - +#else + pinMode (25, OUTPUT); + digitalWrite(25, HIGH); // make sure it doesn't get selected #endif diff --git a/simpleSA_wifi.cpp b/simpleSA_wifi.cpp index 7507240..1f41d21 100644 --- a/simpleSA_wifi.cpp +++ b/simpleSA_wifi.cpp @@ -220,10 +220,31 @@ void webSocketEvent ( uint8_t num, WStype_t type, uint8_t* payload, size_t paylo /* - * Format of message to process * - * #a 123.123 Start frequency - * #b 123.123 Stop frequency + * Message format + * #(code) value where code is a single char. Case is important + * + * a start freq (MHz) - sig gen freq if in sig gen mode + * b stop frequency + * c centre frequency + * s Span + * d Local Oscillator Drive + * g PreAmpGain/Mode + * i IF frequency + * m mode + * p set actual power to peak value + * o RefOut + * r request Settings are pushed + * A internal attenuation (PE4302) + * E external gain ( eg attenuator(-ve) or preamp(+ve) ) + * R requested RBW + * S Spur reduction Off/On + * t trackGen Off/On/Fixed + * T trackGen output level + * F Sig Gen frequency + * L Sig Gen level (dBm) + * G Sig Gen Off/On + * P Sig Gen set max output level (dBm) * * Other formats are ignored */ @@ -248,6 +269,9 @@ void webSocketEvent ( uint8_t num, WStype_t type, uint8_t* payload, size_t paylo case SA_LOW_RANGE: SetSweepStart ( value * 1000000.0 ); // Set Low range sweep start frequency break; + case SIG_GEN_LOW_RANGE: + SetSweepStart ( value * 1000000.0 ); // Set Low range sweep start frequency + break; case IF_SWEEP: SetIFsweepStart ( value * 1000000.0 ); // Set IF sweep start frequency break; diff --git a/ui.cpp b/ui.cpp index 3966c79..ca0ccb7 100644 --- a/ui.cpp +++ b/ui.cpp @@ -197,7 +197,7 @@ uint8_t operation_requested = OP_NONE; // No operations so far enum { KM_START, KM_STOP, KM_CENTER, KM_SPAN, KM_FOCUS, KM_REFPOS, KM_ATTENUATION, KM_ACTUALPOWER, KM_IFFREQ, KM_PREAMP, KM_TUNE, KM_SGFREQ, KM_SGLEVEL, KM_SGLEVCAL, KM_IFSTART, KM_IFSTOP, - KM_IFSIG, KM_TGOFFSET, KM_TGLO_DRIVE, KM_TGIF_DRIVE, KM_BANDSCOPESTART, + KM_IFSIG, KM_TGOFFSET, KM_TGFREQ, KM_TGLO_DRIVE, KM_TGIF_DRIVE, KM_BANDSCOPESTART, KM_WFMIN, KM_WFGAIN, KM_BANDSCOPELEVEL, KM_RXSPAN, KM_RXSIG, KM_RBW, KM_EXTERN }; @@ -216,7 +216,7 @@ static const char * const keypad_mode_label[] = "START", "STOP", "CENTER", "SPAN", "FOCUS", "REFPOS", "ATTEN", "POWER", "IF FREQ", "PREAMP", "XTAL CAL", "SG FREQ", "dBm", "Max dBm", "IF START", "IF STOP", - "IF Sig Freq", "TG OFFSET", "TG LO Drive", "TG IF Drive", "START", + "IF Sig Freq", "TG OFFSET", "TG FREQ", "TG LO Drive", "TG IF Drive", "START", "WF MIN", "WF GAIN", "REF LEVEL", "RX SPAN", "RX Sig Freq", "RBW", "EXTERNAL" }; @@ -291,6 +291,7 @@ static void menu_WaterfallGain_cb ( int item ); static void menu_tracking_cb(int item); // M0WID - added in 3.0e static void menu_tg_offset_cb(int item); // M0WID - added in 3.0e +static void menu_tg_frequency_cb(int item); // M0WID - added in 3.0e static void menu_tgIF_drive_cb(int item); // M0WID - added in 3.0e static void menu_tgLO_drive_cb(int item); // M0WID - added in 3.0e @@ -489,11 +490,13 @@ static Menuitem menu_tracking[] = // Tracking generator mode { Menuitem ( MT_FUNC, "OFF", menu_tracking_cb ), Menuitem ( MT_FUNC, "ON", menu_tracking_cb ), - Menuitem ( MT_FUNC, "OFFSET", menu_tg_offset_cb ), - Menuitem ( MT_FUNC, "\2IF\0DRIVE", menu_tgIF_drive_cb ), #ifdef SI_TG_LO_CS + Menuitem ( MT_FUNC, "GENERATE", menu_tracking_cb ), + Menuitem ( MT_FUNC, "FREQUENCY",menu_tg_frequency_cb ), + Menuitem ( MT_FUNC, "OFFSET", menu_tg_offset_cb ), Menuitem ( MT_FUNC, "\2LO\0DRIVE", menu_tgLO_drive_cb ), #endif + Menuitem ( MT_FUNC, "\2IF\0DRIVE", menu_tgIF_drive_cb ), Menuitem ( MT_BACK, "<-BACK" ), // Next level up Menuitem ( MT_END ) // End marker }; @@ -1388,6 +1391,17 @@ void menu_tg_offset_cb ( int item ) ui_process_keypad (); } +/* + * "menu_tg_frequency_cb" - Handles setting the tracking generator frequency when in sig gen mode + */ + +void menu_tg_frequency_cb ( int item ) +{ + int km = KM_TGFREQ; + tft.fillScreen ( bg ); + ui_mode_keypad ( km ); + ui_process_keypad (); +} /* @@ -1450,6 +1464,11 @@ static void menu_tracking_cb (int item ) ui_mode_normal (); // Back to sweep break; + case 2: // Turn Sig gen mode + SetTracking (2); + ui_mode_normal (); // Back to sweep + break; + } } @@ -2133,6 +2152,7 @@ static const keypads_t * const keypads_mode_tbl[] = keypads_freq, // KM_IFSTOP.........IF Sweep stop frequency keypads_freq, // KM_IFSIG..........IF Sweep signal frequency keypads_signed_freq, // KM_TGOFFSET.......Offset Frequency of TG IF compared to SA IF + keypads_freq, // KM_TGFREQ.........Frequency of TG in sig gen mode keypads_level, // KM_TGLO_DRIVE.....Tracking generator LO drive keypads_level, // KM_TGIF_DRIVE.....Tracking generator IF drive keypads_freq, // KM_BANDSCOPESTART.IF Sweep start frequency @@ -2522,6 +2542,10 @@ static void fetch_numeric_target ( void ) uistat.value = trackGenSetting.Offset; break; + case KM_TGFREQ: + uistat.value = trackGenSetting.Frequency; + break; + case KM_TGIF_DRIVE: uistat.value = trackGenSetting.IF_Drive; break; @@ -2945,6 +2969,23 @@ static int keypad_click ( int key ) SetTGOffset ( (int32_t)value ); break; + + case KM_TGFREQ: + if ( (value > MAX_SIGLO_FREQ) || (value < MIN_SIGLO_FREQ) ) + { + strcpy ( fBuff, FormatSignedFrequency (( int32_t ) value )); + + DisplayError ( ERR_WARN, + fBuff, + "Invalid Frequency!", + NULL, + NULL ); + } + else + SetTGFreq ( (int32_t)value ); + break; + + case KM_TGIF_DRIVE: if ( (value > MAX_DRIVE) || (value < MIN_DRIVE) ) { @@ -2958,6 +2999,8 @@ static int keypad_click ( int key ) SetTGIfDrive ( (uint8_t)value ); break; + +#ifdef SI_TG_LO_CS case KM_TGLO_DRIVE: if ( (value > MAX_DRIVE) || (value < MIN_DRIVE) ) { @@ -2970,7 +3013,8 @@ static int keypad_click ( int key ) else SetTGLoDrive ( (uint8_t)value ); break; - +#endif + case KM_BANDSCOPESTART: // Bandscope Start frequency entered? SetBandscopeStart (( int32_t ) value ); @@ -3228,21 +3272,25 @@ void UiProcessTouch ( void ) if ( (touch_y < 10) && (touch_x < 160) ) { marker[0].Toggle(); // marker 1 + setting.MkrStatus[0] = marker[0].Status(); return; } else if ( (touch_y < 10) && (touch_x > 160) ) { marker[2].Toggle(); // marker 3 + setting.MkrStatus[2] = marker[2].Status(); return; } else if ( (touch_y < 20) && (touch_x < 160) ) { marker[1].Toggle(); // marker 2 + setting.MkrStatus[1] = marker[1].Status(); return; } else if ( (touch_y < 20) && (touch_x > 160) ) { marker[3].Toggle(); // marker 4 + setting.MkrStatus[3] = marker[3].Status(); return; } else if ( (touch_y < 40) && (touch_x > 30) ) From acd6e2b6f4c8d34fc9777a3110e848d9c96e3be9 Mon Sep 17 00:00:00 2001 From: M0WID Date: Tue, 29 Sep 2020 23:16:59 +0100 Subject: [PATCH 5/8] Started on sig gen web page --- SigLo.ino | 19 ++- data/index.html | 89 +++++++++- data/siggen.html | 423 ++++------------------------------------------ data/styles.css | 47 ++++++ simpleSA_wifi.cpp | 5 +- 5 files changed, 181 insertions(+), 402 deletions(-) diff --git a/SigLo.ino b/SigLo.ino index c589816..1c35242 100644 --- a/SigLo.ino +++ b/SigLo.ino @@ -107,6 +107,11 @@ void initSigLow() oldFreq = 0; // Force write of frequency on first loop +#ifdef USE_WIFI + if ( numberOfWebsocketClients > 0 ) + pushSettings (); +#endif + } @@ -128,6 +133,7 @@ void doSigGenLow () showUpDownButtons = 1; #endif + boolean changedSetting = false; // Get current touch state and coordinates boolean pressed = tft.getTouch(&t_x, &t_y); // Just uses standard TFT_eSPI function as not bothered about speed @@ -155,6 +161,7 @@ void doSigGenLow () case 5: case 6: incrementFreq( pow(10, 8-b) ); + changedSetting=true; break; case 7: // Decrement buttons @@ -165,6 +172,7 @@ void doSigGenLow () case 12: case 13: decrementFreq( pow(10, 15-b) ); + changedSetting=true; break; case 14: // Return to SAlo mode @@ -231,6 +239,7 @@ void doSigGenLow () tft.setTextColor(TFT_WHITE, SIG_BACKGROUND_COLOR ); tft.print("OFF"); } + changedSetting = true; } break; @@ -250,6 +259,7 @@ void doSigGenLow () 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; } @@ -278,13 +288,20 @@ void doSigGenLow () if (sigGenOutputOn) { delayMicroseconds(300); - SetRX(3); + SetRX(3); // both LO and RX in tx mode } + changedSetting = true; } oldFreq = sigGenSetting.Frequency; oldIF = setting.IF_Freq; oldSigGenOutputOn = sigGenOutputOn; + +#ifdef USE_WIFI + if ( numberOfWebsocketClients > 0 ) + pushSettings (); +#endif + } diff --git a/data/index.html b/data/index.html index 4faeb04..f8469a5 100644 --- a/data/index.html +++ b/data/index.html @@ -32,7 +32,7 @@ -TinySA-ESP +simpleSA @@ -41,7 +41,7 @@ -
+
+
+ + +
@@ -62,7 +83,7 @@ - + @@ -283,6 +304,10 @@
@@ -62,7 +62,7 @@ - + @@ -70,132 +70,26 @@
- - - MHz -
-
- - + + MHz

-
- - - MHz -
- - - - MHz + + + dBm
- -
- -
-
- - - kHz -
-
-
- - - kHz -
- -
-
- - - dB - - - - dB -
-
-
- - - MHz -
-
-
-
- - -
-
-
-
- - - - - dBm -
-
-
-
-
- - - - - ms -
-
-
-
- - - - - -
-
- - -

Settings

- - + + dB
- - + + dBm

@@ -213,39 +107,10 @@ dBm
-
- - - dB -
-
+
MHz -
-
- -
@@ -287,258 +152,27 @@ var refreshInterval = document.getElementById('refreshInterval'); var refresh = document.getElementById('refresh'); var setMode = document.getElementById('setMode'); -var sweepStart = document.getElementById('sweepStart'); -var sweepStop = document.getElementById('sweepStop'); -var setStart = document.getElementById('setStart'); -var setStop = document.getElementById('setStop'); -var setCenter = document.getElementById('setCenter'); -var setSpan = document.getElementById('setSpan'); -var setAtten = document.getElementById('setAtten'); -var setExtern = document.getElementById('setExtern'); +var setFreq = document.getElementById('setFreq'); +var setLevel = document.getElementById('setLevel'); +var calLevel = document.getElementByID('calLevel'); + var setActPower = document.getElementById('setActPower'); -var levelOffset = document.getElementById('levelOffset'); -var setRefOut = document.getElementById('setRefOut'); -var sweepPoints = document.getElementById('sweepPoints'); -var sweepTime = document.getElementById('sweepTime'); -var setSpur = document.getElementById('spurReduction'); -var actRBW = document.getElementById('actRBW'); -var setRBW = document.getElementById('setRBW'); -var setDrive = document.getElementById('setLODrive'); +var setMaxPower = document.getElementByID('setMaxPower'); + +var setLODrive = document.getElementById('setLODrive'); var setIF = document.getElementById('setIF'); -var setPreAmp = document.getElementById('setPreAmp'); -var setAverage = document.getElementById('Average'); -var setTrackGen = document.getElementById('trackGen'); -var setTrackGenPower = document.getElementById('setTrackGenPower'); -var store1 = document.getElementById('store1'); -var store2 = document.getElementById('store2'); -var store3 = document.getElementById('store3'); -var store4 = document.getElementById('store4'); + //var messageWindow = document.getElementById('message'); -var tempCenter; // initialise these to silly values to force an update first time round -var oldSweepStart = -1; -var oldSweepStop = -1; -var oldSweepCenter = -1; -var oldSetRefOut = -2; -var oldSetRBW = -10; -var oldLevelOffset = 1000; -var oldAttenuation = 1000; -var oldExternalGain = 1000; -var oldDrive = -1; +var oldFreq = 0 +var oldSetLevel = 100; +var oldCalLevel = 100; +var oldMaxPower = 100; +var oldLODrive = -1; var oldIF = 0; -var oldPreAmp = 0; -var oldSweepPoints = 0; -var oldSpur = 2; -var oldTrackGen = 2; -var oldTrackGenPower = 1000; -// Chart configuration - Scope -var RSSISamples = [ - {y:10}, - {y:11}, - {y:12}, - {y:13}, - {y:14}, - {y:15}, - {y:16}, - {y:17}, - {y:18}, - ]; // dummy for test - -var dBSamples = [ - {y:-10}, - {y:-20}, - {y:-23}, - {y:-90}, - {y:-120}, - {y:-100}, - {y:-80}, - {y:-30}, - {y:-40}, - ]; // dummy for test - -var gainSamples = [ - {x:0, y:42}, - {x:10, y:43}, - {x:20, y:44}, - {x:30, y:45}, - {x:40, y:46}, - {x:50, y:47}, - {x:80, y:48}, - {x:90, y:49}, - {x:100, y:40}, - ]; // dummy for test - -var store1Samples = [ - {x:0, y:42}, - {x:10, y:43}, - {x:20, y:44}, - {x:30, y:45}, - {x:40, y:46}, - {x:50, y:47}, - {x:80, y:48}, - {x:90, y:49}, - {x:100, y:40}, - ]; - -var store2Samples = [ - {x:0, y:42}, - {x:10, y:43}, - {x:20, y:44}, - {x:30, y:45}, - {x:40, y:46}, - {x:50, y:47}, - {x:80, y:48}, - {x:90, y:49}, - {x:100, y:40}, - ]; - - var store3Samples = [ - {x:0, y:42}, - {x:10, y:43}, - {x:20, y:44}, - {x:30, y:45}, - {x:40, y:46}, - {x:50, y:47}, - {x:80, y:48}, - {x:90, y:49}, - {x:100, y:40}, - ]; - - var store4Samples = [ - {x:0, y:42}, - {x:10, y:43}, - {x:20, y:44}, - {x:30, y:45}, - {x:40, y:46}, - {x:50, y:47}, - {x:80, y:48}, - {x:90, y:49}, - {x:100, y:40}, - ]; - - -var chartSA = new CanvasJS.Chart("chartSA", - { - animationEnabled: false, - zoomEnabled: true, - zoomType: "xy", - //height:800, - title: { - text: "ESP32 TinySA", - fontSize: 28 - }, - axisX: { - title: "Frequency (MHz)", - titleFontSize: 24 - }, - axisY: - { - title: "dB", - titleFontSize: 24, - minimum: -120 - }, - axisY2: [ - { - title: "RSSI", - titleFontSize: 24, - minimum: 0, - maximum: 255 - }, - { - title: "Gain", - titleFontSize: 24, - minimum: 0, - maximum: 50 - }], - exportEnabled: true, - legend: { - cursor: "pointer", - itemclick: function (e) { - //console.log("legend click: " + e.dataPointIndex); - //console.log(e); - if (typeof (e.dataSeries.visible) === "undefined" || e.dataSeries.visible) { - e.dataSeries.visible = false; - } else { - e.dataSeries.visible = true; - } - - e.chart.render(); - } - }, - data: [ - { - type: "line", - name: "dB", - dataPoints : dBSamples, - showInLegend : true - }, - { - type: "line", - name: "RSSI", - axisYType: "secondary", - dataPoints : RSSISamples, - showInLegend : true, - visible : false - }, - { - type: "line", - name: "gain", - axisYType: "secondary", - axisYIndex: 1, - dataPoints : gainSamples, - showInLegend : true, - visible : false - }, - { - type: "line", - name: "average", - dataPoints : dBSamples, - showInLegend : true, - visible : false - }, - { - type: "line", - name: "min", - dataPoints : dBSamples, - showInLegend : true, - visible : false - }, - { - type: "line", - name: "store1", - dataPoints : store1Samples, - showInLegend : true, - visible : false - }, - { - type: "line", - name: "store2", - dataPoints : store2Samples, - showInLegend : true, - visible : false - }, - { - type: "line", - name: "store3", - dataPoints : store3Samples, - showInLegend : true, - visible : false - }, - { - type: "line", - name: "store4", - dataPoints : store4Samples, - showInLegend : true, - visible : false - } - ] - }); - - -renderChart(); // Add handlers for the change events in the input fields @@ -551,7 +185,7 @@ setMode.addEventListener('change', (event) => { sendValue("m", setMode.value); }); -setStart.addEventListener('change', (event) => { +setFreq.addEventListener('change', (event) => { sendValue("a", setStart.value); }); @@ -1287,7 +921,7 @@ function sendValue(c, val) // // Message format // #(code) value where code is a single char. Case is important - // a start freq (MHz) + // a start freq (MHz) - sig gen freq if in sig gen mode // b stop frequency // c centre frequency // s Span @@ -1304,6 +938,9 @@ function sendValue(c, val) // S Spur reduction Off/On // t trackGen Off/On/Fixed // T trackGen output level + // L Sig Gen level (dBm) + // G Sig Gen Off/On + // P Sig Gen set max output level (dBm) // //connection.send("# " + messageCounter + " " + sampleThreshold + " " + sampleSize); connection.send("#" + c + " " + val); diff --git a/data/styles.css b/data/styles.css index 9a58f19..de25140 100644 --- a/data/styles.css +++ b/data/styles.css @@ -192,8 +192,55 @@ input[type="number"] { .setting-label { width: 80px; display: inline-block; + } + +.freq-label { + width: 160px; + display: inline-block; + font-weight: bolder; + font-size: 32px; } + +.freq-input { + border: solid 1px grey; + text-align: right; + width: 160px; + display: inline-block; + font-weight: bolder; + font-size: 32px; + } + TH, .bold { background-color: lightblue; color: black; } + +.slider { + -webkit-appearance: none; + width: 100%; + height: 15px; + border-radius: 5px; + background: #d3d3d3; + outline: none; + opacity: 0.7; + -webkit-transition: .2s; + transition: opacity .2s; +} + +.slider::-webkit-slider-thumb { + -webkit-appearance: none; + appearance: none; + width: 25px; + height: 25px; + border-radius: 50%; + background: #4CAF50; + cursor: pointer; +} + +.slider::-moz-range-thumb { + width: 25px; + height: 25px; + border-radius: 50%; + background: #4CAF50; + cursor: pointer; +} diff --git a/simpleSA_wifi.cpp b/simpleSA_wifi.cpp index 1f41d21..0af1df8 100644 --- a/simpleSA_wifi.cpp +++ b/simpleSA_wifi.cpp @@ -239,8 +239,9 @@ void webSocketEvent ( uint8_t num, WStype_t type, uint8_t* payload, size_t paylo * E external gain ( eg attenuator(-ve) or preamp(+ve) ) * R requested RBW * S Spur reduction Off/On - * t trackGen Off/On/Fixed + * t trackGen Off/On/Generate * T trackGen output level + * f trackgen signal generator frequency * F Sig Gen frequency * L Sig Gen level (dBm) * G Sig Gen Off/On @@ -372,7 +373,7 @@ void webSocketEvent ( uint8_t num, WStype_t type, uint8_t* payload, size_t paylo SetSpur ( (int8_t)value ); break; - case 't': // Tracking Generator on/off + case 't': // Tracking Generator off/on/generate SetTracking ( (int8_t)value ); break; From ed4563c0c97d60a2ef66d9eb3c10d37a000869b9 Mon Sep 17 00:00:00 2001 From: M0WID Date: Sat, 3 Oct 2020 23:17:19 +0100 Subject: [PATCH 6/8] Sig Gen Web page update Still working out a good layout and method to change frequency on mobile platforms. Now works, needs some formatting and pwr control adding, then duplicate for track gen --- SigLo.ino | 11 ++- cmd.cpp | 38 ++++++++- cmd.h | 4 +- data/index.html | 203 +++++++++++++++++++++++++++++++++++++++++++--- data/styles.css | 81 +++++++++++++++--- simpleSA_wifi.cpp | 8 ++ 6 files changed, 316 insertions(+), 29 deletions(-) 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 @@
-
+ -