From 5614d3e56a0ed0deb2022a360c57c410cd1d2467 Mon Sep 17 00:00:00 2001 From: openshwprojects Date: Mon, 9 Jan 2023 20:48:16 +0100 Subject: [PATCH] doc, warning fix, remove not needed code --- docs/led_gamma_control.md | 25 ++++++++++++++++++++ src/cmnds/cmd_newLEDDriver.c | 45 ------------------------------------ src/new_cfg.c | 10 ++++++++ 3 files changed, 35 insertions(+), 45 deletions(-) create mode 100644 docs/led_gamma_control.md diff --git a/docs/led_gamma_control.md b/docs/led_gamma_control.md new file mode 100644 index 000000000..6fa1432c9 --- /dev/null +++ b/docs/led_gamma_control.md @@ -0,0 +1,25 @@ + + led_gamma_control () - led_gammaCtrl command handler, usage: led_gammaCtrl [parameter(s)] + sub-commands: + cal [f f f] - set RGB calibration values from color-picker or parameters + gamma - LED gamma correction, range 1.0-3.0: 1.0 = gamma off, default = 2.2 + brtMinRGB - minimum brightness in % for RGB mode, range 0.0-10.0%, default = 0.1 + brtMinCW - minimum brightness in % for CW mode, range 0.0-10.0%, default = 0.1 + list - list settings (and enable additional messages) + Results will be displayed as Logs Info:CFG: messages (may want to turn off MAIN, MQTT and GEN to silence other messages) + Any sub-command will enable channel messages containing output values in % + + Calibration sequence: + 1: clear current calibration values (= 1.0, default) by one of these methods: + a: set color-picker to "white", i.e. #FFFFFF and enter command "led_gammaCtrl cal" + b: or set values directly with command "led_gammaCtrl cal 1.0 1.0 1.0" + 2: adjust RGB LEDs to emit white light of preferred temperature and brightness + 3: enter command "led_gammaCtrl cal" - if successful the settings will be listed and stored in flash + + Use command "gamma " to set gamma value. Range 1.0-3.0: 1.0 = gamma off, default is 2.2. + To fully disable gamma correction you may also want to set brtMinX to 0.0. + Use commands "brtMinRGB " and "brtMinCW " to set minimum brightness for RGB and CW LEDs. + Valid range is 0.0-10.0% of full range (including brightness 0). "channel messages" is useful in finding suitable + range: adjust brightness to desired minimum level and use the highest channel % value as brtMinX parameter. + Channels 0-2 is RGB, channels 3-4 is CW + Use command "list" to view gamma and calibration settings. \ No newline at end of file diff --git a/src/cmnds/cmd_newLEDDriver.c b/src/cmnds/cmd_newLEDDriver.c index 25a8c31a4..11eb2923d 100644 --- a/src/cmnds/cmd_newLEDDriver.c +++ b/src/cmnds/cmd_newLEDDriver.c @@ -472,32 +472,6 @@ void apply_smart_light() { sendFullRGBCW_IfEnabled(); } -/* - led_gamma_control () - led_gammaCtrl command handler, usage: led_gammaCtrl [parameter(s)] - sub-commands: - cal [f f f] - set RGB calibration values from color-picker or parameters - gamma - LED gamma correction, range 1.0-3.0: 1.0 = gamma off, default = 2.2 - brtMinRGB - minimum brightness in % for RGB mode, range 0.0-10.0%, default = 0.1 - brtMinCW - minimum brightness in % for CW mode, range 0.0-10.0%, default = 0.1 - list - list settings (and enable additional messages) - Results will be displayed as Logs Info:CFG: messages (may want to turn off MAIN, MQTT and GEN to silence other messages) - Any sub-command will enable channel messages containing output values in % - - Calibration sequence: - 1: clear current calibration values (= 1.0, default) by one of these methods: - a: set color-picker to "white", i.e. #FFFFFF and enter command "led_gammaCtrl cal" - b: or set values directly with command "led_gammaCtrl cal 1.0 1.0 1.0" - 2: adjust RGB LEDs to emit white light of preferred temperature and brightness - 3: enter command "led_gammaCtrl cal" - if successful the settings will be listed and stored in flash - - Use command "gamma " to set gamma value. Range 1.0-3.0: 1.0 = gamma off, default is 2.2. - To fully disable gamma correction you may also want to set brtMinX to 0.0. - Use commands "brtMinRGB " and "brtMinCW " to set minimum brightness for RGB and CW LEDs. - Valid range is 0.0-10.0% of full range (including brightness 0). "channel messages" is useful in finding suitable - range: adjust brightness to desired minimum level and use the highest channel % value as brtMinX parameter. - Channels 0-2 is RGB, channels 3-4 is CW - Use command "list" to view gamma and calibration settings. -*/ void led_gamma_list (void) { // list RGB gamma settings led_gamma_enable_channel_messages = 1; addLogAdv (LOG_INFO, LOG_FEATURE_CFG, "RGB cal %f %f %f\r\n", @@ -506,25 +480,6 @@ void led_gamma_list (void) { // list RGB gamma settings g_cfg.led_corr.led_gamma, g_cfg.led_corr.rgb_bright_min, g_cfg.led_corr.cw_bright_min); } -#ifdef PLATFORM_BK7231T -// add some prototypes from tuya_hal_storage.h - TODO: include the file instead, or use different functions -int tuya_hal_flash_erase (const uint32_t addr, const uint32_t size); -int tuya_hal_flash_write (const uint32_t addr, const uint8_t *src, const uint32_t size); - -# define LED_GAMMA_FLASH_ADDR 0x1df000 // LED gamma config flash address -#endif - -bool isZeroes(const byte *p, int size) { - int i; - - for (i = 0; i < size; i++) { - if (p[i]) - return false; - } - return true; -} - - commandResult_t led_gamma_control (const void *context, const char *cmd, const char *args, int cmdFlags) { int c; diff --git a/src/new_cfg.c b/src/new_cfg.c index 3e0c16f39..dad44a36c 100644 --- a/src/new_cfg.c +++ b/src/new_cfg.c @@ -109,6 +109,16 @@ static byte CFG_CalcChecksum(mainConfig_t *inf) { return crc; } +bool isZeroes(const byte *p, int size) { + int i; + + for (i = 0; i < size; i++) { + if (p[i]) + return false; + } + return true; +} + bool CFG_HasValidLEDCorrectionTable() { if (isZeroes((const byte*)&g_cfg.led_corr, sizeof(g_cfg.led_corr))) { return false;