language.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. //language.h
  2. #ifndef LANGUAGE_H
  3. #define LANGUAGE_H
  4. #include "config.h"
  5. #include <inttypes.h>
  6. #include <stdio.h>
  7. #define PROTOCOL_VERSION "1.0"
  8. #ifdef CUSTOM_MENDEL_NAME
  9. // #define CUSTOM_MENDEL_NAME CUSTOM_MENDEL_NAME
  10. #else
  11. #define MACHINE_NAME "Mendel"
  12. #endif
  13. #ifndef MACHINE_UUID
  14. #define MACHINE_UUID "00000000-0000-0000-0000-000000000000"
  15. #endif
  16. #define MSG_FW_VERSION "Firmware"
  17. #define STRINGIFY_(n) #n
  18. #define STRINGIFY(n) STRINGIFY_(n)
  19. //section progmem0 will be used for localized translated strings
  20. #define PROGMEM_I2 __attribute__((section(".progmem0")))
  21. //section progmem1 will be used for localized strings in english
  22. #define PROGMEM_I1 __attribute__((section(".progmem1")))
  23. //section progmem2 will be used for not localized strings in english
  24. #define PROGMEM_N1 __attribute__((section(".progmem2")))
  25. #if (LANG_MODE == 0) //primary language only
  26. #define _I(s) (__extension__({static const char __c[] PROGMEM_I1 = s; &__c[0];}))
  27. #define ISTR(s) s
  28. #define _i(s) _I(s)
  29. #define _T(s) s
  30. #else //(LANG_MODE == 0)
  31. #define _I(s) (__extension__({static const char __c[] PROGMEM_I1 = "\xff\xff" s; &__c[0];}))
  32. #define ISTR(s) "\xff\xff" s
  33. #define _i(s) lang_get_translation(_I(s))
  34. #define _T(s) lang_get_translation(s)
  35. #endif //(LANG_MODE == 0)
  36. #define _N(s) (__extension__({static const char __c[] PROGMEM_N1 = s; &__c[0];}))
  37. #define _n(s) _N(s)
  38. // Language indices into their particular symbol tables.
  39. #define LANG_ID_PRI 0
  40. #define LANG_ID_SEC 1
  41. // Language is not defined and it shall be selected from the menu.
  42. #define LANG_ID_FORCE_SELECTION 254
  43. // Language is not defined on a virgin RAMBo board.
  44. #define LANG_ID_UNDEFINED 255
  45. // Default language ID, if no language is selected.
  46. #define LANG_ID_DEFAULT LANG_ID_PRI
  47. // Number of languages available in the language table.
  48. #define LANG_NUM 2
  49. // Magic number at begin of lang table.
  50. #define LANG_MAGIC 0x4bb45aa5
  51. // Language codes (ISO639-1)
  52. #define LANG_CODE_XX 0x3f3f //'??'
  53. #define LANG_CODE_EN 0x656e //'en'
  54. #define LANG_CODE_CZ 0x6373 //'cs'
  55. #define LANG_CODE_DE 0x6465 //'de'
  56. #define LANG_CODE_ES 0x6573 //'es'
  57. #define LANG_CODE_IT 0x6974 //'it'
  58. #define LANG_CODE_PL 0x706c //'pl'
  59. #if defined(__cplusplus)
  60. extern "C" {
  61. #endif //defined(__cplusplus)
  62. // Currectly active language selection.
  63. extern uint8_t lang_selected;
  64. #if (LANG_MODE != 0)
  65. extern const char _SEC_LANG[LANG_SIZE_RESERVED];
  66. #endif //(LANG_MODE == 0)
  67. extern const char* lang_get_translation(const char* s);
  68. extern const char* lang_get_sec_lang_str(const char* s);
  69. extern const char* lang_get_sec_lang_str_by_id(uint16_t id);
  70. extern const char* lang_select(uint8_t lang);
  71. extern uint8_t lang_get_count();
  72. extern const char* lang_get_name(uint8_t lang);
  73. extern uint16_t lang_get_code(uint8_t lang);
  74. #ifdef DEBUG_SEC_LANG
  75. extern uint16_t lang_print_sec_lang(FILE* out);
  76. #endif //DEBUG_SEC_LANG
  77. #if defined(__cplusplus)
  78. }
  79. #endif //defined(__cplusplus)
  80. #define CAT2(_s1, _s2) _s1
  81. #define CAT4(_s1, _s2, _s3, _s4) _s1
  82. extern const char MSG_LANGUAGE_NAME[];
  83. #include "messages.h"
  84. #endif //LANGUAGE_H