1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

code style: move variable into function and free 1 byte of RAM :-)

component     free heap used
    ----------------------------
    Nothing            2560    -
    PWM                2432  128
    PPM                2408  152
    DSM                2464   96
    S.Bus              2448  112
    GPS (port only)    2368  192
    GPS (port+module)  1312 1248
    CameraStab         2096  464
    Telemetry          1928  632
This commit is contained in:
Oleg Semyonov 2011-11-13 18:27:52 +02:00
parent 3e4a33169c
commit 4a99ec3298
2 changed files with 16 additions and 13 deletions

View File

@ -62,8 +62,6 @@
// Private variables
static uint8_t camerastabEnabled = 0;
// Private functions
static void attitudeUpdated(UAVObjEvent* ev);
static float bound(float val);
@ -76,16 +74,18 @@ int32_t CameraStabInitialize(void)
{
static UAVObjEvent ev;
HwSettingsInitialize();
bool cameraStabEnabled;
uint8_t optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM];
HwSettingsOptionalModulesGet(optionalModules);
if (optionalModules[HWSETTINGS_OPTIONALMODULES_CAMERASTAB] == HWSETTINGS_OPTIONALMODULES_ENABLED) {
camerastabEnabled=1;
} else {
camerastabEnabled=0;
}
if (camerastabEnabled) {
HwSettingsInitialize();
HwSettingsOptionalModulesGet(optionalModules);
if (optionalModules[HWSETTINGS_OPTIONALMODULES_CAMERASTAB] == HWSETTINGS_OPTIONALMODULES_ENABLED)
cameraStabEnabled = true;
else
cameraStabEnabled = false;
if (cameraStabEnabled) {
AttitudeActualInitialize();

View File

@ -120,14 +120,16 @@ int32_t GPSStart(void)
int32_t GPSInitialize(void)
{
gpsPort = PIOS_COM_GPS;
HwSettingsInitialize();
uint8_t optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM];
HwSettingsOptionalModulesGet(optionalModules);
if (optionalModules[HWSETTINGS_OPTIONALMODULES_GPS] == HWSETTINGS_OPTIONALMODULES_ENABLED) {
if (optionalModules[HWSETTINGS_OPTIONALMODULES_GPS] == HWSETTINGS_OPTIONALMODULES_ENABLED)
gpsEnabled = true;
} else {
else
gpsEnabled = false;
}
if (gpsPort && gpsEnabled) {
GPSPositionInitialize();
@ -149,6 +151,7 @@ int32_t GPSInitialize(void)
return -1;
}
MODULE_INITCALL(GPSInitialize, GPSStart)
// ****************