diff options
| author | Selene ToyKeeper | 2019-08-11 15:16:23 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2019-08-11 15:16:23 -0600 |
| commit | 89a86871aa6330218043586f0347c0c1e7c79dab (patch) | |
| tree | e3a4cc2a4517e5563e91cdaaf86718170d4f0a37 /spaghetti-monster/fsm-pcint.c | |
| parent | Added setup info for Fedora. (diff) | |
| parent | added scripts to flash attiny1634, which were missing before (diff) | |
| download | anduril-89a86871aa6330218043586f0347c0c1e7c79dab.tar.gz anduril-89a86871aa6330218043586f0347c0c1e7c79dab.tar.bz2 anduril-89a86871aa6330218043586f0347c0c1e7c79dab.zip | |
merged fsm to trunk... lots of updates:
+ attiny1634 support
+ Emisar D4v2 support
+ Mateminco MF01S / MT18 support
+ Fireflies E01 and E07v2 support
+ RGB aux LED support
+ added factory reset function
+ added manual / automatic memory toggle
+ added 2-level brightness during lockout
+ added Fireflies UI
+ made momentary mode also support strobe-group modes
* thermal regulation rewritten, behaves mostly better now
* strobe modes auto-reverse their ramp now
* muggle mode fixes
* UI diagram and manual updated
* button timing adjusted, and compile-time options added for it
* general refactoring
Diffstat (limited to 'spaghetti-monster/fsm-pcint.c')
| -rw-r--r-- | spaghetti-monster/fsm-pcint.c | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/spaghetti-monster/fsm-pcint.c b/spaghetti-monster/fsm-pcint.c index acb627d..4928980 100644 --- a/spaghetti-monster/fsm-pcint.c +++ b/spaghetti-monster/fsm-pcint.c @@ -30,7 +30,7 @@ uint8_t button_is_pressed() { // and wait for measurements to settle to all zeroes or all ones do { // shift past readings and add current value - readings = (readings << 1) | ((PINB & (1<<SWITCH_PIN)) == 0); + readings = (readings << 1) | ((SWITCH_PORT & (1<<SWITCH_PIN)) == 0); // wait a moment _delay_loop_2(BOGOMIPS/16); // up to 2ms to stabilize } @@ -40,21 +40,45 @@ uint8_t button_is_pressed() { } inline void PCINT_on() { - // enable pin change interrupt for pin N - GIMSK |= (1 << PCIE); - // only pay attention to the e-switch pin - //PCMSK = (1 << SWITCH_PCINT); - // set bits 1:0 to 0b01 (interrupt on rising *and* falling edge) (default) - // MCUCR &= 0b11111101; MCUCR |= 0b00000001; + #if (ATTINY == 25) || (ATTINY == 45) || (ATTINY == 85) + // enable pin change interrupt + GIMSK |= (1 << PCIE); + // only pay attention to the e-switch pin + #if 0 // this is redundant; was already done in main() + PCMSK = (1 << SWITCH_PCINT); + #endif + // set bits 1:0 to 0b01 (interrupt on rising *and* falling edge) (default) + // MCUCR &= 0b11111101; MCUCR |= 0b00000001; + #elif (ATTINY == 1634) + // enable pin change interrupt + #ifdef SWITCH2_PCIE + GIMSK |= ((1 << SWITCH_PCIE) | (1 << SWITCH2_PCIE)); + #else + GIMSK |= (1 << SWITCH_PCIE); + #endif + #else + #error Unrecognized MCU type + #endif } inline void PCINT_off() { - // disable all pin-change interrupts - GIMSK &= ~(1 << PCIE); + #if (ATTINY == 25) || (ATTINY == 45) || (ATTINY == 85) + // disable all pin-change interrupts + GIMSK &= ~(1 << PCIE); + #elif (ATTINY == 1634) + // disable all pin-change interrupts + GIMSK &= ~(1 << SWITCH_PCIE); + #else + #error Unrecognized MCU type + #endif } //void button_change_interrupt() { +#if (ATTINY == 25) || (ATTINY == 45) || (ATTINY == 85) || (ATTINY == 1634) EMPTY_INTERRUPT(PCINT0_vect); +#else + #error Unrecognized MCU type +#endif /* ISR(PCINT0_vect) { |
