giuliomoro
That seems fairly straightforward, if it works. To test it:
- connect the oled display
- outside the Bela environment:
- put all the files from the library and example in the same folder:
I2C.h SSD1306_OLED.h gfxfont.h I2C.c SSD1306_OLED.c Main.c example_app.c
- compile them and link them all together:
gcc *.c -o oled
- run the result:
./oled
- it this works, keep going!
- put all the files from the library and example in the same folder:
- inside the Bela environment
- create a new C++ Bela project
- put all the files from the library in the project, but in
Main.c
replace the name of the functionmain()
witholed_main()
or similar - edit the
render.cpp
file as follows (untested):#include <Bela.h> extern "C" { int oled_main(void); // declare the oled_main() function from Main.c } AuxiliaryTask oledTask; void* oledTaskFunction(void*) { while(!gShouldStop){ // run the content of the loop until the program stops oled_main(); usleep(50000); // always sleep in a busy loop to avoid hogging all the CPU } } bool setup(BelaContext* context, void* userData) { Bela_createAuxiliaryTask(oledTaskFunction, 1, "oledTask", NULL); Bela_scheduleAuxiliaryTask(oledTask); } // optional: add some sound generator into render()
- run and enjoy
- The next step would be to replace the call to
oled_main()
with something in that reacts to some global variables that you would set inrender()
. - in combination with a Heavy project
- you need a custom
render.cpp
- add there the same changes as above
- use heavy's
sendHook
to set the global variables that affect the OLED output