aboutsummaryrefslogtreecommitdiff
path: root/quantum/fauxclicky.c
diff options
context:
space:
mode:
authorskullY <skullydazed@gmail.com>2019-08-30 11:19:03 -0700
committerskullydazed <skullydazed@users.noreply.github.com>2019-08-30 15:01:52 -0700
commitb624f32f944acdc59dcb130674c09090c5c404cb (patch)
treebc13adbba137d122d9a2c2fb2fafcbb08ac10e25 /quantum/fauxclicky.c
parent61af76a10d00aba185b8338604171de490a13e3b (diff)
downloadqmk_firmware-b624f32f944acdc59dcb130674c09090c5c404cb.tar.gz
qmk_firmware-b624f32f944acdc59dcb130674c09090c5c404cb.zip
clang-format changes
Diffstat (limited to 'quantum/fauxclicky.c')
-rw-r--r--quantum/fauxclicky.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/quantum/fauxclicky.c b/quantum/fauxclicky.c
index c3341ca33..a57e2ed07 100644
--- a/quantum/fauxclicky.c
+++ b/quantum/fauxclicky.c
@@ -20,23 +20,21 @@ 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
23bool fauxclicky_enabled = true; 23bool fauxclicky_enabled = true;
24uint16_t note_start = 0; 24uint16_t note_start = 0;
25bool note_playing = false; 25bool note_playing = false;
26uint16_t note_period = 0; 26uint16_t note_period = 0;
27 27
28void fauxclicky_init() 28void fauxclicky_init() {
29{
30 // Set port PC6 (OC3A and /OC4A) as output 29 // Set port PC6 (OC3A and /OC4A) as output
31 DDRC |= _BV(PORTC6); 30 DDRC |= _BV(PORTC6);
32 31
33 // TCCR3A / TCCR3B: Timer/Counter #3 Control Registers 32 // TCCR3A / TCCR3B: Timer/Counter #3 Control Registers
34 TCCR3A = (0 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30); 33 TCCR3A = (0 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30);
35 TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30); 34 TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30);
36} 35}
37 36
38void fauxclicky_stop() 37void fauxclicky_stop() {
39{
40 FAUXCLICKY_DISABLE_OUTPUT; 38 FAUXCLICKY_DISABLE_OUTPUT;
41 note_playing = false; 39 note_playing = false;
42} 40}
@@ -45,10 +43,10 @@ void fauxclicky_play(float note[]) {
45 if (!fauxclicky_enabled) return; 43 if (!fauxclicky_enabled) return;
46 if (note_playing) fauxclicky_stop(); 44 if (note_playing) fauxclicky_stop();
47 FAUXCLICKY_TIMER_PERIOD = (uint16_t)(((float)F_CPU) / (note[0] * (float)FAUXCLICKY_CPU_PRESCALER)); 45 FAUXCLICKY_TIMER_PERIOD = (uint16_t)(((float)F_CPU) / (note[0] * (float)FAUXCLICKY_CPU_PRESCALER));
48 FAUXCLICKY_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (note[0] * (float)FAUXCLICKY_CPU_PRESCALER)) / (float)2); 46 FAUXCLICKY_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (note[0] * (float)FAUXCLICKY_CPU_PRESCALER)) / (float)2);
49 note_playing = true; 47 note_playing = true;
50 note_period = (note[1] / (float)16) * ((float)60 / (float)FAUXCLICKY_TEMPO) * 1000; 48 note_period = (note[1] / (float)16) * ((float)60 / (float)FAUXCLICKY_TEMPO) * 1000;
51 note_start = timer_read(); 49 note_start = timer_read();
52 FAUXCLICKY_ENABLE_OUTPUT; 50 FAUXCLICKY_ENABLE_OUTPUT;
53} 51}
54 52