Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
ad982e39d6 | ||
|
0ad93d7443 | ||
|
690a08cbbb | ||
|
7923376de1 | ||
|
8582faab6f | ||
|
60a0b08da3 | ||
|
5cc7df8750 |
@@ -155,9 +155,6 @@ endif
|
||||
ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
|
||||
ifeq ($(strip $(VISUALIZER_ENABLE)), yes)
|
||||
CIE1931_CURVE = yes
|
||||
endif
|
||||
ifeq ($(strip $(BACKLIGHT_CUSTOM_DRIVER)), yes)
|
||||
OPT_DEFS += -DBACKLIGHT_CUSTOM_DRIVER
|
||||
endif
|
||||
endif
|
||||
|
||||
|
@@ -35,12 +35,10 @@ New names should try to stick to the standards set by existing layouts, and can
|
||||
|
||||
## Supporting a Layout
|
||||
|
||||
For a keyboard to support a layout, the variable must be defined in it's `<keyboard>.h`, and match the number of arguments/keys (and preferably the physical layout):
|
||||
For a keyboard to support a layout, the variable (`[a-z0-9_]`) must be defined in it's `<keyboard>.h`, and match the number of arguments/keys (and preferably the physical layout):
|
||||
|
||||
#define LAYOUT_60_ansi KEYMAP_ANSI
|
||||
|
||||
The name of the layout must match this regex: `[a-z0-9_]+`
|
||||
|
||||
The folder name must be added to the keyboard's `rules.mk`:
|
||||
|
||||
LAYOUTS = 60_ansi
|
||||
|
@@ -28,8 +28,6 @@ MCU = cortex-m4
|
||||
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
|
||||
ARMV = 7
|
||||
|
||||
USE_FPU = yes
|
||||
|
||||
# Vector table for application
|
||||
# 0x00000000-0x00001000 area is occupied by bootlaoder.*/
|
||||
# The CORTEX_VTOR... is needed only for MCHCK/Infinity KB
|
||||
|
@@ -1,86 +0,0 @@
|
||||
#include "dz60.h"
|
||||
|
||||
#define MODS_CTRL_MASK (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT))
|
||||
|
||||
#define ______ KC_TRNS
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
/* Qwerty
|
||||
* ,-----------------------------------------------------------------------------------------.
|
||||
* | ` ~ | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | Bkspc |
|
||||
* |-----------------------------------------------------------------------------------------+
|
||||
* | Tab | Q | W | E | R | T | Y | U | I | O | P | [ | ] | \ |
|
||||
* |-----------------------------------------------------------------------------------------+
|
||||
* | Caps | A | S | D | F | G | H | J | K | L | ; | ' | Enter |
|
||||
* |-----------------------------------------------------------------------------------------+
|
||||
* | Shift | Z | X | C | V | B | N | M | , | . | / | RSh | U | FN |
|
||||
* |-----------------------------------------------------------------------------------------+
|
||||
* | Ctrl | Alt | Cmd | Space | Cmd | RAlt | L | D | R |
|
||||
* `-----------------------------------------------------------------------------------------'
|
||||
*/
|
||||
|
||||
KEYMAP_2_SHIFTS(
|
||||
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, ______, KC_BSPC,
|
||||
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS,
|
||||
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT,
|
||||
KC_LSFT, ______, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, MO(1),
|
||||
KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_SPC, KC_SPC, KC_RGUI, KC_RALT, KC_LEFT, KC_DOWN, KC_RIGHT
|
||||
),
|
||||
|
||||
/* FN Layer
|
||||
* ,-----------------------------------------------------------------------------------------.
|
||||
* | Esc | BL- | BL+ | BL | | | |RESET| | | | | | |
|
||||
* |-----------------------------------------------------------------------------------------+
|
||||
* | |RBGM | | | | | | | | | | Val+ | Val- |RBGTOG|
|
||||
* |-----------------------------------------------------------------------------------------+
|
||||
* | | Hue+| Hue-| Sat+| Sat-| | | | | | | | |
|
||||
* |-----------------------------------------------------------------------------------------+
|
||||
* | | | | | | | | | | | | | Ctrl| |
|
||||
* |-----------------------------------------------------------------------------------------+
|
||||
* | | | | | | | | | |
|
||||
* `-----------------------------------------------------------------------------------------'
|
||||
*/
|
||||
|
||||
KEYMAP_DIRECTIONAL(
|
||||
KC_ESC, BL_TOGG, BL_STEP, BL_DEC, BL_INC, ______, ______, RESET, ______, ______, ______, ______, ______, ______, ______,
|
||||
______, RGB_MOD, ______, ______, ______, ______, ______, ______, ______, ______, ______, RGB_VAI, RGB_VAD, RGB_TOG,
|
||||
______, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, ______, ______, ______, ______, ______, ______, ______,
|
||||
______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______, KC_RCTL, ______,
|
||||
______, ______, ______, ______, ______, ______, ______, ______, ______, ______, ______
|
||||
),
|
||||
};
|
||||
|
||||
enum function_id {
|
||||
SHIFT_ESC,
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM fn_actions[] = {
|
||||
[0] = ACTION_FUNCTION(SHIFT_ESC),
|
||||
};
|
||||
|
||||
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
|
||||
static uint8_t shift_esc_shift_mask;
|
||||
switch (id) {
|
||||
case SHIFT_ESC:
|
||||
shift_esc_shift_mask = get_mods()&MODS_CTRL_MASK;
|
||||
if (record->event.pressed) {
|
||||
if (shift_esc_shift_mask) {
|
||||
add_key(KC_GRV);
|
||||
send_keyboard_report();
|
||||
} else {
|
||||
add_key(KC_ESC);
|
||||
send_keyboard_report();
|
||||
}
|
||||
} else {
|
||||
if (shift_esc_shift_mask) {
|
||||
del_key(KC_GRV);
|
||||
send_keyboard_report();
|
||||
} else {
|
||||
del_key(KC_ESC);
|
||||
send_keyboard_report();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
@@ -20,7 +20,4 @@
|
||||
#define IGNORE_MOD_TAP_INTERRUPT // this makes it possible to do rolling combos (zx) with keys that convert to other keys on hold (z becomes ctrl when you hold it, and when this option isn't enabled, z rapidly followed by x actually sends Ctrl-x. That's bad.)
|
||||
#define ONESHOT_TAP_TOGGLE 2
|
||||
|
||||
#undef PRODUCT
|
||||
#define PRODUCT DrashnaDox - Hacked ErgoDox EZ Shine
|
||||
|
||||
#endif
|
||||
|
@@ -52,7 +52,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
KC_EQUAL, KC_1, KC_2, KC_3, KC_4, KC_5, TG(_MOUS),
|
||||
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, TG(_DIABLO),
|
||||
KC_BSPACE, KC_A, KC_S, KC_D, KC_F, KC_G,
|
||||
KC_LSFT, LCTL_T(KC_Z),KC_X, KC_C, KC_V, KC_B, TG(_GAMEPAD),
|
||||
OSM(MOD_LSFT), LCTL_T(KC_Z),KC_X, KC_C, KC_V, KC_B, TG(_GAMEPAD),
|
||||
LT(_SYMB,KC_GRAVE),KC_QUOTE, KC_LGUI, KC_LBRACKET,KC_RBRACKET,
|
||||
|
||||
ALT_T(KC_APPLICATION), KC_LGUI,
|
||||
@@ -96,7 +96,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, TG(_MOUS),
|
||||
KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, TG(_DIABLO),
|
||||
KC_BSPC, KC_A, KC_R, KC_S, KC_T, KC_D,
|
||||
KC_LSFT, LCTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B, TG(_GAMEPAD),
|
||||
OSM(MOD_LSFT), LCTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B, TG(_GAMEPAD),
|
||||
LT(_SYMB,KC_GRV),KC_QUOT, KC_LGUI, KC_LBRACKET,KC_RBRACKET,
|
||||
ALT_T(KC_APP), KC_LGUI,
|
||||
KC_HOME,
|
||||
@@ -139,7 +139,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, TG(_MOUS),
|
||||
KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, TG(_DIABLO),
|
||||
KC_BSPC, KC_A, KC_O, KC_E, KC_U, KC_I,
|
||||
KC_LSFT, LCTL_T(KC_SCLN), KC_Q, KC_J, KC_K, KC_X, TG(_GAMEPAD),
|
||||
OSM(MOD_LSFT), LCTL_T(KC_SCLN), KC_Q, KC_J, KC_K, KC_X, TG(_GAMEPAD),
|
||||
LT(_SYMB,KC_GRV),KC_QUOT, KC_LGUI, KC_LBRACKET, KC_RBRACKET,
|
||||
ALT_T(KC_APP), KC_LEAD,
|
||||
KC_HOME,
|
||||
@@ -182,7 +182,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, TG(_MOUS),
|
||||
KC_TAB, KC_Q, KC_D, KC_R, KC_W, KC_B, TG(_DIABLO),
|
||||
KC_BSPC, KC_A, KC_S, KC_H, KC_T, KC_G,
|
||||
KC_LSFT, LCTL_T(KC_Z), KC_X, KC_M, KC_C, KC_V, TG(_GAMEPAD),
|
||||
OSM(MOD_LSFT), LCTL_T(KC_Z), KC_X, KC_M, KC_C, KC_V, TG(_GAMEPAD),
|
||||
LT(_SYMB,KC_GRV),KC_QUOT, KC_LGUI, KC_LBRACKET,KC_RBRACKET,
|
||||
ALT_T(KC_APP), KC_LEAD,
|
||||
KC_HOME,
|
||||
|
@@ -1,212 +0,0 @@
|
||||
/**
|
||||
* Backlighting code for PS2AVRGB boards (ATMEGA32A)
|
||||
* Kenneth A. (github.com/krusli | krusli.me)
|
||||
*/
|
||||
|
||||
#include "backlight.h"
|
||||
#include "quantum.h"
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
#include "backlight_custom.h"
|
||||
#include "breathing_custom.h"
|
||||
|
||||
// DEBUG
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// Port D: digital pins of the AVR chipset
|
||||
#define NUMLOCK_PORT (1 << 1) // 1st pin of Port D (digital)
|
||||
#define CAPSLOCK_PORT (1 << 2) // 2nd pin
|
||||
#define BACKLIGHT_PORT (1 << 4) // 4th pin
|
||||
#define SCROLLLOCK_PORT (1 << 6) // 6th pin
|
||||
|
||||
#define TIMER_CLK_DIV64 0x03 ///< Timer clocked at F_CPU/64
|
||||
#define TIMER1PRESCALE TIMER_CLK_DIV64 ///< timer 1 prescaler default
|
||||
|
||||
#define TIMER_PRESCALE_MASK 0x07 ///< Timer Prescaler Bit-Mask
|
||||
|
||||
#define PWM_MAX 0xFF
|
||||
#define TIMER_TOP 255 // 8 bit PWM
|
||||
|
||||
extern backlight_config_t backlight_config;
|
||||
|
||||
/**
|
||||
* References
|
||||
* Port Registers: https://www.arduino.cc/en/Reference/PortManipulation
|
||||
* TCCR1A: https://electronics.stackexchange.com/questions/92350/what-is-the-difference-between-tccr1a-and-tccr1b
|
||||
* Timers: http://www.avrbeginners.net/architecture/timers/timers.html
|
||||
* 16-bit timer setup: http://sculland.com/ATmega168/Interrupts-And-Timers/16-Bit-Timer-Setup/
|
||||
* PS2AVRGB firmware: https://github.com/showjean/ps2avrU/tree/master/firmware
|
||||
*/
|
||||
|
||||
// @Override
|
||||
// turn LEDs on and off depending on USB caps/num/scroll lock states.
|
||||
void led_set_user(uint8_t usb_led) {
|
||||
if (usb_led & (1 << USB_LED_NUM_LOCK)) {
|
||||
// turn on
|
||||
DDRD |= NUMLOCK_PORT;
|
||||
PORTD |= NUMLOCK_PORT;
|
||||
} else {
|
||||
// turn off
|
||||
DDRD &= ~NUMLOCK_PORT;
|
||||
PORTD &= ~NUMLOCK_PORT;
|
||||
}
|
||||
|
||||
if (usb_led & (1 << USB_LED_CAPS_LOCK)) {
|
||||
DDRD |= CAPSLOCK_PORT;
|
||||
PORTD |= CAPSLOCK_PORT;
|
||||
} else {
|
||||
DDRD &= ~CAPSLOCK_PORT;
|
||||
PORTD &= ~CAPSLOCK_PORT;
|
||||
}
|
||||
|
||||
if (usb_led & (1 << USB_LED_SCROLL_LOCK)) {
|
||||
DDRD |= SCROLLLOCK_PORT;
|
||||
PORTD |= SCROLLLOCK_PORT;
|
||||
} else {
|
||||
DDRD &= ~SCROLLLOCK_PORT;
|
||||
PORTD &= ~SCROLLLOCK_PORT;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
|
||||
// sets up Timer 1 for 8-bit PWM
|
||||
void timer1PWMSetup(void) { // NOTE ONLY CALL THIS ONCE
|
||||
// default 8 bit mode
|
||||
TCCR1A &= ~(1 << 1); // cbi(TCCR1A,PWM11); <- set PWM11 bit to HIGH
|
||||
TCCR1A |= (1 << 0); // sbi(TCCR1A,PWM10); <- set PWM10 bit to LOW
|
||||
|
||||
// clear output compare value A
|
||||
// outb(OCR1AH, 0);
|
||||
// outb(OCR1AL, 0);
|
||||
|
||||
// clear output comparator registers for B
|
||||
OCR1BH = 0; // outb(OCR1BH, 0);
|
||||
OCR1BL = 0; // outb(OCR1BL, 0);
|
||||
}
|
||||
|
||||
bool is_init = false;
|
||||
void timer1Init(void) {
|
||||
// timer1SetPrescaler(TIMER1PRESCALE)
|
||||
// set to DIV/64
|
||||
(TCCR1B) = ((TCCR1B) & ~TIMER_PRESCALE_MASK) | TIMER1PRESCALE;
|
||||
|
||||
// reset TCNT1
|
||||
TCNT1H = 0; // outb(TCNT1H, 0);
|
||||
TCNT1L = 0; // outb(TCNT1L, 0);
|
||||
|
||||
// TOIE1: Timer Overflow Interrupt Enable (Timer 1);
|
||||
TIMSK |= _BV(TOIE1); // sbi(TIMSK, TOIE1);
|
||||
|
||||
is_init = true;
|
||||
}
|
||||
|
||||
void timer1UnInit(void) {
|
||||
// set prescaler back to NONE
|
||||
(TCCR1B) = ((TCCR1B) & ~TIMER_PRESCALE_MASK) | 0x00; // TIMERRTC_CLK_STOP
|
||||
|
||||
// disable timer overflow interrupt
|
||||
TIMSK &= ~_BV(TOIE1); // overflow bit?
|
||||
|
||||
setPWM(0);
|
||||
|
||||
is_init = false;
|
||||
}
|
||||
|
||||
|
||||
// handle TCNT1 overflow
|
||||
//! Interrupt handler for tcnt1 overflow interrupt
|
||||
ISR(TIMER1_OVF_vect, ISR_NOBLOCK)
|
||||
{
|
||||
// sei();
|
||||
// handle breathing here
|
||||
#ifdef BACKLIGHT_BREATHING
|
||||
if (is_breathing()) {
|
||||
custom_breathing_handler();
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO call user defined function
|
||||
}
|
||||
|
||||
// enable timer 1 PWM
|
||||
// timer1PWMBOn()
|
||||
void timer1PWMBEnable(void) {
|
||||
// turn on channel B (OC1B) PWM output
|
||||
// set OC1B as non-inverted PWM
|
||||
TCCR1A |= _BV(COM1B1);
|
||||
TCCR1A &= ~_BV(COM1B0);
|
||||
}
|
||||
|
||||
// disable timer 1 PWM
|
||||
// timer1PWMBOff()
|
||||
void timer1PWMBDisable(void) {
|
||||
TCCR1A &= ~_BV(COM1B1);
|
||||
TCCR1A &= ~_BV(COM1B0);
|
||||
}
|
||||
|
||||
void enableBacklight(void) {
|
||||
DDRD |= BACKLIGHT_PORT; // set digital pin 4 as output
|
||||
PORTD |= BACKLIGHT_PORT; // set digital pin 4 to high
|
||||
}
|
||||
|
||||
void disableBacklight(void) {
|
||||
// DDRD &= ~BACKLIGHT_PORT; // set digital pin 4 as input
|
||||
PORTD &= ~BACKLIGHT_PORT; // set digital pin 4 to low
|
||||
}
|
||||
|
||||
void startPWM(void) {
|
||||
timer1Init();
|
||||
timer1PWMBEnable();
|
||||
enableBacklight();
|
||||
}
|
||||
|
||||
void stopPWM(void) {
|
||||
timer1UnInit();
|
||||
disableBacklight();
|
||||
timer1PWMBDisable();
|
||||
}
|
||||
|
||||
void b_led_init_ports(void) {
|
||||
/* turn backlight on/off depending on user preference */
|
||||
#if BACKLIGHT_ON_STATE == 0
|
||||
// DDRx register: sets the direction of Port D
|
||||
// DDRD &= ~BACKLIGHT_PORT; // set digital pin 4 as input
|
||||
PORTD &= ~BACKLIGHT_PORT; // set digital pin 4 to low
|
||||
#else
|
||||
DDRD |= BACKLIGHT_PORT; // set digital pin 4 as output
|
||||
PORTD |= BACKLIGHT_PORT; // set digital pin 4 to high
|
||||
#endif
|
||||
|
||||
timer1PWMSetup();
|
||||
startPWM();
|
||||
|
||||
#ifdef BACKLIGHT_BREATHING
|
||||
breathing_enable();
|
||||
#endif
|
||||
}
|
||||
|
||||
void b_led_set(uint8_t level) {
|
||||
if (level > BACKLIGHT_LEVELS) {
|
||||
level = BACKLIGHT_LEVELS;
|
||||
}
|
||||
|
||||
setPWM((int)(TIMER_TOP * (float) level / BACKLIGHT_LEVELS));
|
||||
}
|
||||
|
||||
// called every matrix scan
|
||||
void b_led_task(void) {
|
||||
// do nothing for now
|
||||
}
|
||||
|
||||
void setPWM(uint16_t xValue) {
|
||||
if (xValue > TIMER_TOP) {
|
||||
xValue = TIMER_TOP;
|
||||
}
|
||||
OCR1B = xValue; // timer1PWMBSet(xValue);
|
||||
}
|
||||
|
||||
#endif // BACKLIGHT_ENABLE
|
@@ -1,15 +0,0 @@
|
||||
/**
|
||||
* Backlighting code for PS2AVRGB boards (ATMEGA32A)
|
||||
* Kenneth A. (github.com/krusli | krusli.me)
|
||||
*/
|
||||
|
||||
#ifndef BACKLIGHT_CUSTOM_H
|
||||
#define BACKLIGHT_CUSTOM_H
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
void b_led_init_ports(void);
|
||||
void b_led_set(uint8_t level);
|
||||
void b_led_task(void);
|
||||
void setPWM(uint16_t xValue);
|
||||
|
||||
#endif // BACKLIGHT_CUSTOM_H
|
@@ -1,140 +0,0 @@
|
||||
/**
|
||||
* Breathing effect code for PS2AVRGB boards (ATMEGA32A)
|
||||
* Works in conjunction with `backlight.c`.
|
||||
*
|
||||
* Code adapted from `quantum.c` to register with the existing TIMER1 overflow
|
||||
* handler in `backlight.c` instead of setting up its own timer.
|
||||
* Kenneth A. (github.com/krusli | krusli.me)
|
||||
*/
|
||||
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
#ifdef BACKLIGHT_BREATHING
|
||||
|
||||
#include "backlight_custom.h"
|
||||
|
||||
#ifndef BREATHING_PERIOD
|
||||
#define BREATHING_PERIOD 6
|
||||
#endif
|
||||
|
||||
#define breathing_min() do {breathing_counter = 0;} while (0)
|
||||
#define breathing_max() do {breathing_counter = breathing_period * 244 / 2;} while (0)
|
||||
|
||||
// TODO make this share code with quantum.c
|
||||
|
||||
#define BREATHING_NO_HALT 0
|
||||
#define BREATHING_HALT_OFF 1
|
||||
#define BREATHING_HALT_ON 2
|
||||
#define BREATHING_STEPS 128
|
||||
|
||||
static uint8_t breathing_period = BREATHING_PERIOD;
|
||||
static uint8_t breathing_halt = BREATHING_NO_HALT;
|
||||
static uint16_t breathing_counter = 0;
|
||||
|
||||
static bool breathing = false;
|
||||
|
||||
bool is_breathing(void) {
|
||||
return breathing;
|
||||
}
|
||||
|
||||
// See http://jared.geek.nz/2013/feb/linear-led-pwm
|
||||
static uint16_t cie_lightness(uint16_t v) {
|
||||
if (v <= 5243) // if below 8% of max
|
||||
return v / 9; // same as dividing by 900%
|
||||
else {
|
||||
uint32_t y = (((uint32_t) v + 10486) << 8) / (10486 + 0xFFFFUL); // add 16% of max and compare
|
||||
// to get a useful result with integer division, we shift left in the expression above
|
||||
// and revert what we've done again after squaring.
|
||||
y = y * y * y >> 8;
|
||||
if (y > 0xFFFFUL) // prevent overflow
|
||||
return 0xFFFFU;
|
||||
else
|
||||
return (uint16_t) y;
|
||||
}
|
||||
}
|
||||
|
||||
void breathing_enable(void) {
|
||||
breathing = true;
|
||||
breathing_counter = 0;
|
||||
breathing_halt = BREATHING_NO_HALT;
|
||||
// interrupt already registered
|
||||
}
|
||||
|
||||
void breathing_pulse(void) {
|
||||
if (get_backlight_level() == 0)
|
||||
breathing_min();
|
||||
else
|
||||
breathing_max();
|
||||
breathing_halt = BREATHING_HALT_ON;
|
||||
// breathing_interrupt_enable();
|
||||
breathing = true;
|
||||
}
|
||||
|
||||
void breathing_disable(void) {
|
||||
breathing = false;
|
||||
// backlight_set(get_backlight_level());
|
||||
b_led_set(get_backlight_level()); // custom implementation of backlight_set()
|
||||
}
|
||||
|
||||
void breathing_self_disable(void)
|
||||
{
|
||||
if (get_backlight_level() == 0)
|
||||
breathing_halt = BREATHING_HALT_OFF;
|
||||
else
|
||||
breathing_halt = BREATHING_HALT_ON;
|
||||
}
|
||||
|
||||
void breathing_toggle(void) {
|
||||
if (is_breathing())
|
||||
breathing_disable();
|
||||
else
|
||||
breathing_enable();
|
||||
}
|
||||
|
||||
void breathing_period_set(uint8_t value)
|
||||
{
|
||||
if (!value)
|
||||
value = 1;
|
||||
breathing_period = value;
|
||||
}
|
||||
|
||||
void breathing_period_default(void) {
|
||||
breathing_period_set(BREATHING_PERIOD);
|
||||
}
|
||||
|
||||
void breathing_period_inc(void)
|
||||
{
|
||||
breathing_period_set(breathing_period+1);
|
||||
}
|
||||
|
||||
void breathing_period_dec(void)
|
||||
{
|
||||
breathing_period_set(breathing_period-1);
|
||||
}
|
||||
|
||||
/* To generate breathing curve in python:
|
||||
* from math import sin, pi; [int(sin(x/128.0*pi)**4*255) for x in range(128)]
|
||||
*/
|
||||
static const uint8_t breathing_table[BREATHING_STEPS] PROGMEM = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 17, 20, 24, 28, 32, 36, 41, 46, 51, 57, 63, 70, 76, 83, 91, 98, 106, 113, 121, 129, 138, 146, 154, 162, 170, 178, 185, 193, 200, 207, 213, 220, 225, 231, 235, 240, 244, 247, 250, 252, 253, 254, 255, 254, 253, 252, 250, 247, 244, 240, 235, 231, 225, 220, 213, 207, 200, 193, 185, 178, 170, 162, 154, 146, 138, 129, 121, 113, 106, 98, 91, 83, 76, 70, 63, 57, 51, 46, 41, 36, 32, 28, 24, 20, 17, 15, 12, 10, 8, 6, 5, 4, 3, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
// Use this before the cie_lightness function.
|
||||
static inline uint16_t scale_backlight(uint16_t v) {
|
||||
return v / BACKLIGHT_LEVELS * get_backlight_level();
|
||||
}
|
||||
|
||||
void custom_breathing_handler(void) {
|
||||
uint16_t interval = (uint16_t) breathing_period * 244 / BREATHING_STEPS;
|
||||
// resetting after one period to prevent ugly reset at overflow.
|
||||
breathing_counter = (breathing_counter + 1) % (breathing_period * 244);
|
||||
uint8_t index = breathing_counter / interval % BREATHING_STEPS;
|
||||
|
||||
if (((breathing_halt == BREATHING_HALT_ON) && (index == BREATHING_STEPS / 2)) ||
|
||||
((breathing_halt == BREATHING_HALT_OFF) && (index == BREATHING_STEPS - 1)))
|
||||
{
|
||||
// breathing_interrupt_disable();
|
||||
}
|
||||
|
||||
setPWM(cie_lightness(scale_backlight((uint16_t) pgm_read_byte(&breathing_table[index]) * 0x0101U)));
|
||||
}
|
||||
|
||||
#endif // BACKLIGHT_BREATHING
|
||||
#endif // BACKLIGHT_ENABLE
|
@@ -34,8 +34,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/* COL2ROW or ROW2COL */
|
||||
#define DIODE_DIRECTION COL2ROW
|
||||
|
||||
#define BACKLIGHT_LEVELS 12
|
||||
// #define BACKLIGHT_BREATHING // works, but BL_TOGG might not work
|
||||
#define BACKLIGHT_PIN B6
|
||||
#define BACKLIGHT_LEVELS 3
|
||||
|
||||
#define TAPPING_TOGGLE 3
|
||||
|
||||
@@ -45,7 +45,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// The RGB_DI_PIN value seems to be shared between all PS2AVRGB boards.
|
||||
// The same pin is used on the JJ40, at least.
|
||||
#define RGBLED_NUM 5
|
||||
#define RGB_DI_PIN E2 // NOTE: for PS2AVRGB boards, underglow commands are sent via I2C to 0xB0.
|
||||
#define RGB_DI_PIN E2
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
|
||||
/* key combination for command */
|
||||
|
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
|
||||
Modified 2018 Kenneth A. <github.com/krusli>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -25,34 +24,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "i2c.h"
|
||||
|
||||
#include "backlight.h"
|
||||
#include "backlight_custom.h"
|
||||
|
||||
extern rgblight_config_t rgblight_config;
|
||||
|
||||
// for keyboard subdirectory level init functions
|
||||
// @Override
|
||||
void matrix_init_kb(void) {
|
||||
// call user level keymaps, if any
|
||||
// matrix_init_user();
|
||||
}
|
||||
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
/// Overrides functions in `quantum.c`
|
||||
void backlight_init_ports(void) {
|
||||
b_led_init_ports();
|
||||
}
|
||||
|
||||
void backlight_task(void) {
|
||||
b_led_task();
|
||||
}
|
||||
|
||||
void backlight_set(uint8_t level) {
|
||||
b_led_set(level);
|
||||
}
|
||||
#endif
|
||||
|
||||
// custom RGB driver
|
||||
extern rgblight_config_t rgblight_config;
|
||||
void rgblight_set(void) {
|
||||
if (!rgblight_config.enable) {
|
||||
for (uint8_t i=0; i<RGBLED_NUM; i++) {
|
||||
@@ -66,15 +39,8 @@ void rgblight_set(void) {
|
||||
i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
|
||||
}
|
||||
|
||||
bool rgb_init = false;
|
||||
__attribute__ ((weak))
|
||||
void matrix_scan_user(void) {
|
||||
// if LEDs were previously on before poweroff, turn them back on
|
||||
if (rgb_init == false && rgblight_config.enable) {
|
||||
i2c_init();
|
||||
i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM);
|
||||
rgb_init = true;
|
||||
}
|
||||
|
||||
rgblight_task();
|
||||
/* Nothing else for now. */
|
||||
rgblight_task();
|
||||
/* Nothing else for now. */
|
||||
}
|
||||
|
@@ -23,8 +23,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include "keycode.h"
|
||||
#include "action.h"
|
||||
|
||||
void matrix_init_user(void); // TODO port this to other PS2AVRGB boards
|
||||
|
||||
#define KEYMAP_GRID( \
|
||||
K01, K02, K03, K04, K05, K06, K07, K08, K09, K010, K011, K012, \
|
||||
K11, K12, K13, K14, K15, K16, K17, K18, K19, K110, K111, K112, \
|
||||
|
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "jj40.h"
|
||||
#include "action_layer.h"
|
||||
|
||||
|
@@ -1,8 +0,0 @@
|
||||
#ifndef CONFIG_USER_H
|
||||
#define CONFIG_USER_H
|
||||
|
||||
#include "../../config.h"
|
||||
|
||||
#define PREVENT_STUCK_MODIFIERS
|
||||
|
||||
#endif
|
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "jj40.h"
|
||||
#include "action_layer.h"
|
||||
|
||||
@@ -45,7 +62,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, \
|
||||
KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \
|
||||
_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______,_______, _______, _______, \
|
||||
BL_TOGG, BL_STEP, BL_BRTG, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
|
||||
_______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
|
||||
),
|
||||
|
||||
/* Raise
|
||||
@@ -56,13 +73,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | | F7 | F8 | F9 | F10 | F11 | F12 | RGB | RGB | RGB | RGB |Enter |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | RGB | RGB | RGB | RGB | | | | Next | Vol- | Vol+ | Play |
|
||||
* | | RGB | RGB | RGB | RGB | | | Next | Vol- | Vol+ | Play |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_RAISE] = KEYMAP( \
|
||||
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
|
||||
KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \
|
||||
_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, RGB_TOG, RGB_MOD, RGB_VAD, RGB_VAI, _______, \
|
||||
RGB_HUD, RGB_HUI, RGB_SAD, RGB_SAI, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
|
||||
_______, RGB_HUD, RGB_HUI, RGB_SAD, RGB_SAI, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
|
||||
)
|
||||
};
|
||||
|
@@ -29,9 +29,6 @@ static uint8_t debouncing = DEBOUNCE;
|
||||
static matrix_row_t matrix[MATRIX_ROWS];
|
||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
||||
|
||||
void matrix_set_row_status(uint8_t row);
|
||||
uint8_t bit_reverse(uint8_t x);
|
||||
|
||||
void matrix_init(void) {
|
||||
// all outputs for rows high
|
||||
DDRB = 0xFF;
|
||||
@@ -50,8 +47,18 @@ void matrix_init(void) {
|
||||
matrix[row] = 0x00;
|
||||
matrix_debouncing[row] = 0x00;
|
||||
}
|
||||
}
|
||||
|
||||
matrix_init_quantum(); // missing from original port by Luiz
|
||||
void matrix_set_row_status(uint8_t row) {
|
||||
DDRB = (1 << row);
|
||||
PORTB = ~(1 << row);
|
||||
}
|
||||
|
||||
uint8_t bit_reverse(uint8_t x) {
|
||||
x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
|
||||
x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
|
||||
x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0);
|
||||
return x;
|
||||
}
|
||||
|
||||
uint8_t matrix_scan(void) {
|
||||
@@ -86,30 +93,11 @@ uint8_t matrix_scan(void) {
|
||||
}
|
||||
}
|
||||
|
||||
matrix_scan_quantum(); // also missing in original PS2AVRGB implementation
|
||||
matrix_scan_user();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void matrix_scan_kb(void) {
|
||||
// Looping keyboard code goes here
|
||||
// This runs every cycle (a lot)
|
||||
matrix_scan_user();
|
||||
};
|
||||
|
||||
// declarations
|
||||
void matrix_set_row_status(uint8_t row) {
|
||||
DDRB = (1 << row);
|
||||
PORTB = ~(1 << row);
|
||||
}
|
||||
|
||||
uint8_t bit_reverse(uint8_t x) {
|
||||
x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
|
||||
x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
|
||||
x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0);
|
||||
return x;
|
||||
}
|
||||
|
||||
inline matrix_row_t matrix_get_row(uint8_t row) {
|
||||
return matrix[row];
|
||||
}
|
||||
|
@@ -36,13 +36,11 @@ MOUSEKEY_ENABLE = no
|
||||
EXTRAKEY_ENABLE = yes
|
||||
CONSOLE_ENABLE = no
|
||||
COMMAND_ENABLE = yes
|
||||
|
||||
BACKLIGHT_ENABLE = yes
|
||||
BACKLIGHT_CUSTOM_DRIVER = yes
|
||||
BACKLIGHT_ENABLE = no
|
||||
|
||||
RGBLIGHT_ENABLE = yes
|
||||
RGBLIGHT_CUSTOM_DRIVER = yes
|
||||
# DISABLE_WS2812 = no
|
||||
DISABLE_WS2812 = yes # TODO check if this is necessary
|
||||
|
||||
KEY_LOCK_ENABLE = yes
|
||||
|
||||
@@ -53,7 +51,7 @@ OPT_DEFS = -DDEBUG_LEVEL=0
|
||||
|
||||
# custom matrix setup
|
||||
CUSTOM_MATRIX = yes
|
||||
SRC = matrix.c i2c.c backlight.c
|
||||
SRC = matrix.c i2c.c
|
||||
|
||||
# programming options
|
||||
PROGRAM_CMD = ./util/atmega32a_program.py $(TARGET).hex
|
||||
|
@@ -119,7 +119,7 @@ section at the end of this file).
|
||||
* device is powered from the USB bus.
|
||||
*/
|
||||
// max power draw with maxed white underglow measured at 120 mA (peaks)
|
||||
#define USB_CFG_MAX_BUS_POWER 100
|
||||
#define USB_CFG_MAX_BUS_POWER 150
|
||||
/* Set this variable to the maximum USB bus power consumption of your device.
|
||||
* The value is in milliamperes. [It will be divided by two since USB
|
||||
* communicates power requirements in units of 2 mA.]
|
||||
|
@@ -27,7 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/* Use I2C or Serial, not both */
|
||||
|
||||
#define USE_SERIAL
|
||||
#undef USE_I2C
|
||||
// #define USE_I2C
|
||||
|
||||
/* Select hand configuration */
|
||||
|
||||
@@ -71,10 +71,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#define STARTUP_SONG SONG(ZELDA_TREASURE)
|
||||
#endif
|
||||
|
||||
#undef PRODUCT
|
||||
#ifdef KEYBOARD_orthodox_rev1
|
||||
#define PRODUCT Drashna Hacked Orthodox Rev.1
|
||||
#elif KEYBOARD_orthodox_rev3
|
||||
#define PRODUCT Drashna Hacked Orthodox Rev.3
|
||||
#endif
|
||||
#endif
|
||||
|
@@ -32,30 +32,42 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#define _______ KC_TRNS
|
||||
#define XXXXXXX KC_NO
|
||||
|
||||
#ifdef FAUXCLICKY_ENABLE
|
||||
float fauxclicky_pressed_note[2] = MUSICAL_NOTE(_A6, 2); // (_D4, 0.25);
|
||||
float fauxclicky_released_note[2] = MUSICAL_NOTE(_A6, 2); // (_C4, 0.125);
|
||||
float fauxclicky_beep_note[2] = MUSICAL_NOTE(_C6, 2); // (_C4, 0.25);
|
||||
#define AUD_ON FC_ON
|
||||
#define AUD_OFF FC_OFF
|
||||
#else
|
||||
#define AUD_ON AU_ON
|
||||
#define AUD_OFF AU_OFF
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
[_QWERTY] = KEYMAP(\
|
||||
KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \
|
||||
KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_UP, KC_DOWN, KC_LEFT, KC_RIGHT, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
|
||||
KC_LSFT,CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B, LOWER, KC_SPACE, KC_BSPC, KC_DEL, KC_ENT, RAISE, KC_N, KC_M, KC_COMM, KC_DOT, CTL_T(KC_SLASH), KC_LGUI \
|
||||
OSM(MOD_LSFT),CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B, LOWER, KC_SPACE, KC_BSPC, KC_DEL, KC_ENT, RAISE, KC_N, KC_M, KC_COMM, KC_DOT, CTL_T(KC_SLASH), KC_LGUI \
|
||||
),
|
||||
|
||||
[_COLEMAK] = KEYMAP(\
|
||||
KC_ESC, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC, \
|
||||
KC_TAB, KC_A, KC_R, KC_S, KC_T, KC_D, KC_UP, KC_DOWN, KC_LEFT, KC_RIGHT, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT, \
|
||||
KC_LSFT, CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B, LOWER, KC_SPACE, KC_BSPC, KC_DEL, KC_ENT, RAISE, KC_K, KC_M, KC_COMM, KC_DOT, CTL_T(KC_SLASH), KC_LGUI \
|
||||
OSM(MOD_LSFT), CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B, LOWER, KC_SPACE, KC_BSPC, KC_DEL, KC_ENT, RAISE, KC_K, KC_M, KC_COMM, KC_DOT, CTL_T(KC_SLASH), KC_LGUI \
|
||||
),
|
||||
|
||||
[_DVORAK] = KEYMAP(\
|
||||
KC_ESC, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC, \
|
||||
KC_TAB, KC_A, KC_O, KC_E, KC_U, KC_I, KC_UP, KC_DOWN, KC_LEFT, KC_RIGHT, KC_D, KC_H, KC_T, KC_N, KC_S, KC_MINS, \
|
||||
KC_LSFT, CTL_T(KC_SCLN), KC_Q, KC_J, KC_K, KC_X, LOWER, KC_SPACE, KC_BSPC, KC_DEL, KC_ENT, RAISE, KC_B, KC_M, KC_W, KC_V, CTL_T(KC_Z), KC_LGUI \
|
||||
OSM(MOD_LSFT), CTL_T(KC_SCLN), KC_Q, KC_J, KC_K, KC_X, LOWER, KC_SPACE, KC_BSPC, KC_DEL, KC_ENT, RAISE, KC_B, KC_M, KC_W, KC_V, CTL_T(KC_Z), KC_LGUI \
|
||||
),
|
||||
[_WORKMAN] = KEYMAP(\
|
||||
KC_ESC, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC, \
|
||||
KC_TAB, KC_A, KC_O, KC_E, KC_U, KC_I, KC_UP, KC_DOWN, KC_LEFT, KC_RIGHT, KC_D, KC_H, KC_T, KC_N, KC_S, KC_MINS, \
|
||||
KC_LSFT,CTL_T(KC_SCLN), KC_Q, KC_J, KC_K, KC_X, LOWER, KC_SPACE, KC_BSPC, KC_DEL, KC_ENT, RAISE, KC_B, KC_M, KC_W, KC_V, CTL_T(KC_Z), KC_LGUI \
|
||||
OSM(MOD_LSFT), CTL_T(KC_SCLN), KC_Q, KC_J, KC_K, KC_X, LOWER, KC_SPACE, KC_BSPC, KC_DEL, KC_ENT, RAISE, KC_B, KC_M, KC_W, KC_V, CTL_T(KC_Z), KC_LGUI \
|
||||
),
|
||||
|
||||
[_LOWER] = KEYMAP(\
|
||||
@@ -72,7 +84,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
[_ADJUST] = KEYMAP(\
|
||||
KC_MAKE,KC_RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
|
||||
RGB_SMOD,RGB_HUI, KC_FXCL, AUD_ON, AUD_OFF, AG_NORM, _______, _______, _______, _______, AG_SWAP, KC_QWERTY, KC_COLEMAK, KC_DVORAK, KC_WORKMAN, _______, \
|
||||
RGB_SMOD,RGB_HUI, _______, AUD_ON, AUD_OFF, AG_NORM, _______, _______, _______, _______, AG_SWAP, KC_QWERTY, KC_COLEMAK, KC_DVORAK, KC_WORKMAN, _______, \
|
||||
KC_RGB_T,RGB_HUD, MU_ON, MU_OFF, MU_TOG, MU_MOD, _______, _______, _______, _______, _______, _______, MAGIC_TOGGLE_NKRO, KC_MUTE, KC_VOLD, KC_VOLU, KC_MNXT, KC_MPLY \
|
||||
)
|
||||
|
||||
|
@@ -1,11 +1,7 @@
|
||||
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
|
||||
MOUSEKEY_ENABLE = no # Mouse keys(+4700)
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
|
||||
CONSOLE_ENABLE = no # Console for debug(+400)
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
CONSOLE_ENABLE = no
|
||||
TAP_DANCE_ENABLE = no
|
||||
RGBLIGHT_ENABLE = yes
|
||||
AUDIO_ENABLE = yes
|
||||
AUDIO_ENABLE = no
|
||||
MOUSEKEY_ENABLE = no
|
||||
NKRO_ENABLE = yes
|
||||
FAUXCLICKY_ENABLE = no
|
||||
USE_I2C = no
|
||||
|
47
keyboards/planck/keymaps/audio_out/config.h
Normal file
47
keyboards/planck/keymaps/audio_out/config.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef CONFIG_USER_H
|
||||
#define CONFIG_USER_H
|
||||
|
||||
#include "config_common.h"
|
||||
|
||||
#ifdef AUDIO_ENABLE
|
||||
#define STARTUP_SONG SONG(PLANCK_SOUND)
|
||||
// #define STARTUP_SONG SONG(NO_SOUND)
|
||||
|
||||
#define DEFAULT_LAYER_SONGS { SONG(QWERTY_SOUND), \
|
||||
SONG(COLEMAK_SOUND), \
|
||||
SONG(DVORAK_SOUND) \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define MUSIC_MASK (keycode != KC_NO)
|
||||
|
||||
/*
|
||||
* MIDI options
|
||||
*/
|
||||
|
||||
/* Prevent use of disabled MIDI features in the keymap */
|
||||
//#define MIDI_ENABLE_STRICT 1
|
||||
|
||||
/* enable basic MIDI features:
|
||||
- MIDI notes can be sent when in Music mode is on
|
||||
*/
|
||||
|
||||
#define MIDI_BASIC
|
||||
|
||||
/* enable advanced MIDI features:
|
||||
- MIDI notes can be added to the keymap
|
||||
- Octave shift and transpose
|
||||
- Virtual sustain, portamento, and modulation wheel
|
||||
- etc.
|
||||
*/
|
||||
//#define MIDI_ADVANCED
|
||||
|
||||
/* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */
|
||||
//#define MIDI_TONE_KEYCODE_OCTAVES 2
|
||||
|
||||
#define C6_AUDIO
|
||||
#define B7_AUDIO
|
||||
|
||||
#undef BACKLIGHT_PIN
|
||||
|
||||
#endif
|
264
keyboards/planck/keymaps/audio_out/keymap.c
Normal file
264
keyboards/planck/keymaps/audio_out/keymap.c
Normal file
@@ -0,0 +1,264 @@
|
||||
/* Copyright 2015-2017 Jack Humbert
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "planck.h"
|
||||
#include "action_layer.h"
|
||||
|
||||
extern keymap_config_t keymap_config;
|
||||
|
||||
enum planck_layers {
|
||||
_QWERTY,
|
||||
_COLEMAK,
|
||||
_DVORAK,
|
||||
_LOWER,
|
||||
_RAISE,
|
||||
_PLOVER,
|
||||
_ADJUST
|
||||
};
|
||||
|
||||
enum planck_keycodes {
|
||||
QWERTY = SAFE_RANGE,
|
||||
COLEMAK,
|
||||
DVORAK,
|
||||
PLOVER,
|
||||
LOWER,
|
||||
RAISE,
|
||||
BACKLIT,
|
||||
EXT_PLV
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
/* Qwerty
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Esc | A | S | D | F | G | H | J | K | L | ; | " |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | Shift| Z | X | C | V | B | N | M | , | . | / |Enter |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_QWERTY] = {
|
||||
{KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC},
|
||||
{KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT},
|
||||
{KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT },
|
||||
{BACKLIT, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
|
||||
},
|
||||
|
||||
/* Colemak
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | Tab | Q | W | F | P | G | J | L | U | Y | ; | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Esc | A | R | S | T | D | H | N | E | I | O | " |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | Shift| Z | X | C | V | B | K | M | , | . | / |Enter |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_COLEMAK] = {
|
||||
{KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC},
|
||||
{KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT},
|
||||
{KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT },
|
||||
{BACKLIT, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
|
||||
},
|
||||
|
||||
/* Dvorak
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | Tab | " | , | . | P | Y | F | G | C | R | L | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Esc | A | O | E | U | I | D | H | T | N | S | / |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | Shift| ; | Q | J | K | X | B | M | W | V | Z |Enter |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_DVORAK] = {
|
||||
{KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC},
|
||||
{KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH},
|
||||
{KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT },
|
||||
{BACKLIT, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
|
||||
},
|
||||
|
||||
/* Lower
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | Home | End | |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | | | | | | | | Next | Vol- | Vol+ | Play |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_LOWER] = {
|
||||
{KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC},
|
||||
{KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE},
|
||||
{_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, S(KC_NUHS), S(KC_NUBS), KC_HOME, KC_END, _______},
|
||||
{_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
|
||||
},
|
||||
|
||||
/* Raise
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / |Pg Up |Pg Dn | |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | | | | | | | | Next | Vol- | Vol+ | Play |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_RAISE] = {
|
||||
{KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC},
|
||||
{KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS},
|
||||
{_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, KC_PGUP, KC_PGDN, _______},
|
||||
{_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
|
||||
},
|
||||
|
||||
/* Plover layer (http://opensteno.org)
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | # | # | # | # | # | # | # | # | # | # | # | # |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | | S | T | P | H | * | * | F | P | L | T | D |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | | S | K | W | R | * | * | R | B | G | S | Z |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | Exit | | | A | O | | E | U | | | |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
|
||||
[_PLOVER] = {
|
||||
{KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1 },
|
||||
{XXXXXXX, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC},
|
||||
{XXXXXXX, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT},
|
||||
{EXT_PLV, XXXXXXX, XXXXXXX, KC_C, KC_V, XXXXXXX, XXXXXXX, KC_N, KC_M, XXXXXXX, XXXXXXX, XXXXXXX}
|
||||
},
|
||||
|
||||
/* Adjust (Lower + Raise)
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | | Reset| | | | | | | | | | Del |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak|Plover| |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | |Voice-|Voice+|Mus on|Musoff|MIDIon|MIDIof| | | | | |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | | | | | | | | | | | |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[_ADJUST] = {
|
||||
{_______, RESET, DEBUG, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, KC_DEL },
|
||||
{_______, _______, MU_MOD, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, PLOVER, _______},
|
||||
{_______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, TERM_ON, TERM_OFF, _______, _______, _______},
|
||||
{_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
#ifdef AUDIO_ENABLE
|
||||
float plover_song[][2] = SONG(PLOVER_SOUND);
|
||||
float plover_gb_song[][2] = SONG(PLOVER_GOODBYE_SOUND);
|
||||
#endif
|
||||
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
switch (keycode) {
|
||||
case QWERTY:
|
||||
if (record->event.pressed) {
|
||||
print("mode just switched to qwerty and this is a huge string\n");
|
||||
set_single_persistent_default_layer(_QWERTY);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case COLEMAK:
|
||||
if (record->event.pressed) {
|
||||
set_single_persistent_default_layer(_COLEMAK);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case DVORAK:
|
||||
if (record->event.pressed) {
|
||||
set_single_persistent_default_layer(_DVORAK);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case LOWER:
|
||||
if (record->event.pressed) {
|
||||
layer_on(_LOWER);
|
||||
update_tri_layer(_LOWER, _RAISE, _ADJUST);
|
||||
} else {
|
||||
layer_off(_LOWER);
|
||||
update_tri_layer(_LOWER, _RAISE, _ADJUST);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case RAISE:
|
||||
if (record->event.pressed) {
|
||||
layer_on(_RAISE);
|
||||
update_tri_layer(_LOWER, _RAISE, _ADJUST);
|
||||
} else {
|
||||
layer_off(_RAISE);
|
||||
update_tri_layer(_LOWER, _RAISE, _ADJUST);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case BACKLIT:
|
||||
if (record->event.pressed) {
|
||||
register_code(KC_RSFT);
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
backlight_step();
|
||||
#endif
|
||||
PORTE &= ~(1<<6);
|
||||
} else {
|
||||
unregister_code(KC_RSFT);
|
||||
PORTE |= (1<<6);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case PLOVER:
|
||||
if (record->event.pressed) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
stop_all_notes();
|
||||
PLAY_SONG(plover_song);
|
||||
#endif
|
||||
layer_off(_RAISE);
|
||||
layer_off(_LOWER);
|
||||
layer_off(_ADJUST);
|
||||
layer_on(_PLOVER);
|
||||
if (!eeconfig_is_enabled()) {
|
||||
eeconfig_init();
|
||||
}
|
||||
keymap_config.raw = eeconfig_read_keymap();
|
||||
keymap_config.nkro = 1;
|
||||
eeconfig_update_keymap(keymap_config.raw);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case EXT_PLV:
|
||||
if (record->event.pressed) {
|
||||
#ifdef AUDIO_ENABLE
|
||||
PLAY_SONG(plover_gb_song);
|
||||
#endif
|
||||
layer_off(_PLOVER);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
3
keyboards/planck/keymaps/audio_out/rules.mk
Normal file
3
keyboards/planck/keymaps/audio_out/rules.mk
Normal file
@@ -0,0 +1,3 @@
|
||||
AUDIO_ENABLE = yes
|
||||
BACKLIGHT_ENABLE = no
|
||||
MIDI_ENABLE = no
|
@@ -65,7 +65,7 @@ CONSOLE_ENABLE = yes # Console for debug(+400)
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
|
||||
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
|
||||
MIDI_ENABLE = yes # MIDI controls
|
||||
MIDI_ENABLE = no # MIDI controls
|
||||
AUDIO_ENABLE = yes # Audio output on port C6
|
||||
UNICODE_ENABLE = no # Unicode
|
||||
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
|
||||
|
@@ -1,3 +0,0 @@
|
||||
#include "../../config.h"
|
||||
|
||||
#define BACKLIGHT_BREATHING
|
@@ -1,52 +0,0 @@
|
||||
#include "tada68.h"
|
||||
|
||||
// Each layer gets a name for readability, which is then used in the keymap matrix below.
|
||||
// The underscores don't mean anything - you can have a layer called STUFF or any other name.
|
||||
// Layer names don't all need to be of the same length, obviously, and you can also skip them
|
||||
// entirely and just use numbers.
|
||||
#define _BL 0
|
||||
#define _FL 1
|
||||
|
||||
#define _______ KC_TRNS
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* Keymap _BL: (Base Layer) Default Layer
|
||||
* ,----------------------------------------------------------------.
|
||||
* |Esc | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp |~ ` |
|
||||
* |----------------------------------------------------------------|
|
||||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ |Del |
|
||||
* |----------------------------------------------------------------|
|
||||
* |FN | A| S| D| F| G| H| J| K| L| ;| '|Return |PgUp|
|
||||
* |----------------------------------------------------------------|
|
||||
* |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | Up|PgDn|
|
||||
* |----------------------------------------------------------------|
|
||||
* |Ctrl|Win |Alt | Space |Alt| FN|Ctrl|Lef|Dow|Rig |
|
||||
* `----------------------------------------------------------------'
|
||||
*/
|
||||
[_BL] = KEYMAP_ANSI(
|
||||
KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC,KC_GRV, \
|
||||
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC,KC_BSLS,KC_DEL, \
|
||||
MO(_FL), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN,KC_QUOT, KC_ENT,KC_PGUP, \
|
||||
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_RSFT,KC_UP,KC_PGDN, \
|
||||
KC_LCTL, KC_LALT,KC_LGUI, KC_SPC, KC_RALT,MO(_FL),KC_RCTRL, KC_LEFT,KC_DOWN,KC_RGHT),
|
||||
|
||||
/* Keymap _FL: Function Layer
|
||||
* ,----------------------------------------------------------------.
|
||||
* | | F1|F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12|Del |Ins |
|
||||
* |----------------------------------------------------------------|
|
||||
* | | |Up | | | | | |UP | | | | | |Hme |
|
||||
* |----------------------------------------------------------------|
|
||||
* | |<- |Dn | ->| | | |<- |Dn | ->| | | |End |
|
||||
* |----------------------------------------------------------------|
|
||||
* | | |BR |Bl-|BL |BL+| |VU-|VU+|MUT| | McL|MsU|McR |
|
||||
* |----------------------------------------------------------------|
|
||||
* | | | | | | | |MsL|MsD|MsR |
|
||||
* `----------------------------------------------------------------'
|
||||
*/
|
||||
[_FL] = KEYMAP_ANSI(
|
||||
_______, KC_F1 ,KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, KC_INS , \
|
||||
_______,_______, KC_UP,_______,_______, _______,_______,_______, KC_UP,_______,_______,_______,_______, _______,KC_HOME, \
|
||||
_______,KC_LEFT,KC_DOWN,KC_RIGHT,_______,_______,_______,KC_LEFT,KC_DOWN,KC_RIGHT,_______,_______, _______,KC_END, \
|
||||
_______,_______,BL_BRTG,BL_DEC, BL_TOGG,BL_INC, _______,KC_VOLD,KC_VOLU,KC_MUTE,_______,KC_BTN1, KC_MS_U, KC_BTN2, \
|
||||
_______,_______,_______, _______, _______,_______,_______,KC_MS_L,KC_MS_D, KC_MS_R),
|
||||
};
|
@@ -1,15 +0,0 @@
|
||||
# stephengrier's TADA68 layout
|
||||
|
||||
This layout mostly replicates the default ANSI layout of the TADA68 but with a
|
||||
few modifications to suit my tastes.
|
||||
|
||||
The modifications from the default keymap are:
|
||||
|
||||
* Replaced capslock with a second function key
|
||||
* Swapped the left ALT and Win keys to be more like the Mac layout
|
||||
* Added an arrow key cluster on the IJKL keys
|
||||
* Fn+x toggles backlight breathing mode
|
||||
|
||||
With this keymap backlight breathing mode can be enabled/disabled with Fn+x.
|
||||
This is not supported at all in the default keymap.
|
||||
|
@@ -1,21 +0,0 @@
|
||||
# Build Options
|
||||
# change to "no" to disable the options, or define them in the Makefile in
|
||||
# the appropriate keymap folder that will get included automatically
|
||||
#
|
||||
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
|
||||
CONSOLE_ENABLE = no # Console for debug(+400)
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
|
||||
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
||||
MIDI_ENABLE = no # MIDI controls
|
||||
AUDIO_ENABLE = no # Audio output on port C6
|
||||
UNICODE_ENABLE = no # Unicode
|
||||
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
|
||||
RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time.
|
||||
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
|
||||
|
||||
ifndef QUANTUM_DIR
|
||||
include ../../../../Makefile
|
||||
endif
|
@@ -1,62 +0,0 @@
|
||||
#include "xd60.h"
|
||||
#include "action_layer.h"
|
||||
|
||||
/* HHKB-like layout for standard 60% layout with split RShift and split backspace */
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
// 0: Base Layer
|
||||
KEYMAP(
|
||||
KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSLS, KC_GRV, \
|
||||
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSPC, \
|
||||
KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_NO, KC_ENT, \
|
||||
KC_LSFT, KC_NO, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_RSFT, F(0), \
|
||||
KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_RGUI, KC_RALT, F(0), KC_RCTL, KC_RCTL),
|
||||
|
||||
// 1: Function Layer
|
||||
/* Layer HHKB: HHKB mode (HHKB Fn)
|
||||
|------+-----+-----+-----+----+----+----+----+-----+-----+-----+-----+-------+-------+-----|
|
||||
| Pwr | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | Ins | Del |
|
||||
|------+-----+-----+-----+----+----+----+----+-----+-----+-----+-----+-------+-------+-----|
|
||||
| Caps | | | | | | | | Psc | Slk | Pus | Up | | Backs | |
|
||||
|------+-----+-----+-----+----+----+----+----+-----+-----+-----+-----+-------+-------+-----|
|
||||
| | VoD | VoU | Mut | | | * | / | Hom | PgU | Lef | Rig | Enter | | |
|
||||
|------+-----+-----+-----+----+----+----+----+-----+-----+-----+-----+-------+-------+-----|
|
||||
| | | | | | | + | - | End | PgD | Dow | | | | |
|
||||
|------+-----+-----+-----+----+----+----+----+-----+-----+-----+-----+-------+-------+-----|
|
||||
|
||||
|------+------+----------------------+------+------+
|
||||
| **** | **** | ******************** | **** | **** |
|
||||
|------+------+----------------------+------+------+
|
||||
*/
|
||||
KEYMAP(
|
||||
RESET, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_F13, KC_F14, \
|
||||
KC_CAPS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_SLCK, KC_PAUS, KC_UP, KC_TRNS, KC_BSPC, \
|
||||
KC_TRNS, KC_VOLD, KC_VOLU, KC_MUTE, KC_TRNS, KC_TRNS, KC_PAST, KC_PSLS, KC_HOME, KC_PGUP, KC_LEFT, KC_RGHT, KC_NO, KC_ENT, \
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PPLS, KC_PMNS, KC_END, KC_PGDN, KC_DOWN, KC_TRNS, KC_TRNS, KC_TRNS, \
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, F(0), KC_TRNS, KC_TRNS),
|
||||
};
|
||||
|
||||
// Custom Actions
|
||||
const uint16_t PROGMEM fn_actions[] = {
|
||||
[0] = ACTION_LAYER_MOMENTARY(1), // to Fn overlay
|
||||
};
|
||||
|
||||
// Macros
|
||||
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
|
||||
|
||||
// MACRODOWN only works in this function
|
||||
switch(id) {
|
||||
case 0:
|
||||
if (record->event.pressed) { register_code(KC_RSFT); }
|
||||
else { unregister_code(KC_RSFT); }
|
||||
break;
|
||||
}
|
||||
|
||||
return MACRO_NONE;
|
||||
};
|
||||
|
||||
// Loop
|
||||
void matrix_scan_user(void) {
|
||||
// Empty
|
||||
};
|
@@ -1,2 +0,0 @@
|
||||
# krusli's HHKB-style keymap for the XD60
|
||||
HHKB-style keymap for the XD60. The board was not built with split backspace but still has Backspace and |\\ swapped.
|
@@ -47,6 +47,16 @@
|
||||
#define DISABLE_AUDIO_COUNTER_1_ISR TIMSK1 &= ~_BV(OCIE1A)
|
||||
#endif
|
||||
|
||||
#ifdef B6_AUDIO
|
||||
#define ENABLE_AUDIO_COUNTER_1_ISR TIMSK1 |= _BV(OCIE1B)
|
||||
#define DISABLE_AUDIO_COUNTER_1_ISR TIMSK1 &= ~_BV(OCIE1B)
|
||||
#endif
|
||||
|
||||
#ifdef B7_AUDIO
|
||||
#define ENABLE_AUDIO_COUNTER_1_ISR TIMSK1 |= _BV(OCIE1C)
|
||||
#define DISABLE_AUDIO_COUNTER_1_ISR TIMSK1 &= ~_BV(OCIE1C)
|
||||
#endif
|
||||
|
||||
// TCCR3A: Timer/Counter #3 Control Register
|
||||
// Compare Output Mode (COM3An) = 0b00 = Normal port operation, OC3A disconnected from PC6
|
||||
|
||||
@@ -60,6 +70,16 @@
|
||||
#define DISABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A &= ~(_BV(COM1A1) | _BV(COM1A0));
|
||||
#endif
|
||||
|
||||
#ifdef B6_AUDIO
|
||||
#define ENABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A |= _BV(COM1B1);
|
||||
#define DISABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A &= ~(_BV(COM1B1) | _BV(COM1B0));
|
||||
#endif
|
||||
|
||||
#ifdef B7_AUDIO
|
||||
#define ENABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A |= _BV(COM1C1);
|
||||
#define DISABLE_AUDIO_COUNTER_1_OUTPUT TCCR1A &= ~(_BV(COM1C1) | _BV(COM1C0));
|
||||
#endif
|
||||
|
||||
// Fast PWM Mode Controls
|
||||
|
||||
#ifdef C6_AUDIO
|
||||
@@ -72,6 +92,16 @@
|
||||
#define TIMER_1_DUTY_CYCLE OCR1A
|
||||
#endif
|
||||
|
||||
#ifdef B6_AUDIO
|
||||
#define TIMER_1_PERIOD ICR1
|
||||
#define TIMER_1_DUTY_CYCLE OCR1B
|
||||
#endif
|
||||
|
||||
#ifdef B7_AUDIO
|
||||
#define TIMER_1_PERIOD ICR1
|
||||
#define TIMER_1_DUTY_CYCLE OCR1C
|
||||
#endif
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -97,7 +127,7 @@ bool playing_note = false;
|
||||
float note_frequency = 0;
|
||||
float note_length = 0;
|
||||
uint8_t note_tempo = TEMPO_DEFAULT;
|
||||
float note_timbre = TIMBRE_DEFAULT;
|
||||
float note_timbre[NUMBER_OF_TIMERS] = {TIMBRE_DEFAULT};
|
||||
uint16_t note_position = 0;
|
||||
float (* notes_pointer)[][2];
|
||||
uint16_t notes_count;
|
||||
@@ -119,8 +149,8 @@ static bool audio_initialized = false;
|
||||
|
||||
audio_config_t audio_config;
|
||||
|
||||
uint16_t envelope_index = 0;
|
||||
bool glissando = true;
|
||||
uint16_t envelope_index[NUMBER_OF_TIMERS] = {0};
|
||||
bool glissando[NUMBER_OF_TIMERS] = {true};
|
||||
|
||||
#ifndef STARTUP_SONG
|
||||
#define STARTUP_SONG SONG(STARTUP_SOUND)
|
||||
@@ -163,11 +193,25 @@ void audio_init()
|
||||
// PORTB &= ~_BV(PORTB5);
|
||||
#endif
|
||||
|
||||
#ifdef B6_AUDIO
|
||||
DDRB |= _BV(PORTB6);
|
||||
// #else
|
||||
// DDRB |= _BV(PORTB6);
|
||||
// PORTB &= ~_BV(PORTB6);
|
||||
#endif
|
||||
|
||||
#ifdef B7_AUDIO
|
||||
DDRB |= _BV(PORTB7);
|
||||
// #else
|
||||
// DDRB |= _BV(PORTB7);
|
||||
// PORTB &= ~_BV(PORTB7);
|
||||
#endif
|
||||
|
||||
#ifdef C6_AUDIO
|
||||
DISABLE_AUDIO_COUNTER_3_ISR;
|
||||
#endif
|
||||
|
||||
#ifdef B5_AUDIO
|
||||
#ifdef B_AUDIO
|
||||
DISABLE_AUDIO_COUNTER_1_ISR;
|
||||
#endif
|
||||
|
||||
@@ -179,14 +223,17 @@ void audio_init()
|
||||
#ifdef C6_AUDIO
|
||||
TCCR3A = (0 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30);
|
||||
TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30);
|
||||
|
||||
TIMER_3_PERIOD = (uint16_t)(((float)F_CPU) / (440 * CPU_PRESCALER));
|
||||
TIMER_3_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (440 * CPU_PRESCALER)) * note_timbre[TIMER_3_INDEX]);
|
||||
#endif
|
||||
|
||||
#ifdef B5_AUDIO
|
||||
#ifdef B_AUDIO
|
||||
TCCR1A = (0 << COM1A1) | (0 << COM1A0) | (1 << WGM11) | (0 << WGM10);
|
||||
TCCR1B = (1 << WGM13) | (1 << WGM12) | (0 << CS12) | (1 << CS11) | (0 << CS10);
|
||||
|
||||
TIMER_1_PERIOD = (uint16_t)(((float)F_CPU) / (440 * CPU_PRESCALER));
|
||||
TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (440 * CPU_PRESCALER)) * note_timbre);
|
||||
TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (440 * CPU_PRESCALER)) * note_timbre[TIMER_1_INDEX]);
|
||||
#endif
|
||||
|
||||
audio_initialized = true;
|
||||
@@ -213,7 +260,7 @@ void stop_all_notes()
|
||||
DISABLE_AUDIO_COUNTER_3_OUTPUT;
|
||||
#endif
|
||||
|
||||
#ifdef B5_AUDIO
|
||||
#ifdef B_AUDIO
|
||||
DISABLE_AUDIO_COUNTER_1_ISR;
|
||||
DISABLE_AUDIO_COUNTER_1_OUTPUT;
|
||||
#endif
|
||||
@@ -258,12 +305,18 @@ void stop_note(float freq)
|
||||
if (voice_place >= voices) {
|
||||
voice_place = 0;
|
||||
}
|
||||
if (voices == 1) {
|
||||
#if defined(C6_AUDIO) && defined(B_AUDIO)
|
||||
DISABLE_AUDIO_COUNTER_1_ISR;
|
||||
DISABLE_AUDIO_COUNTER_1_OUTPUT;
|
||||
#endif
|
||||
}
|
||||
if (voices == 0) {
|
||||
#ifdef C6_AUDIO
|
||||
DISABLE_AUDIO_COUNTER_3_ISR;
|
||||
DISABLE_AUDIO_COUNTER_3_OUTPUT;
|
||||
#endif
|
||||
#ifdef B5_AUDIO
|
||||
#ifdef B_AUDIO
|
||||
DISABLE_AUDIO_COUNTER_1_ISR;
|
||||
DISABLE_AUDIO_COUNTER_1_OUTPUT;
|
||||
#endif
|
||||
@@ -303,11 +356,11 @@ ISR(TIMER3_COMPA_vect)
|
||||
if (playing_note) {
|
||||
if (voices > 0) {
|
||||
|
||||
#ifdef B5_AUDIO
|
||||
#ifdef B_AUDIO
|
||||
float freq_alt = 0;
|
||||
if (voices > 1) {
|
||||
if (polyphony_rate == 0) {
|
||||
if (glissando) {
|
||||
if (glissando[TIMER_1_INDEX] && NUMBER_OF_TIMERS == 1) {
|
||||
if (frequency_alt != 0 && frequency_alt < frequencies[voices - 2] && frequency_alt < frequencies[voices - 2] * pow(2, -440/frequencies[voices - 2]/12/2)) {
|
||||
frequency_alt = frequency_alt * pow(2, 440/frequency_alt/12/2);
|
||||
} else if (frequency_alt != 0 && frequency_alt > frequencies[voices - 2] && frequency_alt > frequencies[voices - 2] * pow(2, 440/frequencies[voices - 2]/12/2)) {
|
||||
@@ -330,18 +383,18 @@ ISR(TIMER3_COMPA_vect)
|
||||
#endif
|
||||
}
|
||||
|
||||
if (envelope_index < 65535) {
|
||||
envelope_index++;
|
||||
if (envelope_index[TIMER_1_INDEX] < 65535) {
|
||||
envelope_index[TIMER_1_INDEX]++;
|
||||
}
|
||||
|
||||
freq_alt = voice_envelope(freq_alt);
|
||||
freq_alt = voice_envelope(freq_alt,TIMER_1_INDEX);
|
||||
|
||||
if (freq_alt < 30.517578125) {
|
||||
freq_alt = 30.52;
|
||||
}
|
||||
|
||||
TIMER_1_PERIOD = (uint16_t)(((float)F_CPU) / (freq_alt * CPU_PRESCALER));
|
||||
TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq_alt * CPU_PRESCALER)) * note_timbre);
|
||||
TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq_alt * CPU_PRESCALER)) * note_timbre[TIMER_1_INDEX]);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -364,7 +417,7 @@ ISR(TIMER3_COMPA_vect)
|
||||
freq = frequencies[voice_place];
|
||||
#endif
|
||||
} else {
|
||||
if (glissando) {
|
||||
if (glissando[TIMER_3_INDEX] && NUMBER_OF_TIMERS == 1) {
|
||||
if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440/frequencies[voices - 1]/12/2)) {
|
||||
frequency = frequency * pow(2, 440/frequency/12/2);
|
||||
} else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440/frequencies[voices - 1]/12/2)) {
|
||||
@@ -387,18 +440,18 @@ ISR(TIMER3_COMPA_vect)
|
||||
#endif
|
||||
}
|
||||
|
||||
if (envelope_index < 65535) {
|
||||
envelope_index++;
|
||||
if (envelope_index[TIMER_3_INDEX] < 65535) {
|
||||
envelope_index[TIMER_3_INDEX]++;
|
||||
}
|
||||
|
||||
freq = voice_envelope(freq);
|
||||
freq = voice_envelope(freq, TIMER_3_INDEX);
|
||||
|
||||
if (freq < 30.517578125) {
|
||||
freq = 30.52;
|
||||
}
|
||||
|
||||
TIMER_3_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER));
|
||||
TIMER_3_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre);
|
||||
TIMER_3_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre[TIMER_3_INDEX]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -414,13 +467,13 @@ ISR(TIMER3_COMPA_vect)
|
||||
freq = note_frequency;
|
||||
#endif
|
||||
|
||||
if (envelope_index < 65535) {
|
||||
envelope_index++;
|
||||
if (envelope_index[TIMER_3_INDEX] < 65535) {
|
||||
envelope_index[TIMER_3_INDEX]++;
|
||||
}
|
||||
freq = voice_envelope(freq);
|
||||
freq = voice_envelope(freq, TIMER_3_INDEX);
|
||||
|
||||
TIMER_3_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER));
|
||||
TIMER_3_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre);
|
||||
TIMER_3_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre[TIMER_3_INDEX]);
|
||||
} else {
|
||||
TIMER_3_PERIOD = 0;
|
||||
TIMER_3_DUTY_CYCLE = 0;
|
||||
@@ -461,7 +514,7 @@ ISR(TIMER3_COMPA_vect)
|
||||
}
|
||||
} else {
|
||||
note_resting = false;
|
||||
envelope_index = 0;
|
||||
envelope_index[TIMER_3_INDEX] = 0;
|
||||
note_frequency = (*notes_pointer)[current_note][0];
|
||||
note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100);
|
||||
}
|
||||
@@ -477,10 +530,16 @@ ISR(TIMER3_COMPA_vect)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef B_AUDIO
|
||||
#ifdef B5_AUDIO
|
||||
ISR(TIMER1_COMPA_vect)
|
||||
#elif defined(B6_AUDIO)
|
||||
ISR(TIMER1_COMPB_vect)
|
||||
#elif defined(B7_AUDIO)
|
||||
ISR(TIMER1_COMPC_vect)
|
||||
#endif
|
||||
{
|
||||
#if defined(B5_AUDIO) && !defined(C6_AUDIO)
|
||||
#if defined(B_AUDIO) && !defined(C6_AUDIO)
|
||||
float freq = 0;
|
||||
|
||||
if (playing_note) {
|
||||
@@ -504,7 +563,7 @@ ISR(TIMER1_COMPA_vect)
|
||||
freq = frequencies[voice_place];
|
||||
#endif
|
||||
} else {
|
||||
if (glissando) {
|
||||
if (glissando[TIMER_1_INDEX] && NUMBER_OF_TIMERS == 1) {
|
||||
if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440/frequencies[voices - 1]/12/2)) {
|
||||
frequency = frequency * pow(2, 440/frequency/12/2);
|
||||
} else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440/frequencies[voices - 1]/12/2)) {
|
||||
@@ -527,18 +586,18 @@ ISR(TIMER1_COMPA_vect)
|
||||
#endif
|
||||
}
|
||||
|
||||
if (envelope_index < 65535) {
|
||||
envelope_index++;
|
||||
if (envelope_index[TIMER_1_INDEX] < 65535) {
|
||||
envelope_index[TIMER_1_INDEX]++;
|
||||
}
|
||||
|
||||
freq = voice_envelope(freq);
|
||||
freq = voice_envelope(freq, TIMER_1_INDEX);
|
||||
|
||||
if (freq < 30.517578125) {
|
||||
freq = 30.52;
|
||||
}
|
||||
|
||||
TIMER_1_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER));
|
||||
TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre);
|
||||
TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre[TIMER_1_INDEX]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -554,13 +613,13 @@ ISR(TIMER1_COMPA_vect)
|
||||
freq = note_frequency;
|
||||
#endif
|
||||
|
||||
if (envelope_index < 65535) {
|
||||
envelope_index++;
|
||||
if (envelope_index[TIMER_1_INDEX] < 65535) {
|
||||
envelope_index[TIMER_1_INDEX]++;
|
||||
}
|
||||
freq = voice_envelope(freq);
|
||||
freq = voice_envelope(freq, TIMER_1_INDEX);
|
||||
|
||||
TIMER_1_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER));
|
||||
TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre);
|
||||
TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre[TIMER_1_INDEX]);
|
||||
} else {
|
||||
TIMER_1_PERIOD = 0;
|
||||
TIMER_1_DUTY_CYCLE = 0;
|
||||
@@ -601,7 +660,7 @@ ISR(TIMER1_COMPA_vect)
|
||||
}
|
||||
} else {
|
||||
note_resting = false;
|
||||
envelope_index = 0;
|
||||
envelope_index[TIMER_1_INDEX] = 0;
|
||||
note_frequency = (*notes_pointer)[current_note][0];
|
||||
note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100);
|
||||
}
|
||||
@@ -630,7 +689,7 @@ void play_note(float freq, int vol) {
|
||||
#ifdef C6_AUDIO
|
||||
DISABLE_AUDIO_COUNTER_3_ISR;
|
||||
#endif
|
||||
#ifdef B5_AUDIO
|
||||
#ifdef B_AUDIO
|
||||
DISABLE_AUDIO_COUNTER_1_ISR;
|
||||
#endif
|
||||
|
||||
@@ -640,7 +699,6 @@ void play_note(float freq, int vol) {
|
||||
|
||||
playing_note = true;
|
||||
|
||||
envelope_index = 0;
|
||||
|
||||
if (freq > 0) {
|
||||
frequencies[voices] = freq;
|
||||
@@ -652,16 +710,23 @@ void play_note(float freq, int vol) {
|
||||
ENABLE_AUDIO_COUNTER_3_ISR;
|
||||
ENABLE_AUDIO_COUNTER_3_OUTPUT;
|
||||
#endif
|
||||
#ifdef B5_AUDIO
|
||||
|
||||
#ifdef B_AUDIO
|
||||
#ifdef C6_AUDIO
|
||||
if (voices > 1) {
|
||||
envelope_index[TIMER_3_INDEX] = 0;
|
||||
ENABLE_AUDIO_COUNTER_1_ISR;
|
||||
ENABLE_AUDIO_COUNTER_1_OUTPUT;
|
||||
} else {
|
||||
envelope_index[TIMER_3_INDEX] = 0;
|
||||
}
|
||||
#else
|
||||
envelope_index[TIMER_1_INDEX] = 0;
|
||||
ENABLE_AUDIO_COUNTER_1_ISR;
|
||||
ENABLE_AUDIO_COUNTER_1_OUTPUT;
|
||||
#endif
|
||||
#else
|
||||
envelope_index[TIMER_3_INDEX] = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -679,7 +744,7 @@ void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat)
|
||||
#ifdef C6_AUDIO
|
||||
DISABLE_AUDIO_COUNTER_3_ISR;
|
||||
#endif
|
||||
#ifdef B5_AUDIO
|
||||
#ifdef B_AUDIO
|
||||
DISABLE_AUDIO_COUNTER_1_ISR;
|
||||
#endif
|
||||
|
||||
@@ -705,7 +770,7 @@ void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat)
|
||||
ENABLE_AUDIO_COUNTER_3_ISR;
|
||||
ENABLE_AUDIO_COUNTER_3_OUTPUT;
|
||||
#endif
|
||||
#ifdef B5_AUDIO
|
||||
#ifdef B_AUDIO
|
||||
#ifndef C6_AUDIO
|
||||
ENABLE_AUDIO_COUNTER_1_ISR;
|
||||
ENABLE_AUDIO_COUNTER_1_OUTPUT;
|
||||
@@ -803,8 +868,8 @@ void decrease_polyphony_rate(float change) {
|
||||
|
||||
// Timbre function
|
||||
|
||||
void set_timbre(float timbre) {
|
||||
note_timbre = timbre;
|
||||
void set_timbre(float timbre, uint8_t timer_index) {
|
||||
note_timbre[timer_index] = timbre;
|
||||
}
|
||||
|
||||
// Tempo functions
|
||||
|
@@ -36,6 +36,42 @@
|
||||
// Enable vibrato strength/amplitude - slows down ISR too much
|
||||
// #define VIBRATO_STRENGTH_ENABLE
|
||||
|
||||
#if defined(__AVR__)
|
||||
|
||||
// avr
|
||||
|
||||
#ifdef B_AUDIO
|
||||
#error Please define B5_AUDIO, B6_AUDIO, or B7_AUDIO instead
|
||||
#endif
|
||||
|
||||
#if defined(B5_AUDIO) || defined(B6_AUDIO) || defined(B7_AUDIO)
|
||||
#define B_AUDIO
|
||||
#endif
|
||||
|
||||
#if defined(C6_AUDIO) && defined (B_AUDIO)
|
||||
#define NUMBER_OF_TIMERS 2
|
||||
#elif defined(C6_AUDIO)
|
||||
#define NUMBER_OF_TIMERS 1
|
||||
#elif defined(B_AUDIO)
|
||||
#define NUMBER_OF_TIMERS 1
|
||||
#else
|
||||
#define NUMBER_OF_TIMERS 0
|
||||
#endif
|
||||
|
||||
#define TIMER_1_INDEX 0
|
||||
#define TIMER_3_INDEX 1
|
||||
|
||||
#else
|
||||
|
||||
// chibios
|
||||
|
||||
#define NUMBER_OF_TIMERS 2
|
||||
|
||||
#define TIMER_6_INDEX 0
|
||||
#define TIMER_7_INDEX 1
|
||||
|
||||
#endif
|
||||
|
||||
typedef union {
|
||||
uint8_t raw;
|
||||
struct {
|
||||
@@ -75,7 +111,7 @@ void disable_polyphony(void);
|
||||
void increase_polyphony_rate(float change);
|
||||
void decrease_polyphony_rate(float change);
|
||||
|
||||
void set_timbre(float timbre);
|
||||
void set_timbre(float timbre, uint8_t timer_index);
|
||||
void set_tempo(uint8_t tempo);
|
||||
|
||||
void increase_tempo(uint8_t tempo_change);
|
||||
|
@@ -47,7 +47,7 @@ bool playing_note = false;
|
||||
float note_frequency = 0;
|
||||
float note_length = 0;
|
||||
uint8_t note_tempo = TEMPO_DEFAULT;
|
||||
float note_timbre = TIMBRE_DEFAULT;
|
||||
float note_timbre[NUMBER_OF_TIMERS] = {TIMBRE_DEFAULT};
|
||||
uint16_t note_position = 0;
|
||||
float (* notes_pointer)[][2];
|
||||
uint16_t notes_count;
|
||||
@@ -69,31 +69,56 @@ static bool audio_initialized = false;
|
||||
|
||||
audio_config_t audio_config;
|
||||
|
||||
uint16_t envelope_index = 0;
|
||||
bool glissando = true;
|
||||
uint16_t envelope_index[NUMBER_OF_TIMERS] = {0};
|
||||
bool glissando[NUMBER_OF_TIMERS] = {true};
|
||||
|
||||
#ifndef STARTUP_SONG
|
||||
#define STARTUP_SONG SONG(STARTUP_SOUND)
|
||||
#endif
|
||||
float startup_song[][2] = STARTUP_SONG;
|
||||
|
||||
static void gpt_cb6(GPTDriver *gptp);
|
||||
static void gpt_cb7(GPTDriver *gptp);
|
||||
static void gpt_cb8(GPTDriver *gptp);
|
||||
|
||||
#define DAC_BUFFER_SIZE 360
|
||||
|
||||
#define START_CHANNEL_1() gptStart(&GPTD6, &gpt6cfg1); \
|
||||
gptStartContinuous(&GPTD6, 2U)
|
||||
#define START_CHANNEL_2() gptStart(&GPTD7, &gpt7cfg1); \
|
||||
gptStartContinuous(&GPTD7, 2U)
|
||||
#define STOP_CHANNEL_1() gptStopTimer(&GPTD6)
|
||||
#define STOP_CHANNEL_2() gptStopTimer(&GPTD7)
|
||||
#define RESTART_CHANNEL_1() STOP_CHANNEL_1(); \
|
||||
START_CHANNEL_1()
|
||||
#define RESTART_CHANNEL_2() STOP_CHANNEL_1(); \
|
||||
START_CHANNEL_1()
|
||||
#define UPDATE_CHANNEL_1_FREQ(freq) gpt6cfg1.frequency = freq * DAC_BUFFER_SIZE; \
|
||||
RESTART_CHANNEL_1()
|
||||
#define UPDATE_CHANNEL_2_FREQ(freq) gpt7cfg1.frequency = freq * DAC_BUFFER_SIZE; \
|
||||
RESTART_CHANNEL_2()
|
||||
#define GET_CHANNEL_1_FREQ gpt6cfg1.frequency
|
||||
#define GET_CHANNEL_2_FREQ gpt7cfg1.frequency
|
||||
|
||||
|
||||
/*
|
||||
* GPT6 configuration.
|
||||
*/
|
||||
// static const GPTConfig gpt6cfg1 = {
|
||||
// .frequency = 1000000U,
|
||||
// .callback = NULL,
|
||||
// .cr2 = TIM_CR2_MMS_1, /* MMS = 010 = TRGO on Update Event. */
|
||||
// .dier = 0U
|
||||
// };
|
||||
|
||||
GPTConfig gpt6cfg1 = {
|
||||
.frequency = 440,
|
||||
.callback = gpt_cb6,
|
||||
.frequency = 440U*DAC_BUFFER_SIZE,
|
||||
.callback = NULL,
|
||||
.cr2 = TIM_CR2_MMS_1, /* MMS = 010 = TRGO on Update Event. */
|
||||
.dier = 0U
|
||||
};
|
||||
|
||||
GPTConfig gpt7cfg1 = {
|
||||
.frequency = 440,
|
||||
.callback = gpt_cb7,
|
||||
.frequency = 440U*DAC_BUFFER_SIZE,
|
||||
.callback = NULL,
|
||||
.cr2 = TIM_CR2_MMS_1, /* MMS = 010 = TRGO on Update Event. */
|
||||
.dier = 0U
|
||||
};
|
||||
@@ -105,15 +130,122 @@ GPTConfig gpt8cfg1 = {
|
||||
.dier = 0U
|
||||
};
|
||||
|
||||
static void gpt_cb6(GPTDriver *gptp) {
|
||||
palTogglePad(GPIOA, 4);
|
||||
|
||||
/*
|
||||
* DAC test buffer (sine wave).
|
||||
*/
|
||||
// static const dacsample_t dac_buffer[DAC_BUFFER_SIZE] = {
|
||||
// 2047, 2082, 2118, 2154, 2189, 2225, 2260, 2296, 2331, 2367, 2402, 2437,
|
||||
// 2472, 2507, 2542, 2576, 2611, 2645, 2679, 2713, 2747, 2780, 2813, 2846,
|
||||
// 2879, 2912, 2944, 2976, 3008, 3039, 3070, 3101, 3131, 3161, 3191, 3221,
|
||||
// 3250, 3278, 3307, 3335, 3362, 3389, 3416, 3443, 3468, 3494, 3519, 3544,
|
||||
// 3568, 3591, 3615, 3637, 3660, 3681, 3703, 3723, 3744, 3763, 3782, 3801,
|
||||
// 3819, 3837, 3854, 3870, 3886, 3902, 3917, 3931, 3944, 3958, 3970, 3982,
|
||||
// 3993, 4004, 4014, 4024, 4033, 4041, 4049, 4056, 4062, 4068, 4074, 4078,
|
||||
// 4082, 4086, 4089, 4091, 4092, 4093, 4094, 4093, 4092, 4091, 4089, 4086,
|
||||
// 4082, 4078, 4074, 4068, 4062, 4056, 4049, 4041, 4033, 4024, 4014, 4004,
|
||||
// 3993, 3982, 3970, 3958, 3944, 3931, 3917, 3902, 3886, 3870, 3854, 3837,
|
||||
// 3819, 3801, 3782, 3763, 3744, 3723, 3703, 3681, 3660, 3637, 3615, 3591,
|
||||
// 3568, 3544, 3519, 3494, 3468, 3443, 3416, 3389, 3362, 3335, 3307, 3278,
|
||||
// 3250, 3221, 3191, 3161, 3131, 3101, 3070, 3039, 3008, 2976, 2944, 2912,
|
||||
// 2879, 2846, 2813, 2780, 2747, 2713, 2679, 2645, 2611, 2576, 2542, 2507,
|
||||
// 2472, 2437, 2402, 2367, 2331, 2296, 2260, 2225, 2189, 2154, 2118, 2082,
|
||||
// 2047, 2012, 1976, 1940, 1905, 1869, 1834, 1798, 1763, 1727, 1692, 1657,
|
||||
// 1622, 1587, 1552, 1518, 1483, 1449, 1415, 1381, 1347, 1314, 1281, 1248,
|
||||
// 1215, 1182, 1150, 1118, 1086, 1055, 1024, 993, 963, 933, 903, 873,
|
||||
// 844, 816, 787, 759, 732, 705, 678, 651, 626, 600, 575, 550,
|
||||
// 526, 503, 479, 457, 434, 413, 391, 371, 350, 331, 312, 293,
|
||||
// 275, 257, 240, 224, 208, 192, 177, 163, 150, 136, 124, 112,
|
||||
// 101, 90, 80, 70, 61, 53, 45, 38, 32, 26, 20, 16,
|
||||
// 12, 8, 5, 3, 2, 1, 0, 1, 2, 3, 5, 8,
|
||||
// 12, 16, 20, 26, 32, 38, 45, 53, 61, 70, 80, 90,
|
||||
// 101, 112, 124, 136, 150, 163, 177, 192, 208, 224, 240, 257,
|
||||
// 275, 293, 312, 331, 350, 371, 391, 413, 434, 457, 479, 503,
|
||||
// 526, 550, 575, 600, 626, 651, 678, 705, 732, 759, 787, 816,
|
||||
// 844, 873, 903, 933, 963, 993, 1024, 1055, 1086, 1118, 1150, 1182,
|
||||
// 1215, 1248, 1281, 1314, 1347, 1381, 1415, 1449, 1483, 1518, 1552, 1587,
|
||||
// 1622, 1657, 1692, 1727, 1763, 1798, 1834, 1869, 1905, 1940, 1976, 2012
|
||||
// };
|
||||
|
||||
// squarewave
|
||||
static const dacsample_t dac_buffer[DAC_BUFFER_SIZE] = {
|
||||
2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
|
||||
2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
|
||||
2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
|
||||
2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
|
||||
2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
|
||||
2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
|
||||
2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
|
||||
2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
|
||||
2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
|
||||
2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
|
||||
2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
|
||||
2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
|
||||
2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
|
||||
2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
|
||||
2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
/*
|
||||
* DAC streaming callback.
|
||||
*/
|
||||
size_t nx = 0, ny = 0, nz = 0;
|
||||
static void end_cb1(DACDriver *dacp, const dacsample_t *buffer, size_t n) {
|
||||
|
||||
(void)dacp;
|
||||
|
||||
nz++;
|
||||
if (dac_buffer == buffer) {
|
||||
nx += n;
|
||||
}
|
||||
else {
|
||||
ny += n;
|
||||
}
|
||||
|
||||
if ((nz % 1000) == 0) {
|
||||
// palTogglePad(GPIOD, GPIOD_LED3);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* DAC error callback.
|
||||
*/
|
||||
static void error_cb1(DACDriver *dacp, dacerror_t err) {
|
||||
|
||||
static void gpt_cb7(GPTDriver *gptp) {
|
||||
palTogglePad(GPIOA, 5);
|
||||
(void)dacp;
|
||||
(void)err;
|
||||
|
||||
chSysHalt("DAC failure");
|
||||
}
|
||||
|
||||
static const DACConfig dac1cfg1 = {
|
||||
.init = 2047U,
|
||||
.datamode = DAC_DHRM_12BIT_RIGHT
|
||||
};
|
||||
|
||||
static const DACConversionGroup dacgrpcfg1 = {
|
||||
.num_channels = 1U,
|
||||
.end_cb = end_cb1,
|
||||
.error_cb = error_cb1,
|
||||
.trigger = DAC_TRG(0)
|
||||
};
|
||||
|
||||
void audio_init()
|
||||
{
|
||||
|
||||
@@ -128,8 +260,27 @@ void audio_init()
|
||||
// audio_config.raw = eeconfig_read_audio();
|
||||
audio_config.enable = true;
|
||||
|
||||
palSetPadMode(GPIOA, 4, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetPadMode(GPIOA, 5, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
/*
|
||||
* Starting DAC1 driver, setting up the output pin as analog as suggested
|
||||
* by the Reference Manual.
|
||||
*/
|
||||
palSetPadMode(GPIOA, 4, PAL_MODE_INPUT_ANALOG);
|
||||
palSetPadMode(GPIOA, 5, PAL_MODE_INPUT_ANALOG);
|
||||
dacStart(&DACD1, &dac1cfg1);
|
||||
|
||||
/*
|
||||
* Starting GPT6 driver, it is used for triggering the DAC.
|
||||
*/
|
||||
START_CHANNEL_1();
|
||||
START_CHANNEL_2();
|
||||
|
||||
/*
|
||||
* Starting a continuous conversion.
|
||||
*/
|
||||
dacStartConversion(&DACD1, &dacgrpcfg1,
|
||||
(dacsample_t *)dac_buffer, DAC_BUFFER_SIZE);
|
||||
// gptStartContinuous(&GPTD6, 2U);
|
||||
|
||||
|
||||
audio_initialized = true;
|
||||
|
||||
@@ -193,8 +344,8 @@ void stop_note(float freq)
|
||||
voice_place = 0;
|
||||
}
|
||||
if (voices == 0) {
|
||||
gptStopTimer(&GPTD6);
|
||||
gptStopTimer(&GPTD7);
|
||||
STOP_CHANNEL_1();
|
||||
STOP_CHANNEL_2();
|
||||
gptStopTimer(&GPTD8);
|
||||
frequency = 0;
|
||||
frequency_alt = 0;
|
||||
@@ -224,20 +375,6 @@ float vibrato(float average_freq) {
|
||||
|
||||
#endif
|
||||
|
||||
static void restart_gpt6(void) {
|
||||
// gptStopTimer(&GPTD6);
|
||||
|
||||
gptStart(&GPTD6, &gpt6cfg1);
|
||||
gptStartContinuous(&GPTD6, 2U);
|
||||
}
|
||||
|
||||
static void restart_gpt7(void) {
|
||||
// gptStopTimer(&GPTD7);
|
||||
|
||||
gptStart(&GPTD7, &gpt7cfg1);
|
||||
gptStartContinuous(&GPTD7, 2U);
|
||||
}
|
||||
|
||||
static void gpt_cb8(GPTDriver *gptp) {
|
||||
float freq;
|
||||
|
||||
@@ -247,7 +384,7 @@ static void gpt_cb8(GPTDriver *gptp) {
|
||||
float freq_alt = 0;
|
||||
if (voices > 1) {
|
||||
if (polyphony_rate == 0) {
|
||||
if (glissando) {
|
||||
if (glissando[TIMER_6_INDEX]) {
|
||||
if (frequency_alt != 0 && frequency_alt < frequencies[voices - 2] && frequency_alt < frequencies[voices - 2] * pow(2, -440/frequencies[voices - 2]/12/2)) {
|
||||
frequency_alt = frequency_alt * pow(2, 440/frequency_alt/12/2);
|
||||
} else if (frequency_alt != 0 && frequency_alt > frequencies[voices - 2] && frequency_alt > frequencies[voices - 2] * pow(2, 440/frequencies[voices - 2]/12/2)) {
|
||||
@@ -270,23 +407,22 @@ static void gpt_cb8(GPTDriver *gptp) {
|
||||
#endif
|
||||
}
|
||||
|
||||
if (envelope_index < 65535) {
|
||||
envelope_index++;
|
||||
if (envelope_index[TIMER_6_INDEX] < 65535) {
|
||||
envelope_index[TIMER_6_INDEX]++;
|
||||
}
|
||||
|
||||
freq_alt = voice_envelope(freq_alt);
|
||||
freq_alt = voice_envelope(freq_alt, TIMER_6_INDEX);
|
||||
|
||||
if (freq_alt < 30.517578125) {
|
||||
freq_alt = 30.52;
|
||||
}
|
||||
|
||||
if (gpt6cfg1.frequency != (uint16_t)freq_alt) {
|
||||
gpt6cfg1.frequency = freq_alt;
|
||||
restart_gpt6();
|
||||
if (GET_CHANNEL_1_FREQ != (uint16_t)freq_alt) {
|
||||
UPDATE_CHANNEL_1_FREQ(freq_alt);
|
||||
}
|
||||
//note_timbre;
|
||||
} else {
|
||||
// gptStopTimer(&GPTD6);
|
||||
STOP_CHANNEL_1();
|
||||
}
|
||||
|
||||
if (polyphony_rate > 0) {
|
||||
@@ -308,7 +444,7 @@ static void gpt_cb8(GPTDriver *gptp) {
|
||||
freq = frequencies[voice_place];
|
||||
#endif
|
||||
} else {
|
||||
if (glissando) {
|
||||
if (glissando[TIMER_7_INDEX]) {
|
||||
if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440/frequencies[voices - 1]/12/2)) {
|
||||
frequency = frequency * pow(2, 440/frequency/12/2);
|
||||
} else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440/frequencies[voices - 1]/12/2)) {
|
||||
@@ -331,20 +467,19 @@ static void gpt_cb8(GPTDriver *gptp) {
|
||||
#endif
|
||||
}
|
||||
|
||||
if (envelope_index < 65535) {
|
||||
envelope_index++;
|
||||
if (envelope_index[TIMER_7_INDEX] < 65535) {
|
||||
envelope_index[TIMER_7_INDEX]++;
|
||||
}
|
||||
|
||||
freq = voice_envelope(freq);
|
||||
freq = voice_envelope(freq, TIMER_7_INDEX);
|
||||
|
||||
if (freq < 30.517578125) {
|
||||
freq = 30.52;
|
||||
}
|
||||
|
||||
|
||||
if (gpt7cfg1.frequency != (uint16_t)freq) {
|
||||
gpt7cfg1.frequency = freq;
|
||||
restart_gpt7();
|
||||
if (GET_CHANNEL_2_FREQ != (uint16_t)freq) {
|
||||
UPDATE_CHANNEL_2_FREQ(freq);
|
||||
}
|
||||
//note_timbre;
|
||||
} else {
|
||||
@@ -364,17 +499,15 @@ static void gpt_cb8(GPTDriver *gptp) {
|
||||
freq = note_frequency;
|
||||
#endif
|
||||
|
||||
if (envelope_index < 65535) {
|
||||
envelope_index++;
|
||||
if (envelope_index[TIMER_6_INDEX] < 65535) {
|
||||
envelope_index[TIMER_6_INDEX]++;
|
||||
}
|
||||
freq = voice_envelope(freq);
|
||||
freq = voice_envelope(freq, TIMER_6_INDEX);
|
||||
|
||||
|
||||
if (gpt6cfg1.frequency != (uint16_t)freq) {
|
||||
gpt6cfg1.frequency = freq;
|
||||
restart_gpt6();
|
||||
gpt7cfg1.frequency = freq;
|
||||
restart_gpt7();
|
||||
if (GET_CHANNEL_1_FREQ != (uint16_t)freq) {
|
||||
UPDATE_CHANNEL_1_FREQ(freq);
|
||||
UPDATE_CHANNEL_2_FREQ(freq);
|
||||
}
|
||||
//note_timbre;
|
||||
} else {
|
||||
@@ -384,7 +517,7 @@ static void gpt_cb8(GPTDriver *gptp) {
|
||||
|
||||
note_position++;
|
||||
bool end_of_note = false;
|
||||
if (gpt6cfg1.frequency > 0) {
|
||||
if (GET_CHANNEL_1_FREQ > 0) {
|
||||
if (!note_resting)
|
||||
end_of_note = (note_position >= (note_length*16 - 1));
|
||||
else
|
||||
@@ -399,8 +532,8 @@ static void gpt_cb8(GPTDriver *gptp) {
|
||||
if (notes_repeat) {
|
||||
current_note = 0;
|
||||
} else {
|
||||
gptStopTimer(&GPTD6);
|
||||
gptStopTimer(&GPTD7);
|
||||
STOP_CHANNEL_1();
|
||||
STOP_CHANNEL_2();
|
||||
// gptStopTimer(&GPTD8);
|
||||
playing_notes = false;
|
||||
return;
|
||||
@@ -418,7 +551,7 @@ static void gpt_cb8(GPTDriver *gptp) {
|
||||
}
|
||||
} else {
|
||||
note_resting = false;
|
||||
envelope_index = 0;
|
||||
envelope_index[TIMER_6_INDEX] = 0;
|
||||
note_frequency = (*notes_pointer)[current_note][0];
|
||||
note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100);
|
||||
}
|
||||
@@ -449,7 +582,8 @@ void play_note(float freq, int vol) {
|
||||
|
||||
playing_note = true;
|
||||
|
||||
envelope_index = 0;
|
||||
envelope_index[TIMER_6_INDEX] = 0;
|
||||
envelope_index[TIMER_7_INDEX] = 0;
|
||||
|
||||
if (freq > 0) {
|
||||
frequencies[voices] = freq;
|
||||
@@ -492,8 +626,8 @@ void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat)
|
||||
|
||||
gptStart(&GPTD8, &gpt8cfg1);
|
||||
gptStartContinuous(&GPTD8, 2U);
|
||||
restart_gpt6();
|
||||
restart_gpt7();
|
||||
RESTART_CHANNEL_1();
|
||||
RESTART_CHANNEL_2();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -582,8 +716,8 @@ void decrease_polyphony_rate(float change) {
|
||||
|
||||
// Timbre function
|
||||
|
||||
void set_timbre(float timbre) {
|
||||
note_timbre = timbre;
|
||||
void set_timbre(float timbre, uint8_t timer_index) {
|
||||
note_timbre[timer_index] = timbre;
|
||||
}
|
||||
|
||||
// Tempo functions
|
||||
|
@@ -18,73 +18,91 @@
|
||||
#include "stdlib.h"
|
||||
|
||||
// these are imported from audio.c
|
||||
extern uint16_t envelope_index;
|
||||
extern float note_timbre;
|
||||
extern uint16_t envelope_index[NUMBER_OF_TIMERS];
|
||||
extern float note_timbre[NUMBER_OF_TIMERS];
|
||||
extern float polyphony_rate;
|
||||
extern bool glissando;
|
||||
extern bool glissando[NUMBER_OF_TIMERS];
|
||||
|
||||
voice_type voice = default_voice;
|
||||
voice_type voice[NUMBER_OF_TIMERS] = {default_voice};
|
||||
|
||||
void set_voice(voice_type v) {
|
||||
voice = v;
|
||||
void set_all_voices(voice_type v) {
|
||||
for (uint8_t i = 0; i < NUMBER_OF_TIMERS; i++) {
|
||||
voice[i] = v;
|
||||
}
|
||||
}
|
||||
|
||||
void voice_iterate() {
|
||||
voice = (voice + 1) % number_of_voices;
|
||||
void all_voices_iterate(void) {
|
||||
for (uint8_t i = 0; i < NUMBER_OF_TIMERS; i++) {
|
||||
voice[i] = (voice[i] + 1) % number_of_voices;
|
||||
}
|
||||
}
|
||||
|
||||
void voice_deiterate() {
|
||||
voice = (voice - 1 + number_of_voices) % number_of_voices;
|
||||
void all_voices_deiterate(void) {
|
||||
for (uint8_t i = 0; i < NUMBER_OF_TIMERS; i++) {
|
||||
voice[i] = (voice[i] - 1 + number_of_voices) % number_of_voices;
|
||||
}
|
||||
}
|
||||
|
||||
float voice_envelope(float frequency) {
|
||||
// envelope_index ranges from 0 to 0xFFFF, which is preserved at 880.0 Hz
|
||||
void set_voice(voice_type v, uint8_t timer_index) {
|
||||
voice[timer_index] = v;
|
||||
}
|
||||
|
||||
void voice_iterate(uint8_t timer_index) {
|
||||
voice[timer_index] = (voice[timer_index] + 1) % number_of_voices;
|
||||
}
|
||||
|
||||
void voice_deiterate(uint8_t timer_index) {
|
||||
voice[timer_index] = (voice[timer_index] - 1 + number_of_voices) % number_of_voices;
|
||||
}
|
||||
|
||||
float voice_envelope(float frequency, uint8_t timer_index) {
|
||||
// envelope_index[timer_index] ranges from 0 to 0xFFFF, which is preserved at 880.0 Hz
|
||||
__attribute__ ((unused))
|
||||
uint16_t compensated_index = (uint16_t)((float)envelope_index * (880.0 / frequency));
|
||||
uint16_t compensated_index = (uint16_t)((float)envelope_index[timer_index] * (880.0 / frequency));
|
||||
|
||||
switch (voice) {
|
||||
switch (voice[timer_index]) {
|
||||
case default_voice:
|
||||
glissando = false;
|
||||
note_timbre = TIMBRE_50;
|
||||
glissando[timer_index] = false;
|
||||
note_timbre[timer_index] = TIMBRE_50;
|
||||
polyphony_rate = 0;
|
||||
break;
|
||||
|
||||
#ifdef AUDIO_VOICES
|
||||
|
||||
case something:
|
||||
glissando = false;
|
||||
glissando[timer_index] = false;
|
||||
polyphony_rate = 0;
|
||||
switch (compensated_index) {
|
||||
case 0 ... 9:
|
||||
note_timbre = TIMBRE_12;
|
||||
note_timbre[timer_index] = TIMBRE_12;
|
||||
break;
|
||||
|
||||
case 10 ... 19:
|
||||
note_timbre = TIMBRE_25;
|
||||
note_timbre[timer_index] = TIMBRE_25;
|
||||
break;
|
||||
|
||||
case 20 ... 200:
|
||||
note_timbre = .125 + .125;
|
||||
note_timbre[timer_index] = .125 + .125;
|
||||
break;
|
||||
|
||||
default:
|
||||
note_timbre = .125;
|
||||
note_timbre[timer_index] = .125;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case drums:
|
||||
glissando = false;
|
||||
glissando[timer_index] = false;
|
||||
polyphony_rate = 0;
|
||||
// switch (compensated_index) {
|
||||
// case 0 ... 10:
|
||||
// note_timbre = 0.5;
|
||||
// note_timbre[timer_index] = 0.5;
|
||||
// break;
|
||||
// case 11 ... 20:
|
||||
// note_timbre = 0.5 * (21 - compensated_index) / 10;
|
||||
// note_timbre[timer_index] = 0.5 * (21 - compensated_index) / 10;
|
||||
// break;
|
||||
// default:
|
||||
// note_timbre = 0;
|
||||
// note_timbre[timer_index] = 0;
|
||||
// break;
|
||||
// }
|
||||
// frequency = (rand() % (int)(frequency * 1.2 - frequency)) + (frequency * 0.8);
|
||||
@@ -95,15 +113,15 @@ float voice_envelope(float frequency) {
|
||||
|
||||
// Bass drum: 60 - 100 Hz
|
||||
frequency = (rand() % (int)(40)) + 60;
|
||||
switch (envelope_index) {
|
||||
switch (envelope_index[timer_index]) {
|
||||
case 0 ... 10:
|
||||
note_timbre = 0.5;
|
||||
note_timbre[timer_index] = 0.5;
|
||||
break;
|
||||
case 11 ... 20:
|
||||
note_timbre = 0.5 * (21 - envelope_index) / 10;
|
||||
note_timbre[timer_index] = 0.5 * (21 - envelope_index[timer_index]) / 10;
|
||||
break;
|
||||
default:
|
||||
note_timbre = 0;
|
||||
note_timbre[timer_index] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -112,15 +130,15 @@ float voice_envelope(float frequency) {
|
||||
|
||||
// Snare drum: 1 - 2 KHz
|
||||
frequency = (rand() % (int)(1000)) + 1000;
|
||||
switch (envelope_index) {
|
||||
switch (envelope_index[timer_index]) {
|
||||
case 0 ... 5:
|
||||
note_timbre = 0.5;
|
||||
note_timbre[timer_index] = 0.5;
|
||||
break;
|
||||
case 6 ... 20:
|
||||
note_timbre = 0.5 * (21 - envelope_index) / 15;
|
||||
note_timbre[timer_index] = 0.5 * (21 - envelope_index[timer_index]) / 15;
|
||||
break;
|
||||
default:
|
||||
note_timbre = 0;
|
||||
note_timbre[timer_index] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -128,15 +146,15 @@ float voice_envelope(float frequency) {
|
||||
|
||||
// Closed Hi-hat: 3 - 5 KHz
|
||||
frequency = (rand() % (int)(2000)) + 3000;
|
||||
switch (envelope_index) {
|
||||
switch (envelope_index[timer_index]) {
|
||||
case 0 ... 15:
|
||||
note_timbre = 0.5;
|
||||
note_timbre[timer_index] = 0.5;
|
||||
break;
|
||||
case 16 ... 20:
|
||||
note_timbre = 0.5 * (21 - envelope_index) / 5;
|
||||
note_timbre[timer_index] = 0.5 * (21 - envelope_index[timer_index]) / 5;
|
||||
break;
|
||||
default:
|
||||
note_timbre = 0;
|
||||
note_timbre[timer_index] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -144,96 +162,96 @@ float voice_envelope(float frequency) {
|
||||
|
||||
// Open Hi-hat: 3 - 5 KHz
|
||||
frequency = (rand() % (int)(2000)) + 3000;
|
||||
switch (envelope_index) {
|
||||
switch (envelope_index[timer_index]) {
|
||||
case 0 ... 35:
|
||||
note_timbre = 0.5;
|
||||
note_timbre[timer_index] = 0.5;
|
||||
break;
|
||||
case 36 ... 50:
|
||||
note_timbre = 0.5 * (51 - envelope_index) / 15;
|
||||
note_timbre[timer_index] = 0.5 * (51 - envelope_index[timer_index]) / 15;
|
||||
break;
|
||||
default:
|
||||
note_timbre = 0;
|
||||
note_timbre[timer_index] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case butts_fader:
|
||||
glissando = true;
|
||||
glissando[timer_index] = true;
|
||||
polyphony_rate = 0;
|
||||
switch (compensated_index) {
|
||||
case 0 ... 9:
|
||||
frequency = frequency / 4;
|
||||
note_timbre = TIMBRE_12;
|
||||
note_timbre[timer_index] = TIMBRE_12;
|
||||
break;
|
||||
|
||||
case 10 ... 19:
|
||||
frequency = frequency / 2;
|
||||
note_timbre = TIMBRE_12;
|
||||
note_timbre[timer_index] = TIMBRE_12;
|
||||
break;
|
||||
|
||||
case 20 ... 200:
|
||||
note_timbre = .125 - pow(((float)compensated_index - 20) / (200 - 20), 2)*.125;
|
||||
note_timbre[timer_index] = .125 - pow(((float)compensated_index - 20) / (200 - 20), 2)*.125;
|
||||
break;
|
||||
|
||||
default:
|
||||
note_timbre = 0;
|
||||
note_timbre[timer_index] = 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
// case octave_crunch:
|
||||
// polyphony_rate = 0;
|
||||
// switch (compensated_index) {
|
||||
// case 0 ... 9:
|
||||
// case 20 ... 24:
|
||||
// case 30 ... 32:
|
||||
// frequency = frequency / 2;
|
||||
// note_timbre = TIMBRE_12;
|
||||
// break;
|
||||
case octave_crunch:
|
||||
polyphony_rate = 0;
|
||||
switch (compensated_index) {
|
||||
case 0 ... 9:
|
||||
case 20 ... 24:
|
||||
case 30 ... 32:
|
||||
frequency = frequency / 2;
|
||||
note_timbre[timer_index] = TIMBRE_12;
|
||||
break;
|
||||
|
||||
// case 10 ... 19:
|
||||
// case 25 ... 29:
|
||||
// case 33 ... 35:
|
||||
// frequency = frequency * 2;
|
||||
// note_timbre = TIMBRE_12;
|
||||
// break;
|
||||
case 10 ... 19:
|
||||
case 25 ... 29:
|
||||
case 33 ... 35:
|
||||
frequency = frequency * 2;
|
||||
note_timbre[timer_index] = TIMBRE_12;
|
||||
break;
|
||||
|
||||
// default:
|
||||
// note_timbre = TIMBRE_12;
|
||||
// break;
|
||||
// }
|
||||
// break;
|
||||
default:
|
||||
note_timbre[timer_index] = TIMBRE_12;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case duty_osc:
|
||||
// This slows the loop down a substantial amount, so higher notes may freeze
|
||||
glissando = true;
|
||||
glissando[timer_index] = true;
|
||||
polyphony_rate = 0;
|
||||
switch (compensated_index) {
|
||||
default:
|
||||
#define OCS_SPEED 10
|
||||
#define OCS_AMP .25
|
||||
// sine wave is slow
|
||||
// note_timbre = (sin((float)compensated_index/10000*OCS_SPEED) * OCS_AMP / 2) + .5;
|
||||
// note_timbre[timer_index] = (sin((float)compensated_index/10000*OCS_SPEED) * OCS_AMP / 2) + .5;
|
||||
// triangle wave is a bit faster
|
||||
note_timbre = (float)abs((compensated_index*OCS_SPEED % 3000) - 1500) * ( OCS_AMP / 1500 ) + (1 - OCS_AMP) / 2;
|
||||
note_timbre[timer_index] = (float)abs((compensated_index*OCS_SPEED % 3000) - 1500) * ( OCS_AMP / 1500 ) + (1 - OCS_AMP) / 2;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case duty_octave_down:
|
||||
glissando = true;
|
||||
glissando[timer_index] = true;
|
||||
polyphony_rate = 0;
|
||||
note_timbre = (envelope_index % 2) * .125 + .375 * 2;
|
||||
if ((envelope_index % 4) == 0)
|
||||
note_timbre = 0.5;
|
||||
if ((envelope_index % 8) == 0)
|
||||
note_timbre = 0;
|
||||
note_timbre[timer_index] = (envelope_index[timer_index] % 2) * .125 + .375 * 2;
|
||||
if ((envelope_index[timer_index] % 4) == 0)
|
||||
note_timbre[timer_index] = 0.5;
|
||||
if ((envelope_index[timer_index] % 8) == 0)
|
||||
note_timbre[timer_index] = 0;
|
||||
break;
|
||||
case delayed_vibrato:
|
||||
glissando = true;
|
||||
glissando[timer_index] = true;
|
||||
polyphony_rate = 0;
|
||||
note_timbre = TIMBRE_50;
|
||||
note_timbre[timer_index] = TIMBRE_50;
|
||||
#define VOICE_VIBRATO_DELAY 150
|
||||
#define VOICE_VIBRATO_SPEED 50
|
||||
switch (compensated_index) {
|
||||
@@ -246,10 +264,10 @@ float voice_envelope(float frequency) {
|
||||
break;
|
||||
// case delayed_vibrato_octave:
|
||||
// polyphony_rate = 0;
|
||||
// if ((envelope_index % 2) == 1) {
|
||||
// note_timbre = 0.55;
|
||||
// if ((envelope_index[timer_index] % 2) == 1) {
|
||||
// note_timbre[timer_index] = 0.55;
|
||||
// } else {
|
||||
// note_timbre = 0.45;
|
||||
// note_timbre[timer_index] = 0.45;
|
||||
// }
|
||||
// #define VOICE_VIBRATO_DELAY 150
|
||||
// #define VOICE_VIBRATO_SPEED 50
|
||||
@@ -262,28 +280,28 @@ float voice_envelope(float frequency) {
|
||||
// }
|
||||
// break;
|
||||
// case duty_fifth_down:
|
||||
// note_timbre = 0.5;
|
||||
// if ((envelope_index % 3) == 0)
|
||||
// note_timbre = 0.75;
|
||||
// note_timbre[timer_index] = 0.5;
|
||||
// if ((envelope_index[timer_index] % 3) == 0)
|
||||
// note_timbre[timer_index] = 0.75;
|
||||
// break;
|
||||
// case duty_fourth_down:
|
||||
// note_timbre = 0.0;
|
||||
// if ((envelope_index % 12) == 0)
|
||||
// note_timbre = 0.75;
|
||||
// if (((envelope_index % 12) % 4) != 1)
|
||||
// note_timbre = 0.75;
|
||||
// note_timbre[timer_index] = 0.0;
|
||||
// if ((envelope_index[timer_index] % 12) == 0)
|
||||
// note_timbre[timer_index] = 0.75;
|
||||
// if (((envelope_index[timer_index] % 12) % 4) != 1)
|
||||
// note_timbre[timer_index] = 0.75;
|
||||
// break;
|
||||
// case duty_third_down:
|
||||
// note_timbre = 0.5;
|
||||
// if ((envelope_index % 5) == 0)
|
||||
// note_timbre = 0.75;
|
||||
// note_timbre[timer_index] = 0.5;
|
||||
// if ((envelope_index[timer_index] % 5) == 0)
|
||||
// note_timbre[timer_index] = 0.75;
|
||||
// break;
|
||||
// case duty_fifth_third_down:
|
||||
// note_timbre = 0.5;
|
||||
// if ((envelope_index % 5) == 0)
|
||||
// note_timbre = 0.75;
|
||||
// if ((envelope_index % 3) == 0)
|
||||
// note_timbre = 0.25;
|
||||
// note_timbre[timer_index] = 0.5;
|
||||
// if ((envelope_index[timer_index] % 5) == 0)
|
||||
// note_timbre[timer_index] = 0.75;
|
||||
// if ((envelope_index[timer_index] % 3) == 0)
|
||||
// note_timbre[timer_index] = 0.25;
|
||||
// break;
|
||||
|
||||
#endif
|
||||
|
@@ -24,7 +24,7 @@
|
||||
#ifndef VOICES_H
|
||||
#define VOICES_H
|
||||
|
||||
float voice_envelope(float frequency);
|
||||
float voice_envelope(float frequency, uint8_t timer_index);
|
||||
|
||||
typedef enum {
|
||||
default_voice,
|
||||
@@ -45,8 +45,12 @@ typedef enum {
|
||||
number_of_voices // important that this is last
|
||||
} voice_type;
|
||||
|
||||
void set_voice(voice_type v);
|
||||
void voice_iterate(void);
|
||||
void voice_deiterate(void);
|
||||
void set_all_voices(voice_type v);
|
||||
void all_voices_iterate(void);
|
||||
void all_voices_deiterate(void);
|
||||
|
||||
void set_voice(voice_type v, uint8_t timer_index);
|
||||
void voice_iterate(uint8_t timer_index);
|
||||
void voice_deiterate(uint8_t timer_index);
|
||||
|
||||
#endif
|
||||
|
@@ -38,13 +38,13 @@ bool process_audio(uint16_t keycode, keyrecord_t *record) {
|
||||
}
|
||||
|
||||
if (keycode == MUV_IN && record->event.pressed) {
|
||||
voice_iterate();
|
||||
all_voices_iterate();
|
||||
PLAY_SONG(voice_change_song);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (keycode == MUV_DE && record->event.pressed) {
|
||||
voice_deiterate();
|
||||
all_voices_deiterate();
|
||||
PLAY_SONG(voice_change_song);
|
||||
return false;
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ bool music_activated = false;
|
||||
bool midi_activated = false;
|
||||
uint8_t music_starting_note = 0x0C;
|
||||
int music_offset = 7;
|
||||
uint8_t music_mode = MUSIC_MODE_CHROMATIC;
|
||||
uint8_t music_mode = MUSIC_MODE_MAJOR;
|
||||
|
||||
// music sequencer
|
||||
static bool music_sequence_recording = false;
|
||||
|
@@ -885,7 +885,6 @@ void backlight_set(uint8_t level) {}
|
||||
|
||||
uint8_t backlight_tick = 0;
|
||||
|
||||
#ifndef BACKLIGHT_CUSTOM_DRIVER
|
||||
void backlight_task(void) {
|
||||
if ((0xFFFF >> ((BACKLIGHT_LEVELS - get_backlight_level()) * ((BACKLIGHT_LEVELS + 1) / 2))) & (1 << backlight_tick)) {
|
||||
#if BACKLIGHT_ON_STATE == 0
|
||||
@@ -906,12 +905,9 @@ void backlight_task(void) {
|
||||
}
|
||||
backlight_tick = backlight_tick + 1 % 16;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef BACKLIGHT_BREATHING
|
||||
#ifndef BACKLIGHT_CUSTOM_DRIVER
|
||||
#error "Backlight breathing only available with hardware PWM. Please disable."
|
||||
#endif
|
||||
#error "Backlight breathing only available with hardware PWM. Please disable."
|
||||
#endif
|
||||
|
||||
#else // pwm through timer
|
||||
@@ -939,7 +935,6 @@ static inline void set_pwm(uint16_t val) {
|
||||
OCR1x = val;
|
||||
}
|
||||
|
||||
#ifndef BACKLIGHT_CUSTOM_DRIVER
|
||||
__attribute__ ((weak))
|
||||
void backlight_set(uint8_t level) {
|
||||
if (level > BACKLIGHT_LEVELS)
|
||||
@@ -957,7 +952,6 @@ void backlight_set(uint8_t level) {
|
||||
}
|
||||
|
||||
void backlight_task(void) {}
|
||||
#endif // BACKLIGHT_CUSTOM_DRIVER
|
||||
|
||||
#ifdef BACKLIGHT_BREATHING
|
||||
|
||||
|
@@ -168,22 +168,6 @@ OPT_DEFS += -DPROTOCOL_CHIBIOS
|
||||
|
||||
MCUFLAGS = -mcpu=$(MCU)
|
||||
|
||||
# FPU options default (Cortex-M4 and Cortex-M7 single precision).
|
||||
ifeq ($(USE_FPU_OPT),)
|
||||
USE_FPU_OPT = -mfloat-abi=$(USE_FPU) -mfpu=fpv4-sp-d16 -fsingle-precision-constant
|
||||
endif
|
||||
|
||||
# FPU-related options
|
||||
ifeq ($(USE_FPU),)
|
||||
USE_FPU = no
|
||||
endif
|
||||
ifneq ($(USE_FPU),no)
|
||||
OPT += $(USE_FPU_OPT)
|
||||
OPT_DEFS += -DCORTEX_USE_FPU=TRUE
|
||||
else
|
||||
OPT_DEFS += -DCORTEX_USE_FPU=FALSE
|
||||
endif
|
||||
|
||||
DEBUG = gdb
|
||||
|
||||
DFU_ARGS ?=
|
||||
|
@@ -13,8 +13,13 @@ extern "C" {
|
||||
# define wait_us(us) _delay_us(us)
|
||||
#elif defined PROTOCOL_CHIBIOS
|
||||
# include "ch.h"
|
||||
# define wait_ms(ms) chThdSleepMilliseconds(ms)
|
||||
# define wait_us(us) chThdSleepMicroseconds(us)
|
||||
# if defined(STM32F3xx_MCUCONF)
|
||||
# define wait_ms(ms) chSysPolledDelayX(MS2RTC(STM32_HCLK, (ms)))
|
||||
# define wait_us(us) chSysPolledDelayX(US2RTC(STM32_HCLK, (us)))
|
||||
# else
|
||||
# define wait_ms(ms) chThdSleepMilliseconds(ms)
|
||||
# define wait_us(us) chThdSleepMicroseconds(us)
|
||||
# endif
|
||||
#elif defined(__arm__)
|
||||
# include "wait_api.h"
|
||||
#else // Unit tests
|
||||
|
@@ -30,15 +30,6 @@ PROGMEM const char secret[][64] = {
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef FAUXCLICKY_ENABLE
|
||||
float fauxclicky_pressed_note[2] = MUSICAL_NOTE(_A6, 2); // (_D4, 0.25);
|
||||
float fauxclicky_released_note[2] = MUSICAL_NOTE(_A6, 2); // (_C4, 0.125);
|
||||
#else
|
||||
float fauxclicky_pressed[][2] = SONG(E__NOTE(_A6)); // change to your tastes
|
||||
float fauxclicky_released[][2] = SONG(E__NOTE(_A6)); // change to your tastes
|
||||
#endif
|
||||
bool faux_click_enabled = true;
|
||||
|
||||
#ifdef TAP_DANCE_ENABLE
|
||||
//define diablo macro timer variables
|
||||
static uint16_t diablo_timer[4];
|
||||
@@ -236,17 +227,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
xprintf("KL: row: %u, column: %u, pressed: %u\n", record->event.key.col, record->event.key.row, record->event.pressed);
|
||||
#endif
|
||||
|
||||
#ifdef AUDIO_ENABLE
|
||||
if (faux_click_enabled) {
|
||||
if (record->event.pressed) {
|
||||
PLAY_SONG(fauxclicky_pressed);
|
||||
} else {
|
||||
stop_note(NOTE_A6);
|
||||
PLAY_SONG(fauxclicky_released);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
switch (keycode) {
|
||||
case KC_QWERTY:
|
||||
if (record->event.pressed) {
|
||||
@@ -315,7 +295,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
#if !(defined(KEYBOARD_orthodox_rev1) || defined(KEYBOARD_orthodox_rev3) || defined(KEYBOARD_ergodox_ez))
|
||||
#if !(defined(KEYBOARD_orthodox_rev1) || defined(KEYBOARD_ergodox_ez))
|
||||
case KC_OVERWATCH:
|
||||
if (record->event.pressed) {
|
||||
is_overwatch = !is_overwatch;
|
||||
@@ -480,6 +460,11 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
" AUDIO_ENABLE=yes"
|
||||
#else
|
||||
" AUDIO_ENABLE=no"
|
||||
#endif
|
||||
#ifdef FAUXCLICKY_ENABLE
|
||||
" FAUXCLICKY_ENABLE=yes"
|
||||
#else
|
||||
" FAUXCLICKY_ENABLE=no"
|
||||
#endif
|
||||
SS_TAP(X_ENTER));
|
||||
}
|
||||
@@ -514,12 +499,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case KC_FXCL:
|
||||
if (!record->event.pressed) {
|
||||
faux_click_enabled = !faux_click_enabled;
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case KC_RGB_T: // Because I want the option to go back to normal RGB mode rather than always layer indication
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
if (record->event.pressed) {
|
||||
|
@@ -101,7 +101,6 @@ enum userspace_custom_keycodes {
|
||||
KC_SECRET_3,
|
||||
KC_SECRET_4,
|
||||
KC_SECRET_5,
|
||||
KC_FXCL,
|
||||
NEW_SAFE_RANGE //use "NEWPLACEHOLDER for keymap specific codes
|
||||
};
|
||||
|
||||
@@ -134,12 +133,4 @@ enum {
|
||||
|
||||
#define IGNORE_MOD_TAP_INTERRUPT // this makes it possible to do rolling combos (zx) with keys that convert to other keys on hold (z becomes ctrl when you hold it, and when this option isn't enabled, z rapidly followed by x actually sends Ctrl-x. That's bad.)
|
||||
|
||||
#ifdef FAUXCLICKY_ENABLE
|
||||
#define AUD_ON FC_ON
|
||||
#define AUD_OFF FC_OFF
|
||||
#else
|
||||
#define AUD_ON AU_ON
|
||||
#define AUD_OFF AU_OFF
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user