does not link, we are close..
This commit is contained in:
@@ -10,4 +10,4 @@ include_directories(../epaper/Fonts)
|
|||||||
|
|
||||||
# Generate the link library
|
# Generate the link library
|
||||||
add_library(Mare ${DIR_Config_SRCS})
|
add_library(Mare ${DIR_Config_SRCS})
|
||||||
target_link_libraries(Mare PUBLIC Config ePaper pico_stdlib hardware_spi)
|
target_link_libraries(Mare PUBLIC Config ePaper Fonts pico_stdlib hardware_spi)
|
||||||
@@ -38,10 +38,13 @@ namespace Render {
|
|||||||
free(_screenBufferForeground);
|
free(_screenBufferForeground);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T, class ... Args>
|
||||||
void Mare::addDrawable(T){
|
T* Mare::addDrawable(Args&&... args){
|
||||||
static size_t lastDrawableIndex(0);
|
static size_t lastDrawableIndex(0);
|
||||||
auto newD = std::make_shared<T>(lastDrawableIndex++, )
|
static_assert(std::is_base_of_v<Drawable, T>, "Scene::createDrawable<T>() error, type T is not inherited from Drawable.");
|
||||||
|
auto newD = std::make_shared<T>(lastDrawableIndex++, nullptr, this, std::forward<Args>(args)...);
|
||||||
|
_drawables.push_back(newD);
|
||||||
|
return newD.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -54,6 +57,7 @@ namespace Render {
|
|||||||
printf("Drawable is expired");
|
printf("Drawable is expired");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
EPD_2IN9_V2_Display_Partial(_screenBufferBackground);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mare::setPixel(uint8_t* img, uint16_t x, uint16_t y, bool value){
|
void Mare::setPixel(uint8_t* img, uint16_t x, uint16_t y, bool value){
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
/*******************************************
|
/*******************************************
|
||||||
* Most Awesome Renderer Ever
|
* Most Awesome Renderer Ever
|
||||||
*******************************************/
|
*******************************************/
|
||||||
#pragma once
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <pico/stdlib.h>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <DEV_Config.h>
|
#include <DEV_Config.h>
|
||||||
#include <EPD_2in9_V2.h>
|
#include <EPD_2in9_V2.h>
|
||||||
#include <fonts.h>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -52,7 +53,9 @@ namespace Render{
|
|||||||
|
|
||||||
class Mare {
|
class Mare {
|
||||||
friend class Drawable;
|
friend class Drawable;
|
||||||
|
friend class Page;
|
||||||
|
|
||||||
|
public:
|
||||||
Mare(dim_t size);
|
Mare(dim_t size);
|
||||||
~Mare();
|
~Mare();
|
||||||
|
|
||||||
@@ -67,8 +70,8 @@ namespace Render{
|
|||||||
|
|
||||||
// drawables, pages
|
// drawables, pages
|
||||||
public:
|
public:
|
||||||
template <class T>
|
template <class T, class ... Args>
|
||||||
void addDrawable(T);
|
T* addDrawable(Args&&... args);
|
||||||
void removeDrawable(const size_t id);
|
void removeDrawable(const size_t id);
|
||||||
void addPage();
|
void addPage();
|
||||||
void removePage(const uint8_t num);
|
void removePage(const uint8_t num);
|
||||||
@@ -77,9 +80,11 @@ namespace Render{
|
|||||||
|
|
||||||
//render
|
//render
|
||||||
private:
|
private:
|
||||||
void render();
|
|
||||||
void clearBuffer(uint8_t* buffer, Color col);
|
void clearBuffer(uint8_t* buffer, Color col);
|
||||||
void visitDrawables(Drawable* parent);
|
void visitDrawables(Drawable* parent);
|
||||||
|
|
||||||
|
public:
|
||||||
|
void render();
|
||||||
void setPixel(uint8_t* img, uint16_t x, uint16_t y, bool value);
|
void setPixel(uint8_t* img, uint16_t x, uint16_t y, bool value);
|
||||||
|
|
||||||
// members
|
// members
|
||||||
@@ -90,11 +95,15 @@ namespace Render{
|
|||||||
uint8_t* _screenBufferBackground;
|
uint8_t* _screenBufferBackground;
|
||||||
Drawables _drawables; // background drawables for all the pages
|
Drawables _drawables; // background drawables for all the pages
|
||||||
ScreenRotation _rotation;
|
ScreenRotation _rotation;
|
||||||
|
|
||||||
|
public:
|
||||||
|
uint8_t* bBuffer() {return _screenBufferBackground;}
|
||||||
|
uint8_t* fBuffer() {return _screenBufferForeground;}
|
||||||
};
|
};
|
||||||
|
|
||||||
class Drawable {
|
class Drawable {
|
||||||
public:
|
public:
|
||||||
Drawable(const size_t id, const Drawable* parent, const Mare* engine);
|
Drawable(const size_t id, Drawable* parent, Mare* engine);
|
||||||
~Drawable();
|
~Drawable();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -106,12 +115,16 @@ namespace Render{
|
|||||||
void setDirty();
|
void setDirty();
|
||||||
void setBlendMode(const BlendMode mode);
|
void setBlendMode(const BlendMode mode);
|
||||||
|
|
||||||
|
const pos_t getOrigin();
|
||||||
const bbox2d_t getBBox();
|
const bbox2d_t getBBox();
|
||||||
const BlendMode getBlendMode();
|
const BlendMode getBlendMode();
|
||||||
|
|
||||||
|
Mare* engine() { return _engine; };
|
||||||
|
Drawable* parent() { return _parent; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Drawable* _parent;
|
Drawable* _parent;
|
||||||
const Mare* _engine;
|
Mare* _engine;
|
||||||
bool _dirty;
|
bool _dirty;
|
||||||
size_t _id;
|
size_t _id;
|
||||||
pos_t _origin;
|
pos_t _origin;
|
||||||
@@ -121,7 +134,7 @@ namespace Render{
|
|||||||
|
|
||||||
class DrawablePoint: public Drawable {
|
class DrawablePoint: public Drawable {
|
||||||
|
|
||||||
DrawablePoint(const size_t id, const Drawable* parent, const Mare* engine, dim_t size);
|
DrawablePoint(const size_t id, Drawable* parent, Mare* engine, dim_t size);
|
||||||
~DrawablePoint();
|
~DrawablePoint();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -240,6 +253,5 @@ namespace Render{
|
|||||||
private:
|
private:
|
||||||
Drawables _backDrawables;
|
Drawables _backDrawables;
|
||||||
Drawables _frontDrawables;
|
Drawables _frontDrawables;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Render {
|
namespace Render {
|
||||||
|
|
||||||
Drawable::Drawable(const size_t id, const Drawable* parent, const Mare* engine):
|
Drawable::Drawable(const size_t id, Drawable* parent, Mare* engine):
|
||||||
_id(id),
|
_id(id),
|
||||||
_parent(parent),
|
_parent(parent),
|
||||||
_engine(engine)
|
_engine(engine)
|
||||||
@@ -12,13 +12,28 @@ namespace Render {
|
|||||||
|
|
||||||
//--------+--------+--------+--------+--------+--------+--------+--------+--------+--------//
|
//--------+--------+--------+--------+--------+--------+--------+--------+--------+--------//
|
||||||
//Point
|
//Point
|
||||||
DrawablePoint::DrawablePoint(const size_t id, const Drawable* parent, const Mare* engine, dim_t size):
|
DrawablePoint::DrawablePoint(const size_t id, Drawable* parent, Mare* engine, dim_t size):
|
||||||
Drawable(id, parent,engine),
|
Drawable(id, parent,engine),
|
||||||
_size(size)
|
_size(size)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DrawablePoint::render() {
|
||||||
|
uint8_t *buf;
|
||||||
|
if (parent() == nullptr)
|
||||||
|
buf = engine()->bBuffer();
|
||||||
|
else
|
||||||
|
buf = engine()->fBuffer();
|
||||||
|
|
||||||
|
for (uint16_t xx(0); xx< _size.x; xx++){
|
||||||
|
for (uint16_t yy(0); yy < _size.y; yy++)
|
||||||
|
{
|
||||||
|
engine()->setPixel(buf,getOrigin().x+xx,getOrigin().y+yy,true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//--------+--------+--------+--------+--------+--------+--------+--------+--------+--------//
|
//--------+--------+--------+--------+--------+--------+--------+--------+--------+--------//
|
||||||
//Line
|
//Line
|
||||||
|
|||||||
@@ -18,11 +18,6 @@ pico_add_extra_outputs(emon)
|
|||||||
|
|
||||||
# Pull in our pico_stdlib which aggregates commonly used features
|
# Pull in our pico_stdlib which aggregates commonly used features
|
||||||
target_link_libraries(emon
|
target_link_libraries(emon
|
||||||
hardware_spi
|
|
||||||
pico_stdlib
|
pico_stdlib
|
||||||
Config
|
Mare
|
||||||
ePaper
|
|
||||||
GUI
|
|
||||||
Fonts
|
|
||||||
MyLibs
|
|
||||||
)
|
)
|
||||||
|
|||||||
35
src/main.cpp
35
src/main.cpp
@@ -2,29 +2,8 @@
|
|||||||
#include <pico/stdlib.h>
|
#include <pico/stdlib.h>
|
||||||
|
|
||||||
// Ricrdarsi di inserire cosi' tutte le lebrerie C altrimenti non LINKA, vaccamiseria
|
// Ricrdarsi di inserire cosi' tutte le lebrerie C altrimenti non LINKA, vaccamiseria
|
||||||
extern "C" {
|
|
||||||
#include <EPD_2in9_V2.h>
|
|
||||||
}
|
|
||||||
|
|
||||||
#include <myclass.h>
|
|
||||||
#include <mare.h>
|
#include <mare.h>
|
||||||
|
|
||||||
void setPixel(uint8_t* img, uint16_t x, uint16_t y, bool value){
|
|
||||||
img += (sizeof(uint8_t)*x*(EPD_2IN9_V2_WIDTH>>3)+ sizeof(uint8_t)*(y>>3));
|
|
||||||
if (value) *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, bool col){
|
|
||||||
for (auto xx(0); xx< dimX; xx++){
|
|
||||||
for (auto yy(0); yy < dimY; yy++)
|
|
||||||
{
|
|
||||||
setPixel(img,x+xx,y+yy,col);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
stdio_init_all();
|
stdio_init_all();
|
||||||
const uint LED_PIN = PICO_DEFAULT_LED_PIN;
|
const uint LED_PIN = PICO_DEFAULT_LED_PIN;
|
||||||
@@ -32,11 +11,25 @@ int main(){
|
|||||||
gpio_set_dir(LED_PIN, GPIO_OUT);
|
gpio_set_dir(LED_PIN, GPIO_OUT);
|
||||||
bool s=false;
|
bool s=false;
|
||||||
uint i(0);
|
uint i(0);
|
||||||
|
Render::dim_t ssize;
|
||||||
|
ssize.x = EPD_2IN9_V2_WIDTH;
|
||||||
|
ssize.y = EPD_2IN9_V2_HEIGHT;
|
||||||
|
|
||||||
|
auto viewer = Render::Mare(ssize);
|
||||||
|
|
||||||
|
Render::dim_t ps;
|
||||||
|
ps.x=10;
|
||||||
|
ps.y=10;
|
||||||
|
auto point = viewer.addDrawable<Render::DrawablePoint>(ps);
|
||||||
|
point->setOrigin(ps);
|
||||||
|
viewer.render();
|
||||||
|
|
||||||
|
|
||||||
while(true){
|
while(true){
|
||||||
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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user