Created
April 30, 2018 03:41
-
-
Save alexdmejias/ae8dc051d72f9269b9a2675c3fdb4b02 to your computer and use it in GitHub Desktop.
works with three screens. Just have to change line 52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Arduino.h> | |
#include <U8g2lib.h> | |
#ifdef U8X8_HAVE_HW_SPI | |
#include <SPI.h> | |
#endif | |
#ifdef U8X8_HAVE_HW_I2C | |
#include <Wire.h> | |
#endif | |
#define TCAADDR 0x70 // I2C Multiplexer ADDR | |
struct display { | |
U8G2 *display; | |
uint8_t i2cnum; | |
const u8g2_cb_t *rotation; | |
}; | |
//U8G2_SSD1306_128X64_NONAME_1_HW_I2C display128x64(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 4, /* data=*/ 0); // ESP32 Thing, HW I2C with pin remapping | |
//U8G2_SSD1306_128X64_NONAME_1_SW_I2C display128x64(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display | |
U8G2_SSD1306_128X64_NONAME_1_HW_I2C display128x64(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); | |
#define NUMSCREENS 3 | |
display OLEDS[NUMSCREENS] = { | |
{ &display128x64, 1, U8G2_R3 }, | |
{ &display128x64, 7, U8G2_R3 }, | |
{ &display128x64, 2, U8G2_R3 } | |
}; | |
/* I2C multiplexer controls */ | |
void tcaselect(uint8_t i) { | |
if (i > 7) return; | |
Wire.beginTransmission(TCAADDR); | |
Wire.write(1 << i); | |
Wire.endTransmission(); | |
} | |
void setup() { | |
Serial.begin(115200); | |
while (!Serial); | |
Wire.begin(); | |
tcaselect(1); | |
OLEDS[0].display->begin(); | |
tcaselect(2); | |
OLEDS[1].display->begin(); | |
tcaselect(6); | |
OLEDS[1].display->begin(); | |
} | |
void loop(void) { | |
tcaselect(6); | |
OLEDS[0].display->firstPage(); | |
do { | |
OLEDS[0].display->setFont(u8g2_font_ncenB10_tr); | |
OLEDS[0].display->drawStr(0,24,"Hello World!!!"); | |
} while ( OLEDS[0].display->nextPage() ); | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment