Jump to content

How to print large number on LCD?


ReinerS
 Share

Recommended Posts

Hi all,

after getting my LCDs to work here is the next set of questions:

I have an external application (Hauptwerk) that sends configuration messages via sysex. One type of message sends a 28bit signed integer spread over four 7bit-values. So how to combine them into one value? My attempt is value=byte1(MSB)<<21 + byte2<<14+byte3<<7+byte4(LSB), since all bytes represent 7bit integers and the result isexpected 28bit that should work, right?

Related question: Is the int datatype in MIOS8 16bit or 32bit, and if it is 16bit, how do I define a 32bit value (if at all?).

Second question: How do I get the number printed on an LCD? The functions itoa, sprintf, etc. are not part of the framework, so I cannot figure out how to convert a number like 105206 into a string. Anyone can tell me how to do this?

Many thanks!

I really appreciate the support by this forum!

Best

Reiner

Link to comment
Share on other sites

C, I suppose cause you talk about int.

2 hours ago, ReinerS said:

My attempt is value=byte1(MSB)<<21 + byte2<<14+byte3<<7+byte4(LSB), since all bytes represent 7bit integers and the result isexpected 28bit that should work, right?

Right!
 

2 hours ago, ReinerS said:

Related question: Is the int datatype in MIOS8 16bit or 32bit, and if it is 16bit, how do I define a 32bit value (if at all?).

int is a 16bit, use long for 32bit.
 

2 hours ago, ReinerS said:

Second question: How do I get the number printed on an LCD? The functions itoa, sprintf, etc. are not part of the framework, so I cannot figure out how to convert a number like 105206 into a string. Anyone can tell me how to do this

By using the MIOS_LCD functions.
You can use MIOS_LCD_PrintBCD1(1 digit number) to MIOS_LCD_PrintBCD5(5digits number).
In your case you need 6 digits,
105206. You must decompose this number with division/modulo by 1000 for example(or, 10, 100, 10000, 100000), divided by 1000 will does 2 numbers of 3 digits where first is division, second is modulo
N = 105206 => N1=105, N2=206
with N1=N/1000
N2=N-(N1*1000) or N2 = N%1000

Then use:

MIOS_LCD_PrintBCD3(N1);
MIOS_LCD_PrintBCD3(N2);

Note: take care, cause  void MIOS_LCD_PrintBCD3(unsigned char v), it's a char then max 256, so what I said above must be adjusted to your needs, it works for 105206 but not for 300504, but I'm sure you understand the method, maybe better to do it decade by decade(digit by digit) with BCD1 ;)
 

Edited by Antichambre
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...