Comments (7)
There seems to be some kind of support for 16 bit coordinates, it may be called "ram width" / "ram height". This is in bus_core.c:
if (self->ram_width < 0x100) {
data[data_length++] = x1;
data[data_length++] = x2;
} else {
if (self->address_little_endian) {
x1 = __builtin_bswap16(x1);
x2 = __builtin_bswap16(x2);
}
data[data_length++] = x1 >> 8;
data[data_length++] = x1 & 0xff;
data[data_length++] = x2 >> 8;
data[data_length++] = x2 & 0xff;
}
or "single byte bounds"
uint16_t ram_width = 0x100;
uint16_t ram_height = 0x100;
if (single_byte_bounds) {
ram_width = 0xff;
ram_height = 0xff;
}
from circuitpython.
I initially also thought that would be the way to go, but it is not. The C-driver code of Waveshare does:
//set the X coordinates
LCD_WriteReg(0x2A);
LCD_WriteData(Xstart >> 8); //Set the horizontal starting point to the high octet
LCD_WriteData(Xstart & 0xff); //Set the horizontal starting point to the low octet
LCD_WriteData((Xend - 1) >> 8); //Set the horizontal end to the high octet
LCD_WriteData((Xend - 1) & 0xff); //Set the horizontal end to the low octet
And LCD_WriteData()
does:
DEV_Digital_Write(LCD_DC_PIN,1);
DEV_Digital_Write(LCD_CS_PIN,0);
SPI4W_Write_Byte(Data >> 8);
SPI4W_Write_Byte(Data & 0XFF);
DEV_Digital_Write(LCD_CS_PIN,1);
This code sends every byte of the coordinates as 16-bit down the line.
from circuitpython.
I see -- so to send the coordinate 479 (= 0x1df
) it is necessary to send 0x00 0x01 0x00 0xdf
, with CS changes at various times? 🤯
from circuitpython.
Yes. The two SPI4W_Write_Byte
calls push the 2 bytes to the shift register which sends the 16-bit word to the chip. The actual display data is not mangled in this way.
from circuitpython.
This is really an obscure piece of hardware. Instead of directly attaching the SPI-interface to the ILI9488, they put 4 logic ICs in between that translate from SPI to 16-bit parallel.
The data is clocked out to the chip
- on a rising edge of CS
- every 16 bit
Commands and command-parameters are 8-bit, so it is necessary to either toggle CS after each command/command-parameter or send commands and command-parameters with an additional 0x00 fill-byte. Normal display data is 16-bit, so no CS-toggling in between is possible.
I made this work by hacking some lines in displayio/bus_core.c
(mainly sending the coordinates as discussed above). But this is more of a POC than a solution. The real solution would need an additional parameter to BusDisplay
(or FourWire
) that allows to distinguish this hardware from standard SPI-displays.
The main question is: does it make sense to support bad hardware design?!
from circuitpython.
I worry about the flash size cost for this new mode/flag on all the boards that would never use it. If a 2nd manufacturer used this scheme for some reason, or if there was a reason it was "sensible", I'd be happy to reconsider that position.
from circuitpython.
That is exactly what I think. So I just document what I have done and close this issue:
diff --git a/shared-module/displayio/bus_core.c b/shared-module/displayio/bus_core.c
index 301606c1f3..0b434ccd05 100644
--- a/shared-module/displayio/bus_core.c
+++ b/shared-module/displayio/bus_core.c
@@ -145,12 +145,12 @@ void displayio_display_bus_set_region_to_update(displayio_display_bus_t *self, d
// Set column.
displayio_display_bus_begin_transaction(self);
- uint8_t data[5];
+ uint8_t data[9];
data[0] = self->column_command;
uint8_t data_length = 1;
display_byte_type_t data_type = DISPLAY_DATA;
if (!self->data_as_commands) {
- self->send(self->bus, DISPLAY_COMMAND, CHIP_SELECT_UNTOUCHED, data, 1);
+ self->send(self->bus, DISPLAY_COMMAND, CHIP_SELECT_TOGGLE_EVERY_BYTE, data, 1);
data_length = 0;
} else {
data_type = DISPLAY_COMMAND;
@@ -164,9 +164,13 @@ void displayio_display_bus_set_region_to_update(displayio_display_bus_t *self, d
x1 = __builtin_bswap16(x1);
x2 = __builtin_bswap16(x2);
}
+ data[data_length++] = 0;
data[data_length++] = x1 >> 8;
+ data[data_length++] = 0;
data[data_length++] = x1 & 0xff;
+ data[data_length++] = 0;
data[data_length++] = x2 >> 8;
+ data[data_length++] = 0;
data[data_length++] = x2 & 0xff;
}
@@ -196,7 +200,7 @@ void displayio_display_bus_set_region_to_update(displayio_display_bus_t *self, d
data[0] = self->row_command;
data_length = 1;
if (!self->data_as_commands) {
- self->send(self->bus, DISPLAY_COMMAND, CHIP_SELECT_UNTOUCHED, data, 1);
+ self->send(self->bus, DISPLAY_COMMAND, CHIP_SELECT_TOGGLE_EVERY_BYTE, data, 1);
data_length = 0;
}
@@ -208,9 +212,13 @@ void displayio_display_bus_set_region_to_update(displayio_display_bus_t *self, d
y1 = __builtin_bswap16(y1);
y2 = __builtin_bswap16(y2);
}
+ data[data_length++] = 0;
data[data_length++] = y1 >> 8;
+ data[data_length++] = 0;
data[data_length++] = y1 & 0xff;
+ data[data_length++] = 0;
data[data_length++] = y2 >> 8;
+ data[data_length++] = 0;
data[data_length++] = y2 & 0xff;
}
from circuitpython.
Related Issues (20)
- floating point errors HOT 2
- lines drawn with bitmaptools.draw_polygon to a bitmap can partially fail to update a screen HOT 1
- Memento WiFi breaks if espcamera (or PyCamera) object is created. HOT 2
- EPaperdisplay.time_to_refresh never reaches zero
- Reading I2C bus in code.py interferes with auto-reload leaving attached displays inactive
- Some animated GIFS either delay or stop running HOT 2
- Adafruit_MIDI incompatible .mpy file HOT 2
- CircuitPython TLS version in m5stack HOT 16
- Hard Fault - Waveshare esp32s3 pico with espcamera
- Espressif ESP32-S3 DevKit-1 C boards moved NeoPixel pin on board revision HOT 2
- ESPNow fails to initialize on ESP32 C6 DevKit C1 N8 board HOT 1
- What is board_display_obj good for? HOT 3
- Add RGB666 color format for ILI9488 HOT 8
- ESP32-S3 ADC use causes crashes when WiFi in use HOT 52
- Can't run custom board build until large Build Boards CI job has run (giving cached submodules) HOT 4
- EINPROGRESS when trying to connect to wifi the first time each day HOT 4
- ESP32-S3 crashes when a client subscribes to the Notify characteristic of the AccelerationService HOT 1
- Settable microcontroller.cpu.frequency on espressif builds HOT 3
- Raw HID [get_last_received_report()] broken on 9.1.0-beta.3 (Pi Pico rp2040) HOT 5
- SSLSocket: support stream protocol & select
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from circuitpython.