This is better. You see that now it is actually running the task (as you can tell from the fact that the line
(Main)i2c-1: Bus Connected to SSD1306
is printed).
I started debugging this by copying all your code to the board and trying to run the files from your repo as a stand-alone app, and that would fail at compile time. I fixed it with this.
Then, I managed to build a stand-alone program (non-Bela) and run it, but it would only display (Main)i2c-1: Bus Connected to SSD1306
and would not actually show anything on the display.
Did you see the test animation on the display?
Next thing I did was to check out the upstream code (basically, your code without your changes), which is hardcoded to use I2C-2. Once I managed to get it to build (needed the same fix as above), it ran just fine.
I also fixed a buffer overflow that was an accident waiting to happen.
I applied some minimal changes to be able to use i2c-1, without having to go through the whole renaming process you undertook.
After that, the stand-alone application works fine on i2c-1 as well.
Then I copied the files thus updated into the project, and I got to the same point you were at:
crosswick Running project...
(Main)i2c-1: Bus Connected to SSD1306
Segmentation fault
Makefile:524: recipe for target 'runide' failed
make: *** [runide] Error 139
(note this took me over 1 hour, and I could have saved all of that time if you had sent me the code ready to test).
The compiler actually gives you a warning that is the key to solve the issue:
/root/Bela/projects/ssd/render.cpp:17:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
1 warning generated.
This means that you are supposed to return a value from setup()
and you are not. If the initialization goes well, you should return true
.
So this works for me:
bool setup(BelaContext* context, void* userData)
{
oledTask = Bela_createAuxiliaryTask(oledTaskFunction, 1, "oledTask", NULL);
Bela_scheduleAuxiliaryTask(oledTask);
return true;
}
For the avoidance of doubt, here is a repo containing a complete Bela project where this code is working correctly. Note that the program may take a while to stop after you hit stop, because the oled_main()
function takes forever to return.