News:

;) This forum is the property of Proton software developers

Main Menu

TFT DISPLAY

Started by Abdullah, Oct 31, 2025, 04:37 PM

Previous topic - Next topic

Abdullah

    Device 18F25K22
    Declare Xtal 64
    Symbol PLLEN = OSCTUNE.6                    ' PLL enable
    Symbol PLLRDY = OSCCON2.7                    ' PLL run status
    PLLEN = 1                                    ' Enable PLL 4x 20MHz = 80Mhz
    While PLLRDY = 0 : Wend                        ' Wait until PLL is stable

    Dim wFSR0 As FSR0L.Word
    Dim wFSR1 As FSR1L.Word
    Dim wFSR2 As FSR2L.Word
    Dim KeyVal As Byte

    $define ILI9341
    Include "ILI9341_9163.inc"                    ' ILI9341 driver
    Include "Amicus18_spi2.inc"
    Include "ADS7846_spi2.inc"
    Include "rgb565.inc"                        ' List of named internet colors.
    DelayMS 100
    InitILI
    DelayMS 100
    SCRorientation0                                                         
    wColor = WHITE
'   SetFont(Arial_Bold_14)
    wPaper = RED
    wInk = BLACK

    GoTo Initialise

Proc WriteKeys()
    SetFont(Arial_Bold_16)   'was 20
    wInk = BLUE
    wPaper = WHITE ' TEXT COLOUR
    At_XY(40,3)
    PrintString("ASSALAMUALAIKUM")
    At_XY(55,24)
    PrintString("SIR SHAHAB DIN")             'just to put something on the screen at top
    At_XY(8,46)
    'PrintString("Key: ")             'and another line to test spacing
   ; SetFont(Arial_Bold_14)
    PrintString("SIR JI PROTON KA TFT DEMO")
    wColor = RED ' BOX COLOUR

    XBox(10,270,66,38)
    XBox(86,270,66,38)
    XBox(162,270,66,38)

    XBox(10,222,66,38)
    XBox(86,222,66,38)
    XBox(162,222,66,38)

    XBox(10,174,66,38)
    XBox(86,174,66,38)
    XBox(162,174,66,38)

    XBox(10,126,66,38)
    XBox(86,126,66,38)
    XBox(162,126,66,38)

    XBox(10,78,66,38)
    XBox(86,78,66,38)
    XBox(162,78,66,38)

    SetFont(Arial_Bold_16)
    wInk = GREEN ' TEXT COLOUR
    wPaper = WHITE
    At_XY(28,280)
    PrintString("Prev")
    At_XY(100,280)
    PrintString("Save")
    At_XY(177,280)
    PrintString("Next")
    At_XY(16,232)
    PrintString("Cancel")
    At_XY(115,232)
    PrintString("0")
    At_XY(177,232)
    PrintString("Exit")
    At_XY(38,184)
    PrintString("7")
    At_XY(115,184)
    PrintString("8")
    At_XY(188,184)
    PrintString("9")
    At_XY(38,136)
    PrintString("4")
    At_XY(115,136)
    PrintString("5")
    At_XY(188,136)
    PrintString("6")
    At_XY(38,91)
    PrintString("1")
    At_XY(116,91)
    PrintString("2")
    At_XY(188,91)
    PrintString("3")
EndProc
Proc SelectColumn1()
    Select ADS_wYlocation
    Case 212 To 241
        KeyVal = 1
    Case 162 To 192
        KeyVal = 4
    Case 116 To 145
        KeyVal = 7
    Case 61 To 98
        KeyVal = 0
    Case 15 To 47
        KeyVal = 11
    EndSelect
EndProc
Proc SelectColumn2()
    Select ADS_wYlocation
    Case 212 To 241
        KeyVal = 2
    Case 162 To 192
        KeyVal = 5
    Case 116 To 145
        KeyVal = 8
    Case 61 To 98
        KeyVal = 12
    Case 15 To 47
        KeyVal = 13
    EndSelect
EndProc
Proc SelectColumn3()
    Select ADS_wYlocation
    Case 212 To 241
        KeyVal = 3
    Case 162 To 192
        KeyVal = 6
    Case 116 To 145
        KeyVal = 9
    Case 61 To 98
        KeyVal = 14
    Case 15 To 47
        KeyVal = 15
    EndSelect
EndProc
Initialise:
    ADS_Init()
    ClearScreen
Main:
    WriteKeys()
    While
    If ADS_Active() = tStylusOn Then
        hADS_GetSample(cMeasureX)                ' Get the raw X value from the touch screen controller
        wInk = BLACK
        ADS_Get()
    Select ADS_wXlocation
    Case 10 To 64
         SelectColumn1()
    Case 82 To 149
         SelectColumn2()
    Case 164 To 225
         SelectColumn3()
    EndSelect
    SetFont(Arial_20)
    At_XY(60,46)
    PrintString(Str$ (Dec KeyVal)+"   "+ Str$(Dec ADS_wPressure)+"     ")         ' Display the value of the key
    DelayMS 200
    EndIf
    Wend
Include "Arial_Bold_14.Inc"
Include "Arial_Bold_16.inc"
Include "Arial_20.inc"
Declare Reminders Off
@ CONFIG_REQ = 0 ; Override Compiler's configuration settings
Asm-
Config FOSC = HSHP ;HS oscillator (high power > 16 MHz)
Config PLLCFG = On ;Oscillator multiplied by 4
Config PRICLKEN = On ;Primary clock enabled
Config FCMEN = OFF ;Fail-Safe Clock Monitor disabled
Config IESO = OFF ;Oscillator Switchover mode disabled
Config PWRTEN = On ;Power up timer enabled
Config BOREN = SBORDIS ;Brown-out Reset enabled in hardware only (SBOREN is disabled)
Config BORV = 190 ;VBOR set to 1.90 V nominal
Config WDTEN = OFF ;Watch dog timer is always disabled. SWDTEN has no effect.
Config WDTPS = 32768 ;1:32768
Config CCP2MX = PORTC1 ;CCP2 input/output is multiplexed with RC1
Config PBADEN = OFF ;PORTB<5:0> pins are configured as digital I/O on Reset
Config CCP3MX = PORTB5 ;P3A/CCP3 input/output is multiplexed with RB5
Config HFOFST = On ;HFINTOSC output and ready status are not delayed by the oscillator stable status
Config T3CMX = PORTC0 ;T3CKI is on RC0
Config P2BMX = PORTB5 ;P2B is on RB5
Config MCLRE = INTMCLR ;RE3 input pin enabled; MCLR disabled
Config STVREN = OFF ;Stack full/underflow will not cause Reset
Config LVP = OFF ;Single-Supply ICSP disabled
Config XINST = OFF ;Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
Config Debug = OFF ;Disabled
Config Cp0 = OFF ;Block 0 (000800-001FFFh) not code-protected
Config CP1 = OFF ;Block 1 (002000-003FFFh) not code-protected
Config CP2 = OFF ;Block 2 (004000-005FFFh) not code-protected
Config CP3 = OFF ;Block 3 (006000-007FFFh) not code-protected
Config CPB = OFF ;Boot block (000000-0007FFh) not code-protected
Config CPD = OFF ;Data EEPROM not code-protected
Config WRT0 = OFF ;Block 0 (000800-001FFFh) not write-protected
Config WRT1 = OFF ;Block 1 (002000-003FFFh) not write-protected
Config WRT2 = OFF ;Block 2 (004000-005FFFh) not write-protected
Config WRT3 = OFF ;Block 3 (006000-007FFFh) not write-protected
Config WRTC = OFF ;Configuration registers (300000-3000FFh) not write-protected
Config WRTB = OFF ;Boot Block (000000-0007FFh) not write-protected
Config WRTD = OFF ;Data EEPROM not write-protected
Config EBTR0 = OFF ;Block 0 (000800-001FFFh) not protected from table reads executed in other blocks
Config EBTR1 = OFF ;Block 1 (002000-003FFFh) not protected from table reads executed in other blocks
Config EBTR2 = OFF ;Block 2 (004000-005FFFh) not protected from table reads executed in other blocks
Config EBTR3 = OFF ;Block 3 (006000-007FFFh) not protected from table reads executed in other blocks
Config EBTRB = OFF ;Boot Block (000000-0007FFh) not protected from table reads executed in other blocks
Endasm-
Declare Reminders On
HI EVERYONE THIS CODE FOR KEYPAD
XBOX COMMANDS FOR BOX WHAT IS COMMANDS OF CIRCLE