代码
# -*- coding: UTF-8 -*-
# MindPlus
# Python
from pinpong.extension.unihiker import *
from pinpong.board import Board,Pin
from pinpong.board import NeoPixel
from pinpong.board import Board
from unihiker import GUI
import random
import time
# 事件回调函数
def button_click2():
while True:
global flag
flag = 2
if (flag == 2):
for my_variable in range(0, 12):
np1[my_variable] = (255,153,0)
def button_click1():
global flag
flag = 1
while True:
if (flag == 1):
for my_variable in range(0, 12):
np1[my_variable] = (204,51,204)
def button_click4():
global flag
flag = 4
while True:
if (flag == 4):
R = (random.randint(0, 255))
G = (random.randint(0, 255))
B = (random.randint(0, 255))
for my_variable in range(0, 12):
np1[my_variable] = (R,G,B)
time.sleep(0.1)
def button_click3():
while True:
global flag
flag = 3
if (flag == 3):
for my_variable in range(0, 12):
np1[my_variable] = (51,51,255)
time.sleep(0.1)
np1[my_variable] = (0,0,0)
u_gui=GUI()
Board().begin()
bg=u_gui.draw_image(image="背景.png",x=0,y=0)
sad=u_gui.draw_image(image="忧伤.png",x=25,y=157)
sad.config(onclick=button_click1)
smile=u_gui.draw_image(image="开心.png",x=70,y=115)
smile.config(onclick=button_click2)
dance=u_gui.draw_image(image="跳舞.png",x=125,y=112)
dance.config(onclick=button_click3)
sing=u_gui.draw_image(image="音乐.png",x=165,y=155)
sing.config(onclick=button_click4)
wenzi=u_gui.draw_text(text="心情氛围灯",x=120,y=50,font_size=20, color="#FF6600")
wenzi.config(origin="center")
np1 = NeoPixel(Pin((Pin.P24)),7)
flag = 0
R = 0
G = 0
B = 0
while True:
pass
伦**2024.03.17
666