language.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //language.h
  2. #ifndef LANGUAGE_H
  3. #define LANGUAGE_H
  4. #include "config.h"
  5. #define PROTOCOL_VERSION "1.0"
  6. #ifdef CUSTOM_MENDEL_NAME
  7. // #define CUSTOM_MENDEL_NAME CUSTOM_MENDEL_NAME
  8. #else
  9. #define MACHINE_NAME "Mendel"
  10. #endif
  11. #ifndef MACHINE_UUID
  12. #define MACHINE_UUID "00000000-0000-0000-0000-000000000000"
  13. #endif
  14. #define MSG_FW_VERSION "Firmware"
  15. #define STRINGIFY_(n) #n
  16. #define STRINGIFY(n) STRINGIFY_(n)
  17. //section progmem0 will be used for localized translated strings
  18. #define PROGMEM_I2 __attribute__((section(".progmem0")))
  19. //section progmem1 will be used for localized strings in english
  20. #define PROGMEM_I1 __attribute__((section(".progmem1")))
  21. //section progmem2 will be used for not localized strings in english
  22. #define PROGMEM_N1 __attribute__((section(".progmem2")))
  23. #if (LANG_MODE == 0) //primary language only
  24. #define _I(s) (__extension__({static const char __c[] PROGMEM_I1 = s; &__c[0];}))
  25. #define ISTR(s) s
  26. #define _i(s) _I(s)
  27. #define _T(s) s
  28. #else //(LANG_MODE == 0)
  29. #define _I(s) (__extension__({static const char __c[] PROGMEM_I1 = "\xff\xff" s; &__c[0];}))
  30. #define ISTR(s) "\xff\xff" s
  31. #define _i(s) lang_get_translation(_I(s))
  32. #define _T(s) lang_get_translation(s)
  33. #endif //(LANG_MODE == 0)
  34. #define _N(s) (__extension__({static const char __c[] PROGMEM_N1 = s; &__c[0];}))
  35. #define _n(s) _N(s)
  36. // Language indices into their particular symbol tables.
  37. #define LANG_ID_PRI 0
  38. #define LANG_ID_SEC 1
  39. // Language is not defined and it shall be selected from the menu.
  40. #define LANG_ID_FORCE_SELECTION 254
  41. // Language is not defined on a virgin RAMBo board.
  42. #define LANG_ID_UNDEFINED 255
  43. // Default language ID, if no language is selected.
  44. #define LANG_ID_DEFAULT LANG_ID_PRI
  45. // Number of languages available in the language table.
  46. #define LANG_NUM 2
  47. #if defined(__cplusplus)
  48. extern "C" {
  49. #endif //defined(__cplusplus)
  50. // Currectly active language selection.
  51. extern unsigned char lang_selected;
  52. #if (LANG_MODE != 0)
  53. extern const char _SEC_LANG[LANG_SIZE_RESERVED];
  54. #endif //(LANG_MODE == 0)
  55. extern const char* lang_get_translation(const char* s);
  56. extern const char* lang_get_sec_lang_str(const char* s);
  57. extern const char* lang_select(unsigned char lang);
  58. extern unsigned char lang_get_count();
  59. extern const char* lang_get_name(unsigned char lang);
  60. #if defined(__cplusplus)
  61. }
  62. #endif //defined(__cplusplus)
  63. #define CAT2(_s1, _s2) _s1
  64. #define CAT4(_s1, _s2, _s3, _s4) _s1
  65. extern const char MSG_LANGUAGE_NAME[];
  66. #include "messages.h"
  67. #endif //LANGUAGE_H