- Tue Jun 23, 2015 12:41 am
#21327
I have these same mods functioning on an ESP01 with the 4 pin I2C version.
I did not notice any changes to the Adafruit_SSD1306.h file ..
I also changed the top of the .h file to read .. (around line 27)
#ifdef ESP8266
typedef volatile uint32_t PortReg;
typedef uint32_t PortMask;
#else
#ifdef __SAM3X8E__
typedef volatile RwReg PortReg;
typedef uint32_t PortMask;
#else
typedef volatile uint8_t PortReg;
typedef uint8_t PortMask;
#endif
#endif
then since the example kept timing out with a watchdog, as many display routines are designed to be both as fast as possible yet slow, I either had to go through the example and add yield() everywhere..
instead mod the
void Adafruit_SSD1306::display(void) {
function in the library .. search for (around line 529)
#ifdef __AVR__
//#ifndef __SAM3X8E__
uint8_t twbrbackup = TWBR;
TWBR = 12; // upgrade to 400KHz!
#endif
//Serial.println(TWBR, DEC);
//Serial.println(TWSR & 0x3, DEC);
that part of the code and add ..
#ifdef ESP8266
yield();
#endif
and this area at the bottom of the function ..(line 550 after above mods)
//#ifndef __SAM3X8E__
#ifdef __AVR__
TWBR = twbrbackup;
#endif
add this afterwards...
#ifdef ESP8266
yield();
#endif
then whenever the display is updated the yield is called at both the start and finish of the display routine.
have no yields at all in the example code any longer and it is running crash free.
Having a lot of trouble reprogramming however, I am not sure if it is the wire call redirecting i2c functions to GPIO 0 and 2 or if its dodgy wiring, added a 2 second boot delay that helps reprogramming at times.. but I still seem to have to power the unit on and off to get it loading.