bulat | Дата: Пятница, 10.06.2016, 20:31 | Сообщение # 2 |
Группа: Проверенные
Сообщений: 110
Статус: Offline
| Итак,инициализация удалась,подпрограммы взял от какогото ILI9...,пришлось переписывать,дисплей переливается зеленым и красным цветом,работает очистка экрана и установка курсора в определенную позицию Сделал вывод цифр и букв,библиотеку шрифтов взял от нокиа5110,так шрифт 5*8,пришлось сделать 10*16(математич умножение) жаль это никого не интересует,я пожалуй ухожу в подполье-видимо это никому не надо программа в спойлере не знаю как добавить в спойлер...вот $regfile = "m328pdef.dat" $crystal = 16000000 $hwstack = 250 $swstack = 250 $framesize = 300 'Display
' CS --> portb.0 ' DC --> portb.1 ' reset --> portb.2 ' Mosi --> portb.3 ' SCLK-->portb.5 ' Lite --> +5V Config Portb.0 = Output 'Display CS Config Portb.1 = Output 'Display DC Config Portb.2 = Output 'Display reset Lcd_cs Alias Portb.0 Lcd_dc Alias Portb.1 Lcd_reset Alias Portb.2 Portb.0 = 1 Config Spi = Soft , Dout = Portb.3 , Ss = None , Clock = Portb.5 ' Din = None , Spiinit Declare Sub Lcd_init() Declare Sub Lcd_command(byval Command As Byte) Declare Sub Lcd_data(byval Da_ta As Byte) Declare Sub Lcd_write_color(byval Color As Word) Declare Sub Lcd_set_window(byval Xs As Byte , Byval Ys As Byte , Byval Xe As Byte , Byval Ye As Byte) Declare Sub Lcd_set(byval Xs As Byte , Byval Ys As Byte) Declare Sub Lcd_clear(byval Color As Word) Declare Sub Lcd_set_pixel(byval X As Byte , Byval Y As Byte , Byval Color As Word) Declare Sub Lcd_text(byval D3310string As String * 14 , Byval Xs As Byte , Byval Ys As Byte ) Const Transparent = &H1000 Const синий = &H001F Const зеленый = &H07E0 Const красный = &HF800 Const белый = &HFFFF Const серый = &H0000 Const черный = &H0000 '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 , Pix As Word
Call Lcd_init() '******************************************************************************* Call Lcd_clear(черный)
CALL Lcd_text( "HELLO WORD" , 1 , 10 ) Wait 3 Do CALL Lcd_text( "433.925" , 1 , 50 ) Wait 3 CALL Lcd_text( "HELLO WORD" , 100 , 100 ) Wait 3
Call Lcd_clear(черный) Loop End '******************************************************************************* 'УСТАНОВКА КУРСОРА ВЗЯТО ОТСЮДА http://forum.easyelectronics.ru/viewtopic.php?t=13281 '******************************************************************************* Sub Lcd_set(byval Xs As Byte , Byval Ys As Byte ) ' , Byval Xe As Byte , Byval Ye As Byte Call Lcd_command(&H2a) 'column set x Call Lcd_data(&H00) Call Lcd_data(xs) 'start
Call Lcd_command(&H2b) 'row set y Call Lcd_data(&H00) Call Lcd_data(ys) 'Start
Call Lcd_command(&H2c) 'write to ram End Sub 'ОЧИСТКА ДИСПЛЕЯ И ЗАЛИВКА ЦВЕТОМ '******************************************************************************* Sub Lcd_clear(byval Color As Word) Local Zahl As Word Local Hb As Byte , Lb As Byte Hb = High(color) Lb = Low(color) Call Lcd_set(0 , 0) Lcd_cs = 0 Lcd_dc = 1 For Zahl = 1 To 20480 '20480 Spiout Hb , 1 Spiout Lb , 1 Next Lcd_cs = 1 End Sub ' ПОСТАВИТЬ ТОЧКУ '******************************************************************************* Sub Lcd_write_color(byval Color As Word) Local Coll As Byte , Colh As Byte Coll = Low(color) Colh = High(color) Lcd_cs = 0 Lcd_dc = 1 Spiout Colh , 1 Spiout Coll , 1 Lcd_cs = 1 End Sub '******************************************************************************* Sub Lcd_command(byval Command As Byte) Lcd_cs = 0 Lcd_dc = 0 Spiout Command , 1 Lcd_cs = 1 End Sub '******************************************************************************* ' send Data '******************************************************************************* Sub Lcd_data(byval Da_ta As Byte) Lcd_cs = 0 Lcd_dc = 1 Spiout Da_ta , 1 Lcd_cs = 1 End Sub '******************************************************************************* ' ИНИЦИАЛИЗАЦИЯ,ВЗЯТО ОТСЮДА http://www.avrki.ru/articles/content/st7735_stm32/ '******************************************************************************* Sub Lcd_init() Lcd_reset = 0 Waitms 10 Lcd_reset = 1 Waitms 10 Call Lcd_command(&H11) 'ПРОСЫПАЕМСЯ Waitms 10 Call Lcd_command(&H3a) 'режим цвета Call Lcd_data(&H05) ' 16 бит
Call Lcd_command(&H36) 'направление вывода изображения: Call Lcd_data(&H14) ' снизу вверх, справа на лево, порядок цветов RGB
Call Lcd_command(&H29) ' включаем изображение Lcd_cs = 1
End Sub
Sub Lcd_text(byval D3310string As String * 14 , byval Xs As Byte , Byval Ys As Byte ) Local XS_ As Byte : XS_ = XS Local YS_ As Byte : YS_ = YS Local cikl As Byte Local D3310length As Byte 'Holds the length of D3310string Local D3310character As String * 1 'Holds each consecutive character in turn during display output Local D3310stringloop As Byte 'Loop variable for the string Local D3310columnloop As Byte 'Loop variable for the columns Local D3310column As Byte 'Display column output D3310length = Len(d3310string) 'Establish the number of characters For D3310stringloop = 1 To D3310length 'Loop through the string D3310character = Mid(d3310string , D3310stringloop , 1) 'Get the current character Select Case D3310character 'Position the pointer to the correct character in the Eeprom and read the first byte Case "0" : Restore Zero Case "1" : Restore One Case "2" : Restore Two Case "3" : Restore Three Case "4" : Restore Four Case "5" : Restore Five Case "6" : Restore Six Case "7" : Restore Seven Case "8" : Restore Eight Case "9" : Restore Nine Case "A" : Restore A Case "B" : Restore B Case "C" : Restore C Case "D" : Restore D Case "E" : Restore E Case "F" : Restore F Case "G" : Restore G Case "H" : Restore H Case "I" : Restore I Case "J" : Restore J Case "K" : Restore K Case "L" : Restore L Case "M" : Restore M Case "N" : Restore N Case "O" : Restore O Case "P" : Restore P Case "Q" : Restore Q Case "R" : Restore R Case "S" : Restore S Case "T" : Restore T Case "U" : Restore U Case "V" : Restore V Case "W" : Restore W Case "X" : Restore X Case "Y" : Restore Y Case "Z" : Restore Z Case "Е" : Restore Aa Case "Д" : Restore Ae Case "Ц" : Restore Oe Case "a" : Restore A1 Case "b" : Restore B1 Case "c" : Restore C1 Case "d" : Restore D1 Case "e" : Restore E1 Case "f" : Restore F1 Case "g" : Restore G1 Case "h" : Restore H1 Case "i" : Restore I1 Case "j" : Restore J1 Case "k" : Restore K1 Case "l" : Restore L1 Case "m" : Restore M1 Case "n" : Restore N1 Case "o" : Restore O1 Case "p" : Restore P1 Case "q" : Restore Q1 Case "r" : Restore R111 Case "s" : Restore S1 Case "t" : Restore T1 Case "u" : Restore U1 Case "v" : Restore V1 Case "w" : Restore W1 Case "x" : Restore X1 Case "y" : Restore Y1 Case "z" : Restore Z1 Case "е" : Restore Aa1 Case "д" : Restore Ae1 Case "ц" : Restore Oe1 Case " " : Restore Spacesign Case "-" : Restore Dash Case "." : Restore Dot Case ":" : Restore Colon Case ">" : Restore Arrowright Case "°" : Restore Degree Case "@" : Restore Alpha Case "&" : Restore Ampersand Case "'" : Restore Apostrophe Case "<" : Restore Arrowleft Case "*" : Restore Asterisc Case "," : Restore Comma Case "$" : Restore Dollar Case "=" : Restore Equals Case "!" : Restore Exclamation Case "Ѕ" : Restore Grid Case "#" : Restore Hash Case "(" : Restore Leftparagraph Case "[" : Restore Leftsquareparagraph Case "%" : Restore Percent Case "+" : Restore Plus Case "^" : Restore Powerof Case "?" : Restore Question 'Case D3310quotation : Restore Quotation Case "]" : Restore Rightparagraph Case ")" : Restore Rightsquareparagraph Case ";" : Restore Semicolon Case "/" : Restore Slash Case "\" : Restore Backslash Case "_" : Restore Underscore End Select For D3310columnloop = 1 To 5 STEP 1 'Read and print each column Read D3310column ''XS_ = D3310columnloop * 2 'XS_ = XS + XS_ for cikl = 0 to 7 YS_ = CIKL * 2 YS_ = YS + YS_ '+ YS_ Call Lcd_set(XS , YS_) if D3310column.cikl = 1 then call Lcd_write_color(зеленый) call Lcd_write_color(зеленый) Call Lcd_set(XS , YS_ + 1) call Lcd_write_color(зеленый) call Lcd_write_color(зеленый)
'else 'call Lcd_write_color(серый) 'call Lcd_write_color(серый) 'Call Lcd_set(XS , YS_ + 1) 'call Lcd_write_color(серый) 'call Lcd_write_color(серый) END IF call Lcd_write_color(серый) call Lcd_write_color(серый)
' if D3310column.cikl = 1 then call Lcd_write_color(зеленый) else call Lcd_write_color(серый) ' Call Lcd_set(XS_ , YS_ + 1) ' if D3310column.cikl = 1 then call Lcd_write_color(зеленый) else call Lcd_write_color(серый) ' if D3310column.cikl = 1 then call Lcd_write_color(красный) else call Lcd_write_color(серый) next cikl XS = XS + 2 'Call Lcd_set(XS , YS + 8) ' call Lcd_write_color(серый) 'call Lcd_write_color(серый) 'call Lcd_write_color(серый) ' Next D3310columnloop
D3310column = 0 'And print a blank column for inter-character spacing call Lcd_write_color(серый) XS = XS + 1 Next D3310stringloop ' Lcd_cs = 1 'Display data input disable End Sub '=============================================================================== 'ASCII data 'Digits Zero: Data &H3E , &H51 , &H49 , &H45 , &H3E One: Data &H00 , &H42 , &H7F , &H40 , &H00 Two: Data &H42 , &H61 , &H51 , &H49 , &H46 Three: Data &H22 , &H41 , &H49 , &H49 , &H36 Four: Data &H18 , &H14 , &H12 , &H7F , &H10 Five: Data &H27 , &H45 , &H45 , &H45 , &H39 Six: Data &H3E , &H49 , &H49 , &H49 , &H32 Seven: Data &H61 , &H11 , &H09 , &H05 , &H03 Eight: Data &H36 , &H49 , &H49 , &H49 , &H36 Nine: Data &H26 , &H49 , &H49 , &H49 , &H3E 'Upper-case A: Data &H7E , &H09 , &H09 , &H09 , &H7E B: Data &H7F , &H49 , &H49 , &H49 , &H36 C: Data &H3E , &H41 , &H41 , &H41 , &H22 D: Data &H7F , &H41 , &H41 , &H41 , &H3E E: Data &H7F , &H49 , &H49 , &H49 , &H41 F: Data &H7F , &H09 , &H09 , &H09 , &H01 G: Data &H3E , &H41 , &H49 , &H49 , &H3A H: Data &H7F , &H08 , &H08 , &H08 , &H7F I: Data &H00 , &H41 , &H7F , &H41 , &H00 J: Data &H20 , &H41 , &H41 , &H41 , &H3F K: Data &H7F , &H08 , &H14 , &H22 , &H41 L: Data &H7F , &H40 , &H40 , &H40 , &H40 M: Data &H7F , &H02 , &H04 , &H02 , &H7F N: Data &H7F , &H04 , &H08 , &H10 , &H7F O: Data &H3E , &H41 , &H41 , &H41 , &H3E P: Data &H7F , &H09 , &H09 , &H09 , &H06 Q: Data &H3E , &H41 , &H51 , &H61 , &H7E R: Data &H7F , &H09 , &H19 , &H29 , &H46 S: Data &H06 , &H49 , &H49 , &H49 , &H30 T: Data &H01 , &H01 , &H7F , &H01 , &H01 U: Data &H3F , &H40 , &H40 , &H40 , &H3F V: Data &H1F , &H20 , &H40 , &H20 , &H1F W: Data &H7F , &H20 , &H10 , &H20 , &H7F X: Data &H63 , &H14 , &H08 , &H14 , &H63 Y: Data &H03 , &H04 , &H78 , &H04 , &H03 Z: Data &H61 , &H51 , &H49 , &H45 , &H43 Aa: Data &H78 , &H14 , &H15 , &H14 , &H78 Ae: Data &H78 , &H15 , &H14 , &H15 , &H78 Oe: Data &H38 , &H45 , &H44 , &H45 , &H38 A1: Data &H20 , &H54 , &H54 , &H54 , &H78 B1: Data &H7F , &H48 , &H44 , &H44 , &H38 C1: Data &H38 , &H44 , &H44 , &H44 , &H28 D1: Data &H38 , &H44 , &H44 , &H48 , &H7F E1: Data &H38 , &H54 , &H54 , &H54 , &H18 F1: Data &H00 , &H04 , &H7E , &H05 , &H00 G1: Data &H0C , &H52 , &H52 , &H4A , &H3C H1: Data &H7F , &H08 , &H04 , &H04 , &H78 I1: Data &H00 , &H44 , &H7D , &H40 , &H00 J1: Data &H00 , &H40 , &H44 , &H3D , &H00 K1: Data &H7F , &H20 , &H10 , &H28 , &H44 L1: Data &H00 , &H41 , &H7F , &H40 , &H00 M1: Data &H7C , &H04 , &H18 , &H04 , &H7C N1: Data &H7C , &H08 , &H04 , &H04 , &H78 O1: Data &H38 , &H44 , &H44 , &H44 , &H38 P1: Data &H7C , &H14 , &H24 , &H24 , &H18 Q1: Data &H18 , &H24 , &H24 , &H14 , &H7C R111: Data &H7C , &H04 , &H04 , &H08 , &H00 S1: Data &H08 , &H54 , &H54 , &H54 , &H20 T1: Data &H04 , &H3F , &H44 , &H40 , &H00 U1: Data &H3C , &H40 , &H40 , &H40 , &H7C V1: Data &H1C , &H20 , &H40 , &H20 , &H1C W1: Data &H3C , &H40 , &H30 , &H40 , &H3C X1: Data &H44 , &H28 , &H10 , &H28 , &H44 Y1: Data &H0C , &H50 , &H50 , &H48 , &H3C Z1: Data &H44 , &H64 , &H54 , &H4C , &H44 Aa1: Data &H20 , &H54 , &H55 , &H54 , &H78 Ae1: Data &H20 , &H55 , &H54 , &H55 , &H78 Oe1: Data &H38 , &H45 , &H44 , &H45 , &H38 Spacesign: Data &H00 , &H00 , &H00 , &H00 , &H00 Dot: Data &H00 , &H60 , &H60 , &H00 , &H00 Dash: Data &H08 , &H08 , &H08 , &H08 , &H08 Colon: Data &H00 , &H36 , &H36 , &H00 , &H00 Degree: Data &H00 , &H07 , &H05 , &H07 , &H00 Leftsquareparagraph: Data &H00 , &H7F , &H41 , &H41 , &H00 Rightsquareparagraph: Data &H00 , &H41 , &H41 , &H7F , &H00 Grid: Data &H55 , &H2A , &H55 , &H2A , &H55 Powerof: Data &H04 , &H02 , &H01 , &H02 , &H04 Underscore: Data &H40 , &H40 , &H40 , &H40 , &H40 Semicolon: Data &H00 , &H56 , &H36 , &H00 , &H00 Arrowleft: Data &H08 , &H1C , &H36 , &H63 , &H41 Arrowright: Data &H41 , &H63 , &H36 , &H1C , &H08 Equals: Data &H14 , &H14 , &H14 , &H14 , &H14 Question: Data &H02 , &H01 , &H51 , &H09 , &H06 Alpha: Data &H32 , &H49 , &H59 , &H51 , &H3E Exclamation: Data &H00 , &H00 , &H5F , &H00 , &H00 Quotation: Data &H00 , &H07 , &H00 , &H07 , &H00 Hash: Data &H14 , &H7F , &H14 , &H7F , &H14 Dollar: Data &H24 , &H2A , &H7F , &H2A , &H12 Percent: Data &H23 , &H13 , &H08 , &H64 , &H62 Ampersand: Data &H36 , &H49 , &H55 , &H22 , &H50 Apostrophe: Data &H00 , &H05 , &H03 , &H00 , &H00 Leftparagraph: Data &H00 , &H1C , &H22 , &H41 , &H00 Rightparagraph: Data &H00 , &H41 , &H22 , &H1C , &H00 Asterisc: Data &H14 , &H08 , &H3E , &H08 , &H14 Plus: Data &H08 , &H08 , &H3E , &H08 , &H08 Comma: Data &H00 , &H00 , &H50 , &H30 , &H00 Slash: Data &H20 , &H10 , &H08 , &H04 , &H02 Backslash: Data &H02 , &H04 , &H08 , &H10 , &H20
Сообщение отредактировал bulat - Пятница, 10.06.2016, 22:43 |
|
| |