summaryrefslogtreecommitdiffstats
path: root/quantum
diff options
context:
space:
mode:
Diffstat (limited to 'quantum')
-rw-r--r--quantum/audio.c48
-rw-r--r--quantum/audio.h14
-rw-r--r--quantum/quantum.mk1
-rw-r--r--quantum/tools/README.md6
-rw-r--r--quantum/tools/eeprom_reset.hex9
5 files changed, 76 insertions, 2 deletions
diff --git a/quantum/audio.c b/quantum/audio.c
index 50e5505fe..73985479c 100644
--- a/quantum/audio.c
+++ b/quantum/audio.c
@@ -8,6 +8,8 @@
#include "audio.h"
#include "keymap_common.h"
+#include "eeconfig.h"
+
#define PI 3.14159265
// #define PWM_AUDIO
@@ -57,6 +59,25 @@ uint8_t notes_length;
bool notes_repeat;
uint8_t current_note = 0;
+audio_config_t audio_config;
+
+
+void audio_toggle(void) {
+ audio_config.enable ^= 1;
+ eeconfig_write_audio(audio_config.raw);
+}
+
+void audio_on(void) {
+ audio_config.enable = 1;
+ eeconfig_write_audio(audio_config.raw);
+}
+
+void audio_off(void) {
+ audio_config.enable = 0;
+ eeconfig_write_audio(audio_config.raw);
+}
+
+
void stop_all_notes() {
voices = 0;
#ifdef PWM_AUDIO
@@ -129,6 +150,12 @@ void stop_note(double freq) {
void init_notes() {
+ /* check signature */
+ if (!eeconfig_is_enabled()) {
+ eeconfig_init();
+ }
+ audio_config.raw = eeconfig_read_audio();
+
#ifdef PWM_AUDIO
PLLFRQ = _BV(PDIV2);
PLLCSR = _BV(PLLE);
@@ -160,7 +187,6 @@ void init_notes() {
ISR(TIMER3_COMPA_vect) {
-
if (note) {
#ifdef PWM_AUDIO
if (voices == 1) {
@@ -288,9 +314,16 @@ ISR(TIMER3_COMPA_vect) {
}
+ if (!audio_config.enable) {
+ notes = false;
+ note = false;
+ }
}
void play_notes(float (*np)[][2], uint8_t n_length, bool n_repeat) {
+
+if (audio_config.enable) {
+
if (note)
stop_all_notes();
notes = true;
@@ -319,7 +352,12 @@ void play_notes(float (*np)[][2], uint8_t n_length, bool n_repeat) {
#endif
}
+}
+
void play_sample(uint8_t * s, uint16_t l, bool r) {
+
+if (audio_config.enable) {
+
stop_all_notes();
place_int = 0;
sample = s;
@@ -330,9 +368,15 @@ void play_sample(uint8_t * s, uint16_t l, bool r) {
TIMSK3 |= _BV(OCIE3A);
#else
#endif
+
+}
+
}
void play_note(double freq, int vol) {
+
+if (audio_config.enable) {
+
if (notes)
stop_all_notes();
note = true;
@@ -367,4 +411,6 @@ void play_note(double freq, int vol) {
TCCR3A |= _BV(COM3A1);
#endif
+}
+
} \ No newline at end of file
diff --git a/quantum/audio.h b/quantum/audio.h
index 99203cea7..58270015d 100644
--- a/quantum/audio.h
+++ b/quantum/audio.h
@@ -3,9 +3,21 @@
#include <avr/io.h>
#include <util/delay.h>
+typedef union {
+ uint8_t raw;
+ struct {
+ bool enable :1;
+ uint8_t level :7;
+ };
+} audio_config_t;
+
+void audio_toggle(void);
+void audio_on(void);
+void audio_off(void);
+
void play_sample(uint8_t * s, uint16_t l, bool r);
void play_note(double freq, int vol);
void stop_note(double freq);
void stop_all_notes();
void init_notes();
-void play_notes(float (*np)[][2], uint8_t n_length, bool n_repeat); \ No newline at end of file
+void play_notes(float (*np)[][2], uint8_t n_length, bool n_repeat);
diff --git a/quantum/quantum.mk b/quantum/quantum.mk
index 17bb50171..1fe7390eb 100644
--- a/quantum/quantum.mk
+++ b/quantum/quantum.mk
@@ -46,6 +46,7 @@ endif
# Search Path
VPATH += $(TOP_DIR)/$(QUANTUM_DIR)
+VPATH += $(TOP_DIR)/$(QUANTUM_DIR)/keymap_extras
include $(TMK_DIR)/protocol/lufa.mk
diff --git a/quantum/tools/README.md b/quantum/tools/README.md
new file mode 100644
index 000000000..070214423
--- /dev/null
+++ b/quantum/tools/README.md
@@ -0,0 +1,6 @@
+`eeprom_reset.hex` is to reset the eeprom on the Atmega32u4, like this:
+
+ dfu-programmer atmega32u4 erase
+ dfu-programmer atmega32u4 flash --eeprom eeprom-reset.bin
+
+ You'll need to reflash afterwards, because DFU requires the flash to be erased before messing with the eeprom. \ No newline at end of file
diff --git a/quantum/tools/eeprom_reset.hex b/quantum/tools/eeprom_reset.hex
new file mode 100644
index 000000000..a8a75389f
--- /dev/null
+++ b/quantum/tools/eeprom_reset.hex
@@ -0,0 +1,9 @@
+:10000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00
+:10001000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0
+:10002000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE0
+:10003000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD0
+:10004000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC0
+:10005000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFB0
+:10006000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA0
+:10007000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF90
+:00000001FF