Re: [fltk.general] Read Signal from ADC on Raspberry Pi with FLTK

GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Read Signal from ADC on Raspberry Pi with FLTK Ian MacArthur 08:21 Oct 21 top right image
 
On 21 Oct 2020, at 15:48, LosCelos wrote:

mistake from my side:
i dont need the makefile. I can compile the shown adc program in terminal with: gcc testADC.c -o testADC -lwiringPi

i compile the fltk App with: fltk-config --compile app.cxx

the problem is that i cant put the needed  -lwiringPi in the compile line from the fltk


It probably is easier to do this with a Makefile - you will need to create one tailored to your project.

There are some notes you can follow:


and 


Might be good places to start.





is it possible to put the ADC code from above in my fltk App code, and it should some how know the reference, so that it dousnt throw: undefined reference to wiringPiSetup ?


Yes, but it will need to be done via callbacks and so forth. GUI programming is event driven, in general, so the simple linear progression of the sample code you show will not work.

Take a look at the fltk test samples, see how their code works.

In my original reply, I thought you were trying to build an oscilloscope, but if you simply want to display values from the ADC in “real time” then a simpler timer based approach will probably work.

Build a simple fltk app that updates it’s display in response to a timer (see Fl::add_timeout) and in the timer callback call the ADC API there to read the latest value and then display that on your display widget.

Set the timer to repeat at every 0.1 seconds and that will work fine. 

I’m not sure about the ADC that you are using but I’d assume you can probably poll it at 1kHz or so over the i2c bus. You can’t possibly display that many values though (your monitor will only be running at 60Hz, typically) and anyway humans can only parse values at about 10Hz, so refreshing the display any faster than that is just wasting pixels...

There are samples in the test and examples folder that demonstrate how to use the timers and how to make the callbacks, so you can easily start from there.




or do i have to start the ADC programm from my App with treads as you say before? If so, how i make my App knowing the ADC program to start it?


No, you can call the ADC API from your fltk program, in the timer callback if the update rate is low enough.
If you want to capture “all” the samples, you probably do need a separate thread to do that so that the ADC poll is independent of, and does not block, the GUI thread.

But do the timer approach first and once you understand how that works, head on to more challenging techniques!






--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/F58C6BBB-265E-4A13-A65A-3697D462FE18%40gmail.com.
Direct Link to Message ]
 
bottom left image   bottom right image
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2020 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.