Merge remote-tracking branch 'origin/emulator' into dev_aaron

This commit is contained in:
id101010
2015-05-04 22:09:34 +02:00
26 changed files with 1241 additions and 246 deletions

View File

@@ -1,7 +1,7 @@
#include "tft.h"
#include "ll_tft.h"
//it might seems pointless to forward all the functions but we might also introduce functions which have some logic here
#include <string.h>
#include <stdarg.h>
bool tft_init() {
return ll_tft_init();
@@ -37,3 +37,32 @@ void tft_draw_bitmap_unscaled(uint16_t x, uint16_t y, uint16_t width, uint16_t h
void tft_draw_circle(uint16_t x, uint16_t y, uint16_t r, uint16_t color) {
ll_tft_draw_circle(x, y, r, color);
}
uint8_t tft_num_fonts() {
return ll_tft_num_fonts();
}
uint8_t tft_font_height(uint8_t fontnum) {
return ll_tft_font_height(fontnum);
}
uint8_t tft_font_width(uint8_t fontnum) {
return ll_tft_font_width(fontnum);
}
void tft_print_line(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, const char* text) {
if(font>=ll_tft_num_fonts()) return;
for(int i=0; i<strlen(text); i++) {
ll_tft_draw_char(x,y,color,bgcolor, font, text[i]);
x+=ll_tft_font_width(font);
}
}
void tft_print_formatted(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, const char* format, ...) {
static char buffer[256]; //not sure if that's the best solution. It would propbably better to implement putchar and use vprintf
va_list args;
va_start (args, format);
vsprintf(buffer,format,args);
tft_print_line(x,y,color,bgcolor,font,buffer);
va_end(args);
}

View File

@@ -9,6 +9,7 @@
#define WHITE 0xF7BE
#define BLACK RGB(0,0,0)
#define HEX(h) (RGB(((h)>>16),((h)>>8),(h)))
#define TRANSPARENT ((uint16_t)0x80C2)
bool tft_init();
@@ -19,3 +20,10 @@ void tft_draw_rectangle(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2, uint16_
void tft_fill_rectangle(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2, uint16_t color);
void tft_draw_bitmap_unscaled(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint16_t* dat);
void tft_draw_circle(uint16_t x, uint16_t y, uint16_t r, uint16_t color);
uint8_t tft_num_fonts();
uint8_t tft_font_height(uint8_t fontnum);
uint8_t tft_font_width(uint8_t fontnum);
void tft_print_line(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, const char* text);
void tft_print_formatted(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, const char* format, ...);