Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

ILI9341 with SW/HW SPI, 8/16 Bit parallel mode
Goto page Previous  1, 2, 3, 4, 5, 6  Next
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here
View previous topic :: View next topic  
Author Message
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 1136

poland.gif
PostPosted: Sun Nov 27, 2016 8:25 pm    Post subject: Reply with quote

Brackets was the obvious thing but now I think nobody have crystal magic ball, and only one thing I know You should pass a Byte variable.
"Sub Lcd_set_rotation(byval Rotation As Byte) " so hit and hold Shift button and hover Pixels variable to check if this is a byte Very Happy
Back to top
View user's profile Visit poster's website
Joakim

Bascom Member



Joined: 09 Jan 2007
Posts: 38

sweden.gif
PostPosted: Wed Feb 22, 2017 8:47 am    Post subject: Re: ILI9341 with SW/HW SPI, 8/16 Bit parallel mode Reply with quote

Netzman wrote:
Hi,

- SPI (Soft-/Hardware), 8/16 Bit parallel interface
- ATMega/ATXmega
- Fast assembler-optimized routines
- Backlight control (Digital IO or PWM)
- Screen rotation (4 directions), Standby, Color inversion
- Basic graphics, pictures (fast SRAM-pictures), fixed-font text

Demo video (with touch screen)

More info & download: ILI9341 Library 1.0 (Project from the video is included)

br


Excellent work Netzman, saved me a lot of time.
Had one issue with Lcd_text, i could not get it to pass a string. Had to change in the sub, string to "byref" instead of "byval".
Original:
Code:
Sub Lcd_text(Byval S As String , Byval Xoffset As Word , Byval Yoffset As Word , Byval Forecolor As Word , Byval Backcolor As Word)

Now:
Code:
Sub Lcd_text(byref S As String , Byval Xoffset As Word , Byval Yoffset As Word , Byval Forecolor As Word , Byval Backcolor As Word)


Not sure if i missed something else but i could not print a string (only constants) on to the LCD with the original library.
And also.. it wont compile on 2.0.8.0 until all assembler is marked with an "!" before the mnemos. I've fixed that but it's also rewritten for my HW so no real use in sharing it.

regards and thanks
/Joakim
Back to top
View user's profile
Netzman

Bascom Expert



Joined: 25 Nov 2005
Posts: 132
Location: Graz

austria.gif
PostPosted: Sun Mar 26, 2017 5:41 pm    Post subject: Reply with quote

Hello Joakim,

I am currently updating and bugfixing the library, but I can't verify any problems with using Byval instead of Byref for the text routines.
Byval has the advantage to pass string constants as well as variables to the text routine, which creates a local string variable with the required length in the frame space to hold the value:
Code:
Lcd_text "Hello World" , 0 , 0 , Color_white , Color_black

Dim Mystring As String * 12
Mystring = "Hello World"
Lcd_text Mystring , 0 , 0 , Color_white , Color_black
 

While using Byref, only string variables are allowed as parameter.

Have you already tried increasing your (frame) stack sizes?

Best regards

_________________
LCD Menu | Proportional Fonts
Back to top
View user's profile Visit poster's website
mototest2

Bascom Member



Joined: 24 Dec 2006
Posts: 53

poland.gif
PostPosted: Thu Aug 10, 2017 5:50 pm    Post subject: Problem with fonts Xmega128 Reply with quote

Hi

I use library from wiki with xmega128a1
http://mat.midlight.eu/index.php/ILI9341_Library#Text

but here is only one font size (very small 8x8) , have anyone example how use more fonts ?

I tried change listing as below (from other example) , but don't display any text on LCD...

Code:

Sub Lcd_text(byval S As String , Byval Xoffset As Word , Byval Yoffset As Word , Byval Fontset As Byte , Byval Forecolor As Word , Byval Backcolor As Word)
   Local A As Word , Pixels As Byte , Count As Byte , Carcount As Byte , Temp As Word
   Local Row As Byte , Block As Byte , Byteseach As Byte , Blocksize As Byte , Dummy As Byte
   Local Colums As Byte , Columcount As Byte , Rowcount As Byte , Stringsize As Byte
   Local Pixelcount As Byte , Offset As Word
   'Local Pointer As Word
   Local X As Word , Y As Word
   Local Tempstring As String * 1
    Local Xpos As Word , Ypos As Word , Pixel As Word

   Stringsize = Len(s) - 1                                                      'Size of the text string -1 because we must start with 0


   Select Case Fontset
      Case 1 :
         Block = Lookup(0 , Color8x8)                       'Add or remove here fontset's that you need or not,
         Byteseach = Lookup(1 , Color8x8)
         Blocksize = Lookup(2 , Color8x8)
         Dummy = Lookup(3 , Color8x8)
      Case 2 :
      Block = Lookup(0 , Color16x16)
      Byteseach = Lookup(1 , Color16x16)
      Blocksize = Lookup(2 , Color16x16)
      Dummy = Lookup(3 , Color16x16)

   End Select

    Colums = Blocksize / Block                              'Calculate the numbers of colums
   Row = Block * 8                                          'Row is always 8 pixels high = 1 byte, so working with row in steps of 8.
   Row = Row - 1                                            'Want to start with row=0 instead of 1
   Colums = Colums - 1                                      'Same for the colums
   For Carcount = 0 To Stringsize                           'Loop for the numbers of caracters that must be displayed
      Temp = Carcount + 1                                   'Cut the text string in seperate caracters
      Tempstring = Mid(s , Temp , 1)
      Offset = Asc(tempstring) - 32                         'Font files start with caracter 32
      Offset = Offset * Blocksize
      Offset = Offset + 4
      Temp = Carcount * Byteseach
      Temp = Temp + Xoffset
      For Rowcount = 0 To Row Step 8                        'Loop for numbers of rows
         A = Rowcount + Yoffset
         Xpos = Temp
         For Columcount = 0 To Colums                       'Loop for numbers of Colums
            Select Case Fontset
               Case 1 : Pixels = Lookup(offset , Color8x8)
               Case 2 : Pixels = Lookup(offset , Color16x16)

            End Select
            Ypos = A
            For Pixelcount = 0 To 7                         'Loop for 8 pixels to be set or not
               Pixel = Pixels.0                             'Set the pixel (or not)
               If Pixel = 1 Then
                  Pixel = Forecolor
               Else
                  Pixel = Backcolor
               End If

                  Call Lcd_set_pixel(xpos , Ypos , Pixel)

               Shift Pixels , Right                         'Shift the byte 1 bit to the right so the next pixel comes availible
               Incr Ypos                                    'Each pixel on his own spot
            Next Pixelcount
            Incr Offset
            Incr Xpos                                       'Do some calculation to get the caracter on the correct Xposition
         Next Columcount
      Next Rowcount
   Next Carcount
End Sub
 
Back to top
View user's profile
Netzman

Bascom Expert



Joined: 25 Nov 2005
Posts: 132
Location: Graz

austria.gif
PostPosted: Wed Aug 30, 2017 11:05 pm    Post subject: Reply with quote

Hello,

you can find some fonts in the Bascom samples [Bascom installation directory]\SAMPLES\LCDGRAPH
or you can generate your own font using the built-in font editor in the Bascom IDE: Menu->Tools->Font Editor
or use this one (later in the thread): https://bascomforum.de/index.php?thread/343-fonts/

I also updated the library, the changelist:

* Lcd_color_font toggles between normal/color font format, fixes wrong displayed fixed fonts
* Compatibility bug fixes
* Added alternative init sequence for displays showing scanlines, enabled by Lcd_alternative_init
* Fixed bug in HW SPI waitloops
* Updated for Bascom 2.0.8.0
* Added bresenham ellipse function

Download: http://mat.midlight.eu/index.php/ILI9341_Library

best regards

_________________
LCD Menu | Proportional Fonts
Back to top
View user's profile Visit poster's website
mototest2

Bascom Member



Joined: 24 Dec 2006
Posts: 53

poland.gif
PostPosted: Thu Aug 31, 2017 6:55 pm    Post subject: Reply with quote

Thank you for news
For test I try connecting 16bit display, but don't works
I use 128x160
I don't know if good understand connections
for example :
port1
portb.0 - db0
...
portb.7 - db7

port2
pord.0 - db8
...
portd.7-db15

is it correctly ?

Regards
Bob
Back to top
View user's profile
Netzman

Bascom Expert



Joined: 25 Nov 2005
Posts: 132
Location: Graz

austria.gif
PostPosted: Thu Aug 31, 2017 10:00 pm    Post subject: Reply with quote

Hello,

the connections should be ok.
Could you post a link to the module you have? 128x160 is not a standard resolution, maybe the display initialisation sequence needs to be adapted?

best regards

_________________
LCD Menu | Proportional Fonts
Back to top
View user's profile Visit poster's website
mototest2

Bascom Member



Joined: 24 Dec 2006
Posts: 53

poland.gif
PostPosted: Thu Aug 31, 2017 10:05 pm    Post subject: Reply with quote

Here is link
https://www.aliexpress.com/item/1-77-inch-TFT-LCD-Color-Screen-with-Adapter-Board-SPFD54124B-Drive-IC-Compatible-ILI9341-8Bit/32819566745.html?spm=a2g0s.9042311.0.0.VTnaxv
Back to top
View user's profile
mototest2

Bascom Member



Joined: 24 Dec 2006
Posts: 53

poland.gif
PostPosted: Fri Sep 01, 2017 10:30 am    Post subject: Reply with quote

ok, with 8 bit works this display, it is enough for me

Thanks
Back to top
View user's profile
Netzman

Bascom Expert



Joined: 25 Nov 2005
Posts: 132
Location: Graz

austria.gif
PostPosted: Wed Sep 20, 2017 7:27 pm    Post subject: Reply with quote

Glad you got it working, it's a quite cheap and usable display!
I compared the datasheets of the controllers, but could not find any difference in control sequences/commands. It may be possible that they are not 100% compatible, even the datasheet of the ILI controller obviously differs from the real IC...

br

_________________
LCD Menu | Proportional Fonts
Back to top
View user's profile Visit poster's website
hobby

Bascom Member



Joined: 12 Apr 2004
Posts: 109
Location: Brussels

belgium.gif
PostPosted: Sun Nov 18, 2018 9:55 am    Post subject: Reply with quote

Hi,

Before making any mistakes I prefer to ask:
I try to connect display to Arduino pro 2560 mini (5V) to display 2,8\" SPI (https://www.befr.ebay.be/itm/240x320-SPI-TFT-LCD-Touch-Panel-Serial-Port-Module-2-8-With-PCB-ILI9341-5V-3-3V/381186186810?hash=item58c0779e3a:g:RC8AAOSwv0tU~rW1:rk:1:pf:0)

In simple i add for SPI soft (touch screen not needed at this time).
Code:

Const Lcd_enable_spi = True
Const Lcd_use_soft_spi = True
Const Lcd_ctrl_port = Portk
Const Lcd_reset_pin = 0
Const Lcd_pin_dc = 1
Const Lcd_pin_cs = 2
Const Lcd_pin_sdo = 3
Const Lcd_pin_clk = 4
 

The LED pin direct to 5V.
in ili9341.inc file i see: Const Lcd_pin_sdi = 6 but with single quote, normal ? i need to add to constante list ?

According to the seller the screen is compatible 5v for logic, it\'s possible or is it better to use a level adapter?

Thanks
Olivier
Back to top
View user's profile
Netzman

Bascom Expert



Joined: 25 Nov 2005
Posts: 132
Location: Graz

austria.gif
PostPosted: Tue Nov 20, 2018 12:23 pm    Post subject: Reply with quote

I don't know that particular display and the backside of that module is not visible, so I can only guess...
If this module also includes some level shifters then its no problem connecting it to 5V logic, if not, I would at least put series resistors into the signal lines (ILI9341 is 3.3V logic).
Most modules also omit the series resistor for the backlight, so be careful directly connecting it to the 5V rail.

The parameter constants look okay, Lcd_pin_sdi is not needed (there for future use).

br

_________________
LCD Menu | Proportional Fonts
Back to top
View user's profile Visit poster's website
hobby

Bascom Member



Joined: 12 Apr 2004
Posts: 109
Location: Brussels

belgium.gif
PostPosted: Wed Nov 21, 2018 11:36 pm    Post subject: Reply with quote

Hi Netzman,

Thanks to reply.
i have tested with power supply 3V3 for more security, not works, the screen stay white.
In attachement the back of display.

But i have odered the MIKROELEKTRONIKA display (Proto Version, with full connection).
But i have see the D/C pin on this display.

Any a tested this screen in SPI mode ?

Thanks
olivier
Back to top
View user's profile
hobby

Bascom Member



Joined: 12 Apr 2004
Posts: 109
Location: Brussels

belgium.gif
PostPosted: Thu Nov 22, 2018 10:53 pm    Post subject: Reply with quote

Hi,

Today i have tested in SPI soft in 3V3 with MIKROELEKTRONIKA board.
screen stay white.

Now i try in SPI Hard, but in 9341.inc lib the reset pin and CS as the same (portb.0), it's normal ?
Code:

' Select the port of the display control pins (XMega: PortC-PortF, ATMega: for HW SPI)
#if Not Varexist( "Lcd_ctrl_port")
   #if _xmega = True
      Const Lcd_ctrl_port = Portc
   #else
-->  Const Lcd_ctrl_port = Portb
   #endif
#endif
 

Code:

' Port where the display reset is connected to
#if Not Varexist( "Lcd_reset_port")
-->   Const Lcd_reset_port = Lcd_ctrl_port
#endif

' Pin of the display reset signal
#if Not Varexist( "Lcd_reset_pin")
-->   Const Lcd_reset_pin = 0
#endif

#if Lcd_enable_spi = True
   ' SPI mode pin assignments
   #if Not Varexist( "Lcd_pin_dc")
      #if _xmega = True
         Const Lcd_pin_dc = 1
      #else
         Const Lcd_pin_dc = 4
      #endif
   #endif
   ' (HW: fixed, SW: select any)
   #if Not Varexist( "Lcd_pin_cs")
      #if _xmega = True
         Const Lcd_pin_cs = 4
      #else
-->         Const Lcd_pin_cs = 0
      #endif
   #endif
   #if Not Varexist( "Lcd_pin_sdo")
      #if _xmega = True
         Const Lcd_pin_sdo = 5
      #else
         Const Lcd_pin_sdo = 2
      #endif
   #endif
   #if Not Varexist( "Lcd_pin_clk")
      #if _xmega = True
         Const Lcd_pin_clk = 7
      #else
         Const Lcd_pin_clk = 1
      #endif
   #endif
'   Const Lcd_pin_sdi = 6
#else
 


Thanks
Olivier
Back to top
View user's profile
hobby

Bascom Member



Joined: 12 Apr 2004
Posts: 109
Location: Brussels

belgium.gif
PostPosted: Thu Nov 22, 2018 11:12 pm    Post subject: Reply with quote

I move my question in main forum, it's not good idea to post here.
Thanks
Olivier
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here All times are GMT + 1 Hour
Goto page Previous  1, 2, 3, 4, 5, 6  Next
Page 5 of 6

 
Jump to:  
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