Skip to content

Commit ed79739

Browse files
committed
Updated dependencies to newer releases
1 parent d747f7d commit ed79739

File tree

3 files changed

+64
-51
lines changed

3 files changed

+64
-51
lines changed

README.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ The circuit uses an LD1117V33 voltage regulator with two capacitors as specified
99

1010
## Code
1111
### Dependencies
12-
The mentioned versions are tested, other may work as well but may lead to compile issues.
13-
* [esp8266 v.2.4.2](https://github.com/esp8266/Arduino)
14-
* [ArduinoJSON v.6.13.0](https://github.com/bblanchon/ArduinoJson)
12+
The following dependencies have to be installed in Arduino IDE using library or board manager (see project readme) to compile this project. The mentioned versions are tested, other may work as well but may lead to compile issues.
13+
* [esp8266 v.3.0.2](https://github.com/esp8266/Arduino)
14+
* [ArduinoJSON v.6.19.4](https://github.com/bblanchon/ArduinoJson)
15+
16+
The following dependencies will be loaded using a [CDN](https://en.wikipedia.org/wiki/Content_delivery_network) for the web ui. There is no need to install them, but an internet connection is needed for the ui to display.
17+
* [iro.js v.5.5.2](https://github.com/jaames/iro.js)
18+
* [jQuery v.3.6.0](https://github.com/jquery/jquery)
19+
1520

1621
### Configuration
1722

@@ -90,7 +95,7 @@ The controller accecpts POST request at http://ip-adress/api/v1/state. The reque
9095

9196
### Graphical User Interface
9297

93-
A User Interface using [iro.js](https://github.com/jaames/iro.js) is available at http://ip-adress/ui. An Internet connection is required to load additional Javascript libraries from CDN.
98+
A User Interface using [iro.js](https://github.com/jaames/iro.js) is available at http://ip-adress/ui. An Internet connection is required to load additional Javascript libraries from CDN (see dependencies section).
9499

95100
## License
96101
Copyright (c) 2018 Chris Klinger. Licensed under MIT license, see [LICENSE](https://github.com/c-klinger/esp8266-arduino-wifirgb/blob/master/LICENSE.md) for the full license.

WifiRGB/web_interface.h

+55-39
Original file line numberDiff line numberDiff line change
@@ -5,63 +5,79 @@ const char WEBINTERFACE[] PROGMEM = R"=====(
55
<head>
66
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
77
<title>WifiRGB Controller Interface</title>
8-
<script type="text/javascript" src="iro.min.js"></script>
9-
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
8+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@jaames/iro@5"></script>
9+
<script type="text/javascript" src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
1010
<style>
1111
body {
1212
color: #fff;
1313
background: #272727;
1414
text-align: center;
1515
}
1616

17-
#color-picker-container svg {
17+
#color-picker-container {
1818
margin: 48px auto;
1919
}
20+
21+
#color-picker {
22+
margin: auto;
23+
}
2024
</style>
2125
</head>
2226
<body>
2327
<div id="color-picker-container"></div>
2428
<script type="text/javascript">
25-
var size = 0;
26-
if (window.innerWidth > window.innerHeight) {
27-
size = window.innerHeight * 0.8;
28-
} else {
29-
size = window.innerWidth * 0.8;
29+
function resizeColorPicker(colorPicker) {
30+
var size = 0;
31+
if (window.innerWidth > window.innerHeight) {
32+
size = window.innerHeight * 0.8;
33+
} else {
34+
size = window.innerWidth * 0.8;
35+
}
36+
37+
var cssSize = size + "px";
38+
39+
$( "#color-picker-container" ).css( "width", cssSize );
40+
$( "#colorPicker" ).css( "width", cssSize );
41+
colorPicker.resize(size);
3042
}
3143

32-
var demoColorPicker = new iro.ColorPicker("#color-picker-container", {
33-
// color picker options
34-
// Option guide: https://rakujira.jp/projects/iro/docs/guide.html#Color-Picker-Options
35-
width: size,
36-
height: size,
37-
color: {r: 0, g: 0, b: 0},
38-
anticlockwise: true,
39-
borderWidth: 10,
40-
borderColor: "#313131"
41-
});
44+
var colorPicker = new iro.ColorPicker("#color-picker-container", {
45+
// color picker options
46+
// Option guide: https://rakujira.jp/projects/iro/docs/guide.html#Color-Picker-Options
47+
id: "color-picker",
48+
color: {r: 0, g: 0, b: 0},
49+
anticlockwise: true,
50+
borderWidth: 10,
51+
borderColor: "#313131"
52+
});
53+
54+
// inital resize
55+
resizeColorPicker(colorPicker);
56+
57+
// register hook
58+
$( window ).resize(function() {
59+
resizeColorPicker(colorPicker);
60+
});
4261

43-
demoColorPicker.on("color:change", function(color, changes) {
44-
// Log the color's hex RGB value to the dev console
45-
console.log(color.rgb);
46-
console.log(color.hsv.v);
47-
// If the "H" channel has changed, log the color's HSV value too
48-
//if (changes.h) {
49-
// console.log(color.hsv);
50-
//}
51-
var json = {state:"ON",brightness:color.hsv.v,color:{mode:"rgb",r:color.rgb.r,g:color.rgb.g,b:color.rgb.b},mode:"SOLID"};
52-
console.log(json);
53-
console.log(JSON.stringify(json));
62+
63+
colorPicker.on("color:change", function(color, changes) {
64+
// Log the color's hex RGB value to the dev console
65+
console.log(color.rgb);
5466

55-
$.ajax( "/api/v1/state", { data: JSON.stringify(json), dataType: "json", method: "POST", contentType: "application/json", cache: false, timeout: 2000})
56-
.done(function( data ) {
57-
console.log( "Response: " );
58-
console.log( data );
59-
})
60-
.fail(function( data ) {
61-
console.log( "Error: " );
62-
console.log( data );
63-
});
64-
});
67+
var json = {state:"ON",brightness:color.hsv.v,color:{mode:"rgb",r:color.rgb.r,g:color.rgb.g,b:color.rgb.b},mode:"SOLID"};
68+
console.log(json);
69+
console.log(JSON.stringify(json));
70+
71+
$.ajax( "/api/v1/state", { data: JSON.stringify(json), dataType: "json", method: "POST", contentType: "application/json", cache: false, timeout: 2000})
72+
.done(function( data ) {
73+
console.log( "Response: " );
74+
console.log( data );
75+
})
76+
.fail(function( data ) {
77+
console.log( "Error: " );
78+
console.log( data );
79+
});
80+
});
6581
</script>
6682
</body>
6783
</html>

WifiRGB/web_iro_js.h

-8
This file was deleted.

0 commit comments

Comments
 (0)