Ejemplo n.º 1
0
    def __init__(self):
        self.page_now = 0

        self.ser = SerAction()

        self.page_back = 1

        self.connecting_page = ConnectingPage(0)
        self.choose_page = ChoosePage(1, self.__page_update)
        self.snack_page = Snacke(2, self.__page_update, self.page_back,
                                 self.ser)
        self.flappy_page = Flappy(3, self.__page_update, self.page_back,
                                  self.ser)
        self.pacman_page = Pacman(4, self.__page_update, self.page_back,
                                  self.ser)

        self.__setting()
        self.__page_update([self.page_now])
        self.page_switch()

        done()
Ejemplo n.º 2
0
from cuser import SerAction
import time


def hello(ser):
    print(ser[0].get_485_buffer())


def hi(ser):
    print(ser[0].send_485(0x20))


ser = SerAction()
ser.connection()

ser.listen_load('key1', hello, [ser])
ser.listen_load('key2', hi, [ser])
Ejemplo n.º 3
0
class Playground():
    def __init__(self):
        self.page_now = 0

        self.ser = SerAction()

        self.page_back = 1

        self.connecting_page = ConnectingPage(0)
        self.choose_page = ChoosePage(1, self.__page_update)
        self.snack_page = Snacke(2, self.__page_update, self.page_back,
                                 self.ser)
        self.flappy_page = Flappy(3, self.__page_update, self.page_back,
                                  self.ser)
        self.pacman_page = Pacman(4, self.__page_update, self.page_back,
                                  self.ser)

        self.__setting()
        self.__page_update([self.page_now])
        self.page_switch()

        done()

    def __setting(self):
        pensize(4)
        tracer(False)
        up()
        hideturtle()
        colormode(255)
        color((0, 0, 0), "black")
        setup(420, 420, 370, 0)

    def __page_update(self, page):
        self.page_now = page[0]
        self.connecting_page.page_now = self.page_now
        self.choose_page.page_now = self.page_now
        self.snack_page.page_now = self.page_now
        self.flappy_page.page_now = self.page_now
        self.pacman_page.page_now = self.page_now

        self.ser.listen_unload('key1')
        self.ser.listen_unload('key2')
        self.ser.listen_unload('key3')
        self.ser.listen_unload('up')
        self.ser.listen_unload('down')
        self.ser.listen_unload('left')
        self.ser.listen_unload('right')
        self.ser.listen_unload('enter')
        time.sleep(0.2)

        self.page_switch()

    def page_switch(self):
        if self.page_now == 0:
            self.connecting_page.page_animation()
            self.ser.connection()
            self.page_now = 1
            self.__page_update([self.page_now])

        elif self.page_now == 1:
            self.ser.listen_load('up', self.choose_page.change, [-1])
            self.ser.listen_load('down', self.choose_page.change, [1])
            self.ser.listen_load('enter', self.choose_page.enter, [])
            self.ser.set_nixie('choosing')
            self.choose_page.init()
            self.choose_page.move()

        elif self.page_now == 2:
            self.ser.listen_load('right', self.snack_page.change, [10, 0])
            self.ser.listen_load('left', self.snack_page.change, [-10, 0])
            self.ser.listen_load('up', self.snack_page.change, [0, 10])
            self.ser.listen_load('down', self.snack_page.change, [0, -10])
            self.snack_page.init()
            self.snack_page.move()

        elif self.page_now == 3:
            self.ser.listen_load('key1', self.flappy_page.tap, [])
            self.flappy_page.init()
            self.flappy_page.move()

        elif self.page_now == 4:
            self.ser.listen_load('right', self.pacman_page.change, [5, 0])
            self.ser.listen_load('left', self.pacman_page.change, [-5, 0])
            self.ser.listen_load('up', self.pacman_page.change, [0, 5])
            self.ser.listen_load('down', self.pacman_page.change, [0, -5])
            self.pacman_page.init()
            self.pacman_page.move()
Ejemplo n.º 4
0
from cuser import SerAction
import time


def led(s):
    number = 1
    print(111)
    while number <= 128:
        s[0].set_led(number)
        number = number * 2
        time.sleep(0.1)

    s[0].set_led(0)


s = SerAction()
s.connection()
s.listen_load('vibrate', led, [s])
s.vibrate_start()
s.set_nixie('       ')
s.set_led(0)
Ejemplo n.º 5
0
        self.temp_data = 0
        self.address = 0


def op(s):
    if s[0] == 1:
        s[1].address = (s[1].address + 1) % 256
        s[1].data = s[2].read_mem(s[1].address)
        s[1].temp_data = s[1].data
    elif s[0] == 2:
        s[1].temp_data = (s[1].temp_data + 1) % 256
    elif s[0] == 3:
        s[1].data = s[1].temp_data
        s[2].write_mem(s[1].address, s[1].data)

    s[2].set_nixie(str(s[1].address).zfill(2) + ' ' + str(s[1].data).zfill(2) + ' ' + str(s[1].temp_data).zfill(2))


s = SerAction()
m = Mem()

s.connection()

m.data = s.read_mem(m.address)
m.temp_data = s.read_mem(m.address)
s.set_nixie(str(m.address).zfill(2) + ' ' + str(m.data).zfill(2) + ' ' + str(m.temp_data).zfill(2))

s.listen_load('key1', op, [1, m, s])
s.listen_load('key2', op, [2, m, s])
s.listen_load('key3', op, [3, m, s])
Ejemplo n.º 6
0
from cuser import SerAction
import time


def hello(ser):
    ser[0].set_nixie('abcd')


def play(nixie, led, ser):
    i = 0
    while (True):
        i = (i + 1) % 4
        ser.set_nixie(nixie[i])
        ser.set_led(led[i])
        time.sleep(0.5)


nixie = ['1      8', ' 2    7 ', '  3  6  ', '   45  ']

led = [0x81, 0x42, 0x24, 0x18]

ser = SerAction()
ser.connection()
play(nixie, led, ser)
Ejemplo n.º 7
0
# available on Windows

from pynput.keyboard import Key, Controller
from cuser import SerAction
import time


def next(k):
    k[0].press(Key.right)
    k[0].release(Key.right)


def pre(k):
    k[0].press(Key.left)
    k[0].release(Key.left)


k = Controller()
s = SerAction()

s.connection()
s.listen_load('key1', next, [k])
s.listen_load('key2', pre, [k])
t = 0

while True:
    time.sleep(1)
    t += 1
    s.set_nixie(str(t))
Ejemplo n.º 8
0
from cuser import SerAction
from pynput.keyboard import Key, Controller


def press_and_release(k):
    k[0].press(k[1])
    k[0].release(k[1])


k = Controller()
s = SerAction()

s.connection()
s.listen_load('up', press_and_release, [k, Key.up])
s.listen_load('down', press_and_release, [k, Key.down])
s.listen_load('left', press_and_release, [k, Key.left])
s.listen_load('right', press_and_release, [k, Key.right])
s.listen_load('key2', press_and_release, [k, Key.space])