diff --git a/.gitignore b/.gitignore index a007fea..6ac506e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,6 @@ build/* +lib/* +deps/* +.idea/* +cmake-build-debug/* +CMakeLists.txt diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..1223867 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "deps/ssd1306"] + path = deps/ssd1306 + url = https://github.com/lexus2k/ssd1306.git diff --git a/Makefile b/Makefile index a368d0c..6a32bbf 100644 --- a/Makefile +++ b/Makefile @@ -2,12 +2,17 @@ all: linux avr linux: + @echo make linux @make -f linux.Makefile linux -avr: +avr: lib/libssd1306.a + @echo make 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: @make -f avr.Makefile flash diff --git a/avr.Makefile b/avr.Makefile index 211e4e7..82c2988 100644 --- a/avr.Makefile +++ b/avr.Makefile @@ -39,18 +39,17 @@ CFLAGS += -std=gnu99 CXXFLAGS += -std=c++11 -CFLAGS += -I$(INCDIR) -DAVR -CXXFLAGS += -I$(INCDIR) -DAVR +CFLAGS += -I$(INCDIR) -DAVR -Ideps/ssd1306/src/ +CXXFLAGS += -I$(INCDIR) -DAVR -Ideps/ssd1306/src/ -#LDFLAGS = +LDFLAGS = -Llib -lssd1306 #==== Programming Options (avrdude) ============================================ AVRDUDE_PROGRAMMER = arduino -AVRDUDE_PORT = /dev/ttyS4 -AVRDUDE_BAUD = 19200 +AVRDUDE_BAUD = 115200 #AVRDUDE_NO_VERIFY = -V @@ -77,8 +76,8 @@ SRC_PATH = $(SRC:%=$(SRCDIR)/%) OBJ = $(SRC_PATH:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o) -AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex -AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep +AVRDUDE_WRITE_FLASH = -U flash:w:$(OBJDIR)/$(TARGET).hex +AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(OBJDIR)/$(TARGET).eep 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 -flash: $(TARGET).hex +flash: $(OBJDIR)/$(TARGET).hex $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) -eeprom: $(TARGET).eep +eeprom: $(OBJDIR)/$(TARGET).eep $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_EEPROM) diff --git a/deps/ssd1306 b/deps/ssd1306 new file mode 160000 index 0000000..5a1056b --- /dev/null +++ b/deps/ssd1306 @@ -0,0 +1 @@ +Subproject commit 5a1056bc6f8c7588f1ee2d01c5251cfb6c3209e7 diff --git a/inc/hal.h b/inc/hal.h index 069419d..cf16b9c 100644 --- a/inc/hal.h +++ b/inc/hal.h @@ -9,6 +9,7 @@ void print(int str); void setup(); void draw(int x, int y); void render(); +void quit(); #ifndef LINUX diff --git a/src/col.cpp b/src/col.cpp index 46a8922..fb3ce15 100644 --- a/src/col.cpp +++ b/src/col.cpp @@ -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){ diff --git a/src/example.cpp b/src/example.cpp index 227b351..2e45fb6 100644 --- a/src/example.cpp +++ b/src/example.cpp @@ -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 +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); diff --git a/src/main.cpp b/src/main.cpp index 2750f29..1bfa77d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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; }