diff options
| author | Selene ToyKeeper | 2017-06-18 06:39:41 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2017-06-18 06:39:41 -0600 |
| commit | 28f1c7a089d86b8beed3237a8aa40c19744315db (patch) | |
| tree | a050a582d397276e4f2b4c45089802334dc51775 | |
| parent | fixed tiny25 BOGOMIPS value (diff) | |
| parent | merged trunk (diff) | |
| download | anduril-28f1c7a089d86b8beed3237a8aa40c19744315db.tar.gz anduril-28f1c7a089d86b8beed3237a8aa40c19744315db.tar.bz2 anduril-28f1c7a089d86b8beed3237a8aa40c19744315db.zip | |
Merged the crescendo (ramping-clicky UI) branch.
Applied tk-delay.h changes everywhere I could find a need for it.
Diffstat (limited to '')
| -rw-r--r-- | tk-attiny.h | 14 | ||||
| -rw-r--r-- | tk-delay.h | 14 | ||||
| -rw-r--r-- | tk-random.h | 5 |
3 files changed, 31 insertions, 2 deletions
diff --git a/tk-attiny.h b/tk-attiny.h index 308947a..72ed2f0 100644 --- a/tk-attiny.h +++ b/tk-attiny.h @@ -73,6 +73,9 @@ //#define TEMP_DIDR ADC4D #define TEMP_CHANNEL 0b00001111 +#define FAST 0xA3 // fast PWM both channels +#define PHASE 0xA1 // phase-correct PWM both channels + #endif // FET_7135_LAYOUT #ifdef TRIPLEDOWN_LAYOUT @@ -106,7 +109,10 @@ //#define TEMP_DIDR ADC4D #define TEMP_CHANNEL 0b00001111 -#endif // FET_7135_LAYOUT +#define FAST 0xA3 // fast PWM both channels +#define PHASE 0xA1 // phase-correct PWM both channels + +#endif // TRIPLEDOWN_LAYOUT #ifdef FERRERO_ROCHER_LAYOUT /* @@ -118,6 +124,8 @@ * ---- */ // TODO: fill in this section, update Ferrero_Rocher code to use it. +#define FAST 0x23 // fast PWM channel 1 only +#define PHASE 0x21 // phase-correct PWM channel 1 only #endif // FERRERO_ROCHER_LAYOUT #ifdef NANJG_LAYOUT @@ -131,6 +139,10 @@ #define ADC_PRSCL 0x06 // clk/64 #define PWM_LVL OCR0B // OCR0B is the output compare register for PB1 + +#define FAST 0x23 // fast PWM channel 1 only +#define PHASE 0x21 // phase-correct PWM channel 1 only + #endif // NANJG_LAYOUT #ifndef PWM_LVL @@ -23,6 +23,7 @@ #ifdef OWN_DELAY #include "tk-attiny.h" #include <util/delay_basic.h> +#ifdef USE_DELAY_MS // Having own _delay_ms() saves some bytes AND adds possibility to use variables as input void _delay_ms(uint16_t n) { @@ -37,15 +38,28 @@ void _delay_ms(uint16_t n) while(n-- > 0) _delay_loop_2(BOGOMIPS); //#endif } +#endif #ifdef USE_FINE_DELAY void _delay_zero() { _delay_loop_2(BOGOMIPS/3); } #endif +#ifdef USE_DELAY_4MS +void _delay_4ms(uint8_t n) // because it saves a bit of ROM space to do it this way +{ + while(n-- > 0) _delay_loop_2(BOGOMIPS*4); +} +#endif #ifdef USE_DELAY_S void _delay_s() // because it saves a bit of ROM space to do it this way { + #ifdef USE_DELAY_4MS + _delay_4ms(250); + #else + #ifdef USE_DELAY_MS _delay_ms(1000); + #endif + #endif } #endif #else diff --git a/tk-random.h b/tk-random.h index d559659..b2ff296 100644 --- a/tk-random.h +++ b/tk-random.h @@ -22,7 +22,10 @@ uint8_t pgm_rand() { static uint16_t offset = 255; - offset = (offset + 1) & 0x3ff | 0x0100; + // loop through ROM space, but avoid the first 256 bytes + // because the beginning tends to have a big ramp which + // doesn't look very random at all + offset = ((offset + 1) & 0x3ff) | 0x0100; return pgm_read_byte(offset); } |
