Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into neo_v2
Browse files Browse the repository at this point in the history
  • Loading branch information
solosky committed Jun 20, 2024
2 parents b338d19 + b6b9283 commit d02e5e2
Show file tree
Hide file tree
Showing 53 changed files with 3,292 additions and 2,731 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"name": "Pixl.js Openocd Debug",
"cwd": "${workspaceRoot}",
"executable": "fw/_build/pixljs.out",
"armToolchainPath": "D:/dev/SDKs/gcc-arm-none-eabi-10-2020-q4-major/bin",
"armToolchainPath": "",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
Expand Down
96 changes: 81 additions & 15 deletions docs/en/05+5-translation.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,92 @@
# Transalation
# Translation

## How to update exists translation
## Firmware

1. Edit fw/data/i18n.csv with your favorite text editor. For vscode, extension "Edit csv" is recommended.
2. Run `fw/scripts/i18n_gen.py` to generate new language files.
3. Optional: Run `fw/scripts/font_data_gen.sh` to generate new font data if you add new charaters in i18n.csv
4. Run `make full` rebuild firmware
## How to update existing translation

When editing CSV files with VSCode, the extension [Edit CSV](https://marketplace.visualstudio.com/items?itemName=janisdd.vscode-edit-csv) is recommended.

**Windows** requires you to have [Python](https://www.python.org/downloads/) and [Git](https://git-scm.com/download/windows) installed and within your `$PATH`
For **Linux**, most distributions come with `python` and `git` by default and **macOS** comes bundled with `python`, but to use `git` you either need to install the Command Line tools via `xcode-select –-install`, or download [Git](https://git-scm.com/download/mac) separately.

### Windows

note: <br />
The script `font_data_gen.sh` only can be run in Git Bash windows in Windows.
1. Clone this repository
`git clone https://github.com/solosky/pixl.js.git; cd pixl.js`
2. Edit `fw/data/i18n.csv`
3. Run `py.exe fw/scripts/i18n_gen.py` to generate new language files.
4. _Optional:_ Run `py.exe fw/scripts/font_data_gen.py` to generate new font data if you add new characters in `i18n.csv`
5. [Build the Firmware](03-Build-Firmware.md)

### Linux and macOS

1. Clone this repository
`git clone https://github.com/solosky/pixl.js.git; cd pixl.js`
2. Edit `fw/data/i18n.csv`
3. Run `python3 fw/scripts/i18n_gen.py` to generate new language files.
4. Optional: Run `python fw/scripts/font_data_gen.py` to generate new font data if you add new characters in `i18n.csv`
5. [Build the Firmware](03-Build-Firmware.md)

## How to add new language translation

1. Add new column in fw/data/i18n.csv, for example "ja_JP"
The process is similar to updating an existing translation, and has the same requirements depending on your Operating System.

1. Add new column in `fw/data/i18n.csv`, for example "ja_JP"
2. Run `fw/scripts/i18n_gen.py` to generate new language files.
3. Optional: Run `fw/scripts/font_data_gen.sh` to generate new font data if you add new charaters in i18n.csv
3. Optional: Run `fw/scripts/font_data_gen.py` to generate new font data if you add new characters in `i18n.csv`
4. Edit `fw/application/src/i18n/language.h` and `fw/application/src/i18n/language.c` to adopt new language
5. Edit Makefile to include `$(PROJ_DIR)/i18n/ja_JP.c` as C source files
6. Run `make full` rebuild firmware
6. [Build the Firmware](03-Build-Firmware.md)

## Font notes

For release builds (RELEASE=1), the firmware uses wenquanyi_9pt_u8g2.bdf to display unicode characters.
Please check if the new language character codepoint is included in wenquanyi_9pt_u8g2.bdf or not.
If not, it's not recommended supporting the new language due to the MCU internal flash restrictions.

## Web App

### How to update existing translation

The language file can be found under `web/src/i18n'

## How to add new language translation

In this example, we will add a Japanese (ja_JP) translation:

1. Copy the `en_US.js` file and name it `ja_JP.js`
2. Translate the string within `ja_JP.js` including the `changeok` message.

Don't translate the other language names.

Add your language at the bottom of the `lang {` section:

`ja: '日本語',`

3. Edit `web/src/i18n/index.js` while keeping its current structure, adding:

```js
import elementJaLocale from 'element-ui/lib/locale/lang/ja' // element-ui
lang import jaLocale from './ja_JP' elementJpLocale
```

And extending `messages`:

```js
ja_JP: {
...jaLocale,
...elementJaLocale,
},
```

4. Add your language to the other `.js` files (within the `lang: {` section):

`vueja: '日本語',`

## Font notes
5. Add your language to the `web/src/App.vue` file:

For release build (RELEASE=1), the firmware use wenquanyi_9pt_u8g2.bdf to display unicode characters. <br />
Please check new language charater codepoint is included in wenquanyi_9pt_u8g2.bdf or not.<br />
If not, I am not recommended to support the new language due to the MCU internal flash restrction.
```js
<el-dropdown-item Enabled="language==='ja'" command="ja" divided>
{{ $t('lang.ja') }}
</el-dropdown-item>
```
5 changes: 3 additions & 2 deletions fw/application/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ SRC_FILES += \
$(PROJ_DIR)/i18n/nl_NL.c \
$(PROJ_DIR)/i18n/pt_BR.c \
$(PROJ_DIR)/i18n/pt_PT.c \
$(PROJ_DIR)/i18n/ru_RU.c \
$(PROJ_DIR)/i18n/language.c \
$(PROJ_DIR)/hal/hal_nfc_t2t.c \
$(PROJ_DIR)/amiidb/db_amiibo.c \
Expand Down Expand Up @@ -733,10 +734,10 @@ CFLAGS += -DBOARD_$(BOARD)
ifneq ($(RELEASE), 1)
CFLAGS += -DDEBUG
CFLAGS += -DEBUG_NRF
# CFLAGS += -DU8G2_USE_LARGE_GB2312_FONT
#CFLAGS += -DU8G2_USE_LARGE_FONTS
else
CFLAGS += -DNDEBUG
CFLAGS += -DU8G2_USE_LARGE_GB2312_FONT
CFLAGS += -DU8G2_USE_LARGE_FONTS
endif
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_NRF5X
CFLAGS += -DMBEDTLS_CONFIG_FILE=\"nrf_crypto_mbedtls_config.h\"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,11 @@ static void amiibo_scene_amiibo_detail_menu_on_selected(mui_list_view_event_t ev
amiibo_scene_amiibo_detail_no_key_msg(app);
return;
}
char txt[32];
settings_data_t *p_settings = settings_get_data();
p_settings->auto_gen_amiibo = !p_settings->auto_gen_amiibo;
snprintf(txt, sizeof(txt), "%s [%s]", getLangString(_L_AUTO_RANDOM_GENERATION),
p_settings->auto_gen_amiibo ? getLangString(_L_ON) : getLangString(_L_OFF));
settings_save();

string_set_str(p_item->text, txt);

mui_scene_dispatcher_previous_scene(app->p_scene_dispatcher);
mui_list_view_item_set_sub_text(p_item, (p_settings->auto_gen_amiibo ? getLangString(_L_ON_F) : getLangString(_L_OFF_F)));
} break;

case AMIIBO_DETAIL_MENU_REMOVE_AMIIBO: {
Expand All @@ -160,13 +155,11 @@ void amiibo_scene_amiibo_detail_menu_on_enter(void *user_data) {

mui_list_view_add_item(app->p_list_view, 0xe1c5, getLangString(_L_RANDOM_GENERATION),
(void *)AMIIBO_DETAIL_MENU_RAND_UID);

char txt[32];
settings_data_t *p_settings = settings_get_data();

snprintf(txt, sizeof(txt), "%s [%s]", getLangString(_L_AUTO_RANDOM_GENERATION),
p_settings->auto_gen_amiibo ? getLangString(_L_ON) : getLangString(_L_OFF));
mui_list_view_add_item(app->p_list_view, 0xe1c6, txt, (void *)AMIIBO_DETAIL_MENU_AUTO_RAND_UID);
mui_list_view_add_item_ext(app->p_list_view, 0xe1c6, getLangString(_L_AUTO_RANDOM_GENERATION),
(p_settings->auto_gen_amiibo ? getLangString(_L_ON_F) : getLangString(_L_OFF_F)),
(void *)AMIIBO_DETAIL_MENU_AUTO_RAND_UID);
mui_list_view_add_item(app->p_list_view, 0xe1c7, getLangString(_L_DELETE_TAG),
(void *)AMIIBO_DETAIL_MENU_REMOVE_AMIIBO);
mui_list_view_add_item(app->p_list_view, 0xe068, getLangString(_L_BACK_TO_DETAILS),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,10 @@ static void amiibo_scene_file_browser_menu_on_selected(mui_list_view_event_t eve

case FILE_BROWSER_MENU_REMOVE_FOLDER: {
char msg[64];
snprintf(msg, sizeof(msg), "%s %s ?", getLangString(_L_DELETE), string_get_cstr(app->current_file));
mui_msg_box_set_header(app->p_msg_box, getLangString(_L_DELETE));
snprintf(msg, sizeof(msg), _T(DELETE_FILE), string_get_cstr(app->current_file));
mui_msg_box_set_header(app->p_msg_box, getLangString(_L_TIPS));
mui_msg_box_set_message(app->p_msg_box, msg);
mui_msg_box_set_btn_text(app->p_msg_box, getLangString(_L_DELETE), NULL, getLangString(_L_CANCEL));
mui_msg_box_set_btn_text(app->p_msg_box, getLangString(_L_CONFIRM), NULL, getLangString(_L_CANCEL));
mui_msg_box_set_btn_focus(app->p_msg_box, 2);
mui_msg_box_set_event_cb(app->p_msg_box, amiibo_scene_file_browser_menu_msg_box_remove_folder_event_cb);

Expand Down Expand Up @@ -298,9 +298,9 @@ void amiibo_scene_file_browser_menu_on_enter(void *user_data) {
(void *)FILE_BROWSER_MENU_CREATE_AMIIBO_BATCH);
if (string_cmp_str(app->current_file, "..") != 0) {
char txt[32];
snprintf(txt, sizeof(txt), "%s..", getLangString(_L_RENAME));
snprintf(txt, sizeof(txt), "%s", getLangString(_L_RENAME));
mui_list_view_add_item(app->p_list_view, ICON_EMPTY, txt, (void *)FILE_BROWSER_MENU_RENAME_FOLDER);
snprintf(txt, sizeof(txt), "%s..", getLangString(_L_DELETE));
snprintf(txt, sizeof(txt), "%s", getLangString(_L_DELETE));
mui_list_view_add_item(app->p_list_view, ICON_DELETE, txt, (void *)FILE_BROWSER_MENU_REMOVE_FOLDER);
}
mui_list_view_add_item(app->p_list_view, ICON_BACK, getLangString(_L_BACK_TO_FILE_LIST),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ static void amiidb_scene_amiibo_detail_menu_on_selected(mui_list_view_event_t ev
char txt[32];
settings_data_t *p_settings = settings_get_data();
p_settings->auto_gen_amiibo = !p_settings->auto_gen_amiibo;
snprintf(txt, sizeof(txt), "[%s]",
p_settings->auto_gen_amiibo ? getLangString(_L_ON) : getLangString(_L_OFF));
snprintf(txt, sizeof(txt), "%s",
p_settings->auto_gen_amiibo ? getLangString(_L_ON_F) : getLangString(_L_OFF_F));
settings_save();

string_set_str(p_item->sub_text, txt);
Expand All @@ -108,7 +108,7 @@ static void amiidb_scene_amiibo_detail_menu_on_selected(mui_list_view_event_t ev
char txt[32];
settings_data_t *p_settings = settings_get_data();
p_settings->qrcode_enabled = !p_settings->qrcode_enabled;
snprintf(txt, sizeof(txt), "[%s]", p_settings->qrcode_enabled ? getLangString(_L_ON) : getLangString(_L_OFF));
snprintf(txt, sizeof(txt), "%s", p_settings->qrcode_enabled ? getLangString(_L_ON_F) : getLangString(_L_OFF_F));
settings_save();

string_set_str(p_item->sub_text, txt);
Expand Down Expand Up @@ -139,11 +139,11 @@ void amiidb_scene_amiibo_detail_menu_on_enter(void *user_data) {
char txt[32];
settings_data_t *p_settings = settings_get_data();

snprintf(txt, sizeof(txt), "[%s]", p_settings->auto_gen_amiibo ? getLangString(_L_ON) : getLangString(_L_OFF));
snprintf(txt, sizeof(txt), "%s", p_settings->auto_gen_amiibo ? getLangString(_L_ON_F) : getLangString(_L_OFF_F));
mui_list_view_add_item_ext(app->p_list_view, 0xe1c6, getLangString(_L_AUTO_RANDOM_GENERATION), txt,
(void *)AMIIDB_DETAIL_MENU_AUTO_RAND_UID);

snprintf(txt, sizeof(txt), "[%s]", p_settings->qrcode_enabled ? getLangString(_L_ON) : getLangString(_L_OFF));
snprintf(txt, sizeof(txt), "%s", p_settings->qrcode_enabled ? getLangString(_L_ON_F) : getLangString(_L_OFF_F));
mui_list_view_add_item_ext(app->p_list_view, 0xe006, getLangString(_L_SHOW_QRCODE), txt,
(void *)AMIIDB_DETAIL_MENU_SHOW_QRCODE);
mui_list_view_add_item(app->p_list_view, ICON_FAVORITE, getLangString(_L_APP_AMIIDB_DETAIL_FAVORITE),
Expand Down
19 changes: 19 additions & 0 deletions fw/application/src/app/amiidb/scene/amiidb_scene_amiibo_search.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ static void amiidb_scene_amiibo_search_text_input_event_cb(mui_text_input_event_
}
}

static void amiidb_msg_box_error_cb(mui_msg_box_event_t event, mui_msg_box_t *p_msg_box) {
app_amiidb_t *app = p_msg_box->user_data;
mui_view_dispatcher_switch_to_view(app->p_view_dispatcher, AMIIDB_VIEW_ID_LIST);
}

static void amiidb_show_message(app_amiidb_t *app, const char *msg) {
mui_msg_box_set_header(app->p_msg_box, getLangString(_L_ERR));
mui_msg_box_set_message(app->p_msg_box, msg);
mui_msg_box_set_btn_text(app->p_msg_box, NULL, getLangString(_L_KNOW), NULL);
mui_msg_box_set_btn_focus(app->p_msg_box, 1);
mui_msg_box_set_event_cb(app->p_msg_box, amiidb_msg_box_error_cb);

mui_view_dispatcher_switch_to_view(app->p_view_dispatcher, AMIIDB_VIEW_ID_MSG_BOX);
}

static void amiidb_scene_amiibo_search_list_view_on_selected(mui_list_view_event_t event, mui_list_view_t *p_list_view,
mui_list_item_t *p_item) {
uint16_t icon = p_item->icon;
Expand All @@ -49,6 +64,10 @@ static void amiidb_scene_amiibo_search_list_view_on_selected(mui_list_view_event
mui_text_input_set_event_cb(app->p_text_input, amiidb_scene_amiibo_search_text_input_event_cb);
mui_view_dispatcher_switch_to_view(app->p_view_dispatcher, AMIIDB_VIEW_ID_INPUT);
} break;

case ICON_ERROR: {
amiidb_show_message(app, _T(APP_AMIIDB_MORE_MESSAGE));
} break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ static void settings_scene_main_reload(void *user_data) {
(void *)SETTINGS_MAIN_MENU_OLED_CONTRAST);
#else
if (p_settings->lcd_backlight == 0) {
snprintf(txt, sizeof(txt), "[%s]", getLangString(_L_OFF));
snprintf(txt, sizeof(txt), "%s", getLangString(_L_OFF_F));
} else {
snprintf(txt, sizeof(txt), "[%d%%]", p_settings->lcd_backlight);
}
Expand Down
68 changes: 39 additions & 29 deletions fw/application/src/hal/hal_spi_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#define MTC_W25Q32_BV (0x4016) /* W25Q32BV */
#define MTC_W25Q32_DW (0x6016) /* W25Q32DW */
#define MTC_W25Q64_BV_CV (0x4017) /* W25Q64BV W25Q64CV */
#define MTC_W25Q64_DW (0x4017) /* W25Q64DW */
#define MTC_W25Q64_DW (0x6017) /* W25Q64DW */
#define MTC_W25Q128_BV (0x4018) /* W25Q128BV */
#define MTC_W25Q256_FV (TBD) /* W25Q256FV */
#define MTC_MX25L25645_GM2I (0x2019) /* MX25L25645GM2I-10G */
Expand Down Expand Up @@ -151,38 +151,48 @@ ret_code_t hal_spi_flash_info(flash_info_t *info) {
memory_type_capacity = rx[1];
memory_type_capacity = (memory_type_capacity << 8) | rx[2];

if (memory_type_capacity == MTC_MX25L25645_GM2I) {
NRF_LOG_INFO("MX25L25645GM2I-10G detection");
info->block_count = 8192;
} else if (memory_type_capacity == MTC_W25Q128_BV) {
NRF_LOG_INFO("W25Q128BV detection");
info->block_count = 4096;
} else if (memory_type_capacity == MTC_W25Q64_BV_CV) {
NRF_LOG_INFO("W25Q64BV or W25Q64CV detection");
info->block_count = 2048;
} else if (memory_type_capacity == MTC_W25Q64_DW) {
NRF_LOG_INFO("W25Q64DW detection");
info->block_count = 2048;
} else if (memory_type_capacity == MTC_W25Q32_BV) {
NRF_LOG_INFO("W25Q32BV detection");
info->block_count = 1024;
} else if (memory_type_capacity == MTC_W25Q32_DW) {
NRF_LOG_INFO("W25Q32DW detection");
info->block_count = 1024;
} else if (memory_type_capacity == MTC_W25Q16_BV_CL_CV) {
NRF_LOG_INFO("W25Q16BV or W25Q16CL or W25Q16CV detection");
info->block_count = 512;
} else if (memory_type_capacity == MTC_W25Q16_DW) {
NRF_LOG_INFO("W25Q16DW detection");
info->block_count = 512;
} else {
NRF_LOG_INFO("Memory Capacity error! %d", memory_type_capacity);
info->block_count = 0;
return NRF_ERROR_INVALID_PARAM;
switch (memory_type_capacity) {
case MTC_MX25L25645_GM2I:
NRF_LOG_INFO("MX25L25645GM2I-10G detection");
info->block_count = 8192;
break;
case MTC_W25Q128_BV:
NRF_LOG_INFO("W25Q128BV detection");
info->block_count = 4096;
break;
case MTC_W25Q64_BV_CV:
NRF_LOG_INFO("W25Q64BV or W25Q64CV detection");
info->block_count = 2048;
break;
case MTC_W25Q64_DW:
NRF_LOG_INFO("W25Q64DW detection");
info->block_count = 2048;
break;
case MTC_W25Q32_BV:
NRF_LOG_INFO("W25Q32BV detection");
info->block_count = 1024;
break;
case MTC_W25Q32_DW:
NRF_LOG_INFO("W25Q32DW detection");
info->block_count = 1024;
break;
case MTC_W25Q16_BV_CL_CV:
NRF_LOG_INFO("W25Q16BV or W25Q16CL or W25Q16CV detection");
info->block_count = 512;
break;
case MTC_W25Q16_DW:
NRF_LOG_INFO("W25Q16DW detection");
info->block_count = 512;
break;
default:
NRF_LOG_INFO("Memory Capacity error! %d", memory_type_capacity);
info->block_count = 0;
return NRF_ERROR_INVALID_PARAM;
}
return NRF_SUCCESS;
}


ret_code_t hal_spi_flash_read(uint32_t address, void *buffer, size_t size) {

uint8_t tx[4];
Expand Down
Loading

0 comments on commit d02e5e2

Please sign in to comment.