11.8  Frequency control - tuning


Display


There is a separate frequency scale for each band with a red frequency marker.

Clicking or touching the band can be used for coarse frequency positioning.


The blue tuning band has fast, medium and slow lanes.

Mouse drag or thumbwheel rotation over the tuning band will give a tuning rate of fast, medium
or slow according to which lane is used.

Thumbwheel rotation elsewhere over piWebCAT will give the medium speed.

The fast. medium and slow rates for mouse drag and thumbwheel are user definable in the database.


Tuning

Tuning scale

The client code holds band limits and all the information to draw and calibrate the tuning scale

for each band.   Driver code, using this data can:

 - position the marker for a specified frequency

 - yield a frequency when the scale is clicked  


When this scale is clicked, the new frequency is placed in freqSet and a frequency write message

is placed in the ajax queue for transmission to the radio.  

The display is not updated by this process. (It happens later)


Tuning band

The web browser environment provides mouse related event routines to which I can add my own actions.

We have events:   mouse click, mouse down, mouse up, mouse in, mouse out, mouse move.

All these are specific to the blue tuning area.

The code has continuous access to mouse position X and Y coordinates from anywhere on piWebCAT.

The tuning action is a horizontal drag.
We need the start position of our drag. I use mouse down to activate the process of drag recording.

I initialy used the X position at mouse down as my start X position. However, X is indeterminate with

touch screens for finger down. This is because until you touch the screen, there isn't an X position!!
Fortunately, mouse move fires every few pixels and so I can use the X value at the first mouse move event
as my X position origin. I store this in downX and store the frequency at this point as freqDown.


At subsequent mouse move events (until mouse up occurs),  the displacement is X - downX.


The frequency  F =  freqDown + (X - downX)*pixelstep


where pixel step is Hz / pixel for the current lane (fast, medium or slow - database defined)


The new frequency, F is used to set the main frequency display and the marker on the
tuning scale. freqSet is set to this frequency and also queued for transmission to the radio.


The process stops on mouse up or when the mouse coordinates are outside the tuning window.

I check this at every mouse move event.

(I cannot use mouse leave because it also fires when we change lane... which is unacceptable.
   - We need to be able freely change lane whilst drag tuning.)


Mouse move events may occur faster than they can be offloaded from the queue for send to the server.

This does not matter. There is one slot in the queue for FREQ write for VFO A.
If the next mouse move freqSet event arrives before the previous one in the queue has been transmitted,
then it simply overwrites the previous one. We loose some fast mouse moves. We transmit tuning

changes as fast as the system can handle them and we always transmit the latest available.


Mouse wheel

Mouse wheel tuning. There is a mousewheel event for each click of the wheel. This is translated
into a frequency change according to fast, medium or slow lane position of the mouse pointer.
It is then handled as for mouse drag above. (You can use a bluetooth or OTG mouse with android)


Note that drag and mousewheel tuning band events queue the frequency change for immediate
transmission to the radio.   This is essential to give a realistic fast tuning response.


By contrast, clicking on the tuning scale simply sets freqSet .. which is picked up and acted on

a few 100ms later. I don't feel that this delay is a problem for a course change.


Use of the mouse wheel elsewhere on the piWebCAT window gives the medium tuning rate.