def show_text(self, text, duration=2, blink=True):
        """ show text for the given time """

        # should be called with _exec_with_lock
        self._settings.log.msg("DisplayController: showing text: %s" % text)
        if self._brightness == 0:
            time.sleep(duration)
            return
        display.clear()

        # scroll long text
        if len(text) > 4:
            steps = len(text) - 3
            sleep_time = float(duration) / steps
            for i in range(steps):
                display.print_str(text[:4], False)
                display.show()
                time.sleep(sleep_time)
                text = text[1:]
        else:
            display.print_str(text, False)
            if blink:
                display.set_blink(display.HT16K33_BLINK_2HZ)
            display.show()
            time.sleep(duration)
            if blink:
                display.set_blink(display.HT16K33_BLINK_OFF)
    def _set_blink(self, state):
        """ set blink state """

        # should be called with _exec_with_lock
        if state:
            display.set_blink(display.HT16K33_BLINK_1HZ)
        else:
            display.set_blink(display.HT16K33_BLINK_OFF)
    def __display_a(self):
        if self.display_id != self.__display_a:
            self.display_id = self.__display_a
            flp.print_str("LOGC")
            flp.show()
            time.sleep(2)

        flp.print_float(self.temp_a, decimal_digits=1)
        flp.set_blink(flp.HT16K33_BLINK_2HZ)
        flp.show()
    def __display_f(self):
        if self.display_id != self.__display_f:
            flp.set_blink(flp.HT16K33_BLINK_OFF)
            self.display_id = self.__display_f
            #flp.scroll_print("FREEZER")
            flp.print_str("FRZR")
            flp.show()
            time.sleep(2)

        flp.print_float(self.temp_f, decimal_digits=1)
        flp.show()
        flp.glow()
Ejemplo n.º 5
0
#!/usr/bin/env python

import time
import fourletterphat

print("""
Four Letter pHAT: blink.py

Demonstrate the display blinking at
the three available speeds.

Press Ctrl+C to exit.
""")

fourletterphat.clear()
fourletterphat.print_str("BLNK")
fourletterphat.show()

for blink_speed in [fourletterphat.HT16K33_BLINK_HALFHZ, fourletterphat.HT16K33_BLINK_1HZ, fourletterphat.HT16K33_BLINK_2HZ]:
    fourletterphat.set_blink(blink_speed)
    time.sleep(4)

fourletterphat.set_blink(fourletterphat.HT16K33_BLINK_OFF)

fourletterphat.print_str("BOOM")
fourletterphat.show()
time.sleep(1)
Ejemplo n.º 6
0
#!/usr/bin/env python

import time
import fourletterphat as flp

print("""
Four Letter pHAT: blink.py

Demonstrate the display blinking at
the three available speeds.

Press Ctrl+C to exit.
""")

flp.clear()
flp.print_str("BLNK")
flp.show()

# Display each blinkt speed for 4 seconds
for blink_speed in [
        flp.HT16K33_BLINK_HALFHZ, flp.HT16K33_BLINK_1HZ, flp.HT16K33_BLINK_2HZ
]:
    flp.set_blink(blink_speed)
    time.sleep(4)

flp.set_blink(flp.HT16K33_BLINK_OFF)

flp.print_str("BOOM")
flp.show()
time.sleep(1)(10)