Skip to content

Commit

Permalink
Merge pull request #1 from diyhue/master
Browse files Browse the repository at this point in the history
update from diyHue/Light
  • Loading branch information
juanesf committed Feb 28, 2019
2 parents c85bde8 + cdee2e5 commit ff672f2
Show file tree
Hide file tree
Showing 69 changed files with 2,048 additions and 7,902 deletions.
3 changes: 3 additions & 0 deletions .cli-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
board_manager:
additional_urls:
- http://arduino.esp8266.com/stable/package_esp8266com_index.json
25 changes: 25 additions & 0 deletions .github/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Contributing to diyHue Lights

:+1::tada: First off, thanks for taking the time to contribute! :tada::+1:

The following is a set of guidelines for contributing to diyHue Lights. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.

### Building with travis
In order for your sketch to be built with travis, please upload only the `sketch.ino` file in a folder within the Arduino dir. Please make sure that the folder and sketch name are exactly the same, ignoring the extension. For example the sketch would be saved in `Lights/Arudino/Generic_Fun_Light/` and called `Generic_Fun_Light.ino`.

Also within you PR, please create a commit to `.travis.yml`, adding a line in the matrix section. This should be in the format `- SKETCH="YOUR_SKETCH_NAME_HERE"`. Following the above example, `.travis.yml` would look like:

```
...
matrix:
- SKETCH="Generic_RGBW_Light"
- SKETCH="Generic_RGB_Light"
- SKETCH="Generic_CCT_Light"
- SKETCH="Generic_RGB_CCT_Light"
- SKETCH="Generic_WS2812_Strip"
- SKETCH="Generic_SK6812_Strip"
- SKETCH="Generic_Fun_Strip"
...
```

Finaly, if your sketch requires any of the libraries not installed on [this](https://github.com/diyhue/Lights/blob/675d2693afdb5f38fd9e61fdcf21aa042a7817b4/install.sh#L94) line of `install.sh`, then please add a commit adding them.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.elf
59 changes: 59 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
language: c
sudo: false

cache:
directories:
- ~/arduino_cli
- ~/.arduino15/packages/

git:
depth: false
quiet: true

env:
global:
- ARDUINO_CLI_VERSION="0.3.4-alpha.preview"
- COMMIT=${TRAVIS_COMMIT::8}
matrix:
- SKETCH="Generic_RGBW_Light"
- SKETCH="Generic_RGB_Light"
- SKETCH="Generic_CCT_Light"
- SKETCH="Generic_RGB_CCT_Light"
- SKETCH="Generic_WS2812_Strip"
- SKETCH="Generic_SK6812_Strip"

# No update for version 2.0
#- SKETCH="Generic_Dimmable_Light"
#- SKETCH="Generic_ON_OFF_device"
#- SKETCH="Generic_ON_OFF_device_433Mhz"
#- SKETCH="EspLight-fridgefire"
#- SKETCH="MY92XX_RGBW_Light"
#- SKETCH="Sonoff_S20"
#- SKETCH="WS2811_adjustable"
#- SKETCH="WS2812BHueRing"
#- SKETCH="sk6812_wwa"

# Compile error
#- SKETCH="fastLED_SM16726_RGBW_Bulb"
#- SKETCH="P9813_ledstrip_chainable"

install:
- bash ${TRAVIS_BUILD_DIR}/install.sh
- export PATH="$HOME/arduino_cli:$PATH"

script:
# Compile the sketch for NodeMCU board
- arduino-cli compile --fqbn esp8266:esp8266:nodemcu ${TRAVIS_BUILD_DIR}/Arduino/$SKETCH/$SKETCH.ino --output ${TRAVIS_BUILD_DIR}/Arduino/bin/$SKETCH.bin

# Push build files to repo
after_success:
- >
if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
cd ${TRAVIS_BUILD_DIR}
git checkout master
git add *
git commit --message "Build $SKETCH #${COMMIT} [skip travis]"
git remote add origin-travis https://${GH_TOKEN}@github.com/diyhue/Lights.git
git pull origin-travis master
git push origin-travis master
fi
Binary file removed Arduino/Generic_RGBW_Light/Generic_RGBW_Light.bin
Binary file not shown.
30 changes: 24 additions & 6 deletions Arduino/Generic_RGBW_Light/Generic_RGBW_Light.ino
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
This can control bulbs with 5 pwm channels (red, gree, blue, warm white and could wihite). Is tested with MiLight colors bulb.
This can control bulbs with 4 pwm channels (red, gree, blue, warm white and could wihite). Is tested with MiLight colors bulb.
*/
#include <FS.h>
#include <ESP8266WiFi.h>
Expand All @@ -12,12 +12,13 @@

// Define your white led color temp here (Range 2000-6536K).
// For warm-white led try 2000K, for cold-white try 6000K
#define WHITE_TEMP 2000 // kelvin
#define WHITE_TEMP 4500 // kelvin

IPAddress address ( 192, 168, 0, 95); // choose an unique IP Adress
IPAddress gateway ( 192, 168, 0, 1); // Router IP
IPAddress submask (255, 255, 255, 0);

#define light_version 2.01
#define PWM_CHANNELS 4

struct state {
Expand All @@ -29,9 +30,12 @@ struct state {

//core

#define entertainmentTimeout 1500 // millis

state light;
bool inTransition, useDhcp = true;
bool inTransition, entertainmentRun, useDhcp = true;
byte mac[6], packetBuffer[8];
unsigned long lastEPMillis;

//settings
char *lightName = "New Hue RGBW light";
Expand Down Expand Up @@ -656,7 +660,7 @@ void setup() {
root["modelid"] = "LCT015";
root["type"] = "rgbw";
root["mac"] = String(macString);
root["version"] = 2.0;
root["version"] = light_version;
String output;
root.printTo(output);
server.send(200, "text/plain", output);
Expand Down Expand Up @@ -729,15 +733,29 @@ void setup() {
void entertainment() {
int packetSize = Udp.parsePacket();
if (packetSize) {
analogWrite(pins[3], 0);
light.currentColors[3] = 0;
if (!entertainmentRun) {
entertainmentRun = true;
}
lastEPMillis = millis();
Udp.read(packetBuffer, packetSize);
for (uint8_t color = 0; color < 3; color++) {
analogWrite(pins[color - 1], (int)(packetBuffer[color] * 4));
light.currentColors[color] = packetBuffer[color + 1];
analogWrite(pins[color], (int)(packetBuffer[color + 1] * 4));
}
}
}

void loop() {
server.handleClient();
lightEngine();
if (!entertainmentRun) {
lightEngine();
} else {
if ((millis() - lastEPMillis) >= entertainmentTimeout) {
entertainmentRun = false;
processLightdata(4);
}
}
entertainment();
}
Binary file not shown.
31 changes: 25 additions & 6 deletions Arduino/Generic_RGB_CCT_Light/Generic_RGB_CCT_Light.ino
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ struct state {

//core

#define entertainmentTimeout 1500 // millis

state light;
bool inTransition, useDhcp = true;
bool inTransition, entertainmentRun, useDhcp = true;
byte mac[6], packetBuffer[8];
unsigned long lastEPMillis;

//settings
char *lightName = "New Hue RGB-CCT light";
Expand Down Expand Up @@ -469,9 +472,9 @@ void setup() {
}
WiFiManager wifiManager;

if (!useDhcp) {
if (!useDhcp) {
wifiManager.setSTAStaticIPConfig(address, gateway, submask);
}
}

if (!wifiManager.autoConnect(lightName)) {
delay(3000);
Expand Down Expand Up @@ -661,7 +664,7 @@ void setup() {
delay(100);
ESP.reset();
}

});

server.on("/reset", []() {
Expand All @@ -678,15 +681,31 @@ void setup() {
void entertainment() {
int packetSize = Udp.parsePacket();
if (packetSize) {
analogWrite(pins[3], 0);
analogWrite(pins[4], 0);
light.currentColors[3] = 0;
light.currentColors[4] = 0;
if (!entertainmentRun) {
entertainmentRun = true;
}
lastEPMillis = millis();
Udp.read(packetBuffer, packetSize);
for (uint8_t color = 0; color < 3; color++) {
analogWrite(pins[color - 1], (int)(packetBuffer[color] * 4));
light.currentColors[color] = packetBuffer[color + 1];
analogWrite(pins[color], (int)(packetBuffer[color + 1] * 4));
}
}
}

void loop() {
server.handleClient();
lightEngine();
if (!entertainmentRun) {
lightEngine();
} else {
if ((millis() - lastEPMillis) >= entertainmentTimeout) {
entertainmentRun = false;
processLightdata(4);
}
}
entertainment();
}
Binary file removed Arduino/Generic_RGB_Light/Generic_RGB_Light.bin
Binary file not shown.
24 changes: 20 additions & 4 deletions Arduino/Generic_RGB_Light/Generic_RGB_Light.ino
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ IPAddress address ( 192, 168, 0, 95); // choose an unique IP Adress
IPAddress gateway ( 192, 168, 0, 1); // Router IP
IPAddress submask (255, 255, 255, 0);

#define light_version 2.01
#define PWM_CHANNELS 3

struct state {
Expand All @@ -24,9 +25,12 @@ struct state {

//core

#define entertainmentTimeout 1500 // millis

state light;
bool inTransition, useDhcp = true;
bool inTransition, entertainmentRun, useDhcp = true;
byte mac[6], packetBuffer[8];
unsigned long lastEPMillis;

//settings
char *lightName = "New Hue RGB light";
Expand Down Expand Up @@ -615,7 +619,7 @@ void setup() {
root["modelid"] = "LCT015";
root["type"] = "rgb";
root["mac"] = String(macString);
root["version"] = 2.0;
root["version"] = light_version;
String output;
root.printTo(output);
server.send(200, "text/plain", output);
Expand Down Expand Up @@ -686,15 +690,27 @@ void setup() {
void entertainment() {
int packetSize = Udp.parsePacket();
if (packetSize) {
if (!entertainmentRun) {
entertainmentRun = true;
}
lastEPMillis = millis();
Udp.read(packetBuffer, packetSize);
for (uint8_t color = 0; color < 3; color++) {
analogWrite(pins[color - 1], (int)(packetBuffer[color] * 4));
light.currentColors[color] = packetBuffer[color + 1];
analogWrite(pins[color], (int)(packetBuffer[color + 1] * 4));
}
}
}

void loop() {
server.handleClient();
lightEngine();
if (!entertainmentRun) {
lightEngine();
} else {
if ((millis() - lastEPMillis) >= entertainmentTimeout) {
entertainmentRun = false;
processLightdata(4);
}
}
entertainment();
}

0 comments on commit ff672f2

Please sign in to comment.