Axe033 I2c Syntax

DStewert

New Member
Hello. i just got the axe033 lcd with clock option. Iam outputting text using the syntax provided in axe033 manual with no problems. How do i or what is the syntax to output numeric data or variables using I2C ? thanks
 

hippy

Technical Support
Staff member
The best mechanism is to use BINTOASCII to split a number into separate printable digits, then send the digits separately and sequentially to the LCD.
 

DStewert

New Member
I used the following lines:

bintoascii b1,b2,b3,b4

writei2c 0,("temp=",B2,B3,B4 ,255) ' output temp data

Works nicely. Thanks
 

westaust55

Moderator
wrt your original question, - it depends upon:
- what the source value is
-what you are trying to achieve.

BINTOASCII will take a value such as 123 and convert it into three separate ASCII code values so 123 becomes “1”, “2” and “3” each in a separate variable as you have found.

Then if for instance you are taking the BCD code from a DS1307 real time clock you can use BCDTOASCII which takes a value (eg 45) and splits out the two digits “4” and “5” into separate variables.

At the primitive level, and basically what the BINTOASCII does, if you have a single digit 0 to 9 then you can add 48 ($30) to convert it to an ASCII code for that value.

EDIT: following not valid for i2c comms
Other formatting options include placing a hash symbol (#) in front of a variable name
So if b0 = 123 then you can use #b0
Writei2c 0, (“temp=”,#b0, 255)

an advantage of the hash symbol (#) method is that it does not require the use of additional variables as an intermediate step.
 
Last edited:

hippy

Technical Support
Staff member
Writei2c 0, ("temp=",#b0, 255)

The # modifier is only available with SEROUT / SERTXD, not with WRITEI2C. This won't work.
 

westaust55

Moderator
Noted wrt i2c comms. :eek:

# will also work with hserout.

Will edit above post so anyone reading the earlier post in isolation does not get confused.
 
Last edited:
Top