Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

1.44 "Red Series LCD module 128 * 128 TFT color

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here
View previous topic :: View next topic  
Author Message
jure_m

Bascom Member



Joined: 14 Jan 2005
Posts: 68
Location: Ljubljana

slovenia.gif
PostPosted: Sat Jan 14, 2017 12:09 pm    Post subject: 1.44 "Red Series LCD module 128 * 128 TFT color Reply with quote

Hi,

this is modified code from this page: http://bascomforum.de/

Details on modifications are described in the SW.

Best regards
Jure
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5922
Location: Holland

blank.gif
PostPosted: Sat Jan 14, 2017 9:24 pm    Post subject: Reply with quote

Thank you for sharing the mods Jure. And of course Hkipnik for his original work on this LCD.
_________________
Mark
Back to top
View user's profile Visit poster's website
gyimezs

Bascom Member



Joined: 23 Mar 2006
Posts: 6

hungary.gif
PostPosted: Thu Aug 31, 2017 6:43 pm    Post subject: Reply with quote

I bought some red board on the ebay:
http://www.ebay.com/itm/1-44-128-128-SPI-TFT-LCD-Module-Replace-Nokia-5110-LCD-51-M52-/301724405979

Jure_m's modified software is not working with this boards, because after reading chip id, it is ILI9163, not ST7735.

ILI9163 and ST7735 are very similar, but ILI9163 need different initialization process.

So, here is the modified initialization code in "ST7735_functions.inc" for ILI9163:
Code:

Sub Lcd_init()

 Lcd_reset = 0
 Waitms 150
 Lcd_reset = 1
 Waitms 150

'Software reset
 Call Lcd_write_command(&H01)
 Waitms 150

'Stand-by off
 Call Lcd_write_command(&H11)
 Waitms 500

'Idle mode off
 Call Lcd_write_command(&H38)

'Display inversion off
 Call Lcd_write_command(&H20)

'Normal display on
 Call Lcd_write_command(&H13)

'Misc. settings
'Interface pixel format
 Call Lcd_write_command(&H3A)
 Call Lcd_write_data(&H55)
'D55h for 16 bit colors
'D53h for 12 bit colors
'D66h for 18 bit colors

'Memory Access Control
 Call Lcd_write_command(&H36)
 Call Lcd_write_data(&HC0)

'Display on
 Call Lcd_write_command(&H29)
 Waitms 100
End Sub
 
Back to top
View user's profile
ampervadasz78

Bascom Member



Joined: 14 Jul 2016
Posts: 3

hungary.gif
PostPosted: Thu Dec 17, 2020 10:54 am    Post subject: New subrutin ST7735 Reply with quote

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&#337;
Const Disp_typ = 0                                          'RGB order 0=Black Tab   1=Red Tab
'*********************************************************************************

Config Sda = PortD.1
Config Scl = PortD.0
Config I2cdelay = 10


'          Kijelz&#337; 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&#337; fájlok behívása

$include "ST7735_szubrutin.inc"
'
'*********************************************************************************
'            Kijelz&#337; 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"
 
Back to top
View user's profile AIM Address
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum