示例#1
0
 def __init__(self, interval, path):
     self.path = path
     self.interval = interval
     self.count = 0
     self.buttons = buttons.buttons(35, 40, 38)
     self.display = display.Display()
     self.web_start = False
     try:
         print(gphoto.list_cameras())
         self.camera = gphoto.Camera()
         print(self.camera.supported_operations)
         self.camera_connected = True
     except AttributeError:
         print("Please Connect a Camera")
示例#2
0
文件: start.py 项目: rasplay/RAS_HiPi
	# Let it know about display, if display is enabled
	if LCD_ENABLE:
		remote.register_display(display)

# If buttons are enabled, initialize them
if BUTTONS_ENABLE:
	button_pins = {
		'PLAY_BUTTON': PLAY_BUTTON,
		'NEXT_BUTTON': NEXT_BUTTON,
		'PREV_BUTTON': PREV_BUTTON,
		'VDN_BUTTON': VDN_BUTTON,
		'VUP_BUTTON': VUP_BUTTON,
		'STOP_BUTTON': STOP_BUTTON
	}

	btn = buttons.buttons(button_pins, BOUNCE_TIME)
	
	# Register MPD client
	btn.register(mpdcl)

# Wait for MPD client thread to finish
mpdcl.join()

# If LCD is enabled, wait for it's thread to finish
if LCD_ENABLE:
	display.join()
	
# If remote is enabled, wait for it's thread to finish
if REMOTE_ENABLE:
	remote.join()
	
示例#3
0
文件: juego2.py 项目: LdMe/soldados
    def __init__(self, X, Y, height, horizontal):
        self.buttons_list = []
        self.showing = True
        self.keys = {}
        self.teams = {}
        self.actions = {}
        button1 = buttons(-120 / 800.0 * X + horizontal,
                          100 / 800.0 * Y + height, 3, 0, X / 10, Y / 20)
        self.buttons_list.append(button1)
        self.keys["L"] = button1
        self.teams["L"] = 1
        button2 = buttons(40 / 800.0 * X + horizontal,
                          100 / 800.0 * Y + height, 3, 0, X / 10, Y / 20)
        self.buttons_list.append(button2)
        self.keys["R"] = button2
        self.teams["R"] = 2
        self.actions["R"] = "shoot"
        self.actions["L"] = "shoot"
        button1 = buttons(160 / 800.0 * X + horizontal, height, 2, 1, X / 20,
                          Y / 20)
        button2 = buttons(240 / 800.0 * X + horizontal, height, 2, 1, X / 20,
                          Y / 20)
        button3 = buttons(200 / 800.0 * X + horizontal,
                          -40 / 800.0 * Y + height, 2, 1, X / 20, Y / 20)
        button4 = buttons(200 / 800.0 * X + horizontal,
                          40 / 800.0 * Y + height, 2, 1, X / 20, Y / 20)
        self.buttons_list.append(button1)
        self.buttons_list.append(button2)
        self.buttons_list.append(button3)
        self.buttons_list.append(button4)
        self.keys["R_down"] = button4
        self.keys["R_up"] = button3
        self.keys["R_left"] = button1
        self.keys["R_right"] = button2
        self.teams["R_down"] = 2
        self.teams["R_up"] = 2
        self.teams["R_left"] = 2
        self.teams["R_right"] = 2

        self.actions["R_down"] = "brake"
        self.actions["R_up"] = "accelerate"
        self.actions["R_left"] = "left"
        self.actions["R_right"] = "right"

        button1 = buttons(-280 / 800.0 * X + horizontal, height, 1, 1, X / 20,
                          Y / 20)
        button2 = buttons(-200 / 800.0 * X + horizontal, height, 1, 1, X / 20,
                          Y / 20)
        button3 = buttons(-240 / 800.0 * X + horizontal,
                          -40 / 800.0 * Y + height, 1, 1, X / 20, Y / 20)
        button4 = buttons(-240 / 800.0 * X + horizontal,
                          40 / 800.0 * Y + height, 1, 1, X / 20, Y / 20)
        self.buttons_list.append(button1)
        self.buttons_list.append(button2)
        self.buttons_list.append(button3)
        self.buttons_list.append(button4)
        self.keys["L_down"] = button4
        self.keys["L_up"] = button3
        self.keys["L_left"] = button1
        self.keys["L_right"] = button2
        self.teams["L_down"] = 1
        self.teams["L_up"] = 1
        self.teams["L_left"] = 1
        self.teams["L_right"] = 1

        self.actions["L_down"] = "brake"
        self.actions["L_up"] = "accelerate"
        self.actions["L_left"] = "left"
        self.actions["L_right"] = "right"
 def test_buttons_intitialzed_to_false(self):
     with mock.patch('RPi.GPIO'):
         mybuttons = buttons.buttons(35, 40, 38)
         return not mybuttons.read_interval_state()[0]
示例#5
0
    def __init__(self):
        self.font1 = {
            "Width":
            6,
            "Height":
            8,
            "Start":
            32,
            "End":
            127,
            "Data":
            bytearray([
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x5F,
                0x06, 0x00, 0x00, 0x07, 0x03, 0x00, 0x07, 0x03, 0x00, 0x24,
                0x7E, 0x24, 0x7E, 0x24, 0x00, 0x24, 0x2B, 0x6A, 0x12, 0x00,
                0x00, 0x63, 0x13, 0x08, 0x64, 0x63, 0x00, 0x36, 0x49, 0x56,
                0x20, 0x50, 0x00, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00,
                0x3E, 0x41, 0x00, 0x00, 0x00, 0x00, 0x41, 0x3E, 0x00, 0x00,
                0x00, 0x08, 0x3E, 0x1C, 0x3E, 0x08, 0x00, 0x08, 0x08, 0x3E,
                0x08, 0x08, 0x00, 0x00, 0xE0, 0x60, 0x00, 0x00, 0x00, 0x08,
                0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00,
                0x00, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, 0x3E, 0x51, 0x49,
                0x45, 0x3E, 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00, 0x00, 0x62,
                0x51, 0x49, 0x49, 0x46, 0x00, 0x22, 0x49, 0x49, 0x49, 0x36,
                0x00, 0x18, 0x14, 0x12, 0x7F, 0x10, 0x00, 0x2F, 0x49, 0x49,
                0x49, 0x31, 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30, 0x00, 0x01,
                0x71, 0x09, 0x05, 0x03, 0x00, 0x36, 0x49, 0x49, 0x49, 0x36,
                0x00, 0x06, 0x49, 0x49, 0x29, 0x1E, 0x00, 0x00, 0x6C, 0x6C,
                0x00, 0x00, 0x00, 0x00, 0xEC, 0x6C, 0x00, 0x00, 0x00, 0x08,
                0x14, 0x22, 0x41, 0x00, 0x00, 0x24, 0x24, 0x24, 0x24, 0x24,
                0x00, 0x00, 0x41, 0x22, 0x14, 0x08, 0x00, 0x02, 0x01, 0x59,
                0x09, 0x06, 0x00, 0x3E, 0x41, 0x5D, 0x55, 0x1E, 0x00, 0x7E,
                0x11, 0x11, 0x11, 0x7E, 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36,
                0x00, 0x3E, 0x41, 0x41, 0x41, 0x22, 0x00, 0x7F, 0x41, 0x41,
                0x41, 0x3E, 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41, 0x00, 0x7F,
                0x09, 0x09, 0x09, 0x01, 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A,
                0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, 0x00, 0x41, 0x7F,
                0x41, 0x00, 0x00, 0x30, 0x40, 0x40, 0x40, 0x3F, 0x00, 0x7F,
                0x08, 0x14, 0x22, 0x41, 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40,
                0x00, 0x7F, 0x02, 0x04, 0x02, 0x7F, 0x00, 0x7F, 0x02, 0x04,
                0x08, 0x7F, 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, 0x7F,
                0x09, 0x09, 0x09, 0x06, 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E,
                0x00, 0x7F, 0x09, 0x09, 0x19, 0x66, 0x00, 0x26, 0x49, 0x49,
                0x49, 0x32, 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01, 0x00, 0x3F,
                0x40, 0x40, 0x40, 0x3F, 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F,
                0x00, 0x3F, 0x40, 0x3C, 0x40, 0x3F, 0x00, 0x63, 0x14, 0x08,
                0x14, 0x63, 0x00, 0x07, 0x08, 0x70, 0x08, 0x07, 0x00, 0x71,
                0x49, 0x45, 0x43, 0x00, 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00,
                0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x41, 0x41,
                0x7F, 0x00, 0x00, 0x04, 0x02, 0x01, 0x02, 0x04, 0x80, 0x80,
                0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x03, 0x07, 0x00, 0x00,
                0x00, 0x20, 0x54, 0x54, 0x54, 0x78, 0x00, 0x7F, 0x44, 0x44,
                0x44, 0x38, 0x00, 0x38, 0x44, 0x44, 0x44, 0x28, 0x00, 0x38,
                0x44, 0x44, 0x44, 0x7F, 0x00, 0x38, 0x54, 0x54, 0x54, 0x08,
                0x00, 0x08, 0x7E, 0x09, 0x09, 0x00, 0x00, 0x18, 0xA4, 0xA4,
                0xA4, 0x7C, 0x00, 0x7F, 0x04, 0x04, 0x78, 0x00, 0x00, 0x00,
                0x00, 0x7D, 0x40, 0x00, 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00,
                0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00, 0x00, 0x7F,
                0x40, 0x00, 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78, 0x00, 0x7C,
                0x04, 0x04, 0x78, 0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x38,
                0x00, 0xFC, 0x44, 0x44, 0x44, 0x38, 0x00, 0x38, 0x44, 0x44,
                0x44, 0xFC, 0x00, 0x44, 0x78, 0x44, 0x04, 0x08, 0x00, 0x08,
                0x54, 0x54, 0x54, 0x20, 0x00, 0x04, 0x3E, 0x44, 0x24, 0x00,
                0x00, 0x3C, 0x40, 0x20, 0x7C, 0x00, 0x00, 0x1C, 0x20, 0x40,
                0x20, 0x1C, 0x00, 0x3C, 0x60, 0x30, 0x60, 0x3C, 0x00, 0x6C,
                0x10, 0x10, 0x6C, 0x00, 0x00, 0x9C, 0xA0, 0x60, 0x3C, 0x00,
                0x00, 0x64, 0x54, 0x54, 0x4C, 0x00, 0x00, 0x08, 0x3E, 0x41,
                0x41, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x00,
                0x41, 0x41, 0x3E, 0x08, 0x00, 0x02, 0x01, 0x02, 0x01, 0x00,
                0x00, 0x3C, 0x26, 0x23, 0x26, 0x3C
            ])
        }
        #updated pins/buttons
        self.BTN_1 = 0
        self.BTN_2 = 1
        self.BTN_3 = 2
        self.BTN_4 = 3
        self.BTN_5 = 4
        self.BTN_6 = 5
        self.BTN_7 = 6
        self.BTN_8 = 7
        self.BTN_9 = 8
        self.BTN_ASTERISK = 9
        self.BTN_0 = 10
        self.BTN_HASHTAG = 11
        self.BTN_FUN_RIGHT = 12
        self.BTN_FUN_LEFT = 15
        self.BTN_A = 16
        self.BTN_B = 17
        #obsolete buttons, successor - readJoystickX/Y()
        # self.BTN_UP = 18
        # self.BTN_DOWN = 19
        # self.BTN_LEFT = 20
        # self.BTN_RIGHT = 21

        self._BL_PIN = 21
        self._PIXELS_PIN = 12
        self._SIM_PIXELS_ENABLE_PIN = 26
        self._NUM_PIXELS = 8

        self.i2c = I2C(scl=Pin(27), sda=Pin(14), freq=100000)  #ok
        self.buttons = buttons()
        #self.buttons = PCA9539(self.i2c, 0x21) #21 for main buttons, 20 for numerical keypad
        self.spi = SPI(2,
                       baudrate=20000000,
                       polarity=0,
                       phase=0,
                       sck=Pin(18),
                       mosi=Pin(23),
                       miso=Pin(19))  #ok
        self.display = TFT(self.spi, 0, 2, 4)  #ok
        self.display.initr()
        self.display.rgb(True)
        self.display.rotation(1)  #rotation changed to 1 (top left)
        self.display.fill(0)
        self.pixels = NeoPixel(Pin(self._PIXELS_PIN, Pin.OUT),
                               self._NUM_PIXELS,
                               timing=True)

        self.BLACK = 0
        self.RED = self.display.RED
        self.MAROON = self.display.MAROON
        self.GREEN = self.display.GREEN
        self.FOREST = self.display.FOREST
        self.BLUE = self.display.BLUE
        self.NAVY = self.display.NAVY
        self.CYAN = self.display.CYAN
        self.YELLOW = self.display.YELLOW
        self.PURPLE = self.display.PURPLE
        self.WHITE = self.display.WHITE
        self.GRAY = self.display.GRAY

        Pin(self._BL_PIN, Pin.OUT).value(0)
示例#6
0
    # Let it know about display, if display is enabled
    if LCD_ENABLE:
        remote.register_display(display)

# If buttons are enabled, initialize them
if BUTTONS_ENABLE:
    button_pins = {
        'PLAY_BUTTON': PLAY_BUTTON,
        'NEXT_BUTTON': NEXT_BUTTON,
        'PREV_BUTTON': PREV_BUTTON,
        'VDN_BUTTON': VDN_BUTTON,
        'VUP_BUTTON': VUP_BUTTON,
        'STOP_BUTTON': STOP_BUTTON
    }

    btn = buttons.buttons(button_pins, BOUNCE_TIME)

    # Register MPD client
    btn.register(mpdcl)

# Wait for MPD client thread to finish
mpdcl.join()

# If LCD is enabled, wait for it's thread to finish
if LCD_ENABLE:
    display.join()

# If remote is enabled, wait for it's thread to finish
if REMOTE_ENABLE:
    remote.join()