Last active
November 16, 2017 16:31
-
-
Save boochow/a03f2f792f01ed20b123742f6d560bb3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ST7735 import TFT,TFTColor | |
from machine import SPI,Pin | |
spi = SPI(2, baudrate=20000000, polarity=0, phase=0, sck=Pin(14), mosi=Pin(13), miso=Pin(12)) | |
tft=TFT(spi,16,17,18) | |
tft.initr() | |
tft.rgb(True) | |
tft.fill(TFT.BLACK) | |
minX = -2.0 | |
maxX = 1.0 | |
width = 128 | |
height = 160 | |
aspectRatio = 1.25 | |
yScale = (maxX-minX)*(float(height)/width)*aspectRatio | |
for y in range(height): | |
buf = bytes() | |
for x in range(width): | |
c = complex(minX+x*(maxX-minX)/width, y*yScale/height-yScale/2) | |
z = c | |
for color in range(64): | |
if abs(z) > 2: | |
break | |
z = z*z+c | |
r, b, g = color>>4, (color>>2)&3, color & 3 | |
buf += TFTColor((3-r)<<5, (3-g)<<5, (3-b) << 6).to_bytes(2,'big') | |
tft._setwindowloc((0,y),(127,y)) | |
tft.dc(1) | |
tft.cs(0) | |
spi.write(buf) | |
tft.cs(1) | |
spi.deinit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://www.youtube.com/watch?v=DvIzWRm_HOg