implement first test on AVR

This commit is contained in:
j3d1 2018-10-28 20:06:26 +01:00
parent 8fcd668585
commit 3e66bd2c38
10 changed files with 63 additions and 48 deletions

View file

@ -22,28 +22,15 @@ void Layout::p(){
for(int j = 0; j < allocated_; j++){
Node * node;
if((node = slots[j].node) && node->view.render){
print(node->view.minsize);
print("...");
print(node->view.maxsize);
print("\n");
print(slots[j].pos_);
print("...");
print(slots[j].size_);
print("\n");
node->view.render(slots[j].pos_,slots[j].size_,node);
}
print("\n");
}
}
int Layout::apply(Node* node){
int rootslot = allocate_(node, maxslots);
print(rootslot);
print("\n");
int minsize = pack_(rootslot);
print(minsize);
print("\n");
expand_(minsize);
return 0;
}
@ -57,8 +44,6 @@ int Layout::pack_(int usedslots){
minsum+=slots[i].node->view.minsize;
}
allocated_ = i;
print(i);
print("\n");
return minsum;
}
@ -73,8 +58,7 @@ int Layout::expand_(int packedsize){
slots[i].size_=size;
pos+=size;
}
print(pos);
print("\n");
return 0;
}
int Layout::allocate_(Node* node, int depth){

View file

@ -39,8 +39,8 @@ void draw_menu(int offset, int size, Node* val){
//print(ptr->state);
}
for(int i = 0; i<32;i++)
draw(offset,i);
for(int i = 0; i<32 && i<size;i++)
draw(offset+(i%size),i);
for(int i = 0; i<32;i++)
draw(offset,i);
for(int i = 0; i<32 && i<size;i++)
draw(offset+(i%size),i);
}

View file

@ -72,20 +72,31 @@ void print(int str){
#else
#ifdef AVR
#include "ssd1306.h"
#endif
#include "ssd1306.h"
#include "nano_gfx.h"
#include <stdlib.h>
uint8_t canvasData[SCREEN_WIDTH*(SCREEN_HEIGHT/8)];
NanoCanvas canvas(SCREEN_WIDTH, SCREEN_HEIGHT, canvasData);
void setup(){
//TODO implement
ssd1306_128x32_i2c_init();
ssd1306_fillScreen( 0x00 );
canvas.clear();
}
void draw(int x, int y){
//TODO implement
canvas.putPixel(x, y);
}
void render(){
//TODO implement
canvas.blt(0,0);
}
void * operator new(unsigned int size)
{
return malloc(size);

View file

@ -2,15 +2,21 @@
#include "hal.h"
#include "col.h"
#include "example.h"
#ifdef AVR
#include "ssd1306.h"
#endif
int main() {
setup();
//build tree
//build tree
Node root(nullptr,
new Node("foo1",
new Node("foo2",
@ -23,21 +29,21 @@ int main() {
new Node("blub", new Value("BLUB",5,draw_blub)),
new Node("blub", new Value("BLUB",5,draw_blub))
);
root.p(0);
//walk tree + allocate slots
//position slots
///root.p(0);
//walk tree + allocate slots
//position slots
// 128 x 32
Layout l(128);
l.apply(&root);
//render
setup();
l.p();
render();
render();
return 0;
}