mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-02 03:58:33 +08:00
improve for stm32
This commit is contained in:
parent
bdc017faca
commit
b75065650d
@ -103,7 +103,7 @@ ret_t application_init() {
|
|||||||
|
|
||||||
label = label_create(win, 100, 40, 80, 30);
|
label = label_create(win, 100, 40, 80, 30);
|
||||||
widget_set_text(label, L"C enter");
|
widget_set_text(label, L"C enter");
|
||||||
#ifdef WITH_STM32F103ZE_RAW
|
#ifdef WITH_STB_FONT
|
||||||
widget_use_style(label, "3:center");
|
widget_use_style(label, "3:center");
|
||||||
#else
|
#else
|
||||||
widget_use_style(label, "5:center-ap");
|
widget_use_style(label, "5:center-ap");
|
||||||
@ -117,7 +117,7 @@ ret_t application_init() {
|
|||||||
widget_set_value(progress_bar, 40);
|
widget_set_value(progress_bar, 40);
|
||||||
// timer_add(on_timer, progress_bar, 1000);
|
// timer_add(on_timer, progress_bar, 1000);
|
||||||
|
|
||||||
#ifndef WITH_STM32F103ZE_RAW
|
#ifndef WITH_STB_FONT
|
||||||
progress_bar_set_show_text(progress_bar, TRUE);
|
progress_bar_set_show_text(progress_bar, TRUE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
33
demos/demo_main.c
Normal file → Executable file
33
demos/demo_main.c
Normal file → Executable file
@ -20,45 +20,30 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tk.h"
|
#include "tk.h"
|
||||||
|
#include "base/mem.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include "base/system_info.h"
|
#include "base/system_info.h"
|
||||||
|
|
||||||
ret_t application_init(void);
|
ret_t application_init(void);
|
||||||
|
|
||||||
#ifdef WITH_STM32F103ZE_RAW
|
#ifndef HAS_STD_MALLOC
|
||||||
#include "button.h"
|
#ifndef GUI_HEAP_SIZE
|
||||||
#include "delay.h"
|
#define GUI_HEAP_SIZE 2048
|
||||||
#include "flash.h"
|
#endif/*GUI_HEAP_SIZE*/
|
||||||
#include "gui.h"
|
static uint32_t s_heap_mem[GUI_HEAP_SIZE];
|
||||||
#include "lcd_driver.h"
|
|
||||||
#include "led.h"
|
|
||||||
#include "rtc.h"
|
|
||||||
#include "stdlib.h"
|
|
||||||
#include "sys.h"
|
|
||||||
#include "tim.h"
|
|
||||||
#include "touch.h"
|
|
||||||
#include "usart.h"
|
|
||||||
#include "main_loop/main_loop_stm32_raw.h"
|
|
||||||
|
|
||||||
static __align(8) uint32_t s_heap_mem[2048];
|
|
||||||
#elif defined(WITH_RT_THREAD)
|
|
||||||
#include "main_loop/main_loop_rtthread.h"
|
|
||||||
static uint32_t s_heap_mem[2048];
|
|
||||||
#else
|
#else
|
||||||
#include "main_loop/main_loop_sdl2.h"
|
static uint32_t s_heap_mem[1];
|
||||||
static uint32_t s_heap_mem[2048];
|
#endif/*HAS_STD_MALLOC*/
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_GUI_MAIN
|
#ifdef USE_GUI_MAIN
|
||||||
#include "base/mem.h"
|
|
||||||
int gui_app_start(void* params) {
|
int gui_app_start(void* params) {
|
||||||
#elif defined(WIN32)
|
#elif defined(WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) {
|
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) {
|
||||||
#else
|
#else
|
||||||
#include "base/mem.h"
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
tk_init(320, 480, s_heap_mem, sizeof(s_heap_mem));
|
tk_init(320, 480, s_heap_mem, sizeof(s_heap_mem));
|
||||||
|
|
||||||
resource_init();
|
resource_init();
|
||||||
|
@ -29,7 +29,7 @@ static ret_t lcd_reg_begin_frame(lcd_t* lcd, rect_t* dirty_rect) {
|
|||||||
|
|
||||||
static ret_t lcd_reg_draw_hline(lcd_t* lcd, xy_t x, xy_t y, wh_t w) {
|
static ret_t lcd_reg_draw_hline(lcd_t* lcd, xy_t x, xy_t y, wh_t w) {
|
||||||
wh_t i = 0;
|
wh_t i = 0;
|
||||||
pixel_t color = to_pixel(lcd->stroke_color);
|
pixel_t color = color_to_pixel(lcd->stroke_color);
|
||||||
|
|
||||||
set_window_func(x, y, x + w, y);
|
set_window_func(x, y, x + w, y);
|
||||||
for (i = 0; i < w; i++) {
|
for (i = 0; i < w; i++) {
|
||||||
@ -41,7 +41,7 @@ static ret_t lcd_reg_draw_hline(lcd_t* lcd, xy_t x, xy_t y, wh_t w) {
|
|||||||
|
|
||||||
static ret_t lcd_reg_draw_vline(lcd_t* lcd, xy_t x, xy_t y, wh_t h) {
|
static ret_t lcd_reg_draw_vline(lcd_t* lcd, xy_t x, xy_t y, wh_t h) {
|
||||||
wh_t i = 0;
|
wh_t i = 0;
|
||||||
pixel_t color = to_pixel(lcd->stroke_color);
|
pixel_t color = color_to_pixel(lcd->stroke_color);
|
||||||
|
|
||||||
set_window_func(x, y, x, y + h);
|
set_window_func(x, y, x, y + h);
|
||||||
for (i = 0; i < h; i++) {
|
for (i = 0; i < h; i++) {
|
||||||
@ -53,7 +53,7 @@ static ret_t lcd_reg_draw_vline(lcd_t* lcd, xy_t x, xy_t y, wh_t h) {
|
|||||||
|
|
||||||
static ret_t lcd_reg_draw_points(lcd_t* lcd, point_t* points, uint32_t nr) {
|
static ret_t lcd_reg_draw_points(lcd_t* lcd, point_t* points, uint32_t nr) {
|
||||||
wh_t i = 0;
|
wh_t i = 0;
|
||||||
pixel_t color = to_pixel(lcd->stroke_color);
|
pixel_t color = color_to_pixel(lcd->stroke_color);
|
||||||
|
|
||||||
for (i = 0; i < nr; i++) {
|
for (i = 0; i < nr; i++) {
|
||||||
point_t* point = points + i;
|
point_t* point = points + i;
|
||||||
@ -67,7 +67,7 @@ static ret_t lcd_reg_draw_points(lcd_t* lcd, point_t* points, uint32_t nr) {
|
|||||||
static ret_t lcd_reg_fill_rect(lcd_t* lcd, xy_t x, xy_t y, wh_t w, wh_t h) {
|
static ret_t lcd_reg_fill_rect(lcd_t* lcd, xy_t x, xy_t y, wh_t w, wh_t h) {
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
uint32_t size = w * h;
|
uint32_t size = w * h;
|
||||||
pixel_t color = to_pixel(lcd->fill_color);
|
pixel_t color = color_to_pixel(lcd->fill_color);
|
||||||
|
|
||||||
set_window_func(x, y, x + w - 1, y + h - 1);
|
set_window_func(x, y, x + w - 1, y + h - 1);
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ static ret_t lcd_reg_draw_glyph(lcd_t* lcd, glyph_t* glyph, rect_t* src, xy_t x,
|
|||||||
pixel_t color = blend_color(fill_color, text_color, alpha);
|
pixel_t color = blend_color(fill_color, text_color, alpha);
|
||||||
write_data_func(color);
|
write_data_func(color);
|
||||||
} else {
|
} else {
|
||||||
write_data_func(to_pixel(fill_color));
|
write_data_func(color_to_pixel(fill_color));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
src_p += glyph->w;
|
src_p += glyph->w;
|
||||||
@ -114,7 +114,7 @@ static ret_t lcd_reg_draw_image(lcd_t* lcd, bitmap_t* img, rect_t* src, rect_t*
|
|||||||
wh_t dw = dst->w;
|
wh_t dw = dst->w;
|
||||||
wh_t dh = dst->h;
|
wh_t dh = dst->h;
|
||||||
color_t fill_color = lcd->fill_color;
|
color_t fill_color = lcd->fill_color;
|
||||||
pixel_t fill_pixel = to_pixel(fill_color);
|
pixel_t fill_pixel = color_to_pixel(fill_color);
|
||||||
const color_t* data = (color_t*)img->data;
|
const color_t* data = (color_t*)img->data;
|
||||||
|
|
||||||
if (src->w == dst->w && src->h == dst->h) {
|
if (src->w == dst->w && src->h == dst->h) {
|
||||||
@ -129,7 +129,7 @@ static ret_t lcd_reg_draw_image(lcd_t* lcd, bitmap_t* img, rect_t* src, rect_t*
|
|||||||
if (src_color.rgba.a > 7) {
|
if (src_color.rgba.a > 7) {
|
||||||
pixel_t color = src_color.rgba.a < 0xfe
|
pixel_t color = src_color.rgba.a < 0xfe
|
||||||
? blend_color(fill_color, src_color, src_color.rgba.a)
|
? blend_color(fill_color, src_color, src_color.rgba.a)
|
||||||
: to_pixel(src_color);
|
: color_to_pixel(src_color);
|
||||||
write_data_func(color);
|
write_data_func(color);
|
||||||
} else {
|
} else {
|
||||||
write_data_func(fill_pixel);
|
write_data_func(fill_pixel);
|
||||||
@ -154,7 +154,7 @@ static ret_t lcd_reg_draw_image(lcd_t* lcd, bitmap_t* img, rect_t* src, rect_t*
|
|||||||
if (src_color.rgba.a > 7) {
|
if (src_color.rgba.a > 7) {
|
||||||
pixel_t color = src_color.rgba.a < 0xfe
|
pixel_t color = src_color.rgba.a < 0xfe
|
||||||
? blend_color(fill_color, src_color, src_color.rgba.a)
|
? blend_color(fill_color, src_color, src_color.rgba.a)
|
||||||
: to_pixel(src_color);
|
: color_to_pixel(src_color);
|
||||||
|
|
||||||
set_window_func(x, y, x, y);
|
set_window_func(x, y, x, y);
|
||||||
write_data_func(color);
|
write_data_func(color);
|
||||||
|
Loading…
Reference in New Issue
Block a user