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


Python SenseHat.show_message方法代码示例

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


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

示例1: index

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import show_message [as 别名]
def index():
    user = {'nickname': 'Miguel'}  # fake user
    sense = SenseHat()
    sense.show_message("Hello world!")
    return render_template('index.html',
                           title='Home',
                           user=user)
开发者ID:rtibell,项目名称:sens1,代码行数:9,代码来源:flaskweb.py

示例2: main

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import show_message [as 别名]
def main():
    # Initialization stuff
    sense = SenseHat()
    sense.low_light = True
    # Display a random pixel matrix
    pixelValues = [ [ random.randint( 0, 255 ) for j in range( 3 ) ] for i in range( 64 ) ]
    sense.set_pixels( pixelValues )
    time.sleep( 3 )
    # Create a colour 'beat'
    for i in range( 3 ):
        sense.clear( 255, 0, 0 )
        time.sleep ( 0.333 )
        sense.clear( 0, 255, 0 )
        time.sleep ( 0.333 )
        sense.clear( 0, 0, 255 )
        time.sleep ( 0.333 )
    # Toy around with text display
    message = "Einfach Mensch..."
    sense.show_message( message, 0.05 )
    rotation = 0
    for letter in message:
        sense.set_rotation( rotation, False )
        rotation += 90
        if rotation == 270:
            rotation = 0
        sense.show_letter( letter )
        time.sleep( 0.24 )
    sense.clear()
开发者ID:markuspg,项目名称:SenseHatStuff,代码行数:30,代码来源:randomPixels.py

示例3: menu

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import show_message [as 别名]
        def menu():
            global sense, time1, time2, r, t, m, w, k, a, b, elapsed
            sense = SenseHat()
            
            sense.set_rotation(180)
            sense.clear()
            sense.set_pixels(imagemenu)
            
            sense.stick.get_events()
            while True:
                print (" new game1",a," ",b)
                y1 = sense.get_accelerometer_raw()['y']
                y1 = round(y1, 0)

                if y1 == -1:
                    sense.show_message("Highscore '%s'"% (h))
                    sense.set_pixels(imagemenu)
                for event in sense.stick.get_events():
                    if event.action == "pressed" and event.direction == "middle":
                        elapsed = timedelta(seconds=0)
                        sense.set_rotation(180)
                        sense.stick.direction_up = move_up
                        sense.stick.direction_down = move_down
                        sense.stick.direction_right = move_right
                        sense.stick.direction_left = move_left
                        x=0
                        y=0
                        time1 = datetime.now()
                        print(elapsed, " elapsed and e ", e)
                        while elapsed < e:
                            sense.clear()
                            draw_player()
                            test = draw_enemy(x, y)
                            print("menu nivel1 ",test)
                            if test == 1:
                                new_game()
                                break
                            sleep(0.25)
                            y = y+1
                            if y > 7:
                                r = randint(0,7)
                                t = randint(0,7)
                                m = randint(0,7)
                                y = 0
                            x = x+1
                            if x > 7:
                                w = randint(0,7)
                                k = randint(0,7)
                                x = 0
                        if elapsed > e:
                                sense.show_message("Next level", scroll_speed=0.05)
                                sense.set_pixels(imagesmile)
                                sleep(1)
                                level_2(x,y)
                                new_game()
                                break
                    if event.action == "pressed" and (event.direction == "up" or event.direction == "down" or event.direction == "left" or event.direction == "right"):
                        return
开发者ID:Coding4Kids,项目名称:cidadeinteligente,代码行数:60,代码来源:FugaAosQuadrados.py

示例4: __init__

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import show_message [as 别名]
class Screen:
    def __init__(self):
        self.sense = SenseHat()
        self.general_level = 0
        self.wait_time = 4
        self.cur_time = 0
        self.clear()
        self.balance = 0

    def clear(self):
        for i in range(SIZE):
            for j in range(SIZE):
                self.sense.set_pixel(i, j, BLACK)

    def clear_col(self, x):
        for i in range(0, 7):
            self.sense.set_pixel(x, i, BLACK)

    def plot_bar(self, x, height, colors=None):
        if colors is None:
            colors = BAR_COLORS
        self.clear_col(x)
        for i in range(height):
            self.sense.set_pixel(x, 7 - i, colors[7 - i])

    def plot_balance(self):
        for i in range(SIZE):
            self.plot_bar(i, max(1, self.general_level), BAR_COLORS)

    def show_amount(self):
        self.show_message(str(self.balance), color=list(BAR_COLORS[min(7, 8 - self.general_level)]))

    def show_message(self, message, speed=0.1, color=[255, 255, 255]):
        self.sense.show_message(message, speed, color)
        self.plot_balance()

    """ Parses an input in the form:
        balance percentage """

    def parse_input(self, line):
        self.cur_time = 0
        # Split balance and percentage.
        [self.balance, percent] = [float(x) for x in line.split()]
        self.general_level = int(round(min(max(0, percent), 100) / 100.0 * SIZE))
        self.draw_check()

    def draw_check(self):
        types = [BLACK, GREEN]
        pixels = [types[CHECK[i / SIZE][i % SIZE]] for i in range(SIZE * SIZE)]
        self.sense.set_pixels(pixels)

    def no_text(self):
        self.cur_time += SLEEP_TIME
        if self.cur_time > self.wait_time:
            self.cur_time = 0
            self.show_amount()
开发者ID:albertnez,项目名称:pep,代码行数:58,代码来源:screen.py

示例5: login

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import show_message [as 别名]
def login():
    form = LoginForm()
    if form.validate_on_submit():
        sense = SenseHat()
        sense.show_message("Hello {}!".format(form.openid.data))
        #flash('Login requested for OpenID="{}", remember_me={}'.format(form.openid.data, form.remember_me.data))
        return redirect('/index')
    return render_template('login.html', 
                           title='Sign In',
                           form=form)
开发者ID:Daniel-Rix,项目名称:personal-trainer,代码行数:12,代码来源:views.py

示例6: show_tph

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import show_message [as 别名]
def show_tph():
    sense = SenseHat()
    t = 0
    h = 0
    p = 0
    while p < 1:
        p = sense.get_pressure()
        time.sleep(1)

    t = sense.get_temperature()
    h = sense.get_humidity()
    t = round(t, 1)
    p = round(p, 0)
    h = round(h, 0)

    msg = "P{0}H{1}".format(p,h)
    msg1 = "T{0}".format(t)

    sense.set_rotation(rotate_degree)
    sense.show_message(msg, text_colour=cadetblue)
    sense.show_message(msg1, text_colour=red)
开发者ID:ericosur,项目名称:ericosur-snippet,代码行数:23,代码来源:tph.py

示例7: SenseHatMonitor

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import show_message [as 别名]
class SenseHatMonitor(Sensor):
    """
    Data logger class for Astro Pi Sensehat
    No need to supply anything except the identifier as the SenseHad uses some kind of black sorcery to work it out.
    """

    data_headers = ("temperature", "humidity", "pressure")

    def __init__(self, identifier: str = None, **kwargs):
        self.sensehat = SenseHat()
        self.display_str = "Init Sensors..."
        self.sensehat.show_message(self.display_str)
        super(SenseHatMonitor, self).__init__(identifier, **kwargs)

    def show_data(self, measurement):
        """
        displays the data on the osd.
        :param measurement:
        :return:
        """
        try:
            message_str = "T:{0:.2f} H:{1:.2f} P:{2:.2f}"
            self.sensehat.show_message(message_str.format(*measurement))
        except Exception as e:
            self.logger.error(str(e))

    def get_measurement(self) -> tuple:
        """
        get measurements for sensehat
        :return:
        """
        try:
            return self.sensehat.temperature, self.sensehat.humidity, self.sensehat.pressure
        except Exception as e:
            self.logger.error("Couldnt get data, {}".format(str(e)))
            return tuple(None for _ in range(len(self.data_headers)))
开发者ID:borevitzlab,项目名称:Gigvaision-ControlSoftware,代码行数:38,代码来源:Sensor.py

示例8: main

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import show_message [as 别名]
def main():
    menu = Menu(SenseHat(), SenseStick())
    menu.run()
    return
    sense_stick = SenseStick()
    sense_hat = SenseHat()
    sense_hat.clear()
    while True:
        event = sense_stick.read()
        if event.state == SenseStick.STATE_PRESS:
            message = ''
            if event.key == SenseStick.KEY_UP:
                message = 'poo'
            elif event.key == SenseStick.KEY_LEFT:
                message = 'bum'
            elif event.key == SenseStick.KEY_RIGHT:
                message = 'dick'
            elif event.key == SenseStick.KEY_DOWN:
                message = 'balls'
            elif event.key == SenseStick.KEY_ENTER:
                message = 'rofl'
            red = (255, 0, 0)
            sense_hat.show_message(message, text_colour=red, scroll_speed=0.05)
    print 'hello'
开发者ID:porty,项目名称:pi-hat,代码行数:26,代码来源:hat.py

示例9: signal_handler

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import show_message [as 别名]
# sense.show_message("IoT Sensor Pack")
# sense.show_message(str(datetime.datetime.now()))

def signal_handler(signal, frame):
    print("Shutting down.")
    sense.clear()
    sys.exit(0)

signal.signal(signal.SIGINT, signal_handler)

sense.clear()

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

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

        print("T: %d    P: %d     H: %d" % (t, p, h))

        sense.show_message("T: %d P: %d H: %d" % (t, p, h))
        time.sleep(5)

except KeyboardInterrupt:
    print("Breaking out.")
    sense.clear()
开发者ID:brookshire,项目名称:pypicamcapper,代码行数:32,代码来源:status.py

示例10: SenseHat

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

# Uses the user inputted message as a
# command line argument. Argument is then
# concatenated as a string, and sent to SenseHat.
import sys
from sense_hat import SenseHat

sense = SenseHat()
sense.clear(0, 0, 0)
message = ""

for index in range(len(sys.argv) - 1):
    if index == (len(sys.argv) - 1):
        message += sys.argv[index + 1]
    else:
        message += sys.argv[index + 1] + " "

sense.show_message(message, text_colour=(0, 255, 0))
开发者ID:crice88,项目名称:portfolio_interaction,代码行数:21,代码来源:send_message.py

示例11: SenseHat

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import show_message [as 别名]
from sense_hat import SenseHat

import time
import sys

sense = SenseHat()
sense.set_rotation(180)

for v in sys.argv[1:]:
    sense.show_message(v, text_colour=[255, 0, 0])
    
开发者ID:Statoil,项目名称:happyeye,代码行数:12,代码来源:sense-hat-showmessage.py

示例12: __init__

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import show_message [as 别名]
class DataCollector:
    COLOR = [95, 189, 242]
    TIME_FORMAT = '%Y-%m-%d:%H:%M'
    field_names = ['date', 'temp', 'temp_press', 'humidity', 'pressure']

    def __init__(self, filename, samples=3, sample_time=1, no_append=False):
        self._filename = filename
        self._no_append = no_append
        self._sample_time = sample_time
        self._samples = int(samples) if samples and (samples and 1 <= samples < 100) else 3
        self._field_names = DataCollector.field_names + DataCollector.field_names + ['{}{}'.format(name, i) for name in
                                                                                     DataCollector.field_names for i in
                                                                                     range(self._samples)]
        self._sense = SenseHat()
        self._write_header()
        self._sense.show_message("Start!", scroll_speed=0.2, text_colour=DataCollector.COLOR)
        print("Collecting data at {}".format(strftime(DataCollector.TIME_FORMAT)), file=sys.stderr)

    def _write_header(self):
        if not exists(self._filename) or not isfile(self._filename):
            with smart_open(self._filename, no_append=True) as f:
                fcsv = csv.DictWriter(f, delimiter=',', fieldnames=self._field_names)
                fcsv.writeheader()
                f.flush()

    def _get_sample(self):
        # Check if samples and sample_time are realistic,else the script will take forever to produce data.

        dt = self._sample_time if 1 <= self._sample_time < 3 else 1
        temp_data = defaultdict(list)

        for _ in range(self._samples):
            temp_data['date'].append(time())
            temp_data['humidity'].append(self._sense.humidity)
            temp_data['temp'].append(self._sense.temperature)
            temp_data['temp_press'].append(self._sense.get_temperature_from_pressure())
            temp_data['pressure'].append(self._sense.pressure)
            sleep(dt)
        return temp_data

    def _mean_sample(self, data_raw):
        result_data = {}
        for key, value in data_raw.items():
            result_data[key] = mean(value)
        return result_data

    def _procces_raw(self, data_raw):
        raw = {}
        for key, value in data_raw.items():
            for i in range(len(value)):
                raw["{}{}".format(key, i)] = value[i]
        return raw

    def sample(self):
        print("Start Sampling at {}".format(strftime(DataCollector.TIME_FORMAT + ':%S')), file=sys.stderr)
        self._sense.show_message("Sample!", scroll_speed=0.075, text_colour=DataCollector.COLOR)
        with smart_open(self._filename, no_append=self._no_append) as f:
            fcsv = csv.DictWriter(f, delimiter=',', fieldnames=self._field_names)
            raw_data = self._get_sample()
            mean_data = self._mean_sample(raw_data)
            mean_data.update(self._procces_raw(raw_data))
            mean_data['date'] = strftime(DataCollector.TIME_FORMAT)
            fcsv.writerow(mean_data)
            f.flush()

    def monitor(self, interval, max_intervals=-1):
        """
        Collect sensor data with intervals in seconds. And if it has to stop after n intervals
        set max_intervals.

        :param interval: integer
        :param max_intervals: integer
        :return:
        """
        # Check if interval is realistic,else the script will take forever to produce data.
        # to exclude almost everlasting invervals the biggest interval is two days. default each hour.
        dt = interval if interval and 1 <= interval < (2 * 24 * 60 * 60) else (15 * 60)
        if self._no_append:
            self._no_append = True
        i = 0
        while max_intervals < 0 or i < max_intervals:
            self.sample()
            sleep(interval)
开发者ID:CodeRogier,项目名称:WeatherPi,代码行数:85,代码来源:weather.py

示例13: range

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import show_message [as 别名]
    sense.set_pixels(xplod5)
    time.sleep(0.4)
    sense.clear(255,255,255)
    time.sleep(0.05)
    sense.set_pixels(xplod6)
    time.sleep(0.75)

# Warning flash
for i in range(50):
    sense.clear(255,255,255)
    time.sleep(0.05)
    sense.clear()
    time.sleep(0.05)

# Message
sense.show_message("10..9..8..7..6..5..4..3..2..1..", scroll_speed=0.08, text_colour=[204,0,0])
sense.show_message("HAPPY NEW YEAR!", scroll_speed=0.04, text_colour=[204,0,204])
sense.show_letter("2")
time.sleep(0.25)
sense.show_letter("0")
time.sleep(0.25)
sense.show_letter("1")
time.sleep(0.25)
sense.show_letter("6")
time.sleep(0.25)

# Bombs Away
for i in range(7):
    fireworks()
    sense.clear()
开发者ID:langgaibo,项目名称:snippets,代码行数:32,代码来源:nye.py

示例14: SenseHat

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import show_message [as 别名]
from sense_hat import SenseHat

sense = SenseHat()

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

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

    msg = "Temperature = %s, Pressure=%s, Humidity=%s" % (t,p,h)
    print(t)
    print(p)
    print(h)
    sense.show_message(msg,scroll_speed=0.05)
	
开发者ID:dprior1985,项目名称:PiCode,代码行数:20,代码来源:env.py

示例15: SenseHat

# 需要导入模块: from sense_hat import SenseHat [as 别名]
# 或者: from sense_hat.SenseHat import show_message [as 别名]
from sense_hat import SenseHat

from time import sleep

sense = SenseHat()

sense.set_rotation(90)

sense.clear(0, 0, 0,)


while True:
    sense.show_message(" %s F" % round(sense.get_temperature() * 1.8 + 32))
    sleep(1)
    sense.show_message(" %s prh" % round((sense.get_humidity)()))
    sleep(1)
    sense.show_message(" %s''" % round((sense.get_pressure() * 0.0295301), 2))
    sleep(1)
开发者ID:DigiTempReader,项目名称:sense-hat,代码行数:20,代码来源:Environmental_sensors_3.0.py


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