kopia lustrzana https://github.com/peterhinch/micropython-nano-gui
Fix fplot.py import statement.
rodzic
62ff95dbd3
commit
43de979661
|
@ -3,11 +3,9 @@
|
||||||
# Released under the MIT License (MIT). See LICENSE.
|
# Released under the MIT License (MIT). See LICENSE.
|
||||||
# Copyright (c) 2018-2020 Peter Hinch
|
# Copyright (c) 2018-2020 Peter Hinch
|
||||||
|
|
||||||
# Supported displays
|
# Supported display
|
||||||
# Adfruit 1.8' Color TFT LCD display with MicroSD Card Breakout:
|
# Adfruit 1.8' Color TFT LCD display with MicroSD Card Breakout:
|
||||||
# https://www.adafruit.com/product/358
|
# https://www.adafruit.com/product/358
|
||||||
# Adafruit 1.44' Color TFT LCD Display with MicroSD Card breakout:
|
|
||||||
# https://www.adafruit.com/product/2088
|
|
||||||
|
|
||||||
# Based on
|
# Based on
|
||||||
# https://github.com/adafruit/Adafruit_CircuitPython_ST7735R/blob/master/adafruit_st7735r.py
|
# https://github.com/adafruit/Adafruit_CircuitPython_ST7735R/blob/master/adafruit_st7735r.py
|
||||||
|
@ -50,20 +48,20 @@ class ST7735R(framebuf.FrameBuffer):
|
||||||
return (r & 0xe0) | ((g >> 3) & 0x1c) | (b >> 6)
|
return (r & 0xe0) | ((g >> 3) & 0x1c) | (b >> 6)
|
||||||
|
|
||||||
# rst and cs are active low, SPI is mode 0
|
# rst and cs are active low, SPI is mode 0
|
||||||
def __init__(self, spi, cs, dc, rst, height=128, width=128):
|
def __init__(self, spi, cs, dc, rst):
|
||||||
self._spi = spi
|
self._spi = spi
|
||||||
self._rst = rst # Pins
|
self._rst = rst # Pins
|
||||||
self._dc = dc
|
self._dc = dc
|
||||||
self._cs = cs
|
self._cs = cs
|
||||||
self.height = height # Required by Writer class
|
self.height = 128 # Required by Writer class
|
||||||
self.width = width
|
self.width = 160
|
||||||
# Save color mode for use by writer_gui (blit)
|
# Save color mode for use by writer_gui (blit)
|
||||||
self.mode = framebuf.GS8 # Use 8bit greyscale for 8 bit color.
|
self.mode = framebuf.GS8 # Use 8bit greyscale for 8 bit color.
|
||||||
gc.collect()
|
gc.collect()
|
||||||
self.buffer = bytearray(self.height * self.width)
|
self.buffer = bytearray(128 * 160)
|
||||||
self._mvb = memoryview(self.buffer)
|
self._mvb = memoryview(self.buffer)
|
||||||
super().__init__(self.buffer, self.width, self.height, self.mode)
|
super().__init__(self.buffer, 160, 128, self.mode)
|
||||||
self._linebuf = bytearray(int(self.width * 3 // 2)) # 12 bit color out
|
self._linebuf = bytearray(int(160 * 3 // 2)) # 12 bit color out
|
||||||
self._init()
|
self._init()
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
|
@ -123,8 +121,8 @@ class ST7735R(framebuf.FrameBuffer):
|
||||||
wcd(b'\xe0', b'\x02\x1c\x07\x12\x37\x32\x29\x2d\x29\x25\x2B\x39\x00\x01\x03\x10') # GMCTRP1 Gamma
|
wcd(b'\xe0', b'\x02\x1c\x07\x12\x37\x32\x29\x2d\x29\x25\x2B\x39\x00\x01\x03\x10') # GMCTRP1 Gamma
|
||||||
wcd(b'\xe1', b'\x03\x1d\x07\x06\x2E\x2C\x29\x2D\x2E\x2E\x37\x3F\x00\x00\x02\x10') # GMCTRN1
|
wcd(b'\xe1', b'\x03\x1d\x07\x06\x2E\x2C\x29\x2D\x2E\x2E\x37\x3F\x00\x00\x02\x10') # GMCTRN1
|
||||||
|
|
||||||
wcd(b'\x2a', int.to_bytes(self.width, 4, 'big')) # CASET column address 0 start, 160/128 end
|
wcd(b'\x2a', int.to_bytes(160, 4, 'big')) # CASET column address 0 start, 160 end
|
||||||
wcd(b'\x2b', int.to_bytes(self.height, 4, 'big')) # RASET
|
wcd(b'\x2b', int.to_bytes(128, 4, 'big')) # RASET
|
||||||
|
|
||||||
cmd(b'\x13') # NORON
|
cmd(b'\x13') # NORON
|
||||||
sleep_ms(10)
|
sleep_ms(10)
|
||||||
|
@ -132,8 +130,8 @@ class ST7735R(framebuf.FrameBuffer):
|
||||||
sleep_ms(100)
|
sleep_ms(100)
|
||||||
|
|
||||||
def show(self): # Blocks 36ms on Pyboard D at stock frequency (160*128)
|
def show(self): # Blocks 36ms on Pyboard D at stock frequency (160*128)
|
||||||
wd = self.width
|
wd = 160
|
||||||
ht = self.height
|
ht = 128
|
||||||
lb = self._linebuf
|
lb = self._linebuf
|
||||||
buf = self._mvb
|
buf = self._mvb
|
||||||
self._dc(0)
|
self._dc(0)
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
# THE SOFTWARE.
|
# THE SOFTWARE.
|
||||||
|
|
||||||
from nanogui import DObject, circle
|
from gui.core.nanogui import DObject, circle
|
||||||
from cmath import rect, pi
|
from cmath import rect, pi
|
||||||
from micropython import const
|
from micropython import const
|
||||||
from array import array
|
from array import array
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
# As written, supports:
|
# As written, supports:
|
||||||
# Adfruit 1.8' Color TFT LCD display with MicroSD Card Breakout:
|
# Adfruit 1.8' Color TFT LCD display with MicroSD Card Breakout:
|
||||||
# https://www.adafruit.com/product/358
|
# https://www.adafruit.com/product/358
|
||||||
# Adafruit 1.44' Color TFT LCD Display with MicroSD Card breakout:
|
|
||||||
# https://www.adafruit.com/product/2088
|
|
||||||
|
|
||||||
# Demo of initialisation procedure designed to minimise risk of memory fail
|
# Demo of initialisation procedure designed to minimise risk of memory fail
|
||||||
# when instantiating the frame buffer. The aim is to do this as early as
|
# when instantiating the frame buffer. The aim is to do this as early as
|
||||||
|
@ -29,11 +27,11 @@ import gc
|
||||||
from drivers.st7735r.st7735r import ST7735R as SSD
|
from drivers.st7735r.st7735r import ST7735R as SSD
|
||||||
|
|
||||||
height = 128
|
height = 128
|
||||||
width = 128
|
width = 160
|
||||||
|
|
||||||
pdc = machine.Pin('Y1', machine.Pin.OUT_PP, value=0)
|
pdc = machine.Pin('Y1', machine.Pin.OUT_PP, value=0)
|
||||||
pcs = machine.Pin('Y2', machine.Pin.OUT_PP, value=1)
|
pcs = machine.Pin('Y2', machine.Pin.OUT_PP, value=1)
|
||||||
prst = machine.Pin('Y3', machine.Pin.OUT_PP, value=1)
|
prst = machine.Pin('Y3', machine.Pin.OUT_PP, value=1)
|
||||||
spi = machine.SPI(2, baudrate=12_000_000)
|
spi = machine.SPI(2, baudrate=12_000_000)
|
||||||
gc.collect() # Precaution before instantiating framebuf
|
gc.collect() # Precaution before instantiating framebuf
|
||||||
ssd = SSD(spi, pcs, pdc, prst, height, width) # Create a display instance
|
ssd = SSD(spi, pcs, pdc, prst) # Create a display instance
|
||||||
|
|
Ładowanie…
Reference in New Issue