Corrected mistake created while restructuring project files
This commit is contained in:
parent
ea018f3510
commit
729082eb81
BIN
DIY-LosungE-Paper_Case-Part1.FCStd
Executable file
BIN
DIY-LosungE-Paper_Case-Part1.FCStd
Executable file
Binary file not shown.
BIN
DIY-LosungE-Paper_Case-Part1.mp4
Executable file
BIN
DIY-LosungE-Paper_Case-Part1.mp4
Executable file
Binary file not shown.
BIN
DIY-LosungE-Paper_Case-Part1.stl
Executable file
BIN
DIY-LosungE-Paper_Case-Part1.stl
Executable file
Binary file not shown.
19980
DIY-LosungE-Paper_Case-Part1_normal.gcode
Executable file
19980
DIY-LosungE-Paper_Case-Part1_normal.gcode
Executable file
File diff suppressed because it is too large
Load Diff
BIN
DIY-LosungE-Paper_Case-Part2.FCStd
Executable file
BIN
DIY-LosungE-Paper_Case-Part2.FCStd
Executable file
Binary file not shown.
BIN
DIY-LosungE-Paper_Case-Part2.stl
Executable file
BIN
DIY-LosungE-Paper_Case-Part2.stl
Executable file
Binary file not shown.
32681
DIY-LosungE-Paper_Case-Part2_fine.gcode
Executable file
32681
DIY-LosungE-Paper_Case-Part2_fine.gcode
Executable file
File diff suppressed because it is too large
Load Diff
BIN
DIY-LosungE-Paper_Case-Part2_fine.mp4
Executable file
BIN
DIY-LosungE-Paper_Case-Part2_fine.mp4
Executable file
Binary file not shown.
@ -1,4 +1,4 @@
|
||||
This is free and unencumbered software released into the public domain.
|
||||
ESPThis is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
|
||||
|
||||
|
133
display.ino
133
display.ino
@ -1,133 +0,0 @@
|
||||
#include "epdpaint.h"
|
||||
|
||||
String pad(String text, int pad_length, char pad_letter) {
|
||||
if(text.length() >= pad_length) return text; // if theres nothing to fill, return the text unmodified
|
||||
|
||||
for(int i = 0; text.length()<pad_length; i++) text += pad_letter; // fill with pad_letter until the text is as long as padlength specifies
|
||||
return text;
|
||||
}
|
||||
String pad(String text, int pad_length) { return pad(text, pad_length, ' '); } // just a fallback for pad_letter
|
||||
|
||||
/* Tell how many rows of text will be needed at given font-width and box-width for the text given */
|
||||
int getMaxRows(String text, int width, int letter_width) {
|
||||
int lettersPerRow = width / letter_width;
|
||||
float maxRows = float(text.length())/float(lettersPerRow);
|
||||
int maxRowsFloor = text.length()/lettersPerRow;
|
||||
if(maxRows>maxRowsFloor) maxRows = maxRowsFloor+1.0; // if maxRows is e.g. 5.2, write the next-bigger integer into maxRows
|
||||
|
||||
return maxRows;
|
||||
}
|
||||
|
||||
/* text_of_row_x tells which row shall be given, 0 for first row */
|
||||
String getRow(String text, int width, int letter_width, int text_of_row_x) { // width should be a multiple of letter_width to fit perfect
|
||||
// calculate needed vars
|
||||
int lettersPerRow = width / letter_width;
|
||||
int maxRows = getMaxRows(text, width, letter_width);
|
||||
text = pad(text, maxRows*lettersPerRow, ' ');
|
||||
|
||||
// some tests
|
||||
if(text_of_row_x > maxRows) return String();
|
||||
if(text_of_row_x < 0) return String();
|
||||
|
||||
return text.substring(lettersPerRow*text_of_row_x, lettersPerRow*(text_of_row_x+1));
|
||||
}
|
||||
|
||||
// remove special characters (ä,ö,ü,ß)
|
||||
String replaceSpecialChars(String text) {
|
||||
if(text[0] == ' ') { text = text.substring(1,text.length()-1); }
|
||||
text.replace("ä", "ae");
|
||||
text.replace("Ä", "AE");
|
||||
text.replace("ä", "ae");
|
||||
text.replace("Ä", "AE");
|
||||
text.replace("ö", "oe");
|
||||
text.replace("Ö", "OE");
|
||||
text.replace("ö", "oe");
|
||||
text.replace("Ö", "OE");
|
||||
text.replace("ü", "ue");
|
||||
text.replace("Ü", "UE");
|
||||
text.replace("ü", "ue");
|
||||
text.replace("Ü", "UE");
|
||||
text.replace("ß", "ss");
|
||||
text.replace("ẞ", "SS");
|
||||
text.replace("ß", "ss");
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
// show the daily text on the epd
|
||||
void showDailyText(String losung, String lehrtext, String losungPosition, String lehrtextPosition) {
|
||||
// clean the strings for
|
||||
losung = replaceSpecialChars(losung);
|
||||
lehrtext = replaceSpecialChars(lehrtext);
|
||||
losungPosition = replaceSpecialChars(losungPosition);
|
||||
lehrtextPosition = replaceSpecialChars(lehrtextPosition);
|
||||
|
||||
// position vars
|
||||
int text_x = 0;
|
||||
int text_y = 0;
|
||||
|
||||
/* This clears the SRAM of the e-paper display and displays it */
|
||||
epd.ClearFrame();
|
||||
epd.DisplayFrame();
|
||||
|
||||
// now the drawing init
|
||||
unsigned char image[2048];
|
||||
Paint paint(image, 176, TITLE_FONT.Height+2); // width should be the multiple of 8
|
||||
|
||||
// display title
|
||||
paint.Clear(UNCOLORED);
|
||||
int startTitleAtX = round((paint.GetWidth()-strlen(TITLE_TEXT)*TITLE_FONT.Width)/2);
|
||||
paint.DrawStringAt(startTitleAtX, 0, TITLE_TEXT, &TITLE_FONT, COLORED);
|
||||
paint.DrawHorizontalLine(startTitleAtX+15, TITLE_FONT.Height+1, paint.GetWidth()-(startTitleAtX+15)*2, COLORED);
|
||||
text_y = TITLE_PADDING_TOP;
|
||||
epd.TransmitPartialData(paint.GetImage(), text_x, text_y, paint.GetWidth(), paint.GetHeight());
|
||||
text_y += TITLE_FONT.Height+2;
|
||||
|
||||
// Losung
|
||||
paint.SetWidth(TEXT_WIDTH);
|
||||
paint.SetHeight(TEXT_FONT.Height);
|
||||
text_y += TEXT_PADDING_TOP;
|
||||
|
||||
for(int row = 0; row<getMaxRows(losung, TEXT_WIDTH, TEXT_FONT.Width); row++) {
|
||||
String text_of_row = getRow(losung, TEXT_WIDTH, TEXT_FONT.Width, row);
|
||||
|
||||
paint.Clear(COLORED);
|
||||
paint.DrawStringAt(0, 0, text_of_row.c_str(), &TEXT_FONT, UNCOLORED);
|
||||
epd.TransmitPartialData(paint.GetImage(), EPD_WIDTH-TEXT_WIDTH, text_y, paint.GetWidth(), paint.GetHeight());
|
||||
text_y += paint.GetHeight();
|
||||
text_y += TEXT_PADDING_BETWEEN_LINES;
|
||||
}
|
||||
|
||||
// Losung bible position
|
||||
paint.SetWidth(losungPosition.length()*SOURCE_FONT.Width);
|
||||
paint.SetHeight(SOURCE_FONT.Height);
|
||||
paint.Clear(UNCOLORED);
|
||||
paint.DrawStringAt(0, 0, losungPosition.c_str(), &SOURCE_FONT, COLORED);
|
||||
epd.TransmitPartialData(paint.GetImage(), EPD_WIDTH-losungPosition.length()*SOURCE_FONT.Width, text_y, paint.GetWidth(), paint.GetHeight());
|
||||
|
||||
// Lehrtext
|
||||
paint.SetWidth(TEXT_WIDTH); // text block width
|
||||
paint.SetHeight(TEXT_FONT.Height);
|
||||
text_y += TEXT_PADDING_BETWEEN_BLOCKS; // some space between "losung" block
|
||||
|
||||
for(int row = 0; row<getMaxRows(lehrtext, TEXT_WIDTH, TEXT_FONT.Width); row++) {
|
||||
String text_of_row = getRow(lehrtext, TEXT_WIDTH, TEXT_FONT.Width, row);
|
||||
|
||||
paint.Clear(UNCOLORED);
|
||||
paint.DrawStringAt(0, 0, text_of_row.c_str(), &TEXT_FONT, COLORED);
|
||||
epd.TransmitPartialData(paint.GetImage(), 0, text_y, paint.GetWidth(), paint.GetHeight());
|
||||
text_y += paint.GetHeight();
|
||||
text_y += TEXT_PADDING_BETWEEN_LINES;
|
||||
}
|
||||
|
||||
// Lehrtext bible position
|
||||
paint.SetWidth(lehrtextPosition.length()*SOURCE_FONT.Width);
|
||||
paint.SetHeight(SOURCE_FONT.Height);
|
||||
paint.Clear(COLORED);
|
||||
paint.DrawStringAt(0, 0, lehrtextPosition.c_str(), &SOURCE_FONT, UNCOLORED);
|
||||
epd.TransmitPartialData(paint.GetImage(), 5, text_y, paint.GetWidth(), paint.GetHeight());
|
||||
|
||||
|
||||
// display the whole sent data
|
||||
epd.DisplayFrame();
|
||||
}
|
581
epd2in7.cpp
581
epd2in7.cpp
@ -1,581 +0,0 @@
|
||||
/**
|
||||
* @filename : epd2in7.cpp
|
||||
* @brief : Implements for e-paper library
|
||||
* @author : Yehui from Waveshare
|
||||
*
|
||||
* Copyright (C) Waveshare August 18 2017
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documnetation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "epd2in7.h"
|
||||
#include <Arduino.h>
|
||||
#include <SPI.h>
|
||||
|
||||
//////////////////////////////////////full screen update LUT////////////////////////////////////////////
|
||||
//0~3 gray
|
||||
static const unsigned char EPD_2in7_gray_lut_vcom[] =
|
||||
{
|
||||
0x00 ,0x00,
|
||||
0x00 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01,
|
||||
0x60 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01,
|
||||
0x00 ,0x14 ,0x00 ,0x00 ,0x00 ,0x01,
|
||||
0x00 ,0x13 ,0x0A ,0x01 ,0x00 ,0x01,
|
||||
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
|
||||
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
|
||||
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
|
||||
};
|
||||
//R21
|
||||
static const unsigned char EPD_2in7_gray_lut_ww[] ={
|
||||
0x40 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01,
|
||||
0x90 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01,
|
||||
0x10 ,0x14 ,0x0A ,0x00 ,0x00 ,0x01,
|
||||
0xA0 ,0x13 ,0x01 ,0x00 ,0x00 ,0x01,
|
||||
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
|
||||
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
|
||||
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
|
||||
};
|
||||
//R22H r
|
||||
static const unsigned char EPD_2in7_gray_lut_bw[] ={
|
||||
0x40 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01,
|
||||
0x90 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01,
|
||||
0x00 ,0x14 ,0x0A ,0x00 ,0x00 ,0x01,
|
||||
0x99 ,0x0C ,0x01 ,0x03 ,0x04 ,0x01,
|
||||
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
|
||||
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
|
||||
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
|
||||
};
|
||||
//R23H w
|
||||
static const unsigned char EPD_2in7_gray_lut_wb[] ={
|
||||
0x40 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01,
|
||||
0x90 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01,
|
||||
0x00 ,0x14 ,0x0A ,0x00 ,0x00 ,0x01,
|
||||
0x99 ,0x0B ,0x04 ,0x04 ,0x01 ,0x01,
|
||||
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
|
||||
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
|
||||
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
|
||||
};
|
||||
//R24H b
|
||||
static const unsigned char EPD_2in7_gray_lut_bb[] ={
|
||||
0x80 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01,
|
||||
0x90 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01,
|
||||
0x20 ,0x14 ,0x0A ,0x00 ,0x00 ,0x01,
|
||||
0x50 ,0x13 ,0x01 ,0x00 ,0x00 ,0x01,
|
||||
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
|
||||
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
|
||||
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
|
||||
};
|
||||
|
||||
/* END OF FILE */
|
||||
|
||||
|
||||
Epd::~Epd() {
|
||||
};
|
||||
|
||||
Epd::Epd() {
|
||||
};
|
||||
|
||||
int Epd::Init(void) {
|
||||
/* this calls the peripheral hardware interface */
|
||||
pinMode(CS_PIN, OUTPUT);
|
||||
pinMode(RST_PIN, OUTPUT);
|
||||
pinMode(DC_PIN, OUTPUT);
|
||||
pinMode(BUSY_PIN, INPUT);
|
||||
SPI.begin();
|
||||
SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE0));
|
||||
|
||||
/* EPD hardware init start */
|
||||
Reset();
|
||||
SendCommand(POWER_SETTING);
|
||||
SendData(0x03); // VDS_EN, VDG_EN
|
||||
SendData(0x00); // VCOM_HV, VGHL_LV[1], VGHL_LV[0]
|
||||
SendData(0x2b); // VDH
|
||||
SendData(0x2b); // VDL
|
||||
SendData(0x09); // VDHR
|
||||
SendCommand(BOOSTER_SOFT_START);
|
||||
SendData(0x07);
|
||||
SendData(0x07);
|
||||
SendData(0x17);
|
||||
// Power optimization
|
||||
SendCommand(0xF8);
|
||||
SendData(0x60);
|
||||
SendData(0xA5);
|
||||
// Power optimization
|
||||
SendCommand(0xF8);
|
||||
SendData(0x89);
|
||||
SendData(0xA5);
|
||||
// Power optimization
|
||||
SendCommand(0xF8);
|
||||
SendData(0x90);
|
||||
SendData(0x00);
|
||||
// Power optimization
|
||||
SendCommand(0xF8);
|
||||
SendData(0x93);
|
||||
SendData(0x2A);
|
||||
// Power optimization
|
||||
SendCommand(0xF8);
|
||||
SendData(0xA0);
|
||||
SendData(0xA5);
|
||||
// Power optimization
|
||||
SendCommand(0xF8);
|
||||
SendData(0xA1);
|
||||
SendData(0x00);
|
||||
// Power optimization
|
||||
SendCommand(0xF8);
|
||||
SendData(0x73);
|
||||
SendData(0x41);
|
||||
SendCommand(PARTIAL_DISPLAY_REFRESH);
|
||||
SendData(0x00);
|
||||
SendCommand(POWER_ON);
|
||||
WaitUntilIdle();
|
||||
|
||||
SendCommand(PANEL_SETTING);
|
||||
SendData(0xAF); //KW-BF KWR-AF BWROTP 0f
|
||||
SendCommand(PLL_CONTROL);
|
||||
SendData(0x3A); //3A 100HZ 29 150Hz 39 200HZ 31 171HZ
|
||||
SendCommand(VCM_DC_SETTING_REGISTER);
|
||||
SendData(0x12);
|
||||
delay(2);
|
||||
SetLut();
|
||||
/* EPD hardware init end */
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
void Epd::Init_4Gray(void)
|
||||
{
|
||||
Reset();
|
||||
SendCommand(POWER_SETTING); //POWER SETTING
|
||||
SendData (0x03);
|
||||
SendData (0x00);
|
||||
SendData (0x2b);
|
||||
SendData (0x2b);
|
||||
|
||||
|
||||
SendCommand(BOOSTER_SOFT_START); //booster soft start
|
||||
SendData (0x07); //A
|
||||
SendData (0x07); //B
|
||||
SendData (0x17); //C
|
||||
|
||||
SendCommand(0xF8); //boost??
|
||||
SendData (0x60);
|
||||
SendData (0xA5);
|
||||
|
||||
SendCommand(0xF8); //boost??
|
||||
SendData (0x89);
|
||||
SendData (0xA5);
|
||||
|
||||
SendCommand(0xF8); //boost??
|
||||
SendData (0x90);
|
||||
SendData (0x00);
|
||||
|
||||
SendCommand(0xF8); //boost??
|
||||
SendData (0x93);
|
||||
SendData (0x2A);
|
||||
|
||||
SendCommand(0xF8); //boost??
|
||||
SendData (0xa0);
|
||||
SendData (0xa5);
|
||||
|
||||
SendCommand(0xF8); //boost??
|
||||
SendData (0xa1);
|
||||
SendData (0x00);
|
||||
|
||||
SendCommand(0xF8); //boost??
|
||||
SendData (0x73);
|
||||
SendData (0x41);
|
||||
|
||||
SendCommand(PARTIAL_DISPLAY_REFRESH);
|
||||
SendData(0x00);
|
||||
|
||||
SendCommand(POWER_ON);
|
||||
WaitUntilIdle();
|
||||
|
||||
SendCommand(PANEL_SETTING); //panel setting
|
||||
SendData(0xbf); //KW-BF KWR-AF BWROTP 0f
|
||||
|
||||
SendCommand(PLL_CONTROL); //PLL setting
|
||||
SendData (0x90); //100hz
|
||||
|
||||
SendCommand(TCON_RESOLUTION); //resolution setting
|
||||
SendData (0x00); //176
|
||||
SendData (0xb0);
|
||||
SendData (0x01); //264
|
||||
SendData (0x08);
|
||||
|
||||
SendCommand(VCM_DC_SETTING_REGISTER); //vcom_DC setting
|
||||
SendData (0x12);
|
||||
|
||||
SendCommand(VCOM_AND_DATA_INTERVAL_SETTING); //VCOM AND DATA INTERVAL SETTING
|
||||
SendData(0x97);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief: basic function for sending commands
|
||||
*/
|
||||
void Epd::SendCommand(unsigned char command) {
|
||||
digitalWrite(DC_PIN, LOW);
|
||||
digitalWrite(CS_PIN, LOW);
|
||||
SPI.transfer(command);
|
||||
digitalWrite(CS_PIN, HIGH);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief: basic function for sending data
|
||||
*/
|
||||
void Epd::SendData(unsigned char data) {
|
||||
digitalWrite(DC_PIN, HIGH);
|
||||
digitalWrite(CS_PIN, LOW);
|
||||
SPI.transfer(data);
|
||||
digitalWrite(CS_PIN, HIGH);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief: Wait until the BUSY_PIN goes HIGH
|
||||
*/
|
||||
void Epd::WaitUntilIdle(void) {
|
||||
while(digitalRead(BUSY_PIN) == 0) { //0: busy, 1: idle
|
||||
delay(100);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief: module reset.
|
||||
* often used to awaken the module in deep sleep,
|
||||
* see Epd::Sleep();
|
||||
*/
|
||||
void Epd::Reset(void) {
|
||||
digitalWrite(RST_PIN, HIGH);
|
||||
delay(200);
|
||||
digitalWrite(RST_PIN, LOW);
|
||||
delay(10);
|
||||
digitalWrite(RST_PIN, HIGH);
|
||||
delay(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief: set the look-up tables
|
||||
*/
|
||||
void Epd::SetLut(void) {
|
||||
unsigned int count;
|
||||
SendCommand(LUT_FOR_VCOM); //vcom
|
||||
for(count = 0; count < 44; count++) {
|
||||
SendData(lut_vcom_dc[count]);
|
||||
}
|
||||
|
||||
SendCommand(LUT_WHITE_TO_WHITE); //ww --
|
||||
for(count = 0; count < 42; count++) {
|
||||
SendData(lut_ww[count]);
|
||||
}
|
||||
|
||||
SendCommand(LUT_BLACK_TO_WHITE); //bw r
|
||||
for(count = 0; count < 42; count++) {
|
||||
SendData(lut_bw[count]);
|
||||
}
|
||||
|
||||
SendCommand(LUT_WHITE_TO_BLACK); //wb w
|
||||
for(count = 0; count < 42; count++) {
|
||||
SendData(lut_bb[count]);
|
||||
}
|
||||
|
||||
SendCommand(LUT_BLACK_TO_BLACK); //bb b
|
||||
for(count = 0; count < 42; count++) {
|
||||
SendData(lut_wb[count]);
|
||||
}
|
||||
}
|
||||
|
||||
void Epd::gray_SetLut(void)
|
||||
{
|
||||
unsigned int count;
|
||||
SendCommand(LUT_FOR_VCOM); //vcom
|
||||
for(count=0;count<44;count++)
|
||||
{SendData(EPD_2in7_gray_lut_vcom[count]);}
|
||||
|
||||
SendCommand(LUT_WHITE_TO_WHITE); //red not use
|
||||
for(count=0;count<42;count++)
|
||||
{SendData(EPD_2in7_gray_lut_ww[count]);}
|
||||
|
||||
SendCommand(LUT_BLACK_TO_WHITE); //bw r
|
||||
for(count=0;count<42;count++)
|
||||
{SendData(EPD_2in7_gray_lut_bw[count]);}
|
||||
|
||||
SendCommand(LUT_WHITE_TO_BLACK); //wb w
|
||||
for(count=0;count<42;count++)
|
||||
{SendData(EPD_2in7_gray_lut_wb[count]);}
|
||||
|
||||
SendCommand(LUT_BLACK_TO_BLACK); //bb b
|
||||
for(count=0;count<42;count++)
|
||||
{SendData(EPD_2in7_gray_lut_bb[count]);}
|
||||
|
||||
SendCommand(0x25); //vcom
|
||||
for(count=0;count<42;count++)
|
||||
{SendData(EPD_2in7_gray_lut_ww[count]);}
|
||||
|
||||
}
|
||||
/**
|
||||
* @brief: transmit partial data to the SRAM
|
||||
*/
|
||||
void Epd::TransmitPartialData(const unsigned char* buffer, int x, int y, int w, int l) {
|
||||
if (buffer != NULL) {
|
||||
SendCommand(PARTIAL_DATA_START_TRANSMISSION_2);
|
||||
SendData(x >> 8);
|
||||
SendData(x & 0xf8); // x should be the multiple of 8, the last 3 bit will always be ignored
|
||||
SendData(y >> 8);
|
||||
SendData(y & 0xff);
|
||||
SendData(w >> 8);
|
||||
SendData(w & 0xf8); // w (EPD_WIDTH) should be the multiple of 8, the last 3 bit will always be ignored
|
||||
SendData(l >> 8);
|
||||
SendData(l & 0xff);
|
||||
delay(2);
|
||||
for(int i = 0; i < w / 8 * l; i++) {
|
||||
SendData(buffer[i]);
|
||||
}
|
||||
delay(2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief: refreshes a specific part of the display
|
||||
*/
|
||||
void Epd::RefreshPartial(int x, int y, int w, int l) {
|
||||
SendCommand(PARTIAL_DISPLAY_REFRESH);
|
||||
SendData(x >> 8);
|
||||
SendData(x & 0xf8); // x should be the multiple of 8, the last 3 bit will always be ignored
|
||||
SendData(y >> 8);
|
||||
SendData(y & 0xff);
|
||||
SendData(w >> 8);
|
||||
SendData(w & 0xf8); // w (EPD_WIDTH) should be the multiple of 8, the last 3 bit will always be ignored
|
||||
SendData(l >> 8);
|
||||
SendData(l & 0xff);
|
||||
|
||||
WaitUntilIdle();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief: refresh and displays the frame
|
||||
*/
|
||||
void Epd::DisplayFrame(const unsigned char* frame_buffer) {
|
||||
if (frame_buffer != NULL) {
|
||||
SendCommand(DATA_START_TRANSMISSION_1);
|
||||
delay(2);
|
||||
for(int i = 0; i < 5808; i++) {
|
||||
SendData(0xff);
|
||||
}
|
||||
delay(2);
|
||||
SendCommand(DATA_START_TRANSMISSION_2);
|
||||
delay(2);
|
||||
for(int i = 0; i < 5808; i++) {
|
||||
SendData(frame_buffer[i]);
|
||||
}
|
||||
delay(2);
|
||||
|
||||
SendCommand(DISPLAY_REFRESH);
|
||||
delay(200);
|
||||
WaitUntilIdle();
|
||||
}
|
||||
}
|
||||
|
||||
void Epd::Display4Gray(const unsigned char *Image)
|
||||
{
|
||||
int i,j,k;
|
||||
unsigned char temp1,temp2,temp3;
|
||||
|
||||
SendCommand(DATA_START_TRANSMISSION_1);
|
||||
for(i=0;i<5808;i++) //5808*4 46464
|
||||
{
|
||||
temp3=0;
|
||||
for(j=0;j<2;j++)
|
||||
{
|
||||
temp1 = Image[i*2+j];
|
||||
for(k=0;k<2;k++)
|
||||
{
|
||||
temp2 = temp1&0xC0 ;
|
||||
if(temp2 == 0xC0)
|
||||
temp3 |= 0x01;//white
|
||||
else if(temp2 == 0x00)
|
||||
temp3 |= 0x00; //black
|
||||
else if(temp2 == 0x80)
|
||||
temp3 |= 0x01; //gray1
|
||||
else //0x40
|
||||
temp3 |= 0x00; //gray2
|
||||
temp3 <<= 1;
|
||||
|
||||
temp1 <<= 2;
|
||||
temp2 = temp1&0xC0 ;
|
||||
if(temp2 == 0xC0) //white
|
||||
temp3 |= 0x01;
|
||||
else if(temp2 == 0x00) //black
|
||||
temp3 |= 0x00;
|
||||
else if(temp2 == 0x80)
|
||||
temp3 |= 0x01; //gray1
|
||||
else //0x40
|
||||
temp3 |= 0x00; //gray2
|
||||
if(j!=1 || k!=1)
|
||||
temp3 <<= 1;
|
||||
|
||||
temp1 <<= 2;
|
||||
}
|
||||
|
||||
}
|
||||
SendData(temp3);
|
||||
}
|
||||
// new data
|
||||
SendCommand(DATA_START_TRANSMISSION_2);
|
||||
for(i=0;i<5808;i++) //5808*4 46464
|
||||
{
|
||||
temp3=0;
|
||||
for(j=0;j<2;j++)
|
||||
{
|
||||
temp1 = Image[i*2+j];
|
||||
for(k=0;k<2;k++)
|
||||
{
|
||||
temp2 = temp1&0xC0 ;
|
||||
if(temp2 == 0xC0)
|
||||
temp3 |= 0x01;//white
|
||||
else if(temp2 == 0x00)
|
||||
temp3 |= 0x00; //black
|
||||
else if(temp2 == 0x80)
|
||||
temp3 |= 0x00; //gray1
|
||||
else //0x40
|
||||
temp3 |= 0x01; //gray2
|
||||
temp3 <<= 1;
|
||||
|
||||
temp1 <<= 2;
|
||||
temp2 = temp1&0xC0 ;
|
||||
if(temp2 == 0xC0) //white
|
||||
temp3 |= 0x01;
|
||||
else if(temp2 == 0x00) //black
|
||||
temp3 |= 0x00;
|
||||
else if(temp2 == 0x80)
|
||||
temp3 |= 0x00; //gray1
|
||||
else //0x40
|
||||
temp3 |= 0x01; //gray2
|
||||
if(j!=1 || k!=1)
|
||||
temp3 <<= 1;
|
||||
|
||||
temp1 <<= 2;
|
||||
}
|
||||
|
||||
}
|
||||
SendData(temp3);
|
||||
}
|
||||
|
||||
gray_SetLut();
|
||||
SendCommand(DISPLAY_REFRESH);
|
||||
delay(200);
|
||||
WaitUntilIdle();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief: clear the frame data from the SRAM, this won't refresh the display
|
||||
*/
|
||||
void Epd::ClearFrame(void) {
|
||||
SendCommand(DATA_START_TRANSMISSION_1);
|
||||
delay(2);
|
||||
for(int i = 0; i < EPD_WIDTH * EPD_HEIGHT / 8; i++) {
|
||||
SendData(0xFF);
|
||||
}
|
||||
delay(2);
|
||||
SendCommand(DATA_START_TRANSMISSION_2);
|
||||
delay(2);
|
||||
for(int i = 0; i < EPD_WIDTH * EPD_HEIGHT / 8; i++) {
|
||||
SendData(0xFF);
|
||||
}
|
||||
delay(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief: This displays the frame data from SRAM
|
||||
*/
|
||||
void Epd::DisplayFrame(void) {
|
||||
SendCommand(DISPLAY_REFRESH);
|
||||
delay(200);
|
||||
WaitUntilIdle();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief: After this command is transmitted, the chip would enter the deep-sleep mode to save power.
|
||||
* The deep sleep mode would return to standby by hardware reset. The only one parameter is a
|
||||
* check code, the command would be executed if check code = 0xA5.
|
||||
* You can use Epd::Reset() to awaken and use Epd::Init() to initialize.
|
||||
*/
|
||||
void Epd::Sleep() {
|
||||
SendCommand(DEEP_SLEEP);
|
||||
SendData(0xa5);
|
||||
}
|
||||
|
||||
const unsigned char lut_vcom_dc[] = {
|
||||
0x00, 0x00,
|
||||
0x00, 0x0F, 0x0F, 0x00, 0x00, 0x05,
|
||||
0x00, 0x32, 0x32, 0x00, 0x00, 0x02,
|
||||
0x00, 0x0F, 0x0F, 0x00, 0x00, 0x05,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
//R21H
|
||||
const unsigned char lut_ww[] = {
|
||||
0x50, 0x0F, 0x0F, 0x00, 0x00, 0x05,
|
||||
0x60, 0x32, 0x32, 0x00, 0x00, 0x02,
|
||||
0xA0, 0x0F, 0x0F, 0x00, 0x00, 0x05,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
//R22H r
|
||||
const unsigned char lut_bw[] =
|
||||
{
|
||||
0x50, 0x0F, 0x0F, 0x00, 0x00, 0x05,
|
||||
0x60, 0x32, 0x32, 0x00, 0x00, 0x02,
|
||||
0xA0, 0x0F, 0x0F, 0x00, 0x00, 0x05,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
//R24H b
|
||||
const unsigned char lut_bb[] =
|
||||
{
|
||||
0xA0, 0x0F, 0x0F, 0x00, 0x00, 0x05,
|
||||
0x60, 0x32, 0x32, 0x00, 0x00, 0x02,
|
||||
0x50, 0x0F, 0x0F, 0x00, 0x00, 0x05,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
//R23H w
|
||||
const unsigned char lut_wb[] =
|
||||
{
|
||||
0xA0, 0x0F, 0x0F, 0x00, 0x00, 0x05,
|
||||
0x60, 0x32, 0x32, 0x00, 0x00, 0x02,
|
||||
0x50, 0x0F, 0x0F, 0x00, 0x00, 0x05,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
118
epd2in7.h
118
epd2in7.h
@ -1,118 +0,0 @@
|
||||
/**
|
||||
* @filename : epd2in7.h
|
||||
* @brief : Header file for e-paper library epd2in7.cpp
|
||||
* @author : Yehui from Waveshare
|
||||
*
|
||||
* Copyright (C) Waveshare August 10 2017
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documnetation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EPD2IN7_H
|
||||
#define EPD2IN7_H
|
||||
|
||||
// Display resolution
|
||||
#define EPD_WIDTH 176
|
||||
#define EPD_HEIGHT 264
|
||||
|
||||
// Hardware pins
|
||||
#define DC_PIN 25
|
||||
#define CS_PIN 26
|
||||
#define BUSY_PIN 27
|
||||
#define RST_PIN 33
|
||||
|
||||
// EPD2IN7 commands
|
||||
#define PANEL_SETTING 0x00
|
||||
#define POWER_SETTING 0x01
|
||||
#define POWER_OFF 0x02
|
||||
#define POWER_OFF_SEQUENCE_SETTING 0x03
|
||||
#define POWER_ON 0x04
|
||||
#define POWER_ON_MEASURE 0x05
|
||||
#define BOOSTER_SOFT_START 0x06
|
||||
#define DEEP_SLEEP 0x07
|
||||
#define DATA_START_TRANSMISSION_1 0x10
|
||||
#define DATA_STOP 0x11
|
||||
#define DISPLAY_REFRESH 0x12
|
||||
#define DATA_START_TRANSMISSION_2 0x13
|
||||
#define PARTIAL_DATA_START_TRANSMISSION_1 0x14
|
||||
#define PARTIAL_DATA_START_TRANSMISSION_2 0x15
|
||||
#define PARTIAL_DISPLAY_REFRESH 0x16
|
||||
#define LUT_FOR_VCOM 0x20
|
||||
#define LUT_WHITE_TO_WHITE 0x21
|
||||
#define LUT_BLACK_TO_WHITE 0x22
|
||||
#define LUT_WHITE_TO_BLACK 0x23
|
||||
#define LUT_BLACK_TO_BLACK 0x24
|
||||
#define PLL_CONTROL 0x30
|
||||
#define TEMPERATURE_SENSOR_COMMAND 0x40
|
||||
#define TEMPERATURE_SENSOR_CALIBRATION 0x41
|
||||
#define TEMPERATURE_SENSOR_WRITE 0x42
|
||||
#define TEMPERATURE_SENSOR_READ 0x43
|
||||
#define VCOM_AND_DATA_INTERVAL_SETTING 0x50
|
||||
#define LOW_POWER_DETECTION 0x51
|
||||
#define TCON_SETTING 0x60
|
||||
#define TCON_RESOLUTION 0x61
|
||||
#define SOURCE_AND_GATE_START_SETTING 0x62
|
||||
#define GET_STATUS 0x71
|
||||
#define AUTO_MEASURE_VCOM 0x80
|
||||
#define VCOM_VALUE 0x81
|
||||
#define VCM_DC_SETTING_REGISTER 0x82
|
||||
#define PROGRAM_MODE 0xA0
|
||||
#define ACTIVE_PROGRAM 0xA1
|
||||
#define READ_OTP_DATA 0xA2
|
||||
|
||||
extern const unsigned char lut_vcom_dc[];
|
||||
extern const unsigned char lut_ww[];
|
||||
extern const unsigned char lut_bw[];
|
||||
extern const unsigned char lut_bb[];
|
||||
extern const unsigned char lut_wb[];
|
||||
|
||||
class Epd {
|
||||
public:
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
|
||||
Epd();
|
||||
~Epd();
|
||||
int Init(void);
|
||||
void SendCommand(unsigned char command);
|
||||
void SendData(unsigned char data);
|
||||
void WaitUntilIdle(void);
|
||||
void Reset(void);
|
||||
void SetLut(void);
|
||||
void TransmitPartialData(const unsigned char* buffer, int x, int y, int w, int l);
|
||||
void RefreshPartial(int x, int y, int w, int l);
|
||||
void DisplayFrame(const unsigned char* frame_buffer);
|
||||
void DisplayFrame(void);
|
||||
void ClearFrame(void);
|
||||
void Sleep(void);
|
||||
|
||||
void Init_4Gray(void);
|
||||
void gray_SetLut(void);
|
||||
void Display4Gray(const unsigned char *Image);
|
||||
|
||||
private:
|
||||
unsigned int reset_pin;
|
||||
unsigned int dc_pin;
|
||||
unsigned int cs_pin;
|
||||
unsigned int busy_pin;
|
||||
};
|
||||
|
||||
#endif /* EPD2IN7_H */
|
||||
|
||||
/* END OF FILE */
|
322
epdpaint.cpp
322
epdpaint.cpp
@ -1,322 +0,0 @@
|
||||
/**
|
||||
* @filename : epdpaint.cpp
|
||||
* @brief : Paint tools
|
||||
* @author : Yehui from Waveshare
|
||||
*
|
||||
* Copyright (C) Waveshare September 9 2017
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documnetation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "epdpaint.h"
|
||||
|
||||
Paint::Paint(unsigned char* image, int width, int height) {
|
||||
this->rotate = ROTATE_0;
|
||||
this->image = image;
|
||||
/* 1 byte = 8 pixels, so the width should be the multiple of 8 */
|
||||
this->width = width % 8 ? width + 8 - (width % 8) : width;
|
||||
this->height = height;
|
||||
}
|
||||
|
||||
Paint::~Paint() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief: clear the image
|
||||
*/
|
||||
void Paint::Clear(int colored) {
|
||||
for (int x = 0; x < this->width; x++) {
|
||||
for (int y = 0; y < this->height; y++) {
|
||||
DrawAbsolutePixel(x, y, colored);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief: this draws a pixel by absolute coordinates.
|
||||
* this function won't be affected by the rotate parameter.
|
||||
*/
|
||||
void Paint::DrawAbsolutePixel(int x, int y, int colored) {
|
||||
if (x < 0 || x >= this->width || y < 0 || y >= this->height) {
|
||||
return;
|
||||
}
|
||||
if (IF_INVERT_COLOR) {
|
||||
if (colored) {
|
||||
image[(x + y * this->width) / 8] |= 0x80 >> (x % 8);
|
||||
} else {
|
||||
image[(x + y * this->width) / 8] &= ~(0x80 >> (x % 8));
|
||||
}
|
||||
} else {
|
||||
if (colored) {
|
||||
image[(x + y * this->width) / 8] &= ~(0x80 >> (x % 8));
|
||||
} else {
|
||||
image[(x + y * this->width) / 8] |= 0x80 >> (x % 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief: Getters and Setters
|
||||
*/
|
||||
unsigned char* Paint::GetImage(void) {
|
||||
return this->image;
|
||||
}
|
||||
|
||||
int Paint::GetWidth(void) {
|
||||
return this->width;
|
||||
}
|
||||
|
||||
void Paint::SetWidth(int width) {
|
||||
this->width = width % 8 ? width + 8 - (width % 8) : width;
|
||||
}
|
||||
|
||||
int Paint::GetHeight(void) {
|
||||
return this->height;
|
||||
}
|
||||
|
||||
void Paint::SetHeight(int height) {
|
||||
this->height = height;
|
||||
}
|
||||
|
||||
int Paint::GetRotate(void) {
|
||||
return this->rotate;
|
||||
}
|
||||
|
||||
void Paint::SetRotate(int rotate){
|
||||
this->rotate = rotate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief: this draws a pixel by the coordinates
|
||||
*/
|
||||
void Paint::DrawPixel(int x, int y, int colored) {
|
||||
int point_temp;
|
||||
if (this->rotate == ROTATE_0) {
|
||||
if(x < 0 || x >= this->width || y < 0 || y >= this->height) {
|
||||
return;
|
||||
}
|
||||
DrawAbsolutePixel(x, y, colored);
|
||||
} else if (this->rotate == ROTATE_90) {
|
||||
if(x < 0 || x >= this->height || y < 0 || y >= this->width) {
|
||||
return;
|
||||
}
|
||||
point_temp = x;
|
||||
x = this->width - y;
|
||||
y = point_temp;
|
||||
DrawAbsolutePixel(x, y, colored);
|
||||
} else if (this->rotate == ROTATE_180) {
|
||||
if(x < 0 || x >= this->width || y < 0 || y >= this->height) {
|
||||
return;
|
||||
}
|
||||
x = this->width - x;
|
||||
y = this->height - y;
|
||||
DrawAbsolutePixel(x, y, colored);
|
||||
} else if (this->rotate == ROTATE_270) {
|
||||
if(x < 0 || x >= this->height || y < 0 || y >= this->width) {
|
||||
return;
|
||||
}
|
||||
point_temp = x;
|
||||
x = y;
|
||||
y = this->height - point_temp;
|
||||
DrawAbsolutePixel(x, y, colored);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief: this draws a charactor on the frame buffer but not refresh
|
||||
*/
|
||||
void Paint::DrawCharAt(int x, int y, char ascii_char, sFONT* font, int colored) {
|
||||
int i, j;
|
||||
unsigned int char_offset = (ascii_char - ' ') * font->Height * (font->Width / 8 + (font->Width % 8 ? 1 : 0));
|
||||
const unsigned char* ptr = &font->table[char_offset];
|
||||
|
||||
for (j = 0; j < font->Height; j++) {
|
||||
for (i = 0; i < font->Width; i++) {
|
||||
if (*ptr & (0x80 >> (i % 8))) {
|
||||
DrawPixel(x + i, y + j, colored);
|
||||
}
|
||||
if (i % 8 == 7) {
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
if (font->Width % 8 != 0) {
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief: this displays a string on the frame buffer but not refresh
|
||||
*/
|
||||
void Paint::DrawStringAt(int x, int y, const char* text, sFONT* font, int colored) {
|
||||
const char* p_text = text;
|
||||
unsigned int counter = 0;
|
||||
int refcolumn = x;
|
||||
|
||||
/* Send the string character by character on EPD */
|
||||
while (*p_text != 0) {
|
||||
/* Display one character on EPD */
|
||||
DrawCharAt(refcolumn, y, *p_text, font, colored);
|
||||
/* Decrement the column position by 16 */
|
||||
refcolumn += font->Width;
|
||||
/* Point on the next character */
|
||||
p_text++;
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief: this draws a line on the frame buffer
|
||||
*/
|
||||
void Paint::DrawLine(int x0, int y0, int x1, int y1, int colored) {
|
||||
/* Bresenham algorithm */
|
||||
int dx = x1 - x0 >= 0 ? x1 - x0 : x0 - x1;
|
||||
int sx = x0 < x1 ? 1 : -1;
|
||||
int dy = y1 - y0 <= 0 ? y1 - y0 : y0 - y1;
|
||||
int sy = y0 < y1 ? 1 : -1;
|
||||
int err = dx + dy;
|
||||
|
||||
while((x0 != x1) && (y0 != y1)) {
|
||||
DrawPixel(x0, y0 , colored);
|
||||
if (2 * err >= dy) {
|
||||
err += dy;
|
||||
x0 += sx;
|
||||
}
|
||||
if (2 * err <= dx) {
|
||||
err += dx;
|
||||
y0 += sy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief: this draws a horizontal line on the frame buffer
|
||||
*/
|
||||
void Paint::DrawHorizontalLine(int x, int y, int line_width, int colored) {
|
||||
int i;
|
||||
for (i = x; i < x + line_width; i++) {
|
||||
DrawPixel(i, y, colored);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief: this draws a vertical line on the frame buffer
|
||||
*/
|
||||
void Paint::DrawVerticalLine(int x, int y, int line_height, int colored) {
|
||||
int i;
|
||||
for (i = y; i < y + line_height; i++) {
|
||||
DrawPixel(x, i, colored);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief: this draws a rectangle
|
||||
*/
|
||||
void Paint::DrawRectangle(int x0, int y0, int x1, int y1, int colored) {
|
||||
int min_x, min_y, max_x, max_y;
|
||||
min_x = x1 > x0 ? x0 : x1;
|
||||
max_x = x1 > x0 ? x1 : x0;
|
||||
min_y = y1 > y0 ? y0 : y1;
|
||||
max_y = y1 > y0 ? y1 : y0;
|
||||
|
||||
DrawHorizontalLine(min_x, min_y, max_x - min_x + 1, colored);
|
||||
DrawHorizontalLine(min_x, max_y, max_x - min_x + 1, colored);
|
||||
DrawVerticalLine(min_x, min_y, max_y - min_y + 1, colored);
|
||||
DrawVerticalLine(max_x, min_y, max_y - min_y + 1, colored);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief: this draws a filled rectangle
|
||||
*/
|
||||
void Paint::DrawFilledRectangle(int x0, int y0, int x1, int y1, int colored) {
|
||||
int min_x, min_y, max_x, max_y;
|
||||
int i;
|
||||
min_x = x1 > x0 ? x0 : x1;
|
||||
max_x = x1 > x0 ? x1 : x0;
|
||||
min_y = y1 > y0 ? y0 : y1;
|
||||
max_y = y1 > y0 ? y1 : y0;
|
||||
|
||||
for (i = min_x; i <= max_x; i++) {
|
||||
DrawVerticalLine(i, min_y, max_y - min_y + 1, colored);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief: this draws a circle
|
||||
*/
|
||||
void Paint::DrawCircle(int x, int y, int radius, int colored) {
|
||||
/* Bresenham algorithm */
|
||||
int x_pos = -radius;
|
||||
int y_pos = 0;
|
||||
int err = 2 - 2 * radius;
|
||||
int e2;
|
||||
|
||||
do {
|
||||
DrawPixel(x - x_pos, y + y_pos, colored);
|
||||
DrawPixel(x + x_pos, y + y_pos, colored);
|
||||
DrawPixel(x + x_pos, y - y_pos, colored);
|
||||
DrawPixel(x - x_pos, y - y_pos, colored);
|
||||
e2 = err;
|
||||
if (e2 <= y_pos) {
|
||||
err += ++y_pos * 2 + 1;
|
||||
if(-x_pos == y_pos && e2 <= x_pos) {
|
||||
e2 = 0;
|
||||
}
|
||||
}
|
||||
if (e2 > x_pos) {
|
||||
err += ++x_pos * 2 + 1;
|
||||
}
|
||||
} while (x_pos <= 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief: this draws a filled circle
|
||||
*/
|
||||
void Paint::DrawFilledCircle(int x, int y, int radius, int colored) {
|
||||
/* Bresenham algorithm */
|
||||
int x_pos = -radius;
|
||||
int y_pos = 0;
|
||||
int err = 2 - 2 * radius;
|
||||
int e2;
|
||||
|
||||
do {
|
||||
DrawPixel(x - x_pos, y + y_pos, colored);
|
||||
DrawPixel(x + x_pos, y + y_pos, colored);
|
||||
DrawPixel(x + x_pos, y - y_pos, colored);
|
||||
DrawPixel(x - x_pos, y - y_pos, colored);
|
||||
DrawHorizontalLine(x + x_pos, y + y_pos, 2 * (-x_pos) + 1, colored);
|
||||
DrawHorizontalLine(x + x_pos, y - y_pos, 2 * (-x_pos) + 1, colored);
|
||||
e2 = err;
|
||||
if (e2 <= y_pos) {
|
||||
err += ++y_pos * 2 + 1;
|
||||
if(-x_pos == y_pos && e2 <= x_pos) {
|
||||
e2 = 0;
|
||||
}
|
||||
}
|
||||
if(e2 > x_pos) {
|
||||
err += ++x_pos * 2 + 1;
|
||||
}
|
||||
} while(x_pos <= 0);
|
||||
}
|
||||
|
||||
/* END OF FILE */
|
||||
|
||||
|
||||
|
||||
|
75
epdpaint.h
75
epdpaint.h
@ -1,75 +0,0 @@
|
||||
/**
|
||||
* @filename : epdpaint.h
|
||||
* @brief : Header file for epdpaint.cpp
|
||||
* @author : Yehui from Waveshare
|
||||
*
|
||||
* Copyright (C) Waveshare July 28 2017
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documnetation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EPDPAINT_H
|
||||
#define EPDPAINT_H
|
||||
|
||||
// Display orientation
|
||||
#define ROTATE_0 0
|
||||
#define ROTATE_90 1
|
||||
#define ROTATE_180 2
|
||||
#define ROTATE_270 3
|
||||
|
||||
// Color inverse. 1 or 0 = set or reset a bit if set a colored pixel
|
||||
#define IF_INVERT_COLOR 1
|
||||
|
||||
#include "fonts.h"
|
||||
|
||||
class Paint {
|
||||
public:
|
||||
Paint(unsigned char* image, int width, int height);
|
||||
~Paint();
|
||||
void Clear(int colored);
|
||||
int GetWidth(void);
|
||||
void SetWidth(int width);
|
||||
int GetHeight(void);
|
||||
void SetHeight(int height);
|
||||
int GetRotate(void);
|
||||
void SetRotate(int rotate);
|
||||
unsigned char* GetImage(void);
|
||||
void DrawAbsolutePixel(int x, int y, int colored);
|
||||
void DrawPixel(int x, int y, int colored);
|
||||
void DrawCharAt(int x, int y, char ascii_char, sFONT* font, int colored);
|
||||
void DrawStringAt(int x, int y, const char* text, sFONT* font, int colored);
|
||||
void DrawLine(int x0, int y0, int x1, int y1, int colored);
|
||||
void DrawHorizontalLine(int x, int y, int width, int colored);
|
||||
void DrawVerticalLine(int x, int y, int height, int colored);
|
||||
void DrawRectangle(int x0, int y0, int x1, int y1, int colored);
|
||||
void DrawFilledRectangle(int x0, int y0, int x1, int y1, int colored);
|
||||
void DrawCircle(int x, int y, int radius, int colored);
|
||||
void DrawFilledCircle(int x, int y, int radius, int colored);
|
||||
|
||||
private:
|
||||
unsigned char* image;
|
||||
int width;
|
||||
int height;
|
||||
int rotate;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/* END OF FILE */
|
||||
|
1384
font12.cpp
1384
font12.cpp
File diff suppressed because it is too large
Load Diff
1764
font16.cpp
1764
font16.cpp
File diff suppressed because it is too large
Load Diff
2142
font20.cpp
2142
font20.cpp
File diff suppressed because it is too large
Load Diff
2520
font24.cpp
2520
font24.cpp
File diff suppressed because it is too large
Load Diff
65
fonts.h
65
fonts.h
@ -1,65 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file fonts.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.0.0
|
||||
* @date 18-February-2014
|
||||
* @brief Header for fonts.c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __FONTS_H
|
||||
#define __FONTS_H
|
||||
|
||||
/* Max size of bitmap will based on a font24 (17x24) */
|
||||
#define MAX_HEIGHT_FONT 24
|
||||
#define MAX_WIDTH_FONT 17
|
||||
#define OFFSET_BITMAP 54
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include <stdint.h>
|
||||
|
||||
struct sFONT {
|
||||
const uint8_t *table;
|
||||
uint16_t Width;
|
||||
uint16_t Height;
|
||||
};
|
||||
|
||||
extern sFONT Font24;
|
||||
extern sFONT Font20;
|
||||
extern sFONT Font16;
|
||||
extern sFONT Font12;
|
||||
extern sFONT Font8;
|
||||
|
||||
#endif /* __FONTS_H */
|
||||
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@ -1,81 +0,0 @@
|
||||
#include <HTTPClient.h>
|
||||
|
||||
String textBeginString = "@";
|
||||
String textEndString = "@";
|
||||
String lehrTextBeginString = "@@";
|
||||
String sourceBeginString = "@";
|
||||
String sourceEndString = "@";
|
||||
String url = "https://www.losungen.de/fileadmin/media-losungen/kalender/kalender_daten.php";
|
||||
|
||||
String getHTML(String url, String post_params) {
|
||||
String result = "";
|
||||
if(WiFi.status() == WL_CONNECTED) {
|
||||
HTTPClient http;
|
||||
http.begin(url); // initialize the http instance
|
||||
http.addHeader("Content-Type", "application/x-www-form-urlencoded"); // add the header; needed for the POST request
|
||||
Serial.printf("[HTTP] POST %s | DATA: %s\n", url.c_str(), post_params.c_str());
|
||||
int httpCode = http.POST(post_params); // get the page; httpCode will be negative on error
|
||||
|
||||
if(httpCode > 0) {
|
||||
// HTTP header has been send and Server response header has been handled
|
||||
Serial.printf("[HTTP] POST %d: %s\n", httpCode, url.c_str());
|
||||
|
||||
// file found at server
|
||||
if(httpCode == HTTP_CODE_OK) {
|
||||
result = http.getString();
|
||||
}
|
||||
} else {
|
||||
Serial.printf("[HTTP] POST: %s\n", http.errorToString(httpCode).c_str());
|
||||
}
|
||||
|
||||
http.end();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
String getHTML() { // gets the date and year from time.h library
|
||||
struct tm timeinfo;
|
||||
char dayInYear[4];
|
||||
char year[5];
|
||||
|
||||
if(!getLocalTime(&timeinfo)){
|
||||
Serial.println("Failed to obtain time");
|
||||
return "";
|
||||
}
|
||||
sprintf(dayInYear,"%d",timeinfo.tm_yday+1);
|
||||
strftime(year,5, "%Y", &timeinfo);
|
||||
|
||||
String post_params = "jahr=" + String(year) + "&tagid=" + String(dayInYear); // create post parameters of the form "jahr=YYYY&tagid=III" where III is the day in the year
|
||||
return getHTML(url, post_params);
|
||||
}
|
||||
|
||||
String getLosungFromHTML(String html) {
|
||||
int losungBeginIndex = html.indexOf(textBeginString)+textBeginString.length();
|
||||
int losungEndIndex = html.indexOf(textEndString,losungBeginIndex);
|
||||
|
||||
return html.substring(losungBeginIndex, losungEndIndex);
|
||||
}
|
||||
|
||||
String getLosungSourceFromHTML(String html) { // get the source of losung in given html
|
||||
String losung = getLosungFromHTML(html);
|
||||
int losungIndex = html.indexOf(losung);
|
||||
int losungSourceBeginIndex = html.indexOf(sourceBeginString, losungIndex)+sourceBeginString.length();
|
||||
int losungSourceEndIndex = html.indexOf(sourceEndString, losungIndex+losung.length()+sourceBeginString.length());
|
||||
|
||||
return html.substring(losungSourceBeginIndex, losungSourceEndIndex);
|
||||
}
|
||||
|
||||
String getLehrtextFromHTML(String html) {
|
||||
int lehrtextBeginIndex = html.indexOf(lehrTextBeginString)+lehrTextBeginString.length();
|
||||
int lehrtextEndIndex = html.indexOf(textEndString, lehrtextBeginIndex); // calculating is needed for better performance and to get the next index, not the current/previous
|
||||
|
||||
return html.substring(lehrtextBeginIndex, lehrtextEndIndex);
|
||||
}
|
||||
|
||||
String getLehrtextSourceFromHTML(String html) { // get the source of losung in given html
|
||||
String lehrtext = getLehrtextFromHTML(html);
|
||||
int lehrtextIndex = html.indexOf(lehrtext);
|
||||
int lehrtextSourceBeginIndex = html.indexOf(sourceBeginString, lehrtextIndex)+sourceBeginString.length();
|
||||
int lehrtextSourceEndIndex = html.indexOf(sourceEndString, lehrtextSourceBeginIndex); // calculating is needed for better performance and to get the next index, not the current/previous
|
||||
|
||||
return html.substring(lehrtextSourceBeginIndex, lehrtextSourceEndIndex);
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
#include "epd2in7.h"
|
||||
#include "epdpaint.h"
|
||||
|
||||
// b/w e-Paper
|
||||
#define COLORED 0
|
||||
#define UNCOLORED 1
|
||||
|
||||
Epd epd;
|
||||
uint64_t us_s_conversion_factor = 1000*1000; // conversion factor for s to µs
|
||||
uint64_t DEEP_SLEEP_TIME = 6*60*60; // time to deep sleep in microseconds (not milliseconds!)
|
||||
|
||||
// WiFi
|
||||
char wiFiSSID[] = "SSID"; // SSID of your network
|
||||
char wiFiPSK[] = "PRE-SHARED KEY"; //password of your WPA Network
|
||||
|
||||
// NTP (Network Time Protocol)
|
||||
const String ntpServer = "pool.ntp.org"; // address of ntp server; may also be your router, other local service, etc.
|
||||
const long gmtOffset_sec = 3600; // for localization (gmt = greenwich mean time); in germany: 3600
|
||||
const int daylightOffset_sec = 3600; // for daylight saving
|
||||
|
||||
// onboard LED
|
||||
const int LED_ON_WIFI_ERROR = 2;
|
||||
|
||||
// style of the frame shown
|
||||
sFONT TITLE_FONT = Font20;
|
||||
char TITLE_TEXT[] = "Losung heute";
|
||||
int TITLE_PADDING_TOP = 10;
|
||||
sFONT TEXT_FONT = Font12; // for the daily text
|
||||
int TEXT_WIDTH = 168; // width of the box around the text; should be a multiple of the width of the font (eg. Font8 => multiple of 8)
|
||||
int TEXT_PADDING_TOP = 20;
|
||||
int TEXT_PADDING_BETWEEN_BLOCKS = 20; // pixels between the lines
|
||||
int TEXT_PADDING_BETWEEN_LINES = 1; // pixels between the lines
|
||||
sFONT SOURCE_FONT = Font8; // for the position in bible
|
||||
|
||||
void deepSleep() {
|
||||
// deep sleep for DEEP_SLEEP_TIME seconds
|
||||
esp_sleep_enable_timer_wakeup(DEEP_SLEEP_TIME*us_s_conversion_factor);
|
||||
Serial.printf("[ESP32] Entering deep sleep mode for %ds\n", DEEP_SLEEP_TIME);
|
||||
esp_deep_sleep_start();
|
||||
}
|
||||
|
||||
bool gotLosung = false; // if everything worked and http get returned HTTP 200
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(115200);
|
||||
|
||||
Serial.println("[INFO] Initializing e-Paper...");
|
||||
if (epd.Init() != 0) {
|
||||
Serial.println("[FATAL] Failed initializing e-Paper; Exiting...");
|
||||
return;
|
||||
}
|
||||
Serial.println("[INFO] Initialized e-Paper!");
|
||||
|
||||
if(connectWiFi()) {
|
||||
Serial.println("[NTP] Getting time...");
|
||||
configTime(gmtOffset_sec, daylightOffset_sec, ntpServer.c_str());
|
||||
Serial.println("[NTP] Got time.");
|
||||
}
|
||||
String html = getHTML();
|
||||
if(html != "") gotLosung = true;
|
||||
|
||||
if(gotLosung) {
|
||||
showDailyText(getLosungFromHTML(html), getLehrtextFromHTML(html), getLosungSourceFromHTML(html), getLehrtextSourceFromHTML(html));
|
||||
deepSleep();
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if(!gotLosung) {
|
||||
if(connectWiFi()) {
|
||||
Serial.println("[NTP] Getting time...");
|
||||
configTime(gmtOffset_sec, daylightOffset_sec, ntpServer.c_str());
|
||||
Serial.println("[NTP] Got time.");
|
||||
}
|
||||
|
||||
String html = getHTML();
|
||||
if(html != "") gotLosung = true;
|
||||
|
||||
if(gotLosung) {
|
||||
showDailyText(getLosungFromHTML(html), getLehrtextFromHTML(html), getLosungSourceFromHTML(html), getLehrtextSourceFromHTML(html));
|
||||
deepSleep();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
ESPThis is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to http://unlicense.org/
|
@ -1,60 +0,0 @@
|
||||
# Losungepaper
|
||||
|
||||
## Whats this?
|
||||
|
||||
A ESP32-based Daily-Texts display on an e-Paper 2.7".
|
||||
The only language currently supported is German.
|
||||
Supported e-Paper display: 2.7inch e-Paper HAT of Waveshare
|
||||
|
||||
## How it works
|
||||
|
||||
1. The ESP32 connects to WiFi (for configuration, see Section "Install")
|
||||
2. It connects to an NTP (Network Time Protocol) Server, and grabs the date
|
||||
3. It gets today's daily text (in german) over HTTP GET. The URL format is:
|
||||
```
|
||||
https://www.losungen.de/fileadmin/media-losungen/heute/YYYY/MMDD.html
|
||||
```
|
||||
4. Then the HTML page is parsed and the daily text is being formatted for displaying.
|
||||
5. The texts get rendered on the e-Paper.
|
||||
6. The ESP32 goes into deep sleep mode.
|
||||
|
||||
## Install
|
||||
|
||||
First, clone the repo. After this is done, open it in Arduino IDE and change some variables:
|
||||
- wiFiPSK
|
||||
- wiFiSSID
|
||||
|
||||
to your WiFi Preshared Key (often just referred to as Passphrase) and the WiFi SSID.
|
||||
|
||||
Then, the whole project can be uploaded by pressing on the upload button (arrow pointing to the right)
|
||||
|
||||
## Librarys used
|
||||
- **epdpaint.h**, **epd2in7.h** by Yehui from Waveshare
|
||||
- **fonts.h** by MCD Application Team; COPYRIGHT(c) 2014 STMicroelectronics
|
||||
- ...and many librarys of the Arduino Project (e.g **Arduino.h**), and others (e.g. **stdint.h**)
|
||||
|
||||
# License
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to <http://unlicense.org/>
|
38
wifi.ino
38
wifi.ino
@ -1,38 +0,0 @@
|
||||
#include <WiFi.h>
|
||||
#include "time.h"
|
||||
|
||||
void blinkLED(int pin) {
|
||||
pinMode(pin, OUTPUT);
|
||||
delay(500);
|
||||
digitalWrite(pin,HIGH);
|
||||
delay(500);
|
||||
digitalWrite(pin,LOW);
|
||||
delay(500);
|
||||
digitalWrite(pin,HIGH);
|
||||
delay(500);
|
||||
digitalWrite(pin,LOW);
|
||||
}
|
||||
|
||||
bool connectWiFi() { // connect to the wifi with the above defined credentials
|
||||
if(WiFi.status() == WL_CONNECTED) { return true; } // return if not connected
|
||||
|
||||
Serial.print("[WiFi] Connecting to WiFi...");
|
||||
|
||||
WiFi.begin(wiFiSSID, wiFiPSK);
|
||||
while(WiFi.status() != WL_CONNECTED) {
|
||||
delay(2000); Serial.printf(".");
|
||||
if(WiFi.status() == WL_NO_SSID_AVAIL) {
|
||||
Serial.printf("\n[WiFi] Failed to connect to WiFi \"%s\". Reason: WL_NO_SSID_AVAIL\n", wiFiSSID);
|
||||
blinkLED(LED_ON_WIFI_ERROR);
|
||||
return false;
|
||||
} else if(WiFi.status() == WL_CONNECT_FAILED) {
|
||||
Serial.printf("\n[WiFi] Failed to connect to WiFi \"%s\". Reason: WL_CONNECT_FAILED\n", wiFiSSID);
|
||||
blinkLED(LED_ON_WIFI_ERROR);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Serial.printf("\n[WiFi] Connected to WiFi \"%s\", got IP-Adress ", wiFiSSID);
|
||||
Serial.println(WiFi.localIP());
|
||||
|
||||
return true;
|
||||
}
|
Loading…
Reference in New Issue
Block a user