After much experimenting and trial and error, I got almost all of the radio functions tested and working. I did run into an interesting problem, though. If I included ALL of the Icom CI-V enabled radios, and included 2 “spare” integers with the lookup structure, the Arduino would fail out after 180 items in the list.
In order to fix this issue, I disabled all the “Receiver only” radios (IC-Rxx radios), and eliminated the spare integers – now it reads int he radio properly!
Another victory was getting Icom BCD encoding of values working. I’m sure there’s a valid reason for why they did this, but it’s a real hassle when it comes to rolling your own software! By including the following in the code:
#define DEC2BCD(dec) (((dec / 10) << 4) + (dec % 10)) //Decimal to BCD conversion routine
I can then simply enter a (1 or 2 digit) number, and get my BCD result! The following is the call to the above “macro” in action:
void set_RFPower(int level) // set RF Power{
int level2 = constrain(level, 0, 0255); // limit values to allowable limits
int x2 = ((level %100)); // tens and ones byte
int x1 = (level - x2)/100; //thousands and hundreds byte
byte x1b = DEC2BCD(x1);
byte x2b = DEC2BCD(x2);
send_preamble();
Serial.write(0x14); // RX Levels command
Serial.write(0x0A); // RF Power Subcommand
Serial.write(x1b);
Serial.write(x2b);
send_post();
}
I haven’t simplified the frequency portion of the code using this operation yet, but it is in the plans.
I’m working on the rotary encoder now – it’s coming along, but I have to work out the algorithm to allow the encoder to control frequency smoothly. Right now, I just have it counting and throwing the number on the LCD display. With this partially working, I have about 80% of the final hardware involved (still need a keypad and directional buttons for the menus, not to mention porting it to the Arduino Mega).