import lcd4bit as lcd
import tm1637 as tm
import sr04 as sr
import ntc
from machine import Pin
from utime import sleep
disp_temp = tm.TM1637(clk=Pin(3), dio=Pin(4))
disp_dist = tm.TM1637(clk=Pin(12), dio=Pin(13))
sleep(0.1)
print("start")

while 1:
    distance=sr.get_distance()
    temp=ntc.get_temp()
    lcd.cmdwrite(0x80)
    lcd.strwrite(str(round(temp,1))+"^C")
    if temp>30:
        lcd.strwrite(" HOT ")
    else:
        lcd.strwrite(" COLD")
    lcd.cmdwrite(0xC0)
    lcd.strwrite(str(round(distance,1))+"cm")
    if distance>100:
        lcd.strwrite(" FAR ")
    else:
        lcd.strwrite(" NEAR")
    disp_temp.number(int(round(temp,0)))
    disp_dist.number(int(round(distance,0)))
    print("distance:",distance,"cm")
    print("temperature:",temp,"^C")
    sleep(0.3)
    
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT
4-Digit Display
4-Digit Display