📄 lcd.s
字号:
.dbline 153
; lcd_set_e(); // Write data to LCD
sbi 0x18,2
.dbline 154
; asm("nop");
nop
.dbline 155
; asm("nop");
nop
.dbline 156
; lcd_clear_e(); // Disable LCD
cbi 0x18,2
.dbline -2
L7:
.dbline 0 ; func end
ld R22,y+
ld R20,y+
ret
.dbsym r temp 20 c
.dbsym r Data 22 c
.dbend
.dbfunc e Init_LCD _Init_LCD fV
.even
_Init_LCD::
.dbline -1
.dbline 162
; }
; // ********************************* //
; // *** Initialize the LCD driver *** //
; // ********************************* //
; void Init_LCD(void)
; {
.dbline 163
; LCD_INIT();
xcall _LCD_INIT
.dbline 164
; LCD_WriteControl (LCD_FUNCTION_SET);
ldi R16,40
xcall _LCD_WriteControl
.dbline 165
; LCD_WriteControl (LCD_OFF);
ldi R16,8
xcall _LCD_WriteControl
.dbline 166
; LCD_WriteControl (LCD_CLEAR);
ldi R16,1
xcall _LCD_WriteControl
.dbline 167
; LCD_WriteControl (LCD_MODE_SET);
ldi R16,6
xcall _LCD_WriteControl
.dbline 168
; LCD_WriteControl (LCD_ON);
ldi R16,12
xcall _LCD_WriteControl
.dbline 169
; LCD_WriteControl (LCD_HOME);
ldi R16,2
xcall _LCD_WriteControl
.dbline -2
L8:
.dbline 0 ; func end
ret
.dbend
.dbfunc e LCD_Clear _LCD_Clear fV
.even
_LCD_Clear::
.dbline -1
.dbline 175
; }
; // ************************************************ //
; // *** Clear the LCD screen (also homes cursor) *** //
; // ************************************************ //
; void LCD_Clear(void)
; {
.dbline 176
; LCD_WriteControl(0x01);
ldi R16,1
xcall _LCD_WriteControl
.dbline -2
L9:
.dbline 0 ; func end
ret
.dbend
.dbfunc e LCD_Home _LCD_Home fV
.even
_LCD_Home::
.dbline -1
.dbline 182
; }
; // *********************************************** //
; // *** Position the LCD cursor at row 1, col 1 *** //
; // *********************************************** //
; void LCD_Home(void)
; {
.dbline 183
; LCD_WriteControl(0x02);
ldi R16,2
xcall _LCD_WriteControl
.dbline -2
L10:
.dbline 0 ; func end
ret
.dbend
.dbfunc e LCD_DisplayCharacter _LCD_DisplayCharacter fV
; Char -> R10
.even
_LCD_DisplayCharacter::
st -y,R10
mov R10,R16
.dbline -1
.dbline 189
; }
; // ****************************************************************** //
; // *** Display a single character, at the current cursor location *** //
; // ****************************************************************** //
; void LCD_DisplayCharacter (char Char)
; {
.dbline 190
; LCD_WriteData (Char);
mov R16,R10
xcall _LCD_WriteData
.dbline -2
L11:
.dbline 0 ; func end
ld R10,y+
ret
.dbsym r Char 10 c
.dbend
.dbfunc e LCD_DisplayString_F _LCD_DisplayString_F fV
; string -> R20,R21
; column -> R12
; row -> R10
.even
_LCD_DisplayString_F::
xcall push_xgset303C
mov R12,R18
mov R10,R16
ldd R20,y+6
ldd R21,y+7
.dbline -1
.dbline 196
; }
; // ********************************************************************* //
; // *** Display a string at the specified row and column, using FLASH *** //
; // ********************************************************************* //
; void LCD_DisplayString_F (char row, char column , unsigned char __flash *string)
; {
.dbline 197
; LCD_Cursor (row, column);
mov R18,R12
mov R16,R10
xcall _LCD_Cursor
xjmp L14
L13:
.dbline 199
; while (*string)
; {
.dbline 200
; LCD_DisplayCharacter (*string++);
movw R2,R20
subi R20,255 ; offset = 1
sbci R21,255
movw R30,R2
lpm R16,Z
xcall _LCD_DisplayCharacter
.dbline 201
; }
L14:
.dbline 198
movw R30,R20
lpm R2,Z
tst R2
brne L13
X1:
.dbline -2
L12:
.dbline 0 ; func end
xjmp pop_xgset303C
.dbsym r string 20 pc
.dbsym r column 12 c
.dbsym r row 10 c
.dbend
.dbfunc e LCD_DisplayString _LCD_DisplayString fV
; string -> R10,R11
; column -> R14
; row -> R12
.even
_LCD_DisplayString::
xcall push_xgset00FC
mov R14,R18
mov R12,R16
ldd R10,y+6
ldd R11,y+7
.dbline -1
.dbline 207
; }
; // ******************************************************************* //
; // *** Display a string at the specified row and column, using RAM *** //
; // ******************************************************************* //
; void LCD_DisplayString (char row, char column ,unsigned char *string)
; {
.dbline 208
; LCD_Cursor (row, column);
mov R18,R14
mov R16,R12
xcall _LCD_Cursor
xjmp L18
L17:
.dbline 210
; while (*string)
; LCD_DisplayCharacter (*string++);
movw R30,R10
ld R16,Z+
movw R10,R30
xcall _LCD_DisplayCharacter
L18:
.dbline 209
movw R30,R10
ldd R2,z+0
tst R2
brne L17
X2:
.dbline -2
L16:
.dbline 0 ; func end
xjmp pop_xgset00FC
.dbsym r string 10 pc
.dbsym r column 14 c
.dbsym r row 12 c
.dbend
.dbfunc e LCD_Cursor _LCD_Cursor fV
; column -> R20
; row -> R10
.even
_LCD_Cursor::
xcall push_xgsetF00C
mov R20,R18
mov R10,R16
.dbline -1
.dbline 216
; }
; // *************************************************** //
; // *** Position the LCD cursor at "row", "column". *** //
; // *************************************************** //
; void LCD_Cursor (char row, char column)
; {
.dbline 217
; switch (row) {
mov R22,R10
clr R23
cpi R22,1
ldi R30,0
cpc R23,R30
breq L24
X3:
cpi R22,2
ldi R30,0
cpc R23,R30
breq L25
X4:
cpi R22,3
ldi R30,0
cpc R23,R30
breq L26
X5:
cpi R22,4
ldi R30,0
cpc R23,R30
breq L27
X6:
xjmp L22
L24:
.dbline 218
; case 1: LCD_WriteControl (0x80 + column - 1); break;
mov R16,R20
subi R16,128 ; addi 128
subi R16,1
xcall _LCD_WriteControl
.dbline 218
xjmp L22
L25:
.dbline 219
; case 2: LCD_WriteControl (0xc0 + column - 1); break;
mov R16,R20
subi R16,64 ; addi 192
subi R16,1
xcall _LCD_WriteControl
.dbline 219
xjmp L22
L26:
.dbline 220
; case 3: LCD_WriteControl (0x94 + column - 1); break;
mov R16,R20
subi R16,108 ; addi 148
subi R16,1
xcall _LCD_WriteControl
.dbline 220
xjmp L22
L27:
.dbline 221
; case 4: LCD_WriteControl (0xd4 + column - 1); break;
mov R16,R20
subi R16,44 ; addi 212
subi R16,1
xcall _LCD_WriteControl
.dbline 221
.dbline 222
; default: break;
L22:
.dbline -2
L20:
.dbline 0 ; func end
xjmp pop_xgsetF00C
.dbsym r column 20 c
.dbsym r row 10 c
.dbend
.dbfunc e LCD_Cursor_On _LCD_Cursor_On fV
.even
_LCD_Cursor_On::
.dbline -1
.dbline 229
; }
; }
; // ************************** //
; // *** Turn the cursor on *** //
; // ************************** //
; void LCD_Cursor_On (void)
; {
.dbline 230
; LCD_WriteControl (LCD_CURS_ON);
ldi R16,13
xcall _LCD_WriteControl
.dbline -2
L28:
.dbline 0 ; func end
ret
.dbend
.dbfunc e LCD_Cursor_Off _LCD_Cursor_Off fV
.even
_LCD_Cursor_Off::
.dbline -1
.dbline 236
; }
; // *************************** //
; // *** Turn the cursor off *** //
; // *************************** //
; void LCD_Cursor_Off (void)
; {
.dbline 237
; LCD_WriteControl (LCD_ON);
ldi R16,12
xcall _LCD_WriteControl
.dbline -2
L29:
.dbline 0 ; func end
ret
.dbend
.dbfunc e LCD_Display_Off _LCD_Display_Off fV
.even
_LCD_Display_Off::
.dbline -1
.dbline 243
; }
; // ******************** //
; // *** Turn Off LCD *** //
; // ******************** //
; void LCD_Display_Off (void)
; {
.dbline 244
; LCD_WriteControl(LCD_OFF);
ldi R16,8
xcall _LCD_WriteControl
.dbline -2
L30:
.dbline 0 ; func end
ret
.dbend
.dbfunc e LCD_Display_On _LCD_Display_On fV
.even
_LCD_Display_On::
.dbline -1
.dbline 250
; }
; // ******************* //
; // *** Turn On LCD *** //
; // ******************* //
; void LCD_Display_On (void)
; {
.dbline 251
; LCD_WriteControl(LCD_ON);
ldi R16,12
xcall _LCD_WriteControl
.dbline -2
L31:
.dbline 0 ; func end
ret
.dbend
; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -