Browse Source

Merged in soif/espurna/ir_hsv (pull request #31)

Conflicts:
	code/espurna/data/index.html.gz
	code/espurna/static/index.html.gz.h
	code/platformio.ini
fastled
Xose Pérez 6 years ago
parent
commit
1847a12cb8
13 changed files with 5032 additions and 3547 deletions
  1. +1
    -0
      code/espurna/config/arduino.h
  2. +4
    -0
      code/espurna/config/general.h
  3. +104
    -0
      code/espurna/config/hardware.h
  4. BIN
      code/espurna/data/index.html.gz
  5. +6
    -0
      code/espurna/espurna.ino
  6. +17
    -0
      code/espurna/hardware.ino
  7. +6
    -0
      code/espurna/light.ino
  8. +1163
    -0
      code/espurna/light_ir.ino
  9. +3560
    -3543
      code/espurna/static/index.html.gz.h
  10. +34
    -4
      code/espurna/web.ino
  11. +83
    -0
      code/html/custom.js
  12. +30
    -0
      code/html/index.html
  13. +24
    -0
      code/platformio.ini

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

@ -34,6 +34,7 @@
//#define WORKCHOICE_ECOPLUG
//#define AITHINKER_AI_LIGHT
//#define MAGICHOME_LED_CONTROLLER
//#define MAGICHOME_LED_CONTROLLER_IR
//#define HUACANXING_H801
//#define JANGOE_WIFI_RELAY_NC
//#define JANGOE_WIFI_RELAY_NO


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

@ -435,6 +435,10 @@ PROGMEM const char* const custom_reset_string[] = {
// Light module
#define MQTT_TOPIC_CHANNEL "channel"
#define MQTT_TOPIC_COLOR "color"
#define MQTT_TOPIC_COLOR_RGB "color_rgb"
#define MQTT_TOPIC_COLOR_HSV "color_hsv"
#define MQTT_TOPIC_ANIM_MODE "anim_mode"
#define MQTT_TOPIC_ANIM_SPEED "anim_speed"
#define MQTT_TOPIC_BRIGHTNESS "brightness"
#define MQTT_TOPIC_MIRED "mired"
#define MQTT_TOPIC_KELVIN "kelvin"


+ 104
- 0
code/espurna/config/hardware.h View File

@ -726,6 +726,110 @@
#define LIGHT_CH3_INVERSE 0
#define LIGHT_CH4_INVERSE 0
// -----------------------------------------------------------------------------
// LED Controller With IR
// -----------------------------------------------------------------------------
#elif defined(MAGICHOME_LED_CONTROLLER_IR)
// Info
#define MANUFACTURER "MAGICHOME"
#define DEVICE "LED_CONTROLLER_IR"
#define RELAY_PROVIDER RELAY_PROVIDER_LIGHT
#define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER
#define DUMMY_RELAY_COUNT 1
// LEDs
#define LED1_PIN 2
#define LED1_PIN_INVERSE 1
// Channels (for board version 2.0)
#define LIGHT_CH1_PIN 5 // RED
#define LIGHT_CH2_PIN 12 // GREEN
#define LIGHT_CH3_PIN 13 // BLUE
//#define LIGHT_CH4_PIN 14 // WHITE ?
#define LIGHT_IR_PIN 4 // IR LED
#define LIGHT_CH1_INVERSE 0
#define LIGHT_CH2_INVERSE 0
#define LIGHT_CH3_INVERSE 0
#define LIGHT_CH4_INVERSE 0
#define LIGHT_PROVIDER_EXPERIMENTAL_RGB_ONLY_HSV_IR 1
// 24 Buttons Set of the IR Remote
#ifndef IR_BUTTONS_SET
#define IR_BUTTONS_SET 1
#endif
//Remote Buttons SET 1 (for the original Remote shipped with the controller)
#if IR_BUTTONS_SET == 1
#define IR_BUTTON_0 0xFF906F // Brightness +
#define IR_BUTTON_1 0xFFB847 // Brightness -
#define IR_BUTTON_2 0xFFF807 // OFF
#define IR_BUTTON_3 0xFFB04F // ON
#define IR_BUTTON_4 0xFF9867 // RED
#define IR_BUTTON_5 0xFFD827 // GREEN
#define IR_BUTTON_6 0xFF8877 // BLUE
#define IR_BUTTON_7 0xFFA857 // WHITE
#define IR_BUTTON_8 0xFFE817 // "Red" 1
#define IR_BUTTON_9 0xFF48B7 // "Green" 1
#define IR_BUTTON_10 0xFF6897 // "Blue" 1
#define IR_BUTTON_11 0xFFB24D // FLASH Mode
#define IR_BUTTON_12 0xFF02FD // "Red" 2
#define IR_BUTTON_13 0xFF32CD // "Green" 2
#define IR_BUTTON_14 0xFF20DF // "Blue" 2
#define IR_BUTTON_15 0xFF00FF // STROBE Mode
#define IR_BUTTON_16 0xFF50AF // "Red" 3
#define IR_BUTTON_17 0xFF7887 // "Green" 3
#define IR_BUTTON_18 0xFF708F // "Blue" 3
#define IR_BUTTON_19 0xFF58A7 // FADE Mode
#define IR_BUTTON_20 0xFF38C7 // "Red" 4
#define IR_BUTTON_21 0xFF28D7 // "Green" 4
#define IR_BUTTON_22 0xFFF00F // "Blue" 4
#define IR_BUTTON_23 0xFF30CF // SMOOTH Mode
#endif
//Remote Buttons SET 2 (another identical IR Remote shipped with another controller)
#if IR_BUTTONS_SET == 2
#define IR_BUTTON_0 0xFF00FF // Brightness +
#define IR_BUTTON_1 0xFF807F // Brightness -
#define IR_BUTTON_2 0xFF40BF // OFF
#define IR_BUTTON_3 0xFFC03F // ON
#define IR_BUTTON_4 0xFF20DF // RED
#define IR_BUTTON_5 0xFFA05F // GREEN
#define IR_BUTTON_6 0xFF609F // BLUE
#define IR_BUTTON_7 0xFFE01F // WHITE
#define IR_BUTTON_8 0xFF10EF // "Red" 1
#define IR_BUTTON_9 0xFF906F // "Green" 1
#define IR_BUTTON_10 0xFF50AF // "Blue" 1
#define IR_BUTTON_11 0xFFD02F // FLASH Mode
#define IR_BUTTON_12 0xFF30CF // "Red" 2
#define IR_BUTTON_13 0xFFB04F // "Green" 2
#define IR_BUTTON_14 0xFF708F // "Blue" 2
#define IR_BUTTON_15 0xFFF00F // STROBE Mode
#define IR_BUTTON_16 0xFF08F7 // "Red" 3
#define IR_BUTTON_17 0xFF8877 // "Green" 3
#define IR_BUTTON_18 0xFF48B7 // "Blue" 3
#define IR_BUTTON_19 0xFFC837 // FADE Mode
#define IR_BUTTON_20 0xFF28D7 // "Red" 4
#define IR_BUTTON_21 0xFFA857 // "Green" 4
#define IR_BUTTON_22 0xFF6897 // "Blue" 4
#define IR_BUTTON_23 0xFFE817 // SMOOTH Mode
#endif
// -----------------------------------------------------------------------------
// HUACANXING H801
// -----------------------------------------------------------------------------


BIN
code/espurna/data/index.html.gz View File


+ 6
- 0
code/espurna/espurna.ino View File

@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "config/all.h"
#include <EEPROM.h>
#include <FastLED.h> // W.T.H. is this include ALSO needed here ?!?!!
// -----------------------------------------------------------------------------
// METHODS
@ -308,6 +309,11 @@ void loop() {
// Do not run the next services if system is flagged stable
if (!systemCheck()) return;
#if LIGHT_PROVIDER != LIGHT_PROVIDER_NONE
lightLoop();
#endif
buttonLoop();
relayLoop();
ledLoop();


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

@ -244,6 +244,23 @@ void hwUpwardsCompatibility() {
setSetting("chLogic", 4, 0);
setSetting("relays", 1);
#elif defined(MAGICHOME_LED_CONTROLLER_IR)
setSetting("board", 21);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
setSetting("ledGPIO", 1, 2);
setSetting("ledLogic", 1, 1);
setSetting("chGPIO", 1, 5);
setSetting("chGPIO", 2, 12);
setSetting("chGPIO", 3, 13);
setSetting("chGPIO", 4, 14);
setSetting("chLogic", 1, 0);
setSetting("chLogic", 2, 0);
setSetting("chLogic", 3, 0);
setSetting("chLogic", 4, 0);
setSetting("relays", 1);
#elif defined(ITEAD_MOTOR)
setSetting("board", 22);


+ 6
- 0
code/espurna/light.ino View File

@ -7,6 +7,7 @@ Copyright (C) 2016-2017 by Xose Pérez <xose dot perez at gmail dot com>
*/
#if LIGHT_PROVIDER != LIGHT_PROVIDER_NONE
#ifndef LIGHT_PROVIDER_EXPERIMENTAL_RGB_ONLY_HSV_IR
#include <Ticker.h>
#include <ArduinoJson.h>
@ -582,4 +583,9 @@ void lightSetup() {
}
void lightLoop(){
}
#endif // LIGHT_PROVIDER_EXPERIMENTAL_RGB_ONLY_HSV_IR
#endif // LIGHT_PROVIDER != LIGHT_PROVIDER_NONE

+ 1163
- 0
code/espurna/light_ir.ino
File diff suppressed because it is too large
View File


+ 3560
- 3543
code/espurna/static/index.html.gz.h
File diff suppressed because it is too large
View File


+ 34
- 4
code/espurna/web.ino View File

@ -185,7 +185,27 @@ void _wsParse(AsyncWebSocketClient *client, uint8_t * payload, size_t length) {
#endif
#if LIGHT_PROVIDER != LIGHT_PROVIDER_NONE
#ifdef LIGHT_PROVIDER_EXPERIMENTAL_RGB_ONLY_HSV_IR
if (lightHasColor()) {
if (action.equals("color_hsv") && root.containsKey("data")) {
JsonObject& data = root["data"];
setLightColor(data["h"],data["s"],data["v"]);
lightUpdate(true, true);
}
}
if (action.equals("anim_mode") && root.containsKey("data")) {
lightAnimMode(root["data"]);
lightUpdate(true, true);
}
if (action.equals("anim_speed") && root.containsKey("data")) {
lightAnimSpeed(root["data"]);
lightUpdate(true, true);
}
#else
if (lightHasColor()) {
if (action.equals("color") && root.containsKey("data")) {
@ -207,8 +227,8 @@ void _wsParse(AsyncWebSocketClient *client, uint8_t * payload, size_t length) {
lightUpdate(true, true);
}
}
#endif
#endif //LIGHT_PROVIDER_EXPERIMENTAL_RGB_ONLY_HSV_IR
#endif //LIGHT_PROVIDER != LIGHT_PROVIDER_NONE
};
@ -498,8 +518,18 @@ void _wsStart(uint32_t client_id) {
root["useWhite"] = getSetting("useWhite", LIGHT_USE_WHITE).toInt() == 1;
root["useGamma"] = getSetting("useGamma", LIGHT_USE_GAMMA).toInt() == 1;
if (lightHasColor()) {
root["color"] = lightColor();
root["brightness"] = lightBrightness();
#ifdef LIGHT_PROVIDER_EXPERIMENTAL_RGB_ONLY_HSV_IR
root["anim_mode"] = lightAnimMode();
root["anim_speed"] = lightAnimSpeed();
JsonObject& color_hsv = root.createNestedObject("color_hsv");
color_hsv["h"] = lightColorH();
color_hsv["s"] = lightColorS();
color_hsv["v"] = lightColorV();
#else
root["color"] = lightColor();
root["brightness"] = lightBrightness();
#endif
}
JsonArray& channels = root.createNestedArray("channels");
for (unsigned char id=0; id < lightChannels(); id++) {


+ 83
- 0
code/html/custom.js View File

@ -347,6 +347,67 @@ function initColor() {
}
function initColorHsv() {
// check if already initialized
var done = $("#colors > div").length;
if (done > 0) return;
// add template
var template = $("#colorHsvTemplate").children();
var line = $(template).clone();
line.appendTo("#colors");
// init color wheel
$('input[name="color"]').wheelColorPicker({
sliders: 'whsvp'
}).on('sliderup', function() {
var color_all = $(this).wheelColorPicker('getColor');
var color_hsv ={};
color_hsv.h =Math.floor(color_all.h * 255);
color_hsv.s =Math.floor(color_all.s * 255);
color_hsv.v =Math.floor(color_all.v * 255);
websock.send(JSON.stringify({'action': 'color_hsv', 'data' : color_hsv}));
});
}
function initColorsExtras() {
// check if already initialized
var done = $("#colorsExtras > div").length;
if (done > 0) return;
// add template
var template = $("#colorsExtrasTemplate").children();
var line = $(template).clone();
line.appendTo("#colorsExtras");
// init anim mode
$("#animMode").on('change', function() {
var select = this.value;
websock.send(JSON.stringify( {'action': 'anim_mode', 'data' : select }));
});
// init anim speed slider
noUiSlider.create($("#animSpeed").get(0), {
start: 500,
connect: [true, false],
tooltips: true,
format: {
to: function (value) { return parseInt(value); },
from: function (value) { return value; }
},
orientation: "horizontal",
range: { 'min': 0, 'max': 1000}
}).on("change", function() {
var value = parseInt(this.get());
websock.send(JSON.stringify({'action': 'anim_speed', 'data' : value}));
});
}
function initChannels(num) {
// check if already initialized
@ -520,6 +581,28 @@ function processData(data) {
return;
}
if (key == "color_hsv") {
initColorHsv();
var color_hsv ={};
color_hsv.h = data[key]['h'] / 255;
color_hsv.s = data[key]['s'] / 255;
color_hsv.v = data[key]['v'] / 255;
$("input[name='color']").wheelColorPicker('setColor', color_hsv);
return;
}
if (key == "anim_mode") {
initColorsExtras();
$("[name='animation']").val(data[key]);
return;
}
if (key == "anim_speed") {
initColorsExtras();
var slider = $("#animSpeed");
if (slider.length) slider.get(0).noUiSlider.set(data[key]);
return;
}
if (key == "brightness") {
var slider = $("#brightness");
if (slider.length) slider.get(0).noUiSlider.set(data[key]);


+ 30
- 0
code/html/index.html View File

@ -165,6 +165,10 @@
<div id="channels">
</div>
<div id="colorsExtras">
</div>
<div class="pure-g module module-analog">
<label class="pure-u-1 pure-u-sm-1-4" for="analogValue">Analog</label>
<input class="pure-u-1 pure-u-sm-3-4" type="text" name="analogValue" readonly />
@ -941,6 +945,32 @@
</div>
</div>
<div id="colorHsvTemplate" class="template">
<div class="pure-g">
<label class="pure-u-1 pure-u-sm-1-4">Color</label>
<input class="pure-u-1 pure-u-sm-1-4" data-wcp-layout="block" name="color" readonly />
</div>
</div>
<div id="colorsExtrasTemplate" class="template">
<div class="pure-g">
<label class="pure-u-1 pure-u-sm-1-4">Mode</label>
<select class="pure-u-1 pure-u-sm-1-4" name="animation" id="animMode">
<option value=0>Single Color</option>
<option value=1>1 - Flash</option>
<option value=2>2 - Strobe</option>
<option value=3>3 - Fade</option>
<option value=4>4 - Smooth</option>
<option value=5>5 - Party</option>
</select>
</div>
<div class="pure-g">
<label class="pure-u-1 pure-u-sm-1-4">Speed</label>
<div class="slider pure-u-1 pure-u-sm-1-4" id="animSpeed"></div>
</div>
</div>
<div id="channelTemplate" class="template">
<div class="pure-g">
<label class="pure-u-1 pure-u-sm-1-4">Channel #</label>


+ 24
- 0
code/platformio.ini View File

@ -34,6 +34,8 @@ lib_deps =
https://bitbucket.org/xoseperez/debounceevent.git#2.0.1
https://github.com/xoseperez/my9291#2.0.0
https://github.com/xoseperez/RemoteSwitch-arduino-library.git
https://github.com/FastLED/FastLED#v3.1.6
https://github.com/markszabo/IRremoteESP8266#v2.2.0
lib_ignore =
# ------------------------------------------------------------------------------
@ -750,6 +752,28 @@ upload_port = "192.168.4.1"
upload_flags = --auth=fibonacci --port 8266
monitor_baud = 115200
[env:magichome-led-controller-ir]
platform = ${common.platform}
framework = arduino
board = esp01_1m
board_flash_mode = dout
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_1m} -DMAGICHOME_LED_CONTROLLER_IR
monitor_baud = 115200
[env:magichome-led-controller-ir-ota]
platform = ${common.platform}
framework = arduino
board = esp01_1m
board_flash_mode = dout
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_1m} -DMAGICHOME_LED_CONTROLLER_IR
upload_port = "192.168.4.1"
upload_flags = --auth=fibonacci --port 8266
monitor_baud = 115200
[env:huacanxing-h801]
platform = ${common.platform}
framework = arduino


Loading…
Cancel
Save