aboutsummaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
authorPriyadi Iman Nurcahyo <priyadi@priyadi.net>2017-04-19 01:40:16 +0700
committerPriyadi Iman Nurcahyo <priyadi@priyadi.net>2017-04-19 01:40:16 +0700
commitffa4c72a893b416da32efef80f4779b8bd48b4bb (patch)
treed0a3205c6bfef232719d19ce5e14b166d16cbba9 /quantum
parentae8ac581c0253157eefe035d65499a9f162b07aa (diff)
downloadqmk_firmware-ffa4c72a893b416da32efef80f4779b8bd48b4bb.tar.gz
qmk_firmware-ffa4c72a893b416da32efef80f4779b8bd48b4bb.zip
Faux clicky bug fixes
Diffstat (limited to 'quantum')
-rw-r--r--quantum/fauxclicky.c15
-rw-r--r--quantum/fauxclicky.h10
2 files changed, 9 insertions, 16 deletions
diff --git a/quantum/fauxclicky.c b/quantum/fauxclicky.c
index 13273e705..c3341ca33 100644
--- a/quantum/fauxclicky.c
+++ b/quantum/fauxclicky.c
@@ -20,13 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
20#include <stdbool.h> 20#include <stdbool.h>
21#include <musical_notes.h> 21#include <musical_notes.h>
22 22
23__attribute__ ((weak))
24float fauxclicky_pressed_note[2] = MUSICAL_NOTE(_F3, 2);
25__attribute__ ((weak))
26float fauxclicky_released_note[2] = MUSICAL_NOTE(_A3, 2);
27__attribute__ ((weak))
28float fauxclicky_beep_note[2] = MUSICAL_NOTE(_C3, 2);
29
30bool fauxclicky_enabled = true; 23bool fauxclicky_enabled = true;
31uint16_t note_start = 0; 24uint16_t note_start = 0;
32bool note_playing = false; 25bool note_playing = false;
@@ -48,13 +41,13 @@ void fauxclicky_stop()
48 note_playing = false; 41 note_playing = false;
49} 42}
50 43
51void fauxclicky_play(float note[2]) { 44void fauxclicky_play(float note[]) {
52 if (!fauxclicky_enabled) return; 45 if (!fauxclicky_enabled) return;
53 if (note_playing) fauxclicky_stop(); 46 if (note_playing) fauxclicky_stop();
54 FAUXCLICKY_TIMER_PERIOD = (uint16_t)(((float)F_CPU) / (note[0] * FAUXCLICKY_CPU_PRESCALER)); 47 FAUXCLICKY_TIMER_PERIOD = (uint16_t)(((float)F_CPU) / (note[0] * (float)FAUXCLICKY_CPU_PRESCALER));
55 FAUXCLICKY_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (note[0] * FAUXCLICKY_CPU_PRESCALER)) / 2); 48 FAUXCLICKY_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (note[0] * (float)FAUXCLICKY_CPU_PRESCALER)) / (float)2);
56 note_playing = true; 49 note_playing = true;
57 note_period = (note[1] / 16) * (60 / (float)FAUXCLICKY_TEMPO) * 100; // check this 50 note_period = (note[1] / (float)16) * ((float)60 / (float)FAUXCLICKY_TEMPO) * 1000;
58 note_start = timer_read(); 51 note_start = timer_read();
59 FAUXCLICKY_ENABLE_OUTPUT; 52 FAUXCLICKY_ENABLE_OUTPUT;
60} 53}
diff --git a/quantum/fauxclicky.h b/quantum/fauxclicky.h
index 109bd0d83..1a8e188dd 100644
--- a/quantum/fauxclicky.h
+++ b/quantum/fauxclicky.h
@@ -21,11 +21,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
21#include "stdbool.h" 21#include "stdbool.h"
22 22
23__attribute__ ((weak)) 23__attribute__ ((weak))
24float fauxclicky_pressed_note[2]; 24float fauxclicky_pressed_note[2] = MUSICAL_NOTE(_D4, 0.25);
25__attribute__ ((weak)) 25__attribute__ ((weak))
26float fauxclicky_released_note[2]; 26float fauxclicky_released_note[2] = MUSICAL_NOTE(_C4, 0.125);
27__attribute__ ((weak)) 27__attribute__ ((weak))
28float fauxclicky_beep_note[2]; 28float fauxclicky_beep_note[2] = MUSICAL_NOTE(_C4, 0.25);
29 29
30bool fauxclicky_enabled; 30bool fauxclicky_enabled;
31 31
@@ -73,11 +73,11 @@ bool fauxclicky_enabled;
73#endif 73#endif
74 74
75#ifndef FAUXCLICKY_ENABLE_OUTPUT 75#ifndef FAUXCLICKY_ENABLE_OUTPUT
76#define FAUXCLICKY_ENABLE_OUTPUT TCCR3A |= _BV(COM3A1); 76#define FAUXCLICKY_ENABLE_OUTPUT TCCR3A |= _BV(COM3A1)
77#endif 77#endif
78 78
79#ifndef FAUXCLICKY_DISABLE_OUTPUT 79#ifndef FAUXCLICKY_DISABLE_OUTPUT
80#define FAUXCLICKY_DISABLE_OUTPUT TCCR3A &= ~(_BV(COM3A1) | _BV(COM3A0)); 80#define FAUXCLICKY_DISABLE_OUTPUT TCCR3A &= ~(_BV(COM3A1) | _BV(COM3A0))
81#endif 81#endif
82 82
83#ifndef FAUXCLICKY_TIMER_PERIOD 83#ifndef FAUXCLICKY_TIMER_PERIOD