ampervadasz78
Joined: 14 Jul 2016 Posts: 3
|
Posted: Thu Dec 17, 2020 10:54 am Post subject: New subrutin ST7735 |
|
|
Insert ST7735_functions.inc
Code: |
'*********************************************************************************
' Draw Rbox (Lekerekített négyzet)
'*********************************************************************************
Sub Lcd_rbox(byval Xstart As Byte , Byval Ystart As Byte , Byval X_length As Byte , Byval Y_height As Byte , Byval Radius As Byte , Byval Color As Word)
Local Xe As Byte , Ye As Byte , Rad as Byte , Yp as byte , Xp as byte , X0 As Byte , Y0 As Byte
Local Error As Integer , Lenght as byte , Hight as byte
Xe = Xstart + X_length
Ye = Ystart + Y_height
If Radius = 0 Then
Call Lcd_line(xstart , Ystart , Xe , Ystart , 1 , Color)
Call Lcd_line(xstart , Ye , Xe , Ye , 1 , Color)
Call Lcd_line(xstart , Ystart , Xstart , Ye , 1 , Color)
Call Lcd_line(xe , Ystart , Xe , Ye , 1 , Color)
Elseif Radius <> 0 Then
Lenght = X_length / 2
Hight = Y_height / 2
If Radius > Lenght then Radius = Lenght
If Radius > Hight then Radius = Hight
Xp = Radius
Error = -radius
Yp = 0
Call Lcd_line(xstart + Radius , Ystart , Xe - Radius , Ystart , 1 , Color)
Call Lcd_line(xstart + Radius , Ye , Xe - Radius , Ye , 1 , Color)
Call Lcd_line(xstart , Ystart + Radius , Xstart , Ye - Radius , 1 , Color)
Call Lcd_line(xe , Ystart + Radius , Xe , Ye - Radius , 1 , Color)
While Xp >= Yp
X0 = Xstart -Yp : Y0 = Ystart -Xp
X0 = X0 + Radius : Y0 = Y0 + Radius '10,5h -9h
Call Lcd_set_pixel(X0 , Y0 , Color)
'
X0 = Xstart - Xp : Y0 = Ystart - Yp '9h-10,5h
X0 = X0 + Radius : Y0 = Y0 + Radius
Call Lcd_set_pixel(X0 , Y0 , Color)
X0 = Xstart + Yp : Y0 = Ystart - Xp
X0 = X0 + X_length : X0 = X0 - Radius : Y0 = Y0 + Radius
Call Lcd_set_pixel(X0 , Y0 , Color)
X0 = Xstart + Xp : Y0 = Ystart - Yp
X0 = X0 + X_length : X0 = X0 - Radius : Y0 = Y0 + Radius
Call Lcd_set_pixel(X0 , Y0 , Color)
X0 = Xstart + Xp : Y0 = Ystart + Yp
X0 = X0 + X_length : X0 = X0 - Radius : Y0 = Y0 - Radius : Y0 = Y0 + Y_height
Call Lcd_set_pixel(X0 , Y0 , Color)
X0 = Xstart + Yp : Y0 = Ystart + Xp
X0 = X0 + X_length : X0 = X0 - Radius : Y0 = Y0 - Radius : Y0 = Y0 + Y_height
Call Lcd_set_pixel(X0 , Y0 , Color)
X0 = Xstart -Yp : Y0 = Ystart + Xp
X0 = X0 + Radius : Y0 = Y0 + Y_height : Y0 = Y0 - Radius
Call Lcd_set_pixel(X0 , Y0 , Color)
X0 = Xstart - Xp : Y0 = Ystart + Yp
X0 = X0 + Radius : Y0 = Y0 + Y_height : Y0 = Y0 - Radius
Call Lcd_set_pixel(X0 , Y0 , Color)
Error = Error + Yp
Incr Yp
Error = Error + Yp
If Error >= 0 Then
Decr Xp
Error = Error - Xp
Error = Error - Xp
End If
Wend
End If
#if Modus = 1
Call Lcd_set_window(0 , 0 , 161 , 129)
#else
Call Lcd_set_window(0 , 0 , 129 , 161)
#endif
End Sub
'*******************************************************************************
|
Insert ST7735_szubrutin.inc
Code: |
Declare Sub Lcd_rbox(byval Xstart As Byte , Byval Ystart As Byte , Byval X_length As Byte , Byval Y_height As Byte , Byval Radius As Byte , Byval Color As Word)
|
My BASCOM code:
Code: |
$regfile = "m128def.dat" 'ATMEGA 128-as mikrokontroller
$crystal = 8000000 '8MHz órajel frekvencia
$hwstack = 250
$swstack = 250
$framesize = 300
'*********************************************************************************
Const Sdcard = 0 'use SD Card = 1 no SD Card = 0
Const Modus = 1 '0=Álló 1=Fekvő
Const Disp_typ = 0 'RGB order 0=Black Tab 1=Red Tab
'*********************************************************************************
Config Sda = PortD.1
Config Scl = PortD.0
Config I2cdelay = 10
' Kijelző pinjeinek konfigurálása
Config Portb.6 = Output
Config Portb.5 = Output
Config Portb.4 = Output
Lcd_cs Alias Portb.6
Lcd_dc Alias Portb.4
Lcd_reset Alias Portb.5
Portb.6 = 1
'*********************************************************************************
' Külső fájlok behívása
$include "ST7735_szubrutin.inc"
'
'*********************************************************************************
' Kijelző konfigurálás és indítás
Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = High , Phase = 1 , Clockrate = 4 , Noss = 1
Spsr = 1 'SPI megszakítás engedélyezése (Atmega 48, 88, 168 esetén)
Spiinit
Dim a as byte
Call Lcd_init()
Call Lcd_clear(White)
Do
For a = 1 to 20
Call Lcd_rbox(0 , 0 , 160 , 128 , a , Blue)
Next
Call Lcd_rbox(10 , 10 , 50 , 50 , 10 , Red)
Call Lcd_rbox(65 , 20 , 20 , 20 , 20 , Green)
Call Lcd_rbox(15 , 80 , 20 , 40 , 0 , Brown)
Call Lcd_rbox(90 , 5 , 40 , 110 , 40 , Black)
Loop
End
$include "ST7735_functions.inc"
$include "Font\Font12x16.font"
$include "Font\Font8x8.font"
$include "Font\font6x10.font"
$include "Font\font10x16.font"
$include "Font\Font8x12.font"
|
|
|