My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

multi_language.h 3.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /********************
  2. * multi_language.h *
  3. ********************/
  4. /****************************************************************************
  5. * Written By Marcio Teixeira 2019 - Aleph Objects, Inc. *
  6. * *
  7. * This program is free software: you can redistribute it and/or modify *
  8. * it under the terms of the GNU General Public License as published by *
  9. * the Free Software Foundation, either version 3 of the License, or *
  10. * (at your option) any later version. *
  11. * *
  12. * This program is distributed in the hope that it will be useful, *
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  15. * GNU General Public License for more details. *
  16. * *
  17. * To view a copy of the GNU General Public License, go to the following *
  18. * location: <https://www.gnu.org/licenses/>. *
  19. ****************************************************************************/
  20. #pragma once
  21. #include "../inc/MarlinConfigPre.h"
  22. typedef const char Language_Str[];
  23. #ifdef LCD_LANGUAGE_5
  24. #define NUM_LANGUAGES 5
  25. #elif defined(LCD_LANGUAGE_4)
  26. #define NUM_LANGUAGES 4
  27. #elif defined(LCD_LANGUAGE_3)
  28. #define NUM_LANGUAGES 3
  29. #elif defined(LCD_LANGUAGE_2)
  30. #define NUM_LANGUAGES 2
  31. #else
  32. #define NUM_LANGUAGES 1
  33. #endif
  34. // Set unused languages equal to each other so the
  35. // compiler can optimize away the conditionals.
  36. #ifndef LCD_LANGUAGE_2
  37. #define LCD_LANGUAGE_2 LCD_LANGUAGE
  38. #endif
  39. #ifndef LCD_LANGUAGE_3
  40. #define LCD_LANGUAGE_3 LCD_LANGUAGE_2
  41. #endif
  42. #ifndef LCD_LANGUAGE_4
  43. #define LCD_LANGUAGE_4 LCD_LANGUAGE_3
  44. #endif
  45. #ifndef LCD_LANGUAGE_5
  46. #define LCD_LANGUAGE_5 LCD_LANGUAGE_4
  47. #endif
  48. #define _GET_LANG(LANG) Language_##LANG
  49. #define GET_LANG(LANG) _GET_LANG(LANG)
  50. #if NUM_LANGUAGES > 1
  51. #define HAS_MULTI_LANGUAGE 1
  52. #define GET_TEXT(MSG) ( \
  53. ui.language == 4 ? GET_LANG(LCD_LANGUAGE_5)::MSG : \
  54. ui.language == 3 ? GET_LANG(LCD_LANGUAGE_4)::MSG : \
  55. ui.language == 2 ? GET_LANG(LCD_LANGUAGE_3)::MSG : \
  56. ui.language == 1 ? GET_LANG(LCD_LANGUAGE_2)::MSG : \
  57. GET_LANG(LCD_LANGUAGE )::MSG )
  58. #define MAX_LANG_CHARSIZE _MAX(GET_LANG(LCD_LANGUAGE )::CHARSIZE, \
  59. GET_LANG(LCD_LANGUAGE_2)::CHARSIZE, \
  60. GET_LANG(LCD_LANGUAGE_3)::CHARSIZE, \
  61. GET_LANG(LCD_LANGUAGE_4)::CHARSIZE, \
  62. GET_LANG(LCD_LANGUAGE_5)::CHARSIZE )
  63. #else
  64. #define GET_TEXT(MSG) GET_LANG(LCD_LANGUAGE)::MSG
  65. #define MAX_LANG_CHARSIZE LANG_CHARSIZE
  66. #endif
  67. #define GET_TEXT_F(MSG) (const __FlashStringHelper*)GET_TEXT(MSG)
  68. #define GET_LANGUAGE_NAME(INDEX) GET_LANG(LCD_LANGUAGE_##INDEX)::LANGUAGE
  69. #define LANG_CHARSIZE GET_TEXT(CHARSIZE)
  70. #define USE_WIDE_GLYPH (LANG_CHARSIZE > 2)
  71. #define MSG_1_LINE(A) A "\0" "\0"
  72. #define MSG_2_LINE(A,B) A "\0" B "\0"
  73. #define MSG_3_LINE(A,B,C) A "\0" B "\0" C