From 5337092e93b5b41260292d6d02f3752ff107a351 Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Wed, 16 Mar 2016 20:15:54 +0100 Subject: [PATCH] datacopy.cpp generated file now part of the sources and can be generated manually with target datacopy --- radio/src/CMakeLists.txt | 9 +- radio/src/storage/datacopy.cpp | 307 ++++++++++++++++++++++++++++++++ radio/util/generate_datacopy.py | 7 + 3 files changed, 318 insertions(+), 5 deletions(-) create mode 100644 radio/src/storage/datacopy.cpp diff --git a/radio/src/CMakeLists.txt b/radio/src/CMakeLists.txt index b32fd1928..0c419213a 100644 --- a/radio/src/CMakeLists.txt +++ b/radio/src/CMakeLists.txt @@ -70,7 +70,7 @@ if(PCB STREQUAL HORUS) set(GUI_DIR horus) set(TARGET_DIR horus) set(LINKER_SCRIPT targets/horus/stm32f4_flash.ld) - set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} horus_bitmaps datacopy) + set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} horus_bitmaps) set(LUA_EXPORT lua_export_horus) set(FLAVOUR horus) set(VIRTUAL_INPUTS YES) @@ -122,12 +122,11 @@ if(PCB STREQUAL HORUS) STM32F4xx_StdPeriph_Driver/src/stm32f4xx_tim.c STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma2d.c ) - add_custom_command( - OUTPUT datacopy.cpp - COMMAND python ${RADIO_DIRECTORY}/util/generate_datacopy.py ${RADIO_DIRECTORY}/src/datastructs.h -DPCBHORUS -DCPUARM -DCOLORLCD -DVIRTUALINPUTS -DBACKUP > datacopy.cpp + add_custom_target(datacopy + WORKING_DIRECTORY ${RADIO_DIRECTORY}/src + COMMAND python ${RADIO_DIRECTORY}/util/generate_datacopy.py datastructs.h -DPCBHORUS -DCPUARM -DCOLORLCD -DVIRTUALINPUTS -DBACKUP > storage/datacopy.cpp DEPENDS ${RADIO_DIRECTORY}/src/datastructs.h ${RADIO_DIRECTORY}/util/generate_datacopy.py ) - add_custom_target(datacopy DEPENDS datacopy.cpp) elseif(PCB STREQUAL TARANIS) option(PCBREV "PCB Revision" REVPLUS) option(SHUTDOWN_CONFIRMATION "Shutdown confirmation" OFF) diff --git a/radio/src/storage/datacopy.cpp b/radio/src/storage/datacopy.cpp new file mode 100644 index 000000000..239db541d --- /dev/null +++ b/radio/src/storage/datacopy.cpp @@ -0,0 +1,307 @@ +//This file was auto-generated by generate_datacopy.py script on Wed Mar 16 20:12:19 2016. Do not edit this file! + + + +template +void copyCurveRef(A * dest, B * src) +{ + dest->type = src->type; + dest->value = src->value; +} + +template +void copyMixData(A * dest, B * src) +{ + dest->weight = src->weight; + dest->destCh = src->destCh; + dest->srcRaw = src->srcRaw; + dest->carryTrim = src->carryTrim; + dest->mixWarn = src->mixWarn; + dest->mltpx = src->mltpx; + dest->spare = src->spare; + dest->offset = src->offset; + dest->swtch = src->swtch; + dest->flightModes = src->flightModes; + copyCurveRef(&dest->curve, &src->curve); + dest->delayUp = src->delayUp; + dest->delayDown = src->delayDown; + dest->speedUp = src->speedUp; + dest->speedDown = src->speedDown; +} + +template +void copyExpoData(A * dest, B * src) +{ + dest->mode = src->mode; + dest->scale = src->scale; + dest->srcRaw = src->srcRaw; + dest->carryTrim = src->carryTrim; + dest->chn = src->chn; + dest->swtch = src->swtch; + dest->flightModes = src->flightModes; + dest->weight = src->weight; + dest->spare = src->spare; + dest->offset = src->offset; + copyCurveRef(&dest->curve, &src->curve); +} + +template +void copyLimitData(A * dest, B * src) +{ + dest->min = src->min; + dest->max = src->max; + dest->ppmCenter = src->ppmCenter; + dest->offset = src->offset; + dest->symetrical = src->symetrical; + dest->revert = src->revert; + dest->spare = src->spare; + dest->curve = src->curve; +} + +template +void copyLogicalSwitchData(A * dest, B * src) +{ + dest->func = src->func; + dest->v1 = src->v1; + dest->v3 = src->v3; + dest->andsw = src->andsw; + dest->andswtype = src->andswtype; + dest->spare = src->spare; + dest->v2 = src->v2; + dest->delay = src->delay; + dest->duration = src->duration; +} + +template +void copyCustomFunctionData(A * dest, B * src) +{ + dest->swtch = src->swtch; + dest->func = src->func; + dest->active = src->active; +} + +template +void copytrim_t(A * dest, B * src) +{ + dest->value = src->value; + dest->mode = src->mode; +} + +template +void copyFlightModeData(A * dest, B * src) +{ + for (int i=0; i<4; i++) { + copytrim_t(&dest->trim[i], &src->trim[i]); + } + dest->swtch = src->swtch; + dest->spare = src->spare; + dest->fadeIn = src->fadeIn; + dest->fadeOut = src->fadeOut; + memcpy(dest->gvars, src->gvars, sizeof(dest->gvars)); +} + +template +void copyGVarData(A * dest, B * src) +{ + dest->min = src->min; + dest->max = src->max; + dest->popup = src->popup; + dest->prec = src->prec; + dest->unit = src->unit; + dest->spare = src->spare; +} + +template +void copyTimerData(A * dest, B * src) +{ + dest->mode = src->mode; + dest->start = src->start; + dest->value = src->value; + dest->countdownBeep = src->countdownBeep; + dest->minuteBeep = src->minuteBeep; + dest->persistent = src->persistent; + dest->spare = src->spare; +} + +template +void copySwashRingData(A * dest, B * src) +{ + dest->type = src->type; + dest->value = src->value; + dest->collectiveSource = src->collectiveSource; + dest->aileronSource = src->aileronSource; + dest->elevatorSource = src->elevatorSource; + dest->collectiveWeight = src->collectiveWeight; + dest->aileronWeight = src->aileronWeight; + dest->elevatorWeight = src->elevatorWeight; +} + +template +void copyScriptData(A * dest, B * src) +{ + memcpy(dest->file, src->file, sizeof(dest->file)); + memcpy(dest->name, src->name, sizeof(dest->name)); + memcpy(dest->inputs, src->inputs, sizeof(dest->inputs)); +} + +template +void copyFrSkyRSSIAlarm(A * dest, B * src) +{ + dest->level = src->level; + dest->value = src->value; +} + +template +void copyFrSkyTelemetryData(A * dest, B * src) +{ + dest->varioSource = src->varioSource; + dest->varioCenterSilent = src->varioCenterSilent; + dest->varioCenterMax = src->varioCenterMax; + dest->varioCenterMin = src->varioCenterMin; + dest->varioMin = src->varioMin; + dest->varioMax = src->varioMax; + for (int i=0; i<2; i++) { + copyFrSkyRSSIAlarm(&dest->rssiAlarms[i], &src->rssiAlarms[i]); + } +} + +template +void copyModuleData(A * dest, B * src) +{ + dest->type = src->type; + dest->rfProtocol = src->rfProtocol; + dest->channelsStart = src->channelsStart; + dest->channelsCount = src->channelsCount; + dest->failsafeMode = src->failsafeMode; + dest->invertedSerial = src->invertedSerial; + memcpy(dest->failsafeChannels, src->failsafeChannels, sizeof(dest->failsafeChannels)); + dest->ppmDelay = src->ppmDelay; + dest->ppmPulsePol = src->ppmPulsePol; + dest->ppmOutputType = src->ppmOutputType; + dest->ppmFrameLength = src->ppmFrameLength; +} + +template +void copyModelHeader(A * dest, B * src) +{ + memcpy(dest->name, src->name, sizeof(dest->name)); + memcpy(dest->modelId, src->modelId, sizeof(dest->modelId)); +} + +template +void copyZone(A * dest, B * src) +{ + dest->x = src->x; + dest->y = src->y; + dest->w = src->w; + dest->h = src->h; +} + +template +void copyZoneOption(A * dest, B * src) +{ + dest->name = src->name; + dest->type = src->type; + dest->deflt = src->deflt; +} + +template +void copyCustomScreenData(A * dest, B * src) +{ + memcpy(dest->layoutName, src->layoutName, sizeof(dest->layoutName)); + dest->layoutData = src->layoutData; +} + +template +void copyModelData(A * dest, B * src) +{ + copyModelHeader(&dest->header, &src->header); + for (int i=0; i<3; i++) { + copyTimerData(&dest->timers[i], &src->timers[i]); + } + dest->telemetryProtocol = src->telemetryProtocol; + dest->thrTrim = src->thrTrim; + dest->noGlobalFunctions = src->noGlobalFunctions; + dest->displayTrims = src->displayTrims; + dest->ignoreSensorIds = src->ignoreSensorIds; + dest->trimInc = src->trimInc; + dest->disableThrottleWarning = src->disableThrottleWarning; + dest->displayChecklist = src->displayChecklist; + dest->extendedLimits = src->extendedLimits; + dest->extendedTrims = src->extendedTrims; + dest->throttleReversed = src->throttleReversed; + dest->beepANACenter = src->beepANACenter; + for (int i=0; i<64; i++) { + copyMixData(&dest->mixData[i], &src->mixData[i]); + } + for (int i=0; i<32; i++) { + copyLimitData(&dest->limitData[i], &src->limitData[i]); + } + for (int i=0; i<64; i++) { + copyExpoData(&dest->expoData[i], &src->expoData[i]); + } + memcpy(dest->curves, src->curves, sizeof(dest->curves)); + memcpy(dest->points, src->points, sizeof(dest->points)); + for (int i=0; i<64; i++) { + copyLogicalSwitchData(&dest->logicalSw[i], &src->logicalSw[i]); + } + for (int i=0; i<64; i++) { + copyCustomFunctionData(&dest->customFn[i], &src->customFn[i]); + } + copySwashRingData(&dest->swashR, &src->swashR); + for (int i=0; i<9; i++) { + copyFlightModeData(&dest->flightModeData[i], &src->flightModeData[i]); + } + for (int i=0; i<9; i++) { + copyGVarData(&dest->gvars[i], &src->gvars[i]); + } + for (int i=0; i<3; i++) { + copyModuleData(&dest->moduleData[i], &src->moduleData[i]); + } +} + +template +void copyStepsCalibData(A * dest, B * src) +{ + dest->count = src->count; + memcpy(dest->steps, src->steps, sizeof(dest->steps)); +} + +template +void copyCalibData(A * dest, B * src) +{ + dest->mid = src->mid; + dest->spanNeg = src->spanNeg; + dest->spanPos = src->spanPos; +} + +template +void copyTrainerMix(A * dest, B * src) +{ + dest->srcChn = src->srcChn; + dest->mode = src->mode; + dest->studWeight = src->studWeight; +} + +template +void copyTrainerData(A * dest, B * src) +{ + memcpy(dest->calib, src->calib, sizeof(dest->calib)); +} + +template +void copyRadioData(A * dest, B * src) +{ + for (int i=0; i<11; i++) { + copyCalibData(&dest->calib[i], &src->calib[i]); + } + dest->stickMode = src->stickMode; + dest->switchesDelay = src->switchesDelay; + for (int i=0; i<64; i++) { + copyCustomFunctionData(&dest->customFn[i], &src->customFn[i]); + } + dest->slidersConfig = src->slidersConfig; + dest->switchConfig = src->switchConfig; + dest->potsConfig = src->potsConfig; +} + diff --git a/radio/util/generate_datacopy.py b/radio/util/generate_datacopy.py index e770e9647..f4c6e7068 100644 --- a/radio/util/generate_datacopy.py +++ b/radio/util/generate_datacopy.py @@ -4,6 +4,8 @@ from __future__ import print_function import sys import clang.cindex +import time +import os structs = [] @@ -32,6 +34,11 @@ def build(cursor): build_struct(c) return result + +def header(): + print("//This file was auto-generated by %s script on %s. Do not edit this file!\n\n\n" % (os.path.basename(sys.argv[0]), time.asctime())) + index = clang.cindex.Index.create() translation_unit = index.parse(sys.argv[1], ['-x', 'c++', '-std=c++11'] + sys.argv[2:]) +header() build(translation_unit.cursor)