Wish MCUFriends_kbv library for touch screen

derez

Expert
Licensed User
Longtime User
I have a 3.95 '' TFT which works nicely with all the examples they provide after installing these libraries:
https://github.com/prenticedavid/MCUFRIEND_kbv
Can you make it work in B4R as well ? I tried the above and it does not recognize the device.
Thanks
upload_2017-1-23_23-36-6-png.52280

img_20170123_233715-jpg.52281
 

derez

Expert
Licensed User
Longtime User
I can't see any use except for graphics since all the pins are used by the shield...
If you can include drawing, text, Bitmaps it will be great !
I also tried to put it on WEMOS, changing the CS pin to A3 but it is not enough. Working with WEMOS would be great - then I'll be able to use it as the screen to the clock instead of the 1602 LCD, or as a command panel to the IOT's at home.
So - if you can include the parts that allocate the pins to the LCD maybe it will work.
Thank you for the efforts you invest, you should learn to say NO sometimes...
BTW - the photos that I copied from the other thread disappeared !
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Try the attached library.
You need to add a reference to rAdafruitGFX library.

The library was not tested.

B4X:
Sub Process_Globals
   Public Serial1 As Serial
   Private mcu As MCUFRIEND_kbv
   
End Sub

Private Sub AppStart
   Serial1.Initialize(115200)
   Log("AppStart")
   Dim p As Pin 'ignore
   mcu.Initialize(p.A3, p.A2, p.A1, p.A0, p.A4)
   mcu.GFX.DrawCircle(10, 10, 10, mcu.COLOR_GREEN, True)
End Sub
 

Attachments

  • rMCUFRIEND_kbv.zip
    39 KB · Views: 621

derez

Expert
Licensed User
Longtime User
I've just re-visited this thread, thank you Erel, it works !
Can you tell which of the IO pins is not used by the TFT (to be able to connect to other parts/devices) ?
 

derez

Expert
Licensed User
Longtime User
I have checked the printed board on the back of the screen and saw few unconnected pins.
I connected all pins to arduino UNO by wires instead of direct plug-in, then checked the suspected pins.
Pins 0,1,A5 are free to use !
Now I connected a WEMOS by softserial to pins 0,1 (unable to load program when connected, so for loading - disconnect them)
The WEMOS provides time from NIST and the UNO displays it :

EDIT: As the WEMOS just sends data and the UNO just receives data, it is sufficient to connect just one wire from the TX pin of the wemos to RX pin of the UNO (pin D0). With that connection logic conversion is not required (the UNO reads 3.3v as high).

clock.jpg
 
Last edited:

derez

Expert
Licensed User
Longtime User
Additional features to the library will be useful and much appreciated:
- get touched point, to be able to create buttons for UI by the screen.
- Rotate to landscape.

not that there is much space left for more code...
 

rbghongade

Active Member
Licensed User
Longtime User
Dear friends,
Is there any support for touch inputs? If yes, how to to implement the same?
regards,
PS: this issue seems to be raised by derez!
Probably the touch functionality needs the Touch Screen Library. The attached library for Arduino works.Hence requesting the "brains" to wrap it for B4R!
 

Attachments

  • Touch-Screen-Library.zip
    7.8 KB · Views: 542
Last edited:

derez

Expert
Licensed User
Longtime User
Final configuration and box:

clock2.jpg

Edit: I have implemented the daylight saving time change in the code so I don't need any buttons. Just plug it to power !
 
Last edited:

derez

Expert
Licensed User
Longtime User
After the success with the 3.95 TFT and the library I purchased another TFT but couldn't get the 3.95 so I bought 3.5 inch.
It uses the same shield like the first but the colors where all mixed up and the text was written like in a mirror...
I did some guessing and came out with the following corrections:
1. Edit the MCUFRIENDS_kbv.cpp file with this (line 1623 in notepad++)
B4X:
   case 0x8357:
     //   _lcd_capable = AUTO_READINC | MIPI_DCS_REV1 | MV_AXIS | REV_SCREEN | READ_24BITS;
        _lcd_capable = AUTO_READINC | MIPI_DCS_REV1 | MV_AXIS | !REV_SCREEN | READ_24BITS| INVERT_GS;
(I got the 0x number from the ino program, the commented line is the original)
2. Added this function to my application:
B4X:
Sub mycolor(R As Byte,G As Byte,B As Byte) As UInt
    Return mcu.Color(B,G,R) 
End Sub
With this function in place you can use colors with RGB definition.

The cpp file correction does not affect the 3.95 functions.
 
Last edited:

derez

Expert
Licensed User
Longtime User
Checking again the io pins I found that pins 0,1 ,10-13 , A5 are not used by the TFT so they are usable for other tasks. pins 0,1 are used for the ide interface so if used for connection with other boards as HW serial - don't use logging during runtime.
 
Top