Füge Funktion zum Anhalten hinzu
This commit is contained in:
49
main.asm
49
main.asm
@@ -7,16 +7,17 @@
|
|||||||
.include "./m328Pdef.inc"
|
.include "./m328Pdef.inc"
|
||||||
.list
|
.list
|
||||||
|
|
||||||
.def setter = R16
|
.def setter = R16
|
||||||
.def overflows = R17
|
.def overflows = R17
|
||||||
.def active_led = R18
|
.def active_led = R18
|
||||||
.def btn_status = R19
|
.def btn_status = R19
|
||||||
.def cur_direction = R20
|
.def cur_direction = R20
|
||||||
|
|
||||||
.equ L2R = 0x01
|
.equ L2R = 0x01
|
||||||
.equ R2L = 0x04
|
.equ R2L = 0x04
|
||||||
.equ RBTN_PRESSED = 0b00000100
|
.equ RBTN_PRESSED = 0b00000100
|
||||||
.equ LBTN_PRESSED = 0b00000001
|
.equ LBTN_PRESSED = 0b00000001
|
||||||
|
.equ BOTH_PRESSED = 0b00000101
|
||||||
|
|
||||||
.org 0x0000
|
.org 0x0000
|
||||||
rjmp init
|
rjmp init
|
||||||
@@ -93,13 +94,41 @@ overflow_handler:
|
|||||||
; Setze definierten Start für den
|
; Setze definierten Start für den
|
||||||
; Laufrichtungswechsel
|
; Laufrichtungswechsel
|
||||||
;----
|
;----
|
||||||
cpi btn_status, LBTN_PRESSED
|
check_left_btn:
|
||||||
brne PC+2
|
cpi btn_status, LBTN_PRESSED
|
||||||
ldi cur_direction, L2R
|
brne check_right_btn
|
||||||
|
|
||||||
cpi btn_status, RBTN_PRESSED
|
; Linker Button wurde gedrückt
|
||||||
brne PC+2
|
ldi cur_direction, L2R
|
||||||
|
in setter, PORTD
|
||||||
|
cpi setter, 0
|
||||||
|
brne run_animation
|
||||||
|
|
||||||
|
; Lauflicht wurde zuvor gestopped und muss neu initialisiert werden
|
||||||
|
ldi setter, 0b00000001
|
||||||
|
out PORTD, setter
|
||||||
|
rjmp run_animation
|
||||||
|
|
||||||
|
check_right_btn:
|
||||||
|
cpi btn_status, RBTN_PRESSED
|
||||||
|
brne check_both_btn
|
||||||
|
|
||||||
|
; Rechter Button wurde gedrückt
|
||||||
ldi cur_direction, R2L
|
ldi cur_direction, R2L
|
||||||
|
in setter, PORTD
|
||||||
|
cpi setter, 0
|
||||||
|
brne run_animation
|
||||||
|
|
||||||
|
; Lauflicht wurde zuvor gestopped und muss neu initialisiert werden
|
||||||
|
ldi setter, 0b10000000
|
||||||
|
out PORTD, setter
|
||||||
|
rjmp run_animation
|
||||||
|
|
||||||
|
check_both_btn:
|
||||||
|
cpi btn_status, BOTH_PRESSED
|
||||||
|
brne run_animation
|
||||||
|
ldi setter, 0
|
||||||
|
out PORTD, setter
|
||||||
;------
|
;------
|
||||||
|
|
||||||
run_animation:
|
run_animation:
|
||||||
|
|||||||
Reference in New Issue
Block a user