(some changes, e.g. removal of unsused variables, avoiding "shadowing" of global variables, etc. were induced by
running "cppcheck" on the source code).
Makefile
removed PTT_INCLUDE and PTT_OPTIONS since this was nowhere used and this is not necessary
(PTT can be handled by existing GPIO/I2C code). The #ifdef PTT/#endif in gpio.c is also
removed since it initialized variables nowhere used.
MacOS.h:
added (fake implementation of) CLOCK_MONOTONIC_RAW for old MacOS versions that do not have their "own"
clock_gettime().
band.c:
corrected some initial bandstacks (obvious cut+past errors)
make global variable "band" private to band.c, renamed it to
current_band to avoid confusion.
REASON: at zillions of places, this variable was shadowed by
local variables anyway.
MIDI MENU:
midi_menu.c, save_cb(): MIDI device name my contain slashes, e.g.
my CW Keyer takes the name "Teensy MIDI/AUDIO". This is of course
not a valid file name, so in the save_cb, slashes are replaced by
colons, and I took the occasion to replace spaces by underscores,
so the file name in my case is just converted to
"Teensy_MIDI:AUDIO".
midi_menu.c, midi_save_state() and midi_restore_state():
Action strings (ActionTable[i].str) often contain newline
characters (see actions.c. AF_GAIN_RX1 etc.). Writing these
values (with a line break!) to the props file does not work.
So these '\n' are converted to '$' in midi_save_state.
In midi_restore_state, after reading the value from the props
file, '$' is converted back to '\n' before searching this
string in the ActionTablee.
Support for external CW Keyers:
added "actions" in actions.h/actions.c, namely
CW_KEYER_KEYDOWN
CW_KEYER_SIDETONE
CW_KEYER_SPEED
such that external keyer can report key-down/up, CW sidetone change
and CW speed change events.
some CW actions (change side tone etc.) make sense also if not
compiled with LOCALCW since these parameters are then sent to the
radio via the HPSDR protocol (some #ifdef LOCALCW deleted in
actions.c)
MOX and TUNE actions in actions.c
MOX and TUNE handling was a duplicate of the handling
already implemented in toolbar.c which is now used to
avoid code repetition (note: in toolbar.c they now
"respect" can_transmit).
New interface to "process_action"
added interface "schedule_action()" to actions.c, that replaces
allocating a PROCESS_ACTION structure, fill it with data and
put a process_action() in the GTK idle queue.
The reason to do so is that time-critical CW events (keydown, left
and right key) can get "immediate" treatment and this is the same
no matter whether the event was triggered by MIDI, a GPIO encoder
button, a GPIO input line or an i2c input line.
Note this interface also avoids a large amount of code repetition.
I2C service routine
(An attempt to solve some problems in i2c_interrupt function)
make this thread-safe through a mutex. No other thread (e.g.
another instance of i2c_interrrupt() triggered by a bouncing
contact) my intervene between reading the "flags" and the "ints".
bits set in flags (and not in ints) determine which line is
to be handled here. The corresponding bit in "ints" then
determines if a PRESSED or a RELEASED is to be emitted
(i2c only emitted PRESSED so far, which is dysfunctional
e.g. for RIT_PLUS).
if more than one bit is set in flags, process them all
NOTE: I have no "controller", just an MCP23017 on a bread-board,
so this probably needs more testing.
Header files
All declarations of functions with empty parameter lists have been
changed as to explicitly specify this, that is
extern int foo(); ==> extern int foo(void);
This helps the compiler spotting coding errors. Two such errors
(inconsistent use of vfo_update() and set_squelch()) were corrected.
gpio.c
Some more (and more consistent) settings of #ifdef GPIO...#endif,
use new schedule_action() interface such that CW keys can be
handled.
midi3.c
make use of the schedule_action() interface
sliders.c, zoompan.c, sliders.h
The "scale_status" is now logically an "enum action" value, and therefore
its neutral value must be NO_ACTION instead of NO_FUNCTION.
The old scale_status enum from sliders.h is now removed.
set_squelch(RECEIVER *rx)
this now has a RECEIVER * argument, as suggested by its use
in actions.c (SQUELCH_RX1, SQUELCH_RX2).
including "midi_menu.h"
one should always include "midi.h" before one includes "midi_menu.h" in
order to have enum MIDIevent declared (radio.c, new_menu.c)
(some changes, e.g. removal of unsused variables, avoiding "shadowing" of global variables, etc. were induced by running "cppcheck" on the source code).
Makefile
MacOS.h:
band.c:
MIDI MENU:
midi_menu.c, save_cb(): MIDI device name my contain slashes, e.g. my CW Keyer takes the name "Teensy MIDI/AUDIO". This is of course not a valid file name, so in the save_cb, slashes are replaced by colons, and I took the occasion to replace spaces by underscores, so the file name in my case is just converted to "Teensy_MIDI:AUDIO".
midi_menu.c, midi_save_state() and midi_restore_state(): Action strings (ActionTable[i].str) often contain newline characters (see actions.c. AF_GAIN_RX1 etc.). Writing these values (with a line break!) to the props file does not work. So these '\n' are converted to '$' in midi_save_state. In midi_restore_state, after reading the value from the props file, '$' is converted back to '\n' before searching this string in the ActionTablee.
Support for external CW Keyers:
added "actions" in actions.h/actions.c, namely
CW_KEYER_KEYDOWN CW_KEYER_SIDETONE CW_KEYER_SPEED
such that external keyer can report key-down/up, CW sidetone change and CW speed change events.
some CW actions (change side tone etc.) make sense also if not compiled with LOCALCW since these parameters are then sent to the radio via the HPSDR protocol (some #ifdef LOCALCW deleted in actions.c)
MOX and TUNE actions in actions.c
New interface to "process_action"
added interface "schedule_action()" to actions.c, that replaces allocating a PROCESS_ACTION structure, fill it with data and put a process_action() in the GTK idle queue. The reason to do so is that time-critical CW events (keydown, left and right key) can get "immediate" treatment and this is the same no matter whether the event was triggered by MIDI, a GPIO encoder button, a GPIO input line or an i2c input line.
Note this interface also avoids a large amount of code repetition.
I2C service routine
(An attempt to solve some problems in i2c_interrupt function)
make this thread-safe through a mutex. No other thread (e.g. another instance of i2c_interrrupt() triggered by a bouncing contact) my intervene between reading the "flags" and the "ints".
bits set in flags (and not in ints) determine which line is to be handled here. The corresponding bit in "ints" then determines if a PRESSED or a RELEASED is to be emitted (i2c only emitted PRESSED so far, which is dysfunctional e.g. for RIT_PLUS).
if more than one bit is set in flags, process them all
NOTE: I have no "controller", just an MCP23017 on a bread-board, so this probably needs more testing.
Header files
All declarations of functions with empty parameter lists have been changed as to explicitly specify this, that is
extern int foo(); ==> extern int foo(void);
This helps the compiler spotting coding errors. Two such errors (inconsistent use of vfo_update() and set_squelch()) were corrected.
gpio.c
midi3.c
sliders.c, zoompan.c, sliders.h
The "scale_status" is now logically an "enum action" value, and therefore its neutral value must be NO_ACTION instead of NO_FUNCTION. The old scale_status enum from sliders.h is now removed.
set_squelch(RECEIVER *rx)
this now has a RECEIVER * argument, as suggested by its use in actions.c (SQUELCH_RX1, SQUELCH_RX2).
including "midi_menu.h"