diff --git a/radio/src/storage/conversions/yaml/dataconstants_220.h b/radio/src/storage/conversions/yaml/dataconstants_220.h index a627c1186..9b41f3d42 100644 --- a/radio/src/storage/conversions/yaml/dataconstants_220.h +++ b/radio/src/storage/conversions/yaml/dataconstants_220.h @@ -19,8 +19,9 @@ * GNU General Public License for more details. */ -#ifndef _DATACONSTANTS_H_ -#define _DATACONSTANTS_H_ +#if defined(_DATACONSTANTS_H_) +#error "This file MUST NOT be included side-by-side with dataconstants.h" +#endif #include #include @@ -1046,5 +1047,3 @@ enum CalibrationState { CALIB_STORE, CALIB_FINISHED }; - -#endif // _DATACONSTANTS_H_ diff --git a/radio/src/storage/conversions/yaml/datastructs_220.h b/radio/src/storage/conversions/yaml/datastructs_220.h index 4b92466a9..2e5392317 100644 --- a/radio/src/storage/conversions/yaml/datastructs_220.h +++ b/radio/src/storage/conversions/yaml/datastructs_220.h @@ -19,9 +19,6 @@ * GNU General Public License for more details. */ -// No include guards here, this file may be included many times in different namespaces -// i.e. BACKUP RAM Backup/Restore functions - #pragma once #include diff --git a/radio/src/storage/conversions/yaml/myeeprom_220.h b/radio/src/storage/conversions/yaml/myeeprom_220.h index eb185d963..f8b780537 100644 --- a/radio/src/storage/conversions/yaml/myeeprom_220.h +++ b/radio/src/storage/conversions/yaml/myeeprom_220.h @@ -19,11 +19,10 @@ * GNU General Public License for more details. */ -#ifndef _MYEEPROM_H_ -#define _MYEEPROM_H_ +#if defined(_MYEEPROM_H_) +#error "This file MUST NOT be included side-by-side with myeeprom.h" +#endif -// #include "datastructs.h" -// #include "libopenui/src/bitfield.h" #if defined(SDCARD_YAML) #define EEPROM_VER 221 @@ -278,5 +277,3 @@ PACK(union u_int8int16_t { constexpr uint8_t EE_GENERAL = 0x01; constexpr uint8_t EE_MODEL = 0x02; - -#endif // _MYEEPROM_H_ diff --git a/radio/src/storage/yaml/yaml_datastructs_funcs.cpp b/radio/src/storage/yaml/yaml_datastructs_funcs.cpp index 9cc1efda9..53babeed9 100644 --- a/radio/src/storage/yaml/yaml_datastructs_funcs.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_funcs.cpp @@ -24,7 +24,6 @@ #include "yaml_tree_walker.h" // Use definitions from v220 conversions as long as nothing changes -#include "../conversions/datastructs_220.h" namespace yaml_conv_220 { bool in_write_weight(const YamlNode* node, uint32_t val, yaml_writer_func wf, void* opaque); @@ -58,12 +57,28 @@ namespace yaml_conv_220 { yaml_writer_func wf, void* opaque); }; -static_assert(sizeof(CustomFunctionData) == sizeof(bin_storage_220::CustomFunctionData),""); -static_assert(sizeof(ModuleData) == sizeof(bin_storage_220::ModuleData),""); -static_assert(sizeof(FlightModeData) == sizeof(bin_storage_220::FlightModeData),""); - -#if !defined(COLORLCD) -static_assert(sizeof(TelemetryScreenData) == sizeof(bin_storage_220::TelemetryScreenData),""); +// +// WARNING: +// ======== +// +// If any of these static_assert() fails, you need to check that +// the functions bellow are still applicable. +// +// Please note that the sizes used here are those from the v220 format +// (see storage/conversions/yaml/datastructs_220.h) +// +static_assert(sizeof(ModuleData) == 29,""); +#if defined(PCBHORUS) || defined(PCBNV14) +static_assert(sizeof(FlightModeData) == 44, ""); +static_assert(sizeof(CustomFunctionData) == 9,""); +#elif defined(PCBX7) || defined(PCBXLITE) || defined(PCBX9LITE) +static_assert(sizeof(FlightModeData) == 36, ""); +static_assert(sizeof(CustomFunctionData) == 11,""); +static_assert(sizeof(TelemetryScreenData) == 24, ""); +#else +static_assert(sizeof(FlightModeData) == 40, ""); +static_assert(sizeof(CustomFunctionData) == 11,""); +static_assert(sizeof(TelemetryScreenData) == 24, ""); #endif #define GVAR_SMALL 128