diff options
author | Jack Humbert <jack.humb@gmail.com> | 2015-09-06 18:57:23 -0400 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2015-09-06 18:57:23 -0400 |
commit | 44625de59a72e69d4bf2948dfc04cc283664a292 (patch) | |
tree | 64521a5a41c79ab70baedde94474f7e3a1ba9c4c /keyboard/planck/beeps.c | |
parent | ed384bd4376398887a95942b7d6750d5bc4833e8 (diff) |
beeps in an if
Diffstat (limited to 'keyboard/planck/beeps.c')
-rw-r--r-- | keyboard/planck/beeps.c | 62 |
1 files changed, 23 insertions, 39 deletions
diff --git a/keyboard/planck/beeps.c b/keyboard/planck/beeps.c index a1e697be40..8d1f81f210 100644 --- a/keyboard/planck/beeps.c +++ b/keyboard/planck/beeps.c @@ -183,22 +183,6 @@ ISR(TIMER3_COMPA_vect) { // // PORTC |= (1<<6); } -void loop() { -} -// ISR(TIMER1_COMPA_vect) -// { -// // if (i<(sizeof(wave)/sizeof(int))) //don't exceed ends of vector... sizeof(wave) -// if (i<pow(2, 10)) //don't exceed ends of vector... sizeof(wave) -// { -// OCR3A = (int)((float)wave[i]*ICR3/RANGE); //go to next array element -// // int x = 1; -// // int y = 5; -// // OCR3A = (int) (round(sin(i*440*pow(2, x/12.0))*.5+.5 + sin(i*440*pow(2, y/12.0))*.5+.5) / 2 * ICR3); -// i++; //increment -// } -// else i=0; //reset -// } - void play_note(double freq, int vol) { if (freq > 0) { @@ -236,27 +220,27 @@ void play_note(double freq, int vol) { // TCCR3B = 0; } -void note(int x, float length) { - DDRC |= (1<<6); - int t = (int)(440*pow(2,-x/12.0)); // starting note - for (int y = 0; y < length*1000/t; y++) { // note length - PORTC |= (1<<6); - delay_us(t); - PORTC &= ~(1<<6); - delay_us(t); - } - PORTC &= ~(1<<6); -} +// void note(int x, float length) { +// DDRC |= (1<<6); +// int t = (int)(440*pow(2,-x/12.0)); // starting note +// for (int y = 0; y < length*1000/t; y++) { // note length +// PORTC |= (1<<6); +// delay_us(t); +// PORTC &= ~(1<<6); +// delay_us(t); +// } +// PORTC &= ~(1<<6); +// } -void true_note(float x, float y, float length) { - for (uint32_t i = 0; i < length * 50; i++) { - uint32_t v = (uint32_t) (round(sin(PI*2*i*640000*pow(2, x/12.0))*.5+1 + sin(PI*2*i*640000*pow(2, y/12.0))*.5+1) / 2 * pow(2, 8)); - for (int u = 0; u < 8; u++) { - if (v & (1 << u) && !(PORTC&(1<<6))) - PORTC |= (1<<6); - else if (PORTC&(1<<6)) - PORTC &= ~(1<<6); - } - } - PORTC &= ~(1<<6); -}
\ No newline at end of file +// void true_note(float x, float y, float length) { +// for (uint32_t i = 0; i < length * 50; i++) { +// uint32_t v = (uint32_t) (round(sin(PI*2*i*640000*pow(2, x/12.0))*.5+1 + sin(PI*2*i*640000*pow(2, y/12.0))*.5+1) / 2 * pow(2, 8)); +// for (int u = 0; u < 8; u++) { +// if (v & (1 << u) && !(PORTC&(1<<6))) +// PORTC |= (1<<6); +// else if (PORTC&(1<<6)) +// PORTC &= ~(1<<6); +// } +// } +// PORTC &= ~(1<<6); +// }
\ No newline at end of file |