diff --git a/OBJECTS b/OBJECTS index 23bfc66..4213de3 100644 --- a/OBJECTS +++ b/OBJECTS @@ -1,5 +1,5 @@ TARGET = main -SRC = col.cpp hal.cpp main.cpp example.cpp +SRC = col.cpp hal.cpp main.cpp example.cpp gfx/screen.cpp gfx/canvas.cpp gfx/font.cpp SRCDIR = src INCDIR = inc diff --git a/avr.Makefile b/avr.Makefile index 82c2988..b670676 100644 --- a/avr.Makefile +++ b/avr.Makefile @@ -175,10 +175,12 @@ $(OBJDIR)/%.elf: $(OBJ) | $(OBJDIR) $(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR) @echo compile $< + @mkdir -p $(dir $@) @$(CC) -c $(CPU) $(CFLAGS) $< -o $@ $(OBJDIR)/%.o: $(SRCDIR)/%.cpp | $(OBJDIR) @echo compile $< + @mkdir -p $(dir $@) @$(CXX) -c $(CPU) $(CXXFLAGS) $< -o $@ diff --git a/inc/gfx/canvas.h b/inc/gfx/canvas.h new file mode 100644 index 0000000..a3213b1 --- /dev/null +++ b/inc/gfx/canvas.h @@ -0,0 +1,48 @@ +// +// Created by jedi on 11/1/18. +// + +#ifndef MGL_DMXMENU_CANVAS_H +#define MGL_DMXMENU_CANVAS_H + +#include "hal.h" +#include "gfx/font.h" + +class canvas { +private: + const int width_; + const int height_; +public: + + canvas(int w, int h) : width_(w), height_(h) { + + } + + void draw(int x, int y) { + hal_draw(x, y); + } + + void print(int x, int y, const char *str) { + for (int i = 0; str[i]; i++) { + int j = (str[i] - ' ') % 32; + for (int x_ = 0; x_ < 4; x_++) + for (int y_ = 0; y_ < 5; y_++) + if (testFont[j][x_ + 4 * y_]) + draw(x + i * 5 + x_, y + y_); + } + } + + void print(int x, int y, char *str) { + for (int i = 0; str[i]; i++) { + int j = (str[i] - ' ') % 32; + for (int x_ = 0; x_ < 4; x_++) + for (int y_ = 0; y_ < 5; y_++) + if (testFont[j][x_ + 4 * y_]) + draw(x + i * 5 + x_, y + y_); + } + } + +}; + + +#endif //MGL_DMXMENU_CANVAS_H diff --git a/inc/gfx/font.h b/inc/gfx/font.h new file mode 100644 index 0000000..76a321b --- /dev/null +++ b/inc/gfx/font.h @@ -0,0 +1,16 @@ +// +// Created by jedi on 11/1/18. +// + +#ifndef MGL_DMXMENU_FONT_H +#define MGL_DMXMENU_FONT_H + + + +class font { + +}; + +extern bool testFont[32][20]; + +#endif //MGL_DMXMENU_FONT_H diff --git a/inc/gfx/screen.h b/inc/gfx/screen.h new file mode 100644 index 0000000..2c14a77 --- /dev/null +++ b/inc/gfx/screen.h @@ -0,0 +1,32 @@ +// +// Created by jedi on 11/1/18. +// + +#ifndef MGL_DMXMENU_SCREEN_H +#define MGL_DMXMENU_SCREEN_H + +#include "hal.h" + +//template +class screen { +private: + const int width_; + const int height_; + +public: + screen(int w, int h): width_(w), height_(h){ + + } + + void draw(int x, int y){ + hal_draw(x,y); + } + + void print(int x, int y, char* str){ + + } + +}; + + +#endif //MGL_DMXMENU_SCREEN_H diff --git a/inc/hal.h b/inc/hal.h index 7d85635..d2fbe7c 100644 --- a/inc/hal.h +++ b/inc/hal.h @@ -11,9 +11,9 @@ void debug(const char* str); -void setup(); -void draw(int x, int y); -void print(int x, int y, const char* str); +void hal_init(); +void hal_draw(int x, int y); +void hal_print(int x, int y, const char* str); void render(Layout&); void quit(); diff --git a/linux.Makefile b/linux.Makefile index ca62658..7f3236b 100644 --- a/linux.Makefile +++ b/linux.Makefile @@ -28,10 +28,12 @@ $(OBJDIR)/$(TARGET): $(OBJ) | $(OBJDIR) $(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR) @echo compile $< + @mkdir -p $(dir $@) @$(CC) -c $(CFLAGS) $< -o $@ $(OBJDIR)/%.o: $(SRCDIR)/%.cpp | $(OBJDIR) @echo compile $< + @mkdir -p $(dir $@) @$(CXX) -c $(CXXFLAGS) $< -o $@ $(OBJDIR): diff --git a/src/example.cpp b/src/example.cpp index f4c2030..101da8c 100644 --- a/src/example.cpp +++ b/src/example.cpp @@ -17,13 +17,13 @@ void draw_foo(int offset, int size, Node* ptr){ debug("|");*/ for(int i = 0; i<32; i++) - draw(offset,i); + hal_draw(offset,i); for(int i = 0; ititle_); + hal_print(offset+5 , 10, ptr->title_); peng[0]=input[0]?' ':'#'; peng[1]=input[1]?' ':'#'; peng[2]=input[2]?' ':'#'; @@ -31,7 +31,7 @@ void draw_foo(int offset, int size, Node* ptr){ j++; j%=26; peng[4] = 'a'+j; - print(offset+5 , 20, peng); + hal_print(offset+5 , 20, peng); } void draw_blub(int offset, int size, Node* ptr){ @@ -42,9 +42,9 @@ void draw_blub(int offset, int size, Node* ptr){ //print(ptr->state); debug("#");*/ for(int i = 0; i<32;i++) - draw(offset,i); + hal_draw(offset,i); - print(offset+5 , 10, ptr->title_); + hal_print(offset+5 , 10, ptr->title_); } void draw_menu(int offset, int size, Node* val){ @@ -56,7 +56,7 @@ void draw_menu(int offset, int size, Node* val){ }*/ for(int i = 0; i<32;i++) - draw(offset,i); + hal_draw(offset,i); for(int i = 0; i<32 && i +#include + + +extern SDL_Window* window; +extern SDL_Event event; +extern SDL_Renderer *renderer; -#ifdef AVR -#include "ssd1306.h" #endif @@ -36,13 +45,44 @@ int main() { //walk tree + allocate slots //position slots // 128 x 32 + screen s(128, 32);//<128, 32> s; + Layout l(128); l.apply(&root); //render - setup(); - render(l); + hal_init(); + //render(l); + canvas c(64,32); + char foo[] = "ABCDEFGHIJKLMOPQRSTUVWXYZ"; + c.print(1,1,"HELLO"); + c.print(1,7,"Foo Bar"); + c.print(1,13,foo); + //s.draw(0,0,c); + +#ifdef LINUX + bool quit = false; + + SDL_RenderPresent(renderer); + + while (!quit) { + if (SDL_WaitEvent(&event)) { + switch (event.type) { + case SDL_QUIT: + quit = true; + break; + } + } + + + } + + SDL_DestroyRenderer(renderer); + SDL_DestroyWindow(window); + SDL_Quit(); + +#endif return 0; }