Hi,
One way could be to use the ArrayWrite command, something like:
/Henrik.Code:MSG VAR BYTE[4] RawT VAR BYTE RawT = 754 ARRAYWRITE MSG, [DEC RawT]
Hi,
One way could be to use the ArrayWrite command, something like:
/Henrik.Code:MSG VAR BYTE[4] RawT VAR BYTE RawT = 754 ARRAYWRITE MSG, [DEC RawT]
Thank you, Henrik.
I love when the answer is shorter than the question!
To be clear then, it appears that DEC is not a command of itself, but a parameter of some other display functions; it is only valid in an output string to an LCD or other output device (ie serial port) or construct (array-obviously).
I hope it is not too much trouble for any who follow this thread to correct my interpretation as well as to clarify one more point? Can an entry point be specified, as ARRAYWRITE MSG[14], [DEC RawT] so that the variable may be positioned in a larger array? I saw little on this when searching
It is possible to specify an entrypoint, so that (for example) the string "Temperature = XXX degrees" can be dynamically updated with Arraywrite ARRAYNAME[entrypoint] = [DEC variable]
Last edited by Amoque; - 25th March 2012 at 19:44.
Hi,
That's correct. DEC is not a command by itself, it's what the manual calls a modifier among others (BIN, HEX etc).
I've never tried it but I'm pretty sure you can start anywhere in the array in the way you show.
/Henrik.
Hello all,
this is an old post. I'm not sure if my question fits right to here.
I have a temperature values and i would like to send them to a display from 4D Systems.
At the moment i was using the serial SPE commands as 4D Systems calls it, and they have exactly the command to send those variables.
Then i tried their "new" Visi Genie enviroment, which allows you to create "forms" and add any image, button etc.
I have fniished the easy task inside the Visi Genie and i'm in front of a problem that i need to transform the variable to string.
As from 4D Systems:
It is the first time i had to do a task with Checksum and found it interesting way by XORing all the bytes. In a very small code i tryied it worked, as i sent based on 4D Systems the command to change the constrast and it worked.Visie-Genie writes to pre-defined objects so in this case it is a pre-defined string object so all we have to do is convert what we need to send to a string, calculate a checksum and send. This is where Genie differs from Serial as in the Serial mode you are sending a serial command to the display which is translated to a command to do a supported function on the display.
Now i'm trying to see the way to convert var to string. I have read the manual written in 2013Code:command var byte constrast var byte CS var byte ' -----------------------------------------------------------------------------| ' [ LCD Initialization ] | '------------------------------------------------------------------------------| ' FIRST TIME BOOTUP: We give plenty of time for tbe LCD ' lcdinit: pause 2000 command = $04 contrast = $06 gosub checksum hserout [command,contrast,CS] hserin [wait(6)] pause 100 high green return '------------------------------------------------------------------------------| ' CHECKSUM | '------------------------------------------------------------------------------| checksum: cs = 0 cs = cs ^command cs = cs ^ contrast return
Is that the right way? May i have your help please?"A numeric value preceded by a pound sign ( # ) will send the ASCII representation of its decimal value, up to 65535. For example, if W0 = 123, then #W0 (or #123) will send "1", "2", "3"."
Or use DEC modifier like DEC k. If k=5, DEC k will send out the "5".
With DEC you can also specify how many digits you will send. E.g. DEC3 will send 3 digit of the variable with the appropriate leading zeros in this case to fit the number of digits requested.
If k=15 then DEC3 k will send "0", "1", "5"
Ioannis
Last edited by Ioannis; - 28th September 2020 at 09:57.
Thanks so much Ioanni,
will try it out.
Dear all,
i have some problem regarding the conversion of a variable to string.
I have the following code.
Code:'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' VAR for IR to LCD ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' IRCS var byte ' this is the checksum for the IR required in external display command TEMP var word ' this is the word variable for TEMP temperature var word ' for result and output to lcd TEMPIR var word ' set a variable tempir Remainder var word ' Get the remainder = tempir//50 '------------------------------------------------------------------------------* ' Measure IR object temp sent to uLCD * '------------------------------------------------------------------------------* object: reg = $07 ' based on the datasheet $07 is the object's temp addr = %10110100 ' $B4 binary value: %10110100 i2cwrite SDA, scl, addr ' send write command, shift the address B4, 8 bits where LSB is W = 0 i2cwrite sda, scl, reg ' register is $07 addr = %10110101 ' $B5 Binary value: %10110101 i2cwrite sda, scl, addr ' sends read command, shift the address B5, 8 bits where LSB is R = 1, clock idles low i2cread SDA, SCL,addr,reg,[temp.lowbyte,temp.highbyte] ' reg = $07 tempir = (temp.highbyte << 8) + temp.lowbyte temperature = tempir/50 ' based on the manual we need to divide by 50 or 0.02 temperature = temperature - 273 ' subtract 273 for Degree in C,actually is 273,15 remainder = (tempir*2)//100 ' multiply x 2 and get the remainder //100 pause 100 gosub display return '------------------------------------------------------------------------------* ' IR Display 1 the parameters * '------------------------------------------------------------------------------* display: ' IR TEMP hserout2 [$73,$00,$02,$12,$00,$ff,"IR TEMP:",00] Hserin2 timeout,error,[wait(6)] hserout2 [$73,$08,$02,$12,$F8,$00,dec2 temperature,".",dec2 remainder,"*C",00] 'this one works on display 1 which doesnt require CS Hserin2 timeout,error,[wait(6)] gosub checksum2 hserout [$01,$0F,$00,temperature,remainder,IRCS] ' this one doent work, i get random numbers on the display. Hserin timeout,error,[wait(6)] return '------------------------------------------------------------------------------| ' CHECKSUM IR | '------------------------------------------------------------------------------| checksum2: IRCS = 0 IRCS = $01 ^ $0F ^ $00 ^ temperature IRCS = IRCS ^ remainder return
One i do the CS calculation, and returning from checksum2 the following is not working as expectred.
even if i try the following.Code:hserout [$01,$0F,$00,temperature,remainder,IRCS] ' this one doent work, i get random numbers on the display. Hserin timeout,error,[wait(6)] return
Is there a way to convert the variable to string ourside from a preset command like the HSEROUT?Code:hserout [$01,$0F,$00,dec2 temperature,dec remainder,IRCS] ' this one doent work, i get random numbers on the display. Hserin timeout,error,[wait(6)] return
for example is there a way to make something like this in PBP?
temperature = #temperature.
i have had three or four people say i'm not a good teacher,
i'm not surprised since i never have been or ever aspired to be one
so what do think of my new signature ?
Warning I'm not a teacher , one on one Tuition with flowery prose like a gushing embroilment is not my style
Last edited by richard; - 21st December 2021 at 09:11. Reason: if i can get it to take
Warning I'm not a teacher
Richard,
i may need to apologize for my behaviour as well. I do not expect that from you.
Do what you know better to do, in this particular field. Everyone has its bad and good days. We are all in the same boat.
You never know one day, i may be some how useful for you.....
Take care and try to smile.
Bookmarks