Index: sources/device/DeviceModels.h =================================================================== diff -u -r27cc308ff5113a9386899d3c8f8b29962a8498e1 -r23eda7b49841f242485b70d0a96f4bdde50f71bc --- sources/device/DeviceModels.h (.../DeviceModels.h) (revision 27cc308ff5113a9386899d3c8f8b29962a8498e1) +++ sources/device/DeviceModels.h (.../DeviceModels.h) (revision 23eda7b49841f242485b70d0a96f4bdde50f71bc) @@ -20,6 +20,7 @@ // Project #include "MAbstract.h" #include "types.h" +#include "DeviceError.h" // forward declarations @@ -87,15 +88,20 @@ // TODO : Merge the two models as they have much in common in this case. // On the CANBus it was separated since the type of data in send and receive was totally different. // But here it's the same. + // TODO: improve later - this has to be match with HW2UI in response + QMap UI2HW = { // has to map to keep the order + { 20, 1}, + { 40, 3}, + { 60, 5}, + { 80, 6}, + {100, 10}, + }; public: // TODO : these needs to be available in Views static const quint8 mBrightness_min = 2; static const quint8 mBrightness_max = 10; static const quint8 mBrightness_res = 2; - // TODO : Add these two as virtual in parent. - quint8 toDV (quint8) { return 0; /* Place Holder (/ 10) */ } - quint8 toUI (quint8) { return 0; /* Place Holder (* 10) */ } struct Data { quint8 mBrightness_old = mBrightness_min ; @@ -105,6 +111,8 @@ bool mRead = false; } _data; + Device::DeviceError::Scripts_Error_Enum setBrightnessSysVal(); + QString toString() { return MDeviceRequestBase::toString("DeviceBrightness", { _data.mBrightnessPercent }); } @@ -115,14 +123,25 @@ * \details The model for the device brightness value request. */ class MDeviceBrightnessResponse : public MDeviceResponseBase { + // TODO: improve later - this has to be match with UI2HW in request + QMap HW2UI = { // has to map to keep the order + { 1, 20}, + { 3, 40}, + { 5, 60}, + { 6, 80}, + { 10, 100}, + }; + public: struct Data : MDeviceResponseBase::Data { quint8 mBrightnessPercent = 0; } _data; QVariantList parameters () const override { return { _data.mBrightnessPercent }; } - QString infoText () const override { return QString("DeviceBrightness") ; } - Data data () const { return _data; } + QString infoText () const override { return QString("DeviceBrightness") ; } + Data data () const { return _data; } + + Device::DeviceError::Scripts_Error_Enum setBrightnessPercent(quint8 vSysVal); }; // ---------- MDeviceBluetoothPaired 'Reset' ---------- //