View previous topic :: View next topic |
Author |
Message |
daro
Joined: 15 Nov 2010 Posts: 25
|
Posted: Sat Apr 18, 2015 10:00 pm Post subject: Clear part of LCD |
|
|
Hi everybody.
I use this last library for ILI9341.
I need to clear not all bat part of lcd. "Lcd Box" Sub is too slow, so i decide to use, modify and create new sub(instruction) similar to Lcd Clear(color).
I named this sub "Lcd Clear_part.
In declaration file i add:
Code: | Declare Sub Lcd_clear_part(byval Color As Word , Byval X As Word , Byval Y As Word) |
I routines file:
Code: | Sub Lcd_clear_part(byval Color As Word , Byval X As Word , Byval Y As Word)
Local Xx As Word
Local Yy As Word
Xx = X
Yy = Y
Call Lcd_set_window(0 , 0 , Xx , Yy)
!LD XL, Y+0
!LD XH, Y+1
!LD R31, X+
!LD R30, X
Lcd_cs = 0
Lcd_dc = 1
!ldi R16, $03 '76800
Wgloop00:
!ldi R17, $A0
Wgloop11:
!ldi R18, $A0
Wgloop22:
!OUT spdr, R30
Spi_ready11:
!sbis spsr, spif
!rjmp spi_ready11
!OUT spdr, R31
Spi_ready22:
!sbis spsr, spif
!rjmp spi_ready22
!dec R18
!brne WGLOOP22
!dec R17
!brne WGLOOP11
!dec R16
!brne WGLOOP00
Lcd_cs = 1
End Sub |
And i try to use this in main program:
Code: | Call Lcd_clear_part(white , 319 , 184) |
and, "clear" is on selected X and Y area, but fill color is still Blue (shold be white)
Why it not work property?
Any suggestions? Please for help. |
|
Back to top |
|
|
aphawk
Joined: 23 Jan 2010 Posts: 168 Location: Brazil
|
Posted: Sat May 02, 2015 3:59 am Post subject: |
|
|
Hi, Daro,
Your new function don't set the color !
Try this :
Code: |
Sub Lcd_clear_part(byval Color As Word , Byval X As Word , Byval Y As Word)
Local Xx As Word
Local Yy As Word
Local Xz as Word
Xx = X
Yy = Y
Xz = Color
Call Lcd_set_window(0 , 0 , Xx , Yy)
Lcd_write_color(Xz)
!LD XL, Y+0
!LD XH, Y+1
!LD R31, X+
!LD R30, X
Lcd_cs = 0
Lcd_dc = 1
!ldi R16, $03 '76800
Wgloop00:
!ldi R17, $A0
Wgloop11:
!ldi R18, $A0
Wgloop22:
!OUT spdr, R30
Spi_ready11:
!sbis spsr, spif
!rjmp spi_ready11
!OUT spdr, R31
Spi_ready22:
!sbis spsr, spif
!rjmp spi_ready22
!dec R18
!brne WGLOOP22
!dec R17
!brne WGLOOP11
!dec R16
!brne WGLOOP00
Lcd_cs = 1
|
Paulo |
|
Back to top |
|
|
a5020k
Joined: 16 Feb 2014 Posts: 1
|
Posted: Wed May 20, 2015 7:55 am Post subject: |
|
|
Hi everybody.
Mega 128A
Last library for ILI9341.
Everything is working fine.
But it is impossible to switch the font on my Russian language. In fonts Font8x8 (Crn15x16) is coded ..
.db 0 , 0 , 0 , 15 , 10 , 10 , 0 , 0 ; Ф
.db 0 , 0 , 0 , 254 , 10 , 10 , 0 , 0 ; Х
.db 0 , 248 , 8 , 248 , 8 , 8 , 0 , 0 ; Т
.db 8 , 255 , 0 , 255 , 8 , 8 , 0 , 0 ; Ч
.db 10 , 10 , 10 , 251 , 10 , 10 , 0 , 0 ; Щ
Can be anyone tried it? |
|
Back to top |
|
|
ll
Joined: 10 Jan 2010 Posts: 16
|
Posted: Mon May 25, 2015 6:46 pm Post subject: Read-back pixels from ILI341 |
|
|
Hi all,
I use the library for ILI9341 from H.KIPNIK 2.2 v10 with the hardware Arduino Mega.
This works great for me. Thanks H.KIPNIK for this job.
Now I'm looking for a solution to read back pixels from the display ILI9341. I want to draw a line over a picture. But before that, I will save the pixels underneath this line so I can later write these pixels back again. The picture I used 240*340 (bin) comes from the sd-card .
Can anyone please help me develop this code? My aim is to make a analog meter display
on the ILI9341 display. The picture I use is a copy of an existing analog meter. The line represents the needle.
Thanks in advance |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Mon May 25, 2015 9:09 pm Post subject: |
|
|
the simplest way seems to change the LINE routine. You could add a parameter that let you save or restore data.
Then when the parameter is in save mode, save all points you replace. And afterwards, call the routine again, and make the parameter 'save' so it will use the data from the save before.
This assumes there is code in the lib to read a pixel and to set a pixel. _________________ Mark |
|
Back to top |
|
|
ll
Joined: 10 Jan 2010 Posts: 16
|
Posted: Tue May 26, 2015 7:01 pm Post subject: read pixels ILLI9341 |
|
|
Hi Mark,
Tere is no code for reading pixels in de ILLI9341 Bascom Lib .
Any suggestions? Please for help. |
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
Posted: Tue May 26, 2015 8:56 pm Post subject: |
|
|
It should be possible to read back the data from the display, even in serial mode.
Do you have a link for the library your using now? _________________ www.evertdekker.com Bascom code vault |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Tue May 26, 2015 9:01 pm Post subject: |
|
|
the lib you can find in this topic.
the pdf you can find here : http://www.newhavendisplay.com/app_notes/ILI9341.pdf
I see that the lib does not have a read function, but when you read the pdf it should not be that hard to add it. Just take in mind you need a dummy read. _________________ Mark |
|
Back to top |
|
|
ll
Joined: 10 Jan 2010 Posts: 16
|
Posted: Wed May 27, 2015 4:29 pm Post subject: |
|
|
Hi Evert,
I use the lib from this topic on ma 12, 2015 made by H. Kipnik. Version ILI 9341 2.2 V11.zip. |
|
Back to top |
|
|
ll
Joined: 10 Jan 2010 Posts: 16
|
Posted: Wed Jul 22, 2015 9:29 pm Post subject: Read MISO ILI9341 display with SPI |
|
|
Hi everybody
I try to read pixels from de ILI9341 display RAM. The hardware is connected from port B.3 to Miso display. I use the program from H.Kipnik “for display ILI9341 240*320 pixels “ version V10 date 7.9.2013.
I add some code to read the MISO (output) from the display start by “ !LDI R23, $2e” see below.
The program stopped (hang up) by “!rjmp spi_133b” .
What do I wrong , any suggestions pleas for help?
Rgb16 = Y
Lcd_dc = 0
!LDI R23, $2b
!OUT spdr, R23
Spi_11b:
!sbis spsr, spif
!rjmp spi_11b
Lcd_dc = 1
!LDS R30, {rgb16}
!LDS R31, {rgb16+1}
!OUT spdr, R31
Spi_ready7b:
!sbis spsr, spif
!rjmp spi_ready7b
!OUT spdr, R30
Spi_ready8b:
!sbis spsr, spif
!rjmp spi_ready8b
!OUT spdr, R31
Spi_ready9b:
!sbis spsr, spif
!rjmp spi_ready9b
!OUT spdr, R30
Spi_read8b:
!sbis spsr, spif
!rjmp spi_read8b
Lcd_cs = 0
Lcd_dc = 0
Tot hier deel van programma van H.Kipnik date 7.9.2013 dat werkt
!LDI R23, $2e 'commando "uitlezen geheugen" naar display
!OUT spdr, R23
Spi_122b:
!sbis spsr, spif
!rjmp spi_122b
'tot hier loopt het programma. Hierna hangt het programma zich op?
!in r23, spdr
Spi_133b:
!sbis spsr, spif
!rjmp spi_133b |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Thu Jul 23, 2015 8:10 am Post subject: Re: Read MISO ILI9341 display with SPI |
|
|
ll wrote: | Tot hier deel van programma van H.Kipnik date 7.9.2013 dat werkt |
Maybe you want to insert quotes in English? It's not a Dutch spoken forum.
Pretty obvious, where it gets stuck.
Code: | !LDI R23, $2e 'commando "uitlezen geheugen" naar display
!OUT spdr, R23
Spi_122b:
!sbis spsr, spif
!rjmp spi_122b
|
Ok so far, the construct label, sbis and rjmp waits till the serial transfer is complete.
This line clears SPIF in combination with reading SPSR (via sbsis spsr).
Data sheet: Quote: | Alternatively, the SPIF bit is cleared by first reading the SPI Status Register with SPIF set, then accessing the SPI Data Register (SPDR). |
Code: | Spi_133b:
!sbis spsr, spif
!rjmp spi_133b |
This code waits forever for SPIF, which never gets set, as no serial transfer is in progress. |
|
Back to top |
|
|
ll
Joined: 10 Jan 2010 Posts: 16
|
Posted: Thu Jul 23, 2015 7:44 pm Post subject: Reading MISO from ILI9341 |
|
|
High MWS,
O k so far i understand, and see where it gets stuck.
Bud how can i read the data from ILI9341 MISO ?
The command for read RAM is 2EH. The ILI9341 shout respond ( from MISO) with tree bytes : one dummy and two data bytes. This port (MISO) is connected to port B.3 (MISO from m2560 processor).
I assume that these bytes comes from the ILI9341 MISO?
I assume also that the SPI good configured and there are no chances to be needed?
I assume also that the ILI9341 configuration not need to chance?
Are these assume correct?
Thanks in advance |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Thu Jul 23, 2015 9:08 pm Post subject: Re: Reading MISO from ILI9341 |
|
|
ll wrote: | Bud how can i read the data from ILI9341 MISO ? |
Generally said, if the µC is the master, which it obviously is, it provides the clock to the slave. So for the master to get a byte, it has to send a byte.
Quote: | The command for read RAM is 2EH. The ILI9341 shout respond ( from MISO) with tree bytes : one dummy and two data bytes. This port (MISO) is connected to port B.3 (MISO from m2560 processor). |
I did not check the data sheet for said display, but it should suffice to send the command and then clock out dummy bytes. After each byte clocked out, SPDR holds the display controllers response.
Quote: | I assume that these bytes comes from the ILI9341 MISO? |
That's why it's called MISO, Master In Slave Out.
Quote: | I assume also that the SPI good configured and there are no chances to be needed? |
Huhh?
Quote: | I assume also that the ILI9341 configuration not need to chance? |
If you mean change, no, I would not expect that the config has to change. |
|
Back to top |
|
|
ll
Joined: 10 Jan 2010 Posts: 16
|
Posted: Wed Aug 12, 2015 6:16 pm Post subject: Reading pixels from ILI9341 it works |
|
|
Hello forum members,
Earlier I asked questions about reading pixels of the display ILI9341.
Up till now I didn't saw any solutions in BASCOM, but finally I managed to read pixels.
The first problem was the ISP interface. Apart from the MISO signal, these can, with a simple level shifter through resistors, brought back from 5V to 3V.
This is different for the MISO signal because this goes from the display (3V) to the processor (5V)
There probably is a difference in behavior/sensitivity between the MISO signal that's used by the SD card and the MISO signal of the ILI9341 display.
This MISO signal wasn't needed for writing to the display but had to be used for reading ILI9341.
The MISO signal from the ILI9341 was weaker and almost at the limit of reliable detection by the MP. This was solved by using an active level shifter type
This is the hardware adaptation
For the software I made a copy of "ILI9341_declarations.inc" and . "ILI9341_routines.inc" made by Hkipnik..
These routines were given another name "ILI9341_declarations-2.inc" and "ILI9341_routines-2.inc" .
In the "ILI9341_routines-2.inc" two routines are copied from the original with and added with a adjusted name “ Sub Lcd_set_pixel_bewaar” and “Sub Lcd_line_plus_bew “ .
In routine . “Sub Lcd_line_plus_bew “ an array is filled with the X-Y coordinates for all pixels. See program lines 483 till 485 and 504 till 506. These form a line on the screen.
In routine Lcd_set_pixel_bewaar” the old color value is retrieved from the display see program lines 658 till 895.
First send a dummy and then retrieve 3 bytes (see program lines 832 till 869).
After that these 3 bytes are converted to the 16 Bits 5R/6G/5B value. This is saved in an array. The rest of the routine is the same as the original and is repeated to draw a new line.
If you want to draw a line and save the underlying pixel data then you should use this routine. The first time this line is drawn mark it as (lijn=0). After this the routine is lijn=1. To be sure you can add lijn=1, but it's not necessary.
For the demonstration program I read a meter display (meter3.bin) of the SD card.
On top of that the line (pointer) moves in 1 degree steps from left to right vv.
The meter display is now not quite the same curve as the pointer, but it's just to show
the effect.
I made this especially for drawing a line but this solution could also be used for a circle
and such.
There is a minor fault which origins I have not been able to find.
On part of the meter display, at the top of the pointer a pixel remains with the pointers' color.
I've checked many things but have not yet found the solution.
Anyone perhaps have an idea what may cause this?
In the routines I've added many notes in Dutch. These are done solely for my own use. If you are bothered by them, feel free to remove these.
I hope someone can use this information.
Kind regards,
Loek |
|
Back to top |
|
|
ll
Joined: 10 Jan 2010 Posts: 16
|
Posted: Thu Sep 03, 2015 7:11 pm Post subject: reading pixels ILI9341 |
|
|
Dear Forum readers,
At wo Aug 12,2015 I uploaded a demonstration program about the ability of reading pixels
with the ILI 9341 display. Herewith is the improved version.
In the main program, only meant for demonstration, now the right goniometric
formula is used. The turning angle, length of pointer and turning point of the pointer are adjustable now,
The pointer now follows the correct circle shaped track.
In the subroutine LCD_set_pixel_bewaar a number of bugs have been removed (program line 885 till 920).
This solved the problem of the pointer leaving traces/discoloration behind on the red background. Also no pixels are left at the top of the pointer.
Hope this solution is of use to someone.
Best regards
Loek |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|