View previous topic :: View next topic |
Author |
Message |
AndersL
Joined: 25 Jan 2010 Posts: 92 Location: Kragerø,Norway
|
Posted: Mon Jun 20, 2011 5:24 pm Post subject: Bascom goes widescreen |
|
|
Here are som rutines for the ILI9327 TFT controller.
The display are quit cheap (36$) http://cgi.ebay.com/3-2-Width-400-240-TFT-LCD-Module-Display-TP-PCB-/190473133107
I've made a video on youtube http://www.youtube.com/watch?v=akajfj9aIxs
As seen its not very fast clocked on 12 MHz, but it could also be my coding
I was also preparing a test with Xmega128, but I had som problems with avr-dos or such.
Anyhow it was a lot faster with xmega at 32 MHz.
As stated in the files, a lot of the rutines are based on the ones Six1 and Evert made for the ILI9320 and SSD2119 controllers.
So all credit goes to them.
A question that the two gents might be able to answer is: when preparing the bmp files i've noticed that some pictures are shifted to the left
and displayed really unreadable. If i open the file in paint and adjust it a pixel or two it will display ok.
Any idea why this is the case? _________________ Anders |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Mon Jun 20, 2011 8:03 pm Post subject: |
|
|
well done. thanks for the video.
for avr-dos , if using the soft mode spi, change this in the driver lib:
_mmc_send_command:
*BASIC: Reset Mmc_cs ' reset Cs
rcall _Byte2SPI ; Send CMD
mov r16,r3 ; send MSB first ##was R23
and...
_shift_mmc:
clr r20
ld r21,x+ ;LSB
ld r22,x+
ld r3,x+ ; was R23 _________________ Mark |
|
Back to top |
|
|
bzijlstra
Joined: 30 Dec 2004 Posts: 1179 Location: Tilburg - Netherlands
|
Posted: Mon Jun 20, 2011 8:32 pm Post subject: ILI9325... |
|
|
You have beat me on the 16-bit code...
For the ILI9325 I have made this and indeed it is working on the GREAT routines from SIX1 and Evert Dekker.
This is 8 bit by the way...
Code: |
'-------------------------------------------------------------------------------
' ILI9325_select_reg Select an index register
'-------------------------------------------------------------------------------
Sub Ili9325_select_reg(byval Index As Byte )
Cs_disp = 0
Rs_disp = 0
Data_disp = 0
nop
Wr_disp = 0
nop
Wr_disp = 1
Data_disp = Index
nop
Wr_disp = 0
nop
Wr_disp = 1
Cs_disp = 1
End Sub
'-------------------------------------------------------------------------------
' Ili9325_write_data Write 16 Bit Data to Display
'-------------------------------------------------------------------------------
Sub Ili9325_write_data(byref Daten As Word)
Cs_disp = 0
Rs_disp = 1
Data_disp = High(daten)
nop
Wr_disp = 0
nop
Wr_disp = 1
Data_disp = Low(daten)
nop
Wr_disp = 0
nop
Wr_disp = 1
Cs_disp = 1
End Sub
'-------------------------------------------------------------------------------
' Ili9325_write_reg Write 16 Bit Data to Index Register
'-------------------------------------------------------------------------------
Sub Ili9325_write_reg(byval Index As Byte , Daten As Word)
Cs_disp = 0
Rs_disp = 0
Data_disp = &H0 'VH
Nop
Wr_disp = 0
nop
Wr_disp = 1
Data_disp = Index 'VL
Nop
Wr_disp = 0
nop
Wr_disp = 1
Rs_disp = 1
Data_disp = High(daten) 'VH
Nop
Wr_disp = 0
nop
Wr_disp = 1
Data_disp = Low(daten) 'VL
Nop
Wr_disp = 0
nop
Wr_disp = 1
Cs_disp = 1
End Sub
|
I have to use the NOP after I fill the Data_disp and between Wr_disp = 0 and Wr_disp = 1.
Am using the Arduio Mega (atmega1280) shield ITDB02 v1.1 with both 2.4 and 3.2 inch display. 320 x 240.
ITDB02 shield can be found at www.arduinosolutions.com and on www.iteadstudio.com.
What about 11,25 euros for this display, with touchscreen and SD-card slot. On Ebay...
Have fun
Ben Zijlstra |
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
Posted: Mon Jun 20, 2011 9:40 pm Post subject: |
|
|
Hi Anders,
Nice to see your video.
Great job, nice big screen.
My next demo will work on an xmega256 @32mhz with pll pumped up to 40mhz when needed to show bmp or big bgf.
@everybody
I'm looking for a even bigger screen, lets say around 5" color with 320x240 or 400x240, but not much more pixels. And with build in controller like SED or ILI.
It should also not be to expensive to get it affordable for everybody. _________________ www.evertdekker.com Bascom code vault |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Tue Jun 21, 2011 12:22 am Post subject: |
|
|
Very nice, even better for me as I have already got one on the way. |
|
Back to top |
|
|
six1
Joined: 27 Feb 2009 Posts: 553
|
Posted: Tue Jun 21, 2011 3:48 pm Post subject: |
|
|
Hi Evert,
Quote: | @everybody
I'm looking for a even bigger screen, lets say around 5" color with 320x240 or 400x240, but not much more pixels. And with build in controller like SED or ILI.
It should also not be to expensive to get it affordable for everybody. |
and that's the Problem, as you already know...
that is 13cm with 800x400Px. Because of modern Multimedia resulutions i bet, you never will get a Display this size with 320x240.
go make a video board with Ben's displays for 11$
best, Michael _________________ For technical reasons, the signature is on the back of this message. |
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
|
Back to top |
|
|
bzijlstra
Joined: 30 Dec 2004 Posts: 1179 Location: Tilburg - Netherlands
|
Posted: Sun Jul 03, 2011 9:44 am Post subject: Smaller code, turing picture... |
|
|
Again, thanks for your code
For displaying the BGC I have reduced the code
Your code:
Code: | Call Ili9327_setxy_frame(tempx , Tempy , Tempx2 , Tempy)
Do
Read Pixel 'Read the value for the pixel
If Pixel = &HAA Then 'BGC file is lre coded &HAA represents this, the byte after &HAA is the number of times that the byte before &HAA wil be repeated
Read Repeat 'Byte after &HAA contains the number of times to repeat
Repeat = Repeat - 1
For L = 1 To Repeat 'Loop the repeat
Call Ili9327_write_dataw(prevpixel) 'Write the pixel data to the display
Decr Imagesize 'Decrease the bytes still to be processed
Incr Xpos 'Incr the xpos
If Xpos > Xsize Then 'If the xpos is larger then xsize of the image start at a new y line
Xpos = 1 'and set the xpos pos back to the first position on the new line
Incr Ypos 'Start a new y line
Tempx = Xpos + Xoffset 'Pixel position is the image postion + the offset
Tempy = Ypos + Yoffset
Call Ili9327_setxy_frame(tempx , Tempy , Tempx2 , Tempy)
'Print "tempx,tempy,tempx2,tempy " ; Tempx ; " " ; Tempy ; " " ; Tempx2 ; " " ; Tempy
End If
Next L 'Next repeat loop
Else 'It's a regular byte, not LRE encoded
Pixelword = Rgb16(pixel) 'Convert the 8bit pixel to 16bit pixel
Call Ili9327_write_dataw(pixelword) 'Write the pixel data to the display
Prevpixel = Pixelword 'Store the pixel in a temp word, maybe we need it if the next byte is &HAA
Decr Imagesize 'Decrease the bytes still to be processed
Incr Xpos
If Xpos > Xsize Then 'If the xpos is larger then xsize of the image start at a new y line
Xpos = 1 'and set the xpos pos back to the first position on the new line
Incr Ypos
Tempx = Xpos + Xoffset 'Pixel position is the image postion + the offset
Tempy = Ypos + Yoffset
Call Ili9327_setxy_frame(tempx , Tempy , Tempx2 , Tempy) 'Start a new y line, send the xy position to the display
'Print "tempx,tempy,tempx2,tempy " ; Tempx ; " " ; Tempy ; " " ; Tempx2 ; " " ; Tempy
End If
End If
Loop Until Imagesize = 0 'Do until all bytes are processed
|
in to this:
Code: | Call Ili9325_set_window(xoffset , Yoffset , X1size , Y1size)
Do
Read Pixel 'Read the value for the pixel
If Pixel = &HAA Then 'BGC file is rle coded &HAA represents this, the byte after &HAA is the number of times that the byte before &HAA wil be repeated
Read Repeat 'Byte after &HAA contains the number of times to repeat
Repeat = Repeat - 1
For L = 1 To Repeat 'Loop the repeat
Call Ili9325_write_data(prevpixel) 'Write the pixel data to the display
Decr Imagesize 'Decrease the bytes still to be processed
Next L 'Next repeat loop
Else 'It's a regular byte, not LRE encoded
Pixelword = Rgb16(pixel) 'Convert the 8bit pixel to 16bit pixel
Call Ili9325_write_data(pixelword) 'Write the pixel data to the display
Prevpixel = Pixelword 'Store the pixel in a temp word, maybe we need it if the next byte is &HAA
Decr Imagesize 'Decrease the bytes still to be processed
End If
Loop Until Imagesize = 0 'Do until all bytes are processed
|
And this is the way you can turn your picture:
Code: | 'Call Ili9325_write_reg(entry_mode , &B0001000000_01_0_000 ) 'bottom photo under, mirroredl
'Call Ili9325_write_reg(entry_mode , &B0001000000_10_0_000 ) 'bottom photo up, mirrored
'Call Ili9325_write_reg(entry_mode , &B0001000000_11_0_000 ) 'botton photo up, normal
Call Ili9325_write_reg(entry_mode , &B0001000000_00_0_000 ) 'bottom photo under, normal
'
'Call Ili9325_write_reg(entry_mode , &B0001000000_01_1_000 ) 'bottom photo to the left, mirrored
'Call Ili9325_write_reg(entry_mode , &B0001000000_10_1_000 ) 'bottom photo to the right, mirrored
'Call Ili9325_write_reg(entry_mode , &B0001000000_11_1_000 ) 'bottom photo to the left, normal
'Call Ili9325_write_reg(entry_mode , &B0001000000_00_1_000 ) 'bottom photo to the right, normal
|
Tried the 8-bit and 16-bit mode. 8-bit working perfectly, with 16-bit I get stripes while writing. Has something to do with timing.
Have fun
Ben Zijlstra |
|
Back to top |
|
|
freddie
Joined: 26 Sep 2010 Posts: 68
|
Posted: Wed Dec 12, 2012 7:26 pm Post subject: |
|
|
Hello AndersL!
Can you give a connection circuit between uC and LCD. Thank you) |
|
Back to top |
|
|
bzijlstra
Joined: 30 Dec 2004 Posts: 1179 Location: Tilburg - Netherlands
|
Posted: Wed Nov 09, 2016 1:44 am Post subject: ili9327_clrscr faster then blinking your eye... |
|
|
AndersL
Changed the ili9327_clrscr routine in your include file
Faster then you can blink your eye...
Code: | Sub Ili9327_clrscr(byval Color As Word)
Local I As Long
Local Help As Long
If Orient = 1 Then 'Portrait
Call Ili9327_setxy(0 , 0 , 239 , Disp_y_size)
Else
Call Ili9327_setxy(0 , 0 , Disp_y_size , 239)
End If
Set Rs_disp
Reset Cs_disp
' Set Rd_disp
Data_disp_hi = High(color)
Data_disp_lo = Low(color)
Help = 240 * 400
Help = Help / 16
For I = 0 To Help
Reset Wr_disp
Set Wr_disp
Reset Wr_disp
Set Wr_disp
Reset Wr_disp
Set Wr_disp
Reset Wr_disp
Set Wr_disp
Reset Wr_disp
Set Wr_disp
Reset Wr_disp
Set Wr_disp
Reset Wr_disp
Set Wr_disp
Reset Wr_disp
Set Wr_disp
Reset Wr_disp
Set Wr_disp
Reset Wr_disp
Set Wr_disp
Reset Wr_disp
Set Wr_disp
Reset Wr_disp
Set Wr_disp
Reset Wr_disp
Set Wr_disp
Reset Wr_disp
Set Wr_disp
Reset Wr_disp
Set Wr_disp
Reset Wr_disp
Set Wr_disp
Next I
Set Cs_disp
End Sub |
Check loop unrolling: (wikipedia)
Loop unrolling, also known as loop unwinding, is a loop transformation technique that attempts to optimize a program's execution speed at the expense of its binary size, which is an approach known as the space-time tradeoff. The transformation can be undertaken manually by the programmer or by an optimizing compiler.
Have fun
Ben Zijlstra |
|
Back to top |
|
|
AndersL
Joined: 25 Jan 2010 Posts: 92 Location: Kragerø,Norway
|
Posted: Mon Nov 14, 2016 3:21 pm Post subject: |
|
|
Very nice Ben
I’ll have a closer look at loop unrolling. _________________ Anders |
|
Back to top |
|
|
bzijlstra
Joined: 30 Dec 2004 Posts: 1179 Location: Tilburg - Netherlands
|
Posted: Mon Nov 21, 2016 5:49 pm Post subject: Superfast lines with Bresenham Line Algorithm |
|
|
Made by a fellow Bascom-AVR user...
Code: | ' Bresenham Line Algorithm http://www.edepot.com/linebresenham.html
'
Sub Ili9327_line (byval X1 As Word , Byval Y1 As Word , Byval X2 As Word , Byval Y2 As Word , Byval Color_line As Word)
Local X As Word
Local Y As Word
Local Dx As Word
Local Dy As Word
Local Incx As Integer
Local Incy As Integer
Local Balance As Integer
If X2 >= X1 Then
Dx = X2 - X1
Incx = 1
Else
Dx = X1 - X2
Incx = -1
End If
If Y2 >= Y1 Then
Dy = Y2 - Y1
Incy = 1
Else
Dy = Y1 - Y2
Incy = -1
End If
X = X1
Y = Y1
If Dx >= Dy Then
Shift Dy , Left , 1
Balance = Dy - Dx
Shift Dx , Left , 1
While X <> X2
Call Ili9327_set_pixel (x , Y , Color_line )
If Balance >= 0 Then
Y = Y + Incy
Balance = Balance - Dx
End If
Balance = Balance + Dy
X = X + Incx
Wend
Call Ili9327_set_pixel (x , Y , Color_line )
Else
Shift Dx , Left , 1
Balance = Dx - Dy
Shift Dy , Left , 1
While Y <> Y2
Call Ili9327_set_pixel (x , Y , Color_line )
If Balance >= 0 Then
X = X + Incx
Balance = Balance - Dy
End If
Balance = Balance + Dx
Y = Y + Incy
Wend
Call Ili9327_set_pixel (x , Y , Color_line )
End If
End Sub
|
Still more to come...
Have fun
Ben Zijlstra |
|
Back to top |
|
|
bzijlstra
Joined: 30 Dec 2004 Posts: 1179 Location: Tilburg - Netherlands
|
Posted: Mon Nov 21, 2016 6:11 pm Post subject: Fast circle... |
|
|
Same source... circle
'Xc = center X
'Yc = center Y
'R = radius
'Color = color
Code: | Sub Ili9327_circle(byval Xc As Word , Byval Yc As Word , Byval R As Word , Byval Color As Word)
Local X As Word : X = R
Local Y As Word : Y = 0
Local Cd2 As Integer : Cd2 = 0
Local Tmp As Word
Local Tmp2 As Word
If R = 0 Then
Exit Sub
End If
Tmp = Xc - R
Call Ili9327_set_pixel(tmp , Yc , Color)
Tmp = Xc + R
Call Ili9327_set_pixel(tmp , Yc , Color)
Tmp = Yc - R
Call Ili9327_set_pixel(xc , Tmp , Color)
Tmp = Yc + R
Call Ili9327_set_pixel(xc , Tmp , Color)
While X > Y
X = X - 1
Y = Y + 1
Cd2 = Cd2 - X
Cd2 = Cd2 + Y
If Cd2 < 0 Then
Cd2 = Cd2 + X
X = X + 1
End If
Tmp = Xc - X
Tmp2 = Yc - Y
Call Ili9327_set_pixel(tmp , Tmp2 , Color)
Tmp = Xc - Y
Tmp2 = Yc - X
Call Ili9327_set_pixel(tmp , Tmp2 , Color)
Tmp = Xc + Y
Tmp2 = Yc - X
Call Ili9327_set_pixel(tmp , Tmp2 , Color)
Tmp = Xc + X
Tmp2 = Yc - Y
Call Ili9327_set_pixel(tmp , Tmp2 , Color)
Tmp = Xc - X
Tmp2 = Yc + Y
Call Ili9327_set_pixel(tmp , Tmp2 , Color)
Tmp = Xc - Y
Tmp2 = Yc + X
Call Ili9327_set_pixel(tmp , Tmp2 , Color)
Tmp = Xc + Y
Tmp2 = Yc + X
Call Ili9327_set_pixel(tmp , Tmp2 , Color)
Tmp = Xc + X
Tmp2 = Yc + Y
Call Ili9327_set_pixel(tmp , Tmp2 , Color)
Wend
End Sub |
Have fun
Ben Zijlstra |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Tue Nov 22, 2016 3:37 pm Post subject: |
|
|
thanks for sharing. Yes choosing a good algorithm , and coding it clever can make all the difference. _________________ Mark |
|
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
|
|