language.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. #if defined(__cplusplus)
  50. extern "C" {
  51. #endif //defined(__cplusplus)
  52. // Currectly active language selection.
  53. extern uint8_t lang_selected;
  54. #if (LANG_MODE != 0)
  55. extern const char _SEC_LANG[LANG_SIZE_RESERVED];
  56. #endif //(LANG_MODE == 0)
  57. extern const char* lang_get_translation(const char* s);
  58. extern const char* lang_get_sec_lang_str(const char* s);
  59. extern const char* lang_get_sec_lang_str_by_id(uint16_t id);
  60. extern const char* lang_select(uint8_t lang);
  61. extern uint8_t lang_get_count();
  62. extern const char* lang_get_name(uint8_t lang);
  63. #ifdef DEBUG_SEC_LANG
  64. extern uint16_t lang_print_sec_lang(FILE* out);
  65. #endif //DEBUG_SEC_LANG
  66. #if defined(__cplusplus)
  67. }
  68. #endif //defined(__cplusplus)
  69. #define CAT2(_s1, _s2) _s1
  70. #define CAT4(_s1, _s2, _s3, _s4) _s1
  71. extern const char MSG_LANGUAGE_NAME[];
  72. #include "messages.h"
  73. #endif //LANGUAGE_H