Created
September 26, 2020 23:40
-
-
Save Klice/42ea0b0605f0fb8a0d207bf52efdf8ff to your computer and use it in GitHub Desktop.
This file contains 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 <SPI.h> | |
#include <epd2in7b.h> | |
#include "imagedata.h" | |
#include <epdpaint.h> | |
#include <Wire.h> | |
#include <ESP8266WiFi.h> // Include the Wi-Fi library | |
#define SERIAL Serial | |
#define COLORED 1 | |
#define UNCOLORED 0 | |
const char* ssid = "Dunduk"; // The SSID (name) of the Wi-Fi network you want to connect to | |
const char* password = "****"; // The password of the Wi-Fi network | |
void setup() { | |
Epd epd; | |
SERIAL.begin(115200); // Start the Serial communication to send messages to the computer | |
delay(10); | |
SERIAL.println('\n'); | |
WiFi.begin(ssid, password); // Connect to the network | |
SERIAL.print("Connecting to "); | |
SERIAL.print(ssid); Serial.println(" ..."); | |
int i = 0; | |
while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect | |
delay(1000); | |
SERIAL.print(++i); Serial.print(' '); | |
} | |
SERIAL.println('\n'); | |
SERIAL.println("Connection established!"); | |
SERIAL.print("IP address:\t"); | |
SERIAL.println(WiFi.localIP()); // Send the IP address of the ESP8266 to the computer | |
SERIAL.println("Grove i2c port OK"); | |
if (epd.Init() != 0) | |
{ | |
SERIAL.println("e-Paper init failed"); | |
return; | |
} | |
else | |
SERIAL.println("e-Paper init OK"); | |
epd.ClearFrame(); | |
unsigned char image[1024]; | |
Paint paint(image, 176, 24); //width should be the multiple of 8 | |
paint.Clear(UNCOLORED); | |
paint.DrawStringAt(0, 0, "e-Paper Demo", &Font16, COLORED); | |
epd.TransmitPartialBlack(paint.GetImage(), 16, 32, paint.GetWidth(), paint.GetHeight()); | |
paint.Clear(COLORED); | |
paint.DrawStringAt(2, 2, "Hello world!", &Font20, UNCOLORED); | |
epd.TransmitPartialRed(paint.GetImage(), 0, 64, paint.GetWidth(), paint.GetHeight()); | |
paint.SetWidth(64); | |
paint.SetHeight(64); | |
paint.Clear(UNCOLORED); | |
paint.DrawRectangle(0, 0, 40, 50, COLORED); | |
paint.DrawLine(0, 0, 40, 50, COLORED); | |
paint.DrawLine(40, 0, 0, 50, COLORED); | |
epd.TransmitPartialBlack(paint.GetImage(), 10, 130, paint.GetWidth(), paint.GetHeight()); | |
paint.Clear(UNCOLORED); | |
paint.DrawCircle(32, 32, 30, COLORED); | |
epd.TransmitPartialBlack(paint.GetImage(), 90, 120, paint.GetWidth(), paint.GetHeight()); | |
paint.Clear(UNCOLORED); | |
paint.DrawFilledRectangle(0, 0, 40, 50, COLORED); | |
epd.TransmitPartialRed(paint.GetImage(), 10, 200, paint.GetWidth(), paint.GetHeight()); | |
paint.Clear(UNCOLORED); | |
paint.DrawFilledCircle(32, 32, 30, COLORED); | |
epd.TransmitPartialRed(paint.GetImage(), 90, 190, paint.GetWidth(), paint.GetHeight()); | |
/* This displays the data from the SRAM in e-Paper module */ | |
epd.DisplayFrame(); | |
/* This displays an image */ | |
epd.DisplayFrame(IMAGE_BLACK, IMAGE_RED); | |
/* Deep sleep */ | |
epd.Sleep(); | |
} | |
void loop() { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment