Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 22:07 21 Oct 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : RP2350-Touch-LCD-2.8

Author Message
ehewlett
Newbie

Joined: 14/02/2025
Location: Canada
Posts: 9
Posted: 03:28am 01 Oct 2025
Copy link to clipboard 
Print this post

I've just acquired two RP2350-Touch-LCD-2.8 boards from Waveshare, and have put PicoMite BASIC on them, and am loving them. Unfortunately, however, the touchscreen on them is capacitative, rather than resistive - well, fortunately, really, but UNfortunately because I'm unable to get the touchscreens working on them on PicoMite BASIC... probably because they are capacitative.

Here's my OPTION LIST:

PicoMite MMBasic RP2350A Edition V6.00.03
OPTION SYSTEM SPI GP10,GP11,GP12
OPTION SYSTEM I2C GP6,GP7
OPTION FLASH SIZE 16777216
OPTION COLOURCODE ON
OPTION PICO OFF
OPTION CPUSPEED (KHz) 150000
OPTION LCDPANEL CONSOLE
OPTION DISPLAY 20, 40
OPTION LCDPANEL ST7789_320, LANDSCAPE,GP14,GP15,GP13,GP16
OPTION TOUCH GP17,GP18
OPTION SDCARD GP24, GP19, GP20, GP21

And here's the link to the Waveshare wiki page on the device: https://www.waveshare.com/wiki/RP2350-Touch-LCD-2.8

OPTION PICO is OFF because the RP2350 chip is built in, and setting PICO OFF makes GP24 available to the SDCARD.

My biggest hope is to somehow get the touchscreens working under PicoMite BASIC. Any help in this regard that anyone might be able to offer would be much appreciated!

I seem to sort of have gotten touch working with "OPTION SYSTEM I2C GP6,GP7" and then "OPTION TOUCH GP17,GP18", but when I use the "GUI CALIBRATE" command, it gets the first touch fine but errors out on the second touch with the error message, "Touch hardware failure 4095,4095,4095,4095".

ChatGPT's diagnosis of the problem is that my board 'uses a CST328 capacitive controller over I²C, not SPI. It never drives MISO, and it doesn’t understand the SPI commands PicoMite is sending. So when GUI CALIBRATE runs, PicoMite asks the SPI touch chip for coordinates, gets all 1s (0xFFF = 4095), and reports a “hardware failure.”'

Has anyone else tried to get PicoMite BASIC working on one of these boards? If so, any luck with the touchscreen?

Or is support for capacitative touch on the drawing board for an upcoming version of PicoMite BASIC?
Edited 2025-10-01 14:17 by ehewlett
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2782
Posted: 04:41am 01 Oct 2025
Copy link to clipboard 
Print this post

Can only find one supported:-
  Quote  Includes support for FT6336 CAPACITIVE touch chip
OPTION TOUCH FT6336 IRQpin, RESETpin [,BEEPpin] [,sensitivity]
Enables touch support for FT6336 capacitive touch chip. Sensitivity is a number between 0 and 255 - defaults to 50, lower is more sensitive.
SDA and SCK should be connected to valid I2C pins and set up with OPTION SYSTEM I2C.

Edited 2025-10-01 14:44 by phil99
 
ehewlett
Newbie

Joined: 14/02/2025
Location: Canada
Posts: 9
Posted: 05:20am 01 Oct 2025
Copy link to clipboard 
Print this post

Hmm... I see. Thanks! I missed that option.

The touch chip, however, is clearly CST328 over I2C. I'll see if by some chance the option is compatible with my unit's chip... maybe there's a consistent method of communication with capacitative touch chips. What do you think the odds are that the FT6336 and the CST328 are compatible?
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2782
Posted: 05:30am 01 Oct 2025
Copy link to clipboard 
Print this post

You would need to download the data sheets to compare them.
Or, as you indicated just give it a go. First remove the resistive touch with OPTION TOUCH DISABLE.
 
ehewlett
Newbie

Joined: 14/02/2025
Location: Canada
Posts: 9
Posted: 05:38am 01 Oct 2025
Copy link to clipboard 
Print this post

Sigh. No such luck.

The command OPTION TOUCH FT6336 GP17,GP18 returns the following error message:

  Quote  Touch panel ID not found
20 Touch panel not found


Guess my next option is to dive into the data sheets.

I've also glanced at the C code for PicoMite BASIC on the GitHub repo, but that's intimidating... especially since I don't know C! But knowing there's something in there for the FT6336 capacitative touch chip at least gives me something to look for...
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2782
Posted: 08:12am 01 Oct 2025
Copy link to clipboard 
Print this post

LIST SYSTEM I2C should at least tell you what it's address is (in HEX).
 
IanT

Senior Member

Joined: 29/11/2016
Location: United Kingdom
Posts: 114
Posted: 11:03am 01 Oct 2025
Copy link to clipboard 
Print this post

My memory is not what it was but I seem to recall setting up my Waveshare 2.8" for touch when it first arrived (just to test it) but I was using a Pico 1 (directly plugged in) at that time.

It is currently set-up with a new Pico 2 (on a Quad Extender) but I haven't enabled 'Touch' because I don't need it for current uses. I'm away at the moment but can try it on return if you've not resolved your issue by then...

Regards,


IanT
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10493
Posted: 11:39am 01 Oct 2025
Copy link to clipboard 
Print this post

The Waveshare displays I've got all have resistive touch screens using the XPT2046 which has been around forever, seems to be ubiquitous for resistive touch and is of course fully supported by MMBasic.
There seem to be an unending variety of capacitive touch controllers - all different - and some extremely difficult to drive (GT911) which makes it impossible to support all of them in MMbasic. I added the FT6336 because it is fairly common and very simple to drive but the driver won't work with any of the other controllers (including another FT variant).
The only thing I can suggest with a controller like the CST328 is to write the handler in Basic if you can find how. It's simply not possible to add all these different controllers to MMbasic. I already have more TFT displays sitting in a box that I bought to add support than I know what to do with.
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1579
Posted: 02:35pm 01 Oct 2025
Copy link to clipboard 
Print this post

  matherp said  
The only thing I can suggest with a controller like the CST328 is to write the handler in Basic if you can find how.


Another job for Claude?  
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1579
Posted: 02:41pm 01 Oct 2025
Copy link to clipboard 
Print this post

The manual is too big to upload but Claude requests:

  Quote  When you extract the I2C information, it would be really helpful if you could include:

I2C initialization/setup commands
I2C read/write functions (especially how to read multiple bytes)
How interrupts or GPIO inputs are handled (for the touch IRQ pin)
Any timing or delay functions available

I'll also need to implement the CST328's I2C protocol, which typically involves:

I2C address (usually 0x5A for CST328)
Reading touch point data registers
Parsing X/Y coordinates and touch status

Just come back when you have the relevant sections ready, and I'll create a working driver for you!
 
ehewlett
Newbie

Joined: 14/02/2025
Location: Canada
Posts: 9
Posted: 03:35pm 01 Oct 2025
Copy link to clipboard 
Print this post

Wow! A reply from the great Peter Mather himself! (Thanks, Peter. Big fan here!) That’s about as definitive as it gets, I guess. Unfortunately for me, it’s a definitive no.

I totally understand, of course. I remember back in the days of the TRS-80 Color Computer, someone lamenting, in an edition of the Rainbow Magazine dedicated to printers, how frustrating it was to support every new printer that came on the market. I’d offer to send you a RP2350-Touch-LCD-2.8, ‘cause it’s such a nice piece of kit, but I don’t want to add to your frustration - or your box of discarded touchscreens!

I’m not a hardware guy - and, despite that, I actually have a working PS2/VGA PicoMite, for which I learned to solder and soldered myself, as well as two HDMI/USB PicoMites (since JCLPCB had a minimum order of two boards at the time), because I love BASIC and I love what you guys are doing. My hope, as not-a-hardware-guy, was that the RP2350-Touch-LCD-2.8 could be the platform for my project of porting my favourite BASIC game to a PicoMite, as it not only has capacitative touch, but also has a battery charging circuit built in - and it’s only about $30CAD.

I’ve been at this project for a while now, chronicling the ups and downs of it on my blog.
https://blog.ehewlett.net/2025/02/stellar-distractions-building-boot-to.html
https://blog.ehewlett.net/search/label/Stellar%20Empires

I’ve finally got my basic port up and running (haven’t done a post on that yet), and was hoping to move to adapting the interface for touchscreen, which seemed the most promising route to go - and still does, given the challenges of keyboard input on the Pico. (Plus, my vision is for a self-contained portable BASIC gaming device.) Maybe I’ll just have to go back to my old resistive touch Waveshare screens, which inspired the project. Or maybe I’ll have to get Claude to help me. ChatGPT volunteered to write me a handler for the touchscreen in BASIC, but what it gave me was an unusable mess.

I have enough experience programming in other languages, that I also figure I might be able to do C, if I could figure out how and where the various drivers are in Peter and Geoff’s codebase on GitHub (especially now that I know that one does exists for one capacitative screen!), but if a BASIC subroutine will do, I suppose that would be the easier way to go.

Anyhow, thanks for the help and feedback everyone. Reminds me of the “good old days” of BBSs and discussion boards! Any further help and suggestions would also be greatly appreciated!
Edited 2025-10-02 01:37 by ehewlett
 
Arne
Newbie

Joined: 05/01/2025
Location: Germany
Posts: 39
Posted: 04:11pm 01 Oct 2025
Copy link to clipboard 
Print this post

Hello,

I played in the past with this touchscreen. Here you can find my test program based on the datasheet. Due it is multitouch I implemented  „2 fingers“ only.


TouchTST.zip

Have Fun,

Arne
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4096
Posted: 04:45pm 01 Oct 2025
Copy link to clipboard 
Print this post

  ehewlett said  I’ve been at this project for a while now, chronicling the ups and downs of it on my blog.
https://blog.ehewlett.net/2025/02/stellar-distractions-building-boot-to.html

If you still have hardware issues (USB / reset / ...) you might like to put them on here (new thread?) as people here may be able to figure what's wrong.

John
 
ehewlett
Newbie

Joined: 14/02/2025
Location: Canada
Posts: 9
Posted: 12:56am 11 Oct 2025
Copy link to clipboard 
Print this post

Thank you all, and especially, thanks to Arne for his code. His test program got me started, as I saw it was detecting touches and doing something... although I wasn't entirely sure how it was working. So, following PhenixRising's suggestion, I turned to Claude.

I began by uploading the code Arne provided and asking Claude how it worked. Eventually I thought to download and add the Python library for interacting with the CST328 touch-controller chip on the RP2350-Touch-LCD-2.8. That was actually the breakthrough, as the Python library contained everything Claude needed to "know" the specs for writing the touch-handler code, but Arne's code still came in handy, as it gave Claude the lead it needed to debug its own code.

For anyone out there using this screen, here is the touch-handler that Claude wrote:


'Initialize touch controller reset pin (GP17)
SetPin gp17, dout
Pin(gp17) = 1
Pause 10
Pin(gp17) = 0
Pause 10
Pin(gp17) = 1
Pause 100

'Setup interrupt on GP18
SetPin gp18, intb, SUB_TEST

'Main loop
Do
Loop

Sub SUB_TEST
 'Check if there are any touch points (register 0xD005)
 I2C2 write &H1A,0,2,&HD0,&H05
 I2C2 read &H1A,0,1,touch_flag
 
 num_touches = touch_flag And &H0F
 If num_touches = 0 Then Exit Sub
 
 'Read first byte to validate
 I2C2 write &H1A,0,2,&HD0,&H00
 I2C2 read &H1A,0,1,byte0
 If (byte0 And &H0F) <> &H06 Then Exit Sub
 
 'Read first touch point coordinates
 I2C2 write &H1A,0,2,&HD0,&H01
 I2C2 read &H1A,0,1,byte1  'X low byte
 I2C2 write &H1A,0,2,&HD0,&H02
 I2C2 read &H1A,0,1,byte2  'Y low byte
 I2C2 write &H1A,0,2,&HD0,&H03
 I2C2 read &H1A,0,1,byte3  'X/Y high nibbles
 I2C2 write &H1A,0,2,&HD0,&H04
 I2C2 read &H1A,0,1,pressure
 
 'Calculate coordinates (already in screen pixels)
 x_pixel = (byte1 * 16) Or ((byte3 And &HF0) / 16)
 y_pixel = (byte2 * 16) Or (byte3 And &H0F)
 
 Print "Touch at pixel: X=";x_pixel;" Y=";y_pixel;" Pressure=";pressure
End Sub


And then here's a program I wrote to test out its interaction with some of the Color Computer emulation code (the PRINTAT function is replicating TRS-80 CoCo BASIC's PRINT @ X,"" command, where X is a text screen position from 0 to 511 - or 0 to 479 on this device's 32x15-line screen) that I'm using in my Stellar Empires porting project:


Font 4

Sub PRINTAT loc, text$, fgColour
 If fgColour=0 Then fgColour=RGB(black)
 locY = Int(loc/32)
 locX = loc - (locY*32)
 locY = locY * 16
 locX = locX * 10
 Text locX, locY, text$, , , , fgColour
End Sub

'Initialize touch controller reset pin (GP17)
SetPin gp17, dout
Pin(gp17) = 1
Pause 10
Pin(gp17) = 0
Pause 10
Pin(gp17) = 1
Pause 100

'Setup interrupt on GP18
SetPin gp18, intb, SUB_TOUCH

Dim touch_char_x, touch_char_y, touch_detected

CLS

Do
 If touch_detected Then
   touch_detected = 0

   PRINTAT touch_char_x + (touch_char_y * 32), "X", RGB(red)

 EndIf
 Pause 10
Loop

Sub SUB_TOUCH
 I2C2 write &H1A,0,2,&HD0,&H05
 I2C2 read &H1A,0,1,touch_flag
 num_touches = touch_flag And &H0F
 If num_touches = 0 Then Exit Sub

 I2C2 write &H1A,0,2,&HD0,&H00
 I2C2 read &H1A,0,1,byte0
 If (byte0 And &H0F) <> &H06 Then Exit Sub

 I2C2 write &H1A,0,2,&HD0,&H01
 I2C2 read &H1A,0,1,byte1
 I2C2 write &H1A,0,2,&HD0,&H02
 I2C2 read &H1A,0,1,byte2
 I2C2 write &H1A,0,2,&HD0,&H03
 I2C2 read &H1A,0,1,byte3

 x_pixel = (byte1 * 16) Or ((byte3 And &HF0) / 16)
 y_pixel = (byte2 * 16) Or (byte3 And &H0F)

 'Convert pixels to character grid position (LANDSCAPE MODE)
 '320 pixels / 32 chars = 10 pixels per char (X axis uses the 320 dimension)
 '240 pixels / 16 rows = 15 pixels per row (Y axis uses the 240 dimension)
 touch_char_x = 31 - Int(y_pixel / 10)  'Note: y_pixel maps to X character position
 touch_char_y = Int(x_pixel / 15)  'Note: x_pixel maps to Y character position

 touch_detected = 1
End Sub
 
ehewlett
Newbie

Joined: 14/02/2025
Location: Canada
Posts: 9
Posted: 01:22am 17 Oct 2025
Copy link to clipboard 
Print this post

Note: For anyone interested in BASIC touch-handler, I have identified an error in the code. This will not matter much to anyone who simply uses it to identify pixel positions, but the
FONT 4
selection is actually 16 pixels high, resulting in 15 rows of text on this device's 240-pixel high display. Hence the fourth-to-last line in the touch-handler should read

touch_char_y = Int(x_pixel / 16)


and the corresponding comment in the line above should read

'240 pixels / 15 rows = 16 pixels per row (Y axis uses the 240 dimension)


Also, if anyone with any knowledge of this display knows how to tweak the touch-handler and/or the test code to detect when a touch is released, I'd very much appreciate some guidance. I've made this code work (with the above modification), but not being able to detect when a touch is released has made the implementation of touch controls more than a little challenging!
 
Arne
Newbie

Joined: 05/01/2025
Location: Germany
Posts: 39
Posted: 08:54am 19 Oct 2025
Copy link to clipboard 
Print this post

Hello,

Here some expanded demo-code for the touch control with detailed comments.


WS_28_Touch.zip


Due I was lazy the evaluation of coordinates is implemented for 2 fingers only (can easy be expanded as needed; see comments in the program).

Function of demo:
- Draw with 1 finger on LCD
- Draw with 2 fingers LCD
- Clear LCD screen with 3 fingers
- Show text on LCD with 4 fingers
- Display raw data with 5 fingers

With the possibility to use up to 5 fingers also gesture-operations can easy be implemented.

P.S.:
A.) With „OPTION AUDIO I2S GP2,GP4“ you have full sound support.

B.) To the RTC: I was not able to set the correct year. Has anyone an Idea?

Arne
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2782
Posted: 09:00am 19 Oct 2025
Copy link to clipboard 
Print this post

Set Date$ and Time$ then:-

RTC SETTIME DateTime$(now)

or

RTC SETTIME Date$+" "+Time$

And if you have a GPS module connected (and the time-zone with daylight saving configured) :-

If GPS(Valid) then RTC SETTIME GPS(Date)+" "+GPS(Time)
Edited 2025-10-19 19:07 by phil99
 
Arne
Newbie

Joined: 05/01/2025
Location: Germany
Posts: 39
Posted: 10:26am 19 Oct 2025
Copy link to clipboard 
Print this post

Maybe I did not specify correctly…

My problem is that if I set the year of the RTC to e.g. 2025 and then ask the date the year „2005“ is displayed, means that the correct date cannot be set to the RTC.  It seems to be a problem with the RTC-chip implemented to the board (that mmBasic officially does not support). With the demo which came with the board the year (2024) was correct.  I tried to set the year direct to the registers of the RTC but had no success. Maybe setting of date and time has to follow a specific sequence…

Arne
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2782
Posted: 11:04am 19 Oct 2025
Copy link to clipboard 
Print this post

Ok, that is a problem.
This is a long shot but costs little to try - use a 2 digit year:-
  the manual said  The RTC SETTIME command will
also accept a single string argument in the format of dd/mm/yy hh:mm

So:- RTC SETTIME "19/10/25 11:05"
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025