From: pa3gsb Date: Sat, 18 Nov 2017 11:26:28 +0000 (+0100) Subject: cw mode X-Git-Url: https://git.rkrishnan.org/pf/$top_link?a=commitdiff_plain;h=d09ded8dc67ef9134fecfea92bc3518d28569449;p=pihpsdr.git cw mode --- diff --git a/radioberry.c b/radioberry.c index b4cf2f7..2462207 100644 --- a/radioberry.c +++ b/radioberry.c @@ -98,6 +98,24 @@ static int rx1_spi_handler; static int rx2_spi_handler; +#define HANDLER_STEADY_TIME_US 5000 +void setup_handler(int pin, gpioAlertFunc_t pAlert) { + gpioSetMode(pin, PI_INPUT); + gpioSetPullUpDown(pin,PI_PUD_UP); + // give time to settle to avoid false triggers + usleep(10000); + gpioSetAlertFunc(pin, pAlert); + gpioGlitchFilter(pin, HANDLER_STEADY_TIME_US); +} + +void cwPTT_Alert(int gpio, int level, uint32_t tick) { + fprintf(stderr,"init pttAlert\n"); + fprintf(stderr,"%d - %d -%d - %d\n", running, cw_breakin, transmitter->mode, level); + if (running && cw_breakin && (transmitter->mode==modeCWU || transmitter->mode==modeCWL)){ + g_idle_add(mox_update,(gpointer)level); + } +} + float timedifference_msec(struct timeval t0, struct timeval t1) { return (t1.tv_sec - t0.tv_sec) * 1000.0f + (t1.tv_usec - t0.tv_usec) / 1000.0f; @@ -122,6 +140,9 @@ void radioberry_protocol_init(int rx,int pixels) { gpioSetMode(16, PI_INPUT); //rx2_FIFOEmpty gpioSetMode(20, PI_INPUT); gpioSetMode(21, PI_OUTPUT); + + setup_handler(17, cwPTT_Alert); + rx1_spi_handler = spiOpen(0, 15625000, 49155); //channel 0 if (rx1_spi_handler < 0) { @@ -392,8 +413,8 @@ void spiWriter() { } else { txFrequency=vfo[VFO_A].frequency-vfo[VFO_B].lo+vfo[VFO_A].offset; } - tx_iqdata[0] = 0x00; - tx_iqdata[1] = 0x00; + tx_iqdata[0] = cw_keyer_speed | (cw_keyer_mode<<6); + tx_iqdata[1] = cw_keyer_weight | (cw_keyer_spacing<<7); tx_iqdata[2] = ((txFrequency >> 24) & 0xFF); tx_iqdata[3] = ((txFrequency >> 16) & 0xFF); tx_iqdata[4] = ((txFrequency >> 8) & 0xFF); diff --git a/transmitter.c b/transmitter.c index ea37b2e..b624241 100644 --- a/transmitter.c +++ b/transmitter.c @@ -650,8 +650,9 @@ void add_mic_sample(TRANSMITTER *tx,short mic_sample) { if (isTransmitting()) { if (key == 1) { mic_sample_double = getNextSideToneSample(); - cw_audio_write(mic_sample_double * cw_keyer_sidetone_volume/ 127.0); - mic_sample_double = mic_sample_double * 200000; //* amplitude + cw_audio_write(mic_sample_double * ((cw_keyer_sidetone_volume-1)/127.0)); + mic_sample_double = mic_sample_double * 0.001; //the mic sample is added to make keying visible in tx screen. + //keying done at J2 of RPI IO-16 and IO-15; keys via gpio pin BCM18 and BCM19 will give the sidetone. } else mic_sample_double=0.0; } } else {