Show the use of multiple fonts
This commit is contained in:
@ -4,7 +4,6 @@
|
||||
#include "mgos.h"
|
||||
#include "mgos_pwm.h"
|
||||
#include "mongoose-touch.h"
|
||||
#include "fonts/FreeMonoBold9pt7b.h"
|
||||
|
||||
struct screen_t *screen = NULL;
|
||||
|
||||
@ -52,7 +51,6 @@ void tft_demo(void)
|
||||
mgos_stmpe610_set_handler(touch_handler);
|
||||
mgos_stmpe610_set_dimensions(320, 240);
|
||||
|
||||
mgos_ili9341_set_font(&FreeMonoBold9pt7b);
|
||||
mgos_ili9341_set_fgcolor(0,0,0);
|
||||
mgos_ili9341_fillScreen();
|
||||
|
||||
|
@ -27,7 +27,7 @@ static void widget_battery_render(struct widget_t *w, void *ev_data) {
|
||||
if (!w)
|
||||
return;
|
||||
|
||||
mgos_ili9341_set_window(w->x, w->y, w->x+w->w, w->y+w->h);
|
||||
mgos_ili9341_set_window(w->x, w->y, w->x+w->w-1, w->y+w->h-1);
|
||||
|
||||
mvolts=widget_battery_getvoltage();
|
||||
color=ILI9341_RED;
|
||||
|
@ -4,7 +4,7 @@
|
||||
static void widget_default_draw(struct widget_t *w, uint16_t color) {
|
||||
if (!w)
|
||||
return;
|
||||
mgos_ili9341_set_window(w->x, w->y, w->x+w->w, w->y+w->h);
|
||||
mgos_ili9341_set_window(w->x, w->y, w->x+w->w-1, w->y+w->h-1);
|
||||
|
||||
mgos_ili9341_set_fgcolor565(color);
|
||||
mgos_ili9341_drawRoundRect(0, 0, w->w, w->h, 8);
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "mgos_wifi.h"
|
||||
#include "mgos_net.h"
|
||||
#include "mongoose-touch.h"
|
||||
#include "fonts/FreeMonoBold9pt7b.h"
|
||||
|
||||
#define WIDGET_NAME_NAME 0
|
||||
#define WIDGET_NAME_IPADDR 1
|
||||
@ -16,6 +17,7 @@ extern struct screen_t *screen;
|
||||
static void widget_name_render(struct widget_t *w, void *ev_data) {
|
||||
char namestring[21];
|
||||
char *p = NULL;
|
||||
int16_t text_height;
|
||||
|
||||
|
||||
if (!w)
|
||||
@ -54,11 +56,14 @@ static void widget_name_render(struct widget_t *w, void *ev_data) {
|
||||
sprintf(namestring, "%-20s",mgos_sys_config_get_app_hostname());
|
||||
}
|
||||
|
||||
mgos_ili9341_set_window(w->x, w->y, w->x+w->w, w->y+w->h);
|
||||
mgos_ili9341_set_window(w->x, w->y, w->x+w->w-1, w->y+w->h-1);
|
||||
mgos_ili9341_set_fgcolor565(ILI9341_BLACK);
|
||||
mgos_ili9341_fillRect(0, 0, w->w, w->h);
|
||||
|
||||
mgos_ili9341_set_font(&FreeMonoBold9pt7b);
|
||||
mgos_ili9341_set_fgcolor565(ILI9341_GREEN);
|
||||
mgos_ili9341_print(2, 4, namestring);
|
||||
text_height=mgos_ili9341_getStringHeight(namestring);
|
||||
mgos_ili9341_print(2, text_height>w->h?0:(w->h-text_height)/2, namestring);
|
||||
|
||||
(void) ev_data;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ static mgos_timer_id recv_timer = 0;
|
||||
static struct widget_t *widget_network = NULL;
|
||||
|
||||
static void widget_network_render(struct widget_t *w, void *ev_data) {
|
||||
mgos_ili9341_set_window(w->x, w->y, w->x+w->w, w->y+w->h);
|
||||
mgos_ili9341_set_window(w->x, w->y, w->x+w->w-1, w->y+w->h-1);
|
||||
// Send
|
||||
mgos_ili9341_set_fgcolor565(send_timer?ILI9341_YELLOW:ILI9341_DARKGREY);
|
||||
mgos_ili9341_fillTriangle(2, 10, 10, 10, 6, 2);
|
||||
|
@ -1,8 +1,10 @@
|
||||
#include "mgos.h"
|
||||
#include "mongoose-touch.h"
|
||||
#include "fonts/FreeSerifBold9pt7b.h"
|
||||
|
||||
static void widget_time_render(struct widget_t *w, void *ev_data) {
|
||||
char tmp_buff[32];
|
||||
int16_t text_width, text_height;
|
||||
|
||||
time_t now = 3600 + time(0); // TZ=GMT+1
|
||||
struct tm* tm_info = gmtime(&now);
|
||||
@ -11,9 +13,14 @@ static void widget_time_render(struct widget_t *w, void *ev_data) {
|
||||
return;
|
||||
|
||||
mgos_ili9341_set_fgcolor565(ILI9341_YELLOW);
|
||||
sprintf(tmp_buff, " %02d:%02d", tm_info->tm_hour, tm_info->tm_min);
|
||||
mgos_ili9341_set_window(w->x, w->y, w->x+w->w, w->y+w->h);
|
||||
mgos_ili9341_print(2, 4, tmp_buff);
|
||||
sprintf(tmp_buff, " %02d:%02d:%02d", tm_info->tm_hour, tm_info->tm_min, tm_info->tm_sec);
|
||||
mgos_ili9341_set_window(w->x, w->y, w->x+w->w-1, w->y+w->h-1);
|
||||
mgos_ili9341_set_font(&FreeSerifBold9pt7b);
|
||||
|
||||
text_width=mgos_ili9341_getStringWidth(tmp_buff);
|
||||
text_height=mgos_ili9341_getStringHeight(tmp_buff);
|
||||
|
||||
mgos_ili9341_print(text_width>w->w?0:(w->w-text_width)/2, text_height>w->h?0:(w->h-text_height)/2, tmp_buff);
|
||||
|
||||
(void) ev_data;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ static void widget_topbar_render(struct widget_t *w, void *ev_data) {
|
||||
if (!w)
|
||||
return;
|
||||
|
||||
mgos_ili9341_set_window(w->x, w->y, w->x+w->w, w->y+w->h);
|
||||
mgos_ili9341_set_window(w->x, w->y, w->x+w->w-1, w->y+w->h-1);
|
||||
mgos_ili9341_set_fgcolor565(ILI9341_WHITE);
|
||||
mgos_ili9341_fillRect(0, 0, w->w, w->h);
|
||||
|
||||
|
@ -24,7 +24,7 @@ static uint8_t widget_wifi_signal() {
|
||||
static void widget_wifi_render(struct widget_t *w, void *ev_data) {
|
||||
uint8_t x, signal;
|
||||
|
||||
mgos_ili9341_set_window(w->x, w->y, w->x+w->w, w->y+w->h);
|
||||
mgos_ili9341_set_window(w->x, w->y, w->x+w->w-1, w->y+w->h-1);
|
||||
|
||||
mgos_ili9341_set_fgcolor565(ILI9341_DARKGREY);
|
||||
mgos_ili9341_fillTriangle(2, 18, 18, 18, 18, 2);
|
||||
|
Reference in New Issue
Block a user