Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Help for 3 Wire SPI? (Esp32 + St7789V) #62

Open
shr1Khr opened this issue Dec 2, 2018 · 9 comments
Open

Question: Help for 3 Wire SPI? (Esp32 + St7789V) #62

shr1Khr opened this issue Dec 2, 2018 · 9 comments

Comments

@shr1Khr
Copy link

shr1Khr commented Dec 2, 2018

Hi Loboris,

Could you please guide me where to modify the library for the 3wire SPI? The D/CM pin is missing, and that is used as 9th MSB.

@ril3y
Copy link

ril3y commented Feb 6, 2019

@shr1Khr I am in the same boat. I ordered about 50x of these and didnt realize that it was missing the d/c pin which means just as you said. It will only work with 3 bit serial mode. @loboris if you have any time we would very grateful.

@MarsPlanet
Copy link

Was anyone able to solve this?

@willjkeller
Copy link

I came across the description in the datasheet the other day when I was trying to get this library to work with a 7735S. I don't have any displays to test it, but if you want to try it, have a look at page 44 of 201 , v1.1 of the 7735S datasheet.

The change in the protocol is pretty simple -- you just send the value of what the d/c line would be before the MSB of each byte.

Currently the DC transitions are hardcoded with gpio_set_level, so what you would need to do is find everywhere in tftspi.c PIN_NUM_DC is set, remove it, and extend the length of the data by 1 so you can add the value to the front.

It shouldn't be too bad. Good luck!

@ril3y
Copy link

ril3y commented Aug 25, 2019 via email

@shr1Khr
Copy link
Author

shr1Khr commented Aug 26, 2019

Hey guys,

So to solve this, we need to define two functions, one for command and one for parameters, and for EVERY 8 bits we are sending, a parameter/command bit needs to be added at the start.


void Init:: command(uint8_t val){
    //pinMode(_mosi, OUTPUT);  
        digitalWrite(_dc, 0);
        digitalWrite(_mosi, 0);  
        digitalWrite(_sck, HIGH);
        digitalWrite(_sck, LOW);
    
    for (int i = 0; i < 8; i++) {   //send command
        digitalWrite(_mosi, (val & 0x80) != 0);
        digitalWrite(_sck, HIGH);
        digitalWrite(_sck, LOW);
        val <<= 1;
    }
}

void Init::chipEnable(){
  digitalWrite(_cs, LOW);
  }

void Init::chipDisable(){
  digitalWrite(_cs, HIGH);
  }

void Init::chipToggle(){
  digitalWrite(_cs, HIGH);
  delay(1);
  digitalWrite(_cs, LOW);
  
  }
  
void Init:: param(uint8_t val){
    //pinMode(_mosi, OUTPUT);  
    digitalWrite(_dc, 1);
    digitalWrite(_mosi, 1);  
    digitalWrite(_sck, HIGH);
    digitalWrite(_sck, LOW);
    
    for (int i = 0; i < 8; i++) {   //send command
        digitalWrite(_mosi, (val & 0x80) != 0);
        digitalWrite(_sck, HIGH);
        digitalWrite(_sck, LOW);
        val <<= 1;
    }
  }


I tried with SPI and bit banging, and I found that bitbanging is a bit faster compared to SPI. Im using esp32 for this btw.
Also, DC pin is the second serial pin to send the data to LCD. It's called dual SPI mode. In esp32, the flash we use uses quad SPI. You need to look these protocols up, I wasn't able to crack the dual SPI mode of this LCD, so I'm just setting it 1 or 0 as per parameter or command, but this pin can be safely ignored.
The above functions are just to interface with the LCD. You must have received some initialization code or driver code with the LCD that is required with the above functions. Hope this helps.
@ril3y could you please post the pics of the LCD or the link of the seller so that I can check it out?

@shr1Khr
Copy link
Author

shr1Khr commented Aug 26, 2019

One more thing-
To read a register of the LCD screen, you need to first send the command, then make the mosi pin as input and pulse the clock as per the length of the data to be received. After that, you need to set the mosi to output to again send next command, and so on...

@ril3y
Copy link

ril3y commented Aug 26, 2019 via email

@shr1Khr
Copy link
Author

shr1Khr commented Aug 26, 2019

Wow that's a completely different lcd I have, anyways, check out the datasheet of the lcd, one of the following- my code or adafruit's or bodmer's tft code should work.

Here is mine-
https://m.alibaba.com/product/60716482741/1-54-inch-240-240-small.html?spm=a2706.wap_new_search.1998817009.2.3b5c284fkoDZJb&__detailProductImg=%2F%2Fsc02.alicdn.com%2Fkf%2FHTB1fkfSeCtYBeNjSspaq6yOOFXae%2F1-54-inch-240-240-small-IPS.jpg_140x140xz.jpg

@monkeytronics
Copy link

monkeytronics commented Apr 8, 2021

Possibly a daft question on this topic, folks. I want to use a display (Winstar WF32DTLAJDNN0# : Link ) in which the data sheet says it has optional 3-wire 9-bit / 4-wire 8-bit serial interface modes. However, there is only one data line which is bidirectional! I am confused by this definition of 3 wire.

The only way I can make sense of this definition is if the MISO is not used. I.e. the lvgl library never actually reads anything back from the display or is currently doing so it in half duplex mode over a single data pin? In which case, I can ignore this factor? Or else, how do we address this?

Thanks all.

Edit
I've hooked a scope up to the MOSI & MISO on my board to be 100% certain. Nice 40MBaud comms on the MOSI. Not a sausage on the MISO line. But I expect everyone but me already knew that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants