language.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. #if (LANG_MODE == 0)
  18. //#define _i PSTR
  19. //#define _I(s) (__extension__({static const char __c[] __attribute__((section("Txt_i"))) = s; &__c[0];}))
  20. #endif //(LANG_MODE == 0)
  21. //section progmem0 will be used for localized translated strings
  22. #define PROGMEM_I2 __attribute__((section(".progmem0")))
  23. //section progmem1 will be used for localized strings in english
  24. #define PROGMEM_I1 __attribute__((section(".progmem1")))
  25. //section progmem2 will be used for not localized strings in english
  26. #define PROGMEM_N1 __attribute__((section(".progmem2")))
  27. #if (LANG_MODE == 0) //primary language only
  28. #define _I(s) (__extension__({static const char __c[] PROGMEM_I1 = s; &__c[0];}))
  29. #define ISTR(s) s
  30. #define _i(s) _I(s)
  31. #define _T(s) s
  32. #else //(LANG_MODE == 0)
  33. #define _I(s) (__extension__({static const char __c[] PROGMEM_I1 = "\xff\xff"s; &__c[0];}))
  34. #define ISTR(s) "\xff\xff"s
  35. #define _i(s) lang_get_translation(_I(s))
  36. #define _T(s) lang_get_translation(s)
  37. #endif //(LANG_MODE == 0)
  38. #define _N(s) (__extension__({static const char __c[] PROGMEM_N1 = s; &__c[0];}))
  39. #define _n(s) _N(s)
  40. // Language indices into their particular symbol tables.
  41. #define LANG_ID_EN 0
  42. #define LANG_ID_CZ 1
  43. // Language is not defined and it shall be selected from the menu.
  44. #define LANG_ID_FORCE_SELECTION 254
  45. // Language is not defined on a virgin RAMBo board.
  46. #define LANG_ID_UNDEFINED 255
  47. // Default language ID, if no language is selected.
  48. #define LANG_ID_DEFAULT LANG_ID_CZ
  49. // Number of languages available in the language table.
  50. #define LANG_NUM 2
  51. #if defined(__cplusplus)
  52. extern "C" {
  53. #endif //defined(__cplusplus)
  54. // Currectly active language selection.
  55. extern unsigned char lang_selected;
  56. extern const char* lang_get_translation(const char* s);
  57. extern const char* lang_select(unsigned char lang);
  58. #if defined(__cplusplus)
  59. }
  60. #endif //defined(__cplusplus)
  61. #define CAT2(_s1, _s2) _s1
  62. #define CAT4(_s1, _s2, _s3, _s4) _s1
  63. #define MSG_LANGUAGE_NAME_EXPLICIT(i) ((i==0)?PSTR("ENG"):PSTR("CZE"))
  64. #include "messages.h"
  65. #endif //__LANGUAGE_H