import time, math # include time and math module adc = ADC(Pin(Map.WIO_MIC)) # create ADC on built-in Mic Pin WINDOW_SIZE = 50 # amount of previous signal entries that can be averaged together # set variables to 0 INDEX = 0 VALUE = 0 SUM = 0 AVERAGED = 0 READINGS = [0] * WINDOW_SIZE dB = 0 tft = LCD() # LCD initialization tft.setRotation(3) # set screen rotation spr = Sprite(tft) # initialize buffer spr.createSprite(320, 75) # create buffer ltx = 0 # saved x coordinate of bottom of needle osx = 160 # saved x coordinate osy = 160 # saved y coordinate updateTime = 0 # time for next update # create function to draw all graphics on LCD def analogMeter(): tft.fillScreen(tft.color.YELLOW) # set background color tft.fillRect(5, 3, 310, 158, tft.color.WHITE) # set meter box color tft.drawRect(5, 3, 310, 158, tft.color.BLACK) # draw border line
from machine import LCD #include LCD function from machine module lcd = LCD() #initialize TFT LCD lcd.fillScreen(lcd.color.WHITE) #fill background color lcd.setRotation(3) #set screen rotation #draw for title header lcd.fillRect(0, 0, 320, 60, lcd.color.DARKGREEN) #draw rectangle with border lcd.setTextSize(3) #set text size lcd.setTextColor(lcd.color.WHITE, lcd.color.DARKGREEN) #color of text lcd.drawString("MUSIC PLAYER", 55, 15) #draw a string #draw for volume lcd.drawRoundRect(90, 75, 140, 60, 15, lcd.color.BLUE) #draw round corner rectangle with border lcd.fillTriangle(40, 105, 80, 75, 80, 135, lcd.color.RED) #draw triangle with fill color lcd.fillTriangle(280, 105, 240, 75, 240, 135, lcd.color.DARKGREEN) lcd.setTextColor(lcd.color.BLACK) lcd.drawString("VOLUME", 105, 95) #draw for play lcd.drawCircle(160, 190, 45, lcd.color.BLUE) #draw circle with fill color lcd.fillTriangle(60, 185, 100, 155, 100, 215, lcd.color.RED) lcd.fillTriangle(260, 185, 220, 155, 220, 215, lcd.color.DARKGREEN) lcd.drawString("PLAY", 130, 180)