Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 02:33 24 May 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 : Help with  SunFounder IIC I2C TWI Serial 2004 20x4 LCD Module Shield

Author Message
fapplin
Newbie

Joined: 14/02/2025
Location: United States
Posts: 3
Posted: 04:10pm 15 Feb 2025
Copy link to clipboard 
Print this post

Hi.

I'm a retired programmer who plays a lot with small microcontrollers like Raspberry Pi Pico. I have programmed them with the Arduino IDE in C/C++ or used the Pico SDK in C. I just came across MMBASIC for the Pico a couple days ago and decided for fun to convert a working project that I used the Arduino IDE for and re-work in MMBASIC.

I have almost everything working but the 4 x 20 LCD panel (in 2 days). I found some old code that someone posted in 2014 that I'm using and it works, but it only works for 2 lines not 4.

https://www.thebackshed.com/forum/ViewTopic.php?FID=16&TID=6715

Does anyone have an idea of how to get the 3rd and 4th line working?

I promise to post the project when finished. The project lets a user choose a key and scale and it will light up an LED strip above a piano keyboard showing which keys are in that key and scale (scales are definable on an SD Card.

Thanks,

Frank
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7585
Posted: 04:23pm 15 Feb 2025
Copy link to clipboard 
Print this post

So, it's a display with the I2C module on it?

In that code look for the line:
SUB LCDI2C(LineNum,CharPos,Text$)


That's the call used to print to the display. So
LCDI2C(4,3,"Hello")
should (in theory) print "Hello" at the third position on the bottom line. I think....   :)



And welcome to the 'shed. :)

.
Edited 2025-02-16 02:24 by Mixtel90
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
fapplin
Newbie

Joined: 14/02/2025
Location: United States
Posts: 3
Posted: 04:49pm 15 Feb 2025
Copy link to clipboard 
Print this post

This is from his code:


SUB LCDI2C(LineNum,CharPos,Text$)
LOCAL I
IF LineNum=1 THEN I=(&H80 + CharPos-1) 'I=&H02
IF LineNum=2 THEN I=(&HC0 + CharPos-1)
LCDI2C_CMD(I)

FOR I=1 TO LEN(Text$)
LCDI2C_DATA(ASC(MID$(Text$,I,1)))
NEXT I

END SUB


So, he's only doing 2 lines. The hex values were going up by 64, so I tried:


IF LineNum=3 THEN I=(&H100 + CharPos-1)


It was just a guess, but it didn't work.
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4006
Posted: 04:52pm 15 Feb 2025
Copy link to clipboard 
Print this post

hmm... looking at the code, SUB LCDI2C(LineNum,CharPos,Text$) checks LineNum against 1 and 2, setting I accordingly.

I expect it would need to check for 3 or 4 and set I (er, to &H40 and 0?)

I don't know the display needs, though.

John
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4006
Posted: 04:53pm 15 Feb 2025
Copy link to clipboard 
Print this post

Oh, you beat me to it.

Bigger than &h40 does make sense - try a datasheet...

John
 
fapplin
Newbie

Joined: 14/02/2025
Location: United States
Posts: 3
Posted: 06:11pm 15 Feb 2025
Copy link to clipboard 
Print this post

Through trial and error - this works!!


IF LineNum=1 THEN I=(&H80 + CharPos-1) 'I=&H02
IF LineNum=2 THEN I=(&HC0 + CharPos-1)
IF LineNum=3 THEN I=(&H94 + CharPos-1)
IF LineNum=4 THEN I=(&HD4 + CharPos-1)


Frank
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3326
Posted: 06:22pm 15 Feb 2025
Copy link to clipboard 
Print this post

Right. Typically (or at least frequently), the third line location is immediately following the first line (&H94-&H80 is 20 bytes further on), and the forth line immediately follows the second.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4006
Posted: 01:48pm 16 Feb 2025
Copy link to clipboard 
Print this post

Excellent!

John
 
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