Comments (15)
Modifying library code when building sketches for different schematics is a pain in the neck.
Could you please adjust the source code in the way which would allow developers to define constants in their code.
Here is an example how this can be achieved in Adafruit_SSD1306.h
:
#ifndef SSD1306_I2C_ADDRESS
#define SSD1306_I2C_ADDRESS 0x3C
#endif
#if !defined(SSD1306_128_64) && !defined(SSD1306_128_32) && !defined(SSD1306_96_16)
#define SSD1306_128_32
#endif
This way you'll keep backward compatibility.
from adafruit_ssd1306.
+1
from adafruit_ssd1306.
I tried to work out a malloc solution, but it seems the memory is not big enough to support it. So I worked out another solution that separates header files and implementations for each resolution but keep the core source being reused.
This might not be the best solution, but it could avoid changing the source of the library when changing the OLED resolution.
One can change the resolution by changing head file included.
ex.
To use an OLED 128x64:
#include <Adafruit_SSD1306_128_64.h>
from adafruit_ssd1306.
redo the library to use malloc is a big work. So I think you can adopt the option from @Anton-V-K before anyone send a perfect malloc PR.
At least, @Anton-V-K 's version allows me to set the resolution by the build flag -D SSD1306_128_64
. I could specify a build flag when I use some IDE like platformio instead of the default Arduino IDE.
But current version, I can do nothing if I want to keep the library as is.
from adafruit_ssd1306.
@alexgorbatchev I have submitted a PR #94
from adafruit_ssd1306.
hiya, we would accept a solution with malloc that is backward compatible with current code, not #include noodling :)
from adafruit_ssd1306.
Hey @tdicola, this is Fotis from codebender. We just added the SSD1306 library to our platform and we've bumped into the same issue. Users have no write access to libraries' files on codebender, so we'd appreciate if you could move the defines to the examples's code, instead of them being hardcoded in the library code.
Thanks in advance!
from adafruit_ssd1306.
nevermind, this is not actually possible without a pretty fair rewrite because i used #define's not extern variables
there is no way for the library to pick up a #define in the sketch, thats just how C++ works
no fix at this time. will have to go thru and change the design to use malloc & copy the start buffer in from flash
from adafruit_ssd1306.
how much work would it be to address this?
from adafruit_ssd1306.
someone would have to redo the library to use malloc - feel free to do it and send a PR!
from adafruit_ssd1306.
anton's solution doesnt work in Arduino, as how C++ handles #defines, they're not global :) we would only accept a PR that works in Arduino since it is how people use the library
from adafruit_ssd1306.
@programus i like this, would you submit a PR for review?
from adafruit_ssd1306.
This sounds great, please accept this.
from adafruit_ssd1306.
I also tried the malloc solution but it seems consume too much memory to let arduino do something else besides display. So I have to work out this #include noodling thing.
from adafruit_ssd1306.
Fixed as of v1.2; display buffer uses malloc.
from adafruit_ssd1306.
Related Issues (20)
- display.display(), arbitrary display area refresh
- not able to run ESP32 and SSD1306 128x64 i2c HOT 4
- display.begin() always true HOT 3
- Using clearDisplay() in the main loop causes Arduino Micro / Pro Micro bootloader to crash HOT 5
- reset pin not activated properly on stm32 bluepill
- Character's size HOT 2
- SPI communication is very slow
- pgmspace.h: No such file or directory for Raspberry Pi Pico HOT 4
- Custom i2c pins for ESP32 HOT 2
- The problem with the screen
- Cannot compile for Arduino Nano RP2040 Connect HOT 3
- lcd oled 64x48 no working
- inharmony with SD.h
- Teensy issue on top row. HOT 2
- error when several ssd1306 128x64 HOT 1
- Not compatible with ATmega328PB (Watterrott Pro Mini PB)? HOT 1
- [Feature Request] One instance - multiple devices
- adc_timer_dma and Adafruit SSD1306_128x32_i2c reboot loop HOT 1
- still compilation problem for Arduino Nano RP2040 connect (even with v2.5.11)
- I2C SSD1306 does not work in Arduino Leonardo HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adafruit_ssd1306.