![]() |
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 StatesPosts: 3 |
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 KingdomPosts: 7585 |
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 StatesPosts: 3 |
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 KingdomPosts: 4006 |
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 KingdomPosts: 4006 |
Oh, you beat me to it. Bigger than &h40 does make sense - try a datasheet... John |
||||
fapplin Newbie ![]() Joined: 14/02/2025 Location: United StatesPosts: 3 |
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 StatesPosts: 3326 |
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 KingdomPosts: 4006 |
Excellent! John |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |