removing old stuff

This commit is contained in:
Vitor de Miranda Henrique
2021-10-19 10:55:11 -05:00
parent 29c82f70a1
commit d299a28d6e
24 changed files with 0 additions and 4948 deletions

View File

@@ -1,82 +0,0 @@
import smbus
import time
try:
import struct
except ImportError:
import ustruct as struct
class AM2320Exception(Exception):
""" Base class for exception """
class AM2320DeviceNotFound(AM2320Exception, ValueError):
""" Device not found """
class AM2320ReadError(AM2320Exception, RuntimeError):
""" Read error or CRC mismatch """
def _crc16(data):
crc = 0xFFFF
for byte in data:
crc ^= byte
for _ in range(8):
if crc & 0x0001:
crc >>= 1
crc ^= 0xA001
else:
crc >>= 1
return crc
sensor = smbus.SMBus(1)
def getTemp(bus):
for _ in range(3):
try:
bus.write_byte(0x5C, 0x00)
except:
pass
bus.write_i2c_block_data(0x5C, 0x03, [0x02, 2])
time.sleep(0.001)
result = bytearray(bus.read_i2c_block_data(0x5C, 0x00, 6))
if result[0] != 0x3 or result[1] != 2:
raise AM2320ReadError("Command does not match returned data")
temp = struct.unpack(">H", result[2:-2])[0]
crc1 = struct.unpack("<H", bytes(result[-2:]))[0]
crc2 = _crc16(result[0:-2])
if crc1 != crc2:
raise AM2320ReadError("CRC Mismatch")
if temp >= 32768:
temp = 32768 - temp
return (temp / 10.0)
def getHumi(bus):
for _ in range(3):
try:
bus.write_byte(0x5C, 0x00)
except:
pass
bus.write_i2c_block_data(0x5C, 0x03, [0x00, 2])
time.sleep(0.001)
result = bytearray(bus.read_i2c_block_data(0x5C, 0x00, 6))
if result[0] != 0x3 or result[1] != 2:
raise AM2320ReadError("Command does not match returned data")
humi = struct.unpack(">H", result[2:-2])[0]
crc1 = struct.unpack("<H", bytes(result[-2:]))[0]
crc2 = _crc16(result[0:-2])
if crc1 != crc2:
raise AM2320ReadError("CRC Mismatch")
return (humi / 10.0)
def main():
try:
temperature = getTemp(sensor)
humidity = getHumi(sensor)
print('{0:0.1f} | {1:0.1f}'.format(temperature, humidity))
except:
print('-1 | -1')
if __name__ == "__main__":
main()

View File

@@ -1,151 +0,0 @@
import smbus
import sys
import time
from ctypes import c_short
from ctypes import c_byte
from ctypes import c_ubyte
if len(sys.argv) == 2:
DEVICE = int(sys.argv[1],16)
else:
print('-1 | -1')
sys.exit(1)
bus = smbus.SMBus(1) # Rev 2 Pi, Pi 2 & Pi 3 uses bus 1
# Rev 1 Pi uses bus 0
def getShort(data, index):
# return two bytes from data as a signed 16-bit value
return c_short((data[index+1] << 8) + data[index]).value
def getUShort(data, index):
# return two bytes from data as an unsigned 16-bit value
return (data[index+1] << 8) + data[index]
def getChar(data,index):
# return one byte from data as a signed char
result = data[index]
if result > 127:
result -= 256
return result
def getUChar(data,index):
# return one byte from data as an unsigned char
result = data[index] & 0xFF
return result
def readBME280ID(addr=DEVICE):
# Chip ID Register Address
REG_ID = 0xD0
(chip_id, chip_version) = bus.read_i2c_block_data(addr, REG_ID, 2)
return (chip_id, chip_version)
def readBME280All(addr=DEVICE):
# Register Addresses
REG_DATA = 0xF7
REG_CONTROL = 0xF4
REG_CONFIG = 0xF5
REG_CONTROL_HUM = 0xF2
REG_HUM_MSB = 0xFD
REG_HUM_LSB = 0xFE
# Oversample setting - page 27
OVERSAMPLE_TEMP = 2
OVERSAMPLE_PRES = 2
MODE = 1
# Oversample setting for humidity register - page 26
OVERSAMPLE_HUM = 2
bus.write_byte_data(addr, REG_CONTROL_HUM, OVERSAMPLE_HUM)
control = OVERSAMPLE_TEMP<<5 | OVERSAMPLE_PRES<<2 | MODE
bus.write_byte_data(addr, REG_CONTROL, control)
# Read blocks of calibration data from EEPROM
# See Page 22 data sheet
cal1 = bus.read_i2c_block_data(addr, 0x88, 24)
cal2 = bus.read_i2c_block_data(addr, 0xA1, 1)
cal3 = bus.read_i2c_block_data(addr, 0xE1, 7)
# Convert byte data to word values
dig_T1 = getUShort(cal1, 0)
dig_T2 = getShort(cal1, 2)
dig_T3 = getShort(cal1, 4)
dig_P1 = getUShort(cal1, 6)
dig_P2 = getShort(cal1, 8)
dig_P3 = getShort(cal1, 10)
dig_P4 = getShort(cal1, 12)
dig_P5 = getShort(cal1, 14)
dig_P6 = getShort(cal1, 16)
dig_P7 = getShort(cal1, 18)
dig_P8 = getShort(cal1, 20)
dig_P9 = getShort(cal1, 22)
dig_H1 = getUChar(cal2, 0)
dig_H2 = getShort(cal3, 0)
dig_H3 = getUChar(cal3, 2)
dig_H4 = getChar(cal3, 3)
dig_H4 = (dig_H4 << 24) >> 20
dig_H4 = dig_H4 | (getChar(cal3, 4) & 0x0F)
dig_H5 = getChar(cal3, 5)
dig_H5 = (dig_H5 << 24) >> 20
dig_H5 = dig_H5 | (getUChar(cal3, 4) >> 4 & 0x0F)
dig_H6 = getChar(cal3, 6)
# Wait in ms (Datasheet Appendix B: Measurement time and current calculation)
wait_time = 1.25 + (2.3 * OVERSAMPLE_TEMP) + ((2.3 * OVERSAMPLE_PRES) + 0.575) + ((2.3 * OVERSAMPLE_HUM)+0.575)
time.sleep(wait_time/1000) # Wait the required time
# Read temperature/pressure/humidity
data = bus.read_i2c_block_data(addr, REG_DATA, 8)
pres_raw = (data[0] << 12) | (data[1] << 4) | (data[2] >> 4)
temp_raw = (data[3] << 12) | (data[4] << 4) | (data[5] >> 4)
hum_raw = (data[6] << 8) | data[7]
#Refine temperature
var1 = ((((temp_raw>>3)-(dig_T1<<1)))*(dig_T2)) >> 11
var2 = (((((temp_raw>>4) - (dig_T1)) * ((temp_raw>>4) - (dig_T1))) >> 12) * (dig_T3)) >> 14
t_fine = var1+var2
temperature = float(((t_fine * 5) + 128) >> 8);
# Refine pressure and adjust for temperature
var1 = t_fine / 2.0 - 64000.0
var2 = var1 * var1 * dig_P6 / 32768.0
var2 = var2 + var1 * dig_P5 * 2.0
var2 = var2 / 4.0 + dig_P4 * 65536.0
var1 = (dig_P3 * var1 * var1 / 524288.0 + dig_P2 * var1) / 524288.0
var1 = (1.0 + var1 / 32768.0) * dig_P1
if var1 == 0:
pressure=0
else:
pressure = 1048576.0 - pres_raw
pressure = ((pressure - var2 / 4096.0) * 6250.0) / var1
var1 = dig_P9 * pressure * pressure / 2147483648.0
var2 = pressure * dig_P8 / 32768.0
pressure = pressure + (var1 + var2 + dig_P7) / 16.0
# Refine humidity
humidity = t_fine - 76800.0
humidity = (hum_raw - (dig_H4 * 64.0 + dig_H5 / 16384.0 * humidity)) * (dig_H2 / 65536.0 * (1.0 + dig_H6 / 67108864.0 * humidity * (1.0 + dig_H3 / 67108864.0 * humidity)))
humidity = humidity * (1.0 - dig_H1 * humidity / 524288.0)
if humidity > 100:
humidity = 100
elif humidity < 0:
humidity = 0
return temperature/100.0,pressure/100.0,humidity
def main():
try:
temperature,pressure,humidity = readBME280All()
print('{0:0.1f} | {1:0.1f}'.format(temperature, humidity))
except:
print('-1 | -1')
if __name__=="__main__":
main()

View File

@@ -1,49 +0,0 @@
import smbus
import time
import sys
if len(sys.argv) == 2 or len(sys.argv) == 3:
address = int(sys.argv[1],16)
if len(sys.argv) == 3:
busNum = int(sys.argv[2],16)
else:
busNum = 1
else:
print('-1 | -1')
sys.exit(1)
# Get I2C bus
bus = smbus.SMBus(busNum)
# SI7021 address, 0x40(64)
# 0xF5(245) Select Relative Humidity NO HOLD master mode
bus.write_byte(address, 0xF5)
time.sleep(0.3)
# SI7021 address, 0x40(64)
# Read data back, 2 bytes, Humidity MSB first
data0 = bus.read_byte(address)
data1 = bus.read_byte(address)
# Convert the data
humidity = ((data0 * 256 + data1) * 125 / 65536.0) - 6
time.sleep(0.3)
# SI7021 address, 0x40(64)
# 0xF3(243) Select temperature NO HOLD master mode
bus.write_byte(address, 0xF3)
time.sleep(0.3)
# SI7021 address, 0x40(64)
# Read data back, 2 bytes, Temperature MSB first
data0 = bus.read_byte(address)
data1 = bus.read_byte(address)
# Convert the data
cTemp = ((data0 * 256 + data1) * 175.72 / 65536.0) - 46.85
print('{0:0.1f} | {1:0.1f}'.format(cTemp, humidity))

File diff suppressed because it is too large Load Diff

View File

@@ -1,23 +0,0 @@
import sys
import Adafruit_DHT
# Parse command line parameters.
sensor_args = { '11': Adafruit_DHT.DHT11,
'22': Adafruit_DHT.DHT22,
'2302': Adafruit_DHT.AM2302 }
if len(sys.argv) == 3 and sys.argv[1] in sensor_args:
sensor = sensor_args[sys.argv[1]]
pin = sys.argv[2]
else:
sys.exit(1)
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin,2,0.5)
if humidity is not None and temperature is not None:
print('{0:0.1f} | {1:0.1f}'.format(temperature, humidity))
else:
print('-1 | -1')
sys.exit(1)

View File

@@ -1,143 +0,0 @@
"""
copyright 2017 Tim Richardson, github profile: https://github.com/GeekyTim
This file is part of https://github.com/GeekyTim/Open-Smart-RGB-LED-Strip-Driver-for-Raspberry-Pi
Open-Smart-RGB-LED-Strip-Driver-for-Raspberry-Pi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Open-Smart-RGB-LED-Strip-Driver-for-Raspberry-Pi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Open-Smart-RGB-LED-Strip-Driver-for-Raspberry-Pi. If not, see <http://www.gnu.org/licenses/>.
LEDStrip Class
--------------
A Python class that drives the Open-Smart RGB LED Strip from a Raspberry Pi.
Hardware Obtained from http://www.dx.com/p/full-color-rgb-led-strip-driver-module-for-arduino-blue-black-314667
Code originally developed by Philip Leder (https://github.com/schlank/Catalex-Led-Strip-Driver-Raspberry-Pi)
Pin Connections
Choose any two GPIO Pins; one to provide the Clock signal (CLK), the other the Data (DAT)
Pi Open-Smart Controller
Gnd Gnd
+5v Vcc
DAT Din
CLK Cin
Place this file in the same directory as your code.
In your code, import the file:
from ledstrip import LEDStrip
Create a new LED Strip which uses your chosen pins (CLK and DAT) with, e.g.:
CLK = 17
DAT = 18
strip = LEDStrip(CLK, DAT)
Set the colour of the LED strip with
strip.setcolor(red, green, blue):
The following methods are public:
setcolourrgb(r, g, b) - Sets the LED strip to colour rgb where r, g, b are in the range 0 to 255
setcolourwhite() - Sets the strip to white
setcolourred() - Sets the strip to Red
setcolourgreen() - Sets the strip to Green
setcolourblue() - Sets the strip to Blue
setcolouroff() - Turns the strip off
setcolourhex('hex') - Sets the LED strip to the hex colour 'hex' in range '000000' to 'FFFFFF'
"""
import time
import RPi.GPIO as GPIO
class LEDStrip:
def __init__(self, clock, data):
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
self.__clock = clock
self.__data = data
self.__delay = 0
GPIO.setup(self.__clock, GPIO.OUT)
GPIO.setup(self.__data, GPIO.OUT)
def __sendclock(self):
GPIO.output(self.__clock, False)
time.sleep(self.__delay)
GPIO.output(self.__clock, True)
time.sleep(self.__delay)
def __send32zero(self):
for x in range(32):
GPIO.output(self.__data, False)
self.__sendclock()
def __senddata(self, dx):
self.__send32zero()
for x in range(32):
if ((dx & 0x80000000) != 0):
GPIO.output(self.__data, True)
else:
GPIO.output(self.__data, False)
dx <<= 1
self.__sendclock()
self.__send32zero()
def __getcode(self, dat):
tmp = 0
if ((dat & 0x80) == 0):
tmp |= 0x02
if ((dat & 0x40) == 0):
tmp |= 0x01
return tmp
def setcolourrgb(self, red, green, blue):
dx = 0
dx |= 0x03 << 30
dx |= self.__getcode(blue)
dx |= self.__getcode(green)
dx |= self.__getcode(red)
dx |= blue << 16
dx |= green << 8
dx |= red
self.__senddata(dx)
def setcolourwhite(self):
self.setcolourrgb(255, 255, 255)
def setcolouroff(self):
self.setcolourrgb(0, 0, 0)
def setcolourred(self):
self.setcolourrgb(255, 0, 0)
def setcolourgreen(self):
self.setcolourrgb(0, 255, 0)
def setcolourblue(self):
self.setcolourrgb(0, 0, 255)
def setcolourhex(self, hex):
print('Hex')
try:
hexcolour = int(hex, 16)
red = int((hexcolour & 255 * 255 * 255) / (255 * 255))
green = int((hexcolour & 255 * 255) / 255)
blue = hexcolour & 255
self.setcolourrgb(red, green, blue)
except:
hexcolour = 0
print("Error converting Hex input (%s) a colour." % hex)
def cleanup(self):
self.setcolouroff()
GPIO.cleanup()

View File

@@ -1,27 +0,0 @@
import ctypes
import struct
import sys
import Adafruit_GPIO.SPI as SPI
import Adafruit_MAX31855.MAX31855 as MAX31855
def main():
# Get bus address if provided or use default address
SPI_DEVICE = 0
if len(sys.argv) >= 2:
SPI_DEVICE = int(sys.argv[1], 0)
if not 0 <= SPI_DEVICE <= 1:
raise ValueError("Invalid address value")
# Raspberry Pi hardware SPI configuration.
SPI_PORT = 0
sensor = MAX31855.MAX31855(spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE))
temp = sensor.readTempC()
print('{0:0.1f}'.format(temp))
if __name__ == "__main__":
main()

View File

@@ -1,67 +0,0 @@
import sys
import smbus
# default I2C address for device.
MCP9808_I2CADDR_DEFAULT = 0x18
# register addresses.
MCP9808_REG_CONFIG = 0x01
MCP9808_REG_UPPER_TEMP = 0x02
MCP9808_REG_LOWER_TEMP = 0x03
MCP9808_REG_CRIT_TEMP = 0x04
MCP9808_REG_AMBIENT_TEMP = 0x05
MCP9808_REG_MANUF_ID = 0x06
MCP9808_REG_DEVICE_ID = 0x07
MCP9808_REG_RESOLUTION = 0x08
# configuration register values.
MCP9808_REG_CONFIG_CONTCONV = 0x0000
MCP9808_REG_CONFIG_SHUTDOWN = 0x0100
MCP9808_REG_CONFIG_CRITLOCKED = 0x0080
MCP9808_REG_CONFIG_WINLOCKED = 0x0040
MCP9808_REG_CONFIG_INTCLR = 0x0020
MCP9808_REG_CONFIG_ALERTSTAT = 0x0010
MCP9808_REG_CONFIG_ALERTCTRL = 0x0008
MCP9808_REG_CONFIG_ALERTSEL = 0x0002
MCP9808_REG_CONFIG_ALERTPOL = 0x0002
MCP9808_REG_CONFIG_ALERTMODE = 0x0001
def main():
# get bus address if provided or use default address
address = MCP9808_I2CADDR_DEFAULT
if len(sys.argv) == 2:
address = int(sys.argv[1], 16)
# get I2C bus
bus = smbus.SMBus(1)
# MCP9808 address, default 0x18(24)
# configuration register, 0x01(1)
# continuous conversion mode, power-up default
config = [MCP9808_REG_CONFIG_CONTCONV, 0x00]
bus.write_i2c_block_data(address, MCP9808_REG_CONFIG, config)
# MCP9808 address, default 0x18(24)
# select resolution rgister, 0x08(8)
# resolution = +0.0625 / C, 0x03(03)
bus.write_byte_data(address, MCP9808_REG_RESOLUTION, 0x03)
# MCP9808 address, default 0x18(24)
# read data back from 0x05(5), 2 bytes
# temp MSB, TEMP LSB
data = bus.read_i2c_block_data(address, MCP9808_REG_AMBIENT_TEMP, 2)
# convert the data to 13-bits
ctemp = ((data[0] & 0x1F) * 256) + data[1]
if ctemp > 4095:
ctemp -= 8192
ctemp = ctemp * 0.0625
# ftemp = ctemp * 1.8 + 32
# output data
print('{0:0.2f}'.format(ctemp))
if __name__ == "__main__":
main()

View File

@@ -1,30 +0,0 @@
from rpi_ws281x import *
import sys
import time
LED_INVERT = False
LED_FREQ_HZ = 800000
if len(sys.argv) == 8:
LED_PIN = int(sys.argv[1])
LED_COUNT = int(sys.argv[2])
LED_BRIGHTNESS = int(sys.argv[3])
red = int(sys.argv[4])
green = int(sys.argv[5])
blue = int(sys.argv[6])
LED_DMA = int(sys.argv[7])
else:
print("fail")
sys.exit(1)
strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS)
strip.begin()
color = Color(red, green, blue)
for i in range(LED_COUNT):
strip.setPixelColor(i, color)
strip.show()
print("ok")

View File

@@ -1,30 +0,0 @@
import sys
import smbus
import time
if len(sys.argv) == 8:
LED_PIN = int(sys.argv[1])
LED_COUNT = int(sys.argv[2])
LED_BRIGHTNESS = int(sys.argv[3])
red = int(sys.argv[4])
green = int(sys.argv[5])
blue = int(sys.argv[6])
address = int(sys.argv[7],16)
else:
print("fail")
sys.exit(1)
bus = smbus.SMBus(1)
data = [LED_PIN,LED_COUNT,LED_BRIGHTNESS,red,green,blue]
bus.write_i2c_block_data(address,0, data)
# bus.write_byte(address, LED_PIN)
# bus.write_byte(address, LED_COUNT)
# bus.write_byte(address, LED_BRIGHTNESS)
# bus.write_byte(address, red)
# bus.write_byte(address, green)
# bus.write_byte(address, blue)
print("ok")

View File

@@ -1,230 +0,0 @@
/*!
* 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 */

View File

@@ -1,74 +0,0 @@
#enclosure-table {
table-layout: fixed;
width: 100%;
margin-top: 20px;
}
#enclosure-table th,
#enclosure-table td {
vertical-align: middle;
text-align: center;
}
#enclosure-table th.temperature_sensor,
#enclosure-table td.temperature_sensor {
width: 15%;
text-align: left;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
#enclosure-table th.temperature_actual,
#enclosure-table td.temperature_actual {
width: 20%;
}
#enclosure-table th.humidity_actual,
#enclosure-table td.humidity_actual {
width: 15%;
}
#enclosure-table th.temp_hum_control,
#enclosure-table td.temp_hum_control {
width: 15%;
}
#enclosure-table th.temperature_target,
#enclosure-table td.temperature_target {
width: 35%;
overflow: visible;
}
.glyphs-on {
color: blue;
text-shadow: 4px 4px 15px blue;
}
.glyphs-off {
color: red;
text-shadow: 4px 4px 15px red;
}
.enclosure-link{
text-decoration: none;
}
.enclosure-link:hover{
text-decoration: none;
}
.navbar-enclosure{
text-shadow: 0 1px 0 #ccc;
color: #333;
float: none;
padding: 10px 15px 10px;
text-decoration: none;
}
.ledstrip-div, .neopixel-div{
width: 25%;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 557 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 488 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 478 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 504 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

File diff suppressed because one or more lines are too long

View File

@@ -1,710 +0,0 @@
$(function () {
function EnclosureViewModel(parameters) {
var self = this;
self.pluginName = "enclosure";
self.settingsViewModel = parameters[0];
self.connectionViewModel = parameters[1];
self.printerStateViewModel = parameters[2];
self.rpi_outputs = ko.observableArray();
self.rpi_inputs = ko.observableArray();
self.settingsOpen = ko.observable(false);
self.settings_outputs_regular = ko.pureComputed(function () {
return ko.utils.arrayFilter(self.settingsViewModel.settings.plugins.enclosure.rpi_outputs(), function (item) {
return (item.output_type() === "regular_gpio" && !item.toggle_timer());
});
});
self.settings_possible_outputs = ko.pureComputed(function () {
return ko.utils.arrayFilter(self.settingsViewModel.settings.plugins.enclosure.rpi_outputs(), function (item) {
return ((item.output_type() === "regular_gpio" && !item.toggle_timer()) || item.output_type() === "gcode_output" || item.output_type() === "shell_output");
});
});
self.rpi_inputs_temperature_sensors = ko.pureComputed(function () {
return ko.utils.arrayFilter(self.rpi_inputs(), function (item) {
return (item.input_type() === "temperature_sensor");
});
});
self.settings_temperature_sensors = ko.pureComputed(function () {
return ko.utils.arrayFilter(self.settingsViewModel.settings.plugins.enclosure.rpi_inputs(), function (item) {
return (item.input_type() === "temperature_sensor");
});
});
self.settings_hum_sensors = ko.pureComputed(function () {
return ko.utils.arrayFilter(self.settings_temperature_sensors(), function (sensor) {
return (self.humidityCapableSensor(sensor.temp_sensor_type()));
});
});
self.use_sudo = ko.observable();
self.gcode_control = ko.observable();
self.neopixel_dma = ko.observable();
self.debug = ko.observable();
self.debug_temperature_log = ko.observable();
self.use_board_pin_number = ko.observable();
self.filament_sensor_gcode = ko.observable();
self.notification_provider = ko.observable();
self.notification_event_name = ko.observable();
self.notification_api_key = ko.observable();
self.notifications = ko.observableArray([]);
self.humidityCapableSensor = function(sensor){
if (['11', '22', '2302', 'bme280', 'am2320', 'si7021'].indexOf(sensor) >= 0){
return true;
}
return false;
};
self.isRegularOutput = function(index_id){
return_value = false;
if (typeof index_id != 'undefined'){
self.settingsViewModel.settings.plugins.enclosure.rpi_outputs().forEach(function (output) {
if (output.index_id() == index_id && output.output_type() == "regular_gpio") {
return_value = true;
return false;
}
});
}
return return_value;
};
self.linkedTemperatureControl = function(sensor_index){
return ko.pureComputed(function () {
return ko.utils.arrayFilter(self.rpi_outputs(), function (item) {
if (item.linked_temp_sensor){
return (item.linked_temp_sensor() == sensor_index && item.output_type() == "temp_hum_control");
}else{
return false;
}
});
});
};
self.calculateRowSpan = function(index_id){
span = self.linkedTemperatureControl(index_id())().length
return span == 0 ? 1 : span;
};
self.hasAnySensorWithHumidity = function(){
return_value = false;
self.rpi_inputs_temperature_sensors().forEach(function (sensor) {
if (self.humidityCapableSensor(sensor.temp_sensor_type())) {
return_value = true;
return false;
}
});
return return_value;
};
self.hasAnyNavbarOutput = function(){
return_value = false;
self.rpi_outputs().forEach(function (output) {
if ((output.output_type()=="regular_gpio" || output.output_type()=="gcode_output") && output.show_on_navbar()) {
return_value = true;
return false;
}
});
return return_value;
};
self.hasAnyNavbarTemperature = function(){
return_value = false;
self.rpi_inputs_temperature_sensors().forEach(function (sensor) {
if (sensor.temp_sensor_navbar()) {
return_value = true;
return false;
}
});
return return_value;
};
self.hasAnyTemperatureControl = function(){
return_value = false
self.rpi_outputs().forEach(function (output) {
if (output.output_type()=="temp_hum_control") {
return_value = true
return false;
}
});
return return_value;
};
self.onDataUpdaterPluginMessage = function (plugin, data) {
if (typeof plugin == 'undefined'){
return;
}
if (plugin != "enclosure") {
return;
}
if(self.settingsOpen){
return;
}
if (data.hasOwnProperty("sensor_data")) {
data.sensor_data.forEach(function (sensor_data) {
var linked_temp_sensor = ko.utils.arrayFilter(self.rpi_inputs_temperature_sensors(), function (temperature_sensor) {
return (sensor_data['index_id'] == temperature_sensor.index_id());
}).pop();
if (linked_temp_sensor){
linked_temp_sensor.temp_sensor_temp(sensor_data['temperature'])
linked_temp_sensor.temp_sensor_humidity(sensor_data['humidity'])
}
})
}
if (data.hasOwnProperty("set_temperature")) {
data.set_temperature.forEach(function (set_temperature) {
var linked_temp_control = ko.utils.arrayFilter(self.rpi_outputs(), function (temp_control) {
return (set_temperature['index_id'] == temp_control.index_id());
}).pop();
if (linked_temp_control) {
linked_temp_control.temp_ctr_set_value(set_temperature['set_temperature'])
}
})
}
if (data.hasOwnProperty("rpi_output_regular")) {
data.rpi_output_regular.forEach(function (output) {
var linked_output = ko.utils.arrayFilter(self.rpi_outputs(), function (item) {
return (output['index_id'] == item.index_id());
}).pop();
if (linked_output) {
linked_output.gpio_status(output['status'])
linked_output.auto_shutdown(output['auto_shutdown'])
linked_output.auto_startup(output['auto_startup'])
}
})
}
if (data.hasOwnProperty("rpi_output_temp_hum_ctrl")) {
data.rpi_output_temp_hum_ctrl.forEach(function (output) {
var linked_output = ko.utils.arrayFilter(self.rpi_outputs(), function (item) {
return (output['index_id'] == item.index_id());
}).pop();
if (linked_output) {
linked_output.gpio_status(output['status'])
linked_output.auto_shutdown(output['auto_shutdown'])
linked_output.auto_startup(output['auto_startup'])
}
})
}
if (data.hasOwnProperty("rpi_output_pwm")) {
data.rpi_output_pwm.forEach(function (output) {
var linked_output = ko.utils.arrayFilter(self.rpi_outputs(), function (item) {
return (output['index_id'] == item.index_id());
}).pop();
if (linked_output) {
linked_output.duty_cycle(output['pwm_value'])
linked_output.auto_shutdown(output['auto_shutdown'])
linked_output.auto_startup(output['auto_startup'])
}
})
}
if (data.hasOwnProperty("rpi_output_neopixel")) {
data.rpi_output_neopixel.forEach(function (output) {
var linked_output = ko.utils.arrayFilter(self.rpi_outputs(), function (item) {
return (output['index_id'] == item.index_id());
}).pop();
if (linked_output) {
linked_output.neopixel_color(output['color'])
linked_output.auto_shutdown(output['auto_shutdown'])
linked_output.auto_startup(output['auto_startup'])
}
})
}
if (data.hasOwnProperty("rpi_output_ledstrip")) {
data.rpi_output_ledstrip.forEach(function (output) {
var linked_output = ko.utils.arrayFilter(self.rpi_outputs(), function (item) {
return (output['index_id'] == item.index_id());
}).pop();
if (linked_output) {
linked_output.ledstrip_color(output['color'])
linked_output.auto_shutdown(output['auto_shutdown'])
linked_output.auto_startup(output['auto_startup'])
}
})
}
if (data.hasOwnProperty("filament_sensor_status")) {
data.filament_sensor_status.forEach(function (filament_sensor) {
var linked_filament_sensor = ko.utils.arrayFilter(self.rpi_inputs(), function (item) {
return (filament_sensor['index_id'] == item.index_id());
}).pop();
if (linked_filament_sensor) {
linked_filament_sensor.filament_sensor_enabled(filament_sensor['filament_sensor_enabled'])
}
})
}
if (data.is_msg) {
new PNotify({
title: "Enclosure",
text: data.msg,
type: data.msg_type
});
}
};
self.isUser = ko.computed(function () {
return self.connectionViewModel.loginState.isUser();
});
self.isOperational = ko.computed(function () {
return self.connectionViewModel.loginState.isUser() && self.printerStateViewModel.isOperational();
});
self.getCleanTemperature = function (temp) {
if (temp === undefined || isNaN(parseFloat(temp))) return "-";
if (temp < 10) return String("off");
return temp;
}
self.getDutyCycle = function (duty_cycle) {
if (duty_cycle === undefined || isNaN(parseFloat(duty_cycle))) return "-";
if (parseInt(duty_cycle) == 0) return String("off");
return duty_cycle;
}
self.bindFromSettings = function(){
self.rpi_outputs(self.settingsViewModel.settings.plugins.enclosure.rpi_outputs());
self.rpi_inputs(self.settingsViewModel.settings.plugins.enclosure.rpi_inputs());
self.use_sudo(self.settingsViewModel.settings.plugins.enclosure.use_sudo());
self.gcode_control(self.settingsViewModel.settings.plugins.enclosure.gcode_control());
self.neopixel_dma(self.settingsViewModel.settings.plugins.enclosure.neopixel_dma());
self.debug(self.settingsViewModel.settings.plugins.enclosure.debug());
self.debug_temperature_log(self.settingsViewModel.settings.plugins.enclosure.debug_temperature_log());
self.use_board_pin_number(self.settingsViewModel.settings.plugins.enclosure.use_board_pin_number());
self.filament_sensor_gcode(self.settingsViewModel.settings.plugins.enclosure.filament_sensor_gcode());
self.notification_provider(self.settingsViewModel.settings.plugins.enclosure.notification_provider());
self.notification_event_name(self.settingsViewModel.settings.plugins.enclosure.notification_event_name());
self.notification_api_key(self.settingsViewModel.settings.plugins.enclosure.notification_api_key());
self.notifications(self.settingsViewModel.settings.plugins.enclosure.notifications());
};
self.onBeforeBinding = function () {
self.bindFromSettings();
};
self.onSettingsBeforeSave = function() {
self.bindFromSettings();
};
self.onStartupComplete = function () {
self.settingsOpen = false;
};
self.onSettingsShown = function () {
self.settingsOpen = true;
};
self.showColorPicker = function () {
$('[name=colorpicker]').colorpicker({
format: 'rgb'
});
}
self.onSettingsHidden = function () {
self.showColorPicker();
self.settingsOpen = false;
};
self.getRegularOutputs = function () {
return self.rpi_outputs().filter(function (rpi_outputs) {
return rpi_outputs.output_type == 'regular_gpio';
});
};
self.setTemperature = function (item, form) {
var newSetTemperature = item.temp_ctr_new_set_value();
if (form !== undefined) {
$(form).find("input").blur();
}
if(self.isNumeric(newSetTemperature)){
var request = {set_temperature:newSetTemperature, index_id:item.index_id()};
$.ajax({
url: self.buildPluginUrl("/setEnclosureTempHum"),
type: "GET",
dataType: "json",
data: request,
success: function (data) {
item.temp_ctr_new_set_value("");
item.temp_ctr_set_value(newSetTemperature);
self.getUpdateUI();
},
error: function (textStatus, errorThrown) {
new PNotify({
title: "Enclosure",
text: "Error setting temperature",
type: "error"
});
}
});
}else{
new PNotify({
title: "Enclosure",
text: "Invalid set temperature",
type: "error"
});
}
};
self.addRpiOutput = function () {
var arrRelaysLength = self.settingsViewModel.settings.plugins.enclosure.rpi_outputs().length;
var nextIndex = arrRelaysLength == 0 ? 1 : self.settingsViewModel.settings.plugins.enclosure.rpi_outputs()[arrRelaysLength - 1].index_id() + 1;
self.settingsViewModel.settings.plugins.enclosure.rpi_outputs.push({
index_id: ko.observable(nextIndex),
label: ko.observable("Ouput " + nextIndex),
output_type: ko.observable("regular_gpio"),
shell_script: ko.observable(""),
gpio_pin: ko.observable(0),
gpio_status: ko.observable(false),
hide_btn_ui: ko.observable(false),
active_low: ko.observable(true),
pwm_temperature_linked: ko.observable(false),
toggle_timer: ko.observable(false),
toggle_timer_on: ko.observable(0),
toggle_timer_off: ko.observable(0),
startup_with_server: ko.observable(false),
auto_startup: ko.observable(false),
controlled_io: ko.observable(0),
controlled_io_set_value: ko.observable("Low"),
startup_time: ko.observable(0),
auto_shutdown: ko.observable(false),
shutdown_on_failed: ko.observable(false),
shutdown_time: ko.observable(0),
linked_temp_sensor: ko.observable(""),
alarm_set_temp: ko.observable(0),
temp_ctr_type: ko.observable("heater"),
temp_ctr_deadband: ko.observable(0),
temp_ctr_set_value: ko.observable(0),
temp_ctr_new_set_value: ko.observable(""),
temp_ctr_default_value: ko.observable(0),
temp_ctr_max_temp: ko.observable(0),
pwm_frequency: ko.observable(50),
pwm_status: ko.observable(50),
duty_cycle: ko.observable(0),
duty_a: ko.observable(0),
duty_b: ko.observable(0),
temperature_a: ko.observable(0),
temperature_b: ko.observable(0),
default_duty_cycle: ko.observable(0),
new_duty_cycle: ko.observable(""),
neopixel_color: ko.observable("rgb(0,0,0)"),
default_neopixel_color: ko.observable(""),
new_neopixel_color: ko.observable(""),
neopixel_count: ko.observable(0),
neopixel_brightness: ko.observable(255),
ledstrip_color: ko.observable("rgb(0,0,0)"),
default_ledstrip_color: ko.observable(""),
new_ledstrip_color: ko.observable(""),
ledstrip_gpio_clk: ko.observable(""),
ledstrip_gpio_dat: ko.observable(""),
microcontroller_address: ko.observable(0),
gcode: ko.observable(""),
show_on_navbar: ko.observable(false)
});
};
self.removeRpiOutput = function (data) {
self.settingsViewModel.settings.plugins.enclosure.rpi_outputs.remove(data);
};
self.addRpiInput = function () {
var arrRelaysLength = self.settingsViewModel.settings.plugins.enclosure.rpi_inputs().length;
var nextIndex = arrRelaysLength == 0 ? 1 : self.settingsViewModel.settings.plugins.enclosure.rpi_inputs()[arrRelaysLength - 1].index_id() + 1;
self.settingsViewModel.settings.plugins.enclosure.rpi_inputs.push({
index_id: ko.observable(nextIndex),
label: ko.observable("Input " + nextIndex),
input_type: ko.observable("gpio"),
gpio_pin: ko.observable(0),
input_pull_resistor: ko.observable("input_pull_up"),
temp_sensor_type: ko.observable("DS18B20"),
temp_sensor_address: ko.observable(""),
temp_sensor_temp: ko.observable(""),
temp_sensor_humidity: ko.observable(""),
ds18b20_serial: ko.observable(""),
use_fahrenheit: ko.observable(false),
action_type: ko.observable("output_control"),
controlled_io: ko.observable(""),
controlled_io_set_value: ko.observable("low"),
edge: ko.observable("fall"),
printer_action: ko.observable("filament"),
temp_sensor_navbar: ko.observable(true),
filament_sensor_timeout: ko.observable(120),
filament_sensor_enabled: ko.observable(true),
temp_sensor_i2cbus: ko.observable(1)
});
};
self.removeRpiInput = function (definition) {
self.settingsViewModel.settings.plugins.enclosure.rpi_inputs.remove(definition);
};
self.turnOffHeater = function (item) {
var request = { set_temperature: 0, index_id: item.index_id() };
$.ajax({
url: self.buildPluginUrl("/setEnclosureTempHum"),
type: "GET",
dataType: "json",
data: request,
success: function (data) {
self.getUpdateUI();
}
});
};
self.clearGPIOMode = function () {
$.ajax({
url: self.buildPluginUrl("/clearGPIOMode"),
type: "GET",
dataType: "json",
success: function (data) {
new PNotify({
title: "Enclosure",
text: "GPIO Mode cleared successfully",
type: "success"
});
}
});
};
self.getUpdateUI = function () {
$.ajax({
url: self.buildPluginUrl("/updateUI"),
type: "GET"
});
};
self.handleIO = function (item, form) {
var request = {
"status": !item.gpio_status(),
"index_id": item.index_id()
};
$.ajax({
type: "GET",
dataType: "json",
data: request,
url: self.buildPluginUrl("/setIO"),
success: function (data) {
self.getUpdateUI();
}
});
};
self.handleGcode = function (item, form) {
var request = {
"index_id": item.index_id()
};
$.ajax({
type: "GET",
dataType: "json",
data: request,
url: self.buildPluginUrl("/sendGcodeCommand")
});
};
self.handleShellOutput = function (item, form) {
var request = {
"index_id": item.index_id()
};
$.ajax({
type: "GET",
dataType: "json",
data: request,
url: self.buildPluginUrl("/sendShellCommand")
});
};
self.switchAutoStartUp = function (item) {
var request = {
"status": !item.auto_startup(),
"index_id": item.index_id()
};
$.ajax({
type: "GET",
dataType: "json",
data: request,
url: self.buildPluginUrl("/setAutoStartUp"),
success: function (data) {
self.getUpdateUI();
}
});
};
self.switchAutoShutdown = function (item) {
var request = {
"status": !item.auto_shutdown(),
"index_id": item.index_id()
};
$.ajax({
type: "GET",
dataType: "json",
data: request,
url: self.buildPluginUrl("/setAutoShutdown"),
success: function (data) {
self.getUpdateUI();
}
});
};
self.switchFilamentSensor = function (item) {
var request = {
"status": !item.filament_sensor_enabled(),
"index_id": item.index_id()
};
$.ajax({
type: "GET",
dataType: "json",
data: request,
url: self.buildPluginUrl("/setFilamentSensor"),
success: function (data) {
self.getUpdateUI();
}
});
};
self.handlePWM = function (item) {
var pwm_value = item.new_duty_cycle();
pwm_value = parseInt(pwm_value);
if (pwm_value < 0 || pwm_value > 100 || isNaN(pwm_value)) {
item.new_duty_cycle("")
new PNotify({
title: "Enclosure",
text: "Duty Cycle value needs to be between 0 and 100!",
type: "error"
});
} else {
var request = { new_duty_cycle: pwm_value, index_id: item.index_id() };
$.ajax({
type: "GET",
dataType: "json",
data: request,
url: self.buildPluginUrl("/setPWM"),
success: function (data) {
item.new_duty_cycle("");
item.duty_cycle(pwm_value);
self.getUpdateUI();
}
});
}
};
self.handleNeopixel = function (item) {
var index = item.index_id() ;
var or_tempStr = item.new_neopixel_color();
var tempStr = or_tempStr.replace("rgb(", "");
var r = parseInt(tempStr.substring(0, tempStr.indexOf(",")));
tempStr = tempStr.slice(tempStr.indexOf(",") + 1);
var g = parseInt(tempStr.substring(0, tempStr.indexOf(",")));
tempStr = tempStr.slice(tempStr.indexOf(",") + 1);
var 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: {
"index_id": index,
"red": r,
"green": g,
"blue": b
},
url: self.buildPluginUrl("/setNeopixel"),
success: function (data) {
item.new_neopixel_color("");
self.getUpdateUI();
}
});
}
};
self.handleLedstripColor = function (item) {
var index = item.index_id() ;
var or_tempStr = item.new_ledstrip_color();
var tempStr = or_tempStr.replace("rgb(", "");
var r = parseInt(tempStr.substring(0, tempStr.indexOf(",")));
tempStr = tempStr.slice(tempStr.indexOf(",") + 1);
var g = parseInt(tempStr.substring(0, tempStr.indexOf(",")));
tempStr = tempStr.slice(tempStr.indexOf(",") + 1);
var 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: {
"index_id": index,
"rgb": or_tempStr
},
url: self.buildPluginUrl("/setLedstripColor"),
success: function (data) {
item.new_ledstrip_color("");
self.getUpdateUI();
}
});
}
};
self.isNumeric = function (n) {
return !isNaN(parseFloat(n)) && isFinite(n);
};
self.buildPluginUrl = function (path) {
return window.PLUGIN_BASEURL + self.pluginName + path;
};
}
OCTOPRINT_VIEWMODELS.push({
construct: EnclosureViewModel,
// ViewModels your plugin depends on, e.g. loginStateViewModel, settingsViewModel, ...
dependencies: ["settingsViewModel", "connectionViewModel", "printerStateViewModel"],
// Elements to bind to, e.g. #settings_plugin_tasmota-mqtt, #tab_plugin_tasmota-mqtt, ...
elements: ["#tab_plugin_enclosure", "#settings_plugin_enclosure", "#navbar_plugin_enclosure_1", "#navbar_plugin_enclosure_2"]
});
});

View File

@@ -1,54 +0,0 @@
<!-- ko if: ($root.hasAnyNavbarOutput() && $root.isUser()) -->
<a href="javascript:void(0)" title="Raspberry Pi Outputs" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-codepen"></i>
<b class="caret"></b>
</a>
<ul class="dropdown-menu" data-bind="foreach: $root.rpi_outputs()">
<!-- ko if: ($data.show_on_navbar()) -->
<!-- ko if: ($data.output_type() == "regular_gpio") -->
<li>
<a href="javascript:void(0)" data-bind="click: $root.handleIO">
<span data-bind="html: label"> </span>
<!-- ko if: ($data.gpio_status()) -->
<span class="badge badge-success help-inline">on</span>
<!-- /ko -->
<!-- ko ifnot: ($data.gpio_status()) -->
<span class="badge badge-important help-inline">off</span>
<!-- /ko -->
</a>
</li>
<!-- /ko -->
<!-- ko if: ($data.output_type() == "gcode_output") -->
<!-- ko if: ($root.isOperational()) -->
<li>
<a href="javascript:void(0)" data-bind="click: $root.handleGcode">
<span data-bind="html: label"> </span>
<span class="badge badge-info">gcode</span>
</a>
</li>
<!-- /ko -->
<!-- ko ifnot: ($root.isOperational()) -->
<li>
<a href="javascript:void(0)">
<span data-bind="html: label"> </span>
<span class="badge">gcode</span>
</a>
</li>
<!-- /ko -->
<!-- /ko -->
<!-- ko if: ($data.output_type() == "shell_output") -->
<li>
<a href="javascript:void(0)" data-bind="click: $root.handleShellOutput">
<span data-bind="html: label"> </span>
<span class="badge badge-info">shell</span>
</a>
</li>
<!-- /ko -->
<!-- /ko -->
</ul>
<!-- /ko -->

View File

@@ -1,35 +0,0 @@
<!-- ko if: ($root.hasAnyNavbarTemperature() && $root.isUser()) -->
<a href="javascript:void(0)" title="Enclosure Temperatures" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-fire"></i>
<b class="caret"></b>
</a>
<ul class="dropdown-menu" data-bind="foreach: $root.rpi_inputs_temperature_sensors()">
<!-- ko if: ($data.temp_sensor_navbar()) -->
<li>
<a href="javascript:void(0)">
<span data-bind="html: label"> </span>
</a>
</li>
<li>
<a href="javascript:void(0)">
<span data-bind="text: temp_sensor_temp, attr: {title: temp_sensor_temp}"> </span>
<!-- ko if: (use_fahrenheit()) -->
<span class="add-on">&deg;F</span>
<!-- /ko -->
<!-- ko ifnot: (use_fahrenheit()) -->
<span class="add-on">&deg;C</span>
<!-- /ko -->
</a>
</li>
<!-- ko if: ($root.humidityCapableSensor(temp_sensor_type())) -->
<li>
<a href="javascript:void(0)">
<span data-bind="text: temp_sensor_humidity, attr: {title: temp_sensor_humidity}"> </span>
<span class="add-on">%</span>
</a>
</li>
<!-- /ko -->
<!-- /ko -->
</ul>
<!-- /ko -->

View File

@@ -1,912 +0,0 @@
<h4>{{ _('Raspberry Pi Outputs') }}</h4>
<p>
Configure all
<strong>outputs</strong>. Outputs can be everything that do actions based on UI button presses or automatic events or alarms.
</p>
<p>
Example of possible outputs are gpio pins, neopixel LED's, temperature control or sending gcode to the printer.
</p>
<form class="form-horizontal">
<div data-bind="foreach: settingsViewModel.settings.plugins.enclosure.rpi_outputs">
<!-- <div class="controls">
<h5>IO <span data-bind="text: $index"> </span></h5>
</div> -->
<div class="control-group">
<label class="control-label">{{ _('Output Type') }}</label>
<div class="controls">
<label class="radio">
<input type="radio" value="regular_gpio" data-bind="checked: output_type, attr: {name: 'output_type_' + $index() }"> {{ _('Regular IO') }}
</label>
</div>
<div class="controls">
<label class="radio">
<input type="radio" value="pwm" data-bind="checked: output_type, attr: {name: 'output_type_' + $index() }"> {{ _('PWM') }}
</label>
</div>
<div class="controls">
<label class="radio">
<input type="radio" value="neopixel_indirect" data-bind="checked: output_type, attr: {name: 'output_type_' + $index() }"> {{ _('NeoPixel Indirect') }}
</span>
</label>
</div>
<div class="controls">
<label class="radio">
<input type="radio" value="neopixel_direct" data-bind="checked: output_type, attr: {name: 'output_type_' + $index() }"> {{ _('NeoPixel Direct') }}
</span>
</label>
</div>
<div class="controls">
<label class="radio">
<input type="radio" value="ledstrip" data-bind="checked: output_type, attr: {name: 'output_type_' + $index() }"> {{ _('RGB LED Strip') }}
</span>
</label>
</div>
<div class="controls">
<label class="radio">
<input type="radio" value="temp_hum_control" data-bind="checked: output_type, attr: {name: 'output_type_' + $index() }"> {{ _('Temperature / Humidity Control') }}
</span>
</label>
</div>
<div class="controls">
<label class="radio">
<input type="radio" value="temperature_alarm" data-bind="checked: output_type, attr: {name: 'output_type_' + $index() }"> {{ _('Temperature Alarm') }}
</span>
</label>
</div>
<div class="controls">
<label class="radio">
<input type="radio" value="gcode_output" data-bind="checked: output_type, attr: {name: 'output_type_' + $index() }"> {{ _('Gcode') }}
</span>
</label>
</div>
<div class="controls">
<label class="radio">
<input type="radio" value="shell_output" data-bind="checked: output_type, attr: {name: 'output_type_' + $index() }"> {{ _('Shell Script') }}
</span>
</label>
</div>
</div>
<!-- ko if: ($data.output_type() != "temperature_alarm") -->
<div class="control-group">
<label class="control-label">{{ _('Label') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: label">
<span class="help-inline">Name displayed on Enclosure Tab</span>
</div>
</div>
<!-- /ko -->
<div class="control-group">
<label class="control-label">{{ _('Id') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: index_id" disabled="true">
<span class="help-inline">Id used for API control</span>
</div>
</div>
<!-- ko if: ($data.output_type() == "shell_output") -->
<div class="control-group">
<label class="control-label">{{ _('Script') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: shell_script">
<span class="help-inline">Shell script to be executed</span>
</div>
</div>
<!-- /ko -->
<!-- ko ifnot: ($data.output_type() == "gcode_output" || $data.output_type() == "temperature_alarm" || $data.output_type() == "shell_output" || $data.output_type() == "ledstrip") -->
<div class="control-group">
<label class="control-label">{{ _('IO Number') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: gpio_pin">
<!-- ko ifnot: ($data.output_type() == "neopixel_indirect") -->
<span class="help-inline">GPIO number that will be controlled.</span>
<!-- /ko -->
<!-- ko if: ($data.output_type() == "neopixel_indirect") -->
<span class="help-inline">
<span class="label label-danger">Attention</span> Neopixel requires a microcontroller (ex: arduino)
connected to I2C bus. This is the pin on the
microcontroller that is connected to the Neopixel.
</span>
<!-- /ko -->
</div>
</div>
<!-- /ko -->
<!-- ko if: ($data.output_type() == "pwm" ) -->
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: pwm_temperature_linked"> {{ _('Link PWM to Temperature') }}
</label>
<span class="help-inline">Link PWM output to temperature. PWM output will be interpolated between the point from duty A, temperature A -> duty
B, temperature B. This output will automatically start when a print starts and will default to the default
duty cycle when print is complete.
</span>
</div>
</div>
<!-- /ko -->
<!-- ko if: ($data.output_type() == "pwm" && $data.pwm_temperature_linked()) -->
<div class="control-group">
<label class="control-label">{{ _('Duty A') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: duty_a">
</div>
</div>
<div class="control-group">
<label class="control-label">{{ _('Temperature A') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: temperature_a">
</div>
</div>
<div class="control-group">
<label class="control-label">{{ _('Duty B') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: duty_b">
</div>
</div>
<div class="control-group">
<label class="control-label">{{ _('Temperature B') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: temperature_b">
</div>
</div>
<!-- /ko -->
<!-- ko if: ($data.output_type() == "regular_gpio" || ($data.output_type() == "pwm" && !$data.pwm_temperature_linked()) ) -->
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: toggle_timer"> {{ _('Timer Toggle') }}
</label>
<span class="help-inline">Toggle output every amount of seconds. It will start when the print starts and stop when print is complete. For
PWM pins it will use the default PWM value when ON.
</span>
</div>
</div>
<!-- ko if: ($data.toggle_timer()) -->
<div class="control-group">
<label class="control-label">{{ _('On Time') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: toggle_timer_on">
<span class="help-inline">Time in seconds that the GPIO will remain ON</span>
</div>
</div>
<div class="control-group">
<label class="control-label">{{ _('Off Time') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: toggle_timer_off">
<span class="help-inline">Time in seconds that the GPIO will remain when OFF</span>
</div>
</div>
<!-- /ko -->
<!-- /ko -->
<!-- ko ifnot: (($data.output_type() == "regular_gpio" || $data.output_type() == "pwm") && $data.toggle_timer()) -->
<!-- ko ifnot: ($data.output_type() == "gcode_output" || $data.output_type() == "temperature_alarm" || $data.output_type() == "shell_output") -->
<!-- ko ifnot: ($data.output_type() == "pwm" && $data.pwm_temperature_linked()) -->
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: startup_with_server"> {{ _('Start with server') }}
</label>
<span class="help-inline">Choose if output should turn on automatically when octoprint starts</span>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: auto_startup"> {{ _('Auto Startup') }}
</label>
<span class="help-inline">Choose if output should turn on automatically when print starts</span>
</div>
</div>
<!-- /ko -->
<!-- ko if: $data.auto_startup -->
<div data-bind="attr: {id: 'auto_startupField_' + $index() }">
<div class="control-group">
<label class="control-label">{{ _('Startup Delay / Hour') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: startup_time">
<span class="help-inline">Time delay in seconds to turn on GPIO when print starts OR exact time that the event should happen, note that
events will only be scheduled after a print starts, time should be formatted as HH:MM on a 24 hours format, don't
forget to check timezone of your Raspberry Pi.</span>
</div>
</div>
</div>
<!-- /ko -->
<!-- /ko -->
<!-- ko ifnot: ($data.output_type() == "gcode_output" || $data.output_type() == "temperature_alarm" || $data.output_type() == "shell_output") -->
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: auto_shutdown"> {{ _('Auto Shutdown') }}
</label>
<span class="help-inline">Choose if output should turn off automatically when print finishes</span>
</div>
</div>
<!-- /ko -->
<!-- ko if: $data.auto_shutdown -->
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: shutdown_on_failed"> {{ _('Shutdown on Failed or Canceled') }}
</label>
<span class="help-inline">Choose if output should turn off automatically when print is canceled or fails</span>
</div>
</div>
<div data-bind="attr: {id: 'auto_shutdownField_' + $index() }">
<div class="control-group">
<label class="control-label">{{ _('Shutdown Delay / Hour') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: shutdown_time">
<span class="help-inline">Time delay in seconds to turn on GPIO when print starts OR exact time that the event should happen, note that
events will only be scheduled after a print starts, time should be formatted as HH:MM on a 24 hours format, don't
forget to check timezone of your raspberry pi.</span>
<span class="label label-important">Attention</span>
<span> Hour schedule does not work with
<b>Link PWM to Temperature</b> option</span>
</div>
</div>
</div>
<!-- /ko -->
<!-- /ko -->
<!-- ko if: ($data.output_type() == "regular_gpio" || $data.output_type() == "temp_hum_control" ) -->
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: active_low"> {{ _('Active Low') }}
</label>
<span class="help-inline">Active low means that the GPIO will turn on when receive a low signal (ground) from Raspberry PI</span>
</div>
</div>
<!-- /ko -->
<!-- ko if: ($data.output_type() == "regular_gpio" || $data.output_type() == "gcode_output" || $data.output_type() == "shell_output" || $data.output_type() == "ledstrip") -->
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: hide_btn_ui"> {{ _('Hide UI Button') }}
</label>
<span class="help-inline">If you plan to use a physical button (INPUT) and want to hide the button from enclosure tab check this.</span>
</div>
</div>
<!-- ko ifnot: ($data.output_type() == "ledstrip") -->
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: show_on_navbar"> {{ _('Show Button on Navbar') }}
</label>
<span class="help-inline">Add shortcut on navbar to toggle output</span>
</div>
</div>
<!-- /ko -->
<!-- /ko -->
<!-- ko if: ($data.output_type() == "temperature_alarm" || $data.output_type() == "temp_hum_control" || ($data.output_type() == "pwm" && $data.pwm_temperature_linked())) -->
<!-- ko if: ($data.temp_ctr_type() == "heater" || $data.temp_ctr_type() == "cooler" || ($data.output_type() == "pwm" && $data.pwm_temperature_linked())) -->
<div class="control-group">
<label class="control-label">Temperature Sensor</label>
<div class="controls">
<select data-bind="options: $root.settings_temperature_sensors, optionsText: 'label',
optionsValue: 'index_id', value: $data.linked_temp_sensor">
</select>
<span class="help-inline">Temperature sensor responsible for getting the value to be used. Configured on the input side of the plugin.</span>
</div>
</div>
<!-- /ko -->
<!-- ko if: ($data.temp_ctr_type() == "dehumidifier") -->
<div class="control-group">
<label class="control-label">Temperature Sensor</label>
<div class="controls">
<select data-bind="options: $root.settings_hum_sensors, optionsText: 'label',
optionsValue: 'index_id', value: $data.linked_temp_sensor">
</select>
<span class="help-inline">Temperature sensor responsible for getting the value to be used. Configured on the input side of the plugin.</span>
</div>
</div>
<!-- /ko -->
<!-- /ko -->
<!-- ko if: ($data.output_type() == "temp_hum_control") -->
<div class="control-group">
<label class="control-label">{{ _('Temp Control Type') }}</label>
<div class="controls">
<label class="radio">
<input type="radio" value="heater" name="apt_temp_radio" data-bind="checked: temp_ctr_type"> {{ _('Heater') }}</label>
</div>
<div class="controls">
<label class="radio">
<input type="radio" value="cooler" name="apt_temp_radio" data-bind="checked: temp_ctr_type"> {{ _('Cooler') }}</label>
</div>
<div class="controls">
<label class="radio">
<input type="radio" value="dehumidifier" name="apt_temp_radio" data-bind="checked: temp_ctr_type"> {{ _('Dehumidifier') }}</label>
</div>
</div>
<!-- ko if: ($data.auto_startup() || $data.startup_with_server())-->
<div class="control-group">
<label class="control-label">{{ _('Default Value') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: temp_ctr_default_value">
<span class="help-inline">Default temperature / humidity that temperature control will be set when the print starts or the server starts.</span>
</div>
</div>
<!-- /ko -->
<div class="control-group">
<label class="control-label">{{ _('Value Deadband') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: temp_ctr_deadband">
<span class="help-inline">Allowable drift on temperature / humidity control. Set it to zero to disable.</span>
</div>
</div>
<!-- ko if: ($data.temp_ctr_type() == "heater") -->
<div class="control-group">
<label class="control-label">{{ _('Maximum Temperature') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: temp_ctr_max_temp">
<span class="help-inline">Maximum temperature that the enclosure should reach, if this temperature is hit, the heater will be disabled until
it's set temperature is set again.</span>
</div>
</div>
<!-- /ko -->
<!-- /ko -->
<!-- ko if: ($data.output_type() == "temperature_alarm") -->
<div data-bind="attr: {id: 'temp_controlled_' + $index() }">
<div class="control-group">
<label class="control-label">{{ _('Set Temperature') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: alarm_set_temp">
<span class="help-inline">Set temperature that will trigger the event</span>
</div>
</div>
<div class="control-group">
<label class="control-label"> Controlled IO</label>
<div class="controls">
<select data-bind="options: $root.settings_outputs_regular, optionsText: 'label',
optionsValue: 'index_id', value: $data.controlled_io">
</select>
<span class="help-inline">When the event happen, you want control which IO?</span>
</div>
</div>
<div class="control-group">
<label class="control-label">Set Controlled IO Value</label>
<div class="controls">
<select data-bind="value: controlled_io_set_value">
<option value="low">Low</option>
<option value="high">High</option>
</select>
<span class="help-inline">When the event happen, you want to turn the controlled IO HIGH or LOW?</span>
</div>
</div>
</div>
<!-- /ko -->
<!-- ko if: ($data.output_type() == "pwm") -->
<div class="control-group">
<label class="control-label">{{ _('PWM Frequency') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: pwm_frequency">
<span class="help-inline">Value is in Hz</span>
</div>
</div>
<div class="control-group">
<label class="control-label">{{ _('Default Duty Cycle') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: default_duty_cycle">
<span class="help-inline">Value is in percentage, between 0 and 100</span>
</div>
</div>
<!-- /ko -->
<!-- ko if: ($data.output_type() == "neopixel_indirect") -->
<div class="control-group">
<label class="control-label" for="settings-enclosure-dhtPin">{{ _('Microcontroller Address') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: microcontroller_address">
<span class="help-inline">Microcontroller address in HEX value, you can find it by running
<code>i2cdetect -y 1</code> on your Raspberry Pi</span>
</div>
</div>
<!-- /ko -->
<!-- ko if: ($data.output_type() == "ledstrip") -->
<div class="control-group">
<label class="control-label">{{ _('CLK') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: ledstrip_gpio_clk">
<span class="help-inline">Choose any GPIO pin to provide the Clock signal</span>
</div>
<label class="control-label">{{ _('DAT') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: ledstrip_gpio_dat">
<span class="help-inline">Choose any GPIO pin to provide the Data</span>
</div>
</div>
<div class="control-group">
<label class="control-label">{{ _('Color') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: default_ledstrip_color, attr: {name: 'colorpicker' } , click: $root.showColorPicker()">
<span class="help-inline">Value needs to follow the format rgb(value_red,value_green,value_blue) where values should be between 0 and 255</span>
</div>
</div>
<!-- /ko -->
<!-- ko if: ($data.output_type() == "neopixel_indirect" || $data.output_type() == "neopixel_direct") -->
<div class="control-group">
<label class="control-label">{{ _('Number of LED's') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: neopixel_count">
<span class="help-inline">Number of led's on strip</span>
</div>
</div>
<div class="control-group">
<label class="control-label">{{ _('Brightness') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: neopixel_brightness">
<span class="help-inline">Value between 0 and 255</span>
</div>
</div>
<div class="control-group">
<label class="control-label">{{ _('Default Color') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: default_neopixel_color, attr: {name: 'colorpicker' } , click: $root.showColorPicker()">
<span class="help-inline">Value needs to follow the format rgb(value_red,value_green,value_blue) where values should be between 0 and 255</span>
</div>
</div>
<!-- /ko -->
<!-- ko if: ($data.output_type() == "gcode_output") -->
<div class="control-group">
<label class="control-label" for="settings-enclosure-filament-sensor">{{ _('Gcode') }}</label>
<div class="controls">
<textarea rows="4" class="block" data-bind="value: gcode"></textarea>
<span class="help-inline">GCODE that will be sent to the printer. You should add
<code>ENTER</code> on the end of every line sent to the printer</span>
</div>
</div>
<!-- /ko -->
<div class="control-group">
<a title="Delete IO" class="btn btn-danger pull-right" data-bind="click: function() { $parent.removeRpiOutput($data) }">
<i class="icon-trash"></i>
</a>
</div>
<div class="control-group">
<div class="controls">
<hr/>
</div>
</div>
</div>
<div class="control-group">
<button class="btn pull-right" data-bind="click: function() { $root.addRpiOutput(); }">Add Outputs...</button>
</div>
</form>
<h4>{{ _('Raspberry Pi Inputs') }}</h4>
<p>
Configure all
<strong>inputs</strong>. Inputs get data from gpio or connected sensors to provide additional functionality. Inputs can control
outputs or influence how they behave.
</p>
<p>
Example of possible inputs are buttons connected to GPIO pins that control outputs or printer events, temperature and humidity
sensors, and filament sensors.
</p>
<form class="form-horizontal">
<div data-bind="foreach: settingsViewModel.settings.plugins.enclosure.rpi_inputs">
<div class="control-group">
<label class="control-label">{{ _('Label') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: label">
<span class="help-inline">Name of Input</span>
</div>
</div>
<div class="control-group">
<label class="control-label">{{ _('Input Type') }}</label>
<div class="controls">
<input type="radio" value="gpio" data-bind="checked: input_type, attr: {name: 'inputType_' + $index() }"> {{ _('GPIO Input') }}
</div>
<div class="controls">
<input type="radio" value="temperature_sensor" data-bind="checked: input_type, attr: {name: 'inputType_' + $index() }"> {{ _('Temperature Sensor') }}
</div>
<div class="control-group">
<div class="controls">
<!-- ko if: ($data.input_type() == "gpio") -->
<span class="help-inline">
<span class="label label-info">Info:</span> GPIO will input status of the pin, HIGH / LOW </span>
<!-- /ko -->
<!-- ko if: ($data.input_type() == "temperature_sensor") -->
<span class="help-inline">
<span class="label label-info">Info:</span> Temperature Sensors will input temperature and humidity data.
</span>
<!-- /ko -->
</div>
</div>
</div>
<!-- ko if: ($data.input_type() == "temperature_sensor") -->
<div id="temperature_reading_content">
<div class="control-group">
<label class="control-label" for="settings-enclosure-dhtModel">{{ _('Sensor Type') }}</label>
<div class="controls">
<select data-bind="value: temp_sensor_type">
<option value="">Select Sensor</option>
<option value="11">DHT11</option>
<option value="22">DHT22</option>
<option value="2302">AM2302</option>
<option value="18b20">DS18B20</option>
<option value="si7021">SI7021</option>
<option value="bme280">BME280</option>
<option value="am2320">AM2320</option>
<option value="tmp102">TMP102</option>
<option value="max31855">MAX31855</option>
<option value="mcp9808">MCP9808</option>
</select>
<span class="help-inline">
<span class="label label-important">Attention</span> You need to install and configure the necessary libraries for the temperature sensor, check
the documentation on
<a href=" https://github.com/vitormhenrique/OctoPrint-Enclosure">github</a> page</span>
</div>
</div>
<!-- ko if: ($data.temp_sensor_type() == "18b20") -->
<div class="control-group">
<label class="control-label" for="settings-enclosure-dhtPin">{{ _('Sensor Pin') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: gpio_pin" value="4">
<span class="help-inline">GPIO pin for temperature sensor, recommended to use 4 as DS18B20 has default support to pin #4 (BCM)</span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="settings-enclosure-dhtPin">{{ _('DS18B20 Serial') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: ds18b20_serial" value="">
<span class="help-inline">DS18B20 serial value, needs to be used to have support for multiple sensors, read documentation on github page
for more information. The serial is typically in the form of 28-0123456789ab.</span>
</div>
</div>
<!-- /ko -->
<!-- ko if: ($data.temp_sensor_type() == "si7021") || ($data.temp_sensor_type() == "bme280") || ($data.temp_sensor_type() == "am2320") || ($data.temp_sensor_type() == "tmp102") || ($data.temp_sensor_type() == "mcp9808") -->
<div class="control-group">
<label class="control-label" for="settings-enclosure-dhtPin">{{ _('Sensor Pin') }}</label>
<div class="controls">
<input type="text" class="input-block-level" value="SCL / SDA" disabled="true">
<span class="help-inline">GPIO pin for temperature sensor need to connect the sensor to I2C. SCL Clock to GPIO 3 (SCL) and SDA Data to GPIO
2 (SDA)
</span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="settings-enclosure-dhtPin">{{ _('Sensor Address') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: temp_sensor_address">
<span class="help-inline">Sensor address in HEX value, you can find it by running
<code>i2cdetect -y 1</code> on your Raspberry Pi</span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="settings-enclosure-dhtPin">{{ _('i2c Bus') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: temp_sensor_i2cbus">
<span class="help-inline">This value should remain 1 unless you've used dtoverlay=i2c-gpio.
</span>
</div>
</div>
<!-- /ko -->
<!-- ko if: ($data.temp_sensor_type() == "max31855") -->
<div class="control-group">
<label class="control-label" for="settings-enclosure-dhtPin">{{ _('Sensor Pin') }}</label>
<div class="controls">
<input type="text" class="input-block-level" value="MISO / SCLK" disabled="true">
<span class="help-inline">GPIO pin for temperature sensor need to connect the sensor to SPI. Serial Clock to GPIO 1 (SCLK) and Master In/Slave Out Data to GPIO
9 (MISO)
</span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="settings-enclosure-dhtPin">{{ _('Sensor Address (CE Select)') }}</label>
<div class="controls">
<select data-bind="value: temp_sensor_address">
<option value="">Select CE</option>
<option value="0">CE0</option>
<option value="1">CE1</option>
</select>
<span class="help-inline">CE select: CE0 on GPIO 8 or CE1 on GPIO 7</span>
</div>
</div>
<!-- /ko -->
<!-- ko ifnot: ($data.temp_sensor_type() == "18b20") || ($data.temp_sensor_type() == "si7021") || ($data.temp_sensor_type() == "bme280") || ($data.temp_sensor_type() == "am2320") || ($data.temp_sensor_type() == "tmp102") || ($data.temp_sensor_type() == "max31855") || ($data.temp_sensor_type() == "mcp9808") -->
<div class="control-group">
<label class="control-label" for="settings-enclosure-dhtPin">{{ _('Sensor Pin') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: gpio_pin">
<span class="help-inline">GPIO pin for temperature sensor, recommended to use 4 as DS18B20 only works on pin 4</span>
</div>
</div>
<!-- /ko -->
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: use_fahrenheit"> {{ _('Use Fahrenheit Unit') }}
</label>
<span class="help-inline">Choose if you want to work with Celsius or Fahrenheit</span>
</div>
</div>
<!-- /ko -->
<!-- ko if: ($data.input_type() == "gpio") -->
<div class="control-group">
<label class="control-label">{{ _('Action Type') }}</label>
<div class="controls">
<input type="radio" value="output_control" data-bind="checked: action_type, attr: {name: 'actionType_' + $index() }"> {{ _('Output Control') }}
</div>
<div class="controls">
<input type="radio" value="printer_control" data-bind="checked: action_type, attr: {name: 'actionType_' + $index() }"> {{ _('Printer') }}
</div>
<div class="control-group">
<div class="controls">
<!-- ko if: ($data.action_type() == "printer_control") -->
<span class="help-inline">
<span class="label label-info">Info:</span> PRINTER actions when a condition is met, that can be a filament sensor, button, etc. Actions can
be Pause \ Resume \ Cancel a printer_control job, change the filament or disable Temperature Control. You can
use the "change filament" action and set up the input GPIO according to your sensor, for example, if your filament
sensor connects to ground when detects the end of the filament, you should choose PULL UP resistors and detect
the event on the falling edge.</span>
<!-- /ko -->
<!-- ko if: ($data.action_type() == "output_control") -->
<span class="help-inline">
<span class="label label-info">Info:</span> Action will control GPIO outputs when a condition is met, for example detect a press of a button.
You can use this to control any previous configured OUTPUTS, basically being able to control your lights / fan
/ printer using mechanical buttons buttons instead of the octoprint interface. You can only control REGULAR outputs.
</span>
<!-- /ko -->
</div>
</div>
</div>
<!-- /ko -->
<!-- ko if: ($data.input_type() == "gpio") -->
<div data-bind="attr: {id: 'input_io_' + $index() }">
<div class="control-group">
<label class="control-label" for="settings-enclosure-io1">{{ _('Input IO Number') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: gpio_pin">
<span class="help-inline">Input GPIO that will detect the event that should trigger the action. For example if you have a filament sensor
you put the GPIO pin that the sensor is connected. This can also be a press of a button or any other signal that
you want to detect. You can not use GPIO 4 here if you are using temperature sensor DS18B20</span>
</div>
</div>
<div class="control-group">
<label class="control-label">Input Pull Resistor</label>
<div class="controls">
<select data-bind="value: input_pull_resistor">
<option value="input_pull_up">Input Pull-up</option>
<option value="input_pull_down">Input Pull-down</option>
</select>
<span class="help-inline">Choose what type of pull resistors that you want on the output. If you signal is active low, that means it should
run the action when receive a low signal (ground), you should choose PULL UP resistors.</span>
</div>
</div>
<div class="control-group">
<label class="control-label">Event Trigger</label>
<div class="controls">
<select data-bind="value: edge">
<option value="rise">Rise</option>
<option value="fall">Fall</option>
</select>
<span class="help-inline">Do you want trigger the event on the rise or falling edge? If you signal is active low, that means it should run
the action when receive a low signal (ground), you should choose FALLING EDGE.</span>
</div>
</div>
</div>
<!-- ko if: ($data.action_type() == "output_control") -->
<div class="control-group">
<label class="control-label"> Controlled IO</label>
<div class="controls">
<select data-bind="options: $root.settings_possible_outputs, optionsText: 'label',
optionsValue: 'index_id', value: $data.controlled_io">
</select>
<span class="help-inline">When the event happen, you want control which OUTPUT?</span>
</div>
</div>
<!-- ko if: ($root.isRegularOutput($data.controlled_io())) -->
<div class="control-group">
<label class="control-label">Set Controlled IO Value</label>
<div class="controls">
<select data-bind="value: controlled_io_set_value">
<option value="low">Low</option>
<option value="high">High</option>
<option value="toggle">Toggle</option>
</select>
<span class="help-inline">When the event happen, you want to turn the controlled IO HIGH or LOW?</span>
</div>
</div>
<!-- /ko -->
<!-- /ko -->
<!-- ko if: ( $data.action_type() == "printer_control") -->
<div class="control-group">
<label class="control-label">{{ _('Printer Action') }}</label>
<div class="controls">
<select data-bind="value: printer_action">
<option value="filament">Filament Change</option>
<option value="resume">Printer Resume</option>
<option value="pause">Printer Pause</option>
<option value="cancel">Printer Cancel</option>
<option value="start">Start Print</option>
<option value="toggle">Printer Toggle (Connect / Pause / Resume)</option>
<option value="toggle_job">Job Toggle (Connect / Start / Cancel)</option>
<option value="stop_temp_hum_control">Stop Temperature Control</option>
</select>
<span class="help-inline"> You can use filament change on your filament detectors and add buttons to resume and pause the print job.</span>
</div>
</div>
<!-- ko if: ($data.printer_action() == "filament") -->
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: filament_sensor_enabled"> {{ _('Enable') }}
</label>
<span class="help-inline">Enable and disable filament sensors</span>
</div>
</div>
<div class="control-group">
<label class="control-label">{{ _('Filament detection timeout') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: filament_sensor_timeout">
<span class="help-inline">Time in seconds that filament sensor will be inactive after sensing end of filament. This is to avoid sending multiple
commands to the printer.
</span>
</div>
</div>
<!-- /ko -->
<!-- /ko -->
<!-- /ko -->
<!-- ko if: ($data.input_type() == "temperature_sensor") -->
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: temp_sensor_navbar"> {{ _('Show temperature on navbar') }}
</label>
<span class="help-inline">Enable and disable temperature on navbar</span>
</div>
</div>
<!-- /ko -->
<div class="control-group">
<a title="Delete IO" class="btn btn-danger pull-right" data-bind="click: function() { $parent.removeRpiInput($data) }">
<i class="icon-trash"></i>
</a>
</div>
<div class="control-group">
<div class="controls">
<hr/>
</div>
</div>
</div>
<div class="control-group">
<button class="btn pull-right" data-bind="click: function() { $root.addRpiInput(); }">Add Inputs...</button>
</div>
</form>
<form class="form-horizontal">
<a href="#" class="muted" data-toggle="collapse" data-target="#advanced_enclosure">
<i class="icon-caret-right"></i>
Advanced options
</a>
<div id="advanced_enclosure" class="accordion-body collapse">
<form class="form-horizontal">
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: settingsViewModel.settings.plugins.enclosure.use_sudo"> {{ _('Use SUDO') }}
</label>
<span class="help-inline">Use sudo to run python commands.</span>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: settingsViewModel.settings.plugins.enclosure.gcode_control"> {{ _('Enable gcode control') }}
</label>
<span class="help-inline">Use gcode to control outputs, check the documentation on
<a href=" https://github.com/vitormhenrique/OctoPrint-Enclosure">github</a> page</span>
</div>
</div>
<div class="control-group">
<label class="control-label">{{ _('Neopixel DMA Channel') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: settingsViewModel.settings.plugins.enclosure.neopixel_dma">
<span class="help-inline">DMA channel used on direct control of neopixel.</span>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: settingsViewModel.settings.plugins.enclosure.debug"> {{ _('Enable debug info') }}
</label>
<span class="help-inline">Log additional information on octoprint log to help trouble shoot the plugin</span>
</div>
</div>
<!-- ko if: ($root.debug()) -->
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: settingsViewModel.settings.plugins.enclosure.debug_temperature_log"> {{ _('Enable temperature debug info') }}
</label>
<span class="help-inline">Log additional temperature readings on octoprint log to help trouble shoot the plugin</span>
</div>
</div>
<!-- /ko -->
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: settingsViewModel.settings.plugins.enclosure.use_board_pin_number"> {{ _('Use Board Pin #') }}
</label>
<span class="help-inline">Use BOARD pin numbers instead of BCM pin numbers</span>
</div>
</div>
<div class="control-group">
<div class="controls">
<button class="btn" data-bind="click: function() { $root.clearGPIOMode(); }">Clear GPIO Mode</button>
<span class="help-inline">This will clear any GPIO configuration that might exist on your system, use with caution, it might break other
plugins that use GPIO</span>
</div>
</div>
<div class="control-group">
<label class="control-label">{{ _('Filament Change Gcode') }}</label>
<div class="controls">
<textarea rows="4" class="block" data-bind="value: settingsViewModel.settings.plugins.enclosure.filament_sensor_gcode"></textarea>
<span class="help-inline">GCODE that will be sent to the printer to pause and allow filament to be changed. You should add
<code>ENTER</code> on the end of every line sent to the printer</span>
</div>
</div>
<div class="control-group">
<label class="control-label">{{ _('Notification Provider') }}</label>
<div class="controls">
<select data-bind="value: settingsViewModel.settings.plugins.enclosure.notification_provider">
<option value="disabled">Disabled</option>
<option value="ifttt">IFTTT</option>
</select>
</div>
</div>
<!-- ko if: ($root.settingsViewModel.settings.plugins.enclosure.notification_provider() == "ifttt") -->
<div class="control-group">
<label class="control-label">{{ _('Event Name') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: settingsViewModel.settings.plugins.enclosure.notification_event_name">
<span class="help-inline">Event name that was configured on the maker chanel of IFTTT, don't use space between the words</span>
</div>
</div>
<div class="control-group">
<label class="control-label">{{ _('IFTTT API KEY') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: settingsViewModel.settings.plugins.enclosure.notification_api_key">
</div>
</div>
<div class="control-group" data-bind="foreach: settingsViewModel.settings.plugins.enclosure.notifications">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: temperatureAction"> {{ _('Notify temperature actions') }}
</label>
</div>
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: printer_action"> {{ _('Notify printer actions') }}
</label>
</div>
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: gpioAction"> {{ _('Notify gpio actions') }}
</label>
</div>
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: filamentChange"> {{ _('Notify filament change') }}
</label>
</div>
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: printFinish"> {{ _('Notify finish prints') }}
</label>
</div>
</div>
<!-- /ko -->
</form>
</div>

View File

@@ -1,318 +0,0 @@
<!-- <pre data-bind="text: ko.toJSON($root.rpi_outputs(), null, 2)"></pre> -->
<!-- ko if: ($root.rpi_inputs_temperature_sensors().length > 0) -->
<div class="row-fluid">
<h4>Temperature</h4>
<!-- <pre data-bind="text: ko.toJSON($root.rpi_inputs_temperature_sensors(), null, 2)"></pre> -->
<table id="enclosure-table" class="table table-bordered table-hover">
<tbody>
<tr>
<th class="temperature_sensor"></th>
<th class="temperature_actual" title="{{ _('Current actual temperature as reported by your sensor') }}">{{ _('Temperature') }}</th>
<!-- ko if: ($root.hasAnySensorWithHumidity()) -->
<th class="humidity_actual" title="{{ _('Current humidity') }}">{{ _('Humidity') }}</th>
<!-- /ko -->
<!-- ko if: ($root.hasAnyTemperatureControl()) -->
<th class="temp_hum_control">{{ _('Control') }}</th>
<th class="temperature_target" title="{{ _('Current target temperature') }}">{{ _('Target') }}</th>
<!-- /ko -->
</tr>
<!-- ko foreach: $root.rpi_inputs_temperature_sensors() -->
<tr>
<th class="temperature_sensor" data-bind="text: label, attr: {title: label, rowspan: $root.calculateRowSpan(index_id)}"></th>
<td class="temperature_actual" data-bind="attr: {rowspan: $root.calculateRowSpan(index_id)}">
<span data-bind="text: temp_sensor_temp, attr: {title: temp_sensor_temp}"> </span>
<!-- ko if: (use_fahrenheit()) -->
<span class="add-on">&deg;F</span>
<!-- /ko -->
<!-- ko ifnot: (use_fahrenheit()) -->
<span class="add-on">&deg;C</span>
<!-- /ko -->
</td>
<!-- ko if: ($root.humidityCapableSensor(temp_sensor_type())) -->
<td class="humidity_actual" data-bind="attr: {rowspan: $root.calculateRowSpan(index_id)}">
<span data-bind="text: temp_sensor_humidity, attr: {title: temp_sensor_humidity}"> </span>
<span class="add-on">%</span>
</td>
<!-- /ko -->
<!-- ko if: ($root.hasAnySensorWithHumidity()) -->
<!-- ko ifnot: ($root.humidityCapableSensor(temp_sensor_type())) -->
<td class="humidity_actual" data-bind="attr: {rowspan: $root.calculateRowSpan(index_id)}">N/A</td>
<!-- /ko -->
<!-- /ko -->
<!-- ko if: ($root.linkedTemperatureControl(index_id())().length > 0 || $root.hasAnyTemperatureControl()) -->
<!-- ko with: $root.linkedTemperatureControl(index_id())()[0] -->
<th class="temp_hum_control" data-bind="html: label, attr: {title: label}"></th>
<td class="temperature_target">
<form class="form-inline" style="margin:0" data-bind="submit: function(element) { $root.setTemperature($data, element) }">
<div class="input-append">
<input type="number" min="0" max="999" class="input-mini input-nospin" data-bind="enable: $root.isUser(), value: temp_ctr_new_set_value, valueUpdate: 'input', attr: {placeholder:$root.getCleanTemperature(temp_ctr_set_value()), id: 'temp_control_' + index_id()}">
<!-- ko if: ($data.temp_ctr_type() == "heater" || $data.temp_ctr_type() == "cooler") -->
<!-- ko if: ($parent.use_fahrenheit()) -->
<span class="add-on">&deg;F</span>
<!-- /ko -->
<!-- ko ifnot: ($parent.use_fahrenheit()) -->
<span class="add-on">&deg;C</span>
<!-- /ko -->
<!-- /ko -->
<!-- ko if: ($data.temp_ctr_type() == "dehumidifier") -->
<span class="add-on">%</span>
<!-- /ko -->
</div>
<div class="btn-group">
<button type="submit" data-bind="enable: $root.isUser()" class="btn btn-primary" title="{{ _('Set') }}">
<i class="fa fa-check"></i>
</button>
<button class="btn btn-primary dropdown-toggle" data-toggle="dropdown" data-bind="enable: $root.isUser()">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>
<a href="javascript:void(0)" data-bind="enable: $root.isUser(), click: $root.turnOffHeater">{{ _('Off') }}</a>
</li>
</ul>
</div>
</form>
</td>
<!-- /ko -->
<!-- /ko -->
<!-- ko if: ($root.hasAnyTemperatureControl()) -->
<!-- ko if: ( !$root.linkedTemperatureControl(index_id())().length > 0) -->
<td class="temp_hum_control"></td>
<td class="temperature_target"></td>
<!-- /ko -->
<!-- /ko -->
</tr>
<!-- ko if: ($root.hasAnyTemperatureControl()) -->
<!-- ko foreach: $root.linkedTemperatureControl(index_id())-->
<!-- ko ifnot: ($index() == 0) -->
<tr>
<th class="temp_hum_control" data-bind="html: label, attr: {title: label}"></th>
<td class="temperature_target">
<form class="form-inline" style="margin:0" data-bind="submit: function(element) { $root.setTemperature($data, element) }">
<div class="input-append">
<input type="number" min="0" max="999" class="input-mini input-nospin" data-bind="enable: $root.isUser(), value: temp_ctr_new_set_value, valueUpdate: 'input', attr: {placeholder:$root.getCleanTemperature(temp_ctr_set_value()), id: 'temp_control_' + index_id()}">
<!-- ko if: ($data.temp_ctr_type() == "heater" || $data.temp_ctr_type() == "cooler") -->
<!-- ko if: ($parent.use_fahrenheit()) -->
<span class="add-on">&deg;F</span>
<!-- /ko -->
<!-- ko ifnot: ($parent.use_fahrenheit()) -->
<span class="add-on">&deg;C</span>
<!-- /ko -->
<!-- /ko -->
<!-- ko if: ($data.temp_ctr_type() == "dehumidifier") -->
<span class="add-on">%</span>
<!-- /ko -->
</div>
<div class="btn-group">
<button type="submit" data-bind="enable: $root.isUser()" class="btn btn-primary" title="{{ _('Set') }}">
<i class="fa fa-check"></i>
</button>
<button class="btn btn-primary dropdown-toggle" data-toggle="dropdown" data-bind="enable: $root.isUser()">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>
<a href="javascript:void(0)" data-bind="enable: $root.isUser(), click: $root.turnOffHeater">{{ _('Off') }}</a>
</li>
</ul>
</div>
</form>
</td>
</tr>
<!-- /ko -->
<!-- /ko -->
<!-- /ko -->
<!-- /ko -->
</tbody>
</table>
</div>
<!-- /ko -->
<!-- ko foreach: $root.rpi_outputs() -->
<!-- ko ifnot: ($data.hide_btn_ui()) -->
<!-- ko if: ($data.output_type() == "regular_gpio") -->
<h4>
<span data-bind="html: label"> </span>
<span class="badge">regular_gpio gpio</span>
<!-- ko if: ($data.gpio_status()) -->
<span class="badge badge-success help-inline">on</span>
<!-- /ko -->
<!-- ko ifnot: ($data.gpio_status()) -->
<span class="badge badge-important help-inline">off</span>
<!-- /ko -->
</h4>
<div>
<!-- ko if: ($data.gpio_status()) -->
<button data-bind="enable: $root.isUser(), click: $root.handleIO" class="btn">Turn off</button>
<!-- /ko -->
<!-- ko ifnot: ($data.gpio_status()) -->
<button data-bind="enable: $root.isUser(), click: $root.handleIO" class="btn">Turn on</button>
<!-- /ko -->
</div>
<!-- /ko -->
<!-- ko if: ($data.output_type() == "ledstrip") -->
<h4>
<span data-bind="html: label"> </span>
<span class="badge">ledstrip</span>
</h4>
<div class="input-append ledstrip-div">
<input type="text" class="input-block-level" data-bind="click: $root.showColorPicker(), value: new_ledstrip_color, valueUpdate: 'input', attr: {placeholder:ledstrip_color, name: 'colorpicker'}">
<button type="submit" class="btn btn-input-inc" title="Set Color" data-bind="enable: $root.isUser(), click: $root.handleLedstripColor">
<i class="fa fa-check"></i>
</button>
</div>
<!-- /ko -->
<!-- ko if: ($data.output_type() == "gcode_output") -->
<h4>
<span data-bind="html: label"> </span>
<span class="badge">gcode output</span>
</h4>
<div>
<button data-bind="enable: $root.isOperational(), click: $root.handleGcode" class="btn">Send gcode</button>
</div>
<!-- /ko -->
<!-- ko if: ($data.output_type() == "shell_output") -->
<h4>
<span data-bind="html: label"> </span>
<span class="badge">Shell Script</span>
</h4>
<div>
<button data-bind="enable: $root.isUser(), click: $root.handleShellOutput" class="btn">Execute Script</button>
</div>
<!-- /ko -->
<!-- ko if: ($data.output_type() == "pwm") -->
<h4>
<span data-bind="html: label"> </span>
<span class="badge">pwm</span>
</h4>
<div class="input-append">
<input type="text" class="input-mini" data-bind="value: new_duty_cycle, valueUpdate: 'input', attr: {placeholder:$root.getDutyCycle(duty_cycle())}">
<!-- ko ifnot: ($data.pwm_temperature_linked()) -->
<button class="btn btn-input-inc" title="Set PWM" data-bind="enable: $root.isUser(), click: $root.handlePWM">
<i class="fa fa-check"></i>
</button>
<!-- /ko -->
<!-- ko if: ($data.pwm_temperature_linked()) -->
<button class="btn btn-input-inc" title="Temperature controlled PWM" disabled>
<i class="fa fa-check"></i>
</button>
<!-- /ko -->
</div>
<!-- /ko -->
<!-- ko if: ($data.output_type() == "neopixel_direct" || $data.output_type() == "neopixel_indirect") -->
<h4>
<span data-bind="html: label"> </span>
<span class="badge">neopixel</span>
</h4>
<div class="input-append neopixel-div">
<input type="text" class="input-block-level" data-bind="click: $root.showColorPicker(), value: new_neopixel_color, valueUpdate: 'input', attr: {placeholder:neopixel_color, name: 'colorpicker'}">
<button type="submit" class="btn btn-input-inc" title="Set Color" data-bind="enable: $root.isUser(), click: $root.handleNeopixel">
<i class="fa fa-check"></i>
</button>
</div>
<!-- /ko -->
<!-- ko if: ($data.output_type() == "temp_hum_control") -->
<h4>
<span data-bind="html: label"> </span>
<span class="badge">temperature control</span>
<!-- ko if: ($data.temp_ctr_type() == "heater") -->
<span class="badge badge-warning">Heater</span>
<!-- /ko -->
<!-- ko if: ($data.temp_ctr_type() == "cooler") -->
<span class="badge badge-warning">Cooler</span>
<!-- /ko -->
<!-- ko if: ($data.temp_ctr_type() == "dehumidifier") -->
<span class="badge badge-warning">Dehumidifier</span>
<!-- /ko -->
<!-- ko if: ($data.gpio_status()) -->
<span class="badge badge-success help-inline">on</span>
<!-- /ko -->
<!-- ko ifnot: ($data.gpio_status()) -->
<span class="badge badge-important help-inline">off</span>
<!-- /ko -->
</h4>
<!-- /ko -->
<!-- ko ifnot: ($data.output_type() == "pwm" && $data.pwm_temperature_linked()) -->
<!-- ko ifnot: (($data.output_type() == "regular_gpio" || $data.output_type() == "pwm") && $data.toggle_timer()) -->
<!-- ko ifnot: ($data.output_type() == "gcode_output" || $data.output_type() == "temperature_alarm" || $data.output_type() == "shell_output") -->
<div>
<h5>
<!-- ko if: ($root.isUser()) -->
<span>Auto Startup</span>
<!-- ko if: ($data.auto_startup()) -->
<a href="#" data-bind="click: $root.switchAutoStartUp" class="fa fa-toggle-on enclosure-link" title="Disable Auto Startup"></a>
<!-- /ko -->
<!-- ko ifnot: ($data.auto_startup()) -->
<a href="#" data-bind="click: $root.switchAutoStartUp" class="fa fa-toggle-off enclosure-link" title="Enable Auto Startup"></a>
<!-- /ko -->
<!-- /ko -->
</h5>
<h5>
<!-- ko if: ($root.isUser()) -->
<span>Auto Shutdown</span>
<!-- ko if: ($data.auto_shutdown()) -->
<a href="#" data-bind="click: $root.switchAutoShutdown" class="fa fa-toggle-on enclosure-link" title="Disable Auto Shutdown"></a>
<!-- /ko -->
<!-- ko ifnot: ($data.auto_shutdown()) -->
<a href="#" data-bind="click: $root.switchAutoShutdown" class="fa fa-toggle-off enclosure-link" title="Enable Auto Shutdown"></a>
<!-- /ko -->
<!-- /ko -->
</h5>
<!-- ko if: ($data.output_type() == "temp_hum_control" && $data.temp_ctr_type() == "heater" && !$data.auto_shutdown()) -->
<span>
<span class="label label-important">Warning:</span>
<span> Consider making
<b>heater</b> auto shutdown when print finish for safety reasons.</span>
</span>
<!-- /ko -->
</div>
<!-- /ko -->
<!-- /ko -->
<!-- /ko -->
<!-- ko if: (($data.output_type() == "regular_gpio" || $data.output_type() == "pwm") && $data.toggle_timer()) -->
<h5>
<span>Time Toggle</span>
<span class="badge"> active</span>
</h5>
<!-- /ko -->
<br>
<!-- /ko -->
<!-- /ko -->
<!-- ko foreach: $root.rpi_inputs() -->
<!-- ko if: ($data.input_type() == "gpio" && $data.action_type() == "printer_control" && $data.printer_action() == "filament" ) -->
<h4>
<span data-bind="html: label"> </span>
<span class="badge">filament sensor</span>
<!-- ko if: ($root.isUser()) -->
<!-- ko if: ($data.filament_sensor_enabled()) -->
<a href="#" data-bind="click: $root.switchFilamentSensor" class="fa fa-toggle-on enclosure-link" title="Disable Filament Sensor"></a>
<!-- /ko -->
<!-- ko ifnot: ($data.filament_sensor_enabled()) -->
<a href="#" data-bind="click: $root.switchFilamentSensor" class="fa fa-toggle-off enclosure-link" title="Enable Filament Sensor"></a>
<!-- /ko -->
<!-- /ko -->
</h4>
<!-- /ko -->
<!-- /ko -->

View File

@@ -1,48 +0,0 @@
import ctypes
import struct
import sys
import smbus
def main():
# Get bus address if provided or use default address
address = 0x48
if len(sys.argv) >= 2:
address = int(sys.argv[1], 0)
if not 0x48 <= address <= 0x4b:
raise ValueError("Invalid address value")
# Connect to I2C bus (use 0 on original Raspberry Pi, 1 on later models)
bus = smbus.SMBus(1)
# Set pointer to the temperature register
bus.write_byte(address, 0)
# Read two byte value
temp = bus.read_word_data(address, 0)
# Disconnect from bus
bus.close()
# Byte swap
temp = struct.unpack(">H", struct.pack("<H", temp))[0]
# Shift
temp = temp >> 4
# Convert to 2 byte twos compliment negative if negative
if ((temp & 0x800) != 0):
temp |= 0xF800
# Convert into a signed number
temp = ctypes.c_short(temp).value
# Divide by 16 to get value in celsius
temp /= 16.0
print('{0:0.1f}'.format(temp))
if __name__ == "__main__":
main()