tenbaht / sduino

An Arduino-like programming API for the STM8
http://tenbaht.github.io/sduino/
GNU Lesser General Public License v2.1
351 stars 217 forks source link

Not enough memory when compiling the oled-mini example #136

Open IdontKnowWhatToNameThisAccount opened 2 years ago

IdontKnowWhatToNameThisAccount commented 2 years ago

The sduino site has an example of the mini-ssd1306 library for oled screens running on a STM8S103F3. I have a board with an STM8S103F3P6 and it doesnt compile in the Arduino IDE, just throws this error:

data section exceeds available space in board
Sketch uses 6301 bytes (76%) of program storage space. Maximum is 8192 bytes.
Global variables use 1142 bytes (111%) of dynamic memory, leaving -118 bytes for local variables. Maximum is 1024 bytes.
Not enough memory; see https://support.arduino.cc/hc/en-us/articles/360013825179 for tips on reducing your footprint.
Error compiling for board STM8S103F3 Breakout Board.
XanCraft21 commented 1 year ago

I know this comment is a year old but i still want to help. I had this problem too. The board only has 1k of ram, and the library is configured for a 128x64 oled screen, which takes up all the ram. The highest you can go is 128x32, and it’s not that easy to change the resolution.

If you’re using windows you need to go to the folder “%appdata%” (which can be only be found by searching for it), go to the folder named “local” (by default it puts you into the folder named “roaming” if i spelled that correctly), head to the arduino15 folder (arduino17 if using the 2.0 version), go to packages, sduino, hardware, find libraries, find the mini-ssd1306 library and go into the .h file, scroll down about a quarter (i used notepad to edit this, or you can go to edit then find) and look for “#define SSD1306_128_64”. Comment that out and uncomment the one below it, then save the file. This is the only way to change the resolution for this library.

in the arduino sketch below the long comment at the top, there is an if statement that forces an error if the display height is lower than 64. Change that to say 32 then it should work fine.

this will only work for oled displays with 128x32 or 96x16 resolution, the 128x32 oled is more common than the 96x16 oled. I have not tried uploading yet, i will test that in a few days.

I hope this helped, sorry if it’s too long and complex.