Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 09:23 29 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : ILI9341 Parallel Driver

Author Message
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 844
Posted: 02:06am 09 Mar 2016
Copy link to clipboard 
Print this post

I was after a 3.2" touch screen so ordered a couple of these.
SSD1289 Aliexpress  but when they turned up they where not the SSD1289 which can be modified to work as 8 bit as shown here SSD1289 conversion to 8 bit.
The board I received was a TFT_320QVT_9341 instead of previous TFT_320QVT. This seems to be quite common thing and looks like the SSD1289 is on the way out and ILI9341 is being used, in many cases still advertising as SSD1289.

It comes as 16 bit mode and uses the ILI9341, the same chip used on the 2.4 and 2.8 ILI9341 SPI LCD.

A way to convert the ILI9325 another 16 bit LCD to 8 bit mode is shownhere which also requires moving a resistor.

I had two so I opened one up and found only two resistor positions, R1 in place and R2 not populated. So after a bit of mucking around and losing R1 into the carpet I finally got a short across R2.

Based on Peter's drivers and the latest C tutorials I managed to get a driver to compile for the 16 bit unmodified one and it worked in 16 bit mode.

I then tried the modified one with and 8 bit driver and moving R1 to R2 had successfully put it in 8 bit mode. (I really think is nine bit mode but B8 is not used for RGB565.)

I am using Peter's ultimate backpack, and you need to tie B0-7 to B8-15 as for the ILI9325 device.

Anyway, much learned and looks like another LCD option. Its 320*240, touch screen and 3.2" and with the ILI9341 chip some of Peter's other stuff such as rotation and not overwriting the background could be made to work I think.



'  File ILI9341_P8.bas  written 03-Apr-2020  23:19:09
'
CSub ILI9341_P8
   00000148
   'getFPC
   27BDFFF8 AFBF0004 00852023 03E42021 ACC40000 8FBF0004 03E00008 27BD0008
   'write_command_data
   27BDFFF8 AFA60010 AFA70014 3C02BF88 34038000 AC436138 24031000 AC436134
   27A60010 AFA60000 308400FF 34840800 AC446430 24040800 AC446134 AC446138
   AC436138 18A0000D 8FA40000 00001821 24060800 24870004 AFA70000 80840000
   34841800 AC446430 AC466134 AC466138 24630001 1465FFF7 8FA40000 03E00008
   27BD0008
   'defineregion
   27BDFFD8 AFBF0024 AFB10020 AFB0001C 00801021 00A08021 2483FFFF 00661821
   24B1FFFF 02278821 00032202 AFA40010 AFA30014 2404002A 24050004 00023202
   00403821 0411FFCD 00000000 00111202 AFA20010 AFB10014 2404002B 24050004
   00103202 02003821 0411FFC4 00000000 8FBF0024 8FB10020 8FB0001C 03E00008
   27BD0028
   'DrawBitmap_ILI9341
   27BDFFB0 AFBF004C AFBE0048 AFB70044 AFB60040 AFB5003C AFB40038 AFB30034
   AFB20030 AFB1002C AFB00028 AFA40050 00A0F021 00C09021 AFA7005C 8FB00060
   8FA30064 8FA20068 8FB3006C 3C069D00 8CC70094 8CF10000 8CC60098 8CC60000
   AFA60010 0003BC03 32F700F8 7C661340 02E6B825 36F71800 0003B143 32D600E0
   7C6320C0 02C3B025 36D61800 0002AC03 32B500F8 7C431340 02A3A825 36B51800
   0002A143 329400E0 7C4220C0 0282A025 36941800 72123002 8FA2005C 72023802
   0411FFAE 00000000 2404002C 00002821 0411FF89 00000000 24031000 3C02BF88
   AC436138 8FA3005C 1860005B 02007821 AFBE0014 00121023 AFA2001C 7072F002
   27DEFFFF AFB20020 00007021 AFA00018 24180001 3C05BF88 1000004B 24060800
   04400019 0051202B 50800018 24630001 05220016 24630001 51600014 24630001
   91A40000 008C2024 10800009 00000000 ACB76430 ACA66134 ACA66138 ACB66430
   ACA66134 ACA66138 10000008 24630001 ACB56430 ACA66134 ACA66138 ACB46430
   ACA66134 ACA66138 24630001 1470FFE4 24420001 24E70001 2508FFFF 10F20010
   014F5021 00EE1021 24430007 284D0000 006D100B 000268C3 026D6821 000817C3
   00021742 01026021 318C0007 01826023 01986004 01401021 1000FFD1 00001821
   27390001 17300004 25290001 10000009 8FA30018 0000C821 1A40FFF9 8FAA0050
   03C04021 00003821 8FA20010 1000FFE5 0122582B 24630001 AFA30018 8FA20014
   004F1021 AFA20014 8FA3001C 03C3F021 8FA20020 01C27021 8FA30018 8FA2005C
   10620006 8FBF004C 1E00FFEA 8FA90014 1000FFF0 8FA30018 8FBF004C 8FBE0048
   8FB70044 8FB60040 8FB5003C 8FB40038 8FB30034 8FB20030 8FB1002C 8FB00028
   03E00008 27BD0050
   'DrawRectangle_ILI9341
   27BDFFE0 AFBF001C AFB10018 AFB00014 0086102A 14400004 8FB00030 00801021
   00C02021 00403021 00A7102A 14400005 28820000 00A01021 00E02821 00403821
   28820000 0002200B 3C029D00 8C420094 8C420000 0082402B 2443FFFF 0068200A
   28C30000 0003300B 00C2182B 2442FFFF 0043300A 28A20000 0002280B 3C029D00
   8C420098 8C430000 00A3402B 2462FFFF 0048280A 28E20000 0002380B 00E01021
   00E3382B 2463FFFF 0067100A 24070001 00E41823 00663021 00E53823 00E23821
   70E68802 0411FF0B 00000000 2404002C 00002821 0411FEE6 00000000 3C02BF88
   24031000 AC436138 34038000 AC436138 00101C03 306300F8 7E041340 00641825
   00102143 308400E0 7E1020C0 00908025 36101800 240403FC AC446134 34641800
   00031880 AC436138 1220000C 2631FFFF 24030800 2405FFFF AC446430 AC436134
   AC436138 AC506430 AC436134 AC436138 2631FFFF 1625FFF8 00000000 8FBF001C
   8FB10018 8FB00014 03E00008 27BD0020
   'main
   27BDFF88 AFBF0074 AFB40070 AFB3006C AFB20068 AFB10064 AFB00060 0080A021
   00002021 3C059D00 24A50558 27A60058 0411FEAB 00000000 3C029D00 8C430090
   8E840000 A0640015 8C430090 24040014 A0640014 8C420090 2403001C A043002E
   2402003C AFA20018 2402003D AFA2001C 2402003E AFA20020 2402003F AFA20024
   24020040 AFA20028 24020001 AFA2002C 24020002 AFA20030 24020003 AFA20034
   2402000E AFA20038 2402000D AFA2003C 2402000C AFA20040 2402000B AFA20044
   24020011 AFA20048 24020012 AFA2004C 24020015 AFA20050 24020016 AFA20054
   27B20018 27B30038 3C109D00 8E510000 8E020010 02202021 24050008 0040F809
   00003021 8E020010 02202021 24050065 0040F809 00003021 8E02001C 02202021
   0040F809 24050005 26520004 5653FFF0 8E510000 3C109D00 8E020010 2404001B
   24050008 0040F809 00003021 8E020010 2404001B 24050065 0040F809 00003021
   3C11BF88 24021000 AE226138 8E020010 24040018 24050008 0040F809 00003021
   8E020010 24040018 24050065 0040F809 00003021 24020800 AE226138 8E030090
   8E020010 8064002E 24050008 0040F809 00003021 8E030090 8E020010 8064002E
   24050065 0040F809 00003021 8E030090 8E02001C 8064002E 0040F809 24050006
   8E030090 8E02001C 8064002E 0040F809 24050006 8E020004 0040F809 3404C350
   8E030090 8E02001C 8064002E 0040F809 24050005 8E020004 0040F809 3404C350
   8E030090 8E02001C 8064002E 0040F809 24050006 8E020004 0040F809 3404C350
   24040001 00002821 0411FE2D 00000000 8E020004 3C110001 0040F809 362486A0
   24040028 00002821 0411FE25 00000000 240400C0 24050001 24060023 0411FE20
   00000000 240400C1 24050001 24060010 0411FE1B 00000000 240400C5 24050002
   2406002B 2407002B 0411FE15 00000000 240400C7 24050001 240600C0 0411FE10
   00000000 24040036 24050001 24060028 0411FE0B 00000000 24040001 00002821
   0411FE07 00000000 8E020004 0040F809 362486A0 2404003A 24050001 24060055
   0411FDFF 00000000 240400B1 24050002 00003021 2407001B 0411FDF9 00000000
   240400B7 24050001 24060007 0411FDF4 00000000 24040011 00002821 0411FDF0
   00000000 8E020004 3C040002 0040F809 248449F0 24040013 00002821 0411FDE8
   00000000 24040029 00002821 0411FDE4 00000000 8E020004 3C040007 0040F809
   3484A120 8E820000 24040001 14440003 8E830004 1060000C 24060028 24040002
   14440004 24040003 1060000B 24060048 24040003 14440004 24060008 10600006
   240600E8 24060008 24040004 14440002 24020088 0043300A 24040036 24050001
   0411FDC7 00000000 3C029D00 8C420090 90420015 30420001 10400008 3C029D00
   8C430094 24040140 AC640000 8C420098 240300F0 10000007 AC430000 8C430098
   24040140 AC640000 8C420094 240300F0 AC430000 8FA50058 3C029D00 8C430048
   3C049D00 248403B0 00852021 AC640000 8FA50058 8C43004C 3C049D00 24840128
   00852021 AC640000 8C430048 8C440094 8C860000 8C420098 8C470000 AFA00010
   8C620000 00002021 00002821 24C6FFFF 0040F809 24E7FFFF 8FBF0074 8FB40070
   8FB3006C 8FB20068 8FB10064 8FB00060 03E00008 27BD0078
End CSub





Flashing the LED

  Quote  PIN(PA6) = 1
PIN(PA7) = 1
SETPIN PA6, DOUT
SETPIN PA7, DOUT
DO
PIN(PA6) = 0
PULSE PA7,500
PAUSE 500
PIN(PA6) = 1
PAUSE 500
LOOP




Using the ADC


  Quote  Option explicit
Option default none
Option VCC 3.309
Dim integer i, j
CLS
'
' First set up some signals using the onboard DAC
' connect pin 40 to pin 49 and pin 41 to pin 22
' connect a potentiometer to pin 53 to use as a trigger
' PE3 to PC1
'
Dim a(799) As float, b(799) As float, t(799) As float, c%(89), d%(89)
For i=0 To 89
c%(i)=
Sin(Rad(i*4))*1500+2048
d%(i)=i*
4000/90'+2048
Next i%
DAC
start 100000,c%(),d%()
'PLAY TONE 1000,2000
PWM 1,500,50
'
ADC open 100000,pc0,pc2,pc1,adc_done
ADC trigger
3,-2.0 ' Trigger on channel 3 going -ve past 2.0v
'ADC trigger 1,1.0 ' Trigger on channel 1 going +ve past 1.0v


ADC
start a(), b(), t()

Do
Loop
End

SUb ShowResult
 
Box 0,0,MM.HRes,MM.VRes

 
'Pixel 0, 100-a(0)*25, RGB(magenta)
 'Pixel 0, 220-b(0)*25, RGB(green)

 
For i=1 To 319
   
Line i-1,125-a(i-1)*35 , i, 125-a(i)*35 , 1, RGB(magenta)
   
Line i-1,125-b(i-1)*35 , i, 125-b(i)*35 , 1, RGB(green)
   
Line i-1,125-t(i-1)*35 , i, 125-t(i)*35 , 1, RGB(BLUE)
 
Next i
 
'Text MM.HRes\2,MM.VRes\2,"Pre-trigger "+Str$(t(0),1,5)+" Post-trigger "+Str$(t(1),1,5),CM,1
END SUB

'This subroutine called when ADC has filleds the arrays
Sub adc_done
showresult
End Sub




Pump Controller Demonstration


  Quote  '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Demonstration program for the Micromite+ and Armmite F4
' It does not do anything useful except demo the various controls
'
' Geoff Graham, October 2015
' ON ERROR SKIP Added in case click pin not configured G.A. 2021
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Option Explicit
Dim ledsY
Colour RGB(white), RGB(black)

' reference numbers for the controls are defined as constants
Const c_head = 1, c_pmp = 2, sw_pmp = 3, c_flow = 4, tb_flow = 5
Const led_run = 6, led_alarm = 7
Const frm_alarm = 20, nbr_hi = 21, nbr_lo = 22, pb_test =23
Const c_hi = 24, c_lo = 25
Const frm_pump = 30, r_econ = 31, r_norm = 32, r_hi = 33
Const frm_log = 40, cb_enabled = 41, c_fname = 42, tb_fname = 43
Const c_log = 44, cb_flow = 45, cb_pwr = 46, cb_warn = 47
Const cb_alarm = 48, c_bright = 49, sb_bright = 50

' now draw the "Pump Control" display
CLS
GUI Interrupt TouchDown, TouchUp

' display the heading
Font 2,2 : GUI Caption c_head, "Pump Control", 10, 0
Font 3 : GUI Caption c_pmp, "Pump", 20, 60, , RGB(brown)

' now, define and display the controls
' first display the switch
Font 4
GUI Switch sw_pmp, "ON|OFF", 20, 90, 150, 50, RGB(white),RGB(brown)
CtrlVal(sw_pmp) = 1

' the flow rate display box
Font 3 : GUI Caption c_flow, "Flow Rate", 20, 170,, RGB(brown),0
Font 4 : GUI Displaybox tb_flow, 20, 200, 150, 45
CtrlVal(tb_flow) = "20.1"

' the radio buttons and their frame
Font 3 : GUI Frame frm_pump, "Power", 20, 290, 170, 163, RGB(200,20,255)
GUI Radio r_econ, "Economy", 43, 328, 12, RGB(230, 230, 255)
GUI Radio r_norm, "Normal", 43, 374
GUI Radio r_hi, "High", 43, 418
CtrlVal(r_norm) = 1     ' start with the "normal" button selected

' the alarm frame with two number boxes and a push button switch
Font 3 : GUI Frame frm_alarm, "Alarm", 220, 220, 200, 233,RGB(green)
GUI Caption c_hi, "High:", 232, 260, "LT", RGB(yellow)
GUI Numberbox nbr_hi, 318,MM.VPos-6,90,MM.FontHeight+12,RGB(yellow),RGB(64,64,64)
GUI Caption c_lo, "Low:", 232, 325, LT, RGB(yellow),0
GUI Numberbox nbr_lo, 318,MM.VPos-6,90,MM.FontHeight+12,RGB(yellow),RGB(64,64,64)
GUI Button pb_test, "TEST", 257, 383, 130, 40,RGB(yellow), RGB(red)
CtrlVal(nbr_lo) = 15.7 : CtrlVal(nbr_hi) = 35.5

' draw the two LEDs
Const ledsX = 255, coff = 50    ' define their position
ledsY = 105 : GUI LED led_run, "Running", ledsX, ledsY, 15, RGB(green)
ledsY = ledsY+
49 : GUI LED led_alarm, "Alarm", ledsX, ledsY, 15, RGB(red)
CtrlVal(led_run) = 1   ' the switch defaults to on so set the LED on

' the logging frame with check boxes and a text box
Colour RGB(cyan), 0
GUI Frame frm_log, "Log File", 450, 20, 330, 355, RGB(green)
GUI Checkbox cb_enabled, "Logging Enabled", 470, 50, 30, RGB(cyan)
GUI Caption c_fname, "File Name", 470, 105
GUI Textbox tb_fname, 470, 135, 290, 40, RGB(cyan), RGB(64,64,64)
GUI Caption c_log, "Record:", 470, 205, , RGB(cyan), 0
GUI Checkbox cb_flow, "Flow Rate", 500, 245, 25
GUI Checkbox cb_alarm, "Alarms", 500, 285, 25
GUI Checkbox cb_warn, "Warnings", 500, 325, 25
CtrlVal(cb_enabled) = 1
CtrlVal(tb_fname) = "LOGFILE.TXT"

' define and display the spinbox for controlling the backlight
GUI Caption c_bright, "Backlight", 442, 415, ,RGB(200,200,255),0
GUI Spinbox sb_bright, MM.HPos + 8, 400, 200, 50,,,10, 10, 100
CtrlVal(sb_bright) = 100

' All the controls have been defined and displayed. At this point
' the program could do some real work but because this is just a
' demo there is nothing to do.  So it just sits in a loop.
Do : Loop


' the interrupt routine for touch down
' using a select case command it has a different process for each control
Sub TouchDown
 
Select Case Touch(REF)      ' find out the control touched
   Case cb_enabled           ' the enable check box
     If CtrlVal(cb_enabled) Then
       
GUI ENABLE c_fname, tb_fname, c_log, cb_flow, cb_alarm, cb_warn
     
Else
       
GUI Disable c_fname, tb_fname, c_log, cb_flow, cb_alarm, cb_warn
     
EndIf
   
Case sb_bright            ' the brightness spin box
     BackLight CtrlVal(sb_bright)
   
Case sw_pmp               ' the pump on/off switch
     CtrlVal(led_run) = CtrlVal(sw_pmp)
     
CtrlVal(tb_flow) = Str$(CtrlVal(sw_pmp) * 20.1)
     
CtrlVal(r_norm) = 1
   
Case pb_test              ' the alarm test button
     CtrlVal(led_alarm) = 1
     
ON ERROR SKIP  'just in case click pin not configured
     GUI beep 250
   
Case r_econ               ' the economy radio button
     CtrlVal(tb_flow) = Str$(CtrlVal(sw_pmp) * 18.3)
   
Case r_norm               ' the normal radio button
     CtrlVal(tb_flow) = Str$(CtrlVal(sw_pmp) * 20.1)
   
Case r_hi                ' the high radio button
     CtrlVal(tb_flow) = Str$(CtrlVal(sw_pmp) * 23.7)
 
End Select
End Sub

' interrupt routine when the touch is removed
Sub TouchUp
 
Select Case Touch(LASTREF)   ' use the last reference
   Case pb_test               ' was it the test button
     CtrlVal(led_alarm) = 0   ' turn off the LED
 End Select
End Sub




Tutorial on milling PCB on CNC3018 Pro

Candle Grbl Software Tutorial

Introduction to CNC for a Total Novice - Graham Bland
Edited 2021-09-13 21:25 by disco4now
Latest F4 Latest H7
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024