Improve multi (#7136)
[opentx.git] / radio / src / stamp.cpp
blob842020a8cf0cdf11fb3dd0896a10b591562be77e
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 #define EEPROM_STR DEFNUMSTR(EEPROM_VER);
29 #if defined(PCBHORUS)
30 #define TAB "\037\075"
31 #else
32 #define TAB "\037\033"
33 #endif
35 #if defined(FRSKY_RELEASE)
36 #define DISPLAY_VERSION "FrSky"
37 #elif defined(JUMPER_RELEASE)
38 #define DISPLAY_VERSION "JumperRC"
39 #else
40 #define DISPLAY_VERSION VERSION
41 #endif
43 #if defined(COLORLCD)
44 const char vers_stamp[] = "VERS" TAB ": " "opentx-" FLAVOUR "-" DISPLAY_VERSION " (" GIT_STR ")";
45 const char date_stamp[] = "DATE" TAB ": " DATE;
46 const char time_stamp[] = "TIME" TAB ": " TIME;
47 const char eeprom_stamp[] = "EEPR" TAB ": " EEPROM_STR;
48 #elif defined(BOARD_NAME)
49 const char vers_stamp[] = "FW" TAB ": opentx-" BOARD_NAME "\036VERS" TAB ": " DISPLAY_VERSION " (" GIT_STR ")" "\036DATE" TAB ": " DATE " " TIME "\036EEPR" TAB ": " EEPROM_STR;
50 #else
51 const char vers_stamp[] = "FW" TAB ": opentx-" FLAVOUR "\036VERS" TAB ": " DISPLAY_VERSION " (" GIT_STR ")" "\036DATE" TAB ": " DATE " " TIME "\036EEPR" TAB ": " EEPROM_STR;
52 #endif
54 /**
55 * Retrieves the version of the bootloader or firmware
56 * @return
58 #if defined(STM32) && !defined(SIMU)
60 __SECTION_USED(".fwversiondata") const char firmware_version[] = "opentx-" FLAVOUR "-" DISPLAY_VERSION " (" GIT_STR ")";
61 __SECTION_USED(".bootversiondata") const char boot_version[] = "opentx-" FLAVOUR "-" DISPLAY_VERSION " (" GIT_STR ")";
63 /**
64 * Tries to find opentx version in the first 1024 byte of either firmware/bootloader (the one not running) or the buffer
65 * @param buffer If non-null find the firmware version in the buffer instead
67 const char * getOtherVersion(char* buffer)
69 #if defined(BOOT)
70 const char * startother = (char*)(FIRMWARE_ADDRESS+BOOTLOADER_SIZE);
71 #else
72 const char * startother = (char*)(FIRMWARE_ADDRESS);
73 #endif
74 if (buffer != nullptr)
75 startother = buffer;
77 const char * other_str = nullptr;
78 for (int i=0; i<1024;i++) {
79 if (memcmp(startother+i, "opentx-", 7) == 0) {
80 other_str = startother + i;
81 break;
85 if (other_str != nullptr)
86 return other_str;
87 else
88 return "no version found";
90 #endif