Code:
'Test program for displaying photos and text - 16F726 w/ uLCD-320-PM2
'****************************************************************
Include "MODEDEFS.BAS" ' Include Shiftin/out modes
DEFINE OSC 16 ' 16 MHz Osc.
DEFINE HSER_BAUD 38400 ' Set baud rate
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 24h
DEFINE HSER_SPBRG 25 ' 19200 Baud @ 8MHz, 38400 Baud @ 16MHz
@ __config _CONFIG1, _DEBUG_OFF & _PLL_EN & _BORV_2_5 & _BOR_ON & _CP_OFF & _MCLRE_OFF & _PWRT_EN & _WDT_OFF & _INTOSCIO
@ __config _CONFIG2, _VCAP_RA0
'----------------------------------------------------------------------------
'SETUP SOME PORTS AND REGISTERS-----------------???????????????????????????????????----------------
OSCCON=%00110000 'Set Osc to 16MHz.
TRISA=%00000000 'Set 'em all to outputs
TRISB=%00000010 'Set portB to all outputs except RB1
TRISC=%10000000 'Set portC to all outputs except RC7
ANSELA=%00000000 ' Set all pins to digital
ANSELB=%00000000 ' Set all pins to digital
ADCON0=%00000000 'ADC off
option_reg.7=0
WPUB=%00000010
'ALIAS PINS----------------------------------------------------
to_LCD var PORTC.6 '??????????????????????
from_LCD var PORTC.7 '?????????????????????
offbutton var PORTB.1 '????????????????????????
'---------------------------
'---ALLOCATE VARIABLES----------------------------
textstartX var word : textstartX=05 'starting X position for text
textstart1YH var word : textstart1YH=01 'starting Y HIGH positon for text line 1
textstart1YL var word : textstart1YL=05 'starting Y LOW positon for text line 1
textstart2YH var word : textstart2YH=01 'starting Y HIGH positon for text line 2
textstart2YL var word : textstart2YL=35 'starting Y LOW positon for text line 2
photostartX var byte : photostartx =22 'starting X position for photo
photostartY var BYTE : photostartY = 40 'starting Y position for photo
width var byte : width = 200 'image width
height_H var byte : height_H = 0 'image height high byte
height_L var byte : height_L = 200 'image height low byte
addr_H var byte : addr_H=$00 'image address on card HIGH byte
addr_M var byte : addr_M=$10 'image address on card MID byte
addr_L var byte : addr_L=$00 'image address on card LOW byte
'---Font sizes---------------------------------------
fontsize1 var word : fontsize1=01
fontsize2 var word : fontsize2=02
fontsize3 var word : fontsize3=03
'---Predefine a few common colors---------------------------
redH var byte : redH=%11111000
redL var byte : redL=%00000000
greenH var BYTE : greenH=%00000111
greenL var byte : greenL=%11100000
blueH var byte : blueH=%00000000
bluel var byte : bluel=%00011111
yellowH var byte : yellowH=%11111111
yellowL var byte : yellowL=%11100000
magentaH var byte : magentaH=%11111000
magentaL var byte : magentaL=%00011111
cyanH var byte : cyanH=%00000111
cyanL var byte : cyanL=%11111111
orangeH var byte : orangeH=%11111010
orangeL var Byte : orangeL=%11100000
BlackH var Byte : BlackH=%00000000
BlackL var Byte : BlackL=%00000000
'-----------------------------------
Goto main: 'skip the subroutines and JGIG\
'---SUBROUTINE TO SHUT DOWN THE LCD DISPLAY "SAFELY" and end the program. (needs power reset to restart)
shutdown:
HSEROUT [$59,$03,$00] 'power down command
pause 250
end
'----------------------------------------------------------
'-----------------------------------------------------------
Main:
PAUSE 2000 'Make sure the LCD is awake
Hserout [$42, blackH,blackL] 'background color = black
pause 700
Hserout ["O", 01] 'Opaque text
pause 5
HSEROUT ["S",13,00,10,3,greenH,greenL,1,1," BYTE_BUTCHER",$00] 'Put user name at top of screen
pause 100
HSEROUT [$40,$49,photostartx,00,photostartY,width,height_H,height_L,16,addr_H,addr_M,addr_L] 'grab a photo from the uSD card and display it at the predefined coordinates
pause 200
Hserout ["S",textstartX,textstart1YH,textstart1YL,fontsize2,yellowH,yellowL,2,2, " Greetings",$00] 'text line 1
pause 20
Hserout ["S",textstartX,textstart2YH,textstart2YL,fontsize3,cyanH,cyanL,1,1, " PBP users!",$00] 'text line 2
'----------
checkbutton:
if offbutton = 0 then gosub shutdown
Pause 100
goto checkbutton
end
steve
Bookmarks