placeholders fro drawables
This commit is contained in:
160
libs/mare/mare.h
160
libs/mare/mare.h
@@ -1,22 +1,164 @@
|
|||||||
/*******************************************
|
/*******************************************
|
||||||
* Most Awesome Renderer Ever
|
* Most Awesome Renderer Ever
|
||||||
*******************************************/
|
*******************************************/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#include <DEV_Config.h>
|
extern "C" {
|
||||||
#include <EPD_2in9b_V3.h>
|
#include <DEV_Config.h>
|
||||||
#include <fonts.h>
|
#include <EPD_2in9b_V3.h>
|
||||||
|
#include <fonts.h>
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace Render{
|
namespace Render{
|
||||||
|
|
||||||
class Mare {
|
struct pos_t {
|
||||||
public:
|
uint16_t x;
|
||||||
Mare();
|
uint16_t y;
|
||||||
virtual ~Mare();
|
};
|
||||||
|
|
||||||
|
struct bbox2d_t {
|
||||||
|
uint16_t xMin, Ymin;
|
||||||
|
uint16_t Xmax, Ymax;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class ScreenRotation {
|
||||||
|
Rot0 = 0,
|
||||||
|
Rot90 = 90,
|
||||||
|
Rot180 = 180,
|
||||||
|
Rot270 = 270
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class BlendMode {
|
||||||
|
Add,
|
||||||
|
Intersect
|
||||||
|
};
|
||||||
|
|
||||||
|
class Page;
|
||||||
|
class Drawable;
|
||||||
|
|
||||||
|
typedef pos_t dim_t;
|
||||||
|
typedef std::vector<Page*> Pages;
|
||||||
|
typedef std::vector<Drawable*> Drawables;
|
||||||
|
|
||||||
|
class Mare {
|
||||||
|
Mare();
|
||||||
|
virtual ~Mare();
|
||||||
|
|
||||||
|
// getters, setters
|
||||||
public:
|
public:
|
||||||
void render();
|
void setSize(const uint16_t x, const uint16_t y);
|
||||||
|
const dim_t getSize();
|
||||||
|
void setRotation(const ScreenRotation r);
|
||||||
|
const ScreenRotation getRotation();
|
||||||
|
|
||||||
|
const Pages& getPages();
|
||||||
|
const uint8_t getCurrentPage();
|
||||||
|
void setCurrentPage(const uint8_t p);
|
||||||
|
|
||||||
|
const Drawables& getDrawables();
|
||||||
|
|
||||||
|
// drawables, pages
|
||||||
|
public:
|
||||||
|
void addDrawable();
|
||||||
|
void removeDrawable(size_t id);
|
||||||
|
void addPage(uint8_t num);
|
||||||
|
void removePage(uint8_t num);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int _var;
|
void visitDrawables(Drawable* parent);
|
||||||
|
void render();
|
||||||
|
void setPixel(uint16_t x, uint16_t y, bool value);
|
||||||
|
|
||||||
|
// members
|
||||||
|
private:
|
||||||
|
uint8_t* _screenBufferForeground;
|
||||||
|
uint8_t* _screenBufferBackgrund;
|
||||||
|
dim_t _screenSize;
|
||||||
|
Pages _pages;
|
||||||
|
Drawables _drawables;
|
||||||
|
ScreenRotation _rotation;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Drawable {
|
||||||
|
|
||||||
|
Drawable(const size_t id, const pos_t position, const Drawable* parent);
|
||||||
|
virtual ~Drawable();
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual void render();
|
||||||
|
|
||||||
|
public:
|
||||||
|
void setId(const size_t id);
|
||||||
|
void setOrigin(const pos_t origin);
|
||||||
|
void setDirty();
|
||||||
|
void setBlendMode(const BlendMode mode);
|
||||||
|
|
||||||
|
const bbox2d_t getBBox();
|
||||||
|
const BlendMode getBlendMode();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool _dirty;
|
||||||
|
size_t _id;
|
||||||
|
pos_t _origin;
|
||||||
|
bbox2d_t _bbox;
|
||||||
|
Drawables _children;
|
||||||
|
Drawable* _parent;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class DrawablePoint: public Drawable {
|
||||||
|
|
||||||
|
DrawablePoint();
|
||||||
|
~DrawablePoint();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
private:
|
||||||
|
void render();
|
||||||
|
|
||||||
|
// members
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
class DrawableLine: public Drawable {
|
||||||
|
|
||||||
|
DrawableLine();
|
||||||
|
~DrawableLine();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
private:
|
||||||
|
void render() {};
|
||||||
|
|
||||||
|
// members
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
class DrawableRectangle: public Drawable {
|
||||||
|
|
||||||
|
DrawableRectangle();
|
||||||
|
~DrawableRectangle();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
private:
|
||||||
|
void render() {};
|
||||||
|
|
||||||
|
// members
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
class Page {
|
||||||
|
|
||||||
|
Page();
|
||||||
|
~Page();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
31
libs/mare/mare_drawables.cpp
Normal file
31
libs/mare/mare_drawables.cpp
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#include "mare.h"
|
||||||
|
|
||||||
|
namespace Render {
|
||||||
|
|
||||||
|
Drawable::Drawable(const size_t id, const pos_t position, const Drawable* parent) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------+--------+--------+--------+--------+--------+--------+--------+--------+--------//
|
||||||
|
//Point
|
||||||
|
|
||||||
|
|
||||||
|
//--------+--------+--------+--------+--------+--------+--------+--------+--------+--------//
|
||||||
|
//Line
|
||||||
|
|
||||||
|
//--------+--------+--------+--------+--------+--------+--------+--------+--------+--------//
|
||||||
|
//Rectangle
|
||||||
|
|
||||||
|
//--------+--------+--------+--------+--------+--------+--------+--------+--------+--------//
|
||||||
|
//Circle
|
||||||
|
|
||||||
|
//--------+--------+--------+--------+--------+--------+--------+--------+--------+--------//
|
||||||
|
//Character
|
||||||
|
|
||||||
|
//--------+--------+--------+--------+--------+--------+--------+--------+--------+--------//
|
||||||
|
//String
|
||||||
|
|
||||||
|
//--------+--------+--------+--------+--------+--------+--------+--------+--------+--------//
|
||||||
|
//Custom
|
||||||
|
|
||||||
|
}
|
||||||
10
libs/mare/mare_pages.cpp
Normal file
10
libs/mare/mare_pages.cpp
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#include "mare.h"
|
||||||
|
|
||||||
|
namespace Render {
|
||||||
|
|
||||||
|
Page::Page(){
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
29
src/main.cpp
29
src/main.cpp
@@ -15,11 +15,11 @@ void setPixel(uint8_t* img, uint16_t x, uint16_t y, bool value){
|
|||||||
else *img |= 0x01 << y%8;
|
else *img |= 0x01 << y%8;
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawSquare(uint8_t* img, uint16_t x, uint16_t y, uint16_t dimX, uint16_t dimY){
|
void drawSquare(uint8_t* img, uint16_t x, uint16_t y, uint16_t dimX, uint16_t dimY, bool col){
|
||||||
for (auto xx(0); xx< dimX; xx++){
|
for (auto xx(0); xx< dimX; xx++){
|
||||||
for (auto yy(0); yy < dimY; yy++)
|
for (auto yy(0); yy < dimY; yy++)
|
||||||
{
|
{
|
||||||
setPixel(img,x+xx,y+yy,true);
|
setPixel(img,x+xx,y+yy,col);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -54,22 +54,25 @@ int main(){
|
|||||||
delta[i][j]=0xff;
|
delta[i][j]=0xff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uint8_t dot(16);
|
uint8_t dot(8);
|
||||||
|
bool col(false);
|
||||||
while(true){
|
while(true){
|
||||||
EPD_2IN9_V2_Display_Base((uint8_t*)img);
|
EPD_2IN9_V2_Display_Base((uint8_t*)img);
|
||||||
//EPD_2IN9_V2_Clear();
|
for(auto k(0); k<2; ++k){
|
||||||
for (auto x(0); x <= EPD_2IN9_V2_HEIGHT-dot;x+=dot){
|
col = col ? false : true;
|
||||||
for(auto y(0); y <= EPD_2IN9_V2_WIDTH-dot;y+=dot){
|
for (auto x(0); x <= EPD_2IN9_V2_WIDTH-dot;x+=dot){
|
||||||
drawSquare((uint8_t*)delta,x,y,dot,dot);
|
for(auto y(0); y <= EPD_2IN9_V2_HEIGHT-dot;y+=dot){
|
||||||
EPD_2IN9_V2_Display_Partial((uint8_t*)delta);
|
drawSquare((uint8_t*)delta,y,EPD_2IN9_V2_WIDTH-x-dot,dot,dot,col);
|
||||||
}
|
EPD_2IN9_V2_Display_Partial((uint8_t*)delta);
|
||||||
for(auto i(0); i < EPD_2IN9B_V3_HEIGHT; ++i){
|
|
||||||
for (auto j(0); j< EPD_2IN9B_V3_WIDTH/8; ++j){
|
|
||||||
delta[i][j]=0xff;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(auto i(0); i < EPD_2IN9B_V3_HEIGHT; ++i){
|
||||||
|
for (auto j(0); j< EPD_2IN9B_V3_WIDTH/8; ++j){
|
||||||
|
delta[i][j]=0xff;
|
||||||
|
}
|
||||||
|
}
|
||||||
printf("[%u] Hello, world!\n",i++);
|
printf("[%u] Hello, world!\n",i++);
|
||||||
gpio_put(LED_PIN,s);
|
gpio_put(LED_PIN,s);
|
||||||
s = s ? false : true;
|
s = s ? false : true;
|
||||||
|
|||||||
Reference in New Issue
Block a user