Band Configuration Change Example - K7MDL2/IC-705-BLE-Serial-Example GitHub Wiki
In the ideal world I would have a generic mechanism like a config file to plug in a band and have the right stuff show up in the right places. Maybe later. A request came in to replace the existing 222 and 902 bands I had configured with 10G AND 24G Xvtr bands. Below is the guidance I provided.
The best way is to use the predefined bands and replace button band assignments which occur in a few places. The band table is searched lowest record to highest record for band edges so you do not want to alter it.
These 2 new bands already exist in the bands table and are enumerated as BAND_3cm, BAND_24G, The enumeration is simple an index to the table - the row number.
The bands table struct Bands bands[NUM_OF_BANDS] = { has predefined bands for 0 to 122GHz. Some are arranged to match the IC-705 hence the AIR,FM, and AM bands. If your radio doen not have some of these bands then they are simply ignored as they should never be chosen.
#define XVBOX is used as an alternate configuration for my 3-band transverter project and does not have to be used but it can be convenient if you are only using the band buttons (or PC CAT control) and have only 3 Xvtr bands. Without XVBOX config XVTR bands are cycled through.
The XVBOX sections contain config assignments (like buttons and wired input patterns) for 222, 902/3 and 1296 Xvtr bands and use an alternate LO value of 28MHz IF for 902/3 to match my Xvtr vs the standard 144 that most 33cm Xvtrs use.
Here is a section of the bands table for example showing the different LO (4th column, 874Mhz LO for my 28Mhz IF) for my 33cm band:
{ "Air", 118000000, 137000000, 0, 119200000, 2, 1, 0, 1, 0, 0, 0, 25, DECODE_INPUT_BANDAIR }, // AIR
{ "2M", 144000000, 148000000, 0, 144200000, 1, 1, 0, 1, 0, 0, 0, 25, DECODE_INPUT_BAND144 }, // 2m
{ "1.25M", 222000000, 225000000, 194000000, 222100000, 1, 1, 0, 1, 0, 0, 0, 25, DECODE_INPUT_BAND222 }, // 222 with 28Mhz LO
{ "70cm", 430000000, 450000000, 0, 432100000, 1, 1, 0, 1, 0, 0, 0, 25, DECODE_INPUT_BAND432 }, // 430/440 No LO
#ifdef XVBOX // for 705 transverter box, using 28Mhz IF 902
{ "33cm", 902000000, 928000000, 874000000, 903100000, 1, 1, 0, 1, 0, 0, 0, 25, DECODE_INPUT_BAND902 }, // 902 with 28Mhz LO
#else // typical usage 144 IF for 902
{ "33cm", 902000000, 928000000, 758000000, 903100000, 1, 1, 0, 1, 0, 0, 0, 25, DECODE_INPUT_BAND902 }, // 902 with 144Mhz LO
#endif
{ "23cm", 1240000000, 1300000000, 1152000000, 1296100000, 1, 1, 0, 1, 0, 0, 0, 25, DECODE_INPUT_BAND1296 }, // 1296Mhz with 144Mhz LO
{ "13cm", 2300000000, 2450000000, 1870000000, 2304100000, 1, 1, 0, 1, 0, 0, 0, 25, DECODE_INPUT_BAND2400 }, // 2.3 and 2.4GHz
{ "9cm", 3400000000, 3410000000, 3256000000, 3400100000, 1, 1, 0, 1, 0, 0, 0, 25, DECODE_INPUT_BAND3300 }, // 3.3GHz
{ "6cm", 5650000000, 5925000000, 5328000000, 5760100000, 1, 1, 0, 1, 0, 0, 0, 25, DECODE_INPUT_BAND5760 }, // 5.7GHz
{ "3cm", 10000000000, 10500000000, 0, 10368100000, 1, 1, 0, 1, 0, 0, 0, 25, DECODE_INPUT_BAND10G }, // 10GHz
{ "24G", 24000000000, 24002000000, 0, 24031000000, 1, 1, 0, 1, 0, 0, 0, 25, DECODE_INPUT_BAND24G }, // 24GHz
{ "47G", 47000000000, 47002000000, 0, 47192100000, 1, 1, 0, 1, 0, 0, 0, 25, DECODE_INPUT_BAND47G }, // 47GHz
{ "76G", 76000000000, 76002000000, 0, 76000000000, 1, 1, 0, 1, 0, 0, 0, 25, DECODE_INPUT_BAND76G }, // 76GHz
{"122G", 122000000000, 122002000000, 0, 122001000000, 1, 1, 0, 1, 0, 0, 0, 25, DECODE_INPUT_BAND122G }, // 122GHz
{"GENE", 0, 123000000000, 0, 432000000, 1, 1, 0, 1, 0, 0, 0, 25, DECODE_INPUT_B_GENERAL } // 0 to 122GHz
Edit the LO values for any Xvtr band with your LO value. For 10G with 432 IF and 24G band with 144 IF calculate the LO values:
24.0GHz – 144.0Mhz = 23,856,000,000
10.0GHz = 432.0Mhz = 9,136,000,000
Then plug them into the table.
{ "3cm", 10000000000, 10500000000, 9136000000, 10368100000, 1, 1, 0, 1, 0, 0, 0, 25, DECODE_INPUT_BAND10G }, // 10GHz
{ "24G", 24000000000, 24002000000, 23856000000, 24031000000, 1, 1, 0, 1, 0, 0, 0, 25, DECODE_INPUT_BAND24G }, // 24GHz
You can just edit the table, no need to make them conditional with XVBox. I used XVBox because I was building and testing for multiple configurations. You can keep using XVBOX for the other desired effects but it is not required in the table for most users.
To assign the desired bands to the 3 buttons you search for the old band enums like “BAND_1_25M”
When XVBox is defined, The 3 M5Core module buttons are assigned directly to 3 chosen Xvtr bands ran than other behaviors like cycling through a list. Pressing them activates the Xvtr band and Xvtr mode assigned, and touching an active band button again deactivates Xvtr mode, restoring the 705 back to the last non-Xvtr band.
To change the direct button assignment in XVBox config, look at the "if (BtnA_pressed)" and similar functions for BtnB and BtnC. Here, still using the XVBOX define, this code applies, for 222 and 903 for example. BtnC was 1296.
if (BtnA_pressed) {
BtnA_pressed = false;
#ifdef XVBOX
// select band 222
if (band != BAND_1_25M)
band_Selector(3, false);
else
band_Selector(0, false);
#else
There are 3 buttons and here is where you assign any band you like. Still using XVBOX , here are BtnA and Btn B changed. BtnC is left as 1296.
if (BtnA_pressed) {
BtnA_pressed = false;
#ifdef XVBOX
// select band 3cm
if (band != BAND_3cm)
band_Selector(3, false);
else
band_Selector(0, false);
#else
…
if (BtnB_pressed) {
BtnB_pressed = false;
#ifdef XVBOX
// select band 24G
if (band != BAND_24G)
band_Selector(5, false);
else
band_Selector(0, false);
#else
…
band_Selector() passes the input pattern as if it was detected by wired input. 10GHz(3cm) is passing the value of 3 (0011) and 24GHz is passing 5 (0101). The 2nd argument says if it was an external input or local with True for PC CAT command source. False is for local button or wired inputs.
The function:
void band_Selector(uint8_t _band_input_pattern, bool ext_input)
searches for a pattern match against bands[_input_band].InputMap value for each band …
for (_input_band = 0; _input_band < NUM_OF_BANDS; _input_band++) {
//DPRINTF("Input search index = "); DPRINTLN(_input_band);
//DPRINTF(" Band Map Value = "); DPRINT(bands[_input_band].InputMap);
//DPRINTF(" Input Band Value = "); DPRINTLN(_band_input_pattern);
if (bands[_input_band].InputMap == _band_input_pattern) {
…
InputMap is the last value in each row of the 'bands[]' table. Here are predefined rows for 10 and 24GHz bands:
{ "3cm", 10000000000, 10500000000, 0, 10368100000, 1, 1, 0, 1, 0, 0, 0, 25, DECODE_INPUT_BAND10G }, // 10GHz
{ "24G", 24000000000, 24002000000, 0, 24031000000, 1, 1, 0, 1, 0, 0, 0, 25, DECODE_INPUT_BAND24G }, // 24GHz
These values are defined in Decoder.h - here are some example band defines
#define DECODE_INPUT_BAND6M (0x01) //6M
#define DECODE_INPUT_BAND144 (0x02) //2M
#define DECODE_INPUT_BAND222 (0x03) //222
#define DECODE_INPUT_BAND432 (0x04) //432
#define DECODE_INPUT_BAND902 (0x05) //902
#define DECODE_INPUT_BAND1296 (0x06) //1296
And
#define DECODE_INPUT_BAND10G (0x01) //10.368.1G
#define DECODE_INPUT_BAND24G (0x01) //24.192G
Looking at this as if you have a wired BCD input pattern that indicates a band, the goal is to have a unique pattern for each band of interest. The first match found is used. I had '3' for 222 and '5' for 902 and they are unique in the list guaranteeing a unique match.
If an input == 1, the first match found is #define DECODE_INPUT_BANDAM (not shown above) and the outputs will be set for that band.
If you are not using wired band inputs to the M5 (such as an external manual band select switch for example), just using the buttons or PC input methods, then the actual value has no matter as long as they are unique for the bands you want. You can change the decode input pattern to get 3 and 5 to match to the right bands, 10 and 24G… Taking the above and modifying it
#define DECODE_INPUT_BAND6M (0x01) //6M
#define DECODE_INPUT_BAND144 (0x02) //2M
#define DECODE_INPUT_BAND222 (0x01) //222 changed from 3 to 1
#define DECODE_INPUT_BAND432 (0x04) //432
#define DECODE_INPUT_BAND902 (0x01) //902 changed from 5 to 1
#define DECODE_INPUT_BAND1296 (0x06) //1296
And
#define DECODE_INPUT_BAND10G (0x03) //10.368.1G changed from 1 to 3
#define DECODE_INPUT_BAND24G (0x05) //24.192G changed from 1 to 5
Or you could leave all as it was and just change 10 and 24G
#define DECODE_INPUT_BAND10G (0x07) //10.368.1G 7 is unique
#define DECODE_INPUT_BAND24G (0x08) //24.192G 8 is unique
Then change the pattern passed in the BtnA and BtnB
band_Selector(3, false); to band_Selector(7, false);
band_Selector(5, false); to band_Selector(8, false);
If just using the buttons then 7 and 8 are unique values in the list and will result in 10G or 24G bands becoming active when matched. This may seem a bit round-about. The decoder was designed as a wired input with buttons only cycling through the large number of bands that could be active. Later when I only needed 3 xvtr bands, it was easiest to just emulate the wired input to leverage the band input matching logic. One could simply reference the row in the band table directly but that would mean new code to translate that and I was lazy 😊.
The next step is to re-label the M5Core button text for your new bands which is drawn in function 'draw_new_screen()'.
#elif defined (XVBOX)
M5.Lcd.drawString(" 222 903 1296 ", (int)(M5.Lcd.width() / 2), 220, 2);
You would change to
M5.Lcd.drawString(" 10G 24G 1296 ", (int)(M5.Lcd.width() / 2), 220, 2);
All the above is about getting the band selected. The last step is to specify what you want for outputs for each band. This is in Decoder .h and is simpler. Adjust the output pattern for each band. They can be the same or unique, what ever you need.
For band select outputs with BCD pattern on selected VHF+ bands I have these as default. By choice I have them matching the input pattern. I am using 4 outputs, 3 for BAND, 1 for PTT, so the BAND output pattern values must be limited to 0-7 (lowest 3 bit positions).
#define DECODE_BAND6M (0x0001) //6M
#define DECODE_BAND144 (0x0002) //2M
#define DECODE_BAND432 (0x0004) //432
#define DECODE_BAND902 (0x0005) //902
#define DECODE_BAND1296 (0x0006) //1296
#define DECODE_BAND2400 (0x0000) //2400 0 value results in no output pin activated
#define DECODE_BAND3300 (0x0000) //3400
#define DECODE_BAND5760 (0x0000) //5760M
#define DECODE_BAND10G (0x0000) //10.368.1G
#define DECODE_BAND24G (0x0000) //24.192G
For 10G and 24Gbands you might make them the same as 222 and 902 were, but they can be anything you need.
#define DECODE_BAND10G (0x0003) //10.368.1G
#define DECODE_BAND24G (0x0005) //24.192G
For PTT the value 8 is used for a single PTT output active for any band. '8' is the 4th bit position. The 3 lower bit positions are band outputs so set to 0. 8 is b'1000'.
#define DECODE_BAND10G_PTT (0x0008) //10.368.1G_PTT
#define DECODE_BAND24G_PTT (0x0008) //24.192G_PTT