mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-16 04:29:08 +00:00
WIP - self-code-review ... C
This commit is contained in:
parent
8a6fcda60c
commit
8eaa86b2e1
@ -181,7 +181,7 @@ message ApplySettings {
|
||||
}
|
||||
|
||||
/**
|
||||
* Request: change the device language via translation data
|
||||
* Request: change the device language via translation data.
|
||||
* Does not send the translation data itself, as they are too large for one message.
|
||||
* Device will request the translation data in chunks.
|
||||
* @start
|
||||
@ -189,7 +189,7 @@ message ApplySettings {
|
||||
* @next Failure
|
||||
*/
|
||||
message ChangeLanguage {
|
||||
required uint32 data_length = 1; // byte length of the whole translation blob (set to 0 for default language)
|
||||
required uint32 data_length = 1; // byte length of the whole translation blob (set to 0 for default language - english)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -198,7 +198,7 @@ message ChangeLanguage {
|
||||
* @next TranslationDataAck
|
||||
*/
|
||||
message TranslationDataRequest {
|
||||
required uint32 data_length = 1; // Number of bytes being requested (<= 1024)
|
||||
required uint32 data_length = 1; // Number of bytes being requested
|
||||
required uint32 data_offset = 2; // Offset of the first byte being requested
|
||||
}
|
||||
|
||||
@ -208,7 +208,7 @@ message ChangeLanguage {
|
||||
* @next Success
|
||||
*/
|
||||
message TranslationDataAck {
|
||||
required bytes data_chunk = 1; // Bytes from translation payload (<= 1024 bytes)
|
||||
required bytes data_chunk = 1; // Bytes from translation payload
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "py/mphal.h"
|
||||
@ -340,7 +339,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_trezorconfig_translations_set_obj,
|
||||
|
||||
/// def translations_wipe() -> None:
|
||||
/// """
|
||||
/// Wipe all the translations data before writing a new one
|
||||
/// Wipe all the translations data before writing a new one.
|
||||
/// """
|
||||
STATIC mp_obj_t mod_trezorconfig_translations_wipe(void) {
|
||||
translations_erase();
|
||||
@ -351,7 +350,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_trezorconfig_translations_wipe_obj,
|
||||
|
||||
/// def translations_max_bytesize() -> int:
|
||||
/// """
|
||||
/// How much is the maximum bytesize of translations data
|
||||
/// How much is the maximum bytesize of translations data.
|
||||
/// """
|
||||
STATIC mp_obj_t mod_trezorconfig_translations_max_bytesize(void) {
|
||||
uint32_t count = translations_area_bytesize();
|
||||
|
@ -104,7 +104,7 @@
|
||||
/* { */ static const uint8_t Font_Unifont_Regular_16_glyph_123[] = { 4, 13, 7, 1, 11, 52, 66, 36, 132, 34, 68, 48 };
|
||||
/* | */ static const uint8_t Font_Unifont_Regular_16_glyph_124[] = { 1, 14, 7, 3, 12, 255, 252 };
|
||||
/* } */ static const uint8_t Font_Unifont_Regular_16_glyph_125[] = { 4, 13, 7, 1, 11, 194, 36, 66, 18, 68, 34, 192 };
|
||||
/* ~ */ static const uint8_t Font_Unifont_Regular_16_glyph_126[] = { 7, 3, 7, 0, 11, 99, 38, 48 };
|
||||
/* ~ */ static const uint8_t Font_Unifont_Regular_16_glyph_126[] = { 7, 3, 8, 0, 11, 99, 38, 48 }; // < --- advanced changed from 7 to 8
|
||||
|
||||
/* ? */ const uint8_t Font_Unifont_Regular_16_glyph_nonprintable[] = { 6, 10, 7, 0, 10, 133, 231, 190, 247, 190, 255, 239, 191 };
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include "fonts.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#ifdef TRANSLATIONS
|
||||
#include "librust_fonts.h"
|
||||
#endif
|
||||
@ -139,8 +139,8 @@ int font_baseline(int font) {
|
||||
|
||||
const uint8_t *font_get_glyph(int font, uint8_t c) {
|
||||
uint16_t c_2bytes = convert_char_utf8(c);
|
||||
bool is_printable = c_2bytes != 0x7F;
|
||||
if (!c_2bytes) return 0;
|
||||
bool is_printable = c_2bytes != 0x7F;
|
||||
|
||||
#ifdef TRANSLATIONS
|
||||
// found UTF8 character
|
||||
@ -148,6 +148,8 @@ const uint8_t *font_get_glyph(int font, uint8_t c) {
|
||||
// embedded blob
|
||||
if (c_2bytes > 0xFF) {
|
||||
PointerData glyph_data = get_utf8_glyph(c_2bytes, font);
|
||||
// TODO: is it better to use (!glyph_data.ptr) or (glyph_data.ptr == NULL)?
|
||||
// first one does not require import
|
||||
if (glyph_data.ptr != NULL) {
|
||||
return glyph_data.ptr;
|
||||
} else {
|
||||
|
@ -33,7 +33,6 @@ const flash_area_t TRANSLATIONS_AREA = {
|
||||
.num_subareas = 1,
|
||||
.subarea[0] =
|
||||
{
|
||||
// TODO: can we use the 4th sector?
|
||||
.first_sector = 12,
|
||||
.num_sectors = 3,
|
||||
},
|
||||
|
@ -3,4 +3,5 @@ typedef struct {
|
||||
uint32_t len;
|
||||
} PointerData;
|
||||
|
||||
// TODO: Theoretically, the `len` is not used by the client and does not have to be sent
|
||||
PointerData get_utf8_glyph(uint16_t char_code, int font);
|
||||
|
@ -1,6 +1,4 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include "secbool.h"
|
||||
|
||||
void translations_write(uint8_t* data, uint32_t offset, uint32_t len);
|
||||
|
||||
|
@ -118,14 +118,14 @@ def translations_set(blob: bytes, offset: int) -> None:
|
||||
# extmod/modtrezorconfig/modtrezorconfig.c
|
||||
def translations_wipe() -> None:
|
||||
"""
|
||||
Wipe all the translations data before writing a new one
|
||||
Wipe all the translations data before writing a new one.
|
||||
"""
|
||||
|
||||
|
||||
# extmod/modtrezorconfig/modtrezorconfig.c
|
||||
def translations_max_bytesize() -> int:
|
||||
"""
|
||||
How much is the maximum bytesize of translations data
|
||||
How much is the maximum bytesize of translations data.
|
||||
"""
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user