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

5
.gitignore vendored
View file

@ -1 +1,6 @@
build/* build/*
lib/*
deps/*
.idea/*
cmake-build-debug/*
CMakeLists.txt

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "deps/ssd1306"]
path = deps/ssd1306
url = https://github.com/lexus2k/ssd1306.git

View file

@ -2,12 +2,17 @@
all: linux avr all: linux avr
linux: linux:
@echo make linux
@make -f linux.Makefile linux @make -f linux.Makefile linux
avr: avr: lib/libssd1306.a
@echo make avr
@make -f avr.Makefile avr @make -f avr.Makefile avr
lib/libssd1306.a:
@cd deps/ssd1306/src/; make -f Makefile.avr
@mkdir -p lib
@cp deps/ssd1306/bld/libssd1306.a lib/libssd1306.a
flash: flash:
@make -f avr.Makefile flash @make -f avr.Makefile flash

View file

@ -39,18 +39,17 @@ CFLAGS += -std=gnu99
CXXFLAGS += -std=c++11 CXXFLAGS += -std=c++11
CFLAGS += -I$(INCDIR) -DAVR CFLAGS += -I$(INCDIR) -DAVR -Ideps/ssd1306/src/
CXXFLAGS += -I$(INCDIR) -DAVR CXXFLAGS += -I$(INCDIR) -DAVR -Ideps/ssd1306/src/
#LDFLAGS = LDFLAGS = -Llib -lssd1306
#==== Programming Options (avrdude) ============================================ #==== Programming Options (avrdude) ============================================
AVRDUDE_PROGRAMMER = arduino AVRDUDE_PROGRAMMER = arduino
AVRDUDE_PORT = /dev/ttyS4 AVRDUDE_BAUD = 115200
AVRDUDE_BAUD = 19200
#AVRDUDE_NO_VERIFY = -V #AVRDUDE_NO_VERIFY = -V
@ -77,8 +76,8 @@ SRC_PATH = $(SRC:%=$(SRCDIR)/%)
OBJ = $(SRC_PATH:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o) OBJ = $(SRC_PATH:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o)
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex AVRDUDE_WRITE_FLASH = -U flash:w:$(OBJDIR)/$(TARGET).hex
AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(OBJDIR)/$(TARGET).eep
MEMORYTYPES = flash eeprom fuse lfuse hfuse efuse boot calibration lock signature application apptable prodsig usersig MEMORYTYPES = flash eeprom fuse lfuse hfuse efuse boot calibration lock signature application apptable prodsig usersig
@ -126,11 +125,11 @@ size: $(OBJDIR)/$(TARGET).size
program: flash eeprom program: flash eeprom
flash: $(TARGET).hex flash: $(OBJDIR)/$(TARGET).hex
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
eeprom: $(TARGET).eep eeprom: $(OBJDIR)/$(TARGET).eep
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_EEPROM) $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_EEPROM)

1
deps/ssd1306 vendored Submodule

@ -0,0 +1 @@
Subproject commit 5a1056bc6f8c7588f1ee2d01c5251cfb6c3209e7

View file

@ -9,6 +9,7 @@ void print(int str);
void setup(); void setup();
void draw(int x, int y); void draw(int x, int y);
void render(); void render();
void quit();
#ifndef LINUX #ifndef LINUX

View file

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

View file

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

View file

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