feat(ipod): Piezo beeps now match headphone beeps
This commit is contained in:
parent
e5ecff3db7
commit
339f770b0c
9 changed files with 52 additions and 43 deletions
25
apps/misc.c
25
apps/misc.c
|
@ -1007,6 +1007,13 @@ void system_sound_play(enum system_sound sound)
|
|||
|
||||
if (*params->setting)
|
||||
{
|
||||
#if defined(HAVE_HARDWARE_CLICK) && !defined(SIMULATOR)
|
||||
if (global_settings.keyclick_hardware)
|
||||
{
|
||||
piezo_button_beep(params->frequency,
|
||||
params->duration, true);
|
||||
}
|
||||
#endif
|
||||
beep_play(params->frequency, params->duration,
|
||||
params->amplitude * *params->setting);
|
||||
}
|
||||
|
@ -1068,23 +1075,7 @@ void keyclick_click(bool rawbutton, int action)
|
|||
do_beep = keyclick_current_callback(action, keyclick_data);
|
||||
keyclick_current_callback = NULL;
|
||||
|
||||
if (do_beep)
|
||||
{
|
||||
#ifdef HAVE_HARDWARE_CLICK
|
||||
if (global_settings.keyclick)
|
||||
{
|
||||
system_sound_play(SOUND_KEYCLICK);
|
||||
}
|
||||
if (global_settings.keyclick_hardware)
|
||||
{
|
||||
#if !defined(SIMULATOR)
|
||||
piezo_button_beep(false, false);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
system_sound_play(SOUND_KEYCLICK);
|
||||
#endif
|
||||
}
|
||||
if (do_beep) { system_sound_play(SOUND_KEYCLICK); }
|
||||
}
|
||||
|
||||
/* Return the ReplayGain mode adjusted by other relevant settings */
|
||||
|
|
|
@ -158,7 +158,7 @@ bool piezo_busy(void)
|
|||
return !queue_empty(&piezo_queue);
|
||||
}
|
||||
|
||||
/* conversion factor based on the following data
|
||||
/* conversion factor used to based on the following data
|
||||
|
||||
period Hz
|
||||
10 8547
|
||||
|
@ -174,11 +174,33 @@ bool piezo_busy(void)
|
|||
|
||||
someone with better recording/analysing equipment should be able
|
||||
to get more accurate figures
|
||||
|
||||
|
||||
Above measurements are not measuring fundamental frequency,
|
||||
but rather a subharmonic frequency
|
||||
|
||||
Given a 192khz frequency with a divisor of 1,
|
||||
these following values should be measurable
|
||||
|
||||
Divisor Hz
|
||||
10 19200
|
||||
20 9600
|
||||
30 6400
|
||||
40 4800
|
||||
50 3840
|
||||
60 3200
|
||||
70 2743
|
||||
80 2400
|
||||
90 2133
|
||||
100 1920
|
||||
|
||||
*/
|
||||
|
||||
unsigned int piezo_hz(unsigned int hz)
|
||||
{
|
||||
if (hz > 0)
|
||||
return 91225/hz;
|
||||
// Calculated by measuring frequency cycle time on ipodvideo
|
||||
return 192000/hz;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
@ -193,19 +215,16 @@ void piezo_init(void)
|
|||
IF_COP(, CPU));
|
||||
}
|
||||
|
||||
void piezo_button_beep(bool beep, bool force)
|
||||
void piezo_button_beep(unsigned short hz, unsigned short dur, bool force)
|
||||
{
|
||||
/* old on clickwheel action - piezo_play_for_usec(50, 0x80, 400);
|
||||
old on button action - piezo_play_for_usec(50, 0x80, 3000); */
|
||||
|
||||
if (force)
|
||||
if (force) {
|
||||
piezo_clear();
|
||||
|
||||
if (queue_empty(&piezo_queue))
|
||||
piezo_play_for_usec(piezo_hz(hz), 0x80, dur * 1000);
|
||||
} else if (queue_empty(&piezo_queue))
|
||||
{
|
||||
if (beep)
|
||||
piezo_play_for_tick(40, 0x80, HZ/5);
|
||||
else
|
||||
piezo_play_for_usec(91, 0x80, 4000);
|
||||
piezo_play_for_usec(piezo_hz(hz), 0x80, dur * 1000);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,4 +29,4 @@ void piezo_stop(void);
|
|||
void piezo_clear(void);
|
||||
bool piezo_busy(void);
|
||||
unsigned int piezo_hz(unsigned int hz);
|
||||
void piezo_button_beep(bool beep, bool force);
|
||||
void piezo_button_beep(unsigned short hz, unsigned short dur, bool force);
|
||||
|
|
|
@ -56,10 +56,11 @@ void piezo_init(void)
|
|||
{
|
||||
}
|
||||
|
||||
void piezo_button_beep(bool beep, bool force)
|
||||
void piezo_button_beep(unsigned short hz, unsigned short dur, bool force)
|
||||
{
|
||||
/* hw can only do a click */
|
||||
(void)beep;
|
||||
(void)hz;
|
||||
(void)dur;
|
||||
(void)force;
|
||||
piezo_hw_voltage_on();
|
||||
udelay(1000);
|
||||
|
|
|
@ -20,4 +20,4 @@
|
|||
****************************************************************************/
|
||||
|
||||
void piezo_init(void);
|
||||
void piezo_button_beep(bool beep, bool force);
|
||||
void piezo_button_beep(unsigned short hz, unsigned short dur, bool force);
|
||||
|
|
|
@ -81,7 +81,7 @@ void piezo_init(void)
|
|||
beeping = 0;
|
||||
}
|
||||
|
||||
void piezo_button_beep(bool beep, bool force)
|
||||
void piezo_button_beep(unsigned short hz, unsigned short dur, bool force)
|
||||
{
|
||||
if (force)
|
||||
while (beeping)
|
||||
|
@ -89,9 +89,8 @@ void piezo_button_beep(bool beep, bool force)
|
|||
|
||||
if (!beeping)
|
||||
{
|
||||
if (beep)
|
||||
piezo_start(22, 457);
|
||||
else
|
||||
piezo_start(40, 4);
|
||||
/* Cycle count estimated for durations up to 2048ms
|
||||
and with frequencies in 4hz increments */
|
||||
piezo_start(50000/hz, (dur << 5) / ((7999 / (hz >> 2)) + 1));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,4 +23,4 @@ void piezo_init(void);
|
|||
void piezo_stop(void);
|
||||
void piezo_clear(void);
|
||||
bool piezo_busy(void);
|
||||
void piezo_button_beep(bool beep, bool force);
|
||||
void piezo_button_beep(unsigned short hz, unsigned short dur, bool force);
|
||||
|
|
|
@ -81,7 +81,7 @@ void piezo_init(void)
|
|||
piezo_stop();
|
||||
}
|
||||
|
||||
void piezo_button_beep(bool beep, bool force)
|
||||
void piezo_button_beep(unsigned short hz, unsigned short dur, bool force)
|
||||
{
|
||||
if (force)
|
||||
while (beeping)
|
||||
|
@ -89,10 +89,9 @@ void piezo_button_beep(bool beep, bool force)
|
|||
|
||||
if (!beeping)
|
||||
{
|
||||
if (beep)
|
||||
piezo_start(22, 457);
|
||||
else
|
||||
piezo_start(40, 4);
|
||||
/* Cycle count estimated for durations up to 2048ms
|
||||
and with frequencies in 4hz increments */
|
||||
piezo_start(50000/hz, (dur << 5) / ((7999 / (hz >> 2)) + 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ void piezo_init(void);
|
|||
void piezo_stop(void);
|
||||
void piezo_clear(void);
|
||||
bool piezo_busy(void);
|
||||
void piezo_button_beep(bool beep, bool force);
|
||||
void piezo_button_beep(unsigned short hz, unsigned short dur, bool force);
|
||||
|
||||
#ifdef BOOTLOADER
|
||||
#include <inttypes.h>
|
||||
|
|
Loading…
Reference in a new issue