Moderators: adafruit_support_bill, adafruit
Hellbus wrote:I noticed on closer inspection that I had forgotten to install C10. I'm putting the clock back together now and will report whether the second issue is fixed. There is one thing I noticed when I was experimenting last night that got me thinking. As a test, I soldered in a jumper to short the fuse and then tried to adjust the brightness. It got as far as showing a final zero at the end of the display before resetting, which made me wonder if the VFD might be drawing too much power.
That was prior to adding C10, and my random resets were not solved by the jumper, so I have since removed it.
SIGNAL(SIG_PIN_CHANGE2) {
// allow interrupts while we're doing this
PCMSK2 = 0;
sei();
// kick the dog
kickthedog();
if (! (PIND & _BV(BUTTON1))) {
// button1 is pressed
if (! (last_buttonstate & 0x1)) { // was not pressed before
delayms(10); // debounce
if (PIND & _BV(BUTTON1)) // filter out bounces
{
PCMSK2 = _BV(PCINT21) | _BV(PCINT20);
return;
}
tick(); // make a noise
// check if we will snag this button press for snoozing
if (alarming) {
// turn on snooze
setsnooze();
PCMSK2 = _BV(PCINT21) | _BV(PCINT20);
return;
}
last_buttonstate |= 0x1;
just_pressed |= 0x1;
DEBUGP("b1");
}
} else {
last_buttonstate &= ~0x1;
}
if (! (PIND & _BV(BUTTON3))) {
// button3 is pressed
if (! (last_buttonstate & 0x4)) { // was not pressed before
delayms(10); // debounce
if (PIND & _BV(BUTTON3)) // filter out bounces
{
PCMSK2 = _BV(PCINT21) | _BV(PCINT20);
return;
}
buttonholdcounter = 2; // see if we're press-and-holding
while (buttonholdcounter) {
if (PIND & _BV(BUTTON3)) { // released
tick(); // make a noise
last_buttonstate &= ~0x4;
// check if we will snag this button press for snoozing
if (alarming) {
// turn on snooze
setsnooze();
PCMSK2 = _BV(PCINT21) | _BV(PCINT20);
return;
}
DEBUGP("b3");
just_pressed |= 0x4;
PCMSK2 = _BV(PCINT21) | _BV(PCINT20);
return;
}
}
last_buttonstate |= 0x4;
pressed |= 0x4; // held down
}
} else {
pressed = 0; // button released
last_buttonstate &= ~0x4;
}
PCMSK2 = _BV(PCINT21) | _BV(PCINT20);
}
// Just button #2
SIGNAL(SIG_PIN_CHANGE0) {
PCMSK0 = 0;
sei();
if (! (PINB & _BV(BUTTON2))) {
// button2 is pressed
if (! (last_buttonstate & 0x2)) { // was not pressed before
delayms(10); // debounce
if (PINB & _BV(BUTTON2)) // filter out bounces
{
PCMSK0 = _BV(PCINT0);
return;
}
tick(); // make a noise
// check if we will snag this button press for snoozing
if (alarming) {
setsnooze(); // turn on snooze
PCMSK0 = _BV(PCINT0);
return;
}
last_buttonstate |= 0x2;
just_pressed |= 0x2;
DEBUGP("b2");
}
} else {
last_buttonstate &= ~0x2;
}
PCMSK0 = _BV(PCINT0);
}
//Alarm Switch
SIGNAL(SIG_INTERRUPT0) {
EIMSK = 0; //Disable this interrupt while we are processing it.
uart_putchar('i');
uint8_t x = ALARM_PIN & _BV(ALARM);
sei();
delayms(10); // wait for debouncing
if (x != (ALARM_PIN & _BV(ALARM)))
{
EIMSK = _BV(INT0);
return;
}
setalarmstate();
EIMSK = _BV(INT0); //And reenable it before exiting.
}Users browsing this forum: No registered users and 2 guests