Closed andresbott closed 4 years ago
Yes, there is a way. Look around line 1261 in tgy.asm. That's where the beep code starts. It's written in atmel assembler with a bunch of macros though, and it'll take a while to unwind what's going on.
This is largely quax' beep code. It's pretty dumb/simple. Count and interval define the duration and pitch. Somebody did do a tuned version of it, but I'm not sure where that code ended up. Some have suggested it play "O Canada", but I've left that low on the priority list. ;)
jeje, i also found line 1261 and interpreted this is the point to satrt looking, the main problem is i have no clue on assembler... thoug .... il't try see what happens. worst case some bricked ESCs :-)
Haha! - this was on my list too when I was looking for a 'Hello, world!' equivalent when these devices don't have any other form of output.
Here's my mod :
...
...
line 2625: i_rc_puls3:
.endif
rcall beep_f1 ; signal: rcpuls ready [Custom tune!]
rcall beep_f2
rcall beep_f1
rcall beep_f2
rcall beep_f3
rcall beep_f2
rcall beep_f3
rcall beep_f4
rcall beep_f3
rcall beep_f4
; Fall through to restart_control
;-----bko-----------------------------------------------------------------
restart_control:
...
...
Its a very noddy tune though, more like a primary school piano lesson(!) but demonstrates the point, and gives me a smile to this day whenever I power on my Quads :-)
This has peaked my interest again, so having just re-read the original code, I believe it does the following:
Routines beep_f1
through to beep_f4
define both temp2
and temp4
and then run beep
which I believe translates as:
Do
FETs On*
Wait 2 x 16us
FETs Off*
Wait temp4 x 16us
Loop temp2 times
This would mean that the tones are of duration (temp4 + 2) * temp2 * 16us = circa 1/3 of second. Questions :
I'll have a play and report back.
OK, today i decided to write some code. and i got some near Star Wars melody as arming sound :-) here the changes on the actual branch (23/05/2015)
sure, there is a lot of space of inprovement, i'm not really familiar with this language, i'm not even sure what kind of language this is... asambler????
on tgy.asm: added a variable (¿constant?) (line 163)
.equ ARMING_MELODY = 3 ; Include arming melody (line 3165) and notes (line 1747)
on the beep definition (line 1749) , added an if to include tones:
.if (ARMING_MELODY > 0)
.include "arming_melody_notes.inc"
.endif
same thing on line 3175:
.if (ARMING_MELODY > 0 )
.include "arming_melody.inc"
.else
rcall beep_f1 ; Usual startup beeps
rcall beep_f2
rcall beep_f3
.endif
on one side the tones file (tones are automatiocly generated, and dont mach actual notes) Improvements to do here!!!!
;#######################################
note_a1: ldi temp2, 40
ldi temp4, 240
note_a1_on: BpFET_on
AnFET_on
rcall beep
brne note_a1_on
ret
;#######################################
note_a2: ldi temp2, 50
ldi temp4, 230
note_a2_on: BpFET_on
AnFET_on
rcall beep
brne note_a2_on
ret
;#######################################
note_a3: ldi temp2, 60
ldi temp4, 220
note_a3_on: BpFET_on
AnFET_on
rcall beep
brne note_a3_on
ret
;#######################################
note_a4: ldi temp2, 70
ldi temp4, 210
note_a4_on: BpFET_on
AnFET_on
rcall beep
brne note_a4_on
ret
;#######################################
note_a5: ldi temp2, 80
ldi temp4, 200
note_a5_on: BpFET_on
AnFET_on
rcall beep
brne note_a5_on
ret
;#######################################
note_a6: ldi temp2, 90
ldi temp4, 190
note_a6_on: BpFET_on
AnFET_on
rcall beep
brne note_a6_on
ret
;#######################################
note_a7: ldi temp2, 100
ldi temp4, 180
note_a7_on: BpFET_on
AnFET_on
rcall beep
brne note_a7_on
ret
;#######################################
note_a8: ldi temp2, 110
ldi temp4, 170
note_a8_on: BpFET_on
AnFET_on
rcall beep
brne note_a8_on
ret
;#######################################
note_a9: ldi temp2, 120
ldi temp4, 160
note_a9_on: BpFET_on
AnFET_on
rcall beep
brne note_a9_on
ret
;#######################################
note_a10: ldi temp2, 130
ldi temp4, 150
note_a10_on: BpFET_on
AnFET_on
rcall beep
brne note_a10_on
ret
;#######################################
note_a11: ldi temp2, 140
ldi temp4, 140
note_a11_on: BpFET_on
AnFET_on
rcall beep
brne note_a11_on
ret
;#######################################
note_a12: ldi temp2, 150
ldi temp4, 130
note_a12_on: BpFET_on
AnFET_on
rcall beep
brne note_a12_on
ret
;#######################################
note_a13: ldi temp2, 160
ldi temp4, 120
note_a13_on: BpFET_on
AnFET_on
rcall beep
brne note_a13_on
ret
;#######################################
note_a14: ldi temp2, 170
ldi temp4, 110
note_a14_on: BpFET_on
AnFET_on
rcall beep
brne note_a14_on
ret
;#######################################
note_a15: ldi temp2, 180
ldi temp4, 100
note_a15_on: BpFET_on
AnFET_on
rcall beep
brne note_a15_on
ret
;#######################################
note_a16: ldi temp2, 190
ldi temp4, 90
note_a16_on: BpFET_on
AnFET_on
rcall beep
brne note_a16_on
ret
;#######################################
note_a17: ldi temp2, 200
ldi temp4, 80
note_a17_on: BpFET_on
AnFET_on
rcall beep
brne note_a17_on
ret
;#######################################
note_a18: ldi temp2, 210
ldi temp4, 70
note_a18_on: BpFET_on
AnFET_on
rcall beep
brne note_a18_on
ret
;#######################################
note_a19: ldi temp2, 220
ldi temp4, 60
note_a19_on: BpFET_on
AnFET_on
rcall beep
brne note_a19_on
ret
;#######################################
note_a20: ldi temp2, 230
ldi temp4, 50
note_a20_on: BpFET_on
AnFET_on
rcall beep
brne note_a20_on
ret
;#######################################
note_a21: ldi temp2, 240
ldi temp4, 40
note_a21_on: BpFET_on
AnFET_on
rcall beep
brne note_a21_on
ret
;#######################################
note_a22: ldi temp2, 250
ldi temp4, 30
note_a22_on: BpFET_on
AnFET_on
rcall beep
brne note_a22_on
ret
And the actual melody (changing the number on the first config line you can change the actual melody):
;wait240ms: rcall wait120ms
;wait120ms: rcall wait60ms
;wait60ms: rcall wait30ms
;wait30ms: ldi temp2, 15
; TEST TONE
.if (ARMING_MELODY == 1 )
rcall beep_f1 ; Usual startup beeps
rcall beep_f2
rcall beep_f3
.endif
.if (ARMING_MELODY == 2 )
rcall note_a1
rcall wait30ms
rcall note_a2
rcall wait30ms
rcall note_a3
rcall wait30ms
rcall note_a4
rcall wait30ms
rcall note_a5
rcall wait30ms
rcall note_a6
rcall wait30ms
rcall note_a7
rcall wait30ms
rcall note_a8
rcall wait30ms
rcall note_a9
rcall wait30ms
rcall note_a10
rcall wait30ms
rcall note_a11
rcall wait30ms
rcall note_a12
rcall wait30ms
rcall note_a13
rcall wait30ms
rcall note_a14
rcall wait30ms
rcall note_a15
rcall wait30ms
rcall note_a16
rcall wait30ms
rcall note_a17
rcall wait30ms
rcall note_a18
rcall wait30ms
rcall note_a19
rcall wait30ms
rcall note_a20
rcall wait30ms
rcall note_a21
rcall wait30ms
rcall note_a22
rcall wait30ms
.endif
; STAR WARS
.if (ARMING_MELODY == 3 )
rcall note_a1
rcall note_a1
rcall wait30ms
rcall note_a1
rcall note_a1
rcall wait30ms
rcall note_a1
rcall note_a1
rcall wait30ms
rcall note_a7
rcall note_a7
rcall note_a7
rcall wait30ms
rcall note_a13
rcall note_a13
rcall note_a13
rcall note_a13
rcall note_a13
rcall wait30ms
rcall note_a12
rcall wait30ms
rcall note_a11
rcall wait30ms
rcall note_a10
rcall wait30ms
rcall note_a16
rcall note_a16
rcall note_a16
rcall note_a16
rcall wait60ms
rcall note_a13
rcall note_a13
rcall note_a13
rcall wait60ms
rcall note_a12
rcall wait30ms
rcall note_a11
rcall wait30ms
rcall note_a10
rcall wait30ms
rcall note_a16
rcall note_a16
rcall note_a16
rcall note_a16
rcall wait60ms
rcall note_a13
rcall note_a13
rcall note_a13
rcall wait60ms
rcall note_a12
rcall wait30ms
rcall note_a11
rcall wait30ms
rcall note_a12
rcall wait30ms
rcall note_a10
rcall note_a10
rcall note_a10
rcall wait30ms
.endif
hi, is there a way to modify the code so to make, for example a patch, to modify/change the sounds-melody of the esc when arming?
what lines do i have to look? i'm not really experimentated with compiling this kind of software.
thanks for any help