V 4.5
This commit is contained in:
99
extras/octoprint_neopixel/octoprint_neopixel.ino
Normal file
99
extras/octoprint_neopixel/octoprint_neopixel.ino
Normal file
@@ -0,0 +1,99 @@
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "Wire.h"
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
|
||||
//define DEBUG //Uncoment this line to get debug information of the Serial port.
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DEBUG_PRINT(x) Serial.print (x)
|
||||
#define DEBUG_PRINTDEC(x) Serial.print (x, DEC)
|
||||
#define DEBUG_PRINTBIN(x) Serial.print (x, BIN)
|
||||
#define DEBUG_PRINTLN(x) Serial.println (x)
|
||||
#define DEBUG_WRITE(x) Serial.write (x)
|
||||
#define DEBUG_WRITE_LEN(x,len) Serial.write (x,len)
|
||||
#else
|
||||
#define DEBUG_PRINT(x)
|
||||
#define DEBUG_PRINTDEC(x)
|
||||
#define DEBUG_PRINTBIN(x)
|
||||
#define DEBUG_PRINTLN(x)
|
||||
#define DEBUG_WRITE(x)
|
||||
#define DEBUG_WRITE_LEN(x,len)
|
||||
#endif
|
||||
|
||||
#define LED_TYPE NEO_GRB + NEO_KHZ800
|
||||
#define I2CADDRESS 0x04
|
||||
|
||||
Adafruit_NeoPixel strip = Adafruit_NeoPixel();
|
||||
|
||||
bool gotData = false;
|
||||
int command = 0;
|
||||
int neopixelPin = 0;
|
||||
int neopixelLeds = 0;
|
||||
int neopixelBrightness = 0;
|
||||
int redValue = 0;
|
||||
int greenValue = 0;
|
||||
int blueValue = 0;
|
||||
|
||||
void receiveEvent(int byteCount){
|
||||
DEBUG_PRINT("WIRE BUFFER: ");
|
||||
DEBUG_PRINTLN(Wire.available());
|
||||
DEBUG_PRINT("CMD ");
|
||||
command = Wire.read();
|
||||
DEBUG_PRINTLN(command);
|
||||
|
||||
DEBUG_PRINT("PIN ");
|
||||
neopixelPin = Wire.read();
|
||||
DEBUG_PRINTLN(neopixelPin);
|
||||
|
||||
DEBUG_PRINT("N LED ");
|
||||
neopixelLeds = Wire.read();
|
||||
DEBUG_PRINTLN(neopixelLeds);
|
||||
|
||||
DEBUG_PRINT("BRIGHTNESS ");
|
||||
neopixelBrightness = Wire.read();
|
||||
DEBUG_PRINTLN(neopixelBrightness);
|
||||
|
||||
DEBUG_PRINT("RED ");
|
||||
redValue = Wire.read();
|
||||
DEBUG_PRINTLN(redValue);
|
||||
|
||||
DEBUG_PRINT("GREEN ");
|
||||
greenValue = Wire.read();
|
||||
DEBUG_PRINTLN(greenValue);
|
||||
|
||||
DEBUG_PRINT("BLUE ");
|
||||
blueValue = Wire.read();
|
||||
DEBUG_PRINTLN(blueValue);
|
||||
|
||||
gotData = true;
|
||||
|
||||
}
|
||||
|
||||
void setup() {
|
||||
|
||||
Wire.begin(I2CADDRESS);
|
||||
#ifdef DEBUG
|
||||
Serial.begin(115200);
|
||||
while (!Serial) ;
|
||||
Serial.println("Debuging...");
|
||||
#endif
|
||||
Wire.onReceive(receiveEvent);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if(gotData){
|
||||
strip.setPin(neopixelPin);
|
||||
strip.setBrightness(neopixelBrightness);
|
||||
strip.updateLength(neopixelLeds);
|
||||
strip.updateType(LED_TYPE);
|
||||
strip.begin();
|
||||
for(uint16_t i=0; i<strip.numPixels(); i++) {
|
||||
strip.setPixelColor(i, strip.Color(redValue, greenValue, blueValue));
|
||||
}
|
||||
strip.show();
|
||||
gotData = false;
|
||||
}
|
||||
|
||||
}
|
||||
230
octoprint_enclosure/static/css/bootstrap-colorpicker.css
vendored
Executable file
230
octoprint_enclosure/static/css/bootstrap-colorpicker.css
vendored
Executable file
@@ -0,0 +1,230 @@
|
||||
/*!
|
||||
* Bootstrap Colorpicker v2.5.1
|
||||
* https://itsjavi.com/bootstrap-colorpicker/
|
||||
*
|
||||
* Originally written by (c) 2012 Stefan Petre
|
||||
* Licensed under the Apache License v2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
*
|
||||
*/
|
||||
.colorpicker-saturation {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
background-image: url("../img/bootstrap-colorpicker/saturation.png");
|
||||
cursor: crosshair;
|
||||
float: left;
|
||||
}
|
||||
.colorpicker-saturation i {
|
||||
display: block;
|
||||
height: 5px;
|
||||
width: 5px;
|
||||
border: 1px solid #000;
|
||||
-webkit-border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
margin: -4px 0 0 -4px;
|
||||
}
|
||||
.colorpicker-saturation i b {
|
||||
display: block;
|
||||
height: 5px;
|
||||
width: 5px;
|
||||
border: 1px solid #fff;
|
||||
-webkit-border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.colorpicker-hue,
|
||||
.colorpicker-alpha {
|
||||
width: 15px;
|
||||
height: 100px;
|
||||
float: left;
|
||||
cursor: row-resize;
|
||||
margin-left: 4px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.colorpicker-hue i,
|
||||
.colorpicker-alpha i {
|
||||
display: block;
|
||||
height: 1px;
|
||||
background: #000;
|
||||
border-top: 1px solid #fff;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
margin-top: -1px;
|
||||
}
|
||||
.colorpicker-hue {
|
||||
background-image: url("../img/bootstrap-colorpicker/hue.png");
|
||||
}
|
||||
.colorpicker-alpha {
|
||||
background-image: url("../img/bootstrap-colorpicker/alpha.png");
|
||||
display: none;
|
||||
}
|
||||
.colorpicker-saturation,
|
||||
.colorpicker-hue,
|
||||
.colorpicker-alpha {
|
||||
background-size: contain;
|
||||
}
|
||||
.colorpicker {
|
||||
padding: 4px;
|
||||
min-width: 130px;
|
||||
margin-top: 1px;
|
||||
-webkit-border-radius: 4px;
|
||||
-moz-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
z-index: 2500;
|
||||
}
|
||||
.colorpicker:before,
|
||||
.colorpicker:after {
|
||||
display: table;
|
||||
content: "";
|
||||
line-height: 0;
|
||||
}
|
||||
.colorpicker:after {
|
||||
clear: both;
|
||||
}
|
||||
.colorpicker:before {
|
||||
content: '';
|
||||
display: inline-block;
|
||||
border-left: 7px solid transparent;
|
||||
border-right: 7px solid transparent;
|
||||
border-bottom: 7px solid #ccc;
|
||||
border-bottom-color: rgba(0, 0, 0, 0.2);
|
||||
position: absolute;
|
||||
top: -7px;
|
||||
left: 6px;
|
||||
}
|
||||
.colorpicker:after {
|
||||
content: '';
|
||||
display: inline-block;
|
||||
border-left: 6px solid transparent;
|
||||
border-right: 6px solid transparent;
|
||||
border-bottom: 6px solid #ffffff;
|
||||
position: absolute;
|
||||
top: -6px;
|
||||
left: 7px;
|
||||
}
|
||||
.colorpicker div {
|
||||
position: relative;
|
||||
}
|
||||
.colorpicker.colorpicker-with-alpha {
|
||||
min-width: 140px;
|
||||
}
|
||||
.colorpicker.colorpicker-with-alpha .colorpicker-alpha {
|
||||
display: block;
|
||||
}
|
||||
.colorpicker-color {
|
||||
height: 10px;
|
||||
margin-top: 5px;
|
||||
clear: both;
|
||||
background-image: url("../img/bootstrap-colorpicker/alpha.png");
|
||||
background-position: 0 100%;
|
||||
}
|
||||
.colorpicker-color div {
|
||||
height: 10px;
|
||||
}
|
||||
.colorpicker-selectors {
|
||||
display: none;
|
||||
height: 10px;
|
||||
margin-top: 5px;
|
||||
clear: both;
|
||||
}
|
||||
.colorpicker-selectors i {
|
||||
cursor: pointer;
|
||||
float: left;
|
||||
height: 10px;
|
||||
width: 10px;
|
||||
}
|
||||
.colorpicker-selectors i + i {
|
||||
margin-left: 3px;
|
||||
}
|
||||
.colorpicker-element .input-group-addon i,
|
||||
.colorpicker-element .add-on i {
|
||||
display: inline-block;
|
||||
cursor: pointer;
|
||||
height: 16px;
|
||||
vertical-align: text-top;
|
||||
width: 16px;
|
||||
}
|
||||
.colorpicker.colorpicker-inline {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
float: none;
|
||||
z-index: auto;
|
||||
}
|
||||
.colorpicker.colorpicker-horizontal {
|
||||
width: 110px;
|
||||
min-width: 110px;
|
||||
height: auto;
|
||||
}
|
||||
.colorpicker.colorpicker-horizontal .colorpicker-saturation {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.colorpicker.colorpicker-horizontal .colorpicker-color {
|
||||
width: 100px;
|
||||
}
|
||||
.colorpicker.colorpicker-horizontal .colorpicker-hue,
|
||||
.colorpicker.colorpicker-horizontal .colorpicker-alpha {
|
||||
width: 100px;
|
||||
height: 15px;
|
||||
float: left;
|
||||
cursor: col-resize;
|
||||
margin-left: 0px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.colorpicker.colorpicker-horizontal .colorpicker-hue i,
|
||||
.colorpicker.colorpicker-horizontal .colorpicker-alpha i {
|
||||
display: block;
|
||||
height: 15px;
|
||||
background: #ffffff;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 1px;
|
||||
border: none;
|
||||
margin-top: 0px;
|
||||
}
|
||||
.colorpicker.colorpicker-horizontal .colorpicker-hue {
|
||||
background-image: url("../img/bootstrap-colorpicker/hue-horizontal.png");
|
||||
}
|
||||
.colorpicker.colorpicker-horizontal .colorpicker-alpha {
|
||||
background-image: url("../img/bootstrap-colorpicker/alpha-horizontal.png");
|
||||
}
|
||||
.colorpicker-right:before {
|
||||
left: auto;
|
||||
right: 6px;
|
||||
}
|
||||
.colorpicker-right:after {
|
||||
left: auto;
|
||||
right: 7px;
|
||||
}
|
||||
.colorpicker-no-arrow:before {
|
||||
border-right: 0;
|
||||
border-left: 0;
|
||||
}
|
||||
.colorpicker-no-arrow:after {
|
||||
border-right: 0;
|
||||
border-left: 0;
|
||||
}
|
||||
.colorpicker.colorpicker-visible,
|
||||
.colorpicker-alpha.colorpicker-visible,
|
||||
.colorpicker-saturation.colorpicker-visible,
|
||||
.colorpicker-hue.colorpicker-visible,
|
||||
.colorpicker-selectors.colorpicker-visible {
|
||||
display: block;
|
||||
}
|
||||
.colorpicker.colorpicker-hidden,
|
||||
.colorpicker-alpha.colorpicker-hidden,
|
||||
.colorpicker-saturation.colorpicker-hidden,
|
||||
.colorpicker-hue.colorpicker-hidden,
|
||||
.colorpicker-selectors.colorpicker-hidden {
|
||||
display: none;
|
||||
}
|
||||
.colorpicker-inline.colorpicker-visible {
|
||||
display: inline-block;
|
||||
}
|
||||
/*# sourceMappingURL=bootstrap-colorpicker.css.map */
|
||||
BIN
octoprint_enclosure/static/img/bootstrap-colorpicker/alpha-horizontal.png
Executable file
BIN
octoprint_enclosure/static/img/bootstrap-colorpicker/alpha-horizontal.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 557 B |
BIN
octoprint_enclosure/static/img/bootstrap-colorpicker/alpha.png
Executable file
BIN
octoprint_enclosure/static/img/bootstrap-colorpicker/alpha.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 488 B |
BIN
octoprint_enclosure/static/img/bootstrap-colorpicker/hue-horizontal.png
Executable file
BIN
octoprint_enclosure/static/img/bootstrap-colorpicker/hue-horizontal.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 478 B |
BIN
octoprint_enclosure/static/img/bootstrap-colorpicker/hue.png
Executable file
BIN
octoprint_enclosure/static/img/bootstrap-colorpicker/hue.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 504 B |
BIN
octoprint_enclosure/static/img/bootstrap-colorpicker/saturation.png
Executable file
BIN
octoprint_enclosure/static/img/bootstrap-colorpicker/saturation.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 4.0 KiB |
5
octoprint_enclosure/static/js/bootstrap-colorpicker.min.js
vendored
Executable file
5
octoprint_enclosure/static/js/bootstrap-colorpicker.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
@@ -18,6 +18,14 @@ $(function() {
|
||||
|
||||
|
||||
self.previousGpioStatus;
|
||||
self.previousGpioPWMStatus;
|
||||
self.navbarTemp= ko.observable();
|
||||
self.navbarHum= ko.observable();
|
||||
|
||||
self.notificationProvider = ko.observable();
|
||||
self.event_name = ko.observable();
|
||||
self.apiKEY = ko.observable();
|
||||
self.notifications = ko.observable();
|
||||
|
||||
self.onDataUpdaterPluginMessage = function(plugin, data) {
|
||||
if (plugin != "enclosure") {
|
||||
@@ -26,9 +34,23 @@ $(function() {
|
||||
|
||||
if (data.hasOwnProperty("enclosuretemp")) {
|
||||
self.enclosureTemp(data.enclosuretemp);
|
||||
|
||||
|
||||
self.temperature_reading().forEach(function(element) {
|
||||
if("useFahrenheit" in element ){
|
||||
useFahrenheit = element['useFahrenheit']()
|
||||
|
||||
if(useFahrenheit){
|
||||
self.navbarTemp(_.sprintf("Enc: %.1f°F", data.enclosuretemp));
|
||||
}else{
|
||||
self.navbarTemp(_.sprintf("Enc: %.1f°C", data.enclosuretemp));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (data.hasOwnProperty("enclosureHumidity")) {
|
||||
self.enclosureHumidity(data.enclosureHumidity);
|
||||
self.navbarHum(_.sprintf("Hum: %.1f%%", data.enclosureHumidity));
|
||||
}
|
||||
|
||||
if (data.hasOwnProperty("enclosureSetTemp")){
|
||||
@@ -43,6 +65,10 @@ $(function() {
|
||||
data.rpi_output = self.previousGpioStatus;
|
||||
}
|
||||
|
||||
if(!data.rpi_output_pwm){
|
||||
data.rpi_output_pwm = self.previousGpioPWMStatus;
|
||||
}
|
||||
|
||||
if(data.rpi_output){
|
||||
data.rpi_output.forEach(function(gpio) {
|
||||
key = Object.keys(gpio)[0];
|
||||
@@ -57,6 +83,19 @@ $(function() {
|
||||
self.previousGpioStatus = data.rpi_output;
|
||||
}
|
||||
|
||||
if(data.rpi_output_pwm){
|
||||
data.rpi_output_pwm.forEach(function(gpio) {
|
||||
key = Object.keys(gpio)[0];
|
||||
val = gpio[key];
|
||||
if (parseFloat(val)!=100){
|
||||
$("#dutycycle_"+key).attr("placeholder", val);
|
||||
}else{
|
||||
$("#dutycycle_"+key).attr("placeholder", "off");
|
||||
}
|
||||
});
|
||||
self.previousGpioPWMStatus = data.rpi_output_pwm;
|
||||
}
|
||||
|
||||
if (data.isMsg) {
|
||||
new PNotify({title:"Enclosure", text:data.msg, type: "error"});
|
||||
}
|
||||
@@ -74,20 +113,38 @@ $(function() {
|
||||
self.rpi_outputs(self.settings.rpi_outputs());
|
||||
self.rpi_inputs(self.settings.rpi_inputs());
|
||||
self.filamentSensorGcode(self.settings.filamentSensorGcode());
|
||||
|
||||
self.notificationProvider(self.settings.notificationProvider());
|
||||
self.event_name(self.settings.event_name());
|
||||
self.apiKEY(self.settings.apiKEY());
|
||||
self.notifications(self.settings.notifications());
|
||||
};
|
||||
|
||||
self.onStartupComplete = function () {
|
||||
self.getUpdateBtnStatus();
|
||||
};
|
||||
|
||||
self.onDataUpdaterReconnect = function () {
|
||||
self.getUpdateBtnStatus();
|
||||
};
|
||||
|
||||
self.onSettingsShown = function(){
|
||||
self.fixUI();
|
||||
};
|
||||
|
||||
self.showColorPicker = function(){
|
||||
$('[name=colorpicker]').colorpicker({format: 'rgb'});
|
||||
}
|
||||
|
||||
self.onSettingsHidden = function(){
|
||||
self.getUpdateBtnStatus();
|
||||
};
|
||||
|
||||
self.getRegularOutputs = function(){
|
||||
return self.global_settings.settings.plugins.enclosure.rpi_outputs().filter(function(rpi_outputs) {
|
||||
return rpi_outputs.outputType == 'regular';
|
||||
});
|
||||
};
|
||||
self.setTemperature = function(){
|
||||
if(self.isNumeric($("#enclosureSetTemp").val())){
|
||||
$.ajax({
|
||||
@@ -108,8 +165,9 @@ $(function() {
|
||||
self.addRpiOutput = function(){
|
||||
self.global_settings.settings.plugins.enclosure.rpi_outputs.push({label: ko.observable("Ouput "+
|
||||
(self.global_settings.settings.plugins.enclosure.rpi_outputs().length+1)) ,
|
||||
gpioPin: 0,activeLow: true,
|
||||
autoStartup:ko.observable(false), startupTimeDelay:0, autoShutdown:ko.observable(false),shutdownTimeDelay:0});
|
||||
gpioPin:ko.observable(0),activeLow: true,
|
||||
autoStartup:ko.observable(false), startupTimeDelay:0, autoShutdown:ko.observable(false),shutdownTimeDelay:0,
|
||||
outputType:ko.observable('regular'),frequency:50,dutycycle:0,color:"rgb(255,0,0)",neopixelCount:0,neopixelBrightness:255,microAddress:0});
|
||||
};
|
||||
|
||||
self.removeRpiOutput = function(definition) {
|
||||
@@ -152,6 +210,7 @@ $(function() {
|
||||
};
|
||||
|
||||
self.getUpdateBtnStatus = function(){
|
||||
|
||||
$.ajax({
|
||||
url: "/plugin/enclosure/getUpdateBtnStatus",
|
||||
type: "GET"
|
||||
@@ -191,6 +250,47 @@ $(function() {
|
||||
});
|
||||
};
|
||||
|
||||
self.handlePWM = function(data, event){
|
||||
io = parseInt(data[0]);
|
||||
pwmVal = parseInt($("#dutycycle_"+io).val());
|
||||
if(pwmVal<0 || pwmVal>100 || isNaN(pwmVal)){
|
||||
$("#dutycycle_"+io).val('')
|
||||
new PNotify({title:"Enclosure", text:"Duty Cycle value needs to be between 0 and 100!", type: "error"});
|
||||
}else{
|
||||
// console.log(pwmVal);
|
||||
$("#dutycycle_"+io).val('')
|
||||
$("#dutycycle_"+io).attr("placeholder", pwmVal);
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
data: {"io": io, "pwmVal": pwmVal},
|
||||
url: "/plugin/enclosure/setPWM",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
self.handleNeopixel = function(data, event){
|
||||
io = parseInt(data[0]);
|
||||
tempStr = ($("#color_"+io).val()).replace("rgb(", "");
|
||||
|
||||
r = parseInt(tempStr.substring(0, tempStr.indexOf(",")));
|
||||
tempStr = tempStr.slice(tempStr.indexOf(",")+1);
|
||||
g = parseInt(tempStr.substring(0, tempStr.indexOf(",")));
|
||||
tempStr = tempStr.slice(tempStr.indexOf(",")+1);
|
||||
b = parseInt(tempStr.substring(0, tempStr.indexOf(")")));
|
||||
|
||||
if(r<0 || r>255 || g<0 || g>255 || b<0 || b >255 || isNaN(r) || isNaN(g) || isNaN(b)){
|
||||
new PNotify({title:"Enclosure", text:"Color needs to follow the format rgb(value_red,value_green,value_blue)!", type: "error"});
|
||||
}else {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
data: {"io": io, "red": r,"green": g,"blue": b},
|
||||
url: "/plugin/enclosure/setNeopixel",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
self.fixUI = function(){
|
||||
if($('#enableTemperatureReading').is(':checked')){
|
||||
$('#enableHeater').prop('disabled', false);
|
||||
@@ -267,6 +367,6 @@ $(function() {
|
||||
OCTOPRINT_VIEWMODELS.push([
|
||||
EnclosureViewModel,
|
||||
["settingsViewModel","connectionViewModel","printerStateViewModel"],
|
||||
["#tab_plugin_enclosure","#settings_plugin_enclosure"]
|
||||
["#tab_plugin_enclosure","#settings_plugin_enclosure","#navbar_plugin_enclosure"]
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user