diff -r 7feeaeb473b5 -r 88c930373d62 led7seg.s --- a/led7seg.s Wed May 05 23:54:56 2010 +0300 +++ b/led7seg.s Thu May 06 00:13:54 2010 +0300 @@ -163,15 +163,17 @@ ; Load char lpm r16, Z + + ;; Continue +;; Display a raw segment mask +;; Input: r16 +LCD_ShowRaw: ; Invert com r16 ; Display - rcall SPI_Send - - ; Done - ret + rjmp SPI_Send ;; Delay for approx. 1s Delay_1s: @@ -190,6 +192,71 @@ ret +;; Count down from 9 +; Returns once we've hit zero +Main_Countdown: + ; init from 9 + ldi r24, LCD_9 + +loop: + ; display + mov r16, r24 + rcall LCD_Show + + ; exit if zero + tst r24 + ret + + ; count down + dec r24 + + ; wait... + rcall Delay_1s + + ; next + rjmp loop + +;; Blink between dot and empty +Main_Blink: +_blink_loop: + ; dot + ldi r16, LCD_DOT + rcall LCD_Show + + ; wait... + rcall Delay_1s + + ; empty + ldi r16, LCD_EMPTY + rcall LCD_Show + + rcall Delay_1s + + ; loop + rjmp _blink_loop + +;; Chase segments +Main_Spin: +_spin_init: + ; init from top + ldi r24, 0b00000001 + +_spin_next: + ; display + mov r16, r24 + rcall LCD_ShowRaw + + ; wait + rcall Delay_1s + + ; next segment + lsl r24 + + ; go back to A if we hit G + sbrc r24, 6 + rjmp _spin_init + + rjmp _spin_next Main: init: @@ -207,47 +274,10 @@ ; LCD (requires interrupts) rcall LCD_Init - -;; Count down from 9 -count: - ; init from 9 - ldi r24, LCD_9 - -loop: - ; display - mov r16, r24 - rcall LCD_Show - - ; exit if zero - tst r24 - breq blink - - ; count down - dec r24 - - ; wait... - rcall Delay_1s - - ; next - rjmp loop - -;; Blink between dot and empty -blink: - rcall Delay_1s - - ; dot - ldi r16, LCD_DOT - rcall LCD_Show - - ; wait... - rcall Delay_1s - - ; empty - ldi r16, LCD_EMPTY - rcall LCD_Show - - ; loop - rjmp blink + + ; Run + ; spin! + rcall Main_Spin end: rjmp end