Skip to content

Commit

Permalink
CAT
Browse files Browse the repository at this point in the history
  • Loading branch information
lu7did committed May 13, 2020
1 parent 9cfd934 commit 717ee67
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 39 deletions.
Binary file modified bin/OT4D
Binary file not shown.
Binary file modified bin/demo_genSSB
Binary file not shown.
13 changes: 0 additions & 13 deletions src/OT/OT.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,3 @@ typedef void (*CALLBACK)();
#define KEY_UP 0x00

#define NSEC_PER_SEC (1000000000)
enum {
CHECK = 0,
PREDOT,
PREDASH,
SENDDOT,
SENDDASH,
DOTDELAY,
DASHDELAY,
DOTHELD,
DASHHELD,
LETTERSPACE,
EXITLOOP
};
10 changes: 5 additions & 5 deletions src/OT4D/OT4D.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,12 @@ void setPTT(bool ptt) {
void CATchangeFreq() {

if (usb->statePTT == true) {
(TRACE>=0x01 ? fprintf(stderr,"%s:CATchangeFreq() cat.SetFrequency(%d) request while transmitting, ignored!\n",PROGRAMID,(int)cat->SetFrequency) : _NOP);
cat->SetFrequency=f;
(TRACE>=0x01 ? fprintf(stderr,"%s:CATchangeFreq() cat.SetFrequency(%d) request while transmitting, ignored!\n",PROGRAMID,(int)cat->f) : _NOP);
cat->f=f;
return;
}

cat->SetFrequency=f;
cat->f=f;
(TRACE>=0x01 ? fprintf(stderr,"%s:CATchangeFreq() Frequency change is not allowed(%d)\n",PROGRAMID,(int)f) : _NOP);

}
Expand Down Expand Up @@ -573,7 +573,7 @@ strcpy(HW,"hw:1");
cat=new CAT817(CATchangeFreq,CATchangeStatus,CATchangeMode,CATgetRX,CATgetTX);
cat->FT817=FT817;
cat->POWER=DDS_MAXLEVEL;
cat->SetFrequency=f;
cat->f=f;
cat->MODE=MUSB;
cat->TRACE=TRACE;
cat->open(port,catbaud);
Expand All @@ -582,7 +582,7 @@ strcpy(HW,"hw:1");
setWord(&cat->FT817,AGC,false);
setWord(&cat->FT817,PTT,getWord(MSW,PTT));

vfo=new genVFO(NULL,NULL,NULL);
vfo=new genVFO(NULL,NULL,NULL,NULL);
vfo->TRACE=TRACE;
vfo->FT817=FT817;
vfo->MODE=cat->MODE;
Expand Down
18 changes: 9 additions & 9 deletions src/lib/CAT817.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class CAT817

byte bufChar[128];
int bufLen=0;
float SetFrequency;
float f;

int n=0;
byte rxBuffer[128];
Expand Down Expand Up @@ -300,8 +300,8 @@ void CAT817::processCAT(byte* rxBuffer) {

switch(rxBuffer[4]) {
case 0x01: { //* Set Frequency
int f=BCD2Dec(&rxBuffer[0]);
SetFrequency=f;
int freq=BCD2Dec(&rxBuffer[0]);
this->f=freq;
BCDBuf[4]=0x01;
hex2str(&buffer[0],&BCDBuf[0],1);
(TRACE>=0x01 ? fprintf(stderr,"%s::processCAT() Command 0x01 Resp(%s)\n",this->PROGRAMID,(char*) &buffer[0]) : _NOP);
Expand All @@ -314,8 +314,8 @@ void CAT817::processCAT(byte* rxBuffer) {
sendStatus();
return;}
case 0x03: { //* Get Frequency and Mode
int f=(int)SetFrequency;
dec2BCD(&BCDBuf[0],f);
int freq=(int)f;
dec2BCD(&BCDBuf[0],freq);
BCDBuf[4]=MODE;
hex2str(&buffer[0],&BCDBuf[0],5);
(TRACE>=0x02 ? fprintf(stderr,"%s::processCAT() Command 0x03 Resp(%s)\n",this->PROGRAMID,buffer) : _NOP);
Expand Down Expand Up @@ -474,12 +474,12 @@ void CAT817::processCAT(byte* rxBuffer) {
offsetBuf[0]=0x00;
offsetBuf[1]=0x00;
offsetBuf[4]=0xF5;
int f=BCD2Dec(&offsetBuf[0]);
f=f/10;
int ofs=BCD2Dec(&offsetBuf[0]);
ofs=ofs/10;
if (rxBuffer[0]==0x00) {
RITOFS=+f;
RITOFS=+ofs;
} else {
RITOFS=(-1)*f;
RITOFS=(-1)*ofs;
}
(TRACE>=0x02 ? fprintf(stderr,"%s::processCAT() Command 0xF5 Resp(%s)\n",this->PROGRAMID,buffer) : _NOP);
BCDBuf[0]=0x00;
Expand Down
6 changes: 3 additions & 3 deletions src/lib/demo_genSSB.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ void setPTT(bool ptt) {
void CATchangeFreq() {

if (g->statePTT == true) {
fprintf(stderr,"%s:CATchangeFreq() cat.SetFrequency(%d) request while transmitting, ignored!\n",PROGRAMID,(int)cat->SetFrequency);
cat->SetFrequency=f;
fprintf(stderr,"%s:CATchangeFreq() cat.SetFrequency(%d) request while transmitting, ignored!\n",PROGRAMID,(int)cat->f);
cat->f=f;
return;
}

Expand Down Expand Up @@ -309,7 +309,7 @@ int main(int argc, char** argv)

cat->FT817=FT817;
cat->POWER=7;
cat->SetFrequency=f;
cat->f=f;
cat->MODE=MUSB;
cat->TRACE=TRACE;

Expand Down
58 changes: 49 additions & 9 deletions src/lib/genVFO.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#define VFOB 1
#define VFOMAX 2

#define GODOWN 0
#define GOUP 1

#define VLF 0
#define LF 1
#define B160M 2
Expand Down Expand Up @@ -103,6 +106,7 @@ class genVFO
void setRIT(bool b);

void swapVFO();
void setVFO(byte v);

int getBand(float f);
void setBand(byte band);
Expand All @@ -119,6 +123,9 @@ class genVFO
float update(int dir);
float update(byte v,int dir);

bool getLock();
void setLock(bool f);

float updateRIT(byte v,int dir);
float updateRIT(int dir);

Expand All @@ -134,7 +141,8 @@ class genVFO
byte getMode();
byte getMode(byte m);
long int code2step(byte b);
byte step2code(long int s);
byte step2code(long int s);
byte vfodir=GODOWN;

FSTR vfostr[VFOMAX];

Expand Down Expand Up @@ -169,7 +177,6 @@ const char *COPYRIGHT="(c) LU7DID 2019,2020";
float fmin[VFOMAX];
float fmax[VFOMAX];
byte band[VFOMAX];

};

#endif
Expand All @@ -191,9 +198,9 @@ genVFO::genVFO(CALLBACK_FREQ df,CALLBACK_RIT dr, CALLBACK_MODE dm,CALLBACK_STAT
step[i]=VFO_STEP_100Hz;
rit[i]=0.0;
shift[i]=600.0;

}

this->vfodir=GODOWN;
this->setSplit(getWord(FT817,SPLIT));

setBand(VFOA,getBand(14000000));
Expand Down Expand Up @@ -263,12 +270,31 @@ void genVFO::setMode(byte v,byte m) {
this->MODE=m;
if (changeMode!=NULL) {changeMode(m);}
}
//*---------------------------------------------------------------------------------------------------
//* CLASS Implementation
//*---------------------------------------------------------------------------------------------------
void genVFO::setMode(byte m) {
return this->setMode(this->vfo,m);
}
//*---------------------------------------------------------------------------------------------------
//* CLASS Implementation
//*---------------------------------------------------------------------------------------------------
bool genVFO::getLock() {
return getWord(FT817,LOCK);
}
//*---------------------------------------------------------------------------------------------------
//* CLASS Implementation
//*---------------------------------------------------------------------------------------------------
void genVFO::setLock(bool f) {
setWord(&FT817,LOCK,f);
byte S=0x00;
setWord(&S,LOCK,true);
if (changeStatus!=NULL) {changeStatus(S);}
return;
}
//*---------------------------------------------------------------------------------------------------
//* CLASS Implementation
//*---------------------------------------------------------------------------------------------------
void genVFO::set(byte v,float freq) {


Expand Down Expand Up @@ -317,7 +343,7 @@ byte S=0x00;
setWord(&FT817,SPLIT,b);
this->vfo2str(this->vfo,buffer);
(this->TRACE>=0x02 ? fprintf(stderr,"%s::setSplit() VFO[%s] Split[%s]\n",PROGRAMID,buffer,BOOL2CHAR(getWord(FT817,SPLIT))) : _NOP);
setWord(&S,SPLIT,b);
setWord(&S,SPLIT,true);
if (changeStatus!=NULL) {changeStatus(S);}
return;
}
Expand All @@ -331,7 +357,7 @@ byte S=0x00;
}

setWord(&FT817,RITX,b);
setWord(&S,RITX,b);
setWord(&S,RITX,true);
this->vfo2str(v,buffer);

(this->TRACE>=0x02 ? fprintf(stderr,"%s::setRIT() VFO[%s] RIT[%s] RitOffset[%f]\n",PROGRAMID,buffer,BOOL2CHAR(getWord(FT817,RITX)),rit[v]) : _NOP);
Expand Down Expand Up @@ -366,7 +392,7 @@ byte S=0x00;
setWord(&FT817,PTT,false);
o=o+f[vfo];
(this->TRACE>=0x02 ? fprintf(stderr,"%s::setPTT() PTT[%s] frequency(%f)\n",PROGRAMID,BOOL2CHAR(getWord(FT817,PTT)),o) : _NOP);
setWord(&S,PTT,false);
setWord(&S,PTT,true);
if (changeStatus!=NULL) {changeStatus(S);}
return o;
}
Expand All @@ -384,7 +410,7 @@ byte S=0x00;
}
o=f[vfo]+s;
setWord(&FT817,PTT,b);
setWord(&S,PTT,b);
setWord(&S,PTT,true);

(this->TRACE>=0x02 ? fprintf(stderr,"%s::setPTT() PTT[%s] frequency(%f)\n",PROGRAMID,BOOL2CHAR(getWord(FT817,PTT)),o) : _NOP);
if (changeStatus!=NULL) {changeStatus(S);}
Expand All @@ -411,17 +437,30 @@ byte S=0x00;
//*------------------------------------------------------------------------------------------------------
//* Flip VFOA/VFOB
//*------------------------------------------------------------------------------------------------------
void genVFO::setVFO(byte v) {
byte S=0x00;

if (v!=VFOA && v!=VFOB) { return; }
this->vfo=v;
(v==VFOA ? setWord(&FT817,VFO,VFOA) : setWord(&FT817,VFO,VFOB));
setWord(&S,VFO,true);
if (changeStatus!=NULL) {changeStatus(S);}
return;
}
//*------------------------------------------------------------------------------------------------------
//* Flip VFOA/VFOB
//*------------------------------------------------------------------------------------------------------
void genVFO::swapVFO() {
byte S=0x00;

if (this->vfo==VFOA) {
this->vfo = VFOB;
setWord(&S,VFO,this->vfo);
setWord(&S,VFO,true);
if (changeStatus!=NULL) {changeStatus(S);}
return;
}
this->vfo=VFOA;
setWord(&S,VFO,this->vfo);
setWord(&S,VFO,true);
if (changeStatus!=NULL) {changeStatus(S);}
return;
}
Expand Down Expand Up @@ -500,6 +539,7 @@ float genVFO::update(byte v,int dir) {
f[v]=fmin[v];
}

(dir>=0 ? vfodir=GOUP : vfodir=GODOWN);
this->vfo2str(v,buffer);
(this->TRACE>=0x02 ? fprintf(stderr,"%s::update() VFO[%s] dir[%d] f[%f]->[%f]\n",PROGRAMID,buffer,dir,freq,f[v]) : _NOP);
if (changeVFO!=NULL) {changeVFO(f[v]);}
Expand Down

0 comments on commit 717ee67

Please sign in to comment.