Ok that has worked greatr.
I have made some progress and my code now looks like this.
import sys
import pygame
import time
import os
import math
from pygame.locals import *
from ft5406 import Touchscreen
from gui import widgets, Button, Slider, Dial, render_widgets, touchscreen_event
from mote import Mote
mote = Mote()
mote.configure_channel(1, 16, False)
mote.configure_channel(2, 16, False)
mote.configure_channel(3, 16, False)
mote.configure_channel(4, 16, False)
mote.clear()
pygame.init()
size = width, height = 800, 480
screen = pygame.display.set_mode(size, pygame.FULLSCREEN)
pygame.mouse.set_visible(False)
ts = Touchscreen()
for touch in ts.touches:
touch.on_press = touchscreen_event
touch.on_release = touchscreen_event
touch.on_move = touchscreen_event
def my_exit(b, e, t):
global running
running = False
def mote_on(b,e,t):
mote.clear()
for channel in range(1, 5):
for pixel in range(16):
mote.set_pixel(channel, pixel, 255, 255, 255)
mote.show()
def mote_off(b,e,t):
mote.clear()
for channel in range(1, 5):
for pixel in range(16):
mote.set_pixel(channel, pixel,0,0,0)
mote.show()
Button(
"ON",
(0, 255, 0),
(20, 20),
(220, 220),
mote_on)
Button(
"OFF",
(255,0,0),
(20, 250),
(220, 220),
mote_off)
Button(
"x",
(255, 0, 0),
(760, 0),
(40, 40),
my_exit)
for x in range(3):
if x == 0:
colour=(255,0,0)
elif x == 1:
colour=(0,255,0)
elif x == 2:
colour=(0,0,255)
Slider(
(0,100,0),
colour,
(270 + (x*175), 20),
(100, 450),
None)
ts.run()
running = True
while running:
for event in pygame.event.get():
if event.type == KEYDOWN and event.key == K_ESCAPE:
ts.stop()
sys.exit()
screen.fill((0, 0, 0))
render_widgets(screen)
pygame.display.flip()
time.sleep(0.01)
ts.stop()
I was wondering if i would be able to get 3 seperate values from the sliders ending up in a
functioni looking like this
def change_mote():
r,g,b= wizardry to get values
mote.clear()
for channel in range(1, 5):
for pixel in range(16):
mote.set_pixel(channel, pixel, r,g,b)
mote.show()
anyway to get the values from the sliders would be helpful!