uint16_t c;
TCCR1 = 0x8;
OCR1C = divisor;
- OCR1B = divisor / 2;
+ c = (divisor * 2) / 3;
+ OCR1B = c;
for (c = 0; c < duration - pause; c++)
_delay_ms(2);
- OCR1B = 255;
- OCR1C = 14;
+ TCCR1 = 0x6;
+ OCR1C = PWM_CYCLE;
+ OCR1B = 12;
for (c = 0; c < pause; c++)
_delay_ms(2);
TCCR1 = 0x6;
- OCR1C = 14;
- OCR1B = 14;
+ OCR1C = PWM_CYCLE;
+ OCR1B = PWM_CYCLE;
}
static void tone_enter(void)
static void snd_off(void)
{
TCCR1 = 0x6;
- OCR1C = 14;
- OCR1B = 14;
+ OCR1C = PWM_CYCLE;
+ OCR1B = PWM_CYCLE;
}
#else
#endif
}
-ISR(PCINT0_vect){
+void mm_switch_pinchange_callback(void)
+{
static uint8_t btn_last = 0;
- mm_pinchange_handler();
-
if (BTN_PRESSED && !btn_last) {
config.learn_mode++;
config.learn_mode %= LM_END;
static uint8_t get_speed(uint8_t command)
{
- uint8_t b1, b3, b5, b7;
+ uint8_t b1, b3, b5, b7;
b1 = ((command & 0x80) != 0);
b3 = ((command & 0x20) != 0);
//if ((b1 != b2) || (b2 != b3) || (b3 != b4) || (b5 != b6) || (b7 != b8))
// return 0xff;
-
- return (b1 + b3*2 + b5*4 +b7*8);
+ return (b1 + b3 * 2 + b5 * 4 +b7 * 8);
}
}
alert_last = (speed == 1);
break;
+
case 50:
if (speed)
- speed -= 1;
-
+ speed = speed - 1;
+
if (config.learn_mode == LM_EASY_MODE) {
config.initial_pulse = speed;
}
break;
case 51:
+ if (speed)
+ speed = speed - 1;
+
if (config.learn_mode == LM_EASY_MODE)
config.on_duty_cycle = speed;
break;
void shift(uint8_t mu);
#ifdef WITH_PWM
-#define DRIVE_OFF {OCR1B = 14;}
-#define DRIVE_ON {OCR1B = 14 - config.on_duty_cycle;}
+#define DRIVE_OFF {OCR1B = PWM_CYCLE;}
+#define DRIVE_ON {OCR1B = PWM_CYCLE - config.on_duty_cycle;}
#define DRIVE_FULL {OCR1B = 0;}
#else
#define DRIVE_OFF {setpin(PIN_DRIVE, 0);}
uint8_t drive_slope = 0;
#endif
-
#ifdef USE_REGISTER_VARS
drive_on = 0;
#endif
config.learn_mode = LM_LEARN_ON_KEY;
}
sei();
-
while (1) {
drive_start:
config.learn_mode > LM_LEARN_OP_MODE)
continue;
-
for (i = 0; i < config.learn_mode; i++) {
setpin(PIN_LED, 1);
snd_on();