I meant to post a worked example of the polling approach. But then I forgot...
Here is it anyway - I have commented out the R.Pi specific parts, and stubbed the read of the ADC, but it shows the basics of the timer polling approach...
With the ADC stuff added back in (and my dummy counter removed) this ought to pretty much work on the R.Pi, though you will need to link against wiringPi of course, as well as the fltk lib.
Something like this might do the trick to compile it:
g++ `fltk-config --cxxflags` app.cxx -o app -lwiringPi `fltk-config --ldstaticflags`
// Start of file
// You would need these headers...
// #include <wiringPi.h>
// #include <mcp3004.h>
#define BASE 100
#define SPI_CHAN 0
#define chan0 0 /* Poti */
#define chan1 1 /* LDR */
static Fl_Double_Window *main_win = NULL;
static Fl_Value_Output *adc_out = NULL;
static int get_adc (void)
// This is where the ADC read would go...
//return analogRead (BASE);
// for now, here's a dummy test stub - reomve this!
static int dummy = 0;
if (dummy > 255) dummy = 0;
} // get_adc
// animate the meter for testing purposes
static void poll_adc (void *)
static int old_level = (-1);
int level = get_adc ();
if (level != old_level)
old_level = level;
} // poll_adc
static void cb_Exit (void *)
} // cb_Exit
int main (int argc, char **argv)
// Setup wiringPi and mcp3004
// mcp3004Setup(BASE, SPI_CHAN);
main_win = new Fl_Double_Window(247, 130);
adc_out = new Fl_Value_Output(100, 22, 66, 33, "ADC READ :");
Fl_Button* o = new Fl_Button(175, 80, 60, 25, "Exit");
} // main
// end of file
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 firstname.lastname@example.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/86F89B84-CF9B-439B-90C7-560ADD925F17%40gmail.com.
[ Direct Link to Message ]