def rms_difference(p1, p2): # p1 and p2 are two filenames of picture img1 = bmp.bmp(p1) img2 = bmp.bmp(p2) d1 = img1.reverse_data d2 = img2.reverse_data n1 = img1.bi_width m1 = img1.bi_height n2 = img2.bi_width m2 = img2.bi_height if m1 != m2 or n1 != n2: print('sizes of pic1 and pic2 are different') m = min(m1, m2) n = min(n1, n2) diff = 0 for i in range(m): for j in range(n): diff += abs(d1[i][j][0] - d2[i][j][0])**2 diff += abs(d1[i][j][1] - d2[i][j][1])**2 diff += abs(d1[i][j][2] - d2[i][j][2])**2 rms = (diff / float(m * n))**0.5 return rms
lcd_gfx.drawTrie(42, 2, 21, 23, 63, 23, d, 1) d.display() time.sleep(1) d.clear() lcd_gfx.drawFillRect(10, 12, 20, 20, d, 1) d.display() time.sleep(1) d.clear() lcd_gfx.drawCircle(70, 24, 20, d, 1) d.display() time.sleep(1) d.clear() bmp.bmp('icon.bmp', d) d.display() time.sleep(5) d.clear() d.p_string('HHHHHHHHHHHHHHHHHHHHH') d.p_string('HHHHHHHHHHHHHHHHHHHHH') d.p_string('HHHHHHHHHHHHHHHHHHHHH') d.p_string('HHHHHHHHHHHHHHHHHHHHH') d.p_string('HHHHHHHHHHHAHHHHHHHHH') d.p_string('HHHHHHHHHHHHHHHHHHHHH') d.p_string('HHHHHHHHHHHHHHHHHHHHH') d.p_string('HHHHHHHHHHHHHHHHHHHHH') d.display() time.sleep(5)
import time import lcd_gfx from bmp import bmp import machine import ST7735 spi = machine.SPI(2, baudrate=8000000, polarity=0, phase=0) d = ST7735.ST7735(spi, rst='Y4', ce='Y5', dc='Y3') d.reset() d.begin() d._bground = 0xffff d.fill_screen(d._bground) d.set_rotation(0) bmp('flower64x48.bmp', d, 10, 10, 1) d.set_rotation(1) bmp('flower64x48.bmp', d, 10, 10, 1) d.set_rotation(2) bmp('flower64x48.bmp', d, 10, 10, 1) d.set_rotation(3) bmp('flower64x48.bmp', d, 10, 10, 1) d._color = 0 d.set_rotation(0) d.p_string(10, 10, 'Hello World') d._color = 0xf800 #红色