init
This commit is contained in:
89
.gitignore
vendored
Normal file
89
.gitignore
vendored
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
|
||||||
|
# Created by https://www.gitignore.io/api/c,c++,visualstudiocode
|
||||||
|
# Edit at https://www.gitignore.io/?templates=c,c++,visualstudiocode
|
||||||
|
|
||||||
|
### C ###
|
||||||
|
# Prerequisites
|
||||||
|
*.d
|
||||||
|
|
||||||
|
# Object files
|
||||||
|
*.o
|
||||||
|
*.ko
|
||||||
|
*.obj
|
||||||
|
*.elf
|
||||||
|
|
||||||
|
# Linker output
|
||||||
|
*.ilk
|
||||||
|
*.map
|
||||||
|
*.exp
|
||||||
|
|
||||||
|
# Precompiled Headers
|
||||||
|
*.gch
|
||||||
|
*.pch
|
||||||
|
|
||||||
|
# Libraries
|
||||||
|
*.lib
|
||||||
|
*.a
|
||||||
|
*.la
|
||||||
|
*.lo
|
||||||
|
|
||||||
|
# Shared objects (inc. Windows DLLs)
|
||||||
|
*.dll
|
||||||
|
*.so
|
||||||
|
*.so.*
|
||||||
|
*.dylib
|
||||||
|
|
||||||
|
# Executables
|
||||||
|
*.exe
|
||||||
|
*.out
|
||||||
|
*.app
|
||||||
|
*.i*86
|
||||||
|
*.x86_64
|
||||||
|
*.hex
|
||||||
|
|
||||||
|
# Debug files
|
||||||
|
*.dSYM/
|
||||||
|
*.su
|
||||||
|
*.idb
|
||||||
|
*.pdb
|
||||||
|
|
||||||
|
# Kernel Module Compile Results
|
||||||
|
*.mod*
|
||||||
|
*.cmd
|
||||||
|
.tmp_versions/
|
||||||
|
modules.order
|
||||||
|
Module.symvers
|
||||||
|
Mkfile.old
|
||||||
|
dkms.conf
|
||||||
|
|
||||||
|
### C++ ###
|
||||||
|
# Prerequisites
|
||||||
|
|
||||||
|
# Compiled Object files
|
||||||
|
*.slo
|
||||||
|
|
||||||
|
# Precompiled Headers
|
||||||
|
|
||||||
|
# Compiled Dynamic libraries
|
||||||
|
|
||||||
|
# Fortran module files
|
||||||
|
*.mod
|
||||||
|
*.smod
|
||||||
|
|
||||||
|
# Compiled Static libraries
|
||||||
|
*.lai
|
||||||
|
|
||||||
|
# Executables
|
||||||
|
|
||||||
|
### VisualStudioCode ###
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
|
||||||
|
### VisualStudioCode Patch ###
|
||||||
|
# Ignore all local history of files
|
||||||
|
.history
|
||||||
|
|
||||||
|
# End of https://www.gitignore.io/api/c,c++,visualstudiocode
|
||||||
63
.vscode/settings.json
vendored
Normal file
63
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
{
|
||||||
|
"files.associations": {
|
||||||
|
"array": "cpp",
|
||||||
|
"atomic": "cpp",
|
||||||
|
"*.tcc": "cpp",
|
||||||
|
"cctype": "cpp",
|
||||||
|
"chrono": "cpp",
|
||||||
|
"clocale": "cpp",
|
||||||
|
"cmath": "cpp",
|
||||||
|
"condition_variable": "cpp",
|
||||||
|
"cstdarg": "cpp",
|
||||||
|
"cstdint": "cpp",
|
||||||
|
"cstdio": "cpp",
|
||||||
|
"cstdlib": "cpp",
|
||||||
|
"cstring": "cpp",
|
||||||
|
"ctime": "cpp",
|
||||||
|
"cwchar": "cpp",
|
||||||
|
"cwctype": "cpp",
|
||||||
|
"deque": "cpp",
|
||||||
|
"list": "cpp",
|
||||||
|
"unordered_map": "cpp",
|
||||||
|
"unordered_set": "cpp",
|
||||||
|
"vector": "cpp",
|
||||||
|
"exception": "cpp",
|
||||||
|
"fstream": "cpp",
|
||||||
|
"functional": "cpp",
|
||||||
|
"initializer_list": "cpp",
|
||||||
|
"iomanip": "cpp",
|
||||||
|
"iosfwd": "cpp",
|
||||||
|
"iostream": "cpp",
|
||||||
|
"istream": "cpp",
|
||||||
|
"limits": "cpp",
|
||||||
|
"mutex": "cpp",
|
||||||
|
"new": "cpp",
|
||||||
|
"ostream": "cpp",
|
||||||
|
"numeric": "cpp",
|
||||||
|
"ratio": "cpp",
|
||||||
|
"sstream": "cpp",
|
||||||
|
"stdexcept": "cpp",
|
||||||
|
"streambuf": "cpp",
|
||||||
|
"system_error": "cpp",
|
||||||
|
"thread": "cpp",
|
||||||
|
"cinttypes": "cpp",
|
||||||
|
"tuple": "cpp",
|
||||||
|
"type_traits": "cpp",
|
||||||
|
"utility": "cpp",
|
||||||
|
"typeinfo": "cpp",
|
||||||
|
"valarray": "cpp",
|
||||||
|
"cstddef": "cpp",
|
||||||
|
"bit": "cpp",
|
||||||
|
"map": "cpp",
|
||||||
|
"set": "cpp",
|
||||||
|
"algorithm": "cpp",
|
||||||
|
"iterator": "cpp",
|
||||||
|
"memory": "cpp",
|
||||||
|
"memory_resource": "cpp",
|
||||||
|
"optional": "cpp",
|
||||||
|
"random": "cpp",
|
||||||
|
"string": "cpp",
|
||||||
|
"string_view": "cpp",
|
||||||
|
"variant": "cpp"
|
||||||
|
}
|
||||||
|
}
|
||||||
95
StackPanel.cpp
Normal file
95
StackPanel.cpp
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
#include "StackPanel.hpp"
|
||||||
|
#include <functional>
|
||||||
|
#include <GUI_Paint.h>
|
||||||
|
|
||||||
|
//using namespace myink::ui;
|
||||||
|
|
||||||
|
void draw_background(const PositionalProperties & positionals, const Color & background_color);
|
||||||
|
void draw_border(const PositionalProperties positionals, const Color & color, const LineWidth & border_line_width);
|
||||||
|
PositionalProperties move_down(const PositionalProperties & i, const PositionalProperties & p);
|
||||||
|
PositionalProperties move_right(const PositionalProperties & i, const PositionalProperties & p);
|
||||||
|
|
||||||
|
StackPanel::StackPanel(const PositionalProperties & p, const StackPanelStyleProperties & s, const DrawItemCallBackList & i, const MoveToNextItem & m) : positionals(p), style(s), itmes(i), move(m)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
StackPanel::~StackPanel()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void StackPanel::draw() const
|
||||||
|
{
|
||||||
|
auto border_line_width = style.border_line_width;
|
||||||
|
auto margin = style.margin;
|
||||||
|
auto padding = style.padding;
|
||||||
|
auto inner_gap = border_line_width + padding;
|
||||||
|
auto gap = inner_gap + margin;
|
||||||
|
if (itmes.size == 0) {
|
||||||
|
PositionalProperties outer = {
|
||||||
|
positionals.left,
|
||||||
|
positionals.top,
|
||||||
|
positionals.width + 2 * (gap),
|
||||||
|
positionals.height + 2 * (gap)
|
||||||
|
};
|
||||||
|
draw_background(outer, style.background_color);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PositionalProperties inner = {
|
||||||
|
positionals.left + gap,
|
||||||
|
positionals.top + gap,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
for(auto i = 0; i < itmes.size; i++) {
|
||||||
|
auto callback = itmes.callbacks[i];
|
||||||
|
auto last = callback(inner);
|
||||||
|
inner = move(inner, last);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (border_line_width < 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PositionalProperties border_positionals = {
|
||||||
|
positionals.left + padding,
|
||||||
|
positionals.top + padding,
|
||||||
|
inner.width + (2 * margin) + border_line_width,
|
||||||
|
inner.height + (2 * margin) + border_line_width
|
||||||
|
};
|
||||||
|
|
||||||
|
draw_border(border_positionals, style.border_line_color, border_line_width);
|
||||||
|
}
|
||||||
|
|
||||||
|
PositionalProperties StackPanel::move_down(const PositionalProperties & i, const PositionalProperties & p)
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
i.left,
|
||||||
|
i.top + p.height,
|
||||||
|
p.width > i.width ? p.width : i.width,
|
||||||
|
i.height + p.height
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
PositionalProperties StackPanel::move_right(const PositionalProperties & i, const PositionalProperties & p)
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
i.left + p.width,
|
||||||
|
i.top,
|
||||||
|
i.width + p.width,
|
||||||
|
p.height > i.height ? p.height : i.height
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw_background(const PositionalProperties & positionals, const Color & background_color)
|
||||||
|
{
|
||||||
|
Paint_ClearWindows(positionals.left, positionals.top, positionals.left + positionals.width, positionals.top + positionals.height, background_color);
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw_border(const PositionalProperties p, const Color & color, const LineWidth & border_line_width)
|
||||||
|
{
|
||||||
|
auto border_line_width_pixel = border_line_width > 8 ? DOT_PIXEL::DOT_PIXEL_8X8 : DOT_PIXEL(border_line_width);
|
||||||
|
Paint_DrawRectangle(p.left, p.top, p.left + p.width, p.top + p.height, color, border_line_width_pixel, DRAW_FILL_EMPTY);
|
||||||
|
}
|
||||||
32
StackPanel.hpp
Normal file
32
StackPanel.hpp
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#ifndef STACK_PANEL_H
|
||||||
|
#define STACK_PANEL_H
|
||||||
|
|
||||||
|
#include "StackPanel_t.hpp"
|
||||||
|
|
||||||
|
//namespace myink { namespace ui {
|
||||||
|
|
||||||
|
class StackPanel
|
||||||
|
{
|
||||||
|
|
||||||
|
private:
|
||||||
|
const PositionalProperties & positionals;
|
||||||
|
const StackPanelStyleProperties & style;
|
||||||
|
const DrawItemCallBackList & itmes;
|
||||||
|
const MoveToNextItem & move;
|
||||||
|
|
||||||
|
public:
|
||||||
|
StackPanel(const PositionalProperties & positionals, const StackPanelStyleProperties & style, const DrawItemCallBackList & itmes, const MoveToNextItem & move);
|
||||||
|
~StackPanel();
|
||||||
|
|
||||||
|
void draw() const;
|
||||||
|
static PositionalProperties move_down(const PositionalProperties & i, const PositionalProperties & p);
|
||||||
|
static PositionalProperties move_right(const PositionalProperties & i, const PositionalProperties & p);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//}}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
41
StackPanel_t.hpp
Normal file
41
StackPanel_t.hpp
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#ifndef STACK_PANEL_T_H
|
||||||
|
#define STACK_PANEL_T_H
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
//namespace myink { namespace ui {
|
||||||
|
class StackPanel;
|
||||||
|
typedef StackPanel * StackPanelPtr;
|
||||||
|
typedef struct PositionalProperties_t
|
||||||
|
{
|
||||||
|
size_t left;
|
||||||
|
size_t top;
|
||||||
|
size_t width;
|
||||||
|
size_t height;
|
||||||
|
} PositionalProperties, *PositionalPropertiesPtr;
|
||||||
|
|
||||||
|
typedef size_t Color;
|
||||||
|
typedef size_t LineWidth;
|
||||||
|
typedef size_t Margin;
|
||||||
|
typedef size_t Padding;
|
||||||
|
typedef PositionalProperties(*DrawItemCallBack)(const PositionalProperties &);
|
||||||
|
typedef struct DrawItemCallBackList_t
|
||||||
|
{
|
||||||
|
size_t size;
|
||||||
|
DrawItemCallBack * callbacks;
|
||||||
|
} DrawItemCallBackList, *DrawItemCallBackListPtr;
|
||||||
|
|
||||||
|
typedef PositionalProperties (*MoveToNextItem)(const PositionalProperties &, const PositionalProperties & );
|
||||||
|
|
||||||
|
typedef struct StackPanelStyleProperties_t
|
||||||
|
{
|
||||||
|
Color background_color;
|
||||||
|
LineWidth border_line_width;
|
||||||
|
Color border_line_color;
|
||||||
|
Margin margin;
|
||||||
|
Padding padding;
|
||||||
|
} StackPanelStyleProperties, *StackPanelStylePropertiesPtr;
|
||||||
|
|
||||||
|
//}}
|
||||||
|
|
||||||
|
#endif
|
||||||
66
myink.ino
Normal file
66
myink.ino
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
#include <DEV_Config.h>
|
||||||
|
#include <EPD.h>
|
||||||
|
#include <fonts.h>
|
||||||
|
#include <GUI_Paint.h>
|
||||||
|
#include <Debug.h>
|
||||||
|
|
||||||
|
#include "StackPanel.hpp"
|
||||||
|
|
||||||
|
PAINT_TIME show_time = {2020, 04, 27, 22, 42, 5};
|
||||||
|
UBYTE *BlackImage;
|
||||||
|
sFONT * font = &Font8;
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
// put your setup code here, to run once:
|
||||||
|
DEV_Module_Init();
|
||||||
|
EPD_7IN5_V2_Init();
|
||||||
|
|
||||||
|
/* 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;
|
||||||
|
if ((BlackImage = (UBYTE *)malloc(Imagesize / 2)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
while (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Paint_NewImage(BlackImage, EPD_7IN5_V2_WIDTH , EPD_7IN5_V2_HEIGHT / 2, 90, WHITE);
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
// put your main code here, to run repeatedly:
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
|
||||||
|
show_time.Sec = show_time.Sec + 1;
|
||||||
|
Paint_DrawTime(100, 10, &show_time, &Font24, WHITE, BLACK);
|
||||||
|
DrawItemCallBack itmes[] = {
|
||||||
|
[](const PositionalProperties & p) -> PositionalProperties {
|
||||||
|
Paint_DrawString_EN(p.left, p.top, "Hallo Miri :)", font, WHITE, BLACK);
|
||||||
|
return { p.left, p.top, 13 * font->Width, font->Height};
|
||||||
|
},
|
||||||
|
[](const PositionalProperties & p) -> PositionalProperties {
|
||||||
|
Paint_DrawString_EN(p.left, p.top, "Hallo Felix", font, WHITE, BLACK);
|
||||||
|
return { p.left, p.top, 13 * font->Width, font->Height};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
StackPanel(
|
||||||
|
{50, 200 ,200, 50},
|
||||||
|
{WHITE, 1, BLACK, 2, 4},
|
||||||
|
{2, itmes},
|
||||||
|
StackPanel::move_right
|
||||||
|
).draw();
|
||||||
|
|
||||||
|
EPD_7IN5_V2_SendHalfImage(0, BlackImage);
|
||||||
|
font = &Font24;
|
||||||
|
|
||||||
|
StackPanel(
|
||||||
|
{0, 400 ,200, 50},
|
||||||
|
{WHITE, 2, BLACK, 4, 8},
|
||||||
|
{2, itmes},
|
||||||
|
StackPanel::move_down
|
||||||
|
).draw();
|
||||||
|
|
||||||
|
EPD_7IN5_V2_SendHalfImage(1, BlackImage);
|
||||||
|
EPD_7IN5_V2_TurnOnDisplay();
|
||||||
|
EPD_7IN5_V2_Sleep();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user