kopia lustrzana https://github.com/peterhinch/micropython-nano-gui
Selected drivers: make mode a bound variable
rodzic
29ef2002b4
commit
7ecabf0fc1
|
@ -186,7 +186,8 @@ Bound variables:
|
|||
* `source` The path of the source image file.
|
||||
* `rows` Image dimensions in pixels.
|
||||
* `cols`
|
||||
* `mode` Mode used to create a FrameBuffer
|
||||
* `mode` Mode used to create a FrameBuffer: values correspond to
|
||||
[FrameBuffer constants](https://docs.micropython.org/en/latest/library/framebuf.html#constants).
|
||||
* `data` Image data bytes, with layout as per binary file.
|
||||
|
||||
## 3.3 Using a Python image file
|
||||
|
|
|
@ -77,12 +77,12 @@ class GC9A01(framebuf.FrameBuffer):
|
|||
self.width = width
|
||||
self._spi_init = init_spi
|
||||
self._gscale = False # Interpret buffer as index into color LUT
|
||||
mode = framebuf.GS4_HMSB
|
||||
self.palette = BoolPalette(mode)
|
||||
self.mode = framebuf.GS4_HMSB
|
||||
self.palette = BoolPalette(self.mode)
|
||||
gc.collect()
|
||||
buf = bytearray(height * width // 2) # Frame buffer
|
||||
self.mvb = memoryview(buf)
|
||||
super().__init__(buf, width, height, mode)
|
||||
super().__init__(buf, width, height, self.mode)
|
||||
self._linebuf = bytearray(width * 2) # Line buffer (16-bit colors)
|
||||
|
||||
# Hardware reset
|
||||
|
|
|
@ -63,12 +63,12 @@ class GC9A01(framebuf.FrameBuffer):
|
|||
self.height = height # Logical dimensions for GUIs
|
||||
self.width = width
|
||||
self._spi_init = init_spi
|
||||
mode = framebuf.GS8 # Use 8bit greyscale for 8 bit color.
|
||||
self.palette = BoolPalette(mode)
|
||||
self.mode = framebuf.GS8 # Use 8bit greyscale for 8 bit color.
|
||||
self.palette = BoolPalette(self.mode)
|
||||
gc.collect()
|
||||
buf = bytearray(height * width) # Frame buffer
|
||||
self.mvb = memoryview(buf)
|
||||
super().__init__(buf, width, height, mode)
|
||||
super().__init__(buf, width, height, self.mode)
|
||||
self._linebuf = bytearray(width * 2) # Line buffer (16-bit colors)
|
||||
|
||||
# Hardware reset
|
||||
|
|
|
@ -62,12 +62,12 @@ class ILI9341(framebuf.FrameBuffer):
|
|||
self.width = width
|
||||
self._spi_init = init_spi
|
||||
self._gscale = False # Interpret buffer as index into color LUT
|
||||
mode = framebuf.GS4_HMSB
|
||||
self.palette = BoolPalette(mode)
|
||||
self.mode = framebuf.GS4_HMSB
|
||||
self.palette = BoolPalette(self.mode)
|
||||
gc.collect()
|
||||
buf = bytearray(self.height * self.width // 2)
|
||||
self.mvb = memoryview(buf)
|
||||
super().__init__(buf, self.width, self.height, mode)
|
||||
super().__init__(buf, self.width, self.height, self.mode)
|
||||
self._linebuf = bytearray(self.width * 2)
|
||||
# Hardware reset
|
||||
self._rst(0)
|
||||
|
|
|
@ -92,12 +92,12 @@ class ILI9486(framebuf.FrameBuffer):
|
|||
self._short = min(height, width)
|
||||
self._spi_init = init_spi
|
||||
self._gscale = False # Interpret buffer as index into color LUT
|
||||
mode = framebuf.GS4_HMSB
|
||||
self.palette = BoolPalette(mode)
|
||||
self.mode = framebuf.GS4_HMSB
|
||||
self.palette = BoolPalette(self.mode)
|
||||
gc.collect()
|
||||
buf = bytearray(height * width // 2)
|
||||
self.mvb = memoryview(buf)
|
||||
super().__init__(buf, width, height, mode) # Logical aspect ratio
|
||||
super().__init__(buf, width, height, self.mode) # Logical aspect ratio
|
||||
self._linebuf = bytearray(self._short * 2)
|
||||
|
||||
# Hardware reset
|
||||
|
|
|
@ -96,12 +96,12 @@ class ST7789(framebuf.FrameBuffer):
|
|||
self._spi_init = init_spi # Possible user callback
|
||||
self._lock = asyncio.Lock()
|
||||
self._gscale = False # Interpret buffer as index into color LUT
|
||||
mode = framebuf.GS4_HMSB # Use 4bit greyscale.
|
||||
self.palette = BoolPalette(mode)
|
||||
self.mode = framebuf.GS4_HMSB # Use 4bit greyscale.
|
||||
self.palette = BoolPalette(self.mode)
|
||||
gc.collect()
|
||||
buf = bytearray(height * -(-width // 2)) # Ceiling division for odd widths
|
||||
self.mvb = memoryview(buf)
|
||||
super().__init__(buf, width, height, mode)
|
||||
super().__init__(buf, width, height, self.mode)
|
||||
self._linebuf = bytearray(self.width * 2) # 16 bit color out
|
||||
self._init(disp_mode, orientation)
|
||||
self.show()
|
||||
|
|
Ładowanie…
Reference in New Issue