Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:56 02 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Format text for display on LCD

Author Message
Glen0
Regular Member

Joined: 12/10/2014
Location: New Zealand
Posts: 95
Posted: 09:17pm 13 Jul 2022
Copy link to clipboard 
Print this post

I have been trying to display the temperature from an MCP9700 to an SPI LCD as seen in the attached photo.
The code below shows what steps and variations I have been trying.

'Temperature from MCP9700 and ADC test
SetPin 34, Ain

Do
 A = Pin(34)-0.535
 A1 = A*100
 A2 = val (Str$ (A1, 2 ,1))
 'A3 = VAL (A2)
 'print A3
 'Print str$ (A1, 2, 1)
 'Z = Val(STR$(A,2,2))*100
 TEXT 100, 70, str$(A2), CM, 6, 1, RGB(CYAN), DBlue
 Pause 600
Loop

All is well until the displayed temp reaches exactly 20, for example, it then leaves "artifacts", (for lack of a better term,) of the previous temperature.
I can get it to work fine if I don't display any decimal but as soon as I try to display 1 decimal point I have this problem.
What am i doing wrong in my code.
Can someone please give me a snippet of code showing how to take an ADC reading and display it to 1 decimal point.
I am trying to avoid using CLS as much as possible, because the flashing is annoying.


MCP9700 test.zip

Cheers
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 09:24pm 13 Jul 2022
Copy link to clipboard 
Print this post

Try
A2$ = Str$ (A1, 2 ,1)
TEXT 100, 70, a2$, CM, 6, 1, RGB(CYAN), DBlue

VK7JH
MMedit
 
Glen0
Regular Member

Joined: 12/10/2014
Location: New Zealand
Posts: 95
Posted: 09:33pm 13 Jul 2022
Copy link to clipboard 
Print this post

Thanks Jim, perfect.

It's all about where you put your mighty $   :-))

I need to get used to strings, values, integers etc.

Turnaround on this forum is marvellous.

Cheers
Edited 2022-07-14 07:34 by Glen0
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025