From 43de979661f35ee7018f7a940e3cc8a51529fb86 Mon Sep 17 00:00:00 2001 From: Peter Hinch Date: Thu, 26 Nov 2020 16:09:03 +0000 Subject: [PATCH] Fix fplot.py import statement. --- drivers/st7735r/st7735r.py | 24 +++++++++++------------- gui/core/fplot.py | 2 +- st7735r_setup.py | 6 ++---- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/drivers/st7735r/st7735r.py b/drivers/st7735r/st7735r.py index 4e6b204..e977503 100644 --- a/drivers/st7735r/st7735r.py +++ b/drivers/st7735r/st7735r.py @@ -3,11 +3,9 @@ # Released under the MIT License (MIT). See LICENSE. # Copyright (c) 2018-2020 Peter Hinch -# Supported displays +# Supported display # Adfruit 1.8' Color TFT LCD display with MicroSD Card Breakout: # 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 # 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) # 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._rst = rst # Pins self._dc = dc self._cs = cs - self.height = height # Required by Writer class - self.width = width + self.height = 128 # Required by Writer class + self.width = 160 # Save color mode for use by writer_gui (blit) self.mode = framebuf.GS8 # Use 8bit greyscale for 8 bit color. gc.collect() - self.buffer = bytearray(self.height * self.width) + self.buffer = bytearray(128 * 160) self._mvb = memoryview(self.buffer) - super().__init__(self.buffer, self.width, self.height, self.mode) - self._linebuf = bytearray(int(self.width * 3 // 2)) # 12 bit color out + super().__init__(self.buffer, 160, 128, self.mode) + self._linebuf = bytearray(int(160 * 3 // 2)) # 12 bit color out self._init() 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'\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'\x2b', int.to_bytes(self.height, 4, 'big')) # RASET + wcd(b'\x2a', int.to_bytes(160, 4, 'big')) # CASET column address 0 start, 160 end + wcd(b'\x2b', int.to_bytes(128, 4, 'big')) # RASET cmd(b'\x13') # NORON sleep_ms(10) @@ -132,8 +130,8 @@ class ST7735R(framebuf.FrameBuffer): sleep_ms(100) def show(self): # Blocks 36ms on Pyboard D at stock frequency (160*128) - wd = self.width - ht = self.height + wd = 160 + ht = 128 lb = self._linebuf buf = self._mvb self._dc(0) diff --git a/gui/core/fplot.py b/gui/core/fplot.py index e53e0c7..9638383 100644 --- a/gui/core/fplot.py +++ b/gui/core/fplot.py @@ -23,7 +23,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -from nanogui import DObject, circle +from gui.core.nanogui import DObject, circle from cmath import rect, pi from micropython import const from array import array diff --git a/st7735r_setup.py b/st7735r_setup.py index 57e8327..ee3b689 100644 --- a/st7735r_setup.py +++ b/st7735r_setup.py @@ -6,8 +6,6 @@ # As written, supports: # Adfruit 1.8' Color TFT LCD display with MicroSD Card Breakout: # 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 # 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 height = 128 -width = 128 +width = 160 pdc = machine.Pin('Y1', machine.Pin.OUT_PP, value=0) pcs = machine.Pin('Y2', machine.Pin.OUT_PP, value=1) prst = machine.Pin('Y3', machine.Pin.OUT_PP, value=1) spi = machine.SPI(2, baudrate=12_000_000) 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