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

Add Beta Localization Support for HDZERO Goggles Firmware #439

Closed
wants to merge 8 commits into from
Closed
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ FROM --platform=linux/x86_64 mcr.microsoft.com/devcontainers/base:ubuntu

RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update && \
apt-get -y install --no-install-recommends cmake build-essential ninja-build libsdl2-dev
apt-get -y install --no-install-recommends cmake build-essential ninja-build libsdl2-dev nodejs npm && \
npm i lv_i18n -g
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ media.tar.gz
/tmp
/.vscode/settings.json
.DS_Store
/node_modules
package-lock.json
package.json
7 changes: 6 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"editor.formatOnSave": true
"editor.formatOnSave": true,
"files.associations": {
"ui_osd_element_pos.h": "c",
"msp_displayport.h": "c",
"complex": "c"
}
}
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ file(GLOB SRC_FILES_CORE "src/core/*.c" "src/core/*.h")
file(GLOB SRC_FILES_DRIVER "src/driver/*.c" "src/driver/*.h")
file(GLOB SRC_FILES_FONTS "src/fonts/*.c" "src/fonts/*.h")
file(GLOB SRC_FILES_IMAGE "src/image/*.c" "src/image/*.h")
file(GLOB SRC_FIELS_LV_I18N "src/lv_i18n/*.c" "src/lv_i18n/*.h")
file(GLOB SRC_FILES_UI "src/ui/*.c" "src/ui/*.h")
file(GLOB SRC_FILES_BMI "src/bmi270/*.c" "src/bmi270/*.h")
file(GLOB SRC_FILES_UTIL "src/util/*.c" "src/util/*.h")
Expand All @@ -76,6 +77,7 @@ set(SRC_FILES
${SRC_FILES_DRIVER}
${SRC_FILES_FONTS}
${SRC_FILES_IMAGE}
${SRC_FIELS_LV_I18N}
${SRC_FILES_UI}
${SRC_FILES_BMI}
${SRC_FILES_UTIL}
Expand Down
Empty file added internalisationGudie.md
Empty file.
4 changes: 2 additions & 2 deletions lib/lvgl/lv_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,10 @@
/*Optionally declare custom fonts here.
*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
#define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(montserrat_16) LV_FONT_DECLARE(montserrat_18) LV_FONT_DECLARE(montserrat_20)LV_FONT_DECLARE(montserrat_26) LV_FONT_DECLARE(montserrat_40)

/*Always set a default font*/
#define LV_FONT_DEFAULT &lv_font_montserrat_26
#define LV_FONT_DEFAULT &montserrat_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
3 changes: 3 additions & 0 deletions mkapp/app/setting.ini
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ sta_passwd=MyPassword
[osd]
embedded_mode=0

[language]
lang=en-US

#### OSD elements ####
# top fan speed
element_topfan_speed_show=true
Expand Down
4 changes: 4 additions & 0 deletions src/core/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ SDL_mutex *global_sdl_mutex;
#include "driver/mcp3021.h"
#include "driver/oled.h"
#include "driver/rtc.h"
#include "lv_i18n/lv_i18n.h"
#include "ui/page_power.h"
#include "ui/page_scannow.h"
#include "ui/page_source.h"
Expand Down Expand Up @@ -140,6 +141,9 @@ void lvgl_init() {
false, LV_FONT_DEFAULT);
lv_disp_set_theme(dispp, theme);
lv_obj_set_style_bg_color(lv_scr_act(), lv_color_make(64, 64, 64), 0);

lv_i18n_init(lv_i18n_language_pack);
lv_i18n_set_locale(g_setting.language.lang);
}

int main(int argc, char *argv[]) {
Expand Down
6 changes: 6 additions & 0 deletions src/core/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ const setting_t g_setting_defaults = {
.hdzero_band = SETTING_SOURCES_HDZERO_BAND_RACEBAND,
.hdzero_bw = SETTING_SOURCES_HDZERO_BW_WIDE,
},
.language = {
.lang = "en-GB",
},
};

int settings_put_osd_element_shown(bool show, char *config_name) {
Expand Down Expand Up @@ -449,6 +452,9 @@ void settings_load(void) {
ini_gets("wifi", "root_pw", g_setting_defaults.wifi.root_pw, g_setting.wifi.root_pw, WIFI_PASSWD_MAX, SETTING_INI);
g_setting.wifi.ssh = settings_get_bool("wifi", "ssh", g_setting_defaults.wifi.ssh);

// language
ini_gets("language", "lang", g_setting_defaults.language.lang, g_setting.language.lang, 6, SETTING_INI);

// no dial under video mode
g_setting.ease.no_dial = fs_file_exists(NO_DIAL_FILE);

Expand Down
5 changes: 5 additions & 0 deletions src/core/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ typedef struct {
bool ssh;
} wifi_t;

typedef struct {
char lang[6];
} setting_language_t;

typedef struct {
uint8_t no_dial; // 1=disable turning channels under video mode
} ease_use_t;
Expand Down Expand Up @@ -270,6 +274,7 @@ typedef struct {
setting_head_tracker_t ht;
setting_elrs_t elrs;
wifi_t wifi;
setting_language_t language;
setting_osd_t osd;
setting_clock_t clock;
setting_inputs_t inputs;
Expand Down
Loading