Skip to content

Commit

Permalink
feat: Rework beeper routines and add a 5th beacon tone
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasvr committed Dec 28, 2020
1 parent 1b521c6 commit 5659d3b
Showing 1 changed file with 50 additions and 32 deletions.
82 changes: 50 additions & 32 deletions Bluejay.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2652,32 +2652,47 @@ comm61_rev:

;**** **** **** **** **** **** **** **** **** **** **** **** ****
;
; Beeper routines (4 different entry points)
; Beeper routines (Multiple entry points)
;
;**** **** **** **** **** **** **** **** **** **** **** **** ****
beep_f1: ; Entry point 1, load beeper frequency 1 settings
mov Temp3, #20 ; Off wait loop length
mov Temp4, #120 ; Number of beep pulses
beep_f1:
mov Temp3, #66 ; Off wait loop length (Tone)
mov Temp4, #(3500 / 66) ; Number of beep pulses (Duration)
sjmp beep

beep_f2: ; Entry point 2, load beeper frequency 2 settings
mov Temp3, #16
mov Temp4, #140
beep_f2:
mov Temp3, #45
mov Temp4, #(3500 / 45)
sjmp beep

beep_f3: ; Entry point 3, load beeper frequency 3 settings
mov Temp3, #13
mov Temp4, #180
beep_f3:
mov Temp3, #38
mov Temp4, #(3500 / 38)
sjmp beep

beep_f4: ; Entry point 4, load beeper frequency 4 settings
mov Temp3, #11
mov Temp4, #200
beep_f4:
mov Temp3, #25
mov Temp4, #(3500 / 25)
sjmp beep

beep: ; Beep loop start
beep_f5:
mov Temp3, #20
mov Temp4, #(3500 / 25)
sjmp beep

beep_f1_short:
mov Temp3, #66
mov Temp4, #(2000 / 66)
sjmp beep

beep_f2_short:
mov Temp3, #45
mov Temp4, #(2000 / 45)
sjmp beep

beep:
mov A, Beep_Strength
djnz ACC, beep_start
djnz ACC, beep_start ; Start if beep strength is not 1
ret

beep_start:
Expand All @@ -2695,20 +2710,20 @@ beep_onoff:
; Turn on pwmfet
mov A, Temp2
jb ACC.0, beep_apwmfet_on
ApwmFET_on ; ApwmFET on
ApwmFET_on
beep_apwmfet_on:
jnb ACC.0, beep_cpwmfet_on
CpwmFET_on ; CpwmFET on
CpwmFET_on
beep_cpwmfet_on:
mov A, Beep_Strength
djnz ACC, $
; Turn off pwmfet
mov A, Temp2
jb ACC.0, beep_apwmfet_off
ApwmFET_off ; ApwmFET off
ApwmFET_off
beep_apwmfet_off:
jnb ACC.0, beep_cpwmfet_off
CpwmFET_off ; CpwmFET off
CpwmFET_off
beep_cpwmfet_off:
mov A, #150 ; 25us off
djnz ACC, $
Expand All @@ -2717,10 +2732,12 @@ beep_cpwmfet_off:
mov A, Temp3
mov Temp1, A
beep_off: ; Fets off loop
mov A, #150
djnz ACC, $
djnz Temp1, beep_off
djnz Temp4, beep
BcomFET_off ; BcomFET off
djnz Temp4, beep_start

BcomFET_off
ret


Expand Down Expand Up @@ -3146,7 +3163,7 @@ beacon_beep4:
sjmp beacon_beep_exit

beacon_beep5:
call beep_f4
call beep_f5

beacon_beep_exit:
mov Temp2, #Pgm_Beep_Strength
Expand Down Expand Up @@ -3213,11 +3230,17 @@ pgm_start:
clr IE_EA ; Disable interrupts explicitly
call wait200ms
call beep_f1
call wait30ms
call wait10ms
call beep_f2
call wait30ms
call wait10ms
call beep_f1
call wait10ms
call beep_f3
call wait30ms
call wait200ms
call beep_f2
call beep_f4
call beep_f4

call led_control


Expand Down Expand Up @@ -3374,11 +3397,8 @@ ENDIF
arming_begin:
; Beep arm sequence start signal
clr IE_EA ; Disable all interrupts
call beep_f1 ; Signal that RC pulse is ready
call beep_f1
call beep_f1
call beep_f1_short ; Signal that RC pulse is ready
setb IE_EA ; Enable all interrupts
call wait200ms

; Arming sequence start
arming_wait:
Expand All @@ -3388,9 +3408,7 @@ arming_wait:

; Beep arm sequence end signal
clr IE_EA ; Disable all interrupts
call beep_f4 ; Signal that RC pulse is ready
call beep_f4
call beep_f4
call beep_f2_short ; Signal that ESC is armed
setb IE_EA ; Enable all interrupts
call wait200ms

Expand Down

0 comments on commit 5659d3b

Please sign in to comment.