Skip to content

Commit

Permalink
v1.460: fix for KiwiSDR Android app
Browse files Browse the repository at this point in the history
  • Loading branch information
jks-prv committed May 24, 2021
1 parent adfc0a7 commit 3628c3d
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 79 deletions.
4 changes: 4 additions & 0 deletions CHANGE_LOG
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ CHANGE_LOG

For the Github commit log see here: github.com/jks-prv/Beagle_SDR_GPS/commits/master

v1.460 May 24, 2021
Fix needed by the KiwiSDR Android app (from the Google Play store).
Match frequency step amounts between "snap to nearest" mode and L/R arrow keys.

v1.459 May 23, 2021
Waterfall / spectrum:
Fixed the CIC compensation added to the last release.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VERSION_MAJ = 1
VERSION_MIN = 459
VERSION_MIN = 460

# Caution: software update mechanism depends on format of first two lines in this file

Expand Down
6 changes: 3 additions & 3 deletions web/extensions/colormap/colormap.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ function colormap_init()
function colormap_select()
{
var which = cmap.which = (wf.cmap >= kiwi.cmap_e.custom_1)? (wf.cmap - kiwi.cmap_e.custom_1) : -1;
var s = localStorage.getItem('colormap');
var s = kiwi_localStorage_getItem('colormap');

if (cmap.transfer_canvas && which == -1) {
var c = cmap.transfer_canvas.ctx;
Expand Down Expand Up @@ -450,7 +450,7 @@ function colormap_clear_button_cb(path, idx)
colormap_color_gain_cb('', 0, true, false, cmap.R, 0);
colormap_color_gain_cb('', 0, true, false, cmap.G, 0);
colormap_color_gain_cb('', 0, true, false, cmap.B, 0);
localStorage.setItem('colormap', JSON.stringify(cmap.save));
kiwi_localStorage_setItem('colormap', JSON.stringify(cmap.save));
}

function colormap_color_gain_cb(path, val, done, first, param, y_new)
Expand Down Expand Up @@ -712,7 +712,7 @@ function colormap_transfer_mouseup_cb(evt, escape)

var s = JSON.stringify(cmap.save);
//console.log('SAVE '+ s);
localStorage.setItem('colormap', s);
kiwi_localStorage_setItem('colormap', s);
}

function colormap_escape_key_cb()
Expand Down
2 changes: 1 addition & 1 deletion web/extensions/colormap/colormap.min.js

Large diffs are not rendered by default.

Binary file modified web/extensions/colormap/colormap.min.js.gz
Binary file not shown.
25 changes: 25 additions & 0 deletions web/kiwi/kiwi_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,31 @@ function deleteCookie(cookie)
createCookie(cookie, 0, -1);
}

// appinventor.mit.edu used by KiwiSDR Android app doesn't have localStorage
function kiwi_localStorage_getItem(s)
{
var rv;
try {
if (localStorage == null) return null;
rv = localStorage.getItem(s);
} catch(ex) {
rv = null;
}
return rv;
}

function kiwi_localStorage_setItem(s, v)
{
var rv;
try {
if (localStorage == null) return null;
rv = localStorage.setItem(s, v);
} catch(ex) {
rv = null;
}
return rv;
}

// Get function from string, with or without scopes (by Nicolas Gauthier)
// stackoverflow.com/questions/912596/how-to-turn-a-string-into-a-javascript-function-call
// returns null if var doesn't exist in last scope, throws error if scope level missing
Expand Down
2 changes: 1 addition & 1 deletion web/kiwi/kiwi_util.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions web/kiwisdr.min.js

Large diffs are not rendered by default.

Binary file modified web/kiwisdr.min.js.gz
Binary file not shown.
118 changes: 48 additions & 70 deletions web/openwebrx/openwebrx.js
Original file line number Diff line number Diff line change
Expand Up @@ -2133,36 +2133,20 @@ function canvas_start_drag(evt, x, y)
dx_show_edit_panel(evt, -1);
} else

// select waterfall on nearest appropriate boundary (1, 5 or 9/10 kHz depending on band)
// select waterfall on nearest appropriate boundary (1, 5 or 9/10 kHz depending on band & mode)
if ((evt.shiftKey && !(evt.ctrlKey || evt.altKey)) || owrx.wf_snap) {
canvas_ignore_mouse_event = true;
if (debug_canvas_drag) console.log('CSD-Wboundary IME=set-true');
var step_Hz = 1000;
var fold = canvas_get_dspfreq(x);

var b = find_band(fold);
//if (b) console.log(b)
var cm = cur_mode.substr(0,2);
var am_ssb_iq_drm = (cm == 'am' || cm == 'sa' || cm == 'qa' || cm == 'ls' || cm == 'us' || cm == 'iq' || cm == 'dr');
//console_log('nearest', cm, am_ssb_iq_drm);
var ITU_region = cfg.init.ITU_region + 1;
var ham_80m_swbc_75m_overlap = (ITU_region == 2 && b && b.name == '75m');

if (b != null && (b.name == 'LW' || b.name == 'MW')) {
if (am_ssb_iq_drm) {
step_Hz = step_9_10? 9000 : 10000;
//console.log('SFT-CLICK 9_10');
}
} else
if (b != null && (b.s == svc.B) && !ham_80m_swbc_75m_overlap) { // SWBC bands
if (am_ssb_iq_drm) {
step_Hz = 5000;
//console.log('SFT-CLICK SWBC');
}
}
var rv = freq_step_amount(b);
var step_Hz = rv.step_Hz;

var trunc = fold / step_Hz;
var fnew = Math.round(trunc) * step_Hz;
//console.log('SFT-CLICK '+cur_mode+' fold='+fold+' step='+step_Hz+' trunc='+trunc+' fnew='+fnew);
//console.log('SFT-CLICK '+cur_mode+' fold='+fold+' step='+step_Hz+' trunc='+trunc+' fnew='+fnew +' '+ rv.s);
freqmode_set_dsp_kHz(fnew/1000, null);
} else

Expand Down Expand Up @@ -3607,8 +3591,7 @@ function waterfall_init()

if (shortcut.keys != '') setTimeout(keyboard_shortcut_url_keys, 3000);


wf_snap(localStorage.getItem('wf_snap'));
wf_snap(kiwi_localStorage_getItem('wf_snap'));

if (kiwi_isMobile() || mobile_laptop_test)
mobile_init();
Expand All @@ -3619,10 +3602,10 @@ function waterfall_init()
function wf_snap(set)
{
//console.log('wf_snap cur='+ owrx.wf_snap +' set='+ set);
owrx.wf_snap = isUndefined(set)? (owrx.wf_snap ^ 1) : (isNull(set)? 0 : +set);
owrx.wf_snap = isUndefined(set)? (owrx.wf_snap ^ 1) : (isNull(set)? 0 : (+set));
//console.log('wf_snap new='+ owrx.wf_snap);
w3_el('id-waterfall-container').style.cursor = owrx.wf_cursor = owrx.wf_snap? 'col-resize' : 'crosshair';
localStorage.setItem('wf_snap', owrx.wf_snap);
kiwi_localStorage_setItem('wf_snap', owrx.wf_snap);
}

var waterfall_dont_scale=0;
Expand Down Expand Up @@ -5182,63 +5165,56 @@ var up_down = {
iq: [ 0, -1, -0.1, 0.1, 1, 0 ],
};

var up_down_default = {
// only referenced by special step logic, so only max/min values used (that's why others are zero)
// NB: abs(values)
am: [ 5, 0, 0, 0, 0, 5 ],
amn: [ 5, 0, 0, 0, 0, 5 ],
sam: [ 5, 0, 0, 0, 0, 5 ],
sal: [ 5, 0, 0, 0, 0, 5 ],
sau: [ 5, 0, 0, 0, 0, 5 ],
sas: [ 5, 0, 0, 0, 0, 5 ],
qam: [ 5, 0, 0, 0, 0, 5 ],
drm: [ 5, 0, 0, 0, 0, 5 ],
usb: [ 5, 0, 0, 0, 0, 5 ],
usn: [ 5, 0, 0, 0, 0, 5 ],
lsb: [ 5, 0, 0, 0, 0, 5 ],
lsn: [ 5, 0, 0, 0, 0, 5 ],
cw: [ 1, 0, 0, 0, 0, 1 ],
cwn: [ 1, 0, 0, 0, 0, 1 ],
// nbfm doesn't have special step
iq: [ 5, 0, 0, 0, 0, 5 ],
};

var NDB_400_1000_mode = 1; // special 400/1000 step mode for NDB band

function special_step(b, sel, caller)
// nearest appropriate boundary (1, 5 or 9/10 kHz depending on band & mode)
function freq_step_amount(b)
{
var s = 'SPECIAL_STEP '+ caller +' sel='+ sel;
var step_Hz;
var step_Hz = 1000;
var s = ' 1k default';
var cm = cur_mode.substr(0,2);
var am_ssb_iq_drm = (cm == 'am' || cm == 'sa' || cm == 'qa' || cm == 'ls' || cm == 'us' || cm == 'iq' || cm == 'dr');
var ITU_region = cfg.init.ITU_region + 1;
var ham_80m_swbc_75m_overlap = (ITU_region == 2 && b && b.name == '75m');

if (b != null && b.name == 'NDB') {
if (b && b.name == 'NDB') {
if (cm == 'cw') {
step_Hz = NDB_400_1000_mode;
} else {
step_Hz = -1;
}
s += ' NDB';
s = ' NDB';
} else
if (b != null && (b.name == 'LW' || b.name == 'MW')) {
var am_ssb_iq_drm = (cm == 'am' || cm == 'sa' || cm == 'qa' || cm == 'ls' || cm == 'us' || cm == 'iq' || cm == 'dr');
if (b && (b.name == 'LW' || b.name == 'MW')) {
//console_log('special step', cm, am_ssb_iq_drm);
if (am_ssb_iq_drm) {
step_Hz = step_9_10? 9000 : 10000;
} else {
step_Hz = -1;
}
s += ' LW/MW';
s = ' LW/MW';
} else
if (b != null && b.chan != 0) {
if (b && (b.s == svc.B) && !ham_80m_swbc_75m_overlap) { // SWBC bands
if (am_ssb_iq_drm) {
step_Hz = 5000;
s = ' SWBC 5k';
//console.log('SFT-CLICK SWBC');
}
} else
if (b && b.chan != 0) {
step_Hz = b.chan;
s += ' band='+ b.name +' ';
} else {
step_Hz = -1;
s += ' no band chan found, use default';
s = ' band='+ b.name +' chan='+ b.chan;
}
if (step_Hz == -1) step_Hz = up_down_default[cur_mode][sel]*1000;

return { step_Hz: step_Hz, s:s };
}

function special_step(b, sel, caller)
{
var s = 'SPECIAL_STEP '+ caller +' sel='+ sel;

var rv = freq_step_amount(b);
var step_Hz = rv.step_Hz;
s += rv.s;

if (sel < num_step_buttons/2) step_Hz = -step_Hz;
s += ' '+ step_Hz;
s += ' step='+ step_Hz;
//console.log(s);
return step_Hz;
}
Expand Down Expand Up @@ -5299,7 +5275,7 @@ function freq_step_update_ui(force)

var cm = cur_mode.substr(0,2);
var am_ssb_iq_drm = (cm == 'am' || cm == 'sa' || cm == 'qa' || cm == 'ls' || cm == 'us' || cm == 'iq' || cm == 'dr');
var show_9_10 = (b != null && (b.name == 'LW' || b.name == 'MW') && am_ssb_iq_drm)? true:false;
var show_9_10 = (b && (b.name == 'LW' || b.name == 'MW') && am_ssb_iq_drm)? true:false;
w3_visible('id-9-10-cell', show_9_10);

for (var i=0; i < num_step_buttons; i++) {
Expand Down Expand Up @@ -6676,7 +6652,8 @@ var shortcut = {
keys: '',
SHIFT: 1,
CTL_OR_ALT: 2,
SHIFT_PLUS_CTL_OR_ALT: 3
SHIFT_PLUS_CTL_OR_ALT: 3,
KEYCODE_ALT: 18
};

function keyboard_shortcut_init()
Expand Down Expand Up @@ -6751,7 +6728,7 @@ function keyboard_shortcut_url_keys()
// :space: :tab:
// .

function keyboard_shortcut(key, mod, ctlAlt)
function keyboard_shortcut(key, mod, ctlAlt, keyCode)
{
var action = true;
var dir = ctlAlt? -1 : 1;
Expand Down Expand Up @@ -6832,7 +6809,7 @@ function keyboard_shortcut(key, mod, ctlAlt)
case '?': case 'h': keyboard_shortcut_help(); break;

default:
if (key.length == 1) console.log('no shortcut key <'+ key +'>');
if (key.length == 1 && keyCode != shortcut.KEYCODE_ALT) console.log('no shortcut key <'+ key +'>');
action = false; break;

}
Expand Down Expand Up @@ -6907,7 +6884,8 @@ function keyboard_shortcut_event(evt)
//console.log('shortcut alt k='+ k);
}

keyboard_shortcut(k, mod, ctlAlt);
//console.log('keyboard_shortcut key=<'+ k +'> keyCode='+ evt.keyCode +' mod='+ mod +' ctlAlt='+ ctlAlt +' alt='+ alt);
keyboard_shortcut(k, mod, ctlAlt, evt.keyCode);

/*
if (k != 'Shift' && k != 'Control' && evt.key != 'Alt') {
Expand Down
2 changes: 1 addition & 1 deletion web/openwebrx/openwebrx.min.js

Large diffs are not rendered by default.

0 comments on commit 3628c3d

Please sign in to comment.