mirror of
https://github.com/opentx/opentx.git
synced 2025-07-14 11:59:50 +03:00
Script for code generation for model/radio structure copy is now OK
This commit is contained in:
parent
e0544e2d1e
commit
8e2c280e4a
3 changed files with 11 additions and 4 deletions
|
@ -116,7 +116,7 @@ if(PCB STREQUAL HORUS)
|
||||||
)
|
)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT datacopy.cpp
|
OUTPUT datacopy.cpp
|
||||||
COMMAND python ${RADIO_DIRECTORY}/util/generate_datacopy.py ${RADIO_DIRECTORY}/src/datastructs.h -DPCBHORUS -DCPUARM -DCOLORLCD -DBACKUP > datacopy.cpp
|
COMMAND python ${RADIO_DIRECTORY}/util/generate_datacopy.py ${RADIO_DIRECTORY}/src/datastructs.h -DPCBHORUS -DCPUARM -DCOLORLCD -DVIRTUALINPUTS -DBACKUP > datacopy.cpp
|
||||||
DEPENDS ${RADIO_DIRECTORY}/src/datastructs.h ${RADIO_DIRECTORY}/util/generate_datacopy.py
|
DEPENDS ${RADIO_DIRECTORY}/src/datastructs.h ${RADIO_DIRECTORY}/util/generate_datacopy.py
|
||||||
)
|
)
|
||||||
add_custom_target(datacopy DEPENDS datacopy.cpp)
|
add_custom_target(datacopy DEPENDS datacopy.cpp)
|
||||||
|
|
|
@ -26,18 +26,23 @@ namespace Backup {
|
||||||
PACK(struct RamBackup {
|
PACK(struct RamBackup {
|
||||||
ModelData model;
|
ModelData model;
|
||||||
RadioData radio;
|
RadioData radio;
|
||||||
}) ramBackup;
|
});
|
||||||
#undef BACKUP
|
#undef BACKUP
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "datacopy.cpp"
|
#include "datacopy.cpp"
|
||||||
|
|
||||||
|
Backup::RamBackup ramBackup;
|
||||||
|
|
||||||
void RamBackupWrite()
|
void RamBackupWrite()
|
||||||
{
|
{
|
||||||
TRACE("RamBackup size=%d vs %d", sizeof(Backup::RamBackup), sizeof(ModelData)+sizeof(RadioData));
|
TRACE("RamBackup size=%d vs %d", sizeof(Backup::RamBackup), sizeof(ModelData)+sizeof(RadioData));
|
||||||
|
copyRadioData(&ramBackup.radio, &g_eeGeneral);
|
||||||
|
copyModelData(&ramBackup.model, &g_model);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RamBackupRead()
|
void RamBackupRead()
|
||||||
{
|
{
|
||||||
|
copyRadioData(&g_eeGeneral, &ramBackup.radio);
|
||||||
|
copyModelData(&g_model, &ramBackup.model);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,12 @@ def build_struct(cursor):
|
||||||
if c.type.get_array_size() > 0:
|
if c.type.get_array_size() > 0:
|
||||||
if c.type.get_array_element_type().spelling in structs:
|
if c.type.get_array_element_type().spelling in structs:
|
||||||
print " for (int i=0; i<%d; i++) {" % c.type.get_array_size()
|
print " for (int i=0; i<%d; i++) {" % c.type.get_array_size()
|
||||||
print " copy%s(dest->%s[i], src->%s[i]);" % (c.type.get_array_element_type().spelling, c.spelling, c.spelling)
|
print " copy%s(&dest->%s[i], &src->%s[i]);" % (c.type.get_array_element_type().spelling, c.spelling, c.spelling)
|
||||||
print " }"
|
print " }"
|
||||||
else:
|
else:
|
||||||
print " memcpy(&dest->%s, &src->%s, sizeof(dest->%s));" % (c.spelling, c.spelling, c.spelling)
|
print " memcpy(&dest->%s, &src->%s, sizeof(dest->%s));" % (c.spelling, c.spelling, c.spelling)
|
||||||
|
elif c.type.get_declaration().spelling in structs:
|
||||||
|
print " copy%s(&dest->%s, &src->%s);" % (c.type.get_declaration().spelling, c.spelling, c.spelling)
|
||||||
else:
|
else:
|
||||||
print " dest->%s = src->%s;" % (c.spelling, c.spelling)
|
print " dest->%s = src->%s;" % (c.spelling, c.spelling)
|
||||||
print "}\n"
|
print "}\n"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue