lcddrive.lis
来自「Atmega64单片机程序(完整工程)」· LIS 代码 · 共 1,014 行 · 第 1/3 页
LIS
1,014 行
026C ; LCD_SendData(0x02);
026C 02E0 ldi R16,2
026E 16DF xcall _LCD_SendData
0270 ; LCD_SendData(0x03);
0270 03E0 ldi R16,3
0272 14DF xcall _LCD_SendData
0274 ; LCD_SendData(0x04);
0274 04E0 ldi R16,4
0276 12DF xcall _LCD_SendData
0278 ; LCD_SendData(0x05);
0278 05E0 ldi R16,5
027A 10DF xcall _LCD_SendData
027C ; LCD_SendData(0x06);
027C 06E0 ldi R16,6
027E 0EDF xcall _LCD_SendData
0280 ; LCD_SendData(0x08);
0280 08E0 ldi R16,8
0282 0CDF xcall _LCD_SendData
0284 ; LCD_SendData(0x0f);
0284 0FE0 ldi R16,15
0286 0ADF xcall _LCD_SendData
0288 ; //blue
0288 ; LCD_SendData(0x00);
0288 0027 clr R16
028A 08DF xcall _LCD_SendData
028C ; LCD_SendData(0x03);
028C 03E0 ldi R16,3
028E 06DF xcall _LCD_SendData
0290 ; LCD_SendData(0x06);
0290 06E0 ldi R16,6
0292 04DF xcall _LCD_SendData
0294 ; LCD_SendData(0x0f);
0294 0FE0 ldi R16,15
0296 02DF xcall _LCD_SendData
0298 ; LCD_DataOver();
0298 A99A sbi 0x15,1
029A ; LCD_Delay();
029A B2DE xcall _LCD_Delay
029C ;
029C ; LCD_SendCommand(0x25); //write contrast
029C 05E2 ldi R16,37
029E C0DE xcall _LCD_SendCommand
02A0 ; LCD_SendData(63);
02A0 0FE3 ldi R16,63
02A2 FCDE xcall _LCD_SendData
02A4 ; LCD_DataOver();
02A4 A99A sbi 0x15,1
02A6 ; LCD_Delay();
02A6 ACDE xcall _LCD_Delay
02A8 ;
02A8 ; LCD_BGColor = 0x00;
02A8 2224 clr R2
02AA 20920100 sts _LCD_BGColor,R2
02AE ; //LCD_PenColor = 0x1f;
02AE ; LCD_PenColor = 0b11111100; //blue
02AE 8CEF ldi R24,252
02B0 80930000 sts _LCD_PenColor,R24
02B4 L41:
02B4 0E940000 xcall pop_gset1
02B8 .dbline 0 ; func end
02B8 0895 ret
02BA ; y -> R20
02BA ; x -> R22
.even
02BA _LCD_ClearScreen::
02BA 0E940000 xcall push_gset2
02BE ; }
02BE ;
02BE ; void LCD_ClearScreen(void)
02BE ; {
02BE ; INT8U x, y;
02BE ; LCD_SendCommand(0x2a); //column address set
02BE 0AE2 ldi R16,42
02C0 AFDE xcall _LCD_SendCommand
02C2 ; LCD_SendData(0);
02C2 0027 clr R16
02C4 EBDE xcall _LCD_SendData
02C6 ; LCD_SendData(LCD_XSIZE);
02C6 01E6 ldi R16,97
02C8 E9DE xcall _LCD_SendData
02CA ; LCD_DataOver();
02CA A99A sbi 0x15,1
02CC ;
02CC ; LCD_SendCommand(0x2b); //page address set
02CC 0BE2 ldi R16,43
02CE A8DE xcall _LCD_SendCommand
02D0 ; LCD_SendData(0);
02D0 0027 clr R16
02D2 E4DE xcall _LCD_SendData
02D4 ; LCD_SendData(LCD_YSIZE);
02D4 04E4 ldi R16,68
02D6 E2DE xcall _LCD_SendData
02D8 ; LCD_DataOver();
02D8 A99A sbi 0x15,1
02DA ;
02DA ; LCD_SendCommand(0x2c); //memory write
02DA 0CE2 ldi R16,44
02DC A1DE xcall _LCD_SendCommand
02DE ; for(y = 0; y < LCD_YSIZE; y ++)
02DE 4427 clr R20
02E0 09C0 xjmp L50
02E2 L47:
02E2 ; for(x = 0; x < LCD_XSIZE; x ++)
02E2 6627 clr R22
02E4 04C0 xjmp L54
02E6 L51:
02E6 00910100 lds R16,_LCD_BGColor
02EA D8DE xcall _LCD_SendData
02EC L52:
02EC 6395 inc R22
02EE L54:
02EE 6136 cpi R22,97
02F0 D0F3 brlo L51
02F2 L48:
02F2 4395 inc R20
02F4 L50:
02F4 4434 cpi R20,68
02F6 A8F3 brlo L47
02F8 ; LCD_SendData(LCD_BGColor);
02F8 ; LCD_DataOver();
02F8 A99A sbi 0x15,1
02FA L46:
02FA 0E940000 xcall pop_gset2
02FE .dbline 0 ; func end
02FE 0895 ret
0300 ; Color -> y+4
0300 ; y -> R20
0300 ; x -> R22
.even
0300 _LCD_DrawPoint::
0300 0E940000 xcall push_gset2
0304 422F mov R20,R18
0306 602F mov R22,R16
0308 ; }
0308 ;
0308 ; /*-------------------读LCD数据----------------------------*/
0308 ; /*
0308 ; INT8U LCD_ReadData(void)
0308 ; {
0308 ; INT8U r = 0;
0308 ;
0308 ; clr_bit(LCD_SIO_DDR, LCD_SIO); //set SDI.DDR = 0
0308 ; set_bit(LCD_SIO_PORT,LCD_SIO);
0308 ;
0308 ; clr_bit(LCD_CS_PORT, LCD_CS); //set CS = L
0308 ;
0308 ; //Bit 0(MSB)
0308 ; clr_bit(LCD_SCL_PORT,LCD_SCL);
0308 ; set_bit(LCD_SCL_PORT,LCD_SCL);
0308 ; if(get_bit(LCD_SIO_PIN, LCD_SIO))
0308 ; r |= 0x80;
0308 ; else
0308 ; r &= ~0x80;
0308 ;
0308 ; //Bit 1
0308 ; clr_bit(LCD_SCL_PORT, LCD_SCL);
0308 ; set_bit(LCD_SCL_PORT, LCD_SCL);
0308 ; if(get_bit(LCD_SIO_PIN, LCD_SIO))
0308 ; r |= 0x40;
0308 ; else
0308 ; r &= ~0x40;
0308 ;
0308 ; //Bit 2
0308 ; clr_bit(LCD_SCL_PORT, LCD_SCL);
0308 ; set_bit(LCD_SCL_PORT, LCD_SCL);
0308 ; if(get_bit(LCD_SIO_PIN, LCD_SIO))
0308 ; r |= 0x20;
0308 ; else
0308 ; r &= ~0x20;
0308 ;
0308 ; //Bit 3
0308 ; clr_bit(LCD_SCL_PORT, LCD_SCL);
0308 ; set_bit(LCD_SCL_PORT, LCD_SCL);
0308 ; if(get_bit(LCD_SIO_PIN, LCD_SIO))
0308 ; r |= 0x10;
0308 ; else
0308 ; r &= ~0x10;
0308 ;
0308 ; //Bit 4
0308 ; clr_bit(LCD_SCL_PORT, LCD_SCL);
0308 ; set_bit(LCD_SCL_PORT, LCD_SCL);
0308 ; if(get_bit(LCD_SIO_PIN, LCD_SIO))
0308 ; r |= 0x08;
0308 ; else
0308 ; r &= ~0x08;
0308 ;
0308 ; //Bit 5
0308 ; clr_bit(LCD_SCL_PORT, LCD_SCL);
0308 ; set_bit(LCD_SCL_PORT, LCD_SCL);
0308 ; if(get_bit(LCD_SIO_PIN, LCD_SIO))
0308 ; r |= 0x04;
0308 ; else
0308 ; r &= ~0x04;
0308 ;
0308 ; //Bit 6
0308 ; clr_bit(LCD_SCL_PORT, LCD_SCL);
0308 ; set_bit(LCD_SCL_PORT, LCD_SCL);
0308 ; if(get_bit(LCD_SIO_PIN, LCD_SIO))
0308 ; r |= 0x02;
0308 ; else
0308 ; r &= ~0x02;
0308 ;
0308 ; //Bit 7(LSB)
0308 ; clr_bit(LCD_SCL_PORT, LCD_SCL);
0308 ; set_bit(LCD_SCL_PORT, LCD_SCL);
0308 ; if(get_bit(LCD_SIO_PIN, LCD_SIO))
0308 ; r |= 0x01;
0308 ; else
0308 ; r &= ~0x01;
0308 ; //done
0308 ; return r;
0308 ; }
0308 ;
0308 ; INT8U LCD_ReadState(void)
0308 ; {
0308 ; return 0;
0308 ; }
0308 ;
0308 ; void lcdSetPage(INT8U page)
0308 ; {
0308 ;
0308 ; }
0308 ;
0308 ; void lcdSetRow(INT8U row)
0308 ; {
0308 ;
0308 ; }*/
0308 ;
0308 ; void LCD_DrawPoint(INT8U x,INT8U y,INT8U Color)
0308 ; {
0308 ; LCD_SendCommand(0x2a); //column address set
0308 0AE2 ldi R16,42
030A 8ADE xcall _LCD_SendCommand
030C ; LCD_SendData(x);
030C 062F mov R16,R22
030E C6DE xcall _LCD_SendData
0310 ; //LCD_SendData(x);
0310 ; LCD_DataOver();
0310 A99A sbi 0x15,1
0312 ;
0312 ; LCD_SendCommand(0x2b); //page address set
0312 0BE2 ldi R16,43
0314 85DE xcall _LCD_SendCommand
0316 ; LCD_SendData(y);
0316 042F mov R16,R20
0318 C1DE xcall _LCD_SendData
031A ; //LCD_SendData(y);
031A ; LCD_DataOver();
031A A99A sbi 0x15,1
031C ;
031C ; LCD_SendCommand(0x2c); //memory write
031C 0CE2 ldi R16,44
031E 80DE xcall _LCD_SendCommand
0320 ; LCD_SendData(Color);
0320 0C81 ldd R16,y+4
0322 BCDE xcall _LCD_SendData
0324 ; LCD_DataOver();
0324 A99A sbi 0x15,1
0326 L55:
0326 0E940000 xcall pop_gset2
032A .dbline 0 ; func end
032A 0895 ret
032C ; line -> R20
032C ; y0 -> R22
032C ; x0 -> R10
032C ; DisplayData -> R12
.even
032C _LCD_Display_Locate::
032C 0E940000 xcall push_gset4
0330 A22E mov R10,R18
0332 C02E mov R12,R16
0334 2197 sbiw R28,1
0336 6985 ldd R22,y+9
0338 ; }
0338 ; /*
0338 ; *****************************************************************************
0338 ; * Display_Locate - LCD上指定位置 显示指定数据
0338 ; * @Param x0:0--96 横向坐标
0338 ; * @Param y0:0--63 纵向坐标
0338 ; * @Param DisplayData:写入的数据
0338 ; *****************************************************************************
0338 ; */
0338 ; void LCD_Display_Locate(INT8U DisplayData,INT8U x0,INT8U y0)
0338 ; {
0338 ; INT8U line;
0338 ;
0338 ; //if( x0>=LCD_XSIZE)
0338 ; // x0=x0%LCD_XSIZE;
0338 ;
0338 ; //if( y0>=LCD_YSIZE)
0338 ; // y0=y0%LCD_YSIZE;
0338 ;
0338 ; for(line=0;line<8;line++)
0338 4427 clr R20
033A 17C0 xjmp L60
033C L57:
033C ; {
033C ; if( get_bit(DisplayData,line) )
033C 01E0 ldi R16,1
033E 142F mov R17,R20
0340 0E940000 xcall lsl8
0344 2C2C mov R2,R12
0346 2022 and R2,R16
0348 41F0 breq L61
034A ; LCD_DrawPoint(x0,y0+line,LCD_PenColor);
034A 20900000 lds R2,_LCD_PenColor
034E 2882 std y+0,R2
0350 262F mov R18,R22
0352 240F add R18,R20
0354 0A2D mov R16,R10
0356 D4DF xcall _LCD_DrawPoint
0358 07C0 xjmp L62
035A L61:
035A ; else
035A ; LCD_DrawPoint(x0,y0+line,LCD_BGColor);
035A 20900100 lds R2,_LCD_BGColor
035E 2882 std y+0,R2
0360 262F mov R18,R22
0362 240F add R18,R20
0364 0A2D mov R16,R10
0366 CCDF xcall _LCD_DrawPoint
0368 L62:
0368 L58:
0368 4395 inc R20
036A L60:
036A 4830 cpi R20,8
036C 38F3 brlo L57
036E L56:
036E 2196 adiw R28,1
0370 0E940000 xcall pop_gset4
0374 .dbline 0 ; func end
0374 0895 ret
.area bss(ram, con, rel)
0000 _LCD_PenColor::
0000 .blkb 1
0001 _LCD_BGColor::
0001 .blkb 1
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?