Browse Source

Improve support fro H801 led controller, thanks to Minh Phuong Ly

fastled
Xose Pérez 7 years ago
parent
commit
4d96cac751
6 changed files with 54 additions and 10 deletions
  1. +1
    -0
      code/espurna/config/general.h
  2. +4
    -6
      code/espurna/config/hardware.h
  3. +14
    -0
      code/espurna/hardware.ino
  4. +12
    -2
      code/espurna/light.ino
  5. +2
    -2
      code/espurna/relay.ino
  6. +21
    -0
      code/platformio.ini

+ 1
- 0
code/espurna/config/general.h View File

@ -232,6 +232,7 @@
#define LIGHT_PROVIDER_RGB 2 #define LIGHT_PROVIDER_RGB 2
#define LIGHT_PROVIDER_RGBW 3 #define LIGHT_PROVIDER_RGBW 3
#define LIGHT_PROVIDER_MY9192 4 #define LIGHT_PROVIDER_MY9192 4
#define LIGHT_PROVIDER_RGB2W 5
#define LIGHT_DEFAULT_COLOR "#000080" #define LIGHT_DEFAULT_COLOR "#000080"
#define LIGHT_SAVE_DELAY 5 #define LIGHT_SAVE_DELAY 5


+ 4
- 6
code/espurna/config/hardware.h View File

@ -299,16 +299,14 @@
// HUACANXING H801 // HUACANXING H801
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#elif defined(H801)
#elif defined(H801_LED_CONTROLLER)
#define MANUFACTURER "HUACANXING" #define MANUFACTURER "HUACANXING"
#define DEVICE "H801" #define DEVICE "H801"
#define LED1_PIN 5 #define LED1_PIN 5
#define LED1_PIN_INVERSE 1 #define LED1_PIN_INVERSE 1
#define LED2_PIN 2
#define LED2_PIN_INVERSE 1
#define RELAY_PROVIDER RELAY_PROVIDER_LIGHT #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT
#define LIGHT_PROVIDER LIGHT_PROVIDER_RGBW
#define LIGHT_PROVIDER LIGHT_PROVIDER_RGB2W
#undef RGBW_INVERSE_LOGIC #undef RGBW_INVERSE_LOGIC
#undef RGBW_RED_PIN #undef RGBW_RED_PIN
@ -316,12 +314,12 @@
#undef RGBW_BLUE_PIN #undef RGBW_BLUE_PIN
#undef RGBW_WHITE_PIN #undef RGBW_WHITE_PIN
#define RGBW_INVERSE_LOGIC 0
#define RGBW_INVERSE_LOGIC 1
#define RGBW_RED_PIN 15 #define RGBW_RED_PIN 15
#define RGBW_GREEN_PIN 13 #define RGBW_GREEN_PIN 13
#define RGBW_BLUE_PIN 12 #define RGBW_BLUE_PIN 12
#define RGBW_WHITE_PIN 14 #define RGBW_WHITE_PIN 14
//#define RGBW_WHITE_PIN 4 <= warm white
#define RGBW_WHITE2_PIN 4
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Jan Goedeke Wifi Relay // Jan Goedeke Wifi Relay


+ 14
- 0
code/espurna/hardware.ino View File

@ -264,6 +264,20 @@ void hwUpwardsCompatibility() {
setSetting("relayLogic", 1, 1); setSetting("relayLogic", 1, 1);
#endif #endif
#ifdef H801_LED_CONTROLLER
setSetting("board", 24);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_RGB2W);
setSetting("ledGPIO", 5, 1);
setSetting("ledLogic", 1, 1);
setSetting("redGPIO", 15);
setSetting("greenGPIO", 13);
setSetting("blueGPIO", 12);
setSetting("whiteGPIO", 14);
setSetting("white2GPIO", 4);
setSetting("lightLogic", 1);
#endif
saveSettings(); saveSettings();
} }

+ 12
- 2
code/espurna/light.ino View File

@ -19,6 +19,7 @@ my9291 * _my9291;
#endif #endif
#if ENABLE_GAMMA_CORRECTION #if ENABLE_GAMMA_CORRECTION
#define GAMMA_TABLE_SIZE (256) #define GAMMA_TABLE_SIZE (256)
#undef LIGHT_PWM_RANGE #undef LIGHT_PWM_RANGE
#define LIGHT_PWM_RANGE (4095) #define LIGHT_PWM_RANGE (4095)
@ -41,6 +42,7 @@ my9291 * _my9291;
2315,2346,2378,2410,2442,2474,2507,2540,2573,2606,2640,2674,2708,2743,2778,2813, 2315,2346,2378,2410,2442,2474,2507,2540,2573,2606,2640,2674,2708,2743,2778,2813,
2849,2884,2920,2957,2993,3030,3067,3105,3143,3181,3219,3258,3297,3336,3376,3416, 2849,2884,2920,2957,2993,3030,3067,3105,3143,3181,3219,3258,3297,3336,3376,3416,
3456,3496,3537,3578,3619,3661,3703,3745,3788,3831,3874,3918,3962,4006,4050,4095 }; 3456,3496,3537,3578,3619,3661,3703,3745,3788,3831,3874,3918,3962,4006,4050,4095 };
#endif #endif
#ifndef LIGHT_PWM_FREQUENCY #ifndef LIGHT_PWM_FREQUENCY
@ -164,7 +166,7 @@ void _lightProviderSet(bool state, unsigned int red, unsigned int green, unsigne
unsigned int white = 0; unsigned int white = 0;
#if (LIGHT_PROVIDER == LIGHT_PROVIDER_MY9192) || (LIGHT_PROVIDER == LIGHT_PROVIDER_RGBW)
#if (LIGHT_PROVIDER == LIGHT_PROVIDER_MY9192) || (LIGHT_PROVIDER == LIGHT_PROVIDER_RGBW) || (LIGHT_PROVIDER == LIGHT_PROVIDER_RGB2W)
// If all set to the same value use white instead // If all set to the same value use white instead
if ((red == green) && (green == blue)) { if ((red == green) && (green == blue)) {
white = red; white = red;
@ -177,7 +179,7 @@ void _lightProviderSet(bool state, unsigned int red, unsigned int green, unsigne
_my9291->setColor((my9291_color_t) { red, green, blue, white }); _my9291->setColor((my9291_color_t) { red, green, blue, white });
#endif #endif
#if (LIGHT_PROVIDER == LIGHT_PROVIDER_RGB) || (LIGHT_PROVIDER == LIGHT_PROVIDER_RGBW)
#if (LIGHT_PROVIDER == LIGHT_PROVIDER_RGB) || (LIGHT_PROVIDER == LIGHT_PROVIDER_RGBW) || (LIGHT_PROVIDER == LIGHT_PROVIDER_RGB2W)
// Check state // Check state
if (!state) red = green = blue = white = 0; if (!state) red = green = blue = white = 0;
@ -188,6 +190,10 @@ void _lightProviderSet(bool state, unsigned int red, unsigned int green, unsigne
#if (LIGHT_PROVIDER == LIGHT_PROVIDER_RGBW) #if (LIGHT_PROVIDER == LIGHT_PROVIDER_RGBW)
analogWrite(RGBW_WHITE_PIN, _intensity2pwm(white)); analogWrite(RGBW_WHITE_PIN, _intensity2pwm(white));
#endif #endif
#if (LIGHT_PROVIDER == LIGHT_PROVIDER_RGB2W)
analogWrite(RGBW_WHITE_PIN, _intensity2pwm(white));
analogWrite(RGBW_WHITE2_PIN, _intensity2pwm(white));
#endif
#endif #endif
} }
@ -288,6 +294,10 @@ void lightSetup() {
#if LIGHT_PROVIDER == LIGHT_PROVIDER_RGBW #if LIGHT_PROVIDER == LIGHT_PROVIDER_RGBW
pinMode(RGBW_WHITE_PIN, OUTPUT); pinMode(RGBW_WHITE_PIN, OUTPUT);
#endif #endif
#if LIGHT_PROVIDER == LIGHT_PROVIDER_RGB2W
pinMode(RGBW_WHITE_PIN, OUTPUT);
pinMode(RGBW_WHITE2_PIN, OUTPUT);
#endif
#endif #endif
_lightColorRestore(); _lightColorRestore();


+ 2
- 2
code/espurna/relay.ino View File

@ -453,9 +453,9 @@ void relaySetup() {
_relays.push_back((relay_t) {0, 0}); _relays.push_back((relay_t) {0, 0});
_relays.push_back((relay_t) {0, 0}); _relays.push_back((relay_t) {0, 0});
#elif defined(AI_LIGHT) | defined(LED_CONTROLLER)
#elif defined(AI_LIGHT) | defined(LED_CONTROLLER) | defined(H801_LED_CONTROLLER)
// One dummy relay for the AI Thinker Light & Magic Home Led Controller
// One dummy relay for the AI Thinker Light & Magic Home and H801 led controllers
_relays.push_back((relay_t) {0, 0}); _relays.push_back((relay_t) {0, 0});
#else #else


+ 21
- 0
code/platformio.ini View File

@ -456,3 +456,24 @@ build_flags = ${common.build_flags_1m128} -DLED_CONTROLLER
upload_speed = 115200 upload_speed = 115200
upload_port = "192.168.4.1" upload_port = "192.168.4.1"
upload_flags = --auth=fibonacci --port 8266 upload_flags = --auth=fibonacci --port 8266
[env:h801-debug]
platform = espressif8266
framework = arduino
board = esp01_1m
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
extra_script = pio_hooks.py
build_flags = -g -Wl,-Tesp8266.flash.1m128.ld -DH801_LED_CONTROLLER -DDEBUG_PORT=Serial1
[env:h801-debug-ota]
platform = espressif8266
framework = arduino
board = esp01_1m
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
extra_script = pio_hooks.py
build_flags = -g -Wl,-Tesp8266.flash.1m128.ld -DH801_LED_CONTROLLER -DDEBUG_PORT=Serial1
upload_speed = 115200
upload_port = "192.168.4.1"
upload_flags = --auth=fibonacci --port 8266

Loading…
Cancel
Save