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(radio): sort global/special function names #5429

Merged
merged 7 commits into from
Aug 23, 2024
Merged

Conversation

philmoz
Copy link
Collaborator

@philmoz philmoz commented Aug 14, 2024

Fixes #3591

Radio side changes.

Companion side has been done already via #4585

Add a sorted index table for the functions so they can be selected in alphabetical order.

Adds a new tool to generate the sorted index table for each language using the language locale (cfn_sorter.sh & cfn_sorter.cpp). Run cfn_sorter.sh in the top level directory to rebuild. Not pretty but does the job.

@elecpower
Copy link
Collaborator

elecpower commented Aug 14, 2024

Not pretty is an understatement. Also another place to update with changes to languages.

I'm glad my side was only two extra lines of code.

@philmoz
Copy link
Collaborator Author

philmoz commented Aug 14, 2024

Not pretty is an understatement. Also another place to update with changes to languages.

It should only require an update if a new function is added - the strings in cfn_sort.cpp are for reference only (to check the sorting).

@pfeerick pfeerick added the enhancement ✨ New feature or request label Aug 14, 2024
@pfeerick pfeerick added this to the 2.11 milestone Aug 14, 2024
@pfeerick
Copy link
Member

Can you let me know if this still works for you on MacOS? I needed the CXX change as gcc is not symlinked on Linux (it really is g++), the rest should mostly just be cosmetics / de-repetition. I couldn't see an immiedately reliably /simple cross-platform way to check the locales, especially since my container is using .utf8 suffix instead of .UTF-8, so left it up to the person who runs this to figure it that part out (i.e. edit /etc/locale.gen and run locales on Linux).

@pfeerick
Copy link
Member

  • FUNC_DISABLE_TOUCH and FUNC_SET_SCREEN need some TLC I think, they seem to be getting created for all radios now - not being marked as colorlcd only.

Is cfn_sort.cpp supposed to be sorted now? As it seems like your system is doing a case sensitive sort if that is the case, as running the script on mine is changing them into case and accent insensitive sort order... i.e.

i.e. for CZ

  /* RGB světlo */ FUNC_RGB_LED,
  /* Reset */ FUNC_RESET,

image

Another example, DE
image

Quite a few others... and it wants to re-order some of the JP, UA, etc... which I have no idea of whether is right order or not, but the rest appear to be correct? 🤷

@pfeerick
Copy link
Member

Diff, for reference

diff --git a/radio/src/cfn_sort.cpp b/radio/src/cfn_sort.cpp
index c10434f026..19d6777045 100644
--- a/radio/src/cfn_sort.cpp
+++ b/radio/src/cfn_sort.cpp
@@ -24,41 +24,41 @@
 #include "dataconstants.h"
 
 Functions cfn_sorted[] = {
-#if   defined(TRANSLATIONS_CN)
+#if defined(TRANSLATIONS_CN)
 
-  /* Lua脚本 */ FUNC_PLAY_SCRIPT,
-  /* RGB LED 灯 */ FUNC_RGB_LED,
-  /* Vario传感器 */ FUNC_VARIO,
-#if defined(OLED_SCREEN)
-  /* 亮度 */ FUNC_BACKLIGHT,
-#endif
-  /* 复位 */ FUNC_RESET,
-  /* 截屏 */ FUNC_SCREENSHOT,
-  /* 振动 */ FUNC_HAPTIC,
-  /* 教练 */ FUNC_TRAINER,
-  /* 测试 */ FUNC_TEST,
 #if !defined(OLED_SCREEN)
   /* 背光 */ FUNC_BACKLIGHT,
 #endif
-  /* 设置 */ FUNC_SET_TIMER,
-  /* 音量 */ FUNC_VOLUME,
+  /* 播放背景音乐 */ FUNC_BACKGND_MUSIC,
   /* 播放声音 */ FUNC_PLAY_SOUND,
   /* 播放数值 */ FUNC_PLAY_VALUE,
-  /* 模块对频 */ FUNC_BIND,
+  /* 播放音频文件 */ FUNC_PLAY_TRACK,
   /* 测距模式 */ FUNC_RANGECHECK,
+  /* 测试 */ FUNC_TEST,
+  /* 复位 */ FUNC_RESET,
+  /* 关闭音频功放 */ FUNC_DISABLE_AUDIO_AMP,
+  /* 记录日志到SD卡 */ FUNC_LOGS,
+  /* 教练 */ FUNC_TRAINER,
+  /* 截屏 */ FUNC_SCREENSHOT,
   /* 禁用触摸 */ FUNC_DISABLE_TOUCH,
   /* 竞速模式 */ FUNC_RACING_MODE,
-  /* 选择主屏 */ FUNC_SET_SCREEN,
-  /* 锁定通道值 */ FUNC_OVERRIDE_CHANNEL,
-  /* 记录日志到SD卡 */ FUNC_LOGS,
-  /* 关闭音频功放 */ FUNC_DISABLE_AUDIO_AMP,
+#if defined(OLED_SCREEN)
+  /* 亮度 */ FUNC_BACKLIGHT,
+#endif
+  /* 模块对频 */ FUNC_BIND,
   /* 屏幕显示图传 */ FUNC_LCD_TO_VIDEO,
-  /* 播放背景音乐 */ FUNC_BACKGND_MUSIC,
-  /* 播放音频文件 */ FUNC_PLAY_TRACK,
-  /* 暂停背景音乐 */ FUNC_BACKGND_MUSIC_PAUSE,
+  /* 设置 */ FUNC_SET_TIMER,
   /* 设置失控保护 */ FUNC_SET_FAILSAFE,
+  /* 锁定通道值 */ FUNC_OVERRIDE_CHANNEL,
   /* 修改全局变量GV值 */ FUNC_ADJUST_GVAR,
+  /* 选择主屏 */ FUNC_SET_SCREEN,
   /* 摇杆值存储到微调 */ FUNC_INSTANT_TRIM,
+  /* 音量 */ FUNC_VOLUME,
+  /* 暂停背景音乐 */ FUNC_BACKGND_MUSIC_PAUSE,
+  /* 振动 */ FUNC_HAPTIC,
+  /* Lua脚本 */ FUNC_PLAY_SCRIPT,
+  /* RGB LED 灯 */ FUNC_RGB_LED,
+  /* Vario传感器 */ FUNC_VARIO,
 
 #elif defined(TRANSLATIONS_CZ)
 
@@ -83,8 +83,8 @@ Functions cfn_sorted[] = {
   /* Podsvětlení */ FUNC_BACKLIGHT,
 #endif
   /* Přehrát wav */ FUNC_PLAY_TRACK,
-  /* RGB světlo */ FUNC_RGB_LED,
   /* Reset */ FUNC_RESET,
+  /* RGB světlo */ FUNC_RGB_LED,
   /* Snímek LCD */ FUNC_SCREENSHOT,
   /* Test */ FUNC_TEST,
   /* Trenér */ FUNC_TRAINER,
@@ -92,9 +92,9 @@ Functions cfn_sorted[] = {
   /* Vibrovat */ FUNC_HAPTIC,
   /* Vybrat hlavní obrazovku */ FUNC_SET_SCREEN,
   /* Vypnutí zesilovače zvuku */ FUNC_DISABLE_AUDIO_AMP,
-  /* Změna */ FUNC_SET_TIMER,
   /* Zámek */ FUNC_OVERRIDE_CHANNEL,
   /* Závodní režim */ FUNC_RACING_MODE,
+  /* Změna */ FUNC_SET_TIMER,
 
 #elif defined(TRANSLATIONS_DA)
 
@@ -117,20 +117,20 @@ Functions cfn_sorted[] = {
   /* RGB led */ FUNC_RGB_LED,
   /* Ræs tilstand */ FUNC_RACING_MODE,
   /* SD Log */ FUNC_LOGS,
-  /* Sæt */ FUNC_SET_TIMER,
-  /* Sæt fejlsikring */ FUNC_SET_FAILSAFE,
-  /* Skærm klip */ FUNC_SCREENSHOT,
 #if defined(OLED_SCREEN)
   /* Skarphed */ FUNC_BACKLIGHT,
 #endif
+  /* Skærm klip */ FUNC_SCREENSHOT,
   /* Sluk audio amplifier */ FUNC_DISABLE_AUDIO_AMP,
-  /* Spil Værdi */ FUNC_PLAY_VALUE,
   /* Spil lyd */ FUNC_PLAY_SOUND,
+  /* Spil Værdi */ FUNC_PLAY_VALUE,
+  /* Sæt */ FUNC_SET_TIMER,
+  /* Sæt fejlsikring */ FUNC_SET_FAILSAFE,
   /* Test */ FUNC_TEST,
   /* Træner */ FUNC_TRAINER,
-  /* Vælg hoved skærm */ FUNC_SET_SCREEN,
   /* Vario */ FUNC_VARIO,
   /* Vibration */ FUNC_HAPTIC,
+  /* Vælg hoved skærm */ FUNC_SET_SCREEN,
 
 #elif defined(TRANSLATIONS_DE)
 
@@ -142,24 +142,24 @@ Functions cfn_sorted[] = {
 #endif
   /* Inst. Trim */ FUNC_INSTANT_TRIM,
   /* Kein Touch */ FUNC_DISABLE_TOUCH,
+  /* Lautstr. */ FUNC_VOLUME,
 #if !defined(OLED_SCREEN)
   /* LCD Licht */ FUNC_BACKLIGHT,
 #endif
   /* LCD to Video */ FUNC_LCD_TO_VIDEO,
-  /* Lautstr. */ FUNC_VOLUME,
   /* Lehrer */ FUNC_TRAINER,
   /* Lua Skript */ FUNC_PLAY_SCRIPT,
   /* ModuleBind */ FUNC_BIND,
-  /* RGB LED */ FUNC_RGB_LED,
   /* RacingMode */ FUNC_RACING_MODE,
   /* RangeCheck */ FUNC_RANGECHECK,
+  /* RGB LED */ FUNC_RGB_LED,
   /* Rücksetz. */ FUNC_RESET,
-  /* SD-Aufz. */ FUNC_LOGS,
   /* Sag Text */ FUNC_PLAY_TRACK,
   /* Sag Wert */ FUNC_PLAY_VALUE,
   /* Screenshot */ FUNC_SCREENSHOT,
-  /* Set Main Screen */ FUNC_SET_SCREEN,
+  /* SD-Aufz. */ FUNC_LOGS,
   /* SetFailsafe */ FUNC_SET_FAILSAFE,
+  /* Set Main Screen */ FUNC_SET_SCREEN,
   /* Setze */ FUNC_SET_TIMER,
   /* Spiel Töne */ FUNC_PLAY_SOUND,
   /* StartMusik */ FUNC_BACKGND_MUSIC,
@@ -194,9 +194,9 @@ Functions cfn_sorted[] = {
   /* Oir pista */ FUNC_PLAY_TRACK,
   /* Oir sonido */ FUNC_PLAY_SOUND,
   /* Oir valor */ FUNC_PLAY_VALUE,
-  /* RGB leds */ FUNC_RGB_LED,
   /* RacingMode */ FUNC_RACING_MODE,
   /* Reset */ FUNC_RESET,
+  /* RGB leds */ FUNC_RGB_LED,
   /* SD Logs */ FUNC_LOGS,
   /* Seguro */ FUNC_OVERRIDE_CHANNEL,
   /* Set Main Screen */ FUNC_SET_SCREEN,
@@ -225,16 +225,16 @@ Functions cfn_sorted[] = {
   /* Play Sound */ FUNC_PLAY_SOUND,
   /* Play Track */ FUNC_PLAY_TRACK,
   /* Play Value */ FUNC_PLAY_VALUE,
-  /* RGB leds */ FUNC_RGB_LED,
   /* RacingMode */ FUNC_RACING_MODE,
   /* RangeCheck */ FUNC_RANGECHECK,
   /* Reset */ FUNC_RESET,
-  /* SD Logs */ FUNC_LOGS,
+  /* RGB leds */ FUNC_RGB_LED,
   /* Safety */ FUNC_OVERRIDE_CHANNEL,
   /* Screenshot */ FUNC_SCREENSHOT,
+  /* SD Logs */ FUNC_LOGS,
   /* Set */ FUNC_SET_TIMER,
-  /* Set Main Screen */ FUNC_SET_SCREEN,
   /* SetFailsafe */ FUNC_SET_FAILSAFE,
+  /* Set Main Screen */ FUNC_SET_SCREEN,
   /* Test */ FUNC_TEST,
   /* Trainer */ FUNC_TRAINER,
   /* Vario */ FUNC_VARIO,
@@ -261,7 +261,6 @@ Functions cfn_sorted[] = {
   /* Non Tactile */ FUNC_DISABLE_TOUCH,
   /* Pause Musique */ FUNC_BACKGND_MUSIC_PAUSE,
   /* Photo Écran */ FUNC_SCREENSHOT,
-  /* RGB leds */ FUNC_RGB_LED,
   /* Racing Mode */ FUNC_RACING_MODE,
   /* Régle Failsafe */ FUNC_SET_FAILSAFE,
   /* Remise à 0 */ FUNC_RESET,
@@ -269,6 +268,7 @@ Functions cfn_sorted[] = {
 #if !defined(OLED_SCREEN)
   /* Rétroécl. */ FUNC_BACKLIGHT,
 #endif
+  /* RGB leds */ FUNC_RGB_LED,
   /* Script Lua */ FUNC_PLAY_SCRIPT,
   /* Test */ FUNC_TEST,
   /* Test Port. */ FUNC_RANGECHECK,
@@ -294,9 +294,9 @@ Functions cfn_sorted[] = {
   /* Play Sound */ FUNC_PLAY_SOUND,
   /* Play Track */ FUNC_PLAY_TRACK,
   /* Play Value */ FUNC_PLAY_VALUE,
-  /* RGB leds */ FUNC_RGB_LED,
   /* RangeCheck */ FUNC_RANGECHECK,
   /* Reset */ FUNC_RESET,
+  /* RGB leds */ FUNC_RGB_LED,
   /* SD Logs */ FUNC_LOGS,
   /* Set */ FUNC_SET_TIMER,
   /* SetFailsafe */ FUNC_SET_FAILSAFE,
@@ -304,13 +304,13 @@ Functions cfn_sorted[] = {
   /* Trainer */ FUNC_TRAINER,
   /* Vario */ FUNC_VARIO,
   /* Volume */ FUNC_VOLUME,
-  /* ללא מסך מגע */ FUNC_DISABLE_TOUCH,
-  /* מצב תחרות */ FUNC_RACING_MODE,
-  /* צילום מסך */ FUNC_SCREENSHOT,
-  /* הגדרת מסך ראשי */ FUNC_SET_SCREEN,
 #if defined(OLED_SCREEN)
   /* בהירות */ FUNC_BACKLIGHT,
 #endif
+  /* הגדרת מסך ראשי */ FUNC_SET_SCREEN,
+  /* ללא מסך מגע */ FUNC_DISABLE_TOUCH,
+  /* מצב תחרות */ FUNC_RACING_MODE,
+  /* צילום מסך */ FUNC_SCREENSHOT,
 
 #elif defined(TRANSLATIONS_IT)
 
@@ -350,8 +350,8 @@ Functions cfn_sorted[] = {
 
 #elif defined(TRANSLATIONS_JP)
 
-  /* BGM再生 */ FUNC_BACKGND_MUSIC,
   /* BGM一時停止 */ FUNC_BACKGND_MUSIC_PAUSE,
+  /* BGM再生 */ FUNC_BACKGND_MUSIC,
   /* Failsafe設定 */ FUNC_SET_FAILSAFE,
   /* G変数修正 */ FUNC_ADJUST_GVAR,
   /* Inst.トリム */ FUNC_INSTANT_TRIM,
@@ -359,30 +359,30 @@ Functions cfn_sorted[] = {
   /* LUAスクリプト */ FUNC_PLAY_SCRIPT,
   /* RGB LED */ FUNC_RGB_LED,
   /* SDログ出力 */ FUNC_LOGS,
-  /* 設定 */ FUNC_SET_TIMER,
-#if defined(OLED_SCREEN)
-  /* 輝度 */ FUNC_BACKLIGHT,
-#endif
-  /* テスト */ FUNC_TEST,
-  /* バリオ */ FUNC_VARIO,
-  /* 上書き */ FUNC_OVERRIDE_CHANNEL,
-  /* 再生値 */ FUNC_PLAY_VALUE,
+  /* オーディオアンプ OFF */ FUNC_DISABLE_AUDIO_AMP,
+  /* サウンド再生 */ FUNC_PLAY_SOUND,
   /* ダイヤル */ FUNC_VOLUME,
-  /* リセット */ FUNC_RESET,
-  /* 非タッチ */ FUNC_DISABLE_TOUCH,
-  /* 音源再生 */ FUNC_PLAY_TRACK,
+  /* テスト */ FUNC_TEST,
   /* トレーナー */ FUNC_TRAINER,
-  /* サウンド再生 */ FUNC_PLAY_SOUND,
   /* バイブレート */ FUNC_HAPTIC,
 #if !defined(OLED_SCREEN)
   /* バックライト */ FUNC_BACKLIGHT,
 #endif
-  /* レースモード */ FUNC_RACING_MODE,
+  /* バリオ */ FUNC_VARIO,
   /* メイン画面設定 */ FUNC_SET_SCREEN,
+  /* モジュールバインド */ FUNC_BIND,
+  /* リセット */ FUNC_RESET,
+  /* レースモード */ FUNC_RACING_MODE,
   /* レンジチェック */ FUNC_RANGECHECK,
+  /* 音源再生 */ FUNC_PLAY_TRACK,
   /* 画面キャプチャ */ FUNC_SCREENSHOT,
-  /* オーディオアンプ OFF */ FUNC_DISABLE_AUDIO_AMP,
-  /* モジュールバインド */ FUNC_BIND,
+#if defined(OLED_SCREEN)
+  /* 輝度 */ FUNC_BACKLIGHT,
+#endif
+  /* 再生値 */ FUNC_PLAY_VALUE,
+  /* 上書き */ FUNC_OVERRIDE_CHANNEL,
+  /* 設定 */ FUNC_SET_TIMER,
+  /* 非タッチ */ FUNC_DISABLE_TOUCH,
 
 #elif defined(TRANSLATIONS_NL)
 
@@ -405,15 +405,15 @@ Functions cfn_sorted[] = {
   /* Override */ FUNC_OVERRIDE_CHANNEL,
   /* Play Track */ FUNC_PLAY_TRACK,
   /* Play Value */ FUNC_PLAY_VALUE,
-  /* RGB leds */ FUNC_RGB_LED,
   /* RacingMode */ FUNC_RACING_MODE,
   /* RangeCheck */ FUNC_RANGECHECK,
   /* Reset */ FUNC_RESET,
-  /* SD Logs */ FUNC_LOGS,
+  /* RGB leds */ FUNC_RGB_LED,
   /* Schermafdr */ FUNC_SCREENSHOT,
+  /* SD Logs */ FUNC_LOGS,
   /* Set */ FUNC_SET_TIMER,
-  /* Set Main Screen */ FUNC_SET_SCREEN,
   /* SetFailsafe */ FUNC_SET_FAILSAFE,
+  /* Set Main Screen */ FUNC_SET_SCREEN,
   /* Test */ FUNC_TEST,
   /* Trainer */ FUNC_TRAINER,
   /* Vario */ FUNC_VARIO,
@@ -423,10 +423,10 @@ Functions cfn_sorted[] = {
 #elif defined(TRANSLATIONS_PL)
 
   /* Bezpiecz */ FUNC_OVERRIDE_CHANNEL,
+  /* Głośność */ FUNC_VOLUME,
   /* GrajDźwięk */ FUNC_PLAY_SOUND,
-  /* GrajWartoś */ FUNC_PLAY_VALUE,
   /* GrajŚcieżk */ FUNC_PLAY_TRACK,
-  /* Głośność */ FUNC_VOLUME,
+  /* GrajWartoś */ FUNC_PLAY_VALUE,
   /* Inst-Trim */ FUNC_INSTANT_TRIM,
 #if defined(OLED_SCREEN)
   /* Jasność */ FUNC_BACKLIGHT,
@@ -440,10 +440,10 @@ Functions cfn_sorted[] = {
 #if !defined(OLED_SCREEN)
   /* Podświetl */ FUNC_BACKLIGHT,
 #endif
-  /* RGB ledy */ FUNC_RGB_LED,
   /* RacingMode */ FUNC_RACING_MODE,
   /* RangeCheck */ FUNC_RANGECHECK,
   /* Resetuj */ FUNC_RESET,
+  /* RGB ledy */ FUNC_RGB_LED,
   /* Set Main Screen */ FUNC_SET_SCREEN,
   /* SetFailsafe */ FUNC_SET_FAILSAFE,
   /* SkryptyLua */ FUNC_PLAY_SCRIPT,
@@ -467,9 +467,9 @@ Functions cfn_sorted[] = {
   /* Brilho */ FUNC_BACKLIGHT,
 #endif
   /* Capt. Tela */ FUNC_SCREENSHOT,
-  /* Def Tela Princ */ FUNC_SET_SCREEN,
   /* DefFailsafe */ FUNC_SET_FAILSAFE,
   /* Definir */ FUNC_SET_TIMER,
+  /* Def Tela Princ */ FUNC_SET_SCREEN,
   /* LCD to Video */ FUNC_LCD_TO_VIDEO,
   /* Leds RGB */ FUNC_RGB_LED,
   /* Logs SD */ FUNC_LOGS,
@@ -500,33 +500,33 @@ Functions cfn_sorted[] = {
   /* Play Value */ FUNC_PLAY_VALUE,
   /* RGB подсветка */ FUNC_RGB_LED,
   /* SD логи */ FUNC_LOGS,
-  /* Муз || */ FUNC_BACKGND_MUSIC_PAUSE,
-  /* Муз фон */ FUNC_BACKGND_MUSIC,
-  /* Вык аудио усил. */ FUNC_DISABLE_AUDIO_AMP,
-  /* Тест */ FUNC_TEST,
-  /* Выбр глав экран */ FUNC_SET_SCREEN,
   /* Авар управ */ FUNC_SET_FAILSAFE,
-  /* Пров диапаз */ FUNC_RANGECHECK,
   /* Варио */ FUNC_VARIO,
   /* Вибро */ FUNC_HAPTIC,
-  /* Сброс */ FUNC_RESET,
   /* Воспр звук */ FUNC_PLAY_SOUND,
   /* Воспр трек */ FUNC_PLAY_TRACK,
-  /* Мгнов трим */ FUNC_INSTANT_TRIM,
-  /* Режим гонка */ FUNC_RACING_MODE,
-  /* Таймер */ FUNC_TRAINER,
-  /* Сенсор вык */ FUNC_DISABLE_TOUCH,
-  /* Оменить */ FUNC_OVERRIDE_CHANNEL,
-  /* Установ */ FUNC_SET_TIMER,
-  /* Скриншот */ FUNC_SCREENSHOT,
+  /* Выбр глав экран */ FUNC_SET_SCREEN,
+  /* Вык аудио усил. */ FUNC_DISABLE_AUDIO_AMP,
   /* Громкость */ FUNC_VOLUME,
+  /* Мгнов трим */ FUNC_INSTANT_TRIM,
+  /* Муз || */ FUNC_BACKGND_MUSIC_PAUSE,
+  /* Муз фон */ FUNC_BACKGND_MUSIC,
   /* Настройка */ FUNC_ADJUST_GVAR,
+  /* Оменить */ FUNC_OVERRIDE_CHANNEL,
 #if defined(OLED_SCREEN)
   /* Подсветка */ FUNC_BACKLIGHT,
 #endif
 #if defined(OLED_SCREEN)
   /* Подсветка */ FUNC_BACKLIGHT,
 #endif
+  /* Пров диапаз */ FUNC_RANGECHECK,
+  /* Режим гонка */ FUNC_RACING_MODE,
+  /* Сброс */ FUNC_RESET,
+  /* Сенсор вык */ FUNC_DISABLE_TOUCH,
+  /* Скриншот */ FUNC_SCREENSHOT,
+  /* Таймер */ FUNC_TRAINER,
+  /* Тест */ FUNC_TEST,
+  /* Установ */ FUNC_SET_TIMER,
 
 #elif defined(TRANSLATIONS_SE)
 
@@ -543,13 +543,13 @@ Functions cfn_sorted[] = {
 #endif
   /* Logga data */ FUNC_LOGS,
   /* Lua-skript */ FUNC_PLAY_SCRIPT,
-  /* Lärare */ FUNC_TRAINER,
   /* Lås */ FUNC_OVERRIDE_CHANNEL,
+  /* Lärare */ FUNC_TRAINER,
   /* Musik */ FUNC_BACKGND_MUSIC,
   /* Parkoppla modul */ FUNC_BIND,
   /* Pausa Musik */ FUNC_BACKGND_MUSIC_PAUSE,
-  /* RGB ledljus */ FUNC_RGB_LED,
   /* Range check */ FUNC_RANGECHECK,
+  /* RGB ledljus */ FUNC_RGB_LED,
   /* Skärmbild */ FUNC_SCREENSHOT,
   /* Spara trimmar */ FUNC_INSTANT_TRIM,
   /* Spela ljud */ FUNC_PLAY_SOUND,
@@ -572,71 +572,71 @@ Functions cfn_sorted[] = {
 #if defined(OLED_SCREEN)
   /* 亮度 */ FUNC_BACKLIGHT,
 #endif
+  /* 修改全局變量GV值 */ FUNC_ADJUST_GVAR,
+  /* 屏幕顯示圖傳 */ FUNC_LCD_TO_VIDEO,
   /* 截屏 */ FUNC_SCREENSHOT,
   /* 振動 */ FUNC_HAPTIC,
-  /* 教練 */ FUNC_TRAINER,
-  /* 測試 */ FUNC_TEST,
-#if !defined(OLED_SCREEN)
-  /* 背光 */ FUNC_BACKLIGHT,
-#endif
-  /* 設置 */ FUNC_SET_TIMER,
-  /* 重啟 */ FUNC_RESET,
-  /* 音量 */ FUNC_VOLUME,
+  /* 搖桿值存儲到微調 */ FUNC_INSTANT_TRIM,
   /* 播放數值 */ FUNC_PLAY_VALUE,
   /* 播放聲音 */ FUNC_PLAY_SOUND,
+  /* 播放背景音樂 */ FUNC_BACKGND_MUSIC,
+  /* 播放音頻文件 */ FUNC_PLAY_TRACK,
+  /* 教練 */ FUNC_TRAINER,
+  /* 暫停背景音樂 */ FUNC_BACKGND_MUSIC_PAUSE,
   /* 模塊對頻 */ FUNC_BIND,
+  /* 測試 */ FUNC_TEST,
   /* 測距模式 */ FUNC_RANGECHECK,
   /* 禁用觸摸 */ FUNC_DISABLE_TOUCH,
   /* 競速模式 */ FUNC_RACING_MODE,
-  /* 選擇主屏 */ FUNC_SET_SCREEN,
-  /* 鎖定通道值 */ FUNC_OVERRIDE_CHANNEL,
+#if !defined(OLED_SCREEN)
+  /* 背光 */ FUNC_BACKLIGHT,
+#endif
   /* 記錄日誌到SD卡 */ FUNC_LOGS,
-  /* 屏幕顯示圖傳 */ FUNC_LCD_TO_VIDEO,
-  /* 播放背景音樂 */ FUNC_BACKGND_MUSIC,
-  /* 播放音頻文件 */ FUNC_PLAY_TRACK,
-  /* 暫停背景音樂 */ FUNC_BACKGND_MUSIC_PAUSE,
+  /* 設置 */ FUNC_SET_TIMER,
   /* 設置失控保護 */ FUNC_SET_FAILSAFE,
+  /* 選擇主屏 */ FUNC_SET_SCREEN,
+  /* 重啟 */ FUNC_RESET,
+  /* 鎖定通道值 */ FUNC_OVERRIDE_CHANNEL,
   /* 關閉音頻功放 */ FUNC_DISABLE_AUDIO_AMP,
-  /* 修改全局變量GV值 */ FUNC_ADJUST_GVAR,
-  /* 搖桿值存儲到微調 */ FUNC_INSTANT_TRIM,
+  /* 音量 */ FUNC_VOLUME,
 
 #elif defined(TRANSLATIONS_UA)
 
-  /* LCD to Video */ FUNC_LCD_TO_VIDEO,
-  /* Lua Скрипт */ FUNC_PLAY_SCRIPT,
-  /* RGB leds */ FUNC_RGB_LED,
-  /* SD лог */ FUNC_LOGS,
-  /* Фон.Муз. */ FUNC_BACKGND_MUSIC,
-  /* Фон.Муз. || */ FUNC_BACKGND_MUSIC_PAUSE,
-  /* Тест */ FUNC_TEST,
-  /* Скид. */ FUNC_RESET,
+  /* АварРежим */ FUNC_SET_FAILSAFE,
   /* Варіо */ FUNC_VARIO,
-  /* Вібро */ FUNC_HAPTIC,
   /* Вибір гол. екр. */ FUNC_SET_SCREEN,
+  /* Вібро */ FUNC_HAPTIC,
+  /* Встан. */ FUNC_SET_TIMER,
   /* Грати Звук */ FUNC_PLAY_SOUND,
-  /* Грати Трек */ FUNC_PLAY_TRACK,
   /* Грати Знач. */ FUNC_PLAY_VALUE,
-  /* Режим перегонів */ FUNC_RACING_MODE,
-  /* Встан. */ FUNC_SET_TIMER,
+  /* Грати Трек */ FUNC_PLAY_TRACK,
+  /* Гучність */ FUNC_VOLUME,
   /* Митєв. трим. */ FUNC_INSTANT_TRIM,
-  /* Тренер */ FUNC_TRAINER,
   /* Модуль Bind */ FUNC_BIND,
-  /* Сенсор вимк. */ FUNC_DISABLE_TOUCH,
   /* Налашт. */ FUNC_ADJUST_GVAR,
-  /* Підсил. вимк. */ FUNC_DISABLE_AUDIO_AMP,
+  /* Перевизнач. */ FUNC_OVERRIDE_CHANNEL,
+  /* ПеревірДіап. */ FUNC_RANGECHECK,
 #if !defined(OLED_SCREEN)
   /* Підсвіт. */ FUNC_BACKLIGHT,
 #endif
-  /* Гучність */ FUNC_VOLUME,
+  /* Підсил. вимк. */ FUNC_DISABLE_AUDIO_AMP,
+  /* Режим перегонів */ FUNC_RACING_MODE,
+  /* Сенсор вимк. */ FUNC_DISABLE_TOUCH,
+  /* Скид. */ FUNC_RESET,
   /* Скріншот */ FUNC_SCREENSHOT,
-  /* АварРежим */ FUNC_SET_FAILSAFE,
+  /* Тест */ FUNC_TEST,
+  /* Тренер */ FUNC_TRAINER,
+  /* Фон.Муз. */ FUNC_BACKGND_MUSIC,
+  /* Фон.Муз. || */ FUNC_BACKGND_MUSIC_PAUSE,
 #if defined(OLED_SCREEN)
   /* Яскравість */ FUNC_BACKLIGHT,
 #endif
-  /* Перевизнач. */ FUNC_OVERRIDE_CHANNEL,
-  /* ПеревірДіап. */ FUNC_RANGECHECK,
+  /* LCD to Video */ FUNC_LCD_TO_VIDEO,
+  /* Lua Скрипт */ FUNC_PLAY_SCRIPT,
+  /* RGB leds */ FUNC_RGB_LED,
+  /* SD лог */ FUNC_LOGS,
 
-#else
+#else defined(TRANSLATIONS_EN)
 
   /* Adjust */ FUNC_ADJUST_GVAR,
   /* Audio Amp Off */ FUNC_DISABLE_AUDIO_AMP,
@@ -658,15 +658,15 @@ Functions cfn_sorted[] = {
   /* Play Sound */ FUNC_PLAY_SOUND,
   /* Play Track */ FUNC_PLAY_TRACK,
   /* Play Value */ FUNC_PLAY_VALUE,
-  /* RGB leds */ FUNC_RGB_LED,
   /* RacingMode */ FUNC_RACING_MODE,
   /* RangeCheck */ FUNC_RANGECHECK,
   /* Reset */ FUNC_RESET,
-  /* SD Logs */ FUNC_LOGS,
+  /* RGB leds */ FUNC_RGB_LED,
   /* Screenshot */ FUNC_SCREENSHOT,
+  /* SD Logs */ FUNC_LOGS,
   /* Set */ FUNC_SET_TIMER,
-  /* Set Main Screen */ FUNC_SET_SCREEN,
   /* SetFailsafe */ FUNC_SET_FAILSAFE,
+  /* Set Main Screen */ FUNC_SET_SCREEN,
   /* Test */ FUNC_TEST,
   /* Trainer */ FUNC_TRAINER,
   /* Vario */ FUNC_VARIO,

@philmoz
Copy link
Collaborator Author

philmoz commented Aug 15, 2024

I changed the enum to not have conditional elements otherwise the sorted list got messier.
They are filtered out at runtime by isAssignableFunctionAvailable.

I could not find a way to do case insensitive sorting with collate - I would prefer to have it sorted case insensitive.
Feel free to update the PR with your version.
The issue as you pointed out is it's hard to know if it's correct for some of the languages. We will need to ask the translators to check the lists.

This line in cfn_sort.cpp throws a warning about extra content after the #else.

#else defined(TRANSLATIONS_EN)

@pfeerick
Copy link
Member

Ok, that should be gone now... I'll done for now ;) the pragma fix is in main if you want to rebase again ;)

dammit! Spotted one mistake, but I am officially off the clock now. 😆 TR_BRIGHTNESS and TR_SF_BACKLIGHT are exactly the same for RU... thus there is a double #if defined(OLED_SCREEN) - the ! side is missing 😮

@pfeerick pfeerick self-requested a review August 18, 2024 10:31
Copy link
Member

@pfeerick pfeerick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is working perfectly on EN for T12MAX, TLite, X9D+ and TX16S.

A secondary consideration may be that we need to change the "default" special function that is used / started with... as Override is in the middle of the list. The same argument can also used for the MPM protocols list also - i.e. "Why does it default to Flysky, when A is before F?" 🤭

Regarding the translated lists needing review by native language speakers, I need to do a translation catchup soon, so will ask for that there, thus anyone that wants do do a custom language nightly can try this out in the meantime.

@pfeerick pfeerick changed the title feat(radio): sort global/special function names. feat(radio): sort global/special function names Aug 23, 2024
@pfeerick pfeerick merged commit e0a3097 into main Aug 23, 2024
47 checks passed
@pfeerick pfeerick deleted the philmoz/cfn-sort branch August 23, 2024 01:57
@3djc
Copy link
Collaborator

3djc commented Aug 30, 2024

Sidenote: this does not work under linux recommended build (ubuntu). Was able to run it on macosx tho

@pfeerick
Copy link
Member

What doesn't work? As I use Linux (etx devcontainer) and fixed some of this to actually work with it 🤣

@3djc
Copy link
Collaborator

3djc commented Aug 30, 2024

It missed a <string.h> include, and generate

image

@pfeerick
Copy link
Member

You probably don't have the locales installed.

@pfeerick
Copy link
Member

pfeerick commented Aug 30, 2024

i.e. you need to enable them all

# Required locales (check your system and install if needed):

# zh_CN.UTF-8 / zh_CN.utf8
# cs_CZ.UTF-8 / cs_CZ.utf8
# da_DK.UTF-8 / da_DK.utf8
# de_DE.UTF-8 / de_DE.utf8
# es_ES.UTF-8 / es_ES.utf8
# en_US.UTF-8 / en_US.utf8
# fi_FI.UTF-8 / fi_FI.utf8
# fr_FR.UTF-8 / fr_FR.utf8
# he_IL.UTF-8 / he_IL.utf8
# it_IT.UTF-8 / it_IT.utf8
# ja_JP.UTF-8 / ja_JP.utf8
# nl_NL.UTF-8 / nl_NL.utf8
# pl_PL.UTF-8 / pl_PL.utf8
# pt_PT.UTF-8 / pt_PT.utf8
# ru_RU.UTF-8 / ru_RU.utf8
# sv_SE.UTF-8 / sv_SE.utf8
# zh_TW.UTF-8 / zh_TW.utf8
# uk_UA.UTF-8 / uk_UA.utf8

and then run locale-gen to generate them...

@3djc
Copy link
Collaborator

3djc commented Aug 30, 2024

I guess I'll keep doing it on the Macbook :D

@pfeerick
Copy link
Member

pfeerick commented Aug 30, 2024

I'll add a note to run this for Linux if you don't have all the locales installed already.

apt update
apt install locales
locale-gen zh_CN.UTF-8 cs_CZ.UTF-8 da_DK.UTF-8 de_DE.UTF-8 es_ES.UTF-8 en_US.UTF-8 fi_FI.UTF-8 fr_FR.UTF-8 he_IL.UTF-8 it_IT.UTF-8 ja_JP.UTF-8 nl_NL.UTF-8 pl_PL.UTF-8 pt_PT.UTF-8 ru_RU.UTF-8 sv_SE.UTF-8 zh_TW.UTF-8 uk_UA.UTF-8

@pfeerick
Copy link
Member

Does this work for you on Mac also with string.h added? As Phil added the strcmp check after I last ran this, so I didn't realise it broke on Linux side...

@3djc
Copy link
Collaborator

3djc commented Aug 30, 2024

Yeah, adding string.h doesn't disturb the Mac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

List special functions / global functions alphabetically
4 participants