📄 lcddrive.s
字号:
ldi R16,90
xcall _LCD_SendData
; LCD_SendData(100);
ldi R16,100
xcall _LCD_SendData
; LCD_SendData(110);
ldi R16,110
xcall _LCD_SendData
; LCD_SendData(127);
ldi R16,127
xcall _LCD_SendData
; LCD_DataOver();
sbi 0x15,1
; LCD_Delay();
xcall _LCD_Delay
;
; LCD_SendCommand(0xb5); //gamma curve set
ldi R16,181
xcall _LCD_SendCommand
; LCD_SendData(0x01);
ldi R16,1
xcall _LCD_SendData
; LCD_DataOver();
sbi 0x15,1
; LCD_Delay();
xcall _LCD_Delay
;
; LCD_SendCommand(0x36); //memery access control
ldi R16,54
xcall _LCD_SendCommand
; LCD_SendData(0x00);
clr R16
xcall _LCD_SendData
; LCD_DataOver();
sbi 0x15,1
; LCD_Delay();
xcall _LCD_Delay
;
; LCD_SendCommand(0xbd); //common driver output select//很重要的
ldi R16,189
xcall _LCD_SendCommand
; LCD_SendData(0x04);
ldi R16,4
xcall _LCD_SendData
; LCD_DataOver();
sbi 0x15,1
; LCD_Delay();
xcall _LCD_Delay
;
; LCD_SendCommand(0xbe); //power control
ldi R16,190
xcall _LCD_SendCommand
; LCD_SendData(0x04);
ldi R16,4
xcall _LCD_SendData
; LCD_DataOver();
sbi 0x15,1
; LCD_Delay();
xcall _LCD_Delay
;
; LCD_SendCommand(0x11); //sleep out
ldi R16,17
xcall _LCD_SendCommand
; LCD_DataOver();
sbi 0x15,1
; LCD_Delay();
xcall _LCD_Delay
;
; LCD_SendCommand(0xba); //voltage control
ldi R16,186
xcall _LCD_SendCommand
; LCD_SendData(127);
ldi R16,127
xcall _LCD_SendData
; LCD_SendData(3);
ldi R16,3
xcall _LCD_SendData
; LCD_DataOver();
sbi 0x15,1
; LCD_Delay();
xcall _LCD_Delay
;
; LCD_SendCommand(0xb7); //temperature gradient set
ldi R16,183
xcall _LCD_SendCommand
; for(i = 0; i < 14; i ++)
clr R20
xjmp L45
L42:
clr R16
xcall _LCD_SendData
L43:
inc R20
L45:
cpi R20,14
brlo L42
; LCD_SendData(0x00);
; LCD_DataOver();
sbi 0x15,1
; LCD_Delay();
xcall _LCD_Delay
;
; LCD_SendCommand(0x29); //display ON
ldi R16,41
xcall _LCD_SendCommand
; LCD_DataOver();
sbi 0x15,1
; LCD_Delay();
xcall _LCD_Delay
;
; LCD_SendCommand(0x03); //booster voltage ON
ldi R16,3
xcall _LCD_SendCommand
; LCD_DataOver();
sbi 0x15,1
; LCD_Delay();
xcall _LCD_Delay
;
; LCD_SendCommand(0x20); //display inversion OFF
ldi R16,32
xcall _LCD_SendCommand
; LCD_DataOver();
sbi 0x15,1
; LCD_Delay();
xcall _LCD_Delay
;
; LCD_SendCommand(0x3a); //interface pixel format
ldi R16,58
xcall _LCD_SendCommand
; LCD_SendData(0x02);
ldi R16,2
xcall _LCD_SendData
; LCD_DataOver();
sbi 0x15,1
; LCD_Delay();
xcall _LCD_Delay
;
; LCD_SendCommand(0x2d); //colour set
ldi R16,45
xcall _LCD_SendCommand
; //red
; LCD_SendData(0x00);
clr R16
xcall _LCD_SendData
; LCD_SendData(0x02);
ldi R16,2
xcall _LCD_SendData
; LCD_SendData(0x03);
ldi R16,3
xcall _LCD_SendData
; LCD_SendData(0x04);
ldi R16,4
xcall _LCD_SendData
; LCD_SendData(0x05);
ldi R16,5
xcall _LCD_SendData
; LCD_SendData(0x06);
ldi R16,6
xcall _LCD_SendData
; LCD_SendData(0x08);
ldi R16,8
xcall _LCD_SendData
; //green
; LCD_SendData(0x0f);
ldi R16,15
xcall _LCD_SendData
; LCD_SendData(0x00);
clr R16
xcall _LCD_SendData
; LCD_SendData(0x02);
ldi R16,2
xcall _LCD_SendData
; LCD_SendData(0x03);
ldi R16,3
xcall _LCD_SendData
; LCD_SendData(0x04);
ldi R16,4
xcall _LCD_SendData
; LCD_SendData(0x05);
ldi R16,5
xcall _LCD_SendData
; LCD_SendData(0x06);
ldi R16,6
xcall _LCD_SendData
; LCD_SendData(0x08);
ldi R16,8
xcall _LCD_SendData
; LCD_SendData(0x0f);
ldi R16,15
xcall _LCD_SendData
; //blue
; LCD_SendData(0x00);
clr R16
xcall _LCD_SendData
; LCD_SendData(0x03);
ldi R16,3
xcall _LCD_SendData
; LCD_SendData(0x06);
ldi R16,6
xcall _LCD_SendData
; LCD_SendData(0x0f);
ldi R16,15
xcall _LCD_SendData
; LCD_DataOver();
sbi 0x15,1
; LCD_Delay();
xcall _LCD_Delay
;
; LCD_SendCommand(0x25); //write contrast
ldi R16,37
xcall _LCD_SendCommand
; LCD_SendData(63);
ldi R16,63
xcall _LCD_SendData
; LCD_DataOver();
sbi 0x15,1
; LCD_Delay();
xcall _LCD_Delay
;
; LCD_BGColor = 0x00;
clr R2
sts _LCD_BGColor,R2
; //LCD_PenColor = 0x1f;
; LCD_PenColor = 0b11111100; //blue
ldi R24,252
sts _LCD_PenColor,R24
L41:
xcall pop_gset1
.dbline 0 ; func end
ret
; y -> R20
; x -> R22
.even
_LCD_ClearScreen::
xcall push_gset2
; }
;
; void LCD_ClearScreen(void)
; {
; INT8U x, y;
; LCD_SendCommand(0x2a); //column address set
ldi R16,42
xcall _LCD_SendCommand
; LCD_SendData(0);
clr R16
xcall _LCD_SendData
; LCD_SendData(LCD_XSIZE);
ldi R16,97
xcall _LCD_SendData
; LCD_DataOver();
sbi 0x15,1
;
; LCD_SendCommand(0x2b); //page address set
ldi R16,43
xcall _LCD_SendCommand
; LCD_SendData(0);
clr R16
xcall _LCD_SendData
; LCD_SendData(LCD_YSIZE);
ldi R16,68
xcall _LCD_SendData
; LCD_DataOver();
sbi 0x15,1
;
; LCD_SendCommand(0x2c); //memory write
ldi R16,44
xcall _LCD_SendCommand
; for(y = 0; y < LCD_YSIZE; y ++)
clr R20
xjmp L50
L47:
; for(x = 0; x < LCD_XSIZE; x ++)
clr R22
xjmp L54
L51:
lds R16,_LCD_BGColor
xcall _LCD_SendData
L52:
inc R22
L54:
cpi R22,97
brlo L51
L48:
inc R20
L50:
cpi R20,68
brlo L47
; LCD_SendData(LCD_BGColor);
; LCD_DataOver();
sbi 0x15,1
L46:
xcall pop_gset2
.dbline 0 ; func end
ret
; Color -> y+4
; y -> R20
; x -> R22
.even
_LCD_DrawPoint::
xcall push_gset2
mov R20,R18
mov R22,R16
; }
;
; /*-------------------读LCD数据----------------------------*/
; /*
; INT8U LCD_ReadData(void)
; {
; INT8U r = 0;
;
; clr_bit(LCD_SIO_DDR, LCD_SIO); //set SDI.DDR = 0
; set_bit(LCD_SIO_PORT,LCD_SIO);
;
; clr_bit(LCD_CS_PORT, LCD_CS); //set CS = L
;
; //Bit 0(MSB)
; clr_bit(LCD_SCL_PORT,LCD_SCL);
; set_bit(LCD_SCL_PORT,LCD_SCL);
; if(get_bit(LCD_SIO_PIN, LCD_SIO))
; r |= 0x80;
; else
; r &= ~0x80;
;
; //Bit 1
; clr_bit(LCD_SCL_PORT, LCD_SCL);
; set_bit(LCD_SCL_PORT, LCD_SCL);
; if(get_bit(LCD_SIO_PIN, LCD_SIO))
; r |= 0x40;
; else
; r &= ~0x40;
;
; //Bit 2
; clr_bit(LCD_SCL_PORT, LCD_SCL);
; set_bit(LCD_SCL_PORT, LCD_SCL);
; if(get_bit(LCD_SIO_PIN, LCD_SIO))
; r |= 0x20;
; else
; r &= ~0x20;
;
; //Bit 3
; clr_bit(LCD_SCL_PORT, LCD_SCL);
; set_bit(LCD_SCL_PORT, LCD_SCL);
; if(get_bit(LCD_SIO_PIN, LCD_SIO))
; r |= 0x10;
; else
; r &= ~0x10;
;
; //Bit 4
; clr_bit(LCD_SCL_PORT, LCD_SCL);
; set_bit(LCD_SCL_PORT, LCD_SCL);
; if(get_bit(LCD_SIO_PIN, LCD_SIO))
; r |= 0x08;
; else
; r &= ~0x08;
;
; //Bit 5
; clr_bit(LCD_SCL_PORT, LCD_SCL);
; set_bit(LCD_SCL_PORT, LCD_SCL);
; if(get_bit(LCD_SIO_PIN, LCD_SIO))
; r |= 0x04;
; else
; r &= ~0x04;
;
; //Bit 6
; clr_bit(LCD_SCL_PORT, LCD_SCL);
; set_bit(LCD_SCL_PORT, LCD_SCL);
; if(get_bit(LCD_SIO_PIN, LCD_SIO))
; r |= 0x02;
; else
; r &= ~0x02;
;
; //Bit 7(LSB)
; clr_bit(LCD_SCL_PORT, LCD_SCL);
; set_bit(LCD_SCL_PORT, LCD_SCL);
; if(get_bit(LCD_SIO_PIN, LCD_SIO))
; r |= 0x01;
; else
; r &= ~0x01;
; //done
; return r;
; }
;
; INT8U LCD_ReadState(void)
; {
; return 0;
; }
;
; void lcdSetPage(INT8U page)
; {
;
; }
;
; void lcdSetRow(INT8U row)
; {
;
; }*/
;
; void LCD_DrawPoint(INT8U x,INT8U y,INT8U Color)
; {
; LCD_SendCommand(0x2a); //column address set
ldi R16,42
xcall _LCD_SendCommand
; LCD_SendData(x);
mov R16,R22
xcall _LCD_SendData
; //LCD_SendData(x);
; LCD_DataOver();
sbi 0x15,1
;
; LCD_SendCommand(0x2b); //page address set
ldi R16,43
xcall _LCD_SendCommand
; LCD_SendData(y);
mov R16,R20
xcall _LCD_SendData
; //LCD_SendData(y);
; LCD_DataOver();
sbi 0x15,1
;
; LCD_SendCommand(0x2c); //memory write
ldi R16,44
xcall _LCD_SendCommand
; LCD_SendData(Color);
ldd R16,y+4
xcall _LCD_SendData
; LCD_DataOver();
sbi 0x15,1
L55:
xcall pop_gset2
.dbline 0 ; func end
ret
; line -> R20
; y0 -> R22
; x0 -> R10
; DisplayData -> R12
.even
_LCD_Display_Locate::
xcall push_gset4
mov R10,R18
mov R12,R16
sbiw R28,1
ldd R22,y+9
; }
; /*
; *****************************************************************************
; * Display_Locate - LCD上指定位置 显示指定数据
; * @Param x0:0--96 横向坐标
; * @Param y0:0--63 纵向坐标
; * @Param DisplayData:写入的数据
; *****************************************************************************
; */
; void LCD_Display_Locate(INT8U DisplayData,INT8U x0,INT8U y0)
; {
; INT8U line;
;
; //if( x0>=LCD_XSIZE)
; // x0=x0%LCD_XSIZE;
;
; //if( y0>=LCD_YSIZE)
; // y0=y0%LCD_YSIZE;
;
; for(line=0;line<8;line++)
clr R20
xjmp L60
L57:
; {
; if( get_bit(DisplayData,line) )
ldi R16,1
mov R17,R20
xcall lsl8
mov R2,R12
and R2,R16
breq L61
; LCD_DrawPoint(x0,y0+line,LCD_PenColor);
lds R2,_LCD_PenColor
std y+0,R2
mov R18,R22
add R18,R20
mov R16,R10
xcall _LCD_DrawPoint
xjmp L62
L61:
; else
; LCD_DrawPoint(x0,y0+line,LCD_BGColor);
lds R2,_LCD_BGColor
std y+0,R2
mov R18,R22
add R18,R20
mov R16,R10
xcall _LCD_DrawPoint
L62:
L58:
inc R20
L60:
cpi R20,8
brlo L57
L56:
adiw R28,1
xcall pop_gset4
.dbline 0 ; func end
ret
.area bss(ram, con, rel)
_LCD_PenColor::
.blkb 1
_LCD_BGColor::
.blkb 1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -