Added font support
This commit is contained in:
@@ -50,7 +50,7 @@ void app_init() {
|
||||
tft_draw_rectangle(40,210,60,235,BLUE);
|
||||
tft_fill_rectangle(100,215,200,225,GREEN);
|
||||
tft_draw_line(10,215,310,225,RGB(0xFF,0,0xFF));
|
||||
tft_draw_circle(10,10,100, RED);
|
||||
tft_draw_circle(10,10,100, RED);
|
||||
|
||||
a1.hookedActions = PEN_DOWN | PEN_UP | PEN_MOVE | PEN_ENTER | PEN_LEAVE;
|
||||
a1.x1 = 30;
|
||||
@@ -60,8 +60,8 @@ void app_init() {
|
||||
a1.callback = touchCB;
|
||||
touch_register_area(&a1);
|
||||
|
||||
tft_draw_rectangle(30,30,100,60,BLUE);
|
||||
|
||||
tft_draw_rectangle(30,30,100,60,BLUE);
|
||||
tft_print_line(30, 30, RED, BLUE, 0, "Hallo");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,3 +9,13 @@ void ll_tft_draw_rectangle(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2, uint
|
||||
void ll_tft_fill_rectangle(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2, uint16_t color);
|
||||
void ll_tft_draw_bitmap_unscaled(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint16_t *dat);
|
||||
void ll_tft_draw_circle(uint16_t x, uint16_t y, uint16_t r, uint16_t color);
|
||||
|
||||
|
||||
uint8_t ll_tft_num_fonts();
|
||||
uint8_t ll_tft_font_height(uint8_t fontnum);
|
||||
uint8_t ll_tft_font_width(uint8_t fontnum);
|
||||
void ll_tft_draw_char(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, char c);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "tft.h"
|
||||
#include "ll_tft.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
//it might seems pointless to forward all the functions but we might also introduce functions which have some logic here
|
||||
|
||||
@@ -37,3 +39,24 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#define WHITE RGB(255,255,255)
|
||||
#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,9 @@ 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);
|
||||
|
||||
Reference in New Issue
Block a user