#include <SPI.h>
#include <Wire.h>
#include "WiFi.h"
#include <Adafruit_GFX.h>
#include <Adafruit_SH110X.h>
/* Uncomment the initialize the I2C address , uncomment only one, If you get a totally blank screen try the other*/
#define i2c_Address 0x3d //initialize with the I2C addr 0x3C Typically eBay OLED's
//#define i2c_Address 0x3d //initialize with the I2C addr 0x3D Typically Adafruit OLED's
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // QT-PY / XIAO
Adafruit_SH1106G display = Adafruit_SH1106G(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
const unsigned char MASK_2 [] PROGMEM = {
// 'M, 44x57px
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x20, 0x00, 0x00,
0x00, 0x03, 0xdf, 0xbc, 0x00, 0x00, 0x00, 0x07, 0xdf, 0xbe, 0x00, 0x00, 0x00, 0x07, 0xdf, 0xbe,
0x00, 0x00, 0x00, 0x17, 0xdf, 0xde, 0x80, 0x00, 0x00, 0x37, 0xdf, 0xde, 0xc0, 0x00, 0x00, 0x77,
0xdf, 0xde, 0xe0, 0x00, 0x00, 0x6f, 0xbf, 0xdf, 0x60, 0x00, 0x00, 0xef, 0xbf, 0xdf, 0x70, 0x00,
0x01, 0xef, 0xbf, 0xdf, 0x78, 0x00, 0x01, 0xef, 0xbf, 0xdf, 0x38, 0x00, 0x03, 0xdf, 0xdf, 0xdf,
0xbc, 0x00, 0x03, 0xdf, 0xdf, 0xbf, 0xbc, 0x00, 0x07, 0xdf, 0xdf, 0xbf, 0xbe, 0x00, 0x07, 0xbf,
0xdf, 0xbf, 0xde, 0x00, 0x07, 0xbf, 0xdf, 0x8f, 0xde, 0x00, 0x07, 0x00, 0x0f, 0x00, 0x0e, 0x00,
0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x02, 0x7f, 0xe6, 0x7f, 0xe4, 0x00, 0x4a, 0x7f, 0xc6, 0x3f,
0xe5, 0x20, 0x50, 0x00, 0x0f, 0x00, 0x00, 0xa0, 0x50, 0x00, 0x00, 0x00, 0x02, 0xa0, 0x4a, 0x7f,
0x80, 0x1f, 0xe5, 0xa0, 0x4d, 0x3e, 0x0e, 0x07, 0xcb, 0x20, 0x4c, 0x98, 0x9f, 0x91, 0x93, 0x20,
0x4e, 0xc3, 0x70, 0xe4, 0x37, 0x20, 0x6f, 0x7c, 0xcf, 0x33, 0xef, 0x60, 0x6f, 0xb3, 0x80, 0x1d,
0xdf, 0x60, 0x6f, 0xc6, 0x00, 0x06, 0x3f, 0x60, 0x2f, 0xcc, 0xff, 0xf3, 0x3f, 0x40, 0x0f, 0xeb,
0xff, 0xfd, 0x7f, 0x00, 0x07, 0xeb, 0xff, 0xfd, 0x7f, 0x00, 0x07, 0xe8, 0x00, 0x01, 0x7e, 0x00,
0x07, 0xe8, 0x00, 0x01, 0x7e, 0x00, 0x03, 0xeb, 0xff, 0xfd, 0x7c, 0x00, 0x01, 0xe9, 0xff, 0xf9,
0x78, 0x00, 0x01, 0xed, 0xff, 0xfb, 0x78, 0x00, 0x00, 0xe4, 0x00, 0x02, 0x70, 0x00, 0x00, 0x74,
0x00, 0x02, 0xe0, 0x00, 0x00, 0x34, 0xff, 0xfa, 0xc0, 0x00, 0x00, 0x36, 0xff, 0xf6, 0xc0, 0x00,
0x00, 0x1a, 0x00, 0x05, 0x80, 0x00, 0x00, 0x0b, 0x7f, 0xed, 0x00, 0x00, 0x00, 0x05, 0x00, 0x0a,
0x00, 0x00, 0x00, 0x00, 0x9f, 0x90, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x30, 0x00, 0x00, 0x00, 0x00,
0x30, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
void setup();
void screenA();
void screenB();
void loop() ;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
delay(250); // wait for the OLED to power up
display.begin(i2c_Address, true); // Address 0x3C default
//display.setContrast (0); // dim display
display.display();
delay(2000);
// Clear the buffer
display.clearDisplay();
screenA();
screenB();
}
void screenA(){
display.clearDisplay();
//display.drawBitmap(6, 0, MASK_2, 44, 57, SH110X_WHITE);
display.setTextColor(SH110X_WHITE);
display.setTextSize(1);
display.setCursor(70,6);
display.print("ALERT!");
display.setTextSize(1);
display.setCursor(74,28);
display.print("Message");
display.setTextSize(1);
display.setCursor(70,50);
display.print("Received");
delay(1000);
display.display();
delay(1000);
}
void screenB(){
display.display();
display.drawBitmap(6, 0, MASK_2, 44, 57, SH110X_WHITE);
display.display();
}
void loop()
{
screenA();
screenB();
}
Loading
wemos-s2-mini
wemos-s2-mini