当前位置: 首页>>代码示例>>Python>>正文


Python AstroPi.show_message方法代码示例

本文整理汇总了Python中astro_pi.AstroPi.show_message方法的典型用法代码示例。如果您正苦于以下问题:Python AstroPi.show_message方法的具体用法?Python AstroPi.show_message怎么用?Python AstroPi.show_message使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在astro_pi.AstroPi的用法示例。


在下文中一共展示了AstroPi.show_message方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: AstroPi

# 需要导入模块: from astro_pi import AstroPi [as 别名]
# 或者: from astro_pi.AstroPi import show_message [as 别名]
from astro_pi import AstroPi
ap = AstroPi()
while True:
    ap.show_message("Astro Pi is awesome!!",scroll_speed=0.05,text_colour=[255,255,0],back_colour=[0,0,255])
开发者ID:LornaLynch,项目名称:getting-started-with-astro-pi,代码行数:6,代码来源:loop_text.py

示例2: AstroPi

# 需要导入模块: from astro_pi import AstroPi [as 别名]
# 或者: from astro_pi.AstroPi import show_message [as 别名]
from astro_pi import AstroPi
ap = AstroPi()

while True:
    t = ap.get_temperature()
    p = ap.get_pressure()
    h = ap.get_humidity()

    t = round(t,1)
    p = round(p,1)
    h = round(h,1)

    msg = "Temperature = %s, Pressure=%s, Humidity=%s" % (t,p,h)

    ap.show_message(msg,scroll_speed=0.05)
开发者ID:LornaLynch,项目名称:getting-started-with-astro-pi,代码行数:17,代码来源:env.py

示例3: print

# 需要导入模块: from astro_pi import AstroPi [as 别名]
# 或者: from astro_pi.AstroPi import show_message [as 别名]
e,e,e,g,g,e,e,e,
e,e,g,g,g,g,e,e,
e,g,e,g,g,e,g,e,
g,e,e,g,g,e,e,g,
e,e,e,g,g,e,e,e,
e,e,e,g,g,e,e,e,
e,e,e,g,g,e,e,e,
e,e,e,g,g,e,e,e
]

pause = 3
score = 0
angle = 0
play = True

ap.show_message("Keep the arrow pointing up",scroll_speed=0.05,text_colour=[100,100,100])

while play == True:
    last_angle = angle
    while angle == last_angle:
      angle = random.choice([0,90,180,270])
    ap.set_rotation(angle)
    ap.set_pixels(arrow)
    time.sleep(pause)

    x,y,z = ap.get_accelerometer_raw().values()
    x=round(x,0)
    y=round(y,0)

    print (angle)
    print (x)
开发者ID:LornaLynch,项目名称:getting-started-with-astro-pi,代码行数:33,代码来源:reaction_game.py

示例4: AstroPi

# 需要导入模块: from astro_pi import AstroPi [as 别名]
# 或者: from astro_pi.AstroPi import show_message [as 别名]
#!/usr/bin/python
from astro_pi import AstroPi

ap = AstroPi()
ap.set_rotation(180)
ap.show_message("One small step for Pi!", text_colour=[255, 0, 0])
开发者ID:New380,项目名称:astro-pi-hat,代码行数:8,代码来源:text_scroll.py

示例5: AstroPi

# 需要导入模块: from astro_pi import AstroPi [as 别名]
# 或者: from astro_pi.AstroPi import show_message [as 别名]
#!/usr/bin/python
from astro_pi import AstroPi
import time

ap = AstroPi()
temp = ap.get_temperature()
humidity = ap.get_humidity()
pressure = ap.get_pressure()

while True:
    ap.set_rotation(180)

    print("Temperature: %s C" % temp)
    ap.show_message("Temperature: %.1f C" % temp, scroll_speed=0.1, text_colour$
    time.sleep(1)

    print("Humidity: %.2f %%rH" % humidity)
    ap.show_message("Humidity: %.1f %%rH" % humidity, scroll_speed=0.1, text_co$
    time.sleep(1)

    print("Pressure: %.2f mb" % pressure)
    ap.show_message("Pressure: %.1f mb" % pressure, scroll_speed=0.1, text_colo$
    time.sleep(1)

ap.clear()
开发者ID:stevenjbagnall,项目名称:Astro-Pi,代码行数:27,代码来源:TempHumPress.py

示例6: AstroPi

# 需要导入模块: from astro_pi import AstroPi [as 别名]
# 或者: from astro_pi.AstroPi import show_message [as 别名]
# Magic 8 Ball

import random
import time
from astro_pi import AstroPi

ap = AstroPi()

ap.show_message("Ask a question", scroll_speed=(0.06))
time.sleep(3)

replies = [
    "Signs point to yes",
    "Without a doubt",
    "You may rely on it",
    "Do not count on it",
    "Looking good",
    "Cannot predict now",
    "It is decidedly so",
    "Outlook not so good",
]

ap.show_message(random.choice(replies), scroll_speed=(0.06))
开发者ID:MarcScott,项目名称:magic-8-ball,代码行数:25,代码来源:magic8ball1.py

示例7: AstroPi

# 需要导入模块: from astro_pi import AstroPi [as 别名]
# 或者: from astro_pi.AstroPi import show_message [as 别名]
from astro_pi import AstroPi
ap = AstroPi()

while True:
    t = ap.get_temperature()
    p = ap.get_pressure()
    h = ap.get_humidity()

    t = round(t,1)
    p = round(p,1)
    h = round(h,1)

    if t > 18.3 and t< 26.7:
        bg = [0,100,0] #green
    else:
        bg = [100,0,0] #red

    msg = "Temperature = %s, Pressure=%s, Humidity=%s" % (t,p,h)

    ap.show_message(msg,scroll_speed=0.05,backcolour=bg)
开发者ID:LornaLynch,项目名称:getting-started-with-astro-pi,代码行数:22,代码来源:scrolling_env.py

示例8: AstroPi

# 需要导入模块: from astro_pi import AstroPi [as 别名]
# 或者: from astro_pi.AstroPi import show_message [as 别名]
#!/usr/bin/python
from astro_pi import AstroPi
import time

ap = AstroPi()
temp = ap.get_temperature()
humidity = ap.get_humidity()
pressure = ap.get_pressure()


print("Temperature: %s C" % temp)               # Show temp on console
print("Humidity: %s %%rH" % humidity)        # Show humidity on console
print("Pressure: %s Millibars" % pressure)    # Show pressure on console

ap.set_rotation(180)        # Set LED matrix to scroll from right to left
              
ap.show_message("Temperature: %.2f C" % temp, scroll_speed=0.05, text_colour=[0, 255, 0])

time.sleep(1)           # Wait 1 second

ap.show_message("Humidity: %.2f %%rH" % humidity, scroll_speed=0.05, text_colour=[255, 0, 0]) 

time.sleep(1)      # Wait 1 second

ap.show_message("Pressure: %.2f Millibars" % humidity, scroll_speed=0.05, text_colour=[0, 0, 255])

ap.clear()      # Clear LED matrix
开发者ID:ontheplains,项目名称:Raspberry-Pi-Code,代码行数:29,代码来源:astroPi.py

示例9: AstroPiSnake

# 需要导入模块: from astro_pi import AstroPi [as 别名]
# 或者: from astro_pi.AstroPi import show_message [as 别名]
class AstroPiSnake():
    UP = 0
    DOWN = 1
    RIGHT = 2
    LEFT = 3

    BACKCOL = [0, 0, 0]
    SNAKECOL = [0, 255, 0]
    APPLECOL = [255, 0, 0]
    
    def __init__(self):
        pygame.init()
        pygame.display.set_mode((640, 480))
        
        self.ap = AstroPi()
        
    def startGame(self):
        self.ap.clear(self.BACKCOL)
        self.direction = self.UP
        self.length = 3
        self.tail = []
        self.tail.insert(0, [4, 4])
        self.createApple()
        self.score = 0
        
        playing = True
        while(playing):
            sleep(0.5)
            for event in pygame.event.get():
                if event.type == KEYDOWN:
                    self._handle_event(event)
            playing = self.move()

        self.ap.clear()

    def _handle_event(self, event):
        if event.key == pygame.K_DOWN:
            self.down()
        elif event.key == pygame.K_UP:
            self.up()
        elif event.key == pygame.K_LEFT:
            self.left()
        elif event.key == pygame.K_RIGHT:
            self.right()
        
    def createApple(self):
        badApple = True
        #try and fnd a location for the apple
        while(badApple):
            x = randint(0, 7)
            y = randint(0, 7)
            badApple = self.checkCollision(x, y)
        self.apple = [x, y]
        self.ap.set_pixel(x, y, self.APPLECOL)

    def checkCollision(self, x, y):
        #is this outside the screen
        if x > 7 or x < 0 or y > 7 or y < 0:
            return True
        else:
            #or in the snakes tail
            for segment in self.tail:
                if segment[0] == x and segment[1] == y:
                    return True
            else:
                return False

    def addSegment(self, x, y):
        #create the new segment of the snake
        self.ap.set_pixel(x, y, self.SNAKECOL)
        self.tail.insert(0, [x, y])
        
        #do I need to clear a segment
        if len(self.tail) > self.length:
            lastSegment = self.tail[-1]
            self.ap.set_pixel(lastSegment[0], lastSegment[1], self.BACKCOL)
            self.tail.pop()
        
    def move(self):
        #work out where the new segment of the snake will be
        newSegment = [self.tail[0][0], self.tail[0][1]]
        if self.direction == self.UP:
            newSegment[1] -= 1
        elif self.direction == self.DOWN:
            newSegment[1] += 1
        elif self.direction == self.LEFT:
            newSegment[0] -= 1
        elif self.direction == self.RIGHT:
            newSegment[0] += 1

        if self.checkCollision(newSegment[0], newSegment[1]):
            #game over
            snakehead = self.tail[0]
            for flashHead in range(0,5):
                self.ap.set_pixel(snakehead[0], snakehead[1], self.SNAKECOL)
                sleep(0.2)
                self.ap.set_pixel(snakehead[0], snakehead[1], self.BACKCOL)
                sleep(0.2)
            self.ap.show_message("Score = {}".format(self.score), text_colour = self.APPLECOL)
            
#.........这里部分代码省略.........
开发者ID:martinohanlon,项目名称:AstroPiSnake,代码行数:103,代码来源:astropisnake.py

示例10: pickMessage

# 需要导入模块: from astro_pi import AstroPi [as 别名]
# 或者: from astro_pi.AstroPi import show_message [as 别名]
#message arrays
goodbyes = ['Bye bye!', 'Have a great day!', 'See you soon!', 'Goodbye Tim!'] #the list of goodbye messages that can be chosen
greetings = ['Hi Tim!', 'How are you, Tim?', 'Howdy Tim!', 'Hello Tim!', 'Hey there Tim!'] #the list of greetings that can be chosen


#choose random message
def pickMessage(messages):
    num_messages = len(messages)
    num_picked = randint(0, num_messages - 1)
    message_picked = messages[num_picked]
    return message_picked   


#Greet Tim
ap.show_message(pickMessage(greetings)) #display a random greeting


#set up date/time
now = datetime.datetime.now() #the current date
thisday = now.strftime("%m-%d") #the current month and day


#take stats from station
StationTemp = 24 #We would get from sensor but Pi board gets hot so not accurate


#sort day and temperature into array
day = []
avTemp = []
开发者ID:astro-pi,项目名称:AstroPiWeatherEntry,代码行数:31,代码来源:AstroPiFinal.py

示例11: print

# 需要导入模块: from astro_pi import AstroPi [as 别名]
# 或者: from astro_pi.AstroPi import show_message [as 别名]
            running = False
       #change the  co-efficient depending on the key pressed , or exit the game
        if event.type==KEYDOWN:
            if event.key==K_ESCAPE:
                running = False
            if event.key==K_LEFT:
                leftco = -1
                upco = 0
            elif event.key==K_RIGHT:
                leftco = 1
                upco = 0
            elif event.key==K_UP:
                leftco = 0
                upco = -1
            elif event.key==K_DOWN:
                leftco = 0
                upco = 1
    ap.set_pixel(x,y,0,0,0)

    now = time.time()
    #game exits after 60 seconds
    if(now - start > 60):
        running = False;
if(running == False):
    print("Finished")

#show the score beofre the game ends    
ap.show_message("points: " + str(points),0.2,[r,g,b])
ap.clear()
pygame.quit ()
开发者ID:compinschools,项目名称:astro-pi,代码行数:32,代码来源:game_chase_example.py

示例12: print

# 需要导入模块: from astro_pi import AstroPi [as 别名]
# 或者: from astro_pi.AstroPi import show_message [as 别名]
    
    endTime = datetime.datetime.now()
    totalTime = endTime - startTime

    timeTaken = (totalTime.seconds * 1000000) + totalTime.microseconds

    print(timeTaken/1000,"miliseconds")
    return timeTaken/1000

for i in range(3):
    playing = True
    while playing:
        cheat = countdown()
        if not cheat:
            time = reaction()
            ap.show_message(str(time), text_colour=[100,0,0])
            playing = False

        else:
            ap.show_message("Too Quick")
            playing = True

    fileObject = open("1Reaction/data.txt","a")
    toWrite = "\n"+str(datetime.datetime.now())+","+str(time)+","+direction
    fileObject.write(toWrite)
    fileObject.close()


pygame.quit()
开发者ID:swooningfish,项目名称:reaction-games,代码行数:31,代码来源:1Reaction.py

示例13:

# 需要导入模块: from astro_pi import AstroPi [as 别名]
# 或者: from astro_pi.AstroPi import show_message [as 别名]
			r = [0,255,0]                          # green if higher
		elif hum_int == hum_prev:
			r = [0,0,255]                          # blue if the same
		else:
			r = [0,255,255]                        # light blue if lower
		hum_prev = hum_int
		image=TDG.numToMatrix(hum_int,back_colour=[0,0,0],text_colour=r)
		ap.set_pixels(image)
	elif y == -1 and x != -1:                      # temp display if USB ports pointing upwards
		ap.set_rotation(180)
		if temp_int > temp_prev:                   # Is the latest reading higher than the last?
			r = [255,0,0]                          # red if higher
		elif temp_int == temp_prev:
			r = [255,128,0]                        # orange if the same
		else:
			r = [255,215,0]                        # yellow if lower
		temp_prev = temp_int
		# use numToMatrix to turn the number into a 64 item list suitable for the LED
		image=TDG.numToMatrix(temp_int,back_colour=[0,0,0],text_colour=r)
		ap.set_pixels(image)
	elif x == 0 and y == 0:                        # if the Pi is flat on its back
		ap.show_message("Recording", text_colour=[150,150,150],scroll_speed=0.03) 
	else:
		ap.show_letter("?")                       # display a ? if at some other orientation

	time.sleep(dataDisplayInterval)
	sec_count+=1



开发者ID:topshed,项目名称:HTLogger,代码行数:29,代码来源:HTLogger.py

示例14: elif

# 需要导入模块: from astro_pi import AstroPi [as 别名]
# 或者: from astro_pi.AstroPi import show_message [as 别名]
        O = [255, 255, 255]  # White

        UK = [
        O, O, O, X, X, O, O, O,
        O, O, O, X, X, O, O, O,
        O, O, O, X, X, O, O, O,
        X, X, X, X, X, X, X, X,
        X, X, X, X, X, X, X, X,
        O, O, O, X, X, O, O, O,
        O, O, O, X, X, O, O, O,
        O, O, O, X, X, O, O, O
        ]

        ap.set_pixels(UK)
        time.sleep(6)
        ap.show_message("Hello ISS, you are over the UK")
        ap.show_message("Hello ISS. How are you!", text_colour=[255, 0, 0])
        

    ###FRANCE###
    elif (lati[0] <= 49 and lati[0] >= 43) and (longt[0] >= -3 and longt[0] <= 6):    
        print "FRANCE"

        X = [255, 0, 0]  # Red 
        O = [255, 255, 255]  # White 
        b= [0,0, 255] #Blue
        French_Flag  = [ 
        b, b, b, O, O, O, X, X,
        b, b, b, O, O, O, X, X, 
        b, b, b, O, O, O, X, X, 
        b, b ,b, O, O, O, X, X, 
开发者ID:TeCoEd,项目名称:iss-tracker,代码行数:33,代码来源:ISS_Tracker.py

示例15: open

# 需要导入模块: from astro_pi import AstroPi [as 别名]
# 或者: from astro_pi.AstroPi import show_message [as 别名]
                if state:
                    #All the locations will be green
                    ap.set_pixel(places[0],places[1],snakeColour)

                #If the state is to turn things off
                if not state:
                    #Set all the pixels to black
                    ap.set_pixel(places[0],places[1],black)

            #If a pixel is out of range then instead of crashing just print "error"
            except ValueError:
                pass
            
        #Inverts the state
        if state:
            state = False

        else:
            state = True

        #Sleeps to allow for the visual flashing
        time.sleep(0.4)

#If you win show the won message in red
if check == "WON":
    ap.show_message("You won!", red)

fileObject = open("2Caterpillar/data.txt", "a")
fileObject.write("\n"+str(datetime.datetime.now())+","+str(snakeBodyLength)+","+str(survivalTime))
fileObject.close()
开发者ID:swooningfish,项目名称:reaction-games,代码行数:32,代码来源:2Caterpillar.py


注:本文中的astro_pi.AstroPi.show_message方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。