def start(): global SAKS global beeper global led led = Led() SAKS = SAKSHAT() beeper = Beeper(SAKS) beeper.start()
def init(self): self.SAKS = SAKSHAT() # 在检测到轻触开关触发时自动执行此函数 def tact_event_handler(pin, status): print pin, status # 停止闹钟响铃(按下任何轻触开关均可触发) self.__alarm_beep_status = False self.__alarm_beep_times = 0 self.SAKS.buzzer.off() self.SAKS.ledrow.off_for_index(6) self.SAKS.tact_event_handler = tact_event_handler self.SAKS.buzzer.off() self.SAKS.ledrow.off_for_index(6)
#!/bin/env python #coding:utf-8 from sakshat import SAKSHAT import threading import time SAKS = SAKSHAT() class Beeper(threading.Thread): '''to make it beep and blink at the same time, this should be in another thread''' def run(self): self.beep = False self.stop = False while not self.stop: if self.beep: self.beep = False SAKS.buzzer.beepAction(0.02, 0.02, 30) time.sleep(0.1)
else: index = second / 10 + 1 if (model == 0): light_low(index) else: saks.ledrow.off() saks.ledrow.on_for_index(8 - int(index)) def timer(model): while True: time_value = time.localtime() time_second = time.strftime("%S", time_value) time_show = time.strftime("%H.%M", time_value) saks.digital_display.show(time_show) show_seconds(model, time_second) time.sleep(1) if __name__ == '__main__': MODEL = 0 if len(sys.argv) >= 2: MODEL = 1 # print("model is %d" % model) # print(len(sys.argv)) saks = SAKSHAT() timer(MODEL)
import pygame from pygame import * import time from sakshat import SAKSHAT from sakspins import SAKSPins as PINS import random import RPi.GPIO as GPIO #screen = pygame.display.set_mode((640, 480), 0, 32) GPIO.setmode(GPIO.BCM) #采用BCM编码模式 SAKS = SAKSHAT() #调用SAKSHAT模块 DS = 6 # 控制LED灯的三个端口的BCM编码 SHCP = 19 STCP = 13 speed = 0.36 # set speed def init(): # 初始化端口状态 GPIO.setup(DS, GPIO.OUT) GPIO.setup(SHCP, GPIO.OUT) GPIO.setup(STCP, GPIO.OUT) GPIO.output(DS, GPIO.LOW) GPIO.output(SHCP, GPIO.LOW) GPIO.output(STCP, GPIO.LOW) # 实现1到8对应流水灯的状态,i对应从左到右前i个LED灯亮
from sakshat import SAKSHAT from sakspins import SAKSPins as PINS import time import random SAKS = SAKSHAT()#瑞士军刀扩展版组件 b = SAKS.buzzer#蜂鸣 c = 100#金额 d = 0#选的灯 l = 0#中奖的灯 x = 0#正在设置的数位 o = 1#是否静音 f = 0#连输次数 a = [0,0,0,0]#下注金额 mode = 0#模式 m = {0:1,1:0,2:3,3:2,4:5,5:4,6:7,7:6}#用以匹配同颜色的灯 def bzy(n):#把数字转成可调用的形式 s = '' s += str(int(n/1000)) if n >= 1000 else '#' s += str(int(n/100%10)) if n >= 100 else '#' s += str(int(n/10%10)) if n >= 10 else '#' s += str(int(n%10)) return s def tty(a,x):#把四位数字的列表转为可调用的形式 s = '' for i in range(3-x): s += '#' for i in range(x+1): s += str(a[x-i])