add 5x4 Font
This commit is contained in:
		
							parent
							
								
									987aa92a23
								
							
						
					
					
						commit
						1009d689bc
					
				
					 15 changed files with 346 additions and 25 deletions
				
			
		
							
								
								
									
										2
									
								
								OBJECTS
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 $@
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										48
									
								
								inc/gfx/canvas.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								inc/gfx/canvas.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -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
 | 
			
		||||
							
								
								
									
										16
									
								
								inc/gfx/font.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								inc/gfx/font.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -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
 | 
			
		||||
							
								
								
									
										32
									
								
								inc/gfx/screen.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								inc/gfx/screen.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -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 <int WIDTH, int HEIGHT>
 | 
			
		||||
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
 | 
			
		||||
| 
						 | 
				
			
			@ -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();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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; i<size; i++)
 | 
			
		||||
		draw(offset+i,31-i%32);
 | 
			
		||||
		hal_draw(offset+i,31-i%32);
 | 
			
		||||
	for(int i = 0; i<size; i++)
 | 
			
		||||
		draw(offset+i,31-(i+16)%32);
 | 
			
		||||
		hal_draw(offset+i,31-(i+16)%32);
 | 
			
		||||
 | 
			
		||||
	print(offset+5 , 10, ptr->title_);
 | 
			
		||||
	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<size;i++)
 | 
			
		||||
		draw(offset+(i%size),i);
 | 
			
		||||
		hal_draw(offset+(i%size),i);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										5
									
								
								src/gfx/canvas.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/gfx/canvas.cpp
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,5 @@
 | 
			
		|||
//
 | 
			
		||||
// Created by jedi on 11/1/18.
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
#include "gfx/canvas.h"
 | 
			
		||||
							
								
								
									
										170
									
								
								src/gfx/font.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										170
									
								
								src/gfx/font.cpp
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,170 @@
 | 
			
		|||
//
 | 
			
		||||
// Created by jedi on 11/1/18.
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
#include "gfx/font.h"
 | 
			
		||||
 | 
			
		||||
bool testFont[32][20] = {
 | 
			
		||||
        //0
 | 
			
		||||
        {0,0,0,0,
 | 
			
		||||
         0,0,0,0,
 | 
			
		||||
         0,0,0,0,
 | 
			
		||||
         0,0,0,0,
 | 
			
		||||
         0,0,0,0},
 | 
			
		||||
        //A
 | 
			
		||||
        {0,1,1,0,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         1,1,1,1,
 | 
			
		||||
         1,0,0,1},
 | 
			
		||||
        //B
 | 
			
		||||
        {1,1,1,0,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         1,1,1,0,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         1,1,1,0},
 | 
			
		||||
        //C
 | 
			
		||||
        {0,1,1,0,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         1,0,0,0,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         0,1,1,0},
 | 
			
		||||
        //D
 | 
			
		||||
        {1,1,1,0,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         1,1,1,0},
 | 
			
		||||
        //E
 | 
			
		||||
        {1,1,1,1,
 | 
			
		||||
         1,0,0,0,
 | 
			
		||||
         1,1,1,0,
 | 
			
		||||
         1,0,0,0,
 | 
			
		||||
         1,1,1,1},
 | 
			
		||||
        //F
 | 
			
		||||
        {1,1,1,1,
 | 
			
		||||
         1,0,0,0,
 | 
			
		||||
         1,1,1,0,
 | 
			
		||||
         1,0,0,0,
 | 
			
		||||
         1,0,0,0},
 | 
			
		||||
        //G
 | 
			
		||||
        {0,1,1,1,
 | 
			
		||||
         1,0,0,0,
 | 
			
		||||
         1,0,1,1,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         0,1,1,1},
 | 
			
		||||
        //H
 | 
			
		||||
        {1,0,0,1,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         1,1,1,1,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         1,0,0,1},
 | 
			
		||||
        //I
 | 
			
		||||
        {1,1,1,0,
 | 
			
		||||
         0,1,0,0,
 | 
			
		||||
         0,1,0,0,
 | 
			
		||||
         0,1,0,0,
 | 
			
		||||
         1,1,1,0},
 | 
			
		||||
        //J
 | 
			
		||||
        {1,1,1,1,
 | 
			
		||||
         0,0,0,1,
 | 
			
		||||
         0,0,0,1,
 | 
			
		||||
         0,0,0,1,
 | 
			
		||||
         1,1,1,0},
 | 
			
		||||
        //K
 | 
			
		||||
        {1,0,0,1,
 | 
			
		||||
         1,0,1,0,
 | 
			
		||||
         1,1,0,0,
 | 
			
		||||
         1,0,1,0,
 | 
			
		||||
         1,0,0,1},
 | 
			
		||||
        //L
 | 
			
		||||
        {1,0,0,0,
 | 
			
		||||
         1,0,0,0,
 | 
			
		||||
         1,0,0,0,
 | 
			
		||||
         1,0,0,0,
 | 
			
		||||
         1,1,1,1},
 | 
			
		||||
        //M
 | 
			
		||||
        {1,0,0,1,
 | 
			
		||||
         1,1,1,1,
 | 
			
		||||
         1,1,1,1,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         1,0,0,1},
 | 
			
		||||
        //N
 | 
			
		||||
        {1,0,0,1,
 | 
			
		||||
         1,1,0,1,
 | 
			
		||||
         1,0,1,1,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         1,0,0,1},
 | 
			
		||||
        //O
 | 
			
		||||
        {0,1,1,0,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         0,1,1,0},
 | 
			
		||||
        //P
 | 
			
		||||
        {1,1,1,0,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         1,1,1,0,
 | 
			
		||||
         1,0,0,0},
 | 
			
		||||
        //Q
 | 
			
		||||
        {0,1,1,0,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         1,0,1,1,
 | 
			
		||||
         0,1,1,1},
 | 
			
		||||
        //R
 | 
			
		||||
        {1,1,1,0,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         1,1,1,0,
 | 
			
		||||
         1,0,0,1},
 | 
			
		||||
        //S
 | 
			
		||||
        {0,1,1,1,
 | 
			
		||||
         1,0,0,0,
 | 
			
		||||
         0,1,1,0,
 | 
			
		||||
         0,0,0,1,
 | 
			
		||||
         1,1,1,0},
 | 
			
		||||
        //T
 | 
			
		||||
        {1,1,1,1,
 | 
			
		||||
         0,0,1,0,
 | 
			
		||||
         0,0,1,0,
 | 
			
		||||
         0,0,1,0,
 | 
			
		||||
         0,0,1,0},
 | 
			
		||||
        //U
 | 
			
		||||
        {1,0,0,1,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         0,1,1,0},
 | 
			
		||||
        //V
 | 
			
		||||
        {1,0,0,1,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         1,0,1,0,
 | 
			
		||||
         1,0,1,0,
 | 
			
		||||
         0,1,0,0},
 | 
			
		||||
        //W
 | 
			
		||||
        {1,0,0,1,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         1,1,1,1,
 | 
			
		||||
         1,1,1,1,
 | 
			
		||||
         0,1,1,0},
 | 
			
		||||
        //X
 | 
			
		||||
        {1,0,0,1,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         0,1,1,0,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         1,0,0,1},
 | 
			
		||||
        //Y
 | 
			
		||||
        {1,0,0,1,
 | 
			
		||||
         1,0,0,1,
 | 
			
		||||
         0,1,1,1,
 | 
			
		||||
         0,0,0,1,
 | 
			
		||||
         1,1,1,0},
 | 
			
		||||
        //Z
 | 
			
		||||
        {1,1,1,1,
 | 
			
		||||
         0,0,0,1,
 | 
			
		||||
         0,1,1,0,
 | 
			
		||||
         1,0,0,0,
 | 
			
		||||
         1,1,1,1},
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										5
									
								
								src/gfx/screen.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/gfx/screen.cpp
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,5 @@
 | 
			
		|||
//
 | 
			
		||||
// Created by jedi on 11/1/18.
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
#include "gfx/screen.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
#include "hal.h"
 | 
			
		||||
 | 
			
		||||
const int SCREEN_WIDTH = 128; 
 | 
			
		||||
const int SCREEN_WIDTH = 128;
 | 
			
		||||
const int SCREEN_HEIGHT = 32;
 | 
			
		||||
 | 
			
		||||
bool input[4];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,19 +9,20 @@
 | 
			
		|||
uint8_t canvasData[SCREEN_WIDTH*(SCREEN_HEIGHT/8)];
 | 
			
		||||
NanoCanvas canvas(SCREEN_WIDTH, SCREEN_HEIGHT, canvasData);
 | 
			
		||||
 | 
			
		||||
void setup(){
 | 
			
		||||
void hal_init(){
 | 
			
		||||
    ssd1306_128x32_i2c_init();
 | 
			
		||||
    ssd1306_fillScreen( 0x00 );
 | 
			
		||||
    //ssd1306_setFixedFont(ssd1306xled_font6x8);
 | 
			
		||||
    ssd1306_setFixedFont(ssd1306xled_font5x7);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void draw(int x, int y){
 | 
			
		||||
void hal_draw(int x, int y){
 | 
			
		||||
    canvas.putPixel(x, y);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void print(int x, int y, const char* str){
 | 
			
		||||
void hal_print(int x, int y, const char* str){
 | 
			
		||||
    canvas.printFixed(x, y, str, STYLE_NORMAL);
 | 
			
		||||
    //TODO delete
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void render(Layout& layout) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,7 +12,7 @@ SDL_Window* window = NULL;
 | 
			
		|||
SDL_Event event;
 | 
			
		||||
SDL_Renderer *renderer;
 | 
			
		||||
 | 
			
		||||
void setup(){
 | 
			
		||||
void hal_init(){
 | 
			
		||||
    if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) {
 | 
			
		||||
        printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() );
 | 
			
		||||
        exit(1);
 | 
			
		||||
| 
						 | 
				
			
			@ -37,12 +37,12 @@ void setup(){
 | 
			
		|||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void draw(int x, int y){
 | 
			
		||||
void hal_draw(int x, int y){
 | 
			
		||||
    SDL_RenderDrawPoint(renderer, x, y);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void print(int x, int y, const char* str){
 | 
			
		||||
    //TODO implement
 | 
			
		||||
void hal_print(int x, int y, const char* str){
 | 
			
		||||
    //TODO delete
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void render(Layout& layout) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										48
									
								
								src/main.cpp
									
										
									
									
									
								
							
							
						
						
									
										48
									
								
								src/main.cpp
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -5,9 +5,18 @@
 | 
			
		|||
 | 
			
		||||
#include "example.h"
 | 
			
		||||
 | 
			
		||||
#include "gfx/screen.h"
 | 
			
		||||
#include "gfx/canvas.h"
 | 
			
		||||
 | 
			
		||||
#ifdef LINUX
 | 
			
		||||
#include <SDL2/SDL.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
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;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue