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-07 22:20:28 +00:00
|
|
|
#define W25X20CL
|
|
|
|
|
2018-05-22 01:20:03 +00:00
|
|
|
#include "config.h"
|
2018-05-30 17:29:52 +00:00
|
|
|
#include <inttypes.h>
|
2018-06-07 22:20:28 +00:00
|
|
|
//#include <stdio.h>
|
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
|
|
|
|
|
|
|
|
#define MSG_FW_VERSION "Firmware"
|
|
|
|
|
|
|
|
#define STRINGIFY_(n) #n
|
|
|
|
#define STRINGIFY(n) STRINGIFY_(n)
|
|
|
|
|
2018-05-22 01:20:03 +00:00
|
|
|
//section progmem0 will be used for localized translated strings
|
|
|
|
#define PROGMEM_I2 __attribute__((section(".progmem0")))
|
|
|
|
//section progmem1 will be used for localized strings in english
|
|
|
|
#define PROGMEM_I1 __attribute__((section(".progmem1")))
|
|
|
|
//section progmem2 will be used for not localized strings in english
|
|
|
|
#define PROGMEM_N1 __attribute__((section(".progmem2")))
|
|
|
|
|
|
|
|
#if (LANG_MODE == 0) //primary language only
|
|
|
|
#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-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-06-07 22:20:28 +00:00
|
|
|
//lang_table_header_t structure - (size= 16byte)
|
|
|
|
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;
|
|
|
|
|
|
|
|
//lang_table_t structure - (size= 16byte + 2*count)
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
lang_table_header_t header;
|
|
|
|
uint16_t table[];
|
|
|
|
} lang_table_t;
|
2018-05-22 01:20:03 +00:00
|
|
|
|
|
|
|
// 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-05-22 01:20:03 +00:00
|
|
|
// Language is not defined and it shall be selected from the menu.
|
|
|
|
#define LANG_ID_FORCE_SELECTION 254
|
2018-06-01 08:47:47 +00:00
|
|
|
|
2018-05-22 01:20:03 +00:00
|
|
|
// Language is not defined on a virgin RAMBo board.
|
|
|
|
#define LANG_ID_UNDEFINED 255
|
2016-07-22 13:28:01 +00:00
|
|
|
|
2018-05-22 01:20:03 +00:00
|
|
|
// 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-06-01 08:47:47 +00:00
|
|
|
// Magic number at begin of lang table.
|
|
|
|
#define LANG_MAGIC 0x4bb45aa5
|
|
|
|
|
|
|
|
// 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'
|
|
|
|
#define LANG_CODE_IT 0x6974 //'it'
|
|
|
|
#define LANG_CODE_PL 0x706c //'pl'
|
2016-07-22 13:28:01 +00:00
|
|
|
|
2018-05-22 01:20:03 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif //defined(__cplusplus)
|
|
|
|
|
|
|
|
// 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-06-09 16:26:53 +00:00
|
|
|
#define _SEC_LANG_TABLE ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00)
|
2018-06-15 18:37:33 +00:00
|
|
|
//extern const uint32_t _PRI_LANG_SIGNATURE;
|
2018-06-07 22:20:28 +00:00
|
|
|
#endif //(LANG_MODE != 0)
|
|
|
|
|
2018-06-10 14:04:32 +00:00
|
|
|
//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-06-15 18:37:33 +00:00
|
|
|
//performs checksum test of secondary language data
|
|
|
|
extern uint8_t lang_check(uint16_t addr);
|
2018-06-10 14:04:32 +00:00
|
|
|
//returns total number of languages (primary + all in xflash)
|
|
|
|
extern uint8_t lang_get_count(void);
|
|
|
|
//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-06-10 14:04:32 +00:00
|
|
|
//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-06-10 14:04:32 +00:00
|
|
|
//returns 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-06-10 14:04:32 +00:00
|
|
|
//reset language to "LANG_ID_FORCE_SELECTION", epprom is updated
|
|
|
|
extern void lang_reset(void);
|
|
|
|
//returns 1 if language is selected
|
|
|
|
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
|
|
|
|