2018-07-23 11:35:38 +00:00
|
|
|
/** @file */
|
2018-05-22 01:20:03 +00:00
|
|
|
//language.h
|
2016-07-22 13:28:01 +00:00
|
|
|
#ifndef LANGUAGE_H
|
|
|
|
#define LANGUAGE_H
|
|
|
|
|
2018-06-21 17:58:13 +00:00
|
|
|
|
2018-05-22 01:20:03 +00:00
|
|
|
#include "config.h"
|
2020-09-11 13:12:49 +00:00
|
|
|
#include "macros.h"
|
2018-05-30 17:29:52 +00:00
|
|
|
#include <inttypes.h>
|
2020-01-31 13:47:44 +00:00
|
|
|
#ifdef DEBUG_SEC_LANG
|
|
|
|
#include <stdio.h>
|
|
|
|
#endif //DEBUG_SEC_LANG
|
2018-05-22 01:20:03 +00:00
|
|
|
|
2016-07-22 13:28:01 +00:00
|
|
|
#define PROTOCOL_VERSION "1.0"
|
|
|
|
|
2018-06-07 22:20:28 +00:00
|
|
|
#ifndef CUSTOM_MENDEL_NAME
|
2016-07-22 13:28:01 +00:00
|
|
|
#define MACHINE_NAME "Mendel"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef MACHINE_UUID
|
|
|
|
#define MACHINE_UUID "00000000-0000-0000-0000-000000000000"
|
|
|
|
#endif
|
|
|
|
|
2018-05-22 01:20:03 +00:00
|
|
|
#if (LANG_MODE == 0) //primary language only
|
2018-10-23 15:32:52 +00:00
|
|
|
#define PROGMEM_I2 __attribute__((section(".progmem0")))
|
|
|
|
#define PROGMEM_I1 __attribute__((section(".progmem1")))
|
|
|
|
#define PROGMEM_N1 __attribute__((section(".progmem2")))
|
2018-05-22 01:20:03 +00:00
|
|
|
#define _I(s) (__extension__({static const char __c[] PROGMEM_I1 = s; &__c[0];}))
|
|
|
|
#define ISTR(s) s
|
|
|
|
#define _i(s) _I(s)
|
|
|
|
#define _T(s) s
|
|
|
|
#else //(LANG_MODE == 0)
|
2018-10-23 15:32:52 +00:00
|
|
|
// section .loc_sec (originaly .progmem0) will be used for localized translated strings
|
|
|
|
#define PROGMEM_I2 __attribute__((section(".loc_sec")))
|
|
|
|
// section .loc_pri (originaly .progmem1) will be used for localized strings in english
|
|
|
|
#define PROGMEM_I1 __attribute__((section(".loc_pri")))
|
|
|
|
// section .noloc (originaly progmem2) will be used for not localized strings in english
|
|
|
|
#define PROGMEM_N1 __attribute__((section(".noloc")))
|
2018-05-30 13:07:24 +00:00
|
|
|
#define _I(s) (__extension__({static const char __c[] PROGMEM_I1 = "\xff\xff" s; &__c[0];}))
|
2018-05-30 12:53:14 +00:00
|
|
|
#define ISTR(s) "\xff\xff" s
|
2018-05-22 01:20:03 +00:00
|
|
|
#define _i(s) lang_get_translation(_I(s))
|
|
|
|
#define _T(s) lang_get_translation(s)
|
|
|
|
#endif //(LANG_MODE == 0)
|
|
|
|
#define _N(s) (__extension__({static const char __c[] PROGMEM_N1 = s; &__c[0];}))
|
|
|
|
#define _n(s) _N(s)
|
|
|
|
|
2018-07-23 11:35:38 +00:00
|
|
|
/** @brief lang_table_header_t structure - (size= 16byte) */
|
2018-06-07 22:20:28 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
uint32_t magic; //+0
|
|
|
|
uint16_t size; //+4
|
|
|
|
uint16_t count; //+6
|
|
|
|
uint16_t checksum; //+8
|
|
|
|
uint16_t code; //+10
|
2018-06-15 18:37:33 +00:00
|
|
|
uint32_t signature; //+12
|
2018-06-07 22:20:28 +00:00
|
|
|
} lang_table_header_t;
|
|
|
|
|
2018-07-23 11:35:38 +00:00
|
|
|
/** @brief lang_table_t structure - (size= 16byte + 2*count) */
|
2018-06-07 22:20:28 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
lang_table_header_t header;
|
|
|
|
uint16_t table[];
|
|
|
|
} lang_table_t;
|
2018-05-22 01:20:03 +00:00
|
|
|
|
2018-07-23 11:35:38 +00:00
|
|
|
/** @name Language indices into their particular symbol tables.*/
|
|
|
|
///@{
|
2018-05-28 15:14:55 +00:00
|
|
|
#define LANG_ID_PRI 0
|
|
|
|
#define LANG_ID_SEC 1
|
2018-07-23 11:35:38 +00:00
|
|
|
///@}
|
2018-05-28 15:14:55 +00:00
|
|
|
|
2018-07-23 11:35:38 +00:00
|
|
|
/** @def LANG_ID_FORCE_SELECTION
|
|
|
|
* @brief Language is not defined and it shall be selected from the menu.*/
|
2018-05-22 01:20:03 +00:00
|
|
|
#define LANG_ID_FORCE_SELECTION 254
|
2018-06-01 08:47:47 +00:00
|
|
|
|
2018-07-23 11:35:38 +00:00
|
|
|
/** @def LANG_ID_UNDEFINED
|
|
|
|
* @brief Language is not defined on a virgin RAMBo board. */
|
2018-05-22 01:20:03 +00:00
|
|
|
#define LANG_ID_UNDEFINED 255
|
2016-07-22 13:28:01 +00:00
|
|
|
|
2018-07-23 11:35:38 +00:00
|
|
|
/** @def LANG_ID_DEFAULT
|
|
|
|
* @brief Default language ID, if no language is selected. */
|
2018-05-28 15:14:55 +00:00
|
|
|
#define LANG_ID_DEFAULT LANG_ID_PRI
|
2016-07-22 13:28:01 +00:00
|
|
|
|
2018-07-23 11:35:38 +00:00
|
|
|
/** @def LANG_MAGIC
|
|
|
|
* @brief Magic number at begin of lang table. */
|
2018-06-01 08:47:47 +00:00
|
|
|
#define LANG_MAGIC 0x4bb45aa5
|
|
|
|
|
2018-07-23 11:35:38 +00:00
|
|
|
/** @name Language codes (ISO639-1)*/
|
|
|
|
///@{
|
|
|
|
#define LANG_CODE_XX 0x3f3f //!<'??'
|
|
|
|
#define LANG_CODE_EN 0x656e //!<'en'
|
|
|
|
#define LANG_CODE_CZ 0x6373 //!<'cs'
|
|
|
|
#define LANG_CODE_DE 0x6465 //!<'de'
|
|
|
|
#define LANG_CODE_ES 0x6573 //!<'es'
|
2018-10-25 16:16:36 +00:00
|
|
|
#define LANG_CODE_FR 0x6672 //!<'fr'
|
2018-07-23 11:35:38 +00:00
|
|
|
#define LANG_CODE_IT 0x6974 //!<'it'
|
|
|
|
#define LANG_CODE_PL 0x706c //!<'pl'
|
2021-12-20 16:32:35 +00:00
|
|
|
#ifdef COMMUNITY_LANGUAGE_SUPPORT //Community language support
|
|
|
|
#ifdef COMMUNITY_LANG_GROUP1_NL
|
2021-03-01 07:22:43 +00:00
|
|
|
#define LANG_CODE_NL 0x6e6c //!<'nl'
|
2021-12-20 16:32:35 +00:00
|
|
|
#endif // COMMUNITY_LANG_GROUP1_NL
|
2021-12-21 13:33:35 +00:00
|
|
|
#ifdef COMMUNITY_LANG_GROUP1_SV
|
|
|
|
#define LANG_CODE_SV 0x7376 //!<'sv'
|
|
|
|
#endif // COMMUNITY_LANG_GROUP1_SV
|
2021-12-21 14:15:23 +00:00
|
|
|
#ifdef COMMUNITY_LANG_GROUP1_DA
|
|
|
|
#define LANG_CODE_DA 0x6461 //!<'da'
|
|
|
|
#endif // COMMUNITY_LANG_GROUP1_DA
|
2021-12-21 14:24:06 +00:00
|
|
|
#ifdef COMMUNITY_LANG_GROUP1_SL
|
|
|
|
#define LANG_CODE_SL 0x736C //!<'sl'
|
|
|
|
#endif // COMMUNITY_LANG_GROUP1_SL
|
2021-12-21 14:28:33 +00:00
|
|
|
#ifdef COMMUNITY_LANG_GROUP1_HU
|
|
|
|
#define LANG_CODE_HU 0x6875 //!<'hu'
|
|
|
|
#endif // COMMUNITY_LANG_GROUP1_HU
|
2021-12-21 14:32:54 +00:00
|
|
|
#ifdef COMMUNITY_LANG_GROUP1_LB
|
|
|
|
#define LANG_CODE_LB 0x6C62 //!<'lb'
|
|
|
|
#endif // COMMUNITY_LANG_GROUP1_LB
|
2021-12-21 14:36:34 +00:00
|
|
|
#ifdef COMMUNITY_LANG_GROUP1_HR
|
|
|
|
#define LANG_CODE_HR 0x6872 //!<'hr'
|
|
|
|
#endif // COMMUNITY_LANG_GROUP1_HR
|
2022-01-03 14:00:45 +00:00
|
|
|
#ifdef COMMUNITY_LANG_GROUP1_LT
|
|
|
|
#define LANG_CODE_LT 0x6C74 //!<'lt'
|
|
|
|
#endif // COMMUNITY_LANG_GROUP1_LT
|
2022-02-10 18:01:04 +00:00
|
|
|
#ifdef COMMUNITY_LANG_GROUP1_SK
|
|
|
|
#define LANG_CODE_SK 0x736b //!<'sk'
|
|
|
|
#endif // COMMUNITY_LANG_GROUP1_SK
|
2022-01-12 09:09:01 +00:00
|
|
|
#ifdef COMMUNITY_LANG_GROUP1_RO
|
|
|
|
#define LANG_CODE_RO 0x726F //!<'ro'
|
|
|
|
#endif // COMMUNITY_LANG_GROUP1_RO
|
2021-03-01 07:22:43 +00:00
|
|
|
//Use the 3 lines below as a template and replace 'QR', '0X7172' and 'qr'
|
2021-12-20 16:32:35 +00:00
|
|
|
//#ifdef COMMUNITY_LANG_GROUP1_QR
|
2021-03-01 07:22:43 +00:00
|
|
|
//#define LANG_CODE_QR 0x7172 //!<'qr'
|
2021-12-20 16:32:35 +00:00
|
|
|
//#endif // COMMUNITY_LANG_GROUP1_QR
|
|
|
|
#endif // COMMUNITY_LANGUAGE_SUPPORT
|
2018-07-23 11:35:38 +00:00
|
|
|
///@}
|
2016-07-22 13:28:01 +00:00
|
|
|
|
2018-05-22 01:20:03 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif //defined(__cplusplus)
|
|
|
|
|
2018-07-23 11:35:38 +00:00
|
|
|
/** @brief Currectly active language selection.*/
|
2018-05-30 17:29:52 +00:00
|
|
|
extern uint8_t lang_selected;
|
2018-05-22 01:20:03 +00:00
|
|
|
|
2018-05-23 13:46:08 +00:00
|
|
|
#if (LANG_MODE != 0)
|
|
|
|
extern const char _SEC_LANG[LANG_SIZE_RESERVED];
|
2018-05-22 01:20:03 +00:00
|
|
|
extern const char* lang_get_translation(const char* s);
|
2018-07-23 11:35:38 +00:00
|
|
|
/** @def _SEC_LANG_TABLE
|
|
|
|
* @brief Align table to start of 256 byte page */
|
2018-06-09 16:26:53 +00:00
|
|
|
#define _SEC_LANG_TABLE ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00)
|
2018-06-07 22:20:28 +00:00
|
|
|
#endif //(LANG_MODE != 0)
|
|
|
|
|
2018-07-23 11:35:38 +00:00
|
|
|
/** @brief selects language, eeprom is updated in case of success */
|
2018-06-07 22:20:28 +00:00
|
|
|
extern uint8_t lang_select(uint8_t lang);
|
2018-07-23 11:35:38 +00:00
|
|
|
/** @brief performs checksum test of secondary language data */
|
2018-06-15 18:37:33 +00:00
|
|
|
extern uint8_t lang_check(uint16_t addr);
|
2018-07-23 11:35:38 +00:00
|
|
|
/** @return total number of languages (primary + all in xflash) */
|
2018-06-10 14:04:32 +00:00
|
|
|
extern uint8_t lang_get_count(void);
|
2018-07-23 11:35:38 +00:00
|
|
|
/** @brief reads lang table header and offset in xflash or progmem */
|
2018-06-08 23:23:04 +00:00
|
|
|
extern uint8_t lang_get_header(uint8_t lang, lang_table_header_t* header, uint32_t* offset);
|
2018-07-23 11:35:38 +00:00
|
|
|
/** @brief reads lang code from xflash or progmem */
|
2018-06-01 08:47:47 +00:00
|
|
|
extern uint16_t lang_get_code(uint8_t lang);
|
2018-07-23 11:35:38 +00:00
|
|
|
/** @return localized language name (text for menu item) */
|
2018-06-07 22:20:28 +00:00
|
|
|
extern const char* lang_get_name_by_code(uint16_t code);
|
2018-07-23 11:35:38 +00:00
|
|
|
/** @brief reset language to "LANG_ID_FORCE_SELECTION", epprom is updated */
|
2018-06-10 14:04:32 +00:00
|
|
|
extern void lang_reset(void);
|
2018-07-23 11:35:38 +00:00
|
|
|
/** @retval 1 language is selected */
|
2018-06-10 14:04:32 +00:00
|
|
|
extern uint8_t lang_is_selected(void);
|
2018-05-30 18:15:43 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG_SEC_LANG
|
2018-06-07 22:20:28 +00:00
|
|
|
extern const char* lang_get_sec_lang_str_by_id(uint16_t id);
|
2018-05-30 17:29:52 +00:00
|
|
|
extern uint16_t lang_print_sec_lang(FILE* out);
|
2018-05-30 18:15:43 +00:00
|
|
|
#endif //DEBUG_SEC_LANG
|
2018-05-22 01:20:03 +00:00
|
|
|
|
2018-06-09 22:22:28 +00:00
|
|
|
extern void lang_boot_update_start(uint8_t lang);
|
2018-06-09 17:16:36 +00:00
|
|
|
|
2018-05-22 01:20:03 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif //defined(__cplusplus)
|
|
|
|
|
|
|
|
#define CAT2(_s1, _s2) _s1
|
|
|
|
#define CAT4(_s1, _s2, _s3, _s4) _s1
|
2018-05-28 15:14:55 +00:00
|
|
|
|
2018-05-22 01:20:03 +00:00
|
|
|
#include "messages.h"
|
2016-07-22 13:28:01 +00:00
|
|
|
|
2018-05-28 15:14:55 +00:00
|
|
|
|
2018-05-29 19:03:47 +00:00
|
|
|
#endif //LANGUAGE_H
|
2018-05-22 01:20:03 +00:00
|
|
|
|