Combining Wire library and OLED

128x128 pixel 1.5" full colour OLED display with MicroSD card slot. [Product page]
Post Reply
touche
Posts: 2
Joined: Sat Nov 02, 2013 5:50 am

Combining Wire library and OLED

Post by touche » Sun Nov 03, 2013 7:56 am

Sixth problem.

Any body had success with
#include <SPI.h>
#include <Wire.h>
#include <SD.h>
#include <FTOLED.h>
#include <fonts/SystemFont5x7.h>
#include <MemoryFree.h>
#include "DHT.h"
all being used together?

My prog runs fine until I simply add #include <Wire.h>
Plenty of spare RAM.
Then program restarts as soon as a bitmap is displayed. Without the wire.h library, the program runs for ever without problems.

wire.h
TwoWire.h - TWI/I2C library for Arduino & Wiring
Copyright (c) 2006 Nicholas Zambetti. All right reserved.

I must say that I have used this library in the past without problems. Just that its a problem today running with oled.

[edit]
Just got rid of wire.h from the sketch. Bitmap works again. Introduced:
#include <SoftI2C.h>
#include <DS3232RTC.h>
instead. When I create instance of DS3232RTC, same deal as wire.h. Problem with bitmap.
Deleted the line #include "DHT.h" and any associated lines and introduced:
SoftI2C i2c(A2, A3); // even changed the ports but still a problem.
DS3232RTC rtc(i2c);
.... and in loop the following.
RTCTime time;
rtc.readTime(&time);
text.print(F("Time:"));
snprintf(buf,SIZEOFBUFFER,"%02i:%02i",time.hour,time.minute);
text.println(buf);
int t1= rtc.readTemperature();
float t = t1 / 4;
text.print(F("Temperature: "));
text.print(int(t));
text.println(F("C"));

Bitmap works perfectly again.

Sounds like:
#include <SPI.h>
#include <SD.h>
#include <FTOLED.h>
#include <fonts/SystemFont5x7.h>
#include <MemoryFree.h>
//#include "DHT.h"
#include <SoftI2C.h>
#include <DS3232RTC.h>

DHT.h cannot be mixed with DS3232RTC (or Wire.h but haven't checked). Any thoughts?

Thanks.

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: Combining Wire library and OLED

Post by angusgr » Mon Nov 04, 2013 8:03 am

Hi touche,

I've split this one into a new topic because it doesn't seem to be related to the OLED128 SD card slot.
touche wrote: My prog runs fine until I simply add #include <Wire.h>
When you say you add that #include line, are you adding just the #include line or also some code in the body of your sketch, that references Wire? If the latter, can you post the full contents of your sketch please?
touche wrote: Plenty of spare RAM.
Then program restarts as soon as a bitmap is displayed. Without the wire.h library, the program runs for ever without problems.
What kind of board are you using, and how much is plenty of spare RAM? Displaying BMPs does use some RAM, 8bpp images in particular are quite memory hungry. The RAM is only allocated while the BMP is being drawn and is freed up as soon as drawing finishes, so checking free memory at other times doesn't account for it.

The FTOLED library wiki gives some estimates of how much RAM a BMP display may use:
https://github.com/freetronics/FTOLED/w ... #ram-usage

As per the comment on the wiki page, 4bpp and 16bpp (oddly) are the best choices for memory-saving BMP colour depths.

Regards,

Angus

Post Reply