I managed to run a python script FLASH.py and ImageConvertor565
.
in the FLASH .py scripts can I put COM.1 as default port to communicate with PIC chip?
On which the port and pin I connects serial communication between PC and PIC
PIC RX-pin is ?
PIC TX-pin is ?
What is the maximum number of buttons possible to make the TFT screen.
I tried to make a four keys and the fourth button is not working. The first three are working.
here's the code for PIC18F4520 that I use:
Code:
'****************************************************************
'* Name : pic18f2520_tft_demo.pbp *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2015 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 8/28/2015 *
'* Version : 1.0 *
'* Notes : sleep, pwm brightness (10 bit pwm) *
'* : *
'****************************************************************
#CONFIG
CONFIG OSC = INTIO67
CONFIG FCMEN = OFF
CONFIG IESO = OFF
CONFIG PWRT = OFF
CONFIG BOREN = SBORDIS
CONFIG BORV = 3
CONFIG WDT = OFF
CONFIG WDTPS = 512
CONFIG CCP2MX = PORTC
CONFIG PBADEN = OFF
CONFIG LPT1OSC = OFF
CONFIG MCLRE = ON
CONFIG STVREN = ON
CONFIG LVP = OFF
CONFIG XINST = OFF
CONFIG DEBUG = OFF
CONFIG CP0 = OFF
CONFIG CP1 = OFF
CONFIG CP2 = OFF
CONFIG CP3 = OFF
CONFIG CPB = OFF
CONFIG CPD = OFF
CONFIG WRT0 = OFF
CONFIG WRT1 = OFF
CONFIG WRT2 = OFF
CONFIG WRT3 = OFF
CONFIG WRTC = OFF
CONFIG WRTB = OFF
CONFIG WRTD = OFF
CONFIG EBTR0 = OFF
CONFIG EBTR1 = OFF
CONFIG EBTR2 = OFF
CONFIG EBTR3 = OFF
CONFIG EBTRB = OFF
#ENDCONFIG
DEFINE NO_CLRWDT 1
#DEFINE TOUCH_SCREEN 1
'#DEFine dbug 1
;-----------connection----------
; pic tft
; <tft_port.tft_dc_bit >-------< dc >
; <tft_port.tft_cs_bit >-------< cs >
; <tft_port.tft_rst_bit>-------< rst >
; <msspx.sdo >-----------------< mosi >
; <msspx.sck >-----------------< sck >
; <back_light>-----------------< led > via pnp cct
tft_dc_bit con 8 ;ie bit 3
tft_cs_bit con 32 ;ie bit 5
tft_rst_bit con 16 ;ie bit 4
tft_port var latb
back_light var latc.2 ;portc.2
cont var word ; backlight level
WIDTH con 320 ; 160 X MUST MATCH TFT MODULE
HEIGHT con 240 ; 128 Y
' my TOUCH_SCREEN connection definitions
T_CLK VAR PORTa.7
T_INPin VAR PORTa.4
T_OUTPin VAR PORTa.6
T_INT VAR PORTb.0
T_CS VAR LATb.2
number_of_buttons con 4
number_of_sliders con 1
INCLUDE "TFT_SPI.pbpmod" ;glcdc
include "tft-ILI9431.bas"
'INCLUDE "flash_spi.pbpmod"
include "TOUCH_TFT.PBPMOD" ;uncomment to use TOUCH_TFT
INCLUDE "font7x8.bas"
latb=255 ; make sure tft etc are not selected ie all cs high
TRISA=111111
TRISB=000011
TRISC=010011
TRISD=000000
PORTD=0000000
OSCCON = 110000 'Internal 8 Mhz Osc
OSCTUNE=000000 'PLL ON
cont=500 ;half brightness
DEFINE OSC 32
buff var byte[32]
t2con=5
PR2 = 255;
CCPR1L = cont>>2; ;set pwm
ccp1con=12|((cont&3)<<4);
SSPCON1=$20 ;$20-21-22 works 20 IS FASTEST
SSPSTAT=$40
TEXTSIZE=4
gosub tft_init
gosub TOUCH_INIT
#ifdef dbug
trisb.7=0 ;DEBUG OUT
latb.7=1
pause 4000
Serout2 PORTb.7,84,["ready ", 13,10]
#ENDIF
glcdc font7x8 ;SET FONT
bg=$ffff
fg=0
fillrect 0,0,WIDTH,height ;cls
MAKEBUTTON 30,180,0,50, "CLEAR"
MAKEBUTTON 90,180,1,50, "SLP"
MAKEBUTTON 150,180,2,50, "LED"
MAKEBUTTON 210,180,3,50, "VISNJA"
MAKESLIDER 100,80,0
slider_index =0
the_slider = slider_index *SL_SZ ; set slider indexing properly
slider_FG[the_slider ]=$ffe0 ;set slider bar colour if default not desired
slider_count[the_slider]=cont/10
bg=0
INTCON2.6=0
main:
fg=$7FF
DRAWBUTTON 0
DRAWBUTTON 1
DRAWBUTTON 2
DRAWBUTTON 3
slider_index =0
the_slider = slider_index *SL_SZ
slider_MODE[the_slider]=0 ;FORCE DRAW OF SLIDER
DRAWSLIDER 0
LOP:
GOSUB CK_BUTTON
IF BUTTON_STATE[0]=1 THEN
BUTTON_STATE[0]=0
fg=0
fillrect 0,0,WIDTH,height ;cls
goto main
ELSEIF BUTTON_STATE[2]=1 THEN
TOGGLE PORTD.0
BUTTON_STATE[2]=0
ELSEIF BUTTON_STATE[3]=1 THEN
TOGGLE PORTD.1
BUTTON_STATE[3]=0
elseIF BUTTON_STATE[1] THEN
if BUTTON_STATE[1]==2 then ; shut it all down
gosub tft_sleep
ccp1con=0
back_light=1
pause 100
intcon=$10
@ sleep
@ nop
intcon=0
gosub tft_wake
CCPR1L = cont>>2;
ccp1con=12|((cont&3)<<4);
endif
BUTTON_STATE[1]=0
endif
slider_index =0
the_slider = slider_index *SL_SZ
IF slider_MODE[the_slider]&1 THEN ; adjust brightness
cont = 1000 - slider_COUNT[0]*10
CCPR1L = cont>>2;
ccp1con=12|((cont&3)<<4);
slider_MODE[the_slider]=slider_MODE[the_slider]&$FE
TEXTSIZE=2
fg=$7FF
ARRAYWRITE buff,[dec3 slider_COUNT[the_slider],0]
GLCDSTR 50,10 ,buff
ENDIF
goto LOP
VISNJA button not working.When I touch them nothing is happend.
Bookmarks