Fix doc path
[opentx.git] / radio / src / stamp.cpp
blob4cc672c88e7caf0881cf7eb4e73ef90c45c32e4c
1 /*
2 * Copyright (C) OpenTX
4 * Based on code named
5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
21 #include "opentx.h"
22 #include "stamp.h"
24 #define STR2(s) #s
25 #define DEFNUMSTR(s) STR2(s)
27 #if defined(PCBSTD)
28 #define EEPROM_STR DEFNUMSTR(EEPROM_VER) "-" DEFNUMSTR(EEPROM_VARIANT)
29 #else
30 #define EEPROM_STR DEFNUMSTR(EEPROM_VER);
31 #endif
33 #if defined(PCBHORUS)
34 #define TAB "\037\075"
35 #endif
37 #if defined(COLORLCD)
38 const pm_char vers_stamp[] PROGMEM = "VERS" TAB ": " "opentx-" FLAVOUR "-" VERSION " (" GIT_STR ")";
39 const pm_char date_stamp[] PROGMEM = "DATE" TAB ": " DATE;
40 const pm_char time_stamp[] PROGMEM = "TIME" TAB ": " TIME;
41 const pm_char eeprom_stamp[] PROGMEM = "EEPR" TAB ": " EEPROM_STR;
42 #elif defined(PCBTARANIS)
43 const pm_char vers_stamp[] PROGMEM = "FW\037\033: " "opentx-" FLAVOUR "\036VERS\037\033: " VERSION " (" GIT_STR ")" "\036DATE\037\033: " DATE " " TIME "\036EEPR\037\033: " EEPROM_STR;
44 #else
45 const pm_char vers_stamp[] PROGMEM = "FW\037\033: " "opentx-" FLAVOUR "\036VERS\037\033: " VERSION "\036DATE\037\033: " DATE "\036TIME\037\033: " TIME "\036EEPR\037\033: " EEPROM_STR;
46 #endif
48 /**
49 * Retrieves the version of the bootloader or firmware
50 * @return
52 #if defined(STM32)
54 __SECTION_USED(".fwversiondata") const char firmware_version[] = "opentx-" FLAVOUR "-" VERSION " (" GIT_STR ")";
55 __SECTION_USED(".bootversiondata") const char boot_version[] = "opentx-" FLAVOUR "-" VERSION " (" GIT_STR ")";
57 /**
58 * Tries to find opentx version in the first 1024 byte of either firmware/bootloader (the one not running) or the buffer
59 * @param buffer If non-null find the firmware version in the buffer instead
61 const char* getOtherVersion(char* buffer)
63 #if defined(BOOT)
64 const char* startother = (char*)(FIRMWARE_ADDRESS+BOOTLOADER_SIZE);
65 #else
66 const char* startother = (char*)(FIRMWARE_ADDRESS);
67 #endif
68 if (buffer != nullptr)
69 startother=buffer;
71 const char* other_str = nullptr;
72 for (int i=0; i< 1024;i++) {
73 if (memcmp(startother+i, "opentx-", 7)==0) {
74 other_str = startother + i;
75 break;
78 if (other_str != nullptr)
79 return other_str;
80 else
81 return "no version found";
83 #endif