Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): new funcs and next gen ui #20

Merged
merged 3 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 10 additions & 10 deletions common/protob/messages-conflux.proto
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ message ConfluxAddress {
*/
message ConfluxSignTx {
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
optional bytes nonce = 2; // <=256 bit unsigned big endian
optional bytes gas_price = 3; // <=256 bit unsigned big endian (in wei)
optional bytes gas_limit = 4; // <=256 bit unsigned big endian
optional string to = 5; // recipient address
optional bytes value = 6;
optional bytes epoch_height = 7;
optional bytes storage_limit = 8; // <=256 bit unsigned big endian (in wei)
optional bytes data_initial_chunk = 9; // The initial data chunk (<= 1024 bytes)
optional uint32 data_length = 10; // Length of transaction payload
optional uint32 chain_id = 11; // Chain Id for EIP 155
required bytes nonce = 2; // <=256 bit unsigned big endian
required bytes gas_price = 3; // <=256 bit unsigned big endian (in wei)
required bytes gas_limit = 4; // <=256 bit unsigned big endian
optional string to = 5 [default='']; // recipient address
optional bytes value = 6 [default=''];
optional bytes epoch_height = 7 [default=''];
optional bytes storage_limit = 8 [default='']; // <=256 bit unsigned big endian (in wei)
optional bytes data_initial_chunk = 9 [default='']; // The initial data chunk (<= 1024 bytes)
optional uint32 data_length = 10 [default=0]; // Length of transaction payload
optional uint32 chain_id = 11 [default=1029]; // Chain Id for EIP 155
}

/**
Expand Down
4 changes: 1 addition & 3 deletions core/.gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
lv_font_scs_bold_30.bin filter=lfs diff=lfs merge=lfs -text
lv_font_scs_bold_72.bin filter=lfs diff=lfs merge=lfs -text
lv_font_scs_reg_30.bin filter=lfs diff=lfs merge=lfs -text
Geist* filter=lfs diff=lfs merge=lfs -text
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,7 @@ STATIC mp_obj_t mod_trezorcrypto_se_thd89_read_certificate(void) {
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_trezorcrypto_se_thd89_read_certificate_obj,
mod_trezorcrypto_se_thd89_read_certificate);

/// def sign_message(
/// ) -> bytes:
/// def sign_message(msg: bytes) -> bytes:
/// """
/// Sign message.
/// """
Expand Down
27 changes: 11 additions & 16 deletions core/embed/lvgl/lv_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,23 +377,18 @@
*You can use these fonts as default font too and they will be available globally.
*E.g. #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) LV_FONT_DECLARE(my_font_2)*/
#define LV_FONT_CUSTOM_DECLARE \
LV_FONT_DECLARE(lv_font_pljs_bold_24) \
LV_FONT_DECLARE(lv_font_pljs_bold_36) \
LV_FONT_DECLARE(lv_font_pljs_regular_24) \
LV_FONT_DECLARE(lv_font_scs_bold_26) \
LV_FONT_DECLARE(lv_font_scs_bold_30) \
LV_FONT_DECLARE(lv_font_scs_bold_38) \
LV_FONT_DECLARE(lv_font_scs_reg_26) \
LV_FONT_DECLARE(lv_font_scs_reg_30) \
LV_FONT_DECLARE(lv_font_scs_bold_72) \
LV_FONT_DECLARE(lv_font_mix_bold_24) \
LV_FONT_DECLARE(lv_font_mix_title_bold_36) \
LV_FONT_DECLARE(lv_font_mono_reg_28) \
LV_FONT_DECLARE(lv_font_status_bar) \
LV_FONT_DECLARE(lv_font_pljs_bold_48)
LV_FONT_DECLARE(lv_font_geist_semibold_64) \
LV_FONT_DECLARE(lv_font_geist_semibold_48) \
LV_FONT_DECLARE(lv_font_geist_semibold_38) \
LV_FONT_DECLARE(lv_font_geist_semibold_30) \
LV_FONT_DECLARE(lv_font_geist_semibold_26) \
LV_FONT_DECLARE(lv_font_geist_regular_30) \
LV_FONT_DECLARE(lv_font_geist_regular_26) \
LV_FONT_DECLARE(lv_font_geist_regular_20) \
LV_FONT_DECLARE(lv_font_geist_mono_28)

/*Always set a default font*/
#define LV_FONT_DEFAULT &lv_font_scs_reg_26
#define LV_FONT_DEFAULT &lv_font_geist_regular_26

/*Enable handling large font and/or fonts with a lot of characters.
*The limit depends on the font size, font face and bpp.
Expand Down Expand Up @@ -423,7 +418,7 @@
#define LV_TXT_ENC LV_TXT_ENC_UTF8

/*Can break (wrap) texts on these chars*/
#define LV_TXT_BREAK_CHARS " ,.;-_"
#define LV_TXT_BREAK_CHARS " ,;"

/*If a word is at least this long, will break wherever "prettiest"
*To disable, set to a value <= 0*/
Expand Down
136 changes: 136 additions & 0 deletions core/embed/lvgl/lv_font_geist_mono_28.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
#include "ff.h"
#include "lv_font_ex.h"
#include "lvgl.h"

static x_header_t __g_xbf_hd = {
.min = 0x0020,
.max = 0xffff,
.bpp = 4,
};

static SRAM1 DWORD clmt[SZ_TBL];
static FIL font_f;
static FRESULT res;
static UINT nums = 0;
static bool is_opend = false;
static uint32_t glyph_location = 0;

static font_data_cache font_cache = {0};

static int __user_font_getdata(uint8_t *data_buf, int offset, int size) {
if (!is_opend) {
uint8_t buf[4] = {0};
uint32_t len = 0;
res = f_open(&font_f, "/res/GeistMono-Regular-28.bin", FA_READ);
if (FR_OK == res) {
font_f.cltbl = clmt; /* Enable fast seek mode (cltbl != NULL) */
clmt[0] = SZ_TBL; /* Set table size */
f_lseek(&font_f, CREATE_LINKMAP); /* Create CLMT */

res = f_lseek(&font_f, LOCA_OFFSET);
if (FR_OK != res) {
return -1;
}
if (f_read(&font_f, &len, 4, &nums) != FR_OK ||
f_read(&font_f, buf, 4, &nums) != FR_OK ||
memcmp("loca", buf, 4) != 0) {
return -1;
}
glyph_location = len + LOCA_OFFSET;

is_opend = true;
} else {
return -1;
}
}
res = f_lseek(&font_f, offset);
if (FR_OK != res) {
return -1;
}
res = f_read(&font_f, data_buf, size, &nums);
if (FR_OK != res) {
return -1;
}
return 0;
}

static const uint8_t *__user_font_get_bitmap(const lv_font_t *font,
uint32_t unicode_letter) {
if (unicode_letter > __g_xbf_hd.max || unicode_letter < __g_xbf_hd.min) {
return NULL;
}
uint8_t *font_data = NULL;
uint32_t data_len = 0;
font_data = font_cache_get_letter(&font_cache, unicode_letter, &data_len);
if (font_data) {
return font_data + sizeof(glyph_dsc_t);
} else {
uint32_t unicode_offset = (unicode_letter - __g_xbf_hd.min + 1) * 4;
uint32_t len = 0;
uint8_t buf[8] = {0};
__user_font_getdata(buf, unicode_offset + LOCA_OFFSET + LOCA_VALUE_OFFSET,
8);
uint32_t *p_pos = (uint32_t *)buf;
if (p_pos[0] != 0) {
len = p_pos[1] - p_pos[0];
font_data = font_malloc(len);
if (__user_font_getdata(font_data, glyph_location + p_pos[0], len) != 0) {
return NULL;
}
font_cache_add_letter(&font_cache, unicode_letter, font_data, len);
return font_data + sizeof(glyph_dsc_t);
} else {
return NULL;
}
}

return NULL;
}

static bool __user_font_get_glyph_dsc(const lv_font_t *font,
lv_font_glyph_dsc_t *dsc_out,
uint32_t unicode_letter,
uint32_t unicode_letter_next) {
if (unicode_letter > __g_xbf_hd.max || unicode_letter < __g_xbf_hd.min) {
return NULL;
}

uint8_t *font_data = NULL;
uint32_t data_len = 0;
font_data = font_cache_get_letter(&font_cache, unicode_letter, &data_len);
if (font_data) {
} else {
uint32_t unicode_offset = (unicode_letter - __g_xbf_hd.min + 1) * 4;
uint32_t len = 0;
uint8_t buf[8] = {0};
__user_font_getdata(buf, unicode_offset + LOCA_OFFSET + LOCA_VALUE_OFFSET,
8);
uint32_t *p_pos = (uint32_t *)buf;
if (p_pos[0] != 0) {
len = p_pos[1] - p_pos[0];
font_data = font_malloc(len);
if (__user_font_getdata(font_data, glyph_location + p_pos[0], len) != 0) {
return false;
}
font_cache_add_letter(&font_cache, unicode_letter, font_data, len);
} else {
return false;
}
}
glyph_dsc_t *gdsc = (glyph_dsc_t *)font_data;
dsc_out->adv_w = (gdsc->adv_w + (1 << 3)) >> 4;
dsc_out->box_h = gdsc->box_h;
dsc_out->box_w = gdsc->box_w;
dsc_out->ofs_x = gdsc->ofs_x;
dsc_out->ofs_y = gdsc->ofs_y;
dsc_out->bpp = __g_xbf_hd.bpp;
return true;
}

// Noto Sans TC + GeistMono ,Regular, 28
const lv_font_t lv_font_geist_mono_28 = {
.get_glyph_bitmap = __user_font_get_bitmap,
.get_glyph_dsc = __user_font_get_glyph_dsc,
.line_height = 28,
.base_line = 3,
};
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static int __user_font_getdata(uint8_t *data_buf, int offset, int size) {
if (!is_opend) {
uint8_t buf[4] = {0};
uint32_t len = 0;
res = f_open(&font_f, "/res/lv_font_scs_bold_72.bin", FA_READ);
res = f_open(&font_f, "/res/Geist-Regular-20.bin", FA_READ);
if (FR_OK == res) {
font_f.cltbl = clmt; /* Enable fast seek mode (cltbl != NULL) */
clmt[0] = SZ_TBL; /* Set table size */
Expand Down Expand Up @@ -127,10 +127,10 @@ static bool __user_font_get_glyph_dsc(const lv_font_t *font,
return true;
}

// Source Han Sans,Bold,72
const lv_font_t lv_font_scs_bold_72 = {
// Noto Sans TC + Geist ,Regular, 20
const lv_font_t lv_font_geist_regular_20 = {
.get_glyph_bitmap = __user_font_get_bitmap,
.get_glyph_dsc = __user_font_get_glyph_dsc,
.line_height = 72,
.line_height = 20,
.base_line = 3,
};
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static int __user_font_getdata(uint8_t *data_buf, int offset, int size) {
if (!is_opend) {
uint8_t buf[4] = {0};
uint32_t len = 0;
res = f_open(&font_f, "/res/lv_font_scs_bold_26.bin", FA_READ);
res = f_open(&font_f, "/res/Geist-Regular-26.bin", FA_READ);
if (FR_OK == res) {
font_f.cltbl = clmt; /* Enable fast seek mode (cltbl != NULL) */
clmt[0] = SZ_TBL; /* Set table size */
Expand Down Expand Up @@ -127,8 +127,8 @@ static bool __user_font_get_glyph_dsc(const lv_font_t *font,
return true;
}

// Source Han Sans,Bold,24
const lv_font_t lv_font_scs_bold_26 = {
// Noto Sans TC + Geist ,Regular, 26
const lv_font_t lv_font_geist_regular_26 = {
.get_glyph_bitmap = __user_font_get_bitmap,
.get_glyph_dsc = __user_font_get_glyph_dsc,
.line_height = 26,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static int __user_font_getdata(uint8_t *data_buf, int offset, int size) {
if (!is_opend) {
uint8_t buf[4] = {0};
uint32_t len = 0;
res = f_open(&font_f, "/res/lv_font_scs_reg_30.bin", FA_READ);
res = f_open(&font_f, "/res/Geist-Regular-30.bin", FA_READ);
if (FR_OK == res) {
font_f.cltbl = clmt; /* Enable fast seek mode (cltbl != NULL) */
clmt[0] = SZ_TBL; /* Set table size */
Expand Down Expand Up @@ -127,8 +127,8 @@ static bool __user_font_get_glyph_dsc(const lv_font_t *font,
return true;
}

// Source Han Sans,Regular,30
const lv_font_t lv_font_scs_reg_30 = {
// Noto Sans TC + Geist ,Regular, 30
const lv_font_t lv_font_geist_regular_30 = {
.get_glyph_bitmap = __user_font_get_bitmap,
.get_glyph_dsc = __user_font_get_glyph_dsc,
.line_height = 30,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static int __user_font_getdata(uint8_t *data_buf, int offset, int size) {
if (!is_opend) {
uint8_t buf[4] = {0};
uint32_t len = 0;
res = f_open(&font_f, "/res/lv_font_scs_reg_26.bin", FA_READ);
res = f_open(&font_f, "/res/Geist-SemiBold-26.bin", FA_READ);
if (FR_OK == res) {
font_f.cltbl = clmt; /* Enable fast seek mode (cltbl != NULL) */
clmt[0] = SZ_TBL; /* Set table size */
Expand Down Expand Up @@ -127,8 +127,8 @@ static bool __user_font_get_glyph_dsc(const lv_font_t *font,
return true;
}

// Source Han Sans,Regular,24
const lv_font_t lv_font_scs_reg_26 = {
// Noto Sans TC + Geist ,SemiBold, 26
const lv_font_t lv_font_geist_semibold_26 = {
.get_glyph_bitmap = __user_font_get_bitmap,
.get_glyph_dsc = __user_font_get_glyph_dsc,
.line_height = 26,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static int __user_font_getdata(uint8_t *data_buf, int offset, int size) {
if (!is_opend) {
uint8_t buf[4] = {0};
uint32_t len = 0;
res = f_open(&font_f, "/res/lv_font_scs_bold_30.bin", FA_READ);
res = f_open(&font_f, "/res/Geist-SemiBold-30.bin", FA_READ);
if (FR_OK == res) {
font_f.cltbl = clmt; /* Enable fast seek mode (cltbl != NULL) */
clmt[0] = SZ_TBL; /* Set table size */
Expand Down Expand Up @@ -127,8 +127,8 @@ static bool __user_font_get_glyph_dsc(const lv_font_t *font,
return true;
}

// Source Han Sans,Bold,30
const lv_font_t lv_font_scs_bold_30 = {
// Noto Sans TC + Geist ,SemiBold, 30
const lv_font_t lv_font_geist_semibold_30 = {
.get_glyph_bitmap = __user_font_get_bitmap,
.get_glyph_dsc = __user_font_get_glyph_dsc,
.line_height = 30,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static int __user_font_getdata(uint8_t *data_buf, int offset, int size) {
if (!is_opend) {
uint8_t buf[4] = {0};
uint32_t len = 0;
res = f_open(&font_f, "/res/lv_font_scs_bold_38.bin", FA_READ);
res = f_open(&font_f, "/res/Geist-SemiBold-38.bin", FA_READ);
if (FR_OK == res) {
font_f.cltbl = clmt; /* Enable fast seek mode (cltbl != NULL) */
clmt[0] = SZ_TBL; /* Set table size */
Expand Down Expand Up @@ -127,8 +127,8 @@ static bool __user_font_get_glyph_dsc(const lv_font_t *font,
return true;
}

// Source Han Sans,Bold,36
const lv_font_t lv_font_scs_bold_38 = {
// Noto Sans TC + Geist ,SemiBold, 38
const lv_font_t lv_font_geist_semibold_38 = {
.get_glyph_bitmap = __user_font_get_bitmap,
.get_glyph_dsc = __user_font_get_glyph_dsc,
.line_height = 38,
Expand Down
Loading
Loading