From 0137460d0b7cd38efaec76a3cd2d47ab6e16818c Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Fri, 18 Dec 2015 23:22:34 +0100 Subject: [PATCH] LP-183 promote int8 and uint8 to their 16 bits equivalents applies only to new Qml friendly properties int16 will be silently cast to and from int8 !!! --- .../vehicleconfigurationhelper.cpp | 54 +++++++++---------- .../generators/gcs/uavobjectgeneratorgcs.cpp | 12 +++-- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/ground/gcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp b/ground/gcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp index 29393684c..566ab24fd 100644 --- a/ground/gcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp +++ b/ground/gcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp @@ -770,30 +770,30 @@ void VehicleConfigurationHelper::applyMixerConfiguration(mixerChannelSettings ch case VehicleConfigurationSource::MULTI_ROTOR_HEXA: case VehicleConfigurationSource::MULTI_ROTOR_HEXA_H: case VehicleConfigurationSource::MULTI_ROTOR_HEXA_X: - mSettings->setMixerValueRoll(100); - mSettings->setMixerValuePitch(100); - mSettings->setMixerValueYaw(100); + mSettings->setMixerValueRoll((qint8) 100); + mSettings->setMixerValuePitch((qint8) 100); + mSettings->setMixerValueYaw((qint8) 100); break; case VehicleConfigurationSource::MULTI_ROTOR_QUAD_X: - mSettings->setMixerValueRoll(50); - mSettings->setMixerValuePitch(50); - mSettings->setMixerValueYaw(50); + mSettings->setMixerValueRoll((qint8) 50); + mSettings->setMixerValuePitch((qint8) 50); + mSettings->setMixerValueYaw((qint8) 50); break; case VehicleConfigurationSource::MULTI_ROTOR_QUAD_PLUS: - mSettings->setMixerValueRoll(100); - mSettings->setMixerValuePitch(100); - mSettings->setMixerValueYaw(50); + mSettings->setMixerValueRoll((qint8) 100); + mSettings->setMixerValuePitch((qint8) 100); + mSettings->setMixerValueYaw((qint8) 50); break; case VehicleConfigurationSource::MULTI_ROTOR_HEXA_COAX_Y: - mSettings->setMixerValueRoll(100); - mSettings->setMixerValuePitch(50); - mSettings->setMixerValueYaw(66); + mSettings->setMixerValueRoll((qint8) 100); + mSettings->setMixerValuePitch((qint8) 50); + mSettings->setMixerValueYaw((qint8) 66); break; case VehicleConfigurationSource::MULTI_ROTOR_OCTO: case VehicleConfigurationSource::MULTI_ROTOR_OCTO_X: - mSettings->setMixerValueRoll(100); - mSettings->setMixerValuePitch(100); - mSettings->setMixerValueYaw(100); + mSettings->setMixerValueRoll((qint8) 100); + mSettings->setMixerValuePitch((qint8) 100); + mSettings->setMixerValueYaw((qint8) 100); break; case VehicleConfigurationSource::MULTI_ROTOR_OCTO_COAX_X: case VehicleConfigurationSource::MULTI_ROTOR_OCTO_COAX_PLUS: @@ -805,9 +805,9 @@ void VehicleConfigurationHelper::applyMixerConfiguration(mixerChannelSettings ch break; } case VehicleConfigurationSource::VEHICLE_FIXEDWING: - mSettings->setMixerValueRoll(100); - mSettings->setMixerValuePitch(100); - mSettings->setMixerValueYaw(100); + mSettings->setMixerValueRoll((qint8) 100); + mSettings->setMixerValuePitch((qint8) 100); + mSettings->setMixerValueYaw((qint8) 100); maxThrottle = 1; break; case VehicleConfigurationSource::VEHICLE_HELI: @@ -816,22 +816,22 @@ void VehicleConfigurationHelper::applyMixerConfiguration(mixerChannelSettings ch { switch (m_configSource->getVehicleSubType()) { case VehicleConfigurationSource::GROUNDVEHICLE_MOTORCYCLE: - mSettings->setMixerValueRoll(100); - mSettings->setMixerValuePitch(100); - mSettings->setMixerValueYaw(100); + mSettings->setMixerValueRoll((qint8) 100); + mSettings->setMixerValuePitch((qint8) 100); + mSettings->setMixerValueYaw((qint8) 100); maxThrottle = 1; break; case VehicleConfigurationSource::GROUNDVEHICLE_CAR: - mSettings->setMixerValueRoll(100); - mSettings->setMixerValuePitch(100); - mSettings->setMixerValueYaw(100); + mSettings->setMixerValueRoll((qint8) 100); + mSettings->setMixerValuePitch((qint8) 100); + mSettings->setMixerValueYaw((qint8) 100); maxThrottle = 1; minThrottle = 0; break; case VehicleConfigurationSource::GROUNDVEHICLE_DIFFERENTIAL: - mSettings->setMixerValueRoll(100); - mSettings->setMixerValuePitch(100); - mSettings->setMixerValueYaw(100); + mSettings->setMixerValueRoll((qint8) 100); + mSettings->setMixerValuePitch((qint8) 100); + mSettings->setMixerValueYaw((qint8) 100); maxThrottle = 0.8; minThrottle = 0; break; diff --git a/ground/uavobjgenerator/generators/gcs/uavobjectgeneratorgcs.cpp b/ground/uavobjgenerator/generators/gcs/uavobjectgeneratorgcs.cpp index 2ff76a829..8f7d75da0 100644 --- a/ground/uavobjgenerator/generators/gcs/uavobjectgeneratorgcs.cpp +++ b/ground/uavobjgenerator/generators/gcs/uavobjectgeneratorgcs.cpp @@ -630,12 +630,18 @@ bool UAVObjectGeneratorGCS::process_object(ObjectInfo *object) fieldCtxt.ucPropName = toPropertyName(field->name); fieldCtxt.propName = toLowerCamelCase(fieldCtxt.ucPropName); fieldCtxt.propType = fieldCtxt.fieldType; - fieldCtxt.propRefType = fieldCtxt.fieldType; - if (field->type == FIELDTYPE_ENUM) { + if (field->type == FIELDTYPE_INT8) { + fieldCtxt.propType = fieldTypeStrCPP(FIELDTYPE_INT16); + } + else if (field->type == FIELDTYPE_UINT8) { + fieldCtxt.propType = fieldTypeStrCPP(FIELDTYPE_UINT16); + } + else if (field->type == FIELDTYPE_ENUM) { QString enumClassName = object->name + "_" + fieldCtxt.ucPropName; fieldCtxt.propType = enumClassName + "::Enum"; - fieldCtxt.propRefType = fieldCtxt.propType; } + // reference type + fieldCtxt.propRefType = fieldCtxt.propType; // deprecation fieldCtxt.hasDeprecatedProperty = (fieldCtxt.fieldName != fieldCtxt.propName) && DEPRECATED;