Proton BASIC Compiler - Driver for ILI9341


  • PicŪ Basic


  • Driver for ILI9341

    This is a simple driver for ILI9341 that prints charactes, lines and boxes. It was originally based on the driver that I extracted from Normnets Pic wav Player v1.0 for Nokia 6100 display which in turn I believe to be based on a driver by James Lynch which I also refered to. I addition to tha I have got some bits and pieces from all over the internet, not the least the Arduino crowd. <br>

    To use this driver you type:
    Include "ILI9341.inc"

    InitILI
    The init routine is in contrast with other inits I have seen very simple, its only starts the display but doesn't tweek any of its settings. My ILI9341 displays starts in BGR mode and mirrored. To fix that you have to set MADCTL register. There are four macros that set screen orientation, size of screen, color order to RGB and printing from left to right.


    SCRorientation0
    SCRorientation90
    SCRorientation180
    SCRorientation270

    There are few "graphic" commands that do what their names imply:

    ClearScreen
    SetPixel(x,y)
    HLine(x,y,w)
    VLine(x,y,h)
    XBlock(x,y,w,h)
    XBox(x,y,w,h)

    Printing of strings

    Fonts used are as defined in AN1182 by Microchip. To make fonts I used Microchip Graphics Resource Converter which is burried deep in Microchip Libraries for Applications. It takes Windows fonts and converts to horizontally arranged bitmaps, which isconvenient for this display. I manually converted these to basic using search and replace in Notepad++. There are several fonts includes in the zip.

    To use a font type for example:

    SetFont

    To print a string you must first set coordinates wXstart and wYstart and then:

    PrintString(string) or PrintString_At(x,y,string) which sets the coordinates first. Both call Sub Print_Chr which increments wXstart by the width of the character. More information on this can be gained by reading the program listing as I believe it to be reasonably commented.

    In the demo program there are some helper routines to set margins and print out whole fonts. It doesn't do much more than that. I will in following days post some more information on this driver and answear questions. I hope there will be some. The driver has some limitations, most notably it's inability to print wery lage fonts. I also hope to do some improvements in the coding.

    Few useful links:

    ILI9341 datasheet:
    https://courses.cs.washington.edu/co...l3/ILI9341.pdf

    Nokia 6100 LCD Display Driver:
    https://elecfreaks.com/estore/downlo...lay_Driver.pdf

    AN1182Fonts in the Microchip Graphics Library:
    http://ww1.microchip.com/downloads/e...tes/01182a.pdf

    Microchip Libraries for Applications:
    https://www.microchip.com/mplab/microchip-libraries-for-applicationsILI9341_menu_test.zip
    This article was originally published in forum thread: Driver for ILI9341 started by flosigud View original post