예제 #1
0
 def stop(self):
     if self.player != None:
         self.player.stop()
     if enable_display:
         scrollphat.clear()
     self.thread_running = False
     self.playing = False
예제 #2
0
 def displayText(text):
     scrollphat.clear()
     scrollphat.write_string(text)
     for i in range(0, scrollphat.buffer_len() - 11):
         scrollphat.scroll()
         sleep(0.1)
     scrollphat.clear()
    def display(self, amt):
        val = 0
        if(amt != None):
            val = int(amt)
            if(val > self.MAX):
                val = self.MAX
                self.flash(val)
                return

        if(val == self.last):
            return

        if(self.last > val):
            scrollphat.clear()

        self.last = val

        y = 0
        x = 0
        while(val > 0):
            scrollphat.set_pixel(x, y, True)
            scrollphat.update()
            x = x + 1
            if(x == 10):
                y = y + 1
                x = 0
            val = val -1
예제 #4
0
    def scrollInSteps(self, stepNumber):
        '''Sets the columns positions from scrolling in from stepNumber'''

        if self.args.verbose:
            print('Running SpaceInvader.scrollInSteps, stepNumber: {}'.format(
                stepNumber))

        # Arm Down
        if stepNumber == 1:
            self.armDownColumn(0, 10)

        # Arm Up
        elif stepNumber == 2:
            for i in range(0, 2):
                self.armUpColumn(i, i + 9)

        # Arm Down
        elif stepNumber == 3:
            for i in range(0, 3):
                self.armDownColumn(i, i + 8)

        # Arm Up
        if stepNumber == 4:
            for i in range(0, 4):
                self.armUpColumn(i, i + 7)

        # Arm Down
        elif stepNumber == 5:
            for i in range(0, 5):
                self.armDownColumn(i, i + 6)

        # Arm Up
        if stepNumber == 6:
            for i in range(0, 6):
                self.armUpColumn(i, i + 5)

        # Arm Down
        elif stepNumber == 7:
            for i in range(0, 7):
                self.armDownColumn(i, i + 4)

        # Arm Up
        if stepNumber == 8:
            for i in range(0, 8):
                self.armUpColumn(i, i + 3)

        # Arm Down
        elif stepNumber == 9:
            for i in range(0, 9):
                self.armDownColumn(i, i + 2)

        # Arm Up
        elif stepNumber == 10:
            for i in range(0, 10):
                self.armUpColumn(i, i + 1)

        scrollphat.update()
        time.sleep(self.args.pause_scroll)
        scrollphat.clear()
예제 #5
0
파일: cavejet.py 프로젝트: Zokol/CaveJet
 def print_scroll(self):
     scrollphat.clear()
     for x, col in enumerate(self.field.buffer):
         for y, pixel in enumerate(col):
             scrollphat.set_pixel(x, y, pixel)
     scrollphat.set_pixel(self.ai.player.x, self.ai.player.y, 1)
     if SCREEN_TYPE == "SCROLL": scrollphat.update()
     if SCREEN_TYPE == "SCROLLHD": scrollphat.show()
예제 #6
0
 async def poll_queue(self) -> None:
     while True:
         text = await self.queue.get()
         scrollphat.clear()
         scrollphat.write_string(text, 11)
         for _ in range(scrollphat.buffer_len()):
             scrollphat.scroll()
             await asyncio.sleep(self.period)
예제 #7
0
def displaySprite(sprite):
    """Display a simple sprite on the matrix.
    The sprite should be an array of 5 binary strings"""
    print("Displaying Sprite: %s"  % sprite)
    scrollphat.clear()
    for rowNum, row in enumerate(sprite):
        for colNum, cell in enumerate(row):
            scrollphat.set_pixel(colNum, rowNum, int(cell))
    scrollphat.update()
예제 #8
0
파일: cavejet.py 프로젝트: Zokol/CaveJet
 def set_checker(self, offset):
     scrollphat.clear()
     n = offset
     for y in range(SCREEN_HEIGHT):
         for x in range(SCREEN_WIDTH):
             scrollphat.set_pixel(x, y, n % 2 == 0)
             n += 1
     if SCREEN_TYPE == "SCROLL": scrollphat.update()
     if SCREEN_TYPE == "SCROLLHD": scrollphat.show()
예제 #9
0
def scroll_message_once():
    length = scrollphat.buffer_len()

    for i in range(length):
        try:
            scrollphat.scroll()
            time.sleep(0.1)
        except KeyboardInterrupt:
            scrollphat.clear()
            raise
예제 #10
0
파일: boozer.py 프로젝트: dryicebomb/boozer
def scroll_once(msg):
    scrollphat.write_string(msg, 11)
    length = scrollphat.buffer_len()

    for i in range(length):
        try:
            scrollphat.scroll()
            time.sleep(0.1)
        except KeyboardInterrupt:
            scrollphat.clear()
    def __init__(self):
        MID_LEVEL = 10
        scrollphat.clear()
        scrollphat.update()
        scrollphat.set_brightness(MID_LEVEL)

        self.last = 0
        self.HEIGHT = 5
        self.WIDTH = 11
        self.MAX = (self.WIDTH) * (self.HEIGHT)
예제 #12
0
파일: main.py 프로젝트: recantha/scroller
def display(message):
    if scrollphat_connected:
        scrollphat.clear()
        scrollphat.write_string(message + "       ", 11)
        for i in range(0, scrollphat.buffer_len() - 11):
            scrollphat.scroll()
            time.sleep(0.08)
    else:
        print(message)
        time.sleep(0.1)
예제 #13
0
    def show(self):
        '''Displays the twitter logo'''

        if self.args.verbose:
            print('Running Twitter.show')

        self.setCentered()
        scrollphat.update()
        time.sleep(self.args.pause_show)
        scrollphat.clear()
예제 #14
0
def display(message):
    if scrollphat_connected:
        scrollphat.clear()
        scrollphat.write_string(message + "       ", 11)
        for i in range(0, scrollphat.buffer_len() - 11):
            scrollphat.scroll()
            time.sleep(0.08)
    else:
        print(message)
        time.sleep(0.1)
예제 #15
0
def scrollText(text):
    """Scroll some text on the display once"""
    print("Displaying text: " + text)
    scrollphat.clear()
    # Write the text to the display, the extra space is to make scrolling look better.
    length = scrollphat.write_string("   " + text)
    for i in range(length - matrix_length):
        scrollphat.scroll()
        time.sleep(0.1)
    scrollphat.clear()
예제 #16
0
    def scrollOutSteps(self, stepNumber):
        '''Sets the columns positions from scrolling out from stepNumber'''

        if self.args.verbose:
            print('Running SpaceInvader.scrollOutSteps, stepNumber: {}'.format(
                stepNumber))

        # Arm Up
        if stepNumber == 1:
            for i in range(1, 10):
                self.armUpColumn(i, i - 1)

        # Arm Down
        elif stepNumber == 2:
            for i in range(2, 10):
                self.armDownColumn(i, i - 2)

        # Arm Up
        elif stepNumber == 3:
            for i in range(3, 10):
                self.armUpColumn(i, i - 3)

        # Arm Down
        elif stepNumber == 4:
            for i in range(4, 10):
                self.armDownColumn(i, i - 4)

        # Arm Up
        elif stepNumber == 5:
            for i in range(5, 10):
                self.armUpColumn(i, i - 5)

        # Arm Down
        elif stepNumber == 6:
            for i in range(6, 10):
                self.armDownColumn(i, i - 6)

        # Arm Up
        elif stepNumber == 7:
            for i in range(7, 10):
                self.armUpColumn(i, i - 7)

        # Arm Down
        elif stepNumber == 8:
            for i in range(8, 10):
                self.armDownColumn(i, i - 8)

        # Arm Up
        elif stepNumber == 9:
            self.armUpColumn(9, 0)

        scrollphat.update()
        time.sleep(self.args.pause_scroll)
        scrollphat.clear()
예제 #17
0
async def poll_queue() -> None:
    if not HAS_SCROLLPHAT:
        return

    while True:
        text = await QUEUE.get()
        scrollphat.clear()
        scrollphat.write_string(text, 11)
        for _ in range(scrollphat.buffer_len()):
            scrollphat.scroll()
            await asyncio.sleep(1 / SPEED)
예제 #18
0
def print_tweet(tweet):
    scrollphat.clear()
    scrollphat.set_brightness(7)
    scrollphat.write_string(tweet)
    x = 0
    # scroll the message twice
    while x < (scrollphat.buffer_len()*2):
        scrollphat.scroll()
        sleep(0.1)
        x += 1
    scrollphat.clear()
예제 #19
0
파일: debug.py 프로젝트: Dalekbot/dalekbot
def print_to_all_devices(text, code=None):

    if debug_on:
        if output_device == 0:
            print(text)
        elif output_device == 1:
            # scrollphat
            print(text)
            if code != None:
                scrollphat.clear()
                scrollphat.write_string(code)
            pass
예제 #20
0
    def clear(fast=False):
        log_str('clear scroll')

        if not fast:
            for x in range(11):
                for y in range(5):
                    scrollphat.set_pixel(x, y, 0)
                    sleep(0.015)
                    scrollphat.update()

        scrollphat.clear_buffer()
        scrollphat.clear()
        scrollphat.update()
예제 #21
0
def main():
    scrollphat.clear()
    while True:
        try:
            current_time = get_time()
            update_display(current_time)
            time.sleep(1)
            new_current_time = get_time()
            if current_time != new_current_time:
                update_display(new_current_time)
        except KeyboardInterrupt:
            scrollphat.clear()
            exit(1)
예제 #22
0
    def dance(self, position):
        '''Sets the tree to dance vertically from position'''

        if self.args.verbose:
            print('Running DisplayVertical.dance, position: %s' % position)
            print('Dancing for %s times' % self.args.dance_times)

        for i in range(0, self.args.dance_times):

            # Center
            self.setPositionCenter(position)
            scrollphat.update()
            time.sleep(args.pause_dance)
            scrollphat.clear()

            # Left
            self.setPositionLeft(position)
            scrollphat.update()
            time.sleep(args.pause_dance)
            scrollphat.clear()

            # Center
            self.setPositionCenter(position)
            scrollphat.update()
            time.sleep(args.pause_dance)
            scrollphat.clear()

            # Right
            self.setPositionRight(position)
            scrollphat.update()
            time.sleep(args.pause_dance)
            scrollphat.clear()
예제 #23
0
def test_scrollphat():
    import scrollphat
    scrollphat.set_brightness(2)

    scrollphat.write_string("BOOZER", 11)
    length = scrollphat.buffer_len()

    for i in range(length):
        try:
            scrollphat.scroll()
            time.sleep(0.1)
        except KeyboardInterrupt:
            scrollphat.clear()
            sys.exit(-1)
예제 #24
0
    def fall(self):
        '''Displays snow like pixels falling'''

        if self.verbose:
            print('Running Snow.fall')

        buf_00 = [1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]
        buf_01 = [2, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0]
        buf_02 = [4, 0, 1, 0, 2, 0, 0, 0, 4, 0, 1]
        buf_03 = [8, 0, 2, 0, 4, 0, 1, 0, 8, 0, 2]
        buf_04 = [16, 1, 4, 0, 8, 0, 2, 0, 16, 0, 4]

        buf_05 = [0, 2, 8, 0, 16, 1, 4, 0, 0, 1, 8]
        buf_06 = [0, 4, 16, 1, 0, 2, 8, 0, 0, 2, 16]
        buf_07 = [0, 8, 0, 2, 0, 4, 16, 0, 0, 4, 0]
        buf_08 = [0, 16, 0, 4, 0, 8, 0, 0, 1, 8, 0]

        buf_09 = [1, 0, 0, 8, 0, 16, 0, 0, 2, 16, 0]
        buf_10 = [2, 0, 0, 16, 1, 0, 0, 0, 4, 0, 0]
        buf_11 = [4, 0, 1, 0, 2, 0, 0, 0, 8, 0, 1]
        buf_12 = [8, 0, 2, 0, 4, 0, 1, 0, 16, 0, 2]
        buf_13 = [16, 1, 4, 1, 8, 0, 2, 0, 0, 1, 4]

        buf_14 = [0, 2, 8, 2, 16, 0, 4, 0, 0, 2, 8]
        buf_15 = [0, 4, 16, 4, 0, 0, 8, 0, 0, 4, 16]
        buf_16 = [0, 8, 0, 8, 0, 0, 16, 0, 0, 8, 0]
        buf_17 = [0, 16, 0, 16, 0, 0, 0, 0, 0, 16, 0]

        for i in range(0, self.fallTimes):
            self.bufferFall(buf_00)
            self.bufferFall(buf_01)
            self.bufferFall(buf_02)
            self.bufferFall(buf_03)
            self.bufferFall(buf_04)
            self.bufferFall(buf_05)
            self.bufferFall(buf_06)
            self.bufferFall(buf_07)
            self.bufferFall(buf_08)
            self.bufferFall(buf_09)
            self.bufferFall(buf_10)
            self.bufferFall(buf_11)
            self.bufferFall(buf_12)
            self.bufferFall(buf_13)
            self.bufferFall(buf_14)
            self.bufferFall(buf_15)
            self.bufferFall(buf_16)
            self.bufferFall(buf_17)

        scrollphat.clear()
예제 #25
0
    def scrollRightLeftInSteps(self, stepNumber):
        '''Sets the columns positions for right to left scrolling in from stepNumber'''

        if self.args.verbose:
            print('Running Twitter.scrollRightLeftInSteps, stepNumber: %s' %
                  stepNumber)

        if stepNumber == 1:
            self.columnPosition(10, 0)

        elif stepNumber == 2:
            for i in range(9, 11):
                self.columnPosition(i, i - 9)

        elif stepNumber == 3:
            for i in range(8, 11):
                self.columnPosition(i, i - 8)

        elif stepNumber == 4:
            for i in range(7, 11):
                self.columnPosition(i, i - 7)

        elif stepNumber == 5:
            for i in range(6, 11):
                self.columnPosition(i, i - 6)

        elif stepNumber == 6:
            for i in range(5, 11):
                self.columnPosition(i, i - 5)

        elif stepNumber == 7:
            for i in range(4, 11):
                self.columnPosition(i, i - 4)

        elif stepNumber == 8:
            for i in range(3, 11):
                self.columnPosition(i, i - 3)

        elif stepNumber == 9:
            for i in range(2, 11):
                self.columnPosition(i, i - 2)

        elif stepNumber == 10:
            for i in range(1, 11):
                self.columnPosition(i, i - 1)

        scrollphat.update()
        time.sleep(self.args.pause_scroll)
        scrollphat.clear()
예제 #26
0
    def scrollRightLeftOutSteps(self, stepNumber):
        '''Sets the columns positions for right to left scrolling out from stepNumber'''

        if self.args.verbose:
            print('Running Twitter.scrollRightLeftOutSteps, stepNumber: %s' %
                  stepNumber)

        if stepNumber == 1:
            for i in range(0, 10):
                self.columnPosition(i, i + 1)

        elif stepNumber == 2:
            for i in range(0, 9):
                self.columnPosition(i, i + 2)

        elif stepNumber == 3:
            for i in range(0, 8):
                self.columnPosition(i, i + 3)

        elif stepNumber == 4:
            for i in range(0, 7):
                self.columnPosition(i, i + 4)

        elif stepNumber == 5:
            for i in range(0, 6):
                self.columnPosition(i, i + 5)

        elif stepNumber == 6:
            for i in range(0, 5):
                self.columnPosition(i, i + 6)

        elif stepNumber == 7:
            for i in range(0, 4):
                self.columnPosition(i, i + 7)

        elif stepNumber == 8:
            for i in range(0, 3):
                self.columnPosition(i, i + 8)

        elif stepNumber == 9:
            for i in range(0, 2):
                self.columnPosition(i, i + 9)

        elif stepNumber == 10:
            self.columnPosition(0, 10)

        scrollphat.update()
        time.sleep(self.args.pause_scroll)
        scrollphat.clear()
예제 #27
0
def destroy():  # Shutdown GPIO and Cleanup modules
    print "\n... Shutting Down...\n"
    scrollphat.clear()  # Shutdown Scroll pHat
    scrollphat.write_string("Ext")
    DalekV2Drive.stop()  # Make sure Bot is not moving when program exits
    DalekV2Drive.cleanup()  # Shutdown all motor control
    global camera  # Allow Access to PiCamera Object
    if camera._check_camera_open() == True:
        camera.close()  # Shutdown Pi Camera
    global wii
    wii.rumble = 1
    time.sleep(0.5)
    wii.rumble = 0
    scrollphat.clear()  # Clear Scroll pHat
    GPIO.cleanup()  # Release GPIO resource
예제 #28
0
    def textScroll(self, text):
        '''Displays a text at the scroll-pHAT'''

        if self.args.verbose:
            print('Running Twitter.textScroll, text: %s' % text)

        scrollphat.write_string(text, 11)
        length = scrollphat.buffer_len()

        for i in range(length):
            try:
                scrollphat.scroll()
                time.sleep(self.args.pause_text_scroll)
            except KeyboardInterrupt:
                scrollphat.clear()
                sys.exit(-1)
예제 #29
0
파일: debug.py 프로젝트: Dalekbot/dalekbot
def set_output_device(_dalekDebugOutputDevice):
    """ 
    sets the output device 
    default is stout/command line only
    "scollphat" adds the bots display as well as stout
    """
    global output_device

    if _dalekDebugOutputDevice == "scrollphat":

        scrollphat.clear()
        scrollphat.write_string("BOT")
        output_device = 1
        debug_on = True  # assume that as it is set,  use it.
    else:
        output_device = 0
예제 #30
0
    def scrollRightLeftOutSteps(self, stepNumber):
        '''Sets the columns positions from right to left scrolling-out from stepNumber'''

        if self.args.verbose:
            print(
                'Running Pacman.scrollLeftRightInSteps, stepNumber: {}'.format(
                    stepNumber))

        # Open
        if stepNumber == 1:
            for i in range(0, 5):
                self.mouthOpenColumn(i, 6 - i)

        # Closed
        elif stepNumber == 2:
            for i in range(0, 5):
                self.mouthClosedColumn(i, 5 - i)

        # Open
        elif stepNumber == 3:
            for i in range(0, 5):
                self.mouthOpenColumn(i, 4 - i)

        # Closed
        elif stepNumber == 4:
            for i in range(0, 4):
                self.mouthClosedColumn(i, 3 - i)

        # Open
        elif stepNumber == 5:
            for i in range(0, 3):
                self.mouthOpenColumn(i, 2 - i)

        # Closed
        elif stepNumber == 6:
            for i in range(0, 2):
                self.mouthClosedColumn(i, 1 - i)

        # Open
        elif stepNumber == 7:
            self.mouthOpenColumn(0, 0)

        scrollphat.update()
        time.sleep(self.args.pause_scroll)
        scrollphat.clear()
예제 #31
0
    def scrollRightLeftInSteps(self, stepNumber):
        '''Sets the columns positions from right to left scrolling-in from stepNumber'''

        if self.args.verbose:
            print(
                'Running Pacman.scrollLeftRightInSteps, stepNumber: {}'.format(
                    stepNumber))

        # Open
        if stepNumber == 1:
            self.mouthOpenColumn(4, 10)

        # Closed
        elif stepNumber == 2:
            for i in range(3, 5):
                self.mouthClosedColumn(i, 13 - i)

        # Open
        elif stepNumber == 3:
            for i in range(2, 5):
                self.mouthOpenColumn(i, 12 - i)

        # Closed
        elif stepNumber == 4:
            for i in range(1, 5):
                self.mouthClosedColumn(i, 11 - i)

        # Open
        elif stepNumber == 5:
            for i in range(0, 5):
                self.mouthOpenColumn(i, 10 - i)

        # Closed
        elif stepNumber == 6:
            for i in range(0, 5):
                self.mouthClosedColumn(i, 9 - i)

        # Open
        elif stepNumber == 7:
            for i in range(0, 5):
                self.mouthOpenColumn(i, 8 - i)

        scrollphat.update()
        time.sleep(self.args.pause_scroll)
        scrollphat.clear()
예제 #32
0
파일: r2d2.py 프로젝트: jaygit/r2d2_clock
def led_status(buttonPin):
	global option, RED, YELLOW, BLUE, GREEN, LED
	if GPIO.input(buttonPin) == GPIO.HIGH:

		print ("LED OFF")
	else:
		print ("LED ON")
		time_hour = int(strftime("%H", time.localtime()))
		say_greeting(time_hour)
		if option == 1:
			LED = GREEN
			current = say_clock()
			cur_time = strftime("%H:%M", time.localtime())

			current =  cur_time + "     " + current

		elif option == 2:
			LED=RED
			current = say_date()

		elif option == 3:
			LED = YELLOW
			current = say_weather() 

		print current

		scrollphat.set_brightness(4)
		while True:
		    try:
			GPIO.output(LED, GPIO.HIGH)
			scrollphat.write_string(current ) 
			scrollphat.scroll()
			time.sleep(0.1)
			GPIO.output(LED, GPIO.LOW)
			if GPIO.input(buttonPin) == GPIO.HIGH:
				raise KeyboardInterrupt()
		    except KeyboardInterrupt:
			play_sound("stop")
			scrollphat.clear()
			GPIO.output(LED, GPIO.LOW)
			option += 1
			if option > 3:
				option = 1

			return
예제 #33
0
    def scrollLeftRightOutSteps(self, stepNumber):
        '''Sets the columns positions from left to right scrolling-out from stepNumber'''

        if self.args.verbose:
            print('Running Pacman.scrollLeftRightOutSteps, stepNumber: %s' %
                  stepNumber)

        # Open
        if stepNumber == 1:
            for i in range(0, 5):
                self.mouthOpenColumn(i, i + 4)

        # Closed
        elif stepNumber == 2:
            for i in range(0, 5):
                self.mouthClosedColumn(i, i + 5)

        # Open
        elif stepNumber == 3:
            for i in range(0, 5):
                self.mouthOpenColumn(i, i + 6)

        # Closed
        elif stepNumber == 4:
            for i in range(0, 4):
                self.mouthClosedColumn(i, i + 7)

        # Open
        elif stepNumber == 5:
            for i in range(0, 3):
                self.mouthOpenColumn(i, i + 8)

        # Closed
        elif stepNumber == 6:
            for i in range(0, 2):
                self.mouthClosedColumn(i, i + 9)

        # Open
        elif stepNumber == 7:
            self.mouthOpenColumn(0, 10)

        scrollphat.update()
        time.sleep(self.args.pause_scroll)
        scrollphat.clear()
예제 #34
0
    def scrollLeftRightInSteps(self, stepNumber):
        '''Sets the columns positions from left to right scrolling-in from stepNumber'''

        if self.args.verbose:
            print('Running Pacman.scrollLeftRightInSteps, stepNumber: %s' %
                  stepNumber)

        # Open
        if stepNumber == 1:
            self.mouthOpenColumn(4, 0)

        # Closed
        elif stepNumber == 2:
            for i in range(3, 5):
                self.mouthClosedColumn(i, i - 3)

        # Open
        elif stepNumber == 3:
            for i in range(2, 5):
                self.mouthOpenColumn(i, i - 2)

        # Closed
        elif stepNumber == 4:
            for i in range(1, 5):
                self.mouthClosedColumn(i, i - 1)

        # Open
        elif stepNumber == 5:
            for i in range(0, 5):
                self.mouthOpenColumn(i, i)

        # Closed
        elif stepNumber == 6:
            for i in range(0, 5):
                self.mouthClosedColumn(i, i + 1)

        # Open
        elif stepNumber == 7:
            for i in range(0, 5):
                self.mouthOpenColumn(i, i + 2)

        scrollphat.update()
        time.sleep(self.args.pause_scroll)
        scrollphat.clear()
예제 #35
0
def update(count):

    global last

    scrollphat.set_pixel(10,4,0)

    if count == None:

        scrollphat.clear()
        scrollphat.write_string("----")

    else:

        if count != last:

            scrollphat.clear()
            scrollphat.write_string(str(count))

            last = count
예제 #36
0
def update(count):

    global last

    scrollphat.set_pixel(10, 4, 0)

    if count == None:

        scrollphat.clear()
        scrollphat.write_string("----")

    else:

        if count != last:

            scrollphat.clear()
            scrollphat.write_string(str(count))

            last = count
예제 #37
0
def destroy():                 # Shutdown GPIO and Cleanup modules

    global soundvolume         # Allow access to sound volume
        
    print ('\n... Shutting Down...\n')
    scrollphat.clear()         # Shutdown Scroll pHat
    scrollphat.write_string('Ext')
    DalekV2Drive.stop()        # Make sure Bot is not moving when program exits
    DalekV2Drive.cleanup()     # Shutdown all motor control
    global wii                 # Allow access to the wii object
    wii.rumble = 1
    time.sleep(0.5)
    wii.rumble = 0
    cv2.destroyAllWindows()    # Shutdown any open windows
    volumesetting = '"--volume=' + str(soundvolume) +'"'
    subprocess.Popen(['mplayer',volumesetting, 'Sound/Grow_stronger.mp3'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    time.sleep(7)
    scrollphat.clear()         # Clear Scroll pHat
    GPIO.cleanup()             # Release GPIO resource
    def draw(self, game):

        text = game.get_scroller_text()

        if text != '':

           scrollphat.write_string(text)
           scrollphat.scroll()
           time.sleep(0.06)

        else:

            scrollphat.clear()

            for x, y in game.get_pixels():
                pixel = int(x), int(y)
                scrollphat.set_pixel(pixel[0], pixel[1], 1)

            scrollphat.update()
예제 #39
0
 def on_success(self, data):
     if 'text' in data:
         h = HTMLParser.HTMLParser()
         user = data['user']['screen_name'].encode('utf-8')
         raw_tweet = h.unescape(data['text'])
         tweet = self.remove_link('     @{}: {}'.format(user.encode('utf-8'), raw_tweet.encode('utf-8')))
         if enable_scrollphat == True:
             scrollphat.write_string(tweet.upper())
             status_length = scrollphat.buffer_len()
             while status_length > 0:
                 scrollphat.scroll()
                 time.sleep(0.1)
                 status_length -= 1
             scrollphat.clear()
         else:
             try:
                 # i can't figure out how to print things reliably on windows with this crapping itself
                 print unicode(tweet).encode('ascii')
             except:
                 print '     @{}: Could not display tweet'.format(user.encode('utf-8'))
예제 #40
0
def standby_process(threadName, q):
    while not exitFlag:
        queueLock.acquire()
        if not q.empty():
            data = q.get()
            queueLock.release()
            print "%s processing %s" % (threadName, data)
            if 'text' in data:
                scrollText(data['text'])
                time.sleep(1)
            if 'spriteName' in data:
                displaySpriteFromName(data['spriteName'])
                time.sleep(1)
            if 'sprite' in data:
                displaySprite(data['sprite'])
                time.sleep(1)
        else:
            queueLock.release()
        time.sleep(1)
    scrollphat.clear()
예제 #41
0
파일: test.py 프로젝트: RaspiKidd/RaspiJam
print joystick.get_axis(0)			# Get the current number of axis

brightness = 20					# Setting brightness on scroll phat

w, h = (11, 5)					# Setting width and height
x, y = (0, 0)					# Setting x and y 

grav = 0.5					# Setting Gravity
jump_vel = 0					# Setting jump velocity
jump_decay = 0.8				# Setting jump decay

move_speed = 1					# Setting movement speed

while True:					# Loop forever

    scrollphat.clear()				# Clearing the display
    scrollphat.set_brightness(brightness)	# Getting the brightness for LEDS
    scrollphat.set_pixel(int(x), int(y), 1)	# Setting pixel to show in bottom left corner
    scrollphat.update()				# Updating scroll phat	
    time.sleep(0.03)				# Set scroll phat to sleep for .3 seconds

    pygame.event.pump()				# Processes pygame event handlers internally

    axis_value = joystick.get_axis(0)		# Setting axis value for x

    if axis_value > 0.8:			# If axis value is greater than 0.8 
        x += move_speed				# increase move speed of x
    elif axis_value < -0.8:			# If axis value is less than 0.8
        x -= move_speed				# Decrease move speed

    if x >= w:					# if x is greater than width
예제 #42
0
def ledclear():
        scrollphat.clear()
 def flash(self,val):
     scrollphat.clear()
     self.slow_fill(val,0.01)
예제 #44
0
파일: flystick.py 프로젝트: jsa/flystick
def main():
    global _output

    pygame.init()

    # Reading only "clicks" via events. These are used for advanced
    # mappings. Events to avoid tracking state manually. Axes are read
    # by snapshotting.
    pygame.event.set_allowed([pygame.JOYBUTTONDOWN,
                              pygame.JOYHATMOTION])

    pi_gpio = 1 << PPM_OUTPUT_PIN

    if pigpio:
        pi = pigpio.pi()
        pi.set_mode(PPM_OUTPUT_PIN, pigpio.OUTPUT)
        pi.wave_add_generic([pigpio.pulse(pi_gpio, 0, 2000)])
        # padding to make deleting logic easier
        waves = [None, None, pi.wave_create()]
        pi.wave_send_repeat(waves[-1])
    else:
        pi = None

    if scrollphat:
        scrollphat.clear()
        scrollphat.set_brightness(DISPLAY_BRIGHTNESS)
        # fork to avoid crash in case of I2C connection issues
        th = threading.Thread(target=render)
        th.daemon = True
        th.start()

    prev = None

    while _running:
        # clicks for advanced mapping
        clicks, hats = [], []
        for evt in pygame.event.get():
            if evt.type == pygame.JOYBUTTONDOWN:
                #print "JOYBUTTONDOWN: %r\n%s" % (evt, dir(evt))
                clicks.append(evt)
            elif evt.type == pygame.JOYHATMOTION and any(evt.value):
                #print "JOYHATMOTION: %r\n%s" % (evt, dir(evt))
                hats.append(evt)

        # tuple to enforce immutability
        _output = tuple(max(min(ch((clicks, hats)), 1.), -1.)
                        for ch in CHANNELS)

        if _output == prev:
            # do nothing
            pass

        elif pigpio:
            pulses, pos = [], 0
            for value in _output:
                # calibrated with Taranis to [-99.6..0..99.4]
                us = int(round(1333 + 453 * value))
                pulses += [pigpio.pulse(0, pi_gpio, 300),
                           pigpio.pulse(pi_gpio, 0, us - 300)]
                pos += us

            pulses += [pigpio.pulse(0, pi_gpio, 300),
                       pigpio.pulse(pi_gpio, 0, 20000 - 300 - pos - 1)]

            pi.wave_add_generic(pulses)
            waves.append(pi.wave_create())
            pi.wave_send_using_mode(waves[-1], pigpio.WAVE_MODE_REPEAT_SYNC)

            last, waves = waves[0], waves[1:]
            if last:
                pi.wave_delete(last)

        else:
            # debugging
            print str(_output)

        prev = _output

        # NO BUSYLOOPING. And locking with ``pygame.event.wait`` doesn't sound
        # very sophisticated. (At this point, at least.)
        time.sleep(.02)

    if scrollphat:
        scrollphat.clear()
    if pi:
        pi.stop()
 def __init__(self, brightness):
     scrollphat.set_brightness(brightness)
     scrollphat.clear()
     scrollphat.update()
    sp.update()
    time.sleep(0.02)
    for r in range(0,2):
        y = randint(0,4)
        x = randint(0,10)
        sp.set_pixel(x,y,0)
        sp.update()
        time.sleep(0.01)
    if clear > 993:
        if clear > 996:
            for w in range(0,randint(3,9)):
                for x in range(0,11):
                    for y in range(0,5):
                        sp.set_pixel(x,y,randint(0,1))
                        sp.set_brightness(128)
                sp.update()
                time.sleep(0.01)
                sp.clear()
                time.sleep(0.01)
        else:
            for w in range(0,randint(3,9)):
                for x in range(0,11):
                    for y in range(0,randint(1,5)):
                        sp.set_pixel(x,y,1)
                        sp.set_brightness(128)
                sp.update()
                time.sleep(0.01)
                sp.clear()
                time.sleep(0.01)
    
예제 #47
0
		display_str = hour + ":" + minute + "  " + temp_str + summary

		# 'M' and 'W' take 6 spaces, rather than 4
		num_m = display_str.count('M')
		num_w = display_str.count('W')
		neg = display_str.count('-')
                # Each letter takes 4 LEDs to display (including trailing space)
                # -1 because the degree symbol only takes 2 LEDs
		# -1 because colon symbol only takes 2 LEDs
		# -2 for each space added to string
                # -11 because they are shown before we need to scroll
                # -1 because there's no trailing space after last letter
		scroll_len = len(display_str)*4 - 1 - 1 - 4 - 11 - 1 + 2*(num_m+num_w) - 1*neg

		s.clear()
		s.write_string(display_str)
		t.sleep(1)
		for i in range(scroll_len):
			t.sleep(0.08)
			s.scroll()
		t.sleep(0.5)

                # Update the weather forecast every 5 minutes
		if ((t.time() - start_time) > 5*60):
			try:
				forecast = f.load_forecast(api_key, lat, lng, units='si')
				current_forecast = forecast.currently()
			except:
				pass
			start_time = t.time()
#!/usr/bin/env python
import sys
import time
import scrollphat

scrollphat.clear()    # Clear pHAT display ensuring nothing is displayed prior to starting

while True:
    try:
        dNumLng = time.strftime("%d")  # Long day with any leading zeroes
        dNum = dNumLng.lstrip("0")     # Strip leading zeroes, if any

        def get_day_sufx(dNum):        # Work out "st", "nd", "rd" or "th"
            if dNum == ("1","21","31"):
                return "st"
            if dNum == ("2","22"):
                return "nd"
            if dNum == ("3","23"):
                return "rd"
            else:
                return "th"

        sufx = get_day_sufx(dNum)   # Run above, supply date, create suffix
        dNam = time.strftime("%A")  # Day name
        mnth = time.strftime("%B")  # Month name (full)
        year = time.strftime("%Y")  # Year (4 digits)
        hour = time.strftime("%H")  # Hours (24 hours)
        mins = time.strftime("%M")  # Minutes
        secs = time.strftime("%S")  # Seconds

        # Assemble all the variables into a single string
    def clear(self):

        scrollphat.clear()
예제 #50
0
        json_data = json.loads(res.text)

        # this response also contains rich geo-location data
        ip = json_data['ip']
    return ip

def get_ip(mode):
    return get_public_ip() if mode == "public" else get_internal_ip()
#    return mode == "public" ? get_public_ip() : get_internal_ip()
    
address_mode = "public"
if(len(sys.argv) == 2):
    address_mode = sys.argv[1]

ip = get_ip(address_mode)

print(address_mode + " IP Address: " +str(ip))

scrollphat.set_brightness(3)

while True:	
    try:
        scrollphat.clear()
        scrollphat.write_string("IP: " + str(ip) + "    ")
        for i in range(0, scrollphat.buffer_len() - 11):
            scrollphat.scroll()
            time.sleep(0.1)
    except KeyboardInterrupt:
        scrollphat.clear()
        sys.exit(-1)
예제 #51
0
파일: evan.py 프로젝트: Edgar121/Raspberry
#!/usr/bin/env python

import scrollphat
import math
import time
import sys

buf = [0] * 11
scrollphat.clear();
scrollphat.set_brightness(20)

buf[0] = 29;



scrollphat.set_buffer(buf)
scrollphat.update()