News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

ILI9341

Started by John Drew, Apr 26, 2021, 12:15 AM

Previous topic - Next topic

John Drew

Using Flosi's ILI9341 code I'm having trouble blanking out previous items on a line using spaces after the new string. It is not practical to clear the whole screen just to update one line.
Adding a string of spaces is difficult because spaces aren't the same width as characters. Additionally my strings are of varying lengths and it has become guess work and many trials and mostly errors!
Maybe I could first print a BOX that occupies the line and set all colours to black. Another solution maybe to get into the fonts and change the width of a space??

Has anyone come across this problem and if so solved it?
John

PS it's a display in portrait mode and 320*240

TimB


The problem of clearing lines with spaces or even clearing the left over text when writing number ex 1.1 is smaller than 8.8 is not new. I encountered it it with my PPrint routines many years ago.

So I wrote a macro called PrintBlankTo to solve it. You can do the same

Look through the print routine to find the var used to store the current x location. Make a loop to print a " " and then check the x variable until it is >= to your required location.

top204

Because of proportional fonts, a space is not the same size as other characters, so clearing with spaces does not work.

What I normally do is create a window that is the size of the text to clear, then simply fill the window with the required paper colour. With the libraries I create for LCDs that have a window mechanism, I always create a Window creating procedure, so all it needs is the start X and Y, and end X and Y. Then a simple loop for the amount of pixels in the window, and write data to the LCD.

John Drew

Thanks Tim and Les,
Two good ideas to follow up. A combination of the two may be an option. If I can read the end of a print and then fill the remainder with a window.
Otherwise I'll just blank a portion of the screen (pseudo line) using the window idea and then print the string into the window. A procedure will do it nicely.
John

SCV

Another idea to consider...
If you know what the text is beforehand, you can re-write the same text with the ink colour set to the paper colour!

Tim.

John Drew

That's an interesting idea Tim. Some lateral thinking 😁
As the strings are built just before use I could copy the previous one and then do as you suggest. Unfortunately i have many strings and saved to different areas of the screen, so I'd end up with many copies . Will have to see if that was practical. Now I have three ideas. Some experiments coming up.
John

flosigud

When this was my problem I defined left and right margins and wrote a routine that filled the line to end.

John Drew

Thanks Flosi,
Is there a variable in your code that tracks the last position written?
I can then write a procedure that takes line and last position to empty that part of the line.
John

flosigud

Yes, I think so. I used it in a menu program I once posted. It used encoder's for input.

I am sitting outside the Danish Pub and the temperature I a wooping 9 degrees.

John Drew

Wow, that's a bit cold Flosi. Beautiful here today, sunshine and 25C, Autumn is our best time of the year. Winter is around the corner though.
On the graphic front I'm going to create a procedure and send it a line number then blank the rest of the line based on the pixel count.
John

flosigud

That is spring in Iceland. My wife who one went Australia on a meeting said that Australian winter was like Icelandic summer slightly warmer, no leaves on trees and no bird singing.

The variable I used was wXstart. It is incremented at the end of Sub Print_Chr and marks he start of the area you need to clear. wXstart is used along with wYstart to position anything that needs to be printed on screen. Sub Print_Chr also leaves bCOLS with the width of the character.

John Drew

Thanks Flosi, that info is exactly what I need.

Regarding the trees, yes there are many imported European trees in our towns and they lose their leaves about now but most Australian trees do not.

The gum trees (Eucalypts) are not deciduous but people rarely plant them in towns as they grow so large and can drop large limbs on houses, cars or people. On camping trips it's not a good idea to put a tent under a gum. Especially sugar gums that frequently drop large branches on frosty mornings.
Best wishes
John

John Drew

#12
OK, thanks all. Here's my little routine to blank the rest of a line. Can't be much simpler. Thanks to all who tossed in ideas. My ILI9341 display is in portrait mode so 240*320 pixels.
John

proc MakeClear()                          'call this to black out the rest of the line
dim Width as word
     width = 240-wxstart
     wink = black
     wcolor = black
     wpaper = black
     XBlock(wxstart,wystart,width,24)     'my lines are 24 pixels high
     wink = white                         'my characters are white
EndProc

John Drew

Yes, there is code available for the ILI9341. Flosi is the main developer. It takes some knowledge to get it going but once done it works well.
John

John Drew

Marco,
I have a zip of the files from Flosi if that is helpful.
John

John Drew

Ok Marco, I'll send it tomorrow.  It's 23:30 here and time for some shut eye.
John

John Drew

Great news Marco. All credit due to Les and Flosi.
Best wishes from Australia
John

Pepe

could share the code

John Drew

I have put the code on the WIKI in example code/graphic lcd section.
All credit to Flosi and Les for the includes and how to make it work.
John

Pepe

Thank you John, Les and Flosi.