Browse Source

update

v1.0
zhaohe 1 year ago
parent
commit
fd8ed7742e
  1. 139
      app/src/basic/ssd1306/driver_ssd1306_basic.c
  2. 4
      app/src/basic/ssd1306/driver_ssd1306_basic.h
  3. 58
      app/src/one_conduction/display_manager.c
  4. 5
      app/src/one_conduction/display_manager.h
  5. 38
      app/src/one_conduction/font.h
  6. 4
      app/src/one_conduction/one_conduction_main.c
  7. BIN
      res/Snipaste_2024-01-26_20-00-58.png

139
app/src/basic/ssd1306/driver_ssd1306_basic.c

@ -561,7 +561,7 @@ uint8_t ssd1306_basic_draw_one_chr(uint8_t xs, uint8_t ys, char *str, FontLibrar
return 0; return 0;
} }
uint8_t ssd1306_basic_draw_str(uint8_t xs, uint8_t ys, const char *str, FontLibrary_t *frontlib) {
uint8_t ssd1306_basic_draw_str(uint8_t xs, uint8_t ys, uint8_t *xchange, uint8_t *ychange, const char *str, FontLibrary_t *frontlib) {
uint8_t x = xs; uint8_t x = xs;
uint8_t y = ys; uint8_t y = ys;
StrIterator_t iterator; StrIterator_t iterator;
@ -575,7 +575,144 @@ uint8_t ssd1306_basic_draw_str(uint8_t xs, uint8_t ys, const char *str, FontLibr
} }
ssd1306_basic_draw_one_chr(x, y, nowchr, frontlib); ssd1306_basic_draw_one_chr(x, y, nowchr, frontlib);
x += (uint8_t)(frontlib->widthPixel); /* x + font/2 */ x += (uint8_t)(frontlib->widthPixel); /* x + font/2 */
*xchange += frontlib->widthPixel;
} }
} }
*ychange += frontlib->heightPixel;
return 0; return 0;
} }
uint8_t ssd1306_basic_draw_battery_level(uint8_t xs, uint8_t ys, uint8_t *xchange, uint8_t *ychange, int level, int width, int high) {
/**
* @brief
* *****
* ********
* * *
* * **** *
* * **** *
* ********
*/
uint8_t xoff = 0;
uint8_t yoff = 0;
int batteryHeaderHigh = 2;
int batteryHeaderWidth = 7;
int batteryBodyHigh = 20;
int batteryBodyWidth = 12;
int border_width = 1;
int blank_width = 1;
float width_mult = width * 1.0 / batteryBodyWidth;
float high_mult = high * 1.0 / (batteryBodyHigh + batteryHeaderHigh);
batteryHeaderHigh = batteryHeaderHigh * high_mult;
batteryHeaderWidth = batteryHeaderWidth * width_mult;
batteryBodyHigh = batteryBodyHigh * high_mult;
batteryBodyWidth = batteryBodyWidth * width_mult;
border_width = 1;
blank_width = 1;
int batteryInterBodyWidth = batteryBodyWidth - blank_width * 2 - border_width * 2;
int batteryInterBodyHigh = batteryBodyHigh - border_width * 2 - blank_width * 2;
/**
* @brief
*/
for (int yoff = 0; yoff < batteryHeaderHigh; yoff++) {
for (int xoff = 0; xoff < batteryBodyWidth; xoff++) {
uint16_t battery_start = (batteryBodyWidth - batteryHeaderWidth) / 2;
uint16_t battery_end = battery_start + batteryHeaderWidth;
if (xoff >= battery_start && xoff <= battery_end) {
ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 1);
} else {
ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 0);
}
}
}
ys += batteryHeaderHigh;
/**
* @brief 沿
*/
for (int yoff = 0; yoff < border_width; yoff++) {
for (int xoff = 0; xoff < batteryBodyWidth; xoff++) {
ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 1);
}
}
ys += border_width;
/**
* @brief
*/
for (int yoff = 0; yoff < blank_width; yoff++) {
for (int xoff = 0; xoff < batteryBodyWidth; xoff++) {
// uint16_t start = blank_width;
if (xoff < border_width) {
ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 1);
} else if (xoff >= (batteryInterBodyWidth + border_width * 1 + blank_width * 2)) {
ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 1);
} else {
ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 0);
}
}
}
ys += blank_width;
/**
* @brief
*/
for (int yoff = 0; yoff < batteryInterBodyHigh; yoff++) {
for (int xoff = 0; xoff < batteryBodyWidth; xoff++) {
// uint16_t start = blank_width;
if (xoff < border_width) {
// right border
ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 1);
} else if (xoff >= border_width + blank_width && xoff < batteryInterBodyWidth + border_width + blank_width) {
// body
// ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 1);
uint16_t batterylevel = (100 - level) / 100.0 * batteryInterBodyHigh;
if (yoff >= batterylevel) {
ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 1);
}
} else if (xoff >= batteryInterBodyWidth + border_width * 1 + blank_width * 2) {
// left border
ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 1);
} else {
ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 0);
}
}
}
ys += batteryInterBodyHigh;
/**
* @brief
*/
for (int yoff = 0; yoff < blank_width; yoff++) {
for (int xoff = 0; xoff < batteryBodyWidth; xoff++) {
// uint16_t start = blank_width;
if (xoff < border_width) {
ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 1);
} else if (xoff >= (batteryInterBodyWidth + border_width * 1 + blank_width * 2)) {
ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 1);
} else {
ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 0);
}
}
}
ys += blank_width;
/**
* @brief 沿
*/
for (int yoff = 0; yoff < border_width; yoff++) {
for (int xoff = 0; xoff < batteryBodyWidth; xoff++) {
ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 1);
}
}
ys += border_width;
*xchange = batteryBodyWidth;
*ychange = batteryBodyHigh + batteryHeaderHigh;
}

4
app/src/basic/ssd1306/driver_ssd1306_basic.h

@ -204,7 +204,9 @@ uint8_t ssd1306_basic_gram_update();
ssd1306_handle_t* ssd1306_handler(); ssd1306_handle_t* ssd1306_handler();
uint8_t ssd1306_basic_line(uint8_t x, uint8_t y, uint8_t data); uint8_t ssd1306_basic_line(uint8_t x, uint8_t y, uint8_t data);
uint8_t ssd1306_basic_draw_str(uint8_t xs, uint8_t ys, const char *str, FontLibrary_t *frontlib);
uint8_t ssd1306_basic_draw_str(uint8_t xs, uint8_t ys, uint8_t *xchange, uint8_t *ychange, const char *str, FontLibrary_t *frontlib);
uint8_t ssd1306_basic_draw_battery_level(uint8_t xs, uint8_t ys, uint8_t *xchange, uint8_t *ychange,int level, int width, int high);
/** /**
* @} * @}

58
app/src/one_conduction/display_manager.c

@ -2,15 +2,17 @@
#include "../../../res/logo_mono.c" #include "../../../res/logo_mono.c"
// //
#include <stdarg.h>
#include "basic/ssd1306/driver_ssd1306.h" #include "basic/ssd1306/driver_ssd1306.h"
#include "basic/ssd1306/driver_ssd1306_basic.h" #include "basic/ssd1306/driver_ssd1306_basic.h"
#include "font.h" #include "font.h"
#include "one_conduction_board.h" #include "one_conduction_board.h"
#include <stdarg.h>
PageState_t g_pageState; PageState_t g_pageState;
void dsp_mgr_init(void) { void dsp_mgr_init(void) {
FontLibrary_regsiter(&fontclocklib); FontLibrary_regsiter(&fontclocklib);
FontLibrary_regsiter(&font8x8_xo_lib);
// fronlib16.asciifront = assci16code; // fronlib16.asciifront = assci16code;
// fronlib16.asciifrontIndex = "0123456789Ero."; // fronlib16.asciifrontIndex = "0123456789Ero.";
@ -47,6 +49,8 @@ void dsp_mgr_change_to_poweroff() {
SingleLeadECG_screen_deinit(); SingleLeadECG_screen_deinit();
} }
void dsp_mgr_poweron() { SingleLeadECG_screen_init(); }
void dsp_mgr_change_to_welcome() { void dsp_mgr_change_to_welcome() {
/** /**
* @brief * @brief
@ -54,14 +58,11 @@ void dsp_mgr_change_to_welcome() {
* 2. * 2.
* 3. * 3.
*/ */
SingleLeadECG_screen_init();
// ssd1306_basic_string(0, 0, "123456789123456789123", 21, 0, SSD1306_FONT_12); // ssd1306_basic_string(0, 0, "123456789123456789123", 21, 0, SSD1306_FONT_12);
ssd1306_basic_draw_screen(gImage_logo_mono); ssd1306_basic_draw_screen(gImage_logo_mono);
ssd1306_basic_gram_update(); ssd1306_basic_gram_update();
dsp_mgr_change_to_page(kPage_welcome); dsp_mgr_change_to_page(kPage_welcome);
dsp_mgr_change_to_main();
} }
const char* fmt(const char* format, ...) { const char* fmt(const char* format, ...) {
@ -75,20 +76,57 @@ const char* fmt(const char* format, ...) {
} }
void dsp_mgr_change_to_main() { void dsp_mgr_change_to_main() {
/**
* @brief
*/
int16_t batterylevel = 80;
int16_t hour = 12;
int16_t min = 32;
ssd1306_basic_clear(); ssd1306_basic_clear();
//
ssd1306_basic_draw_str(40, 32 - fontclocklib.heightPixel / 2, fmt("%02d:%02d", 6, 32), &fontclocklib);
//
uint8_t x = 20;
uint8_t y = 32 - fontclocklib.heightPixel / 2; // 12*4 +12
uint8_t xchange, ychange;
ssd1306_basic_draw_str(x, y, &xchange, &ychange, fmt("%02d:%02d", hour, min), &fontclocklib);
x = x + 2 + xchange;
ssd1306_basic_draw_battery_level(x, y, &xchange, &ychange, batterylevel, 12, 22);
ssd1306_basic_gram_update(); ssd1306_basic_gram_update();
dsp_mgr_change_to_page(kPage_main);
}
void dsp_mgr_change_to_chargingPage() {
int16_t batterylevel = 80;
int16_t hour = 12;
int16_t min = 32;
ssd1306_basic_clear();
uint8_t x = 20;
uint8_t y = 32 - fontclocklib.heightPixel / 2; // 12*4 +12
uint8_t xchange, ychange;
ssd1306_basic_draw_str(x, y, &xchange, &ychange, fmt("%02d:%02d", hour, min), &fontclocklib);
x = x + 2 + xchange;
ssd1306_basic_draw_battery_level(x, y, &xchange, &ychange, batterylevel, 12, 22);
ssd1306_basic_gram_update();
dsp_mgr_change_to_page(kPage_main);
} }
void dsp_mgr_change_to_preparePage() { void dsp_mgr_change_to_preparePage() {
/** /**
* @brief * @brief
*
* 1.
* 2.
*/ */
ssd1306_basic_clear();
uint8_t x = 0;
uint8_t y = 0;
uint8_t xchange, ychange;
// ssd1306_basic_draw_str(&x, &y, "123", &fontclocklib);
ssd1306_basic_draw_str(x, y, &xchange, &ychange, "ooox", &font8x8_xo_lib);
y = y + font8x8_xo_lib.heightPixel;
x = x + font8x8_xo_lib.widthPixel;
ssd1306_basic_draw_str(x, y, &xchange, &ychange, "保持静止", &font24x24_baochijingzhi_lib);
ssd1306_basic_gram_update();
dsp_mgr_change_to_page(kPage_preparePage);
} }
void dsp_mgr_change_to_sampling() {} void dsp_mgr_change_to_sampling() {}
void dsp_mgr_change_to_samplingError() {} void dsp_mgr_change_to_samplingError() {}

5
app/src/one_conduction/display_manager.h

@ -35,6 +35,7 @@ typedef enum {
kPage_samplingError, kPage_samplingError,
kPage_storaging, kPage_storaging,
kPage_storagingSuc, kPage_storagingSuc,
kPage_chargingPage,
} page_t; } page_t;
typedef struct { typedef struct {
@ -60,9 +61,13 @@ void dsp_mgr_schedule(void);
PageState_t* dsp_mgr_get_state(void); PageState_t* dsp_mgr_get_state(void);
uint32_t dsp_mgr_get_page_elapsed_time_s(void); uint32_t dsp_mgr_get_page_elapsed_time_s(void);
void dsp_mgr_poweron();
void dsp_mgr_poweroff();
void dsp_mgr_change_to_poweroff(); void dsp_mgr_change_to_poweroff();
void dsp_mgr_change_to_welcome(); void dsp_mgr_change_to_welcome();
void dsp_mgr_change_to_main(); void dsp_mgr_change_to_main();
void dsp_mgr_change_to_chargingPage();
void dsp_mgr_change_to_preparePage(); void dsp_mgr_change_to_preparePage();
void dsp_mgr_change_to_sampling(); void dsp_mgr_change_to_sampling();
void dsp_mgr_change_to_samplingError(); void dsp_mgr_change_to_samplingError();

38
app/src/one_conduction/font.h

@ -123,3 +123,41 @@ static FontLibrary_t fontclocklib = {
.widthPixel = 12, .widthPixel = 12,
.heightPixel = 24, .heightPixel = 24,
}; };
const char font8x8_xo_code[] = {
0x00, 0x3C, 0x7E, 0x7E, 0x7E, 0x7E, 0x3C, 0x00, /*实心圆,代表完成*/
0x00, 0x3C, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, /*空心圆,代表未完成*/
};
static FontLibrary_t font8x8_xo_lib = {
.font = font8x8_xo_code,
.fontIndex = "ox",
.fontIndexLen = 2,
.fontCode = kutf8,
.isAscii = true,
.widthPixel = 8,
.heightPixel = 8,
};
const char font24x24_baochijingzhi_code[] = {
// (0) (1) (2) (3)
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0x38, 0x10, 0x10, 0xF0, 0x90, 0x10, 0x10, 0x10, 0x88, 0xF8, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x0C, 0x06, 0xE7, 0x1C, 0x10, 0x10, 0x10, 0x10, 0x93,
0x71, 0xFF, 0x39, 0x49, 0x89, 0x08, 0x08, 0x0C, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x04, 0x02, 0x01, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x03, 0x07, 0x06, 0x06, 0x04, 0x04, 0x00, /*"保",0*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFC, 0xFC, 0xC0, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xC2, 0x63, 0x33, 0xFF, 0x0D, 0x09, 0x08, 0x48,
0x48, 0x49, 0x48, 0x47, 0x4F, 0xFC, 0x24, 0x24, 0x26, 0x06, 0x04, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x08, 0x38, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x20, 0x60, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*"持",1*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0xFC, 0x20, 0xA0, 0x20, 0x00, 0x80, 0x60, 0x3C, 0x2C, 0xA0, 0x70, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x0C, 0x94, 0x75, 0x55, 0x57, 0x15, 0xF4, 0x02, 0x90,
0x92, 0x92, 0x92, 0xFF, 0x92, 0x8A, 0x49, 0x3F, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0F, 0x02, 0x01, 0x09, 0x18, 0x0F, 0x00, 0x00, 0x00, 0x20, 0x60, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*"静",2*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xF8, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xF8, 0x00, 0x00, 0x00,
0xFF, 0x0F, 0x08, 0x08, 0x08, 0x0C, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x18, 0x08, 0x08, 0x08, 0x0F, 0x08, 0x08, 0x0C, 0x0F, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, /*"止",3*/
};
static FontLibrary_t font24x24_baochijingzhi_lib = {
.font = font24x24_baochijingzhi_code,
.fontIndex = "保持静止",
.fontIndexLen = 12,
.fontCode = kutf8,
.isAscii = false,
.widthPixel = 24,
.heightPixel = 24,
};

4
app/src/one_conduction/one_conduction_main.c

@ -55,7 +55,9 @@ void one_conduction_main() {
zble_module_start_adv(); zble_module_start_adv();
dsp_mgr_init(); dsp_mgr_init();
dsp_mgr_change_to_welcome();
dsp_mgr_poweron();
dsp_mgr_change_to_preparePage();
znordic_loop(); znordic_loop();
} }

BIN
res/Snipaste_2024-01-26_20-00-58.png

After

Width: 482  |  Height: 281  |  Size: 17 KiB

Loading…
Cancel
Save