This code works for band buttons (after you create the button code of course).
Place it in frontend/src/App.svelte
let band;
let newFrequency;
let newMode;
let currentBand = 80;
function setBand(band,newFrequency,newMode) {
currentBand = band;
frequencyInputComponent.setFrequency(newFrequency * 1e3);
handleFrequencyChange({ detail: newFrequency * 1e3 });
SetMode(newMode);
}
Feed it with :
setBand(80,3750,"LSB")
Next I want to set the waterfall zoom to the width of the chosen band. If you know how to do that, please post your code in this thread.
Update : This change will set the waterfall to the band edges, but you'll need to figure out the numbers for your situation.
function setBand(band,newFrequency,newMode) {
currentBand = band;
frequencyInputComponent.setFrequency(newFrequency * 1e3);
handleFrequencyChange({ detail: newFrequency * 1e3 });
SetMode(newMode);
let [l, m, r] = audio.getAudioRange();
const [waterfallL, waterfallR] = waterfall.getWaterfallRange();
const offset = ((m - waterfallL) / (waterfallR - waterfallL)) * waterfall.canvasWidth;
m = Math.min(waterfall.waterfallMaxSize - 512, Math.max(512, m));
l = Math.floor(m - 512);
r = Math.ceil(m + 512);
switch (band) {
case 2200:
l -= 100;
r += 100;
break;
case 630:
l -= 200;
r += 200;
break;
case 160:
l -= 10000;
r += 10000;
break;
case 80:
l -= 20000;
r += 20000;
break;
}
waterfall.setWaterfallRange(l, r);
frequencyMarkerComponent.updateFrequencyMarkerPositions();
updatePassband();
}
Thank you, I'll try to adopt this as soon as I find time, by "figure out the numbers" you mean the l and r distance form center frequency? still dont get this fully, and how have you coded the button section in HTML?
I used the same button code you did with the Step Selection and just made the some basic changes. I'll post one here.
The full setBand function :
let band;
let newFrequency;
let newMode;
let currentBand = 80; // Set to your startup band or the wrong band button will be highlighted.
function setBand(band,newFrequency,newMode) {
currentBand = band;
frequencyInputComponent.setFrequency(newFrequency * 1e3);
handleFrequencyChange({ detail: newFrequency * 1e3 });
SetMode(newMode);
let [l, m, r] = audio.getAudioRange();
const [waterfallL, waterfallR] = waterfall.getWaterfallRange();
const offset = ((m - waterfallL) / (waterfallR - waterfallL)) * waterfall.canvasWidth;
m = Math.min(waterfall.waterfallMaxSize - 512, Math.max(512, m));
l = Math.floor(m - 512);
r = Math.ceil(m + 512);
switch (band) {
case 2200:
l -= 100;
r += 100;
break;
case 630:
l -= 200;
r += 200;
break;
case 160:
l -= 15000;
r += 15000;
break;
case 80:
l -= 35000;
r += 35000;
break;
case 60:
l -= 6000;
r += 6000;
break;
case 42:
l -= 1000;
r += 1000;
break;
case 40:
l -= 35000;
r += 35000;
break;
case 31:
l -= 1000;
r += 1000;
break;
case 30:
l -= 3300;
r += 3300;
break;
case 20:
l -= 30000;
r += 30000;
break;
case 17:
l -= 7500;
r += 7500;
break;
case 15:
l -= 35000;
r += 35000;
break;
case 12:
l -= 9000;
r += 9000;
break;
case 11:
l -= 35000;
r += 35000;
break;
case 10:
l -= 20000;
r += 20000;
break;
}
waterfall.setWaterfallRange(l, r);
frequencyMarkerComponent.updateFrequencyMarkerPositions();
updatePassband();
}
The button code :
<button class="retro-button text-white font-bold h-10 text-base rounded-md flex items-center justify-center border border-gray-600 shadow-inner transition-all duration-200 ease-in-out {currentBand === 2200 ? 'bg-blue-600 pressed scale-95' : 'bg-gray-700 hover:bg-gray-600'}" on:click={() => setBand(2200,136,"USB")} title="2200 meters" >2200m
</button>
I plan to simplify that function and pass the span information via the function and eliminate that switch(band) mess.
73,
Phil
And thinking about this from an ergonomics standpoint, it'd be much tidier to use a drop down menu like the one that switches the waterfall types than build a bunch of buttons.
I think I will move to that and eliminate the buttons at some point, but for now at least the mobile users are happier.
Very, very good job Phil!!!
Using your code Phil, I think I've made it... http://sv1btlham.no-ip.org:8900/ (http://sv1btlham.no-ip.org:8900/)
Thank you Phil for your great work!
Also implemented on:
http://websdr.hb3xdc.ch:8074/
http://sardinia-sdr.ddns.net:8073/
http://rigi.dyndns-remote.com:8074/
http://zugsdr.ddns.net:8074/
Quote from: Phil - NY4Q on Dec 02, 2024, 11:07 AMI used the same button code you did with the Step Selection and just made the some basic changes. I'll post one here.
The full setBand function :
let band;
let newFrequency;
let newMode;
let currentBand = 80; // Set to your startup band or the wrong band button will be highlighted.
function setBand(band,newFrequency,newMode) {
currentBand = band;
frequencyInputComponent.setFrequency(newFrequency * 1e3);
handleFrequencyChange({ detail: newFrequency * 1e3 });
SetMode(newMode);
let [l, m, r] = audio.getAudioRange();
const [waterfallL, waterfallR] = waterfall.getWaterfallRange();
const offset = ((m - waterfallL) / (waterfallR - waterfallL)) * waterfall.canvasWidth;
m = Math.min(waterfall.waterfallMaxSize - 512, Math.max(512, m));
l = Math.floor(m - 512);
r = Math.ceil(m + 512);
switch (band) {
case 2200:
l -= 100;
r += 100;
break;
case 630:
l -= 200;
r += 200;
break;
case 160:
l -= 15000;
r += 15000;
break;
case 80:
l -= 35000;
r += 35000;
break;
case 60:
l -= 6000;
r += 6000;
break;
case 42:
l -= 1000;
r += 1000;
break;
case 40:
l -= 35000;
r += 35000;
break;
case 31:
l -= 1000;
r += 1000;
break;
case 30:
l -= 3300;
r += 3300;
break;
case 20:
l -= 30000;
r += 30000;
break;
case 17:
l -= 7500;
r += 7500;
break;
case 15:
l -= 35000;
r += 35000;
break;
case 12:
l -= 9000;
r += 9000;
break;
case 11:
l -= 35000;
r += 35000;
break;
case 10:
l -= 20000;
r += 20000;
break;
}
waterfall.setWaterfallRange(l, r);
frequencyMarkerComponent.updateFrequencyMarkerPositions();
updatePassband();
}
The button code :
<button class="retro-button text-white font-bold h-10 text-base rounded-md flex items-center justify-center border border-gray-600 shadow-inner transition-all duration-200 ease-in-out {currentBand === 2200 ? 'bg-blue-600 pressed scale-95' : 'bg-gray-700 hover:bg-gray-600'}" on:click={() => setBand(2200,136,"USB")} title="2200 meters" >2200m
</button>
I plan to simplify that function and pass the span information via the function and eliminate that switch(band) mess.
73,
Phil
Phill, can we include "waterfall controls" to the script? I think it will be a good choice to change automatically "min" and "max" waterfall controls for every band, when a band button is pressed, instead of manually set the sliders, and when "min Zoom" is pressed, to return to default.
Quote from: Emmanuel SV1BTL on Dec 13, 2024, 10:23 AMPhill, can we include "waterfall controls" to the script? I think it will be a good choice to change automatically "min" and "max" waterfall controls for every band, when a band button is pressed, instead of manually set the sliders, and when "min Zoom" is pressed, to return to default.
That should be a fairly easy addition, but I'd like to wait on this to see what Stephen is going to do in the next few days. I believe he posted that he plans to work on some code this month.
Yes he did say that. End of this month.