📄 1335.s
字号:
.even
_lcd_clear_graphics::
st -y,R20
st -y,R21
.dbline -1
.dbline 242
; }
;
;
; /***********************************************************************
; Clears the graphic layer / screen.
; ***********************************************************************/
; void lcd_clear_graphics(void)
; {
.dbline 244
; int i;
; lcd_write_command(0x46);
ldi R16,70
xcall _lcd_write_command
.dbline 245
; lcd_write_data(0x00);
clr R16
xcall _lcd_write_data
.dbline 246
; lcd_write_data(0x10);
ldi R16,16
xcall _lcd_write_data
.dbline 247
; lcd_write_command(0x42);
ldi R16,66
xcall _lcd_write_command
.dbline 248
; for (i=0; i<((LCD_X_SIZE/8)*LCD_Y_SIZE); i++) lcd_write_data(0x00);
clr R20
clr R21
L32:
.dbline 248
clr R16
xcall _lcd_write_data
L33:
.dbline 248
subi R20,255 ; offset = 1
sbci R21,255
.dbline 248
cpi R20,128
ldi R30,37
cpc R21,R30
brlt L32
X6:
.dbline 249
; lcd_write_command(0x46);
ldi R16,70
xcall _lcd_write_command
.dbline 250
; lcd_write_data(0x00);
clr R16
xcall _lcd_write_data
.dbline 251
; lcd_write_data(0x10);
ldi R16,16
xcall _lcd_write_data
.dbline -2
L31:
.dbline 0 ; func end
ld R21,y+
ld R20,y+
ret
.dbsym r i 20 I
.dbend
.dbfunc e lcd_pixel _lcd_pixel fV
; Offset -> R20
; byte -> R10
; high -> R12
; low -> R14
; Address -> R22,R23
; show -> y+10
; y -> R22,R23
; x -> R20,R21
.even
_lcd_pixel::
xcall push_xgsetF0FC
movw R22,R18
movw R20,R16
.dbline -1
.dbline 260
; }
;
;
; /***********************************************************************
; Write pixel data to the display at specified position.
; Set show to 1 to draw pixel, set to 0 to hide pixel.
; ***********************************************************************/
; void lcd_pixel(int x, int y, unsigned char show)
; {
.dbline 266
; unsigned int Address;
; unsigned char Offset;
; unsigned char low;
; unsigned char high;
; unsigned char byte;
; x--;
subi R20,1
sbci R21,0
.dbline 267
; y--;
subi R22,1
sbci R23,0
.dbline 268
; Address = (y * (LCD_X_SIZE/8)) + (x / 8);
ldi R18,8
ldi R19,0
movw R16,R20
xcall div16s
movw R2,R16
ldi R16,40
ldi R17,0
movw R18,R22
xcall empy16s
movw R22,R16
add R22,R2
adc R23,R3
.dbline 269
; Offset = x - ((x / 8) * 8);
ldi R18,8
ldi R19,0
movw R16,R20
xcall div16s
movw R2,R16
lsl R2
rol R3
lsl R2
rol R3
lsl R2
rol R3
sub R20,R2
sbc R21,R3
.dbline 270
; low = (unsigned char) (Address & 0x00ff);
movw R24,R22
andi R25,0
mov R14,R24
.dbline 271
; high = (unsigned char) (((Address & 0xff00) >> 8) + 0x10);
movw R24,R22
andi R24,0
mov R24,R25
clr R25
adiw R24,16
mov R12,R24
.dbline 272
; lcd_write_command(0x46);
ldi R16,70
xcall _lcd_write_command
.dbline 273
; lcd_write_data(low);
mov R16,R14
xcall _lcd_write_data
.dbline 274
; lcd_write_data(high);
mov R16,R12
xcall _lcd_write_data
.dbline 275
; lcd_write_command(0x43);
ldi R16,67
xcall _lcd_write_command
.dbline 276
; byte = lcd_read_data();
xcall _lcd_read_data
mov R10,R16
.dbline 277
; if (show != 0) byte |= (0x80 >> Offset);
ldd R0,y+10
tst R0
breq L37
X7:
.dbline 277
mov R18,R20
clr R19
ldi R16,128
ldi R17,0
xcall asr16
mov R2,R10
clr R3
or R2,R16
or R3,R17
mov R10,R2
xjmp L38
L37:
.dbline 278
; else byte &= (~(0x80 >> Offset));
mov R18,R20
clr R19
ldi R16,128
ldi R17,0
xcall asr16
movw R2,R16
com R2
com R3
mov R4,R10
clr R5
and R4,R2
and R5,R3
mov R10,R4
L38:
.dbline 279
; lcd_write_command(0x46);
ldi R16,70
xcall _lcd_write_command
.dbline 280
; lcd_write_data(low);
mov R16,R14
xcall _lcd_write_data
.dbline 281
; lcd_write_data(high);
mov R16,R12
xcall _lcd_write_data
.dbline 282
; lcd_write_command(0x42);
ldi R16,66
xcall _lcd_write_command
.dbline 283
; lcd_write_data(byte);
mov R16,R10
xcall _lcd_write_data
.dbline -2
L36:
.dbline 0 ; func end
xjmp pop_xgsetF0FC
.dbsym r Offset 20 c
.dbsym r byte 10 c
.dbsym r high 12 c
.dbsym r low 14 c
.dbsym r Address 22 i
.dbsym l show 10 c
.dbsym r y 22 I
.dbsym r x 20 I
.dbend
.dbfunc e lcd_rectangle _lcd_rectangle fV
; i -> R20,R21
; show -> R10
; y2 -> R12,R13
; x2 -> R14,R15
; y1 -> y+11
; x1 -> R22,R23
.even
_lcd_rectangle::
st -y,r19
st -y,r18
xcall push_xgsetF0FC
movw R22,R16
sbiw R28,1
ldd R14,y+13
ldd R15,y+14
ldd R12,y+15
ldd R13,y+16
ldd R10,y+17
.dbline -1
.dbline 292
; }
;
;
; /***********************************************************************
; Draws a rectangle from x1,y1 to x2,y2.
; Set show to 1 to draw pixel, set to 0 to hide pixel.
; ***********************************************************************/
; void lcd_rectangle(int x1, int y1, int x2, int y2, unsigned char show)
; {
.dbline 294
; int i;
; for (i=x1; i<=x2; i++) lcd_pixel(i,y1,show);
movw R20,R22
xjmp L43
L40:
.dbline 294
std y+0,R10
ldd R18,y+11
ldd R19,y+12
movw R16,R20
xcall _lcd_pixel
L41:
.dbline 294
subi R20,255 ; offset = 1
sbci R21,255
L43:
.dbline 294
cp R14,R20
cpc R15,R21
brge L40
X8:
.dbline 295
; for (i=x1; i<=x2; i++) lcd_pixel(i,y2,show);
movw R20,R22
xjmp L47
L44:
.dbline 295
std y+0,R10
movw R18,R12
movw R16,R20
xcall _lcd_pixel
L45:
.dbline 295
subi R20,255 ; offset = 1
sbci R21,255
L47:
.dbline 295
cp R14,R20
cpc R15,R21
brge L44
X9:
.dbline 296
; for (i=y1; i<=y2; i++) lcd_pixel(x1,i,show);
ldd R20,y+11
ldd R21,y+12
xjmp L51
L48:
.dbline 296
std y+0,R10
movw R18,R20
movw R16,R22
xcall _lcd_pixel
L49:
.dbline 296
subi R20,255 ; offset = 1
sbci R21,255
L51:
.dbline 296
cp R12,R20
cpc R13,R21
brge L48
X10:
.dbline 297
; for (i=y1; i<=y2; i++) lcd_pixel(x2,i,show);
ldd R20,y+11
ldd R21,y+12
xjmp L55
L52:
.dbline 297
std y+0,R10
movw R18,R20
movw R16,R14
xcall _lcd_pixel
L53:
.dbline 297
subi R20,255 ; offset = 1
sbci R21,255
L55:
.dbline 297
cp R12,R20
cpc R13,R21
brge L52
X11:
.dbline -2
L39:
.dbline 0 ; func end
adiw R28,1
xcall pop_xgsetF0FC
adiw R28,2
ret
.dbsym r i 20 I
.dbsym r show 10 c
.dbsym r y2 12 I
.dbsym r x2 14 I
.dbsym l y1 11 I
.dbsym r x1 22 I
.dbend
.dbfunc e lcd_degree_line _lcd_degree_line fV
; ty -> R20,R21
; tx -> R14,R15
; fy -> R12,R13
; fx -> R10,R11
; show -> y+23
; outer_radius -> R22,R23
; inner_radius -> R12,R13
; degree -> R20,R21
; y -> y+15
; x -> R14,R15
.even
_lcd_degree_line::
st -y,r19
st -y,r18
xcall push_xgsetF0FC
movw R14,R16
sbiw R28,5
ldd R20,y+17
ldd R21,y+18
ldd R12,y+19
ldd R13,y+20
ldd R22,y+21
ldd R23,y+22
.dbline -1
.dbline 306
; }
;
;
; /***********************************************************************
; Draws a line from x,y at given degree from inner_radius to outer_radius.
; Set show to 1 to draw pixel, set to 0 to hide pixel.
; ***********************************************************************/
; void lcd_degree_line(int x, int y, int degree, int inner_radius, int outer_radius, unsigned char show)
; {
.dbline 308
; int fx,fy,tx,ty;
; fx = x + fround(inner_radius * sin(degree * 3.14 / 180));
ldi R16,<L57
ldi R17,>L57
xcall elpm32
movw R2,R16
movw R4,R18
movw R16,R20
xcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R16,R2
movw R18,R4
xcall fpmule2
movw R2,R16
movw R4,R18
ldi R16,<L58
ldi R17,>L58
xcall elpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R16,R2
movw R18,R4
xcall fpdiv2
xcall _sinf
movw R2,R16
movw R4,R18
movw R16,R12
xcall int2fp
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall fpmule2
xcall _froundf
movw R2,R16
movw R4,R18
movw R16,R14
xcall int2fp
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall fpadd2
xcall fpint
movw R10,R16
.dbline 309
; fy = y - fround(inner_radius * cos(degree * 3.14 / 180));
ldi R16,<L57
ldi R17,>L57
xcall elpm32
movw R2,R16
movw R4,R18
movw R16,R20
xcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R16,R2
movw R18,R4
xcall fpmule2
movw R2,R16
movw R4,R18
ldi R16,<L58
ldi R17,>L58
xcall elpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R16,R2
movw R18,R4
xcall fpdiv2
xcall _cosf
movw R2,R16
movw R4,R18
movw R16,R12
xcall int2fp
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall fpmule2
xcall _froundf
movw R2,R16
movw R4,R18
ldd R16,y+15
ldd R17,y+16
xcall int2fp
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall fpsub2
xcall fpint
movw R12,R16
.dbline 310
; tx = x + fround(outer_radius * sin(degree * 3.14 / 180));
ldi R16,<L57
ldi R17,>L57
xcall elpm32
movw R2,R16
movw R4,R18
movw R16,R20
xcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R16,R2
movw R18,R4
xcall fpmule2
movw R2,R16
movw R4,R18
ldi R16,<L58
ldi R17,>L58
xcall elpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R16,R2
movw R18,R4
xcall fpdiv2
xcall _sinf
movw R2,R16
movw R4,R18
movw R16,R22
xcall int2fp
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall fpmule2
xcall _froundf
movw R2,R16
movw R4,R18
movw R16,R14
xcall int2fp
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall fpadd2
xcall fpint
movw R14,R16
.dbline 311
; ty = y - fround(outer_radius * cos(degree * 3.14 / 180));
ldi R16,<L57
ldi R17,>L57
xcall elpm32
movw R2,R16
movw R4,R18
movw R16,R20
xcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R16,R2
movw R18,R4
xcall fpmule2
movw R2,R16
movw R4,R18
ldi R16,<L58
ldi R17,>L58
xcall elpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R16,R2
movw R18,R4
xcall fpdiv2
xcall _cosf
movw R2,R16
movw R4,R18
movw R16,R22
xcall int2fp
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall fpmule2
xcall _froundf
movw R2,R16
movw R4,R18
ldd R16,y+15
ldd R17,y+16
xcall int2fp
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall fpsub2
xcall fpint
movw R20,R16
.dbline 312
; lcd_line(fx,fy,tx,ty,show);
ldd R0,y+23
std y+4,R0
std y+3,R21
std y+2,R20
std y+1,R15
std y+0,R14
movw R18,R12
movw R16,R10
xcall _lcd_line
.dbline -2
L56:
.dbline 0 ; func end
adiw R28,5
xcall pop_xgsetF0FC
adiw R28,2
ret
.dbsym r ty 20 I
.dbsym r tx 14 I
.dbsym r fy 12 I
.dbsym r fx 10 I
.dbsym l show 23 c
.dbsym r outer_radius 22 I
.dbsym r inner_radius 12 I
.dbsym r degree 20 I
.dbsym l y 15 I
.dbsym r x 14 I
.dbend
.dbfunc e lcd_circle _lcd_circle fV
; p -> R12,R13
; yc -> R22,R23
; xc -> R20,R21
; show -> R10
; radius -> R12,R13
; y -> y+13
; x -> y+11
.even
_lcd_circle::
xcall push_arg4
xcall push_xgsetF0FC
sbiw R28,1
ldd R12,y+15
ldd R13,y+16
ldd R10,y+17
.dbline -1
.dbline 321
; }
;
;
; /***********************************************************************
; Draws a circle with center at x,y with given radius.
; Set show to 1 to draw pixel, set to 0 to hide pixel.
; ***********************************************************************/
; void lcd_circle(int x, int y, int radius, unsigned char show)
; {
.dbline 322
; int xc = 0;
clr R20
clr R21
.dbline 323
; int yc = radius;
movw R22,R12
.dbline 324
; int p = 3 - (radius<<1);
movw R2,R12
lsl R2
rol R3
ldi R24,3
ldi R25,0
movw R12,R24
sub R12,R2
sbc R13,R3
xjmp L61
L60:
.dbline 326
; while (xc <= yc)
; {
.dbline 327
; lcd_pixel(x + xc, y + yc, show);
std y+0,R10
ldd R18,y+13
ldd R19,y+14
add R18,R22
adc R19,R23
ldd R16,y+11
ldd R17,y+12
add R16,R20
adc R17,R21
xcall _lcd_pixel
.dbline 328
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -