From 701586e00e35aca0de584e7704843489c2706cb4 Mon Sep 17 00:00:00 2001 From: i3water <121024123@qq.com> Date: Wed, 7 Nov 2018 17:46:47 +0800 Subject: [PATCH] update codes, upgrade BRIGHTNESS codes --- .../AliGenie_LIGHT/AliGenie_LIGHT.ino | 14 +++++++++++--- src/Blinker/BlinkerApi.h | 6 +++--- src/Blinker/BlinkerConfig.h | 4 ++++ src/utility/BlinkerAliGenie.h | 2 +- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/examples/Blinker_AliGenie/AliGenie_LIGHT/AliGenie_LIGHT.ino b/examples/Blinker_AliGenie/AliGenie_LIGHT/AliGenie_LIGHT.ino index c87f2ce7..4896adf7 100644 --- a/examples/Blinker_AliGenie/AliGenie_LIGHT/AliGenie_LIGHT.ino +++ b/examples/Blinker_AliGenie/AliGenie_LIGHT/AliGenie_LIGHT.ino @@ -255,17 +255,25 @@ void aligeniecMode(const String & cmode) BlinkerAliGenie.print(); } -void aligenieBright(int32_t bright) +void aligenieBright(const String & bright) { BLINKER_LOG2("need set brightness: ", bright); - colorW = bright; + if (bright == BLINKER_CMD_MAX) { + colorW = 255; + } + else if (bright == BLINKER_CMD_MIN) { + colorW = 0; + } + else { + colorW = bright.toInt(); + } BLINKER_LOG2("now set brightness: ", colorW); pixelShow(); - BlinkerAliGenie.brightness(bright); + BlinkerAliGenie.brightness(colorW); BlinkerAliGenie.print(); } diff --git a/src/Blinker/BlinkerApi.h b/src/Blinker/BlinkerApi.h index 6520a485..a874b65a 100644 --- a/src/Blinker/BlinkerApi.h +++ b/src/Blinker/BlinkerApi.h @@ -1671,7 +1671,7 @@ class BlinkerApi _setcModeFunc = newFunction; } - void attachSetBrightness(callback_with_int32_arg_t newFunction) + void attachSetBrightness(callback_with_string_arg_t newFunction) { _setBrightnessFunc = newFunction; } @@ -4811,7 +4811,7 @@ class BlinkerApi callback_with_string_arg_t _setColorFunc = NULL; callback_with_string_arg_t _setModeFunc = NULL; callback_with_string_arg_t _setcModeFunc = NULL; - callback_with_int32_arg_t _setBrightnessFunc = NULL; + callback_with_string_arg_t _setBrightnessFunc = NULL; callback_with_int32_arg_t _setRelativeBrightnessFunc = NULL; callback_with_int32_arg_t _setColorTemperature = NULL; callback_with_int32_arg_t _setRelativeColorTemperature = NULL; @@ -5064,7 +5064,7 @@ class BlinkerApi else if (rootSet.containsKey(BLINKER_CMD_BRIGHTNESS)) { String setValue = rootSet[BLINKER_CMD_BRIGHTNESS]; - if (_setBrightnessFunc) _setBrightnessFunc(setValue.toInt()); + if (_setBrightnessFunc) _setBrightnessFunc(setValue); } else if (rootSet.containsKey(BLINKER_CMD_UPBRIGHTNESS)) { String setValue = rootSet[BLINKER_CMD_UPBRIGHTNESS]; diff --git a/src/Blinker/BlinkerConfig.h b/src/Blinker/BlinkerConfig.h index 1e33c1ee..8def0cce 100644 --- a/src/Blinker/BlinkerConfig.h +++ b/src/Blinker/BlinkerConfig.h @@ -337,6 +337,10 @@ #define BLINKER_CMD_PM25 "pm25" +#define BLINKER_CMD_MAX "max" + +#define BLINKER_CMD_MIN "min" + #define BLINKER_CMD_ALIGENIE "AliGenie" #define BLINKER_CMD_SUMMARY "sum" diff --git a/src/utility/BlinkerAliGenie.h b/src/utility/BlinkerAliGenie.h index 64a6fa57..fe590aa6 100644 --- a/src/utility/BlinkerAliGenie.h +++ b/src/utility/BlinkerAliGenie.h @@ -29,7 +29,7 @@ class BLINKERALIGENIE Blinker.attachSetcMode(newFunction); } - void attachBrightness(callback_with_int32_arg_t newFunction) + void attachBrightness(callback_with_string_arg_t newFunction) { Blinker.attachSetBrightness(newFunction); }