led_control/controller/streamlit.py
2023-01-14 14:56:45 +01:00

34 lines
845 B
Python

import streamlit as st
import controller
import colorsys
hide_streamlit_style = """
<style>
#MainMenu {visibility: hidden;}
footer {visibility: hidden;}
</style>
"""
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
def hex_to_rgb(hex):
r = int(hex[1:3],16)
g = int(hex[3:5],16)
b = int(hex[5:7],16)
return r,g,b
def rgb_to_hex(r,g,b):
return "#" + hex(r)[2:].zfill(2) + hex(g)[2:].zfill(2) + hex(b)[2:].zfill(2)
st.title("LED Control")
# r = st.slider("Red", 0, 255, 0)
# g = st.slider("Green", 0, 255, 0)
# b = st.slider("Blue", 0, 255, 0)
h = st.slider("Hue", 0.0, 1.0, 0.0, 0.01)
s = st.slider("Saturation", 0.0, 1.0, 0.0, 0.01)
v = st.slider("Value", 0.0, 1.0, 0.0, 0.01)
r,g,b = colorsys.hsv_to_rgb(h,s,v)
color = rgb_to_hex(int(r * 255),int(g * 255),int(b * 255))
controller.set_pixels(color[1:])
color