PDA

View Full Version : Displaying strings from codespace.



Byte_Butcher
- 28th March 2010, 16:48
Well, the "strings in codespace" question seems to come up often enough, but my search still didn't come up with an answer that I like. :(

What I want is to store several strings in codespace (not EEPROM) and pull different ones up for display depending on the contents of a variable.

This is a pseudocode equivalent of what I WANT, but I don't know how to make it work in "real life"...




daynumber var byte
weekday var byte[9]


If daynumber = 0 then weekday = " SUNDAY "
If daynumber = 1 then weekday = " MONDAY "
If daynumber = 2 then weekday = " TUESDAY "
If daynumber = 3 then weekday = "WEDNESDAY"

LCDOUT $fe, 1, STR weekday\9



Is there a clever way to do this?

HELP! (please!)


steve

Jerson
- 28th March 2010, 17:06
This is how I do it for my seven segment displays.



msg_LoBatt:
PokeCode Cblank,$13,$15,$1b,$0B,$0a,$18,$18
msg_Func:
PokeCode Cblank,Cblank,Cblank,Cblank,$0f,$19,$14,$0c

'- thanks to Darrell Taylor @ picbasic forum -- Hi Darell ;)
ASM
GetAddress macro Label, Wout ; Returns the Address of a Label as a Word
CHK?RP Wout
movlw low Label
movwf Wout
movlw High Label
movwf Wout + 1
endm
ENDASM


ShowMsgLoBatt:
@ GetAddress _msg_LoBatt, _Address
goto Disp_msg
ShowMsgFunc:
@ GetAddress _msg_Func, _Address
goto Disp_msg

' Display a message from the Address specified
Disp_msg:
for gR[1] = 0 to 7
peekcode Address, gr[0]
DispBuf[gR[1]] = gR[0]
Address = Address+1
next
return




What it does is to load the starting address of the string, and Disp_msg displays the string.

Gr[0] and Gr[1] are general use registers byte wide
DispBuf is a buffer for the seven segment codes that go to the display

This will not directly work like you want it to, but it is close

HenrikOlsson
- 28th March 2010, 17:09
Do you have PBP2.60? If so this should do it, I think:



daynumber var byte
weekday var byte[9]

If daynumber = 0 then Arraywrite weekday, [" SUNDAY "]
If daynumber = 1 then Arraywrite weekday, [" MONDAY "]
If daynumber = 2 then Arraywrite weekday, [" TUESDAY "]
If daynumber = 3 then Arraywrite weekday, ["WEDNESDAY"]

LCDOUT $fe, 1, STR weekday\9

/Henrik.

Byte_Butcher
- 28th March 2010, 18:03
Henrik! Thank you! That did the trick.

So... uhhh.... where the heck did this "Arraywrite" come from?
I don't see any mention of it in the PBP 2.60 manual, not is it in the "Help" file...
And it doesn't even capitalize itself & "go bold" when I type it.

Is there a list somewhere of the new "features" in PBP 2.60?
Clearly the manual doesn't tell the whole story.


Jerson,
Thanks for your example. I found some similar ASM code while I was searching, but most of the threads were years old and I was hoping there was an easier way. It looks like ARRAYWRITE will do it for me.

Thanks!


steve

HenrikOlsson
- 28th March 2010, 19:39
Hi Steve,
It's definitely covered in the printed manual that came with my 2.60 upgrade. It's not in the help-files for MicroCodeStudio because they are not updated by the authour of the software (Mecanique) and that is also why it doesn't "go bold" in MCS.

Have a another look in the manual, it should be there, together with it's companion ArrayRead.

/Henrik.

Charles Linquis
- 28th March 2010, 20:13
You guys have probably already figured this out, but using ArrayWrite is the best way to send messages out multiple ports. I have many occasions where I need to send the same messages out of whatever port is available - HSEROUT, HSEROUT2, or SEROUT2. This, combined with STR can get the job done.

Byte_Butcher
- 28th March 2010, 20:32
It's definitely covered in the printed manual that came with my 2.60 upgrade. It's not in the help-files for MicroCodeStudio because they are not updated by the authour of the software (Mecanique) and that is also why it doesn't "go bold" in MCS.

Have a another look in the manual, it should be there, together with it's companion ArrayRead.


Groan... if only I could get both my brain cells to work together....

Here it is in this OTHER manual that says "2.60" on it. :o


steve