diff --git a/DISPLAYS.md b/DISPLAYS.md index a203014..b99ceed 100644 --- a/DISPLAYS.md +++ b/DISPLAYS.md @@ -10,30 +10,31 @@ owing to their long update time. ## Displays using drivers in this repo -Size is diagonal in inches. C/M color/monochrome. +Size is diagonal in inches. C/M/GS color/monochrome/greyscale. Width and height are pixels. -| Size | Width | Height | Tech | Driver | Description | Notes | -|:-----:|:-----:|:------:|:------|:--------------|:---------------------------|:------| -| 0.96C | 94 | 64 | OLED | [SSD1331][1d] | [Adafruit 684][1m] | | -| 1.27C | 128 | 96 | OLED | [SSD1351][2d] | [Adafruit 1673][2m] | | -| 1.5C | 128 | 128 | OLED | [SSD1351][2d] | [Adafruit 1431][3m] | | -| 1.44C | 128 | 128 | TFT | [ST7735R][4d] | [Adafruit 2088][5m] | | -| 1.5C | 160 | 128 | TFT | [ST7735R][4d] | [Adafruit 358][6m] | | -| 1.3C | 240 | 240 | TFT | [ST7789][5d] | [Adafruit 4313][7m] | | -| 1.5GS | 128 | 128 | OLED | [SSD1327][11d]| [Waveshare 13992][20m] | User contributed | -| 2.0C | 320 | 240 | TFT | [ST7789][5d] | [Waveshare Pico LCD 2][18m]| For Pi Pico | -| 1.54C | 240 | 240 | TFT | [ST7789][5d] | [Adafruit 3787][8m] | | -| 1.14C | 240 | 135 | TFT | [ST7789][5d] | [T-Display][9m] | ESP32 with attached display | -| 2.8C | 320 | 240 | TFT | [ST7789][5d] | [Waveshare pico 2.8][10m] | Display for Pi Pico | -| 1.14C | 240 | 135 | TFT | [ST7789][5d] | [Waveshare pico 1.14][11m] | For Pi Pico. Buttons good for micro-gui | -| 3.2C | 320 | 240 | TFT | [ILI9341][6d] | [Adafruit 1743][12m] | Big display. eBay equivalents work here. | -| 2.9M | 296 | 128 | eInk | [UC8151D][7d] | [Adafruit 4262][13m] | Flexible ePaper display | -| 2.9M | 296 | 128 | eInk | [UC8151D][7d] | [Adafruit 4777][15m] | FeatherWing ePaper display | -| 4.2M | 400 | 300 | eInk | [WS][10d] | [Waveshare pico 4.2][19m] | Pico, Pico W plug in. Other hosts via cable | -| 2.7M | 274 | 176 | eInk | [HAT][8d] | [Waveshare HAT][14m] | HAT designed for Raspberry Pi, repurposed. | -| 2.7M | 400 | 240 | Sharp | [Sharp][9d] | [Adafruit 4694][16m] | Micropower monochrome display. | -| 1.3M | 168 | 144 | Sharp | [Sharp][9d] | [Adafruit 3502][17m] | Ditto | +| Size | Width | Height | Tech | Driver | Description | Notes | +|:------:|:-----:|:------:|:------|:--------------|:---------------------------|:------| +| 0.96C | 94 | 64 | OLED | [SSD1331][1d] | [Adafruit 684][1m] | | +| 1.12GS | 96 | 96 | OLED ] [SSD1327][11d]| [Seeed 104030011[21m] | Obsolescent | +| 1.27C | 128 | 96 | OLED | [SSD1351][2d] | [Adafruit 1673][2m] | | +| 1.5C | 128 | 128 | OLED | [SSD1351][2d] | [Adafruit 1431][3m] | | +| 1.44C | 128 | 128 | TFT | [ST7735R][4d] | [Adafruit 2088][5m] | | +| 1.5C | 160 | 128 | TFT | [ST7735R][4d] | [Adafruit 358][6m] | | +| 1.3C | 240 | 240 | TFT | [ST7789][5d] | [Adafruit 4313][7m] | | +| 1.5GS | 128 | 128 | OLED | [SSD1327][11d]| [Waveshare 13992][20m] | | +| 2.0C | 320 | 240 | TFT | [ST7789][5d] | [Waveshare Pico LCD 2][18m]| For Pi Pico | +| 1.54C | 240 | 240 | TFT | [ST7789][5d] | [Adafruit 3787][8m] | | +| 1.14C | 240 | 135 | TFT | [ST7789][5d] | [T-Display][9m] | ESP32 with attached display | +| 2.8C | 320 | 240 | TFT | [ST7789][5d] | [Waveshare pico 2.8][10m] | Display for Pi Pico | +| 1.14C | 240 | 135 | TFT | [ST7789][5d] | [Waveshare pico 1.14][11m] | For Pi Pico. Buttons good for micro-gui | +| 3.2C | 320 | 240 | TFT | [ILI9341][6d] | [Adafruit 1743][12m] | Big display. eBay equivalents work here. | +| 2.9M | 296 | 128 | eInk | [UC8151D][7d] | [Adafruit 4262][13m] | Flexible ePaper display | +| 2.9M | 296 | 128 | eInk | [UC8151D][7d] | [Adafruit 4777][15m] | FeatherWing ePaper display | +| 4.2M | 400 | 300 | eInk | [WS][10d] | [Waveshare pico 4.2][19m] | Pico, Pico W plug in. Other hosts via cable | +| 2.7M | 274 | 176 | eInk | [HAT][8d] | [Waveshare HAT][14m] | HAT designed for Raspberry Pi, repurposed. | +| 2.7M | 400 | 240 | Sharp | [Sharp][9d] | [Adafruit 4694][16m] | Micropower monochrome display. | +| 1.3M | 168 | 144 | Sharp | [Sharp][9d] | [Adafruit 3502][17m] | Ditto | ## Displays using compatible drivers @@ -87,7 +88,7 @@ simple. See [this doc](./DRIVERS.md#7-writing-device-drivers) for details. [8d]: https://github.com/peterhinch/micropython-nano-gui/blob/master/DRIVERS.md#52-waveshare-eink-display-hat [9d]: https://github.com/peterhinch/micropython-nano-gui/blob/master/DRIVERS.md#4-drivers-for-sharp-displays [10d]: https://github.com/peterhinch/micropython-nano-gui/blob/master/DRIVERS.md#53-waveshare-400x300-pi-pico-display -[11d]: +[11d]: https://github.com/peterhinch/micropython-nano-gui/blob/master/DRIVERS.md#23-drivers-for-ssd1327 [1m]: https://www.adafruit.com/product/684 [2m]: https://www.adafruit.com/product/1673 @@ -109,3 +110,4 @@ simple. See [this doc](./DRIVERS.md#7-writing-device-drivers) for details. [18m]: https://www.waveshare.com/wiki/Pico-LCD-2 [19m]: https://thepihut.com/collections/epaper-displays-for-raspberry-pi/products/4-2-e-paper-display-module-for-raspberry-pi-pico-black-white-400x300 [20m]: https://www.waveshare.com/product/ai/displays/oled/1.5inch-oled-module.htm?___SID=U +[21m]: https://www.seeedstudio.com/Grove-OLED-Display-1-12.html?queryID=080778ddd8f54df96ca0e016af616327&objectID=1763&indexName=bazaar_retailer_products diff --git a/DRIVERS.md b/DRIVERS.md index a60ccf7..6849cfe 100644 --- a/DRIVERS.md +++ b/DRIVERS.md @@ -31,6 +31,7 @@ access via the `Writer` and `CWriter` classes is documented 2. [OLED displays](./DRIVERS.md#2-oled-displays) 2.1 [Drivers for SSD1351](./DRIVERS.md#21-drivers-for-ssd1351) Color OLEDs 2.2 [Drivers for SSD1331](./DRIVERS.md#22-drivers-for-ssd1331) Small color OLEDs + 2.3 [Drivers for SSD1327](./DRIVERS.md#23-drivers-for-ssd1327) Greyscale OLEDs 3. [Color TFT displays](./DRIVERS.md#3-color-tft-displays) 3.1 [Drivers for ST7735R](./DRIVERS.md#31-drivers-for-st7735r) Small TFTs 3.2 [Drivers for ILI9341](./DRIVERS.md#32-drivers-for-ili9341) Large TFTs @@ -244,6 +245,38 @@ def spi_init(spi): ###### [Contents](./DRIVERS.md#contents) +## 2.3 Drivers for SSD1327 + +This driver was contributed by Mike Causer (@mcauser) and Philip Adamson +(@Treadbrook). The displays are 4-bit greyscale. The driver converts 24-bit RGB +colors to 4-bit greyscale based on the maximum brightness of the R, G, and B +values. The driver should support any display using SSD1327 on I2C. Specific +support is for: + + 1. [Seed OLED 96x96](https://www.seeedstudio.com/Grove-OLED-Display-1-12.html?queryID=080778ddd8f54df96ca0e016af616327&objectID=1763&indexName=bazaar_retailer_products) + 2. [Waveshare 128x128](https://www.waveshare.com/product/ai/displays/oled/1.5inch-oled-module.htm?___SID=U) + +The driver provides the following classes: + 1. `SSD1327_I2C` Generic driver for SSD1327 using I2C interface. + 2. `SEEED_OLED_96X96` Subclass for the Seeed display. + 3. `WS_OLED_128X128` Subclass for Waveshare display. + +`SSD1327_I2C` constructor args: + 1. `width` In pixels. + 2. `height` In pixels. + 3. `i2c` Initialised I2C interface. + 4. `addr=0x3C` I2C address. + +The subclasses populate the width and height arguments appropriately for the +supported displays. + +`SEEED_OLED_96X96` constructor arg: + 1. `i2c` Initialised I2C interface. + +`WS_OLED_128X128` constructor args: + 1. `i2c` Initialised I2C interface. + 2. `addr=0x3C` I2C address. + # 3. Color TFT displays ## 3.1 Drivers for ST7735R @@ -1169,8 +1202,16 @@ A typical color display with 8-bit `rrrgggbb` hardware will use: def rgb(r, g, b): return (r & 0xe0) | ((g >> 3) & 0x1c) | (b >> 6) ``` -See the discussion below for other color mappings including 16-bit and 4-bit -variants. +A greyscale display typically maps RGB values onto a 4-bit greyscale color +space: +```python + @staticmethod + def rgb(r, g, b): + return max(r, g, b) >> 4 +``` +See the discussion below for other color mappings. These include 16-bit and +also 4-bit variants where, to conserve RAM, colors are stored in a 4-bit format +and dynamically expanded to values acceptable to the hardware. ## 7.3 Show diff --git a/drivers/ssd1327/ssd1327.py b/drivers/ssd1327/ssd1327.py index cd475f3..8b0a7bd 100644 --- a/drivers/ssd1327/ssd1327.py +++ b/drivers/ssd1327/ssd1327.py @@ -3,7 +3,7 @@ MicroPython SSD1327 OLED I2C driver Adapted for CWriter, nano-gui and micro-gui from https://github.com/mcauser/micropython-ssd1327 -by @mcauser (Mike Causer) and @Treadbrook (Philip Adamson). +by @mcauser (Mike Causer), @Treadbrook (Philip Adamson), @peterhinch (Peter Hinch). MIT License Copyright (c) 2022 Mike Causer @@ -60,7 +60,12 @@ REG_CMD = const(0x80) REG_DATA = const(0x40) class SSD1327(FrameBuffer): - lut = bytearray(32) + # Convert r, g, b in range 0-255 to a 4 bit greyscale value + # acceptable to hardware + @staticmethod + def rgb(r, g, b): + return max(r, g, b) >> 4 + def __init__(self, width=128, height=128): self.width = width self.height = height