Skip to content

Commit

Permalink
Pi4D
Browse files Browse the repository at this point in the history
  • Loading branch information
lu7did committed May 23, 2020
1 parent c32b730 commit 4498c28
Show file tree
Hide file tree
Showing 10 changed files with 238 additions and 146 deletions.
Binary file modified bin/OT4D
Binary file not shown.
Binary file modified bin/demo_genSSB
Binary file not shown.
Binary file modified bin/genSSB
Binary file not shown.
2 changes: 1 addition & 1 deletion python/gpioset.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

port=int(sys.argv[1]);
st=int(sys.argv[2]);
print("gpioset: GPIO pin(%d) state(%d) " % (port,st));
#print("gpioset: GPIO pin(%d) state(%d) " % (port,st));

#* Establish numbering convention, BCM in this case
GPIO.setmode(GPIO.BCM)
Expand Down
24 changes: 12 additions & 12 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ OSC_CFLAGS=-DOSCILLATOR_Z -DOSCILLATOR_D

LSDR = /usr/local/lib/librtlsdr.a

../bin/OT4D : OT4D/OT4D.cpp $(LIBRPITX)/src/librpitx.a OT4D/OT4D.h $(PP)/minIni/minIni.c lib/CAT817.h lib/gpioWrapper.h lib/rtlfm.h lib/genSSB.h $(PP)/minIni/minIni.c
../bin/OT4D : OT4D/OT4D.cpp $(LIBRPITX)/src/librpitx.a OT4D/OT4D.h $(PP)/minIni/minIni.c lib/CAT817.h lib/rtlfm.h lib/genSSB.h $(PP)/minIni/minIni.c
$(CCP) $(OSC_CFLAGS) $(CXYFLAGS) -o ../bin/OT4D OT4D/OT4D.cpp $(PP)/minIni/minIni.c $(LDFLAGS)

../bin/rtl_fm : rtl-sdr/rtl_fm.c rtl-sdr/convenience.c
Expand All @@ -46,11 +46,11 @@ LSDR = /usr/local/lib/librtlsdr.a
$(CCP) $(OSC_CFLAGS) $(CXYFLAGS) -o ../bin/genSSB lib/genSSB.cpp $(LDFLAGS)


../bin/demo_gpio : lib/demo_gpio.c
$(GCC) -o ../bin/demo_gpio ./lib/demo_gpio.c $(CFLAGS)

../bin/gpioWrapper : lib/gpioWrapper.cpp
$(CCP) $(OSC_CFLAGS) $(CXYFLAGS) -g -o ../bin/gpioWrapper ./lib/gpioWrapper.cpp $(LDFLAGS)
#../bin/demo_gpio : lib/demo_gpio.c
# $(GCC) -o ../bin/demo_gpio ./lib/demo_gpio.c $(CFLAGS)
#
#../bin/gpioWrapper : lib/gpioWrapper.cpp
# $(CCP) $(OSC_CFLAGS) $(CXYFLAGS) -g -o ../bin/gpioWrapper ./lib/gpioWrapper.cpp $(LDFLAGS)

../bin/demo_genDDS : lib/demo_genDDS.cpp lib/genDDS.h
$(CCP) -o ../bin/demo_genDDS ./lib/demo_genDDS.cpp ./lib/genDDS.h $(LDFLAGS)
Expand All @@ -64,8 +64,8 @@ LSDR = /usr/local/lib/librtlsdr.a
../bin/decodeFT8 : lib/decodeFT8.cpp lib/libFT8.h
$(CCP) $(OSC_CFLAGS) $(CXYFLAGS) -o ../bin/decodeFT8 ./lib/decodeFT8.cpp $(FT8LIB)/ft8/unpack.cpp $(FT8LIB)/ft8/ldpc.cpp $(FT8LIB)/ft8/decode.cpp $(FT8LIB)/ft8/constants.cpp $(FT8LIB)/ft8/encode.cpp $(FT8LIB)/common/wave.cpp $(FT8LIB)/fft/kiss_fftr.c $(FT8LIB)/fft/kiss_fft.c $(FT8LIB)/ft8/text.cpp $(LDFLAGS)

../bin/demo_craddle : lib/demo_craddle.cpp
$(CCP) $(OSC_CFLAGS) $(CXYFLAGS) -o ../bin/demo_craddle ./lib/demo_craddle.cpp $(LDFLAGS)
#../bin/demo_craddle : lib/demo_craddle.cpp
# $(CCP) $(OSC_CFLAGS) $(CXYFLAGS) -o ../bin/demo_craddle ./lib/demo_craddle.cpp $(LDFLAGS)

../bin/pift8 : rpitx/pift8/pift8.cpp
$(CCP) $(OSC_CFLAGS) $(CXYFLAGS) -o ../bin/pift8 ./rpitx/pift8/pift8.cpp $(FT8LIB)/ft8/pack.cpp $(FT8LIB)/ft8/unpack.cpp $(FT8LIB)/ft8/ldpc.cpp $(FT8LIB)/ft8/decode.cpp $(FT8LIB)/ft8/constants.cpp $(FT8LIB)/ft8/encode.cpp $(FT8LIB)/common/wave.cpp $(FT8LIB)/fft/kiss_fftr.c $(FT8LIB)/fft/kiss_fft.c $(FT8LIB)/ft8/text.cpp $(LDFLAGS)
Expand All @@ -77,13 +77,13 @@ LSDR = /usr/local/lib/librtlsdr.a

clean:
rm -r ../bin/OT4D
rm -r ../bin/gpioWrapper
# rm -r ../bin/gpioWrapper
rm -r ../bin/rtl_fm
rm -r ../bin/genSSB
rm -r ../bin/demo_rtlfm
rm -r ../bin/decimator
rm -r ../bin/demo_rtlfm
rm -r ../bin/demo_gpio
# rm -r ../bin/demo_gpio
rm -r ../bin/demo_decodeFT8
rm -r ../bin/demo_genSSB
rm -r ../bin/decodeFT8
Expand All @@ -92,12 +92,12 @@ clean:

install: all
install -m 0755 ../bin/OT4D /usr/bin
install -m 0755 ../bin/gpioWrapper /usr/bin
# install -m 0755 ../bin/gpioWrapper /usr/bin
install -m 0755 ../bin/rtl_fm /usr/bin
install -m 0755 ../bin/genSSB /usr/bin
install -m 0755 ../bin/demo_rtlfm /usr/bin
install -m 0755 ../bin/demo_decodeFT8 /usr/bin
install -m 0755 ../bin/demo_gpio /usr/bin
# install -m 0755 ../bin/demo_gpio /usr/bin
install -m 0755 ../bin/decimator /usr/bin
install -m 0755 ../bin/pift8 /usr/bin
install -m 0755 ../bin/decodeFT8 /usr/bin
Expand Down
133 changes: 72 additions & 61 deletions src/OT4D/OT4D.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* OT4D
* OT4D /PixiePi
* Conditional construction of methods based on either OT4D or Pi4D directive
*-----------------------------------------------------------------------------
* simple USB transceiver for the OrangeThunder project
* Copyright (C) 2020 by Pedro Colla <lu7did@gmail.com>
Expand Down Expand Up @@ -54,7 +55,7 @@

#include "/home/pi/PixiePi/src/minIni/minIni.h"
#include "../OT/OT.h"
#include "../lib/gpioWrapper.h"
//#include "../lib/gpioWrapper.h"
#include "../lib/genSSB.h"
#include "../lib/CAT817.h"
#include "../lib/genVFO.h"
Expand All @@ -68,7 +69,7 @@
// --- OT4D specific includes
#include "../lib/rtlfm.h"


// --- Program initialization
const char *PROGRAMID="OT4D";
const char *PROG_VERSION="1.0";
const char *PROG_BUILD="00";
Expand Down Expand Up @@ -122,14 +123,6 @@ char iniSection[50];
byte TRACE=0x00;
byte MSW=0x00;

// *----------------------------------------------------------------*
// * GPIO support processing *
// *----------------------------------------------------------------*
// --- gpio object
gpioWrapper* g=nullptr;
char *gpio_buffer;
void gpiochangePin();

// *----------------------------------------------------------------*
// * ssb processing *
// *----------------------------------------------------------------*
Expand Down Expand Up @@ -207,6 +200,27 @@ static void sighandler(int signum)
}
setWord(&MSW,RETRY,true);

}
//---------------------------------------------------------------------------------------------------
// writePin CLASS Implementation
//--------------------------------------------------------------------------------------------------
void writePin(int pin, int v) {

if (pin <= 0 || pin >= MAXGPIO) {
return;
}

if (v != 0 && v!= 1) {
return;
}

if (getWord(MSW,RUN)==false) {
return;
}

(v==1 ? gpioWrite(GPIO_PTT,1) : gpioWrite(GPIO_PTT,0));
(TRACE>=0x02 ? fprintf(stderr,"%s:writePin write pin(%d) value(%d)\n",PROGRAMID,pin,v) : _NOP);

}
// *---------------------------------------------------------------------------------------------------------------------
// setPTT(boolean)
Expand All @@ -217,12 +231,13 @@ void setPTT(bool ptt) {
(TRACE>=0x02 ? fprintf(stderr,"%s:setPTT(%s)\n",PROGRAMID,BOOL2CHAR(ptt)) : _NOP);
if (ptt==true) { //currently receiving now transmitting

#ifdef Pi4D
// *---------------------------------------------*
// * Set PTT into transmit mode *
// *---------------------------------------------*
writePin(GPIO_PTT,1);
(TRACE>=0x02 ? fprintf(stderr,"%s:setPTT(%s) operating relay to TX position\n",PROGRAMID,BOOL2CHAR(ptt)) : _NOP);
if(g!=nullptr) {g->writePin(GPIO_PTT,1);}
usleep(10000);
#endif

// *---------------------------------------------*
// * Set transceiver into TX mode *
Expand All @@ -240,9 +255,13 @@ void setPTT(bool ptt) {
usb->setPTT(ptt);
usleep(10000);

(TRACE>=0x02 ? fprintf(stderr,"%s:setPTT() set GPIO as(%s)\n",PROGRAMID,(getWord(MSW,PTT)==true ? "True" : "False")) : _NOP);
if(g!=nullptr) {g->writePin(GPIO_PTT,0);}
usleep(10000);
#ifdef Pi4D
// *---------------------------------------------*
// * Set PTT into transmit mode *
// *---------------------------------------------*
writePin(GPIO_PTT,0);
(TRACE>=0x02 ? fprintf(stderr,"%s:setPTT(%s) operating relay to TX position\n",PROGRAMID,BOOL2CHAR(ptt)) : _NOP);
#endif

setWord(&MSW,PTT,ptt);
(TRACE>=0x02 ? fprintf(stderr,"%s:setPTT() set PTT as(%s)\n",PROGRAMID,(getWord(MSW,PTT)==true ? "True" : "False")) : _NOP);
Expand Down Expand Up @@ -437,25 +456,19 @@ int main(int argc, char** argv)

// --- memory areas

TRACE=0x02;

(TRACE>=0x01 ? fprintf(stderr,"%s:main() initialize memory areas\n",PROGRAMID) : _NOP);
gpio_buffer=(char*)malloc(GENSIZE*sizeof(unsigned char));
usb_buffer=(char*)malloc(GENSIZE*sizeof(unsigned char));


#ifdef OT4D
strcpy(HW,"hw:Loopback,1,0");
rtl_buffer=(char*)malloc(RTLSIZE*sizeof(unsigned char));
#endif

#ifdef Pi4D
strcpy(HW,"hw:1");
#endif

#ifdef OT4D
rtl_buffer=(char*)malloc(RTLSIZE*sizeof(unsigned char));
#endif

//---------------------------------------------------------------------------------
// arg_parse (parameters override previous configuration)
//---------------------------------------------------------------------------------
Expand Down Expand Up @@ -525,50 +538,35 @@ strcpy(HW,"hw:1");
lcd->backlight(true);
lcd->setCursor(0,0);

fprintf(stderr,"%s %s:main() LCD display turned on\n",getTime(),PROGRAMID);
(TRACE>=0x02 ? fprintf(stderr,"%s %s:main() LCD display turned on\n",getTime(),PROGRAMID) : _NOP);

sprintf(LCD_Buffer,"%s %s(%s)",PROGRAMID,PROG_VERSION,PROG_BUILD);
lcd->println(0,0,LCD_Buffer);

sprintf(LCD_Buffer,"f=%5.1f KHz",f/1000);
sprintf(LCD_Buffer," %5.1f KHz",f/1000);
lcd->println(0,1,LCD_Buffer);

#endif


// --- gpio Wrapper creation
#ifdef OT4D
// --- OT4D manages the PTT and cooler locally whilst

(TRACE>=0x01 ? fprintf(stderr,"%s:main() initialize gpio Wrapper\n",PROGRAMID) : _NOP);
g=new gpioWrapper(NULL);
g->TRACE=TRACE;
if (g->start() == -1) {
(TRACE>=0x00 ? fprintf(stderr,"%s:main() failure to start gpioWrapper object\n",PROGRAMID) : _NOP);
exit(8);
if(gpioInitialise()<0) {
(TRACE>=0x00 ? fprintf(stderr,"%s:setupGPIO() Cannot initialize GPIO\n",PROGRAMID) : _NOP);
exit(16);
}

(TRACE>=0x02 ? fprintf(stderr,"%s:setupGPIO() Setup Cooler\n",PROGRAMID) : _NOP);
gpioSetMode(GPIO_PTT, PI_OUTPUT);
gpioWrite(GPIO_PTT, 0);

#ifdef Pi4D
// *---------------------------------------------*
// * Set cooler ON mode *
// *---------------------------------------------*
(TRACE>=0x01 ? fprintf(stderr,"%s:main() operating relay to cooler activation\n",PROGRAMID) : _NOP);
if(g!=nullptr) {g->writePin(GPIO_COOLER,1);}
usleep(10000);
#endif


#ifdef OT4D
// --- define rtl-sdr handling object
(TRACE>=0x01 ? fprintf(stderr,"%s:main() initialize RTL-SDR controller interface\n",PROGRAMID) : _NOP);
rtl=new rtlfm();
rtl->TRACE=TRACE;
rtl->setMode(MUSB);
rtl->setVol(vol);
rtl->setFrequency(f);
rtl->changeSNR=changeSNR;
rtl->start();
gpioSetMode(GPIO_COOLER, PI_OUTPUT);
gpioWrite(GPIO_COOLER, 1);

#endif


// --- USB generator

(TRACE>=0x01 ? fprintf(stderr,"%s:main() initialize SSB generator interface\n",PROGRAMID) : _NOP);
Expand All @@ -579,15 +577,29 @@ strcpy(HW,"hw:1");
usb->setSoundSR(AFRATE);
usb->setSoundHW(HW);
usb->vox=vox;

#ifdef OT4D
usb->dds=false;
#endif

#ifdef Pi4D
usb->dds=true;
usb->vox=true;
#endif

usb->start();

#ifdef OT4D

// --- define rtl-sdr handling object
(TRACE>=0x01 ? fprintf(stderr,"%s:main() initialize RTL-SDR controller interface\n",PROGRAMID) : _NOP);
rtl=new rtlfm();
rtl->TRACE=TRACE;
rtl->setMode(MUSB);
rtl->setVol(vol);
rtl->setFrequency(f);
rtl->changeSNR=changeSNR;
rtl->start();

// --- creation of CAT object

Expand All @@ -605,6 +617,8 @@ strcpy(HW,"hw:1");
setWord(&cat->FT817,AGC,false);
setWord(&cat->FT817,PTT,getWord(MSW,PTT));

#endif

vfo=new genVFO(NULL,NULL,NULL,NULL);
vfo->TRACE=TRACE;
vfo->FT817=FT817;
Expand All @@ -618,8 +632,10 @@ strcpy(HW,"hw:1");
vfo->setRIT(VFOB,false);

vfo->vfo=VFOA;

#ifdef OT4D
setWord(&cat->FT817,VFO,VFOA);

#endif

// -- establish loop condition

Expand Down Expand Up @@ -647,7 +663,9 @@ strcpy(HW,"hw:1");
//*---------------------------------------------*
//* Process CAT commands *
//*---------------------------------------------*
#ifdef OT4D
cat->get();
#endif

#ifdef OT4D
if (getWord(rtl->MSW,RUN)==true) {
Expand Down Expand Up @@ -693,12 +711,6 @@ strcpy(HW,"hw:1");
// --- Normal termination kills the child first and wait for its termination

#ifdef Pi4D
// *---------------------------------------------*
// * Set cooler ON mode *
// *---------------------------------------------*
(TRACE>=0x01 ? fprintf(stderr,"%s:main() operating relay to cooler de-activation\n",PROGRAMID) : _NOP);
if(g!=nullptr) {g->writePin(GPIO_COOLER,0);}
usleep(10000);

//*--- Turn off LCD

Expand All @@ -713,12 +725,11 @@ strcpy(HW,"hw:1");

(TRACE>=0x01 ? fprintf(stderr,"%s:main() stopping operations\n",PROGRAMID) : _NOP);

g->stop();
cat->close();
usb->stop();

#ifdef OT4D

cat->close();
if (rtl!=nullptr) {
rtl->stop();
}
Expand Down
Loading

0 comments on commit 4498c28

Please sign in to comment.