wbp wrote:Bruce, I agree with you about wanting the alarm to start out as quiet as possible! Unfortunately, I don't know if it's possible to make the Ice Tube's beeper any quieter than the two volume levels already in the code.
Hmm... well, looking quickly at the code, I think you'd have to mess around with how alarmdiv and ALARM_DIVIDER are used in the SIG_OVERFLOW0 handler. Essentially look at the current code as starting at 2 Hz and 50% duty cycle, and have it start more quietly just by tweaking the duty cycle?
- Code: Select all
#define ALARM_FREQUENCY 200 // alarm pulse frequency in 100'ths of a second
#define ALARM_STEP 10 // # of 100'ths of a second added to the alarm 'on' time after each beep
uint16_t alarmcount = 0 // counter for 100'ths of a second while alarm is ringing
uint16_t alarmduty = 0 // range 1 to ALARM_FREQUENCY, duty cycle of alarm beeping
// ... when alarming is set, alarmduty is reset to ALARM_STEP
// and alarm is started, so we start in the 'on' phase of the beep cycle
// then in SIG_OVERFLOW0:
if (alarming && !snoozetimer) {
++alarmcount;
if (alarmcount >= alarmduty) {
alarmcount = 0;
if (alarmduty < ALARM_FREQUENCY-ALARM_STEP) {
alarmduty += ALARM_STEP;
} else {
return;
}
...
If I coded that right, it would give you 40 seconds between chirping and full on blaring. I don't think I'd go that aggressive, myself, but it's some sort of a starting point.
Alternately it may be possible to make the piezo quieter by messing with the PWM duty cycle. I haven't played around with piezos enough to know how well that would work.
Anyway, an interesting problem to think about, but I still think you got the most important mod already in turning the alarm off after a fixed period of time.