Skip to content

Commit

Permalink
for release 0.12.14
Browse files Browse the repository at this point in the history
Modification to support the RF Tool at run time
  • Loading branch information
aa2mz authored Sep 7, 2020
1 parent 2a41139 commit 58dd4cd
Show file tree
Hide file tree
Showing 8 changed files with 215 additions and 81 deletions.
69 changes: 60 additions & 9 deletions software/core/CIV.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "tinyradio.h"

/* civ.h Copyright Ed Taychert 2019,2020
*
* Emulate an ICom 756, maybe com 7100 and 7610 or Xiegu 5105
*/
/* CI-V command/response format
* FE FE 98 E0 Cmd# Sub# Data-area FD
Expand Down Expand Up @@ -81,6 +81,7 @@ class IcomCI_V : public Taskable {
int dataLen ;
int us, them ;
int cno, sub, flavor;
int mainSubSelect ;
// pointer to a class member function
int (IcomCI_V :: *server)(unsigned char*);
CATRadio * radio;
Expand Down Expand Up @@ -167,7 +168,7 @@ class IcomCI_V : public Taskable {
int setup(int arg = 10) {
Taskable:: setup(arg);
if ( serial == 0 )
serial = (Stream*) &Serial ;
setSerial( (Stream*) &Serial) ;
}
int setRadio( CATRadio * r ) {
radio = r ;
Expand Down Expand Up @@ -224,7 +225,7 @@ class IcomCI_V : public Taskable {
case CIVSPLITCMD: // 0X0F , return the value set?
server = &splitCmd ;
break ;
case CIV14CMD : // 0x14 set/get different levels
case CIV14CMD : // 0x14 set/get various levels
server = &civ14Cmd ;
break ;
case CIVGETID : // 0x19
Expand Down Expand Up @@ -287,30 +288,61 @@ int IcomCI_V:: setMode (unsigned char*cmd){
}

int IcomCI_V:: getFreq (unsigned char*cmd){
long f = radio->getFrequency();
long f = radio->getFrequency(mainSubSelect);
f2CIV(f);
}

int IcomCI_V:: setFreq (unsigned char*cmd){
long f = CIV2f((unsigned char*)(cmd+1));
radio->setFrequency(f);
radio->setFrequency(f, mainSubSelect);
okayCmd();
}

int IcomCI_V:: vfoCmd (unsigned char*cmd){
/* 0x07 - map extended main and sub commands into vfoA and vfoB commands
Select the VFO mode
00 Select VFO A
01 select VFO B
A0 equalize B=A
B0 Exchange main and sub bands
B1 Equalize main and sub bands
D0 Select the main band (is vfo a)
D1 Select the sub band (is vfo b)
D2* 00 Send/read main band selection
01 Send/read sub band selection
*/
int c = cmd[0];
int s = cmd[1];

switch (cmd[1]) {
case 0x00 : // select A, no-op
break ;
case 0xd0 :
mainSubSelect = 0 ;
radio->splitCmd (mainSubSelect);
break ;
case 0xd1 :
case 0x01 : // select B
mainSubSelect = 1 ;
radio->splitCmd (mainSubSelect);
break;
case 0xb0 : // swap AB
radio->vfoSwap();
break;
case 0xa0 : // B = A
case 0xb1 : // B = A
radio->vfoBeqA();
break;
case 0xd2 : // read vfo
if (cmd[3] == 0xfd ) { // what the freq?
if (cmd[2] == 0 )
f2CIV(radio->getFrequency(0));
else
f2CIV(radio->getFrequency(1));
} else { // set the freq QQQQ
long f = CIV2f((unsigned char*)(cmd+3));
radio->setFrequency(f, cmd[2]);
}
return ;
default:
nakCmd(0);
return ;
Expand All @@ -325,9 +357,28 @@ int IcomCI_V:: splitCmd (unsigned char*cmd){
}

int IcomCI_V:: civ14Cmd( unsigned char*cmd) {
// qqqqq should be able to do
// 0x09 CW pitch
// 0x0c Key speed
// qqqqq might be able to do come of these
switch (cmd[1]) {
case 0x07 : // if shift 128 = 0 ;
int shift = cmd[2]-128;
radio->setIFShift(shift*10);
break ;
case 0x09 : // CW tone 0 - 255
int deltaTone = (128-cmd[2]) * 4 ; // plus or minus 512
setDictionary(D_CWSIDETONE, 800 + deltaTone) ;
#ifdef TINYKEYER
keyer.setSideTone(P_SIDETONE,getDictionary(D_CWSIDETONE)); // tone pin out, hertz
#endif
break ;
case 0x0a : // RF power 0 - 255 (not FD!!!)
case 0x0f : // break-in 0=2, 255 = 13 (?ms?)
case 0x18 : // LCD contrast, hA HA Ha
case 0x19 : // LCD brightness
case 0x1a : // notch filter 0-255
break;
default:
okayCmd();
}
okayCmd();
}
int IcomCI_V:: getID (unsigned char*cmd) {
Expand Down
26 changes: 15 additions & 11 deletions software/core/Persistence.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <EEPROM.h>

// change the version if you change the meaning of EPROM data
#define D_VERSION 0x10d
#define D_VERSION 0x12c
#define D_loaderversion 1
#define D_loading 0
/*
Expand Down Expand Up @@ -305,7 +305,7 @@ void dictionaryDefault(void)
#ifndef DICTIONARYCACHING
eePut((uint32_t *)(D_VFOAFREQUENCY*4+DICT_OFFSET), 7040000L);
#endif
setDictionary(D_VFOAMODE, 3L);
setDictionary(D_VFOAMODE, 0L);
setDictionary(D_VFOBFREQUENCY, 14300000L);
setDictionary(D_VFOBMODE, 1L);

Expand Down Expand Up @@ -333,16 +333,20 @@ void dictionaryDefault(void)
setDictionary(D_CWAKEYDOT, 450) ;
setDictionary(D_CWAKEYDASH, 800) ;

setDictionary(D_FILTER0LOW, 0L); // AM
setDictionary(D_FILTER0LOW, 0L); // change for AM, setting used for DC and RFT00L
setDictionary(D_FILTER0HIGH, 0L+0L);
setDictionary(D_FILTER1LOW, 0L); // sideband
setDictionary(D_FILTER1HIGH, 0L+0L);
setDictionary(D_FILTER2LOW, 0L); // CW
setDictionary(D_FILTER2HIGH, 0L+0L);
setDictionary(D_FILTER3LOW, 0L); // Digital
setDictionary(D_FILTER3HIGH, 0L+0L);

setDictionary(D_FILTER0IFSHIFT, 300L);
setDictionary(D_FILTER1LOW, 8000000L); // sideband
setDictionary(D_FILTER1HIGH, 8000000L+1800L);
setDictionary(D_FILTER2LOW, 8000000L); // CW
setDictionary(D_FILTER2HIGH, 8000000L+400L);
setDictionary(D_FILTER3LOW, 8000000L); // Digital
setDictionary(D_FILTER3HIGH, 8000000L+4000L);

// true AM puts the carrier in the middle of a wide filter
setDictionary(D_FILTER0IFSHIFT, 0L);
// side band filters put the (suppressed) carrier frequency below the edge of the filer.
// This allows a narrower filter on receive
// and better suppresses the unwanted sideband on transmit.
setDictionary(D_FILTER1IFSHIFT, 300L);
setDictionary(D_FILTER2IFSHIFT, 500L);
setDictionary(D_FILTER3IFSHIFT, 300L);
Expand Down
3 changes: 0 additions & 3 deletions software/core/RadioClocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,6 @@ class Si5351Clocks : public RadioClocks {
}

int setFrequency( uint32_t fout, int clkNo= 0) { // Set a CLK to fout Hz
//Serial.print(clkNo);
//Serial.print(" ");
//Serial.println(fout);
uint8_t clknum = clkNo;
uint32_t msa, msb, msc, msxp1, msxp2, msxp3p2top;
if ((fout<500000) || (fout>109000000)) // If clock freq out of range
Expand Down
38 changes: 30 additions & 8 deletions software/core/TextCAT.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class TextCAT : public Taskable {
int setBand(void) ;
int getFreq(void) ;
int setFreq(void) ;
int getPTT(void) {} ;
int setPTT(void) {} ;
int getPTT(void) {radio->getPtt();} ;
int setPTT(void) {static int p; radio->pttCmd(p=1-p);} ;
int sendCW(void) {
#ifdef TEXT2CW
keyer.send(cmd+1) ; // not safe, cmd will be over written with next command
Expand All @@ -69,7 +69,7 @@ class TextCAT : public Taskable {
int setup(int arg = 0) {
Taskable:: setup(4);
if ( serial == 0 )
serial = (Stream*) &Serial ;
setSerial( (Stream*) &Serial) ;
serial->println("# Hello");
serial->flush();
}
Expand Down Expand Up @@ -163,6 +163,11 @@ int TextCAT:: getMode(void) { // M
serial->println((char*)cmd);
}
int TextCAT:: setMode(void) { // m
cmd[0] -= 32 ;
if (cmd[1] == 0) {
getMode();
return;
}
int i,m ;
for (i = 0 ; i < strlen(Mode_Chars) ; i++ )
if (cmd[1] == Mode_Chars[i] )
Expand All @@ -175,7 +180,6 @@ int TextCAT:: setMode(void) { // m
radio->setMode(i);
else
radio->setFilter(i-8);
cmd[0] -= 32 ;
cmd[2] = 0;
serial->println((char*)cmd);
}
Expand Down Expand Up @@ -208,12 +212,17 @@ int TextCAT:: getFreq(void) { //F
}
int TextCAT:: setFreq(void) { //f
cmd[0] -= 32 ;
if (cmd[1] == 0) {
getFreq();
return;
}
radio->setFrequency(atol(cmd+1));
serial->println((char*)cmd);
}

// extra commands not in CATRadio, use a cast
int TextCAT:: setBaud(void) {
cmd[0] -= 32 ;
long b ;
b = (cmd[1]-'0') * 10L + cmd[2]-'0' ;
if (b == 12) b=1200;
Expand All @@ -225,10 +234,10 @@ int TextCAT:: setBaud(void) {
else if (b == 57) b=57600;
else if (b == 11) b=115200;
else {
serial->println("! Bad Baud");
// serial->println("! Bad Baud");
getBaud();
return;
}
cmd[0] -= 32 ;
serial->println((char*)cmd);
serial->flush() ; // make sure reply is visable

Expand All @@ -240,6 +249,11 @@ int TextCAT:: getBaud (void){
serial->println((char*)cmd);
}
int TextCAT:: setEProm (void) {

if ( *(cmd+1) == 0 ) {
getEProm();
return ;
}
int addr=atoi(cmd+1);
long value;
char *s = cmd+1 ;
Expand All @@ -248,7 +262,7 @@ int TextCAT:: setEProm (void) {
while ( *s && !isdigit(*s) && *s != '-' ) s++ ; // find start of value

if (*s == 0 ) {
question ();
getEProm ();
return;
}
value = atol(s);
Expand Down Expand Up @@ -276,7 +290,10 @@ int TextCAT:: getEProm(void) {
serial->print(addr); serial->print("[ ");
serial->print (dictName(addr));
serial->print (" = ]") ;
serial->println( getDictionary(addr)) ;
if ( addr == D_COPYRIGHT )
serial->println( getDictionary(addr),HEX) ;
else
serial->println( getDictionary(addr)) ;
}
}
int TextCAT:: question (void) {
Expand All @@ -287,6 +304,11 @@ int TextCAT:: question (void) {
}
if (*cmd == 'Y' || *cmd == 'y') {
setDictionary(qAddress, qValue);
if (qAddress == D_PROTOCOL ) { // force a restart to change protocols
// qqq might not be needed if we had a complete method for their initialization.
delay(100);
SoftwareReset();
}
}
serial->print("# ") ;
serial->print(qAddress); serial->print(" = ") ; serial->println(getDictionary(qAddress)) ;
Expand Down
Loading

0 comments on commit 58dd4cd

Please sign in to comment.