'*******************************************************************************
'Programm für ein Display ST7735R 1.8Zoll 128x160
'Display from adafruit.com/products/358
'or HY-1.8 Spi Display
'Bascom IDE 2.0.7.5
'
'Version:13092012
'By Hkipnik
' © Copyright by H.Kipnik 2012
'Date 13.09.2012
'update 03.06.2013
'*******************************************************************************
' SD Card CS --> portb.0
' Miso --> portb.3
' Mosi --> portb.2
' Clock --> portb.1
'Display
' CS --> portb.7
' DC --> portb.5
' reset --> portb.6
' Mosi --> portb.2
' Lite --> +5V
'
'Display typ Red or black Tab have different RGB order
'color of the display plastic wrap
'*******************************************************************************
$regfile = "m328Pdef.dat"
$crystal = 16000000
$hwstack = 150
$swstack = 150
$framesize = 150
$baud = 57600
'*******************************************************************************
Const Sdcard = 0 'use SD Card = 1 no SD Card = 0
Const Modus = 1 '0=Portrait 1=Landscape
Const Disp_typ = 1 'RGB order 0=Black Tab 1=Red Tab
'*******************************************************************************
'( Mega 2560
Config Portb.7 = Output
Config Portb.5 = Output
Config Portb.6 = Output
Lcd_cs Alias Portb.7
Lcd_dc Alias Portb.5
Lcd_reset Alias Portb.6
Portb.7 = 1
')
'Mega 328P
Config PortC.1 = Output
Config PortC.0 = Output
Config PortC.2 = Output
Lcd_cs Alias PortC.1
Lcd_dc Alias PortC.0
Lcd_reset Alias PortC.2
PortC.1 = 1
'*******************************************************************************
$include "ST7735_declarations.inc"
#if Sdcard = 1
$include "Config_MMCSD_HC.bas"
$include "Config_AVR-DOS.bas"
Call Init_sd_card()
#endif
#if Sdcard = 0
Config Portb.0 = Output 'auch wenn nicht genutzt
Portb.0 = 1
Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = High , Phase = 1 , Clockrate = 4 , Noss = 1
Spsr = 1
Spiinit
#endif
'use for demo
Dim Xx As Byte , Yy As Byte , Temp As Byte , Yy1 As Byte , Xx1 As Byte , Col5 As Word , Teller As Byte
Call Lcd_init()
'*******************************************************************************
'Main
Do
'*******************************************************************************
'test landscape
'*******************************************************************************
#if Modus = 1
Call Lcd_clear(gray3)
Wait 1
Call Lcd_clear(black)
Call Lcd_text( "Font 6x10" , 5 , 20 , 4 , Red , Black)
Call Lcd_text( "Font 8x8" , 5 , 40 , 1 , Yellow , Black)
Call Lcd_text( "Font 8x12" , 5 , 60 , 3 , Green , Black)
Call Lcd_text( "Font 12x16" , 1 , 80 , 2 , Blue , Black)
Call Lcd_text( "Font 10x16" , 1 , 110 , 5 , Magenta , Black)
#if Sdcard = 1
Call Lcd_pic(0 , 0 , 160 , 127 , "160.bin")
Wait 2
Call Lcd_clear(black)
Call Lcd_pic(10 , 0 , 100 , 126 , "miki.bin")
Wait 2
Call Lcd_clear(black)
Call Lcd_pic(50 , 50 , 50 , 50 , "uhr1.bin")
Wait 2
Call Lcd_clear(black)
Call Lcd_pic(55 , 55 , 50 , 50 , "uhr1.bin")
Wait 2
#endif
Call Lcd_clear(red)
Call Lcd_box(10 , 10 , 50 , 50 , 1 , Yellow , Blue)
Call Lcd_line(10 , 64 , 100 , 100 , 4 , White)
Wait 3
Call Lcd_clear(black)
Call Lcd_clear(blue)
Wait 2
Call Lcd_line(0 , 0 , 159 , 0 , 1 , White)
Call Lcd_line(0 , 127 , 159 , 127 , 1 , White)
Call Lcd_line(0 , 0 , 0 , 127 , 1 , White)
Call Lcd_line(159 , 0 , 159 , 127 , 1 , White)
Wait 1
Call Lcd_clear(black)
Call Lcd_circle(80 , 64 , 40 , 1 , Green)
Wait 2
Call Lcd_clear(black)
Call Lcd_circle(80 , 64 , 40 , 0 , Green)
Wait 2
Call Lcd_clear(black)
Call Lcd_fill_circle(80 , 64 , 50 , Green)
Wait 2
Call Lcd_clear(black)
Call Lcd_clear(black)
Call Lcd_text( "Box Fill" , 10 , 2 , 3 , Yellow , Black)
For Temp = 1 To 10
Xx = 10 + Rnd(50)
Yy = 5 + Rnd(60)
Yy1 = 5 + Rnd(30)
Xx1 = 10 + Rnd(50)
Col5 = 1 + Rnd(10)
Call Lcd_box(xx , Yy , Xx1 , Yy1 , 1 , Color_array(col5) , Red)
Next
Wait 2
Call Lcd_clear(black)
Call Lcd_text( "Box with Border" , 5 , 2 , 3 , Yellow , Black)
For Temp = 1 To 10
Xx = 10 + Rnd(50)
Yy = 10 + Rnd(70)
Yy1 = 5 + Rnd(50)
Xx1 = 10 + Rnd(50)
Col5 = 1 + Rnd(10)
Call Lcd_box(xx , Yy , Xx1 , Yy1 , 2 , Color_array(col5) , Cyan0)
Next
Wait 2
Call Lcd_clear(black)
Call Lcd_text( "Box" , 10 , 2 , 3 , Yellow , Black)
For Temp = 1 To 10
Xx = 10 + Rnd(50)
Yy = 5 + Rnd(80)
Yy1 = 5 + Rnd(50)
Xx1 = 10 + Rnd(50)
Col5 = 1 + Rnd(10)
Call Lcd_box(xx , Yy , Xx1 , Yy1 , 3 , Color_array(col5) , Transparent)
Next
Wait 2
'-------------------------------------------------------------------------------
Call Lcd_clear(black)
For Teller = 1 To 5
Xx = 80
Xx1 = 4
Yy = 50
Yy1 = 4
For Temp = 1 To 10
Col5 = 1 + Rnd(10)
Call Lcd_box(xx , Yy , Xx1 , Yy1 , 3 , Color_array(col5) , Transparent)
Xx = Xx - 4
Xx1 = Xx1 + 8
Yy = Yy - 4
Yy1 = Yy1 + 8
Next Temp
Next Teller
Wait 1
#endif
'*******************************************************************************
'test Portrait
'*******************************************************************************
#if Modus = 0
Call Lcd_clear(black)
Call Lcd_clear(black)
Call Lcd_text( "Font 6x10" , 5 , 20 , 4 , Red , Black)
Call Lcd_text( "Font 8x8" , 5 , 40 , 1 , Yellow , Black)
Call Lcd_text( "Font 8x12" , 5 , 60 , 3 , Green , Black)
Call Lcd_text( "Font 12x16" , 1 , 80 , 2 , Blue , Black)
Call Lcd_text( "Font 10x16" , 1 , 110 , 5 , Magenta , Black)
Wait 2
Call Lcd_clear(red)
' Wait 2
Call Lcd_clear(blue)
Call Lcd_clear(black)
Call Lcd_text( "Line" , 40 , 2 , 3 , Yellow , Black)
Xx = 1
For Temp = 1 To 20
Xx = Xx + 6
Col5 = 1 + Rnd(10)
Call Lcd_line(1 , 1 , Xx , 160 , 1 , Color_array(col5))
Next
Xx = 128
For Temp = 1 To 20
Xx = Xx - 6
Col5 = 1 + Rnd(10)
Call Lcd_line(128 , 1 , Xx , 160 , 1 , Color_array(col5))
Next
Call Lcd_clear(black)
Call Lcd_text( "Line" , 40 , 2 , 3 , Yellow , Black)
Xx = 1
For Temp = 1 To 20
Xx = Xx + 6
Col5 = 1 + Rnd(10)
Call Lcd_line(1 , 1 , Xx , 160 , 2 , Color_array(col5))
Next
Xx = 128
For Temp = 1 To 20
Xx = Xx - 6
Col5 = 1 + Rnd(10)
Call Lcd_line(128 , 1 , Xx , 160 , 2 , Color_array(col5))
Next
Wait 2
'-------------------------------------------------------------------------------
Call Lcd_clear(black)
Call Lcd_text( "Circle fill" , 18 , 2 , 3 , Yellow , Black)
Yy1 = 50
Call Lcd_fill_circle(64 , 80 , Yy1 , Red)
For Temp = 1 To 10
Yy1 = Yy1 - 5
Col5 = 1 + Rnd(10)
Call Lcd_fill_circle(64 , 80 , Yy1 , Color_array(col5))
Next
Wait 2
Call Lcd_clear(black)
Call Lcd_text( "Circle" , 38 , 2 , 3 , Yellow , Black)
Yy1 = 60
Call Lcd_circle(64 , 80 , Yy1 , 0 , Red)
For Temp = 1 To 10
Yy1 = Yy1 - 5
Col5 = 1 + Rnd(10)
Call Lcd_circle(64 , 80 , Yy1 , 0 , Color_array(col5))
Next
Wait 2
'-------------------------------------------------------------------------------
Wait 1
Call Lcd_clear(black)
#if Sdcard = 1
Call Lcd_pic(11 , 5 , 106 , 150 , "klein.bin")
Wait 2
Call Lcd_clear(black)
Call Lcd_pic(10 , 10 , 50 , 50 , "uhr1.bin")
Call Lcd_pic(60 , 60 , 50 , 50 , "uhr1.bin")
Wait 2
Call Lcd_pic(0 , 0 , 127 , 160 , "011.bin")
Call Lcd_text( "Transparent" , 10 , 50 , 3 , Red , Transparent)
Wait 2
Call Lcd_pic(0 , 0 , 127 , 160 , "009.bin")
Wait 2
Call Lcd_pic(0 , 0 , 127 , 160 , "012.bin")
Wait 2
Call Lcd_pic(0 , 0 , 127 , 160 , "016.bin")
Wait 2
Call Lcd_pic(0 , 0 , 127 , 160 , "022.bin")
Wait 2
Call Lcd_pic(0 , 0 , 127 , 160 , "023.bin")
Wait 2
Call Lcd_pic(0 , 0 , 127 , 160 , "024.bin")
Wait 2
Call Lcd_pic(0 , 0 , 127 , 160 , "028.bin")
Wait 2
Call Lcd_pic(0 , 0 , 127 , 160 , "034.bin")
Wait 2
Call Lcd_pic(0 , 0 , 127 , 160 , "045.bin")
Wait 2
#endif
'-------------------------------------------------------------------------------
Call Lcd_clear(black)
Call Lcd_text( "Box Fill" , 10 , 2 , 3 , Yellow , Black)
For Temp = 1 To 10
Xx = 10 + Rnd(50)
Yy = 20 + Rnd(80)
Yy1 = 20 + Rnd(50)
Xx1 = 10 + Rnd(50)
Col5 = 1 + Rnd(10)
Call Lcd_box(xx , Yy , Xx1 , Yy1 , 1 , Color_array(col5) , Red)
Next
Wait 2
Call Lcd_clear(black)
Call Lcd_text( "Box with Border" , 5 , 2 , 3 , Yellow , Black)
For Temp = 1 To 10
Xx = 10 + Rnd(50)
Yy = 20 + Rnd(80)
Yy1 = 20 + Rnd(50)
Xx1 = 10 + Rnd(50)
Col5 = 1 + Rnd(10)
Call Lcd_box(xx , Yy , Xx1 , Yy1 , 2 , Color_array(col5) , Cyan0)
Next
Wait 2
Call Lcd_clear(black)
Call Lcd_text( "Box" , 10 , 2 , 3 , Yellow , Black)
For Temp = 1 To 10
Xx = 10 + Rnd(50)
Yy = 20 + Rnd(80)
Yy1 = 20 + Rnd(50)
Xx1 = 10 + Rnd(50)
Col5 = 1 + Rnd(10)
Call Lcd_box(xx , Yy , Xx1 , Yy1 , 3 , Color_array(col5) , Transparent)
Next
Wait 2
'-------------------------------------------------------------------------------
Call Lcd_clear(black)
For Teller = 1 To 5
Xx = 62
Xx1 = 4
Yy = 78
Yy1 = 4
For Temp = 1 To 15
Col5 = 1 + Rnd(10)
Call Lcd_box(xx , Yy , Xx1 , Yy1 , 3 , Color_array(col5) , Transparent)
Xx = Xx - 4
Xx1 = Xx1 + 8
Yy = Yy - 4
Yy1 = Yy1 + 8
Next Temp
Next Teller
Wait 1
#endif
Loop
End
'*******************************************************************************
$include "ST7735_functions.inc"
#if Sdcard = 1
$include "SD_card_init.inc"
#endif
$include "Font\Font12x16.font"
$include "Font\Font8x8.font"
$include "Font\font8x12.font"
$include "Font\font6x10.font"
$include "Font\font10x16.font"
'*******************************************************************************