Added more tft functions to common and emulator. Fixed eventloop.
This commit is contained in:
@@ -1,14 +1,27 @@
|
||||
#include "app.h"
|
||||
#include "tft.h"
|
||||
#include "system.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void app_init() {
|
||||
system_init();
|
||||
tft_init();
|
||||
|
||||
|
||||
//only testwise
|
||||
tft_clear(WHITE);
|
||||
tft_draw_pixel(0,0,GREEN);
|
||||
tft_draw_pixel(320-1,240-1,GREEN);
|
||||
tft_draw_line(10,10,30,40,RGB(0xFF,0,0xFF));
|
||||
tft_draw_pixel(100,100,RED);
|
||||
tft_draw_rectangle(120,120,20,30,BLUE);
|
||||
tft_fill_rectangle(200,120,30,30,GREEN);
|
||||
|
||||
tft_draw_line(10,10,30,40,0b11111);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//app event loop
|
||||
void app_process() {
|
||||
/// printf("hello world\n");
|
||||
|
||||
|
||||
2
common/lowlevel/ll_system.h
Normal file
2
common/lowlevel/ll_system.h
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
bool ll_system_init();
|
||||
@@ -1,14 +1,10 @@
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
bool ll_tft_init();
|
||||
void ll_tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
bool ll_tft_init();
|
||||
void ll_tft_clear(uint16_t color);
|
||||
void ll_tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
|
||||
void ll_tft_draw_pixel(uint16_t x,uint16_t y,uint16_t color);
|
||||
void ll_tft_draw_rectangle(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2, uint16_t color);
|
||||
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 uint8_t* dat);
|
||||
|
||||
|
||||
8
common/system/system.c
Normal file
8
common/system/system.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include "system.h"
|
||||
#include "ll_system.h"
|
||||
|
||||
|
||||
bool system_init() {
|
||||
return ll_system_init();
|
||||
}
|
||||
|
||||
4
common/system/system.h
Normal file
4
common/system/system.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
bool system_init();
|
||||
@@ -1,13 +1,35 @@
|
||||
#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
|
||||
|
||||
bool tft_init() {
|
||||
return ll_tft_init();
|
||||
|
||||
}
|
||||
|
||||
void tft_clear(uint16_t color) {
|
||||
ll_tft_clear(color);
|
||||
}
|
||||
|
||||
void tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color) {
|
||||
ll_tft_draw_line(x1,y1,x2,y2,color);
|
||||
}
|
||||
|
||||
|
||||
void tft_draw_pixel(uint16_t x,uint16_t y,uint16_t color) {
|
||||
ll_tft_draw_pixel(x,y,color);
|
||||
}
|
||||
|
||||
void tft_draw_rectangle(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2, uint16_t color) {
|
||||
//could be implemented with 4 lines instead of introducing a ll func
|
||||
ll_tft_draw_rectangle(x1,y1,x2,y2,color);
|
||||
}
|
||||
|
||||
void tft_fill_rectangle(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2, uint16_t color) {
|
||||
ll_tft_fill_rectangle(x1,y1,x2,y2,color);
|
||||
}
|
||||
|
||||
void tft_draw_bitmap_unscaled(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint8_t* dat) {
|
||||
ll_tft_draw_bitmap_unscaled(x,y,width,height,dat);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
#include<stdbool.h>
|
||||
#include<stdint.h>
|
||||
|
||||
|
||||
#define RGB(r,g,b) ((((r) & 0xF8) << 8) | (((g) & 0xFC) << 3) | (((b) & 0xF8) >> 3))
|
||||
#define RED RGB(255,0,0)
|
||||
#define GREEN RGB(0,255,0)
|
||||
#define BLUE RGB(0,0,255)
|
||||
#define WHITE RGB(255,255,255)
|
||||
#define BLACK RGB(0,0,0)
|
||||
#define HEX(h) (RGB(((h)>>16),((h)>>8),(h)))
|
||||
|
||||
|
||||
bool tft_init();
|
||||
void tft_clear(uint16_t color);
|
||||
void tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
|
||||
void tft_draw_pixel(uint16_t x,uint16_t y,uint16_t color);
|
||||
void tft_draw_rectangle(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2, uint16_t color);
|
||||
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 uint8_t* dat);
|
||||
|
||||
Reference in New Issue
Block a user