def trippleText(x, y, txt, clr):
    if tcfg['textBG'] is not False:
        lcd.textClear(x, y, txt, int(tcfg['textBG']))
    else:
        lcd.text(x, y + 1, txt, 0)
        lcd.text(x, y - 1, txt, 0)
    lcd.text(x, y, txt, clr)
Esempio n. 2
0
 def update_clock(self):
     if self._isShown:
         if self._isSleeping:
             return
         elif self._lastInteraction + 120 < utime.time():
             self._sleep()
         else:
             lcd.textClear(90, 85, '                       ', lcd.WHITE)
             lcd.setCursor(105, 85)
             lcd.print("{}".format(
                 utime.strftime('%H:%M:%S', utime.localtime())))
             lcd.textClear(90, 115, '                       ', lcd.WHITE)
             lcd.setCursor(112, 115)
             lcd.print("{} C".format(kippenstal.getTemperature()))
Esempio n. 3
0
    def printToLcd(self):
        if self._coord == None:
            self._coord = lcd.getCursor()

        oldTxt = self._format.format(self._oldValue) + self._suffix
        oldTxtWidth = lcd.textWidth(oldTxt)
        txt = self._format.format(self.value) + self._suffix
        txtWidth = lcd.textWidth(txt)
        # erase
        lcd.textClear(self._coord[0], self._coord[1], oldTxt, lcd.WHITE)
        lcd.line(self._coord[0], self._coord[1] + 25,
                 self._coord[0] + oldTxtWidth, self._coord[1] + 25, lcd.WHITE)

        # write
        lcd.setCursor(self._coord[0], self._coord[1])
        lcd.print(txt)
        if self._editingActive:
            lcd.line(self._coord[0], self._coord[1] + 25,
                     self._coord[0] + txtWidth, self._coord[1] + 25)
Esempio n. 4
0
    def printToLcd(self):
        if self._coord == None:
            self._coord = lcd.getCursor()

        oldTxt = self._oldValue
        oldTxtWith = lcd.textWidth(oldTxt)
        txt = self.value
        txtWidth = lcd.textWidth(txt)
        # erase
        lcd.textClear(self._coord[0], self._coord[1], oldTxt, lcd.WHITE)
        lcd.line(self._coord[0], self._coord[1] + 25,
                 self._coord[0] + oldTxtWith, self._coord[1] + 25, lcd.WHITE)

        # write
        x = (320 - (lcd.textWidth(self.value))) / 2
        lcd.setCursor(int(x), self._coord[1])
        self._coord = lcd.getCursor()
        lcd.print(txt)
        if self._editingActive:
            lcd.line(self._coord[0], self._coord[1] + 25,
                     self._coord[0] + txtWidth, self._coord[1] + 25)
Esempio n. 5
0
 def displayTime():
     time = rtc.now()
     txt = '{:02d}:{:02d}:{:02d}'.format(*time[-3:])
     lcd.textClear(9, 148, txt, 0xFFFFFF)
     lcd.text(9, 148, txt, 0)
from machine import Pin, time_pulse_us
from utime import sleep, sleep_us

from m5stack import lcd, buttonA

lcd.font(lcd.FONT_DejaVu24)
lcd.clear()
lcd.text(lcd.CENTER, 0,'Telemetre')
lcd.text(lcd.CENTER,30,'Module HC-SR04')
lcd.text(40,210,'Stop')

# Prise GROVE B : 36 (Echo) / 26 (Trig) / Vcc / GND
trig = Pin(26,Pin.OUT)
echo = Pin(36,Pin.IN)

trig.value(0)

while not buttonA.wasPressed():
    trig.value(1)
    sleep_us(10)
    trig.value(0)
    duree = time_pulse_us(echo,1)
    distance = 345*duree*1E-6/2
    lcd.text(20,90, 'Dt = %d us    ' %duree)  # Durée
    lcd.text(20,120,'D = %.3f m    ' %distance)
    sleep(1)

lcd.text(lcd.CENTER,180,"** Fin **")
lcd.textClear(40,210,'Stop')
    
Esempio n. 7
0
def main():
    ########## 初期化 ##########
    # 液晶画面を初期化する
    lcd.setColor(color, background_color)
    lcd.clear()

    # センサーを初期化する
    sensor = DHT12()

    # 温度計、湿度計の表示を初期化する
    temperature_view = ThermometerView(10, 10, min_value=-15, max_value=45)
    humidity_view = ThermometerView(80,
                                    10,
                                    min_value=0,
                                    max_value=100,
                                    color=lcd.BLUE,
                                    label='%')

    # SDカードのマウント
    uos.mountsd()

    # 背景の描画
    temperature_view.init()
    humidity_view.init()

    ########## 無限ループ ##########
    while not buttonC.isPressed():
        # センサーで温度と湿度を計測する
        sensor.measure()
        temperature = sensor.temperature()
        humidity = sensor.humidity()

        # デバッグ用
        print("Temperature: {} `C, Humidity: {} %".format(
            temperature, humidity))

        # 温度計、湿度計の表示を更新する
        temperature_view.update(temperature)
        humidity_view.update(humidity)

        # WBGT値を求める
        try:
            wbgt = calc_wbgt(temperature, humidity)
        except ValueError:
            wbgt = None

        # WBGT値を画面に表示する
        lcd.font(lcd.FONT_Default, color=color, transparent=False)
        lcd.textClear(160, 30, 'WBGT: Unknown')
        if wbgt is not None:
            lcd.text(160, 30, 'WBGT: {}'.format(wbgt))
        else:
            lcd.text(160, 30, 'WBGT: Unknown')

        image_path = None

        # WBGT値に応じて画像を描画する
        # 31度以上          : 危険
        # 28度以上31度未満  : 厳重警戒
        # 25度以上28度未満  : 警戒
        # 25度未満          : 注意
        if temperature >= 21 and wbgt is not None:
            if wbgt >= 31:
                # 危険
                image_path = image_path_kiken
            elif wbgt >= 28:
                # 厳重警戒
                image_path = image_path_genjukeikai
            elif wbgt >= 25:
                # 警戒
                image_path = image_path_keikai

        # 湿度に応じてインフルエンザ注意情報を表示する
        # 湿度40%未満 : インフルエンザ感染注意
        if humidity < 40:
            image_path = image_path_influenza

        if image_path is not None:
            # 画像を描画する
            lcd.image(image_x, image_y, image_path)
        else:
            # 画像を描画した領域を背景色で塗りつぶす
            lcd.rect(image_x, image_y, image_width, image_height,
                     background_color, background_color)

        # 表示の更新間隔
        utime.sleep(interval)