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.
Can anybody tell me what does 240RGB x 320 dots mean?
Also How can I work out a location on the LCD?
That's all folks Hope it's not too difficult.
Thanks
Mike
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2934
Posted: 10:57pm 11 Mar 2016
Copy link to clipboard
Print this post
Hi Mike,
The 240x320 is referring to the pixels (dots) that make up the display.
If the TFT screen is 'Portrait' then there are 240 dots/pixels wide, by 320 dots/pixels high.
If in 'landscape' mode, then 320 dots wide, and 240 dots high.
Anything you 'draw' on the screen is given a x & y co-ordinate. The top left hand corner is 0,0.
For Landscape mode, the bottom right corner is 319,239. Note it is not 320,240 as the 'pixel reference coordinate starts at 0; not 1.
For portrait mode the bottom right corner is 239,319.
All text you 'write' to the screen with the TEXT command needs an x & y coordinate. ALSO another 'formatting parameter is given (such as CM) to define exactly where the text is printed.Refer to user manual for full details; but for now just liken it to 'formatting' of text in a word-processor (left, right, centre, top, middle, bottom justified).
All the 'graphical' commands (BOX, CIRCLE, LINE, PIXEL etc) also need a X & Y coordinate.
If you have a TFT connected to a uM then I suggest just working through the various commands detailed in the User Manual (typing them at the command prompt to see the instant result).
Hope this helps a bit.
WWEdited by WhiteWizzard 2016-03-13
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10250
Posted: 10:59pm 11 Mar 2016
Copy link to clipboard
Print this post
Think of the display as an x-y plot with x scaled from 0-239 and y from 0-319 (in portrait mode) or x scaled from 0-319 and y from 0-239 (in landscape mode)
Lets assume landscape (OPTION LCDPANEL ILI9341,L,....) i.e. 320x240
So to put a single dot in the middle of the screen we could use
PIXEL 160,120
to write a string centred in the screen we could go
TEXT 160,120,"MyString",CM
Hope this makes sense
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2934
Posted: 11:07pm 11 Mar 2016
Copy link to clipboard
Print this post
Taking it to the 'next level' there are two 'constants' in MMBasic called MM.HRES and MM.VRES.
When you configure the ILI9341, you have to declare portrait or landscape mode (or the reverse of either).
To position something in the centre of the screen, you can refer to X and Y with numbers, as explained in matherp's post above) OR you could use MM.HRES and MM.VRES.
So with 'any' screen dots size, to position something in the centre of the screen, you would use:
TEXT MM.HRES/2, MM.VRES/2,"MyString",CM
since MM.HRES holds the number of pixels across the width (horizontal), and MM.VRES is the number of pixels high (vertical).
You will see Geoff refers to screen locations using these two inbuilt 'constants' a lot in the User Manual (and other code examples that people post here on TBS).
Thanks so much for the simple answer and also the prompt replies.
I did understand the MM.HRES & MM.VRES by reading the manual, but couldn't get where the origins were. The answers above make my task so much simpler.
Thanks again
Mike
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209
Posted: 12:05am 12 Mar 2016
Copy link to clipboard
Print this post
Sometimes that resolution is given as 720x320.
Note the missing "RGB" part.
In that case you wil need to divide the first number by three if it is a color screen.
Each pixel is actually made up of three subpixels and some manufacturers use the number of subpixels for resolution. Technically correct as you can address each subpixel, but practical it is not and can be a source of confusion.