doc, warning fix, remove not needed code

This commit is contained in:
openshwprojects
2023-01-09 20:48:16 +01:00
parent ad7cebefff
commit 5614d3e56a
3 changed files with 35 additions and 45 deletions

25
docs/led_gamma_control.md Normal file
View File

@@ -0,0 +1,25 @@
led_gamma_control () - led_gammaCtrl command handler, usage: led_gammaCtrl <sub-command> [parameter(s)]
sub-commands:
cal [f f f] - set RGB calibration values from color-picker or parameters
gamma <f> - LED gamma correction, range 1.0-3.0: 1.0 = gamma off, default = 2.2
brtMinRGB <f> - minimum brightness in % for RGB mode, range 0.0-10.0%, default = 0.1
brtMinCW <f> - 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 <f>" 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 <f>" and "brtMinCW <f>" 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.

View File

@@ -472,32 +472,6 @@ void apply_smart_light() {
sendFullRGBCW_IfEnabled();
}
/*
led_gamma_control () - led_gammaCtrl command handler, usage: led_gammaCtrl <sub-command> [parameter(s)]
sub-commands:
cal [f f f] - set RGB calibration values from color-picker or parameters
gamma <f> - LED gamma correction, range 1.0-3.0: 1.0 = gamma off, default = 2.2
brtMinRGB <f> - minimum brightness in % for RGB mode, range 0.0-10.0%, default = 0.1
brtMinCW <f> - 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 <f>" 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 <f>" and "brtMinCW <f>" 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;

View File

@@ -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;