g0orx / pihpsdr

Raspberry Pi standalone code for HPSDR (Protocol 1 and Protocol 2)
GNU General Public License v2.0
110 stars 73 forks source link

Compiler error when Enabling PTT in MakeFile #154

Open K7MDL2 opened 3 years ago

K7MDL2 commented 3 years ago

I wired up a speaker/mic and trying to get the PTT pin to function. The GPIO pin is responding fine.

In the Makefile I uncomment the PTT_INCLUDE=PTT definition. PTT is defined to my pin of choice in gpio.c (12 in my case). Start a build and getting 2 errors:

: error: expected identifier before numeric constant actions.h:106:3: note: in expansion of macro 'PTT' PTT, ^~~ In file included from discovery.c:53 actions.h:180:33: error: /ACTIONS' undeclared here (mot i a function); did you mean 'ACTION'? extern ACTION_TABLE ActionTable[ACTIONS+1]; ^~~~~~ ACTION make: *** [makefile:228: discovery.o] Error 1 I see ACTIONS defined in some tables in actions.h.
K7MDL2 commented 3 years ago

Have PTT from a gpio pin now working. I am using pin 12 on my controller1 version since I have a GPS on the serial port pins 14 and 15. I also set i2c_interrupt = 0, was 15, just in case the serial activity triggers something.

The compiler error was because the Makefile feature include was named PTT. PTT was also in the ACTION enum lists in action.h and in a action.c structure. I changed PTT in both action.x files to PTT_KEY. In practice, I am mapping the PTT to MOX action and not using the PTT_KEY action.

The rest of the change was basically cloning the line monitoring setup for PTT_GPIO and adding logic into process_edge

snippets added are:

in gpio_init()

// setup PTT gpio input such as a hand held mic PTT button

ifdef PTT

g_print("%s: ENABLE_PTT INPUT LINE=%d\n", FUNCTION, PTT_KEY); if(ENABLE_PTT_GPIO) { if((ret=setup_line(chip,PTT_GPIO,PTT_ACTIVE_LOW==1))<0) { goto err; } }

endif

In process_edge():

ifdef PTT

if(ENABLE_PTT_GPIO) { if(PTT_GPIO==offset) { //g_print("%s: ENABLE_PTT INPUT LINE=%d\n", FUNCTION, PTT_KEY); g_print("%s: found GPIO Line %d, PTT Button\n",FUNCTION,offset); t=millis(); found=TRUE; // Map PTT to MOX and store PTT io state there for debounce.
if(t<switches[MOX].switch_debounce) { return; } switches[MOX].switch_debounce=t+50; //settle_time; PROCESS_ACTION *a=g_new(PROCESS_ACTION,1); a->action=MOX; a->mode=value?PRESSED:RELEASED; g_idle_add(process_action,a); found=TRUE; } } if(found) return;

end

actions.c.txt actions.h.txt gpio.c.txt

EDIT: updated with debounce logic added for PTT

K7MDL2 commented 2 years ago

Things have progress on this topic. I have found that without external hardware debounce that settle time of 0ms works best for me. The i2c switches do not seem to have a problem with this value. Further, with help of DL1YCF I now have PTT (and internal CW key) working in his fork without the PTT_INCLUDE make option needed. I think those changes may flow into this fork.

Now I am assigning the paddles and PTT functions via the menus to unused switches in the encoder, switch, or toolbar menus. My encoders do not have push switches so I assigned those switches to CW LEFT, CW Right and PTT.

I then ran wires for CW jack and PTT from my mic button to those unused encoder switch PCB pads. If you do not have any extra switches/GPIO then consider using the TeensyUSBAudioMidiKeyer (See HL2 Github site) which can use MIDI commands over USB, no GPIO required and your sidetone latency goes away also. leaving open for now until this issue is closed or declined in this repository.