writer over half
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
#ifndef __utility/EPD_H_
|
#ifndef __EPD_H_
|
||||||
#define __utility/EPD_H_
|
#define __EPD_H_
|
||||||
|
|
||||||
#include "Debug.h"
|
#include "Debug.h"
|
||||||
#include "EPD_7in5_V2.h"
|
#include "EPD_7in5_V2.h"
|
||||||
|
|||||||
@@ -91,6 +91,8 @@ void Paint_NewImage(UBYTE *image, UWORD Width, UWORD Height, UWORD Rotate, UWORD
|
|||||||
|
|
||||||
Paint.WidthMemory = Width;
|
Paint.WidthMemory = Width;
|
||||||
Paint.HeightMemory = Height;
|
Paint.HeightMemory = Height;
|
||||||
|
Paint.WidthOffset = 0;
|
||||||
|
Paint.HeightOffset = 0;
|
||||||
Paint.Color = Color;
|
Paint.Color = Color;
|
||||||
Paint.Scale = 2;
|
Paint.Scale = 2;
|
||||||
Paint.WidthByte = (Width % 8 == 0)? (Width / 8 ): (Width / 8 + 1);
|
Paint.WidthByte = (Width % 8 == 0)? (Width / 8 ): (Width / 8 + 1);
|
||||||
@@ -174,8 +176,10 @@ parameter:
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
void Paint_SetPixel(UWORD Xpoint, UWORD Ypoint, UWORD Color)
|
void Paint_SetPixel(UWORD Xpoint, UWORD Ypoint, UWORD Color)
|
||||||
{
|
{
|
||||||
|
Xpoint = Xpoint < Paint.WidthOffset ? 0xffff : Xpoint - Paint.WidthOffset ;
|
||||||
|
Ypoint = Ypoint < Paint.HeightOffset ? 0xffff : Ypoint - Paint.HeightOffset;
|
||||||
if(Xpoint > Paint.Width || Ypoint > Paint.Height){
|
if(Xpoint > Paint.Width || Ypoint > Paint.Height){
|
||||||
Debug("Exceeding display boundaries\r\n");
|
//Debug("Exceeding display boundaries\r\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
UWORD X, Y;
|
UWORD X, Y;
|
||||||
@@ -285,10 +289,10 @@ parameter:
|
|||||||
void Paint_DrawPoint(UWORD Xpoint, UWORD Ypoint, UWORD Color,
|
void Paint_DrawPoint(UWORD Xpoint, UWORD Ypoint, UWORD Color,
|
||||||
DOT_PIXEL Dot_Pixel, DOT_STYLE Dot_Style)
|
DOT_PIXEL Dot_Pixel, DOT_STYLE Dot_Style)
|
||||||
{
|
{
|
||||||
if (Xpoint > Paint.Width || Ypoint > Paint.Height) {
|
// if (Xpoint > Paint.Width || Ypoint > Paint.Height) {
|
||||||
Debug("Paint_DrawPoint Input exceeds the normal display range\r\n");
|
// Debug("Paint_DrawPoint Input exceeds the normal display range\r\n");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
int16_t XDir_Num , YDir_Num;
|
int16_t XDir_Num , YDir_Num;
|
||||||
if (Dot_Style == DOT_FILL_AROUND) {
|
if (Dot_Style == DOT_FILL_AROUND) {
|
||||||
@@ -323,11 +327,11 @@ parameter:
|
|||||||
void Paint_DrawLine(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend,
|
void Paint_DrawLine(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend,
|
||||||
UWORD Color, DOT_PIXEL Line_width, LINE_STYLE Line_Style)
|
UWORD Color, DOT_PIXEL Line_width, LINE_STYLE Line_Style)
|
||||||
{
|
{
|
||||||
if (Xstart > Paint.Width || Ystart > Paint.Height ||
|
// if (Xstart > Paint.Width || Ystart > Paint.Height ||
|
||||||
Xend > Paint.Width || Yend > Paint.Height) {
|
// Xend > Paint.Width || Yend > Paint.Height) {
|
||||||
Debug("Paint_DrawLine Input exceeds the normal display range\r\n");
|
// Debug("Paint_DrawLine Input exceeds the normal display range\r\n");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
UWORD Xpoint = Xstart;
|
UWORD Xpoint = Xstart;
|
||||||
UWORD Ypoint = Ystart;
|
UWORD Ypoint = Ystart;
|
||||||
@@ -381,11 +385,11 @@ parameter:
|
|||||||
void Paint_DrawRectangle(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend,
|
void Paint_DrawRectangle(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend,
|
||||||
UWORD Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill)
|
UWORD Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill)
|
||||||
{
|
{
|
||||||
if (Xstart > Paint.Width || Ystart > Paint.Height ||
|
// if (Xstart > Paint.Width || Ystart > Paint.Height ||
|
||||||
Xend > Paint.Width || Yend > Paint.Height) {
|
// Xend > Paint.Width || Yend > Paint.Height) {
|
||||||
Debug("Input exceeds the normal display range\r\n");
|
// Debug("Input exceeds the normal display range\r\n");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (Draw_Fill) {
|
if (Draw_Fill) {
|
||||||
UWORD Ypoint;
|
UWORD Ypoint;
|
||||||
@@ -414,10 +418,10 @@ parameter:
|
|||||||
void Paint_DrawCircle(UWORD X_Center, UWORD Y_Center, UWORD Radius,
|
void Paint_DrawCircle(UWORD X_Center, UWORD Y_Center, UWORD Radius,
|
||||||
UWORD Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill)
|
UWORD Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill)
|
||||||
{
|
{
|
||||||
if (X_Center > Paint.Width || Y_Center >= Paint.Height) {
|
// if (X_Center > Paint.Width || Y_Center >= Paint.Height) {
|
||||||
Debug("Paint_DrawCircle Input exceeds the normal display range\r\n");
|
// Debug("Paint_DrawCircle Input exceeds the normal display range\r\n");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
//Draw a circle from(0, R) as a starting point
|
//Draw a circle from(0, R) as a starting point
|
||||||
int16_t XCurrent, YCurrent;
|
int16_t XCurrent, YCurrent;
|
||||||
@@ -485,10 +489,10 @@ void Paint_DrawChar(UWORD Xpoint, UWORD Ypoint, const char Acsii_Char,
|
|||||||
{
|
{
|
||||||
UWORD Page, Column;
|
UWORD Page, Column;
|
||||||
|
|
||||||
if (Xpoint > Paint.Width || Ypoint > Paint.Height) {
|
// if (Xpoint > Paint.Width || Ypoint > Paint.Height) {
|
||||||
Debug("Paint_DrawChar Input exceeds the normal display range\r\n");
|
// Debug("Paint_DrawChar Input exceeds the normal display range\r\n");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
uint32_t Char_Offset = (Acsii_Char - ' ') * Font->Height * (Font->Width / 8 + (Font->Width % 8 ? 1 : 0));
|
uint32_t Char_Offset = (Acsii_Char - ' ') * Font->Height * (Font->Width / 8 + (Font->Width % 8 ? 1 : 0));
|
||||||
const unsigned char *ptr = &Font->table[Char_Offset];
|
const unsigned char *ptr = &Font->table[Char_Offset];
|
||||||
@@ -535,10 +539,10 @@ void Paint_DrawString_EN(UWORD Xstart, UWORD Ystart, const char * pString,
|
|||||||
UWORD Xpoint = Xstart;
|
UWORD Xpoint = Xstart;
|
||||||
UWORD Ypoint = Ystart;
|
UWORD Ypoint = Ystart;
|
||||||
|
|
||||||
if (Xstart > Paint.Width || Ystart > Paint.Height) {
|
// if (Xstart > Paint.Width || Ystart > Paint.Height) {
|
||||||
Debug("Paint_DrawString_EN Input exceeds the normal display range\r\n");
|
// Debug("Paint_DrawString_EN Input exceeds the normal display range\r\n");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
while (* pString != '\0') {
|
while (* pString != '\0') {
|
||||||
//if X direction filled , reposition to(Xstart,Ypoint),Ypoint is Y direction plus the Height of the character
|
//if X direction filled , reposition to(Xstart,Ypoint),Ypoint is Y direction plus the Height of the character
|
||||||
@@ -680,10 +684,10 @@ void Paint_DrawNum(UWORD Xpoint, UWORD Ypoint, int32_t Nummber,
|
|||||||
uint8_t Str_Array[ARRAY_LEN] = {0}, Num_Array[ARRAY_LEN] = {0};
|
uint8_t Str_Array[ARRAY_LEN] = {0}, Num_Array[ARRAY_LEN] = {0};
|
||||||
uint8_t *pStr = Str_Array;
|
uint8_t *pStr = Str_Array;
|
||||||
|
|
||||||
if (Xpoint > Paint.Width || Ypoint > Paint.Height) {
|
// if (Xpoint > Paint.Width || Ypoint > Paint.Height) {
|
||||||
Debug("Paint_DisNum Input exceeds the normal display range\r\n");
|
// Debug("Paint_DisNum Input exceeds the normal display range\r\n");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
//Converts a number to a string
|
//Converts a number to a string
|
||||||
while (Nummber) {
|
while (Nummber) {
|
||||||
|
|||||||
@@ -83,6 +83,8 @@ typedef struct {
|
|||||||
UWORD Height;
|
UWORD Height;
|
||||||
UWORD WidthMemory;
|
UWORD WidthMemory;
|
||||||
UWORD HeightMemory;
|
UWORD HeightMemory;
|
||||||
|
UWORD WidthOffset;
|
||||||
|
UWORD HeightOffset;
|
||||||
UWORD Color;
|
UWORD Color;
|
||||||
UWORD Rotate;
|
UWORD Rotate;
|
||||||
UWORD Mirror;
|
UWORD Mirror;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
//namespace myink { namespace ui {
|
//namespace myink { namespace ui {
|
||||||
PositionalProperties Paint_DrawString(UWORD Xstart, UWORD Ystart, const char * pString, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background);
|
PositionalProperties Paint_DrawString(UWORD Xstart, UWORD Ystart, const char * pString, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background);
|
||||||
|
|
||||||
TextBlock::TextBlock(const char * t, const TextBlockStyleProperties & s): text(t), style(s)
|
TextBlock::TextBlock(const char * t, const TextBlockStyleProperties & s): style(s), text(t)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,10 +28,11 @@ PositionalProperties Paint_DrawString(UWORD Xstart, UWORD Ystart, const char * p
|
|||||||
UWORD max_x_pos = Xstart;
|
UWORD max_x_pos = Xstart;
|
||||||
UWORD max_y_pos = Ystart + Font->Height;
|
UWORD max_y_pos = Ystart + Font->Height;
|
||||||
UWORD Ypoint = Ystart;
|
UWORD Ypoint = Ystart;
|
||||||
|
UWORD max_width = 2*Paint.Width;
|
||||||
|
|
||||||
while (* pString != '\0') {
|
while (* pString != '\0') {
|
||||||
//if X direction filled , reposition to(Xstart,Ypoint),Ypoint is Y direction plus the Height of the character
|
//if X direction filled , reposition to(Xstart,Ypoint),Ypoint is Y direction plus the Height of the character
|
||||||
if (*pString == '\n'|| (Xpoint + Font->Width ) > Paint.Width ) {
|
if (*pString == '\n'|| (Xpoint + Font->Width ) > max_width ) {
|
||||||
Xpoint = Xstart;
|
Xpoint = Xstart;
|
||||||
Ypoint += Font->Height;
|
Ypoint += Font->Height;
|
||||||
if(Ypoint >= max_y_pos) {
|
if(Ypoint >= max_y_pos) {
|
||||||
|
|||||||
68
src/main.cpp
68
src/main.cpp
@@ -1,5 +1,6 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <DEV_Config.h>
|
#include <DEV_Config.h>
|
||||||
|
#include <EspMQTTClient.h>
|
||||||
#include <EPD.h>
|
#include <EPD.h>
|
||||||
#include <fonts.h>
|
#include <fonts.h>
|
||||||
#include <GUI_Paint.h>
|
#include <GUI_Paint.h>
|
||||||
@@ -8,9 +9,24 @@
|
|||||||
#include "StackPanel.hpp"
|
#include "StackPanel.hpp"
|
||||||
#include "TextBlock.hpp"
|
#include "TextBlock.hpp"
|
||||||
|
|
||||||
PAINT_TIME show_time = {2020, 04, 27, 22, 42, 5};
|
|
||||||
UBYTE *BlackImage;
|
EspMQTTClient client(
|
||||||
sFONT * font = &Font8;
|
"08151234711-Gast",
|
||||||
|
"ahVee!M9",
|
||||||
|
"mqtt.stubbe.rocks", // MQTT Broker server ip
|
||||||
|
"eeN!ei2eilo1aiT6", // Can be omitted if not needed
|
||||||
|
"AS5hoh5ug(ei8eer", // Can be omitted if not needed
|
||||||
|
"minkclient", // Client name that uniquely identify your device
|
||||||
|
1883 // The MQTT port, default to 1883. this line can be omitted
|
||||||
|
);
|
||||||
|
|
||||||
|
UBYTE *BlackImage;
|
||||||
|
sFONT * font = &Font8;
|
||||||
|
PositionalProperties current_msg_pos = {0, 0 , 0, 0};
|
||||||
|
StackPanelStyleProperties sstyle = {WHITE, 0, BLACK, 0, 1};
|
||||||
|
DrawItemCallBack sdraw_items[] ={};
|
||||||
|
DrawItemCallBackList sdraw_list = {0, sdraw_items};
|
||||||
|
StackPanel cleaner = StackPanel(sstyle, sdraw_list, StackPanel::move_down);
|
||||||
|
|
||||||
PositionalProperties draw_label(const char * title, const char * value, const PositionalProperties & p, const sFONT & f)
|
PositionalProperties draw_label(const char * title, const char * value, const PositionalProperties & p, const sFONT & f)
|
||||||
{
|
{
|
||||||
@@ -50,10 +66,52 @@ PositionalProperties draw_meeting(const char * date, const char * subject, const
|
|||||||
return meeting_stack.draw(p);
|
return meeting_stack.draw(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onConnectionEstablished()
|
||||||
|
{
|
||||||
|
// Subscribe to "mytopic/test" and display received message to Serial
|
||||||
|
client.subscribe("myink/test", [](const String & payload) {
|
||||||
|
Serial.println(payload);
|
||||||
|
cleaner.draw(current_msg_pos);
|
||||||
|
PositionalProperties msg_pos = {0, 300 , 300, 300};
|
||||||
|
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint.WidthOffset = 0;
|
||||||
|
Paint.HeightOffset = 0;
|
||||||
|
current_msg_pos = draw_meeting("1", payload.c_str(), "msg", msg_pos, Font12);
|
||||||
|
EPD_7IN5_V2_SendHalfImage(0, BlackImage);
|
||||||
|
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint.WidthOffset = 240;
|
||||||
|
Paint.HeightOffset = 0;
|
||||||
|
current_msg_pos = draw_meeting("1", payload.c_str(), "msg", msg_pos, Font12);
|
||||||
|
EPD_7IN5_V2_SendHalfImage(1, BlackImage);
|
||||||
|
EPD_7IN5_V2_TurnOnDisplay();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Subscribe to "mytopic/wildcardtest/#" and display received message to Serial
|
||||||
|
client.subscribe("myink/wildcardtest/#", [](const String & topic, const String & payload) {
|
||||||
|
Serial.println(topic + ": " + payload);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Publish a message to "mytopic/test"
|
||||||
|
client.publish("myink/test", "This is a message"); // You can activate the retain flag by setting the third parameter to true
|
||||||
|
|
||||||
|
// Execute delayed instructions
|
||||||
|
client.executeDelayed(5 * 1000, []() {
|
||||||
|
client.publish("myink/test", "This is a message sent 5 seconds later");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// put your setup code here, to run once:
|
// put your setup code here, to run once:
|
||||||
DEV_Module_Init();
|
DEV_Module_Init();
|
||||||
EPD_7IN5_V2_Init();
|
EPD_7IN5_V2_Init();
|
||||||
|
Serial.begin(9600);
|
||||||
|
// Optionnal functionnalities of EspMQTTClient :
|
||||||
|
client.enableDebuggingMessages(); // Enable debugging messages sent to serial output
|
||||||
|
client.enableHTTPWebUpdater(); // Enable the web updater. User and password default to values of MQTTUsername and MQTTPassword. These can be overrited with enableHTTPWebUpdater("user", "password").
|
||||||
|
client.enableLastWillMessage("TestClient/lastwill", "I am going offline"); // You can activate the retain flag by setting the third parameter to true
|
||||||
|
|
||||||
|
|
||||||
/* you have to edit the startup_stm32fxxx.s file and set a big enough heap size */
|
/* you have to edit the startup_stm32fxxx.s file and set a big enough heap size */
|
||||||
UWORD Imagesize = ((EPD_7IN5_V2_WIDTH % 8 == 0) ? (EPD_7IN5_V2_WIDTH / 8 ) : (EPD_7IN5_V2_WIDTH / 8 + 1)) * EPD_7IN5_V2_HEIGHT;
|
UWORD Imagesize = ((EPD_7IN5_V2_WIDTH % 8 == 0) ? (EPD_7IN5_V2_WIDTH / 8 ) : (EPD_7IN5_V2_WIDTH / 8 + 1)) * EPD_7IN5_V2_HEIGHT;
|
||||||
@@ -74,5 +132,7 @@ void setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
EPD_7IN5_V2_Sleep();
|
//Serial.println("loop");
|
||||||
|
client.loop();
|
||||||
|
//EPD_7IN5_V2_Sleep();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user