B4R Question rSPI32 lib - Send One Command Byte and Receive Two Bytes Back As Int

KiloBravo

Active Member
Licensed User
Can I use SPI.Transfer_Byte_Array in the rSPI32 lib to accomplish this ?
The syntax to do it is currently eluding me! :)

SPI Send One Command Byte then Receive Two Bytes Back (Int):
        ' y1 
           Dim yi As Int = 0
           Dim Y_COMMAND_BYTE As Byte = 0x90  ' Send One Byte Y Command
           Dim MSB, LSB As Byte = 0 ' Receive Back Two Bytes
          
           SPI.Transfer_Byte(Y_COMMAND_BYTE) ' send command byte
           MSB = SPI.Transfer_Byte(0)
           LSB = SPI.Transfer_Byte(0)
           yi = Bit.ShiftLeft(Bit.And(MSB,MSB_BIT_MASK),8)
           yi = yi + LSB
           yi = Bit.ShiftRight(yi,3)
 

KiloBravo

Active Member
Licensed User
Hello
I really like "PROSITRON" for PICs, it is a great compiler but it falters in the IDE, now they are starting to use VSCODE and I think it will be a great advance. The compiler is very highly optimized and creates very compact and fast code. But I think that with the ESP32 costers and the power that the PIC days have, they are coming to an end, that's why I'm initiating the change and I think that B4R has a lot of future and a lot to optimize.
Do you have a link for PROSITRON ?
 
Upvote 0

KiloBravo

Active Member
Licensed User
I ordered 3 new 3.5" TFT SPI 480x320 boards on 12/15. They arrived 9 days later from Hong Kong. 9 days and 8100 miles from my click to buy to my mail box!

Unfortunately I did not realize the larger size TFT display has an ILI988 & XP2046 chip set. So the driver Erel wrapped for the ILI9341 does not work with my new boards!
The main difference is 24 bit color instead of 16 bit color.

I am looking at this lib to get it working

jaretburkett/ILI9488 ... https://github.com/jaretburkett/ILI9488
 
Upvote 0

Gerardo Tenreiro

Active Member
Licensed User
It is a pity the error in the order of the TFTs, the difference of the ILI9486 and the ILI9488 is very big and means the change of library, also it is not a very useful driver and the documentation and existing libraries are not many.
I don't have any TFT with ILI9488 so I won't be able to try many, however I have ILI9486 and I do use them frequently and it might help.
I'm going to see the price of a TFT with ILI9488 and touch to see if I can order it for the three wise men.
Happy Holidays.
 
Upvote 0

KiloBravo

Active Member
Licensed User
Candide, Thank You! I found that Lib after a google search and was "thinking" about wrapping it.
All I can say is there are '10' kinds of people in the B4X world ... Those that can wrap libraries & know Binary and those that can't/don't ! :eek:

I have wrapped one Lib successfully. But, just when I think I know what I am doing something comes up that I am not quiet sure how to handle.

A little bit of Holiday humor , but your wrapped Lib is greatly appreciated !!! :)
 
Upvote 0

candide

Active Member
Licensed User
unfortunately,ILI9488 library is based on Adafruit_GFX library and a lot of functions from Adafruit_GFX must be added to have this library working.
i am looking at what is missing, but before a new version it cannot be used.

Sorry for that...
 
Upvote 0

KiloBravo

Active Member
Licensed User
Yes, I found that out today. :)

I manually installed the Arduino Libs. Then compiled and ran the The graphicstest.ino program. It works fine running in Arduino v 1.8.15.

I did have to comment out one section in the ILI9488.cpp file. Lines 110 to 125.

C:
/* #else
    // Fast SPI bitbang swiped from LPD8806 library
    for(uint8_t bit = 0x80; bit; bit >>= 1) {
      if(c & bit) {
    //digitalWrite(_mosi, HIGH);
    *mosiport |=  mosipinmask;
      } else {
    //digitalWrite(_mosi, LOW);
    *mosiport &= ~mosipinmask;
      }
      //digitalWrite(_sclk, HIGH);
      *clkport |=  clkpinmask;
      //digitalWrite(_sclk, LOW);
      *clkport &= ~clkpinmask;
    }
*/
 
Upvote 0

candide

Active Member
Licensed User
this is Last version of library including adafruit GFX functions

i converted example provided for Arduino, in B4R format and compilation is OK but now we need tests with real board.

Now it is a big library and it will be a miracle if everything is working without test!
The best way should be to start simple and to add functions used step by step.

good luck!
 

Attachments

  • rILI9488.zip
    30.1 KB · Views: 292
Upvote 0

KiloBravo

Active Member
Licensed User
Thanks I will see what I can do. It is not compiling for me.
Getting a lot of these ...
!B4X\b4x_addlibs\B4R\rILI9488\B4R\Objects\src\rILI9488.cpp: In member function 'void B4R::B4RILI9488::setTextSize1(byte, byte)':
rILI9488.cpp:289:31: error: no matching function for call to 'ILI9488::setTextSize(byte&, byte&)'
rcs->setTextSize(sx, sy);
Just need to go through them one by one. :)
 
Upvote 0

KiloBravo

Active Member
Licensed User
Candide,
Great Job ! It works !!!

I am using a Lolin ESP32 Board. Arduino 1.8.15 B4R 3.90

I went into my Arduino Libs and Installed Adafruit_GFX_Library v 1.10.12
That lib required Adafruit_BUS_IO v 1.9.9
 
Upvote 0

KiloBravo

Active Member
Licensed User
So my Display Screen works fine with your code.

One thing I did notice was the first section Read Diagnostics don't return any values.
But they DID NOT work in the original lib either. The one from jaretburkett/ILI9488 ... https://github.com/jaretburkett/ILI9488

B4X:
'  // read diagnostics (optional but can help debug problems)
  Dim x As Byte = tft.readcommand8(tft.ILI9488_RDMODE,0)
  Log("Display Power Mode: 0x",BytetoHexa(x))
  x = tft.readcommand8(tft.ILI9488_RDMADCTL,0)
  Log("MADCTL Mode: 0x",BytetoHexa(x))
  x = tft.readcommand8(tft.ILI9488_RDPIXFMT,0)
  Log("Pixel Format: 0x",BytetoHexa(x))
  x = tft.readcommand8(tft.ILI9488_RDIMGFMT,0)
  Log("Image Format: 0x",BytetoHexa(x))
  x = tft.readcommand8(tft.ILI9488_RDSELFDIAG,0)
  Log("Self Diagnostic: 0x", BytetoHexa(x))



I am going to see if I can get the Touch Screen part working as well. Thanks!!!
 
Upvote 0

KiloBravo

Active Member
Licensed User
SPI for the Display (ILI9488) uses the default pins on the ESP32.

I added rSPI32 lib to use the second SPI port on the ESP32.

B4X:
    'CHANGE HERE THE PIN NUMBERS (SCK, MISO, MOSI, CS)
    'SS/CS =15 MISO=12 MOSI=13 SCK =14 T_IRQ = 0
    SPI.ESP32_SPI_Set_Pins(14,12,13,15)
    SPI.CSPinDeActivate(SPI.CS__SPI)     
    tirqPin.Initialize(0,tirqPin.MODE_INPUT_PULLUP)


SPI.Begin_Transaction(12000000, SPI.MSBFIRST, SPI.SPI_MODE0)

Touch interface(XPT2046) works good.

Speed of 12 000 000 seems to work the best for the touch. If I went higher like 16 000 000. I got some false touch reads.
12 000 000 works for me.

Thanks Again ! ?
 
Upvote 0

KiloBravo

Active Member
Licensed User
Lolin32 (WROOM32)
3.5" TFT SPI 480x320 V1.0
I used a prototype board.
ESP32 is powered by the usb cable/port used to program it. This is connected to my laptop.
The prototype board is powered by a separate +3.3v usb power supply.
This is just one of the ubiquitous usb +5v or +3.3v (select with a jumper) from China. (10 for $10 Ali-express)
The TFT is powered from this separate +3.3v usb power supply.
I tied the grounds together on the prototype board.

TFT Pins--------ESP32

VCC------------+3.3v
GND-----------GND
CS--------------05
Reset-----------17
DC/RS----------16
SDI/MOSI------23
SCK------------18
LED------------+3.3v
SDO/MISO-----19

T_CLK-----------14
T_CS------------15
T_DIN-----------13
T_DO-----------12
T_IRQ-----------0
 
Upvote 0

KiloBravo

Active Member
Licensed User
I did not include the rESP32extras library. I forget if the esp32 pins are defined in that library or not, but I did not use them.
 
Upvote 0
Top