def sensor_cb(timer): #external inputs / outputs global readings while data_ready(): read_data() readings = process_data() #output the results to the serial print("Temperature: {Temp:4.1f} C, Humidity: {Humi:2.0f}%, Altitude: {Alt} meters, Pressure: {Pres:7.2f} HPa".format( **readings)) #print("IAQ Accuracy: {IAQa} , IAQ : {IAQ}, Gas {Gas} Ohm".format( **readings)) print('') windows.mainwindow() windows.writeln("Temperature: {Temp:4.1f} C\nHumidity: {Humi:2.0f}%\nAltitude: {Alt} meters\nPressure: {Pres:7.2f} HPa\nAir Quality : {IAQ}".format( **readings) ,windows.tft.WHITE )
def start(): global t3 #Clean main window windows.mainwindow() windows.writeln('Initializing sensor' ) init_sensor() #create a timer s=10 windows.writeln('Starting {}s update'.format(s) ) t3 = machine.Timer(3) # call the sensor_cb function every 2 seconds t3.init(period=s*1000, mode=t3.PERIODIC, callback=sensor_cb)
tft.line(0, y, 20, y, tft.YELLOW) tft.text(25, y, "{}".format(y), color=tft.WHITE) time.sleep(0.5) #Horizontal Ruler tft.line(0, 10, screen_w, 10) for x in range(0, screen_w, 50): tft.line(x, 0, x, 20, tft.YELLOW) tft.text(x, 25, "{}".format(x), color=tft.WHITE) #================================================================== pause("create a simple window grid") windows.borders() windows.header('<insert Tile here>') windows.mainwindow() #================================================================== #line by line # Todo: line 1 leaves whitespace on top pause("Text can be positioned per pixel") windows.header('Manual positioning lines') windows.mainwindow() #left top corner tft.text(0, 0, "Line 1 ...............") width, height = tft.fontSize() #go one line down, Calculate the position for n in range(1, 10): tft.text(0, tft.LASTY + height + 2, "Line {} ...............".format(n))
print("-------------------------------------") print("Lab 6.3 Air Quality ") print("-------------------------------------") # import MCU680 # MCU680.t3.stop() # MCU680.t3.deinit() import windows import time windows.borders() windows.header('Lab 6.3 Air Quality') windows.mainwindow() import timer_display as td td.start()