PDA

View Full Version : How to move data from array into LCD? (Using LCDOUT)



CuriousOne
- 2nd September 2016, 15:20
Hello. I have certain project, it uses a lot of custom characters, and they need to be changed frequently. I've already learned how to read data from eeprom into array, but I'd like to somehow mate array and LCDOUT, so I can slide-in out data, to create visual effects, any idea?

I'm asking for this:



lcdout $fe,$40, $e, $11, $12, $14, $1e, $11, $11, $12


How to replace hex data here with dynamic data from array?

Just in theory, how I see this code in some idealistic BASIC:



DIM GRAPH(8) 'define array with 8 lines
GRAPH(1)=$FE
GRAPH(2)=$CO ' and so on, example of data in array
For A=0 to 7 ' loop till 8
LCDOUT $FE, $40+A, GRAPH(A) - write bytes to LCD memory
NEXT A


But of course, above won't work in PBP.

HenrikOlsson
- 2nd September 2016, 15:36
Section 5.38, LCDOUT:

STR ArrayVar{\count} Send string of n characters

Then of course if you want to do it in the idealistic BASIC way

Graph[0] = $11
Graph[1] = $23
'and so on.
LCDOUT $FE, 1 'Clear the screen
For i = 0 to 7
LCDOUT Graph[i]
NEXT


/Henrik.

CuriousOne
- 2nd September 2016, 17:13
With LCDOUT, I don't want to put new characters on screen, I want to update LCD screen custom character RAM, so process of char redrawing will be shown as animation.

HenrikOlsson
- 3rd September 2016, 07:48
What's the difference between writing to DDRAM and CGRAM? Instead of sending the clearscreen command as in the example, send the correct command to access CGRAM and then the data.

/Henrik.

CuriousOne
- 3rd September 2016, 17:55
The question is in following. Say, first character RAM starts at $40. And this is address for top line, right? and address for next line is $41 ? I mean, if I do code, where $40 will be incremented by 1 in loop for 7 times, all lines will be written properly?



LCDOUT $FE, $40+A,


is such structure correct?

HenrikOlsson
- 3rd September 2016, 18:50
The adress pointer in the 44780 is incremented automatically so if you set it to $40 and send 5 bytes of data they will end up at adress $40-$44 automatically. Just as they would when you write to the DDRAM, you (for example) clear the screen which sets the adress pointer to 0 (first char on first line). Each byte received from there on will end up at "the next" location, right? There's no difference in writing to CGRAM. So if you prefer your idealistic way over using the STR modifer

LCDOUT $FE, $40 ' Set adress pointer to first location of CGRAM
For i = 0 to 7 ' Send 8 bytes of CG data
LCDOUT Graph[i]
NEXT

At least give it a try and see if it does what you're asking.

/Henrik.

CuriousOne
- 3rd September 2016, 20:07
The problem is, that I want sent data byte by byte, not all together, but with small delay.

CuriousOne
- 3rd September 2016, 20:10
I mean, I want to send one byte into 1st line of 1st char, then send 1 byte into 1st line of 2nd char and so on.

CuriousOne
- 3rd September 2016, 21:02
So say this code:



LCDOUT $FE, $40,$12
LCDOUT $FE, $48,$15


Will send $12 to 1st line of 1st char and $15 to 1st line of 2nd char, but if I call the LCDOUT $FE, $40, $12 again, it will be written into 2nd line of 1st char, right?

HenrikOlsson
- 3rd September 2016, 21:34
I'm sorry but your comments doesn't make any sense to me. I don't understand what it is you're actually asking or trying to do. Either I'm stupid or you don't make a very good job of explaining yourself - it's probably the former....

First you said you DON'T want to put characters on the screen with LCDOUT and now you're talking about first character on line 1 and line 2. Writing to CGRAM won't put characters anywhere on the screen, it will however update any instances OF the character no matter WHERE on the screen they are.

Then you say you want a delay, which you can just do with a PAUSE within the FOR-NEXT loop.



LCDOUT $FE, $40,$12 ' Write $12 to CGRAM 0
LCDOUT $FE, $48,$15 ' Write $15 to CGRAM 8
LCDOUT $FE, $40,$12 ' Write $12 to CGRAM 0 (again)
LCDOUT $13,$14,$15 ' Write $13, $14, $15 to CGRAM 1, 2, 3 (because the previous command wrote to location 0)
LCDOUT $FE, $49, $16, ' Write $16 to CGRAM location 9




LCDOUT $FE, $40+A ' This will set the adress pointer to CGRAM location 0+A
For i = 0 to 7
LCDOUT Graph[i] ' Send a byte to CGRAM location 0+A+i
PAUSE 100
NEXT

CuriousOne
- 4th September 2016, 05:48
Yes, I know how CGRAM character works.

I asked two questions:

1. Can I any time access any CGRAM address?
2. Can I use variable for accessing that address?

richard
- 4th September 2016, 06:25
what have you tried ?
what did it do ?
what do actually want it to do differently ?



or is it that you have you copied this code from somewhere

DIM GRAPH(8) 'define array with 8 lines
GRAPH(1)=$FE
GRAPH(2)=$CO ' and so on, example of data in array
For A=0 to 7 ' loop till 8
LCDOUT $FE, $40+A, GRAPH(A) - write bytes to LCD memory
NEXT A
and need help to convert it to pbp

HenrikOlsson
- 4th September 2016, 07:32
I don't mean to sound harsh but like Richard says, have you tried to use any CGRAM adress at any time or use a variable when setting CGRAM adress?

1. Can I any time access any CGRAM address?
Yes, of course you can, just send the command for setting the adresspointer to whatever location you want.

2. Can I use variable for accessing that address?
Yes, of course tou can, just send the command for setting the adresspointer to whatever location you want. (That location being held in a variable or in the result of calculation, like in the example).

Just try it for crying out loud :-) 10 minutes of writing some testcode would provide you with the answers you've been looking for for two days now :-)


/Henrik.

CuriousOne
- 4th September 2016, 12:18
I do not have access to hardware on weekends, so I prefer to solve theoretic ussies on weekend, to deal with them in hardware next week :)

Art
- 5th September 2016, 15:40
Assuming the array is bytes (characters) because that’s what you did in your first post, are you talking about rotating the bytes through the array?
There are a lot of ways to do it, you can run a loop that copies the array element after the current byte, to the current byte, and write the new byte to the last one.
That would see your data scroll across the screen for example, even though you use the same array in the same order in the LCDOUT command, it’s the data that changed.

If it’s this circuit in the other thread where your LCD isn’t working, if you power it, but don’t initialise it do you see the first row of solid bars?
If not, you can look at power and contrast first.

CuriousOne
- 5th September 2016, 16:23
No, these are different circuits :) This one works as it should, and I already created some interesting animation effects, like ones that can be seen in old skool demoscene intros :)

technotronix
- 22nd September 2016, 14:25
I think efm8 microcontroller would be helpful.

HenrikOlsson
- 22nd September 2016, 18:39
In what way exactly would an EFM8 microcontroller help the OP with his question reagarding using the PBP cpmmand LCDOUT on a PIC microcontroller? Please explain because I don't understand.

I don't know if you're actaully TRYING to help or just plain out trolling but you do realise that this forum is mainly for discussing PICs and specifically the PBP compiler from MicroEngineeringLabs don't you?

You've been here a month, haven't asked a single question (that's totally fine) or given a single answer to anything pertaining to the forum topic. You continue to post totally unrelated links to sites about CCS, Perl, C++, other microcontroller or just plain out spam. I don't get it.

If you really ARE here to discuss PBP and the use of it please accept my appologies for jumping on you but if my feeling is right and you don't even know what PBP is please educate yourself and then stick to the forum topics and stop posting nonsense.

/Henrik.

Scampy
- 26th September 2016, 08:34
In what way exactly would an EFM8 microcontroller help the OP with his question reagarding using the PBP cpmmand LCDOUT on a PIC microcontroller? Please explain because I don't understand.

I don't know if you're actaully TRYING to help or just plain out trolling but you do realise that this forum is mainly for discussing PICs and specifically the PBP compiler from MicroEngineeringLabs don't you?

You've been here a month, haven't asked a single question (that's totally fine) or given a single answer to anything pertaining to the forum topic. You continue to post totally unrelated links to sites about CCS, Perl, C++, other microcontroller or just plain out spam. I don't get it.

If you really ARE here to discuss PBP and the use of it please accept my appologies for jumping on you but if my feeling is right and you don't even know what PBP is please educate yourself and then stick to the forum topics and stop posting nonsense.

/Henrik.

Well said Henrik