Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2306c974e5 | ||
|
|
833c5ae87a | ||
|
|
57de9e65ef | ||
|
|
6b6e47cbf1 | ||
|
|
54b6bf5910 | ||
|
|
73728e9bec | ||
|
|
4f1a62ca1d | ||
|
|
4e826ba61f | ||
|
|
b438c6f8ea | ||
|
|
bad9468ce1 | ||
|
|
9810756ee0 | ||
|
|
918a85d342 | ||
|
|
116c0e44a1 | ||
|
|
3c0ef04390 |
No files matched your search
@@ -136,22 +136,22 @@ If you define these options you will enable the associated feature, which may in
|
|||||||
* enables handling for per key `TAPPING_TERM` settings
|
* enables handling for per key `TAPPING_TERM` settings
|
||||||
* `#define RETRO_TAPPING`
|
* `#define RETRO_TAPPING`
|
||||||
* tap anyway, even after TAPPING_TERM, if there was no other key interruption between press and release
|
* tap anyway, even after TAPPING_TERM, if there was no other key interruption between press and release
|
||||||
* See [Retro Tapping](#retro-tapping) for details
|
* See [Retro Tapping](tap_hold.md#retro-tapping) for details
|
||||||
* `#define TAPPING_TOGGLE 2`
|
* `#define TAPPING_TOGGLE 2`
|
||||||
* how many taps before triggering the toggle
|
* how many taps before triggering the toggle
|
||||||
* `#define PERMISSIVE_HOLD`
|
* `#define PERMISSIVE_HOLD`
|
||||||
* makes tap and hold keys trigger the hold if another key is pressed before releasing, even if it hasn't hit the `TAPPING_TERM`
|
* makes tap and hold keys trigger the hold if another key is pressed before releasing, even if it hasn't hit the `TAPPING_TERM`
|
||||||
* See [Permissive Hold](#permissive-hold) for details
|
* See [Permissive Hold](tap_hold.md#permissive-hold) for details
|
||||||
* `#define PERMISSIVE_HOLD_PER_KEY`
|
* `#define PERMISSIVE_HOLD_PER_KEY`
|
||||||
* enabled handling for per key `PERMISSIVE_HOLD` settings
|
* enabled handling for per key `PERMISSIVE_HOLD` settings
|
||||||
* `#define IGNORE_MOD_TAP_INTERRUPT`
|
* `#define IGNORE_MOD_TAP_INTERRUPT`
|
||||||
* makes it possible to do rolling combos (zx) with keys that convert to other keys on hold, by enforcing the `TAPPING_TERM` for both keys.
|
* makes it possible to do rolling combos (zx) with keys that convert to other keys on hold, by enforcing the `TAPPING_TERM` for both keys.
|
||||||
* See [Mod tap interrupt](#ignore-mod-tap-interrupt) for details
|
* See [Ignore Mod Tap Interrupt](tap_hold.md#ignore-mod-tap-interrupt) for details
|
||||||
* `#define IGNORE_MOD_TAP_INTERRUPT_PER_KEY`
|
* `#define IGNORE_MOD_TAP_INTERRUPT_PER_KEY`
|
||||||
* enables handling for per key `IGNORE_MOD_TAP_INTERRUPT` settings
|
* enables handling for per key `IGNORE_MOD_TAP_INTERRUPT` settings
|
||||||
* `#define TAPPING_FORCE_HOLD`
|
* `#define TAPPING_FORCE_HOLD`
|
||||||
* makes it possible to use a dual role key as modifier shortly after having been tapped
|
* makes it possible to use a dual role key as modifier shortly after having been tapped
|
||||||
* See [Hold after tap](#tapping-force-hold)
|
* See [Tapping Force Hold](tap_hold.md#tapping-force-hold)
|
||||||
* Breaks any Tap Toggle functionality (`TT` or the One Shot Tap Toggle)
|
* Breaks any Tap Toggle functionality (`TT` or the One Shot Tap Toggle)
|
||||||
* `#define TAPPING_FORCE_HOLD_PER_KEY`
|
* `#define TAPPING_FORCE_HOLD_PER_KEY`
|
||||||
* enables handling for per key `TAPPING_FORCE_HOLD` settings
|
* enables handling for per key `TAPPING_FORCE_HOLD` settings
|
||||||
|
|||||||
@@ -221,6 +221,12 @@ void oled_write(const char *data, bool invert);
|
|||||||
// Advances the cursor to the next page, wiring ' ' to the remainder of the current page
|
// Advances the cursor to the next page, wiring ' ' to the remainder of the current page
|
||||||
void oled_write_ln(const char *data, bool invert);
|
void oled_write_ln(const char *data, bool invert);
|
||||||
|
|
||||||
|
// Pans the buffer to the right (or left by passing true) by moving contents of the buffer
|
||||||
|
// Useful for moving the screen in preparation for new drawing
|
||||||
|
// oled_scroll_left or oled_scroll_right should be preferred for all cases of moving a static
|
||||||
|
// image such as a logo or to avoid burn-in as it's much, much less cpu intensive
|
||||||
|
void oled_pan(bool left);
|
||||||
|
|
||||||
// Writes a PROGMEM string to the buffer at current cursor position
|
// Writes a PROGMEM string to the buffer at current cursor position
|
||||||
// Advances the cursor while writing, inverts the pixels if true
|
// Advances the cursor while writing, inverts the pixels if true
|
||||||
// Remapped to call 'void oled_write(const char *data, bool invert);' on ARM
|
// Remapped to call 'void oled_write(const char *data, bool invert);' on ARM
|
||||||
@@ -235,6 +241,9 @@ void oled_write_ln_P(const char *data, bool invert);
|
|||||||
// Writes a string to the buffer at current cursor position
|
// Writes a string to the buffer at current cursor position
|
||||||
void oled_write_raw(const char *data, uint16_t size);
|
void oled_write_raw(const char *data, uint16_t size);
|
||||||
|
|
||||||
|
// Writes a single byte into the buffer at the specified index
|
||||||
|
void oled_write_raw_byte(const char data, uint16_t index);
|
||||||
|
|
||||||
// Writes a PROGMEM string to the buffer at current cursor position
|
// Writes a PROGMEM string to the buffer at current cursor position
|
||||||
void oled_write_raw_P(const char *data, uint16_t size);
|
void oled_write_raw_P(const char *data, uint16_t size);
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
# Tap-Hold Configuration Options
|
# Tap-Hold Configuration Options
|
||||||
|
|
||||||
While Tap-Hold options are fantastic, they are not without their issues. We have tried to configure them with reasonal defaults, but that may still cause issues for some people.
|
While Tap-Hold options are fantastic, they are not without their issues. We have tried to configure them with reasonable defaults, but that may still cause issues for some people.
|
||||||
|
|
||||||
These options let you modify the behavior of the Tap-Hold keys.
|
These options let you modify the behavior of the Tap-Hold keys.
|
||||||
|
|
||||||
|
|||||||
@@ -428,6 +428,31 @@ void oled_write_ln(const char *data, bool invert) {
|
|||||||
oled_advance_page(true);
|
oled_advance_page(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void oled_pan(bool left) {
|
||||||
|
uint16_t i = 0;
|
||||||
|
for (uint16_t y = 0; y < OLED_DISPLAY_HEIGHT / 8; y++) {
|
||||||
|
if (left) {
|
||||||
|
for (uint16_t x = 0; x < OLED_DISPLAY_WIDTH - 1; x++) {
|
||||||
|
i = y * OLED_DISPLAY_WIDTH + x;
|
||||||
|
oled_buffer[i] = oled_buffer[i + 1];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (uint16_t x = OLED_DISPLAY_WIDTH - 1; x > 0; x--) {
|
||||||
|
i = y * OLED_DISPLAY_WIDTH + x;
|
||||||
|
oled_buffer[i] = oled_buffer[i - 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
oled_dirty = ~((OLED_BLOCK_TYPE)0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void oled_write_raw_byte(const char data, uint16_t index) {
|
||||||
|
if (index > OLED_MATRIX_SIZE) index = OLED_MATRIX_SIZE;
|
||||||
|
if (oled_buffer[index] == data) return;
|
||||||
|
oled_buffer[index] = data;
|
||||||
|
oled_dirty |= (1 << (index / OLED_BLOCK_SIZE));
|
||||||
|
}
|
||||||
|
|
||||||
void oled_write_raw(const char *data, uint16_t size) {
|
void oled_write_raw(const char *data, uint16_t size) {
|
||||||
if (size > OLED_MATRIX_SIZE) size = OLED_MATRIX_SIZE;
|
if (size > OLED_MATRIX_SIZE) size = OLED_MATRIX_SIZE;
|
||||||
for (uint16_t i = 0; i < size; i++) {
|
for (uint16_t i = 0; i < size; i++) {
|
||||||
|
|||||||
@@ -200,7 +200,11 @@ void oled_write(const char *data, bool invert);
|
|||||||
// Advances the cursor to the next page, wiring ' ' to the remainder of the current page
|
// Advances the cursor to the next page, wiring ' ' to the remainder of the current page
|
||||||
void oled_write_ln(const char *data, bool invert);
|
void oled_write_ln(const char *data, bool invert);
|
||||||
|
|
||||||
|
// Pans the buffer to the right (or left by passing true) by moving contents of the buffer
|
||||||
|
void oled_pan(bool left);
|
||||||
|
|
||||||
void oled_write_raw(const char *data, uint16_t size);
|
void oled_write_raw(const char *data, uint16_t size);
|
||||||
|
void oled_write_raw_byte(const char data, uint16_t index);
|
||||||
|
|
||||||
#if defined(__AVR__)
|
#if defined(__AVR__)
|
||||||
// Writes a PROGMEM string to the buffer at current cursor position
|
// Writes a PROGMEM string to the buffer at current cursor position
|
||||||
|
|||||||
@@ -0,0 +1,110 @@
|
|||||||
|
/* Copyright 2020 Sam Reinehr
|
||||||
|
*
|
||||||
|
* 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 QMK_KEYBOARD_H
|
||||||
|
enum my_keycodes {
|
||||||
|
K00 = SAFE_RANGE,
|
||||||
|
K01,
|
||||||
|
K02,
|
||||||
|
K03,
|
||||||
|
K04,
|
||||||
|
K05,
|
||||||
|
K06,
|
||||||
|
K07,
|
||||||
|
K08,
|
||||||
|
K09,
|
||||||
|
K10,
|
||||||
|
K11,
|
||||||
|
K12,
|
||||||
|
K13,
|
||||||
|
K14,
|
||||||
|
K15,
|
||||||
|
};
|
||||||
|
/* just a simple way to give each key a unique code */
|
||||||
|
//clang-format off
|
||||||
|
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
|
/* Base */
|
||||||
|
[0] = LAYOUT_ortho_4x4(
|
||||||
|
K00, K01, K02, K03,
|
||||||
|
K04, K05, K06, K07,
|
||||||
|
K08, K09, K10, K11,
|
||||||
|
K12, K13, K14, K15
|
||||||
|
)
|
||||||
|
};
|
||||||
|
/* flags describing current free square/0 */
|
||||||
|
uint8_t current = 0;
|
||||||
|
/* r g and b describe the colors for the initial map,
|
||||||
|
currently blank for free, and evenly spaced hues with maximum sat/value */
|
||||||
|
const uint8_t r[16] = {
|
||||||
|
0x00, 0xFF, 0xFF, 0xFF,
|
||||||
|
0xCC, 0x66, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x66, 0xCC, 0xFF, 0xFF
|
||||||
|
};
|
||||||
|
const uint8_t g[16] = {
|
||||||
|
0x00, 0x00, 0x66, 0xCC,
|
||||||
|
0xFF, 0xFF, 0xFF, 0xFF,
|
||||||
|
0xFF, 0xCC, 0x66, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00
|
||||||
|
};
|
||||||
|
const uint8_t b[16] = {
|
||||||
|
0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x66,
|
||||||
|
0xCC, 0xFF, 0xFF, 0xFF,
|
||||||
|
0xFF, 0xFF, 0xCC, 0x66
|
||||||
|
};
|
||||||
|
/* pos contains the current positions, could technically be compressed to 4 bits per, but not worth it
|
||||||
|
index into pos is the position we're looking at, output is the tile that is currently there */
|
||||||
|
uint8_t tiles[16] = {
|
||||||
|
0, 1, 2, 3,
|
||||||
|
4, 5, 6, 7,
|
||||||
|
8, 9, 10, 11,
|
||||||
|
12, 13, 14, 15
|
||||||
|
};
|
||||||
|
/* default led array for super 16 has them in a snake, so we must do some remapping/flipping of the 2nd and 4th rows */
|
||||||
|
uint8_t remap[16] = {
|
||||||
|
0, 1, 2, 3,
|
||||||
|
7, 6, 5, 4,
|
||||||
|
8, 9, 10, 11,
|
||||||
|
15, 14, 13, 12
|
||||||
|
};
|
||||||
|
//clang-format on
|
||||||
|
/* function to refresh the led coloring with the positions with current tiles */
|
||||||
|
void refresh_leds(void) {
|
||||||
|
for (uint8_t index = 0; index < 16; ++index) {
|
||||||
|
uint8_t tile = tiles[index];
|
||||||
|
setrgb(r[tile], g[tile], b[tile], (LED_TYPE *)&led[remap[index]]);
|
||||||
|
}
|
||||||
|
rgblight_set();
|
||||||
|
}
|
||||||
|
void keyboard_post_init_user(void) {
|
||||||
|
rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT);
|
||||||
|
rgblight_enable_noeeprom();
|
||||||
|
refresh_leds();
|
||||||
|
}
|
||||||
|
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
|
uint8_t offset = keycode - K00;
|
||||||
|
uint8_t x = offset & 0x03;
|
||||||
|
uint8_t y = (offset & 0x0C) >> 2;
|
||||||
|
/* if the adjacent space exists and is empty, */
|
||||||
|
if ((x > 0 && 0 == tiles[offset - 1]) || (y > 0 && 0 == tiles[offset - 4]) || (x < 3 && 0 == tiles[offset + 1]) || (y < 3 && 0 == tiles[offset + 4])) {
|
||||||
|
/* set the currently blank tile to this tile, and make this one blank */
|
||||||
|
tiles[current] = tiles[offset];
|
||||||
|
tiles[offset] = 0;
|
||||||
|
current = offset;
|
||||||
|
}
|
||||||
|
refresh_leds();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Trying to put a game that plays like the 15 puzzle on the super16
|
||||||
|
The 15/16 puzzle consists of a grid where one space is free, and adjacent spaces can be swapped with the free space
|
||||||
|
* future planned features:
|
||||||
|
* fix the start at red
|
||||||
|
* have a cute animation play when the puzzle is solved
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
RGBLIGHT_ENABLE = yes
|
||||||
|
RGB_MATRIX_ENABLE = no
|
||||||
@@ -8,39 +8,6 @@ void matrix_init_kb(void) {
|
|||||||
led_init_ports();
|
led_init_ports();
|
||||||
}
|
}
|
||||||
|
|
||||||
void matrix_scan_kb(void) {
|
|
||||||
matrix_scan_user();
|
|
||||||
}
|
|
||||||
|
|
||||||
void backlight_init_ports(void) {
|
|
||||||
print("init_backlight_pin()\n");
|
|
||||||
// Set our LED pins as output
|
|
||||||
//DDRD |= (1<<6); // Esc
|
|
||||||
//DDRB |= (1<<7); // Page Up
|
|
||||||
//DDRD |= (1<<4); // Arrows
|
|
||||||
|
|
||||||
// Set our LED pins low
|
|
||||||
//PORTD &= ~(1<<6); // Esc
|
|
||||||
//PORTB &= ~(1<<7); // Page Up
|
|
||||||
//PORTD &= ~(1<<4); // Arrows
|
|
||||||
}
|
|
||||||
|
|
||||||
void backlight_set(uint8_t level) {
|
|
||||||
/*
|
|
||||||
if ( level == 0 ) {
|
|
||||||
// Turn off light
|
|
||||||
PORTD |= (1<<6); // Esc
|
|
||||||
PORTB |= (1<<7); // Page Up
|
|
||||||
PORTD |= (1<<4); // Arrows
|
|
||||||
} else {
|
|
||||||
// Turn on light
|
|
||||||
PORTD &= ~(1<<6); // Esc
|
|
||||||
PORTB &= ~(1<<7); // Page Up
|
|
||||||
PORTD &= ~(1<<4); // Arrows
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void led_init_ports() {
|
void led_init_ports() {
|
||||||
// Set our LED pins as output
|
// Set our LED pins as output
|
||||||
palSetPadMode(GPIOB, 13, PAL_MODE_OUTPUT_PUSHPULL); // LED1
|
palSetPadMode(GPIOB, 13, PAL_MODE_OUTPUT_PUSHPULL); // LED1
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ MCU = STM32F303
|
|||||||
# Build Options
|
# Build Options
|
||||||
# comment out to disable the options.
|
# comment out to disable the options.
|
||||||
#
|
#
|
||||||
BACKLIGHT_ENABLE = yes
|
|
||||||
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration
|
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration
|
||||||
MOUSEKEY_ENABLE = yes # Mouse keys
|
MOUSEKEY_ENABLE = yes # Mouse keys
|
||||||
EXTRAKEY_ENABLE = yes # Audio control and System control
|
EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||||
@@ -12,7 +11,8 @@ CONSOLE_ENABLE = yes # Console for debug
|
|||||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||||
NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
|
NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
|
||||||
AUDIO_ENABLE = no
|
AUDIO_ENABLE = no
|
||||||
RGBLIGHT_ENABLE = no # Enable keyboard underlight functionality
|
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
|
||||||
|
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
|
||||||
MIDI_ENABLE = no # MIDI controls
|
MIDI_ENABLE = no # MIDI controls
|
||||||
UNICODE_ENABLE = no # Unicode
|
UNICODE_ENABLE = no # Unicode
|
||||||
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
|
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
|
||||||
|
|||||||
Executable → Regular
File mode changed.
@@ -63,10 +63,13 @@ void pointing_device_task(void){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void led_init(void) {
|
void led_init(void) {
|
||||||
DDRD |= (1<<1);
|
setPinOutput(D1);
|
||||||
PORTD |= (1<<1);
|
setPinOutput(F5);
|
||||||
DDRF |= (1<<4) | (1<<5);
|
setPinOutput(F6);
|
||||||
PORTF |= (1<<4) | (1<<5);
|
|
||||||
|
writePinHigh(D1);
|
||||||
|
writePinHigh(F5);
|
||||||
|
writePinHigh(F6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,16 @@
|
|||||||
#include "pointing_device.h"
|
#include "pointing_device.h"
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
|
|
||||||
#define red_led_off() PORTF |= (1<<6)
|
#define red_led_off() writePinHigh(F6)
|
||||||
#define red_led_on() PORTF &= ~(1<<6)
|
#define red_led_on() writePinLow(F6)
|
||||||
#define blu_led_off() PORTF |= (1<<5)
|
#define blu_led_off() writePinHigh(F5)
|
||||||
#define blu_led_on() PORTF &= ~(1<<5)
|
#define blu_led_on() writePinLow(F5)
|
||||||
#define grn_led_off() PORTD |= (1<<1)
|
#define grn_led_off() writePinHigh(D1)
|
||||||
#define grn_led_on() PORTD &= ~(1<<1)
|
#define grn_led_on() writePinLow(D1)
|
||||||
|
|
||||||
|
#define red_led(flag) if (flag) red_led_on(); else red_led_off()
|
||||||
|
#define blu_led(flag) if (flag) blu_led_on(); else blu_led_off()
|
||||||
|
#define grn_led(flag) if (flag) grn_led_on(); else grn_led_off()
|
||||||
|
|
||||||
#define set_led_off() red_led_off(); grn_led_off(); blu_led_off()
|
#define set_led_off() red_led_off(); grn_led_off(); blu_led_off()
|
||||||
#define set_led_red() red_led_on(); grn_led_off(); blu_led_off()
|
#define set_led_red() red_led_on(); grn_led_off(); blu_led_off()
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define TAPPING_TERM 200
|
||||||
|
#define TAPPING_TOGGLE 2
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
/*
|
||||||
|
* 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 QMK_KEYBOARD_H
|
||||||
|
|
||||||
|
enum layer_names {
|
||||||
|
_QWERTY,
|
||||||
|
_LOWER,
|
||||||
|
_RAISE,
|
||||||
|
_MOUSE,
|
||||||
|
_ADJUST
|
||||||
|
};
|
||||||
|
|
||||||
|
enum dichotomy_keycodes {
|
||||||
|
MS_BTN1 = SAFE_RANGE,
|
||||||
|
MS_BTN2,
|
||||||
|
MS_BTN3
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
|
|
||||||
|
[_QWERTY] = LAYOUT( /* Base layout, nearly qwerty but with modifications because it's not a full keyboard. Obviously. */
|
||||||
|
KC_ESCAPE, 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_H, KC_J, KC_K, KC_L, KC_SCLN, KC_ENT,
|
||||||
|
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, TT(_MOUSE),
|
||||||
|
KC_LGUI, KC_LALT, KC_DEL, KC_RCTL, KC_RALT, KC_RGUI,
|
||||||
|
MS_BTN3, SFT_T(KC_ESCAPE), KC_LCTL, KC_SPC, KC_SPC, TT(_RAISE), TT(_LOWER), MS_BTN3
|
||||||
|
),
|
||||||
|
|
||||||
|
[_RAISE] = LAYOUT( /* Shifted layout, small changes (because angle brackets have been moved to thumb cluster buttons) */
|
||||||
|
_______, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______,
|
||||||
|
_______, _______, KC_VOLD, KC_VOLU, KC_MPLY, KC_MNXT, KC_MUTE, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, _______,
|
||||||
|
_______, _______, KC_GRV, _______, _______, KC_MPRV, _______, KC_LABK, KC_RABK, KC_BSLS, KC_QUOT, _______,
|
||||||
|
_______, _______, _______, _______, _______, _______,
|
||||||
|
_______, _______, _______, _______, _______, _______, _______, _______
|
||||||
|
),
|
||||||
|
|
||||||
|
[_LOWER] = LAYOUT( /* Number layout, basically the main function layer */
|
||||||
|
_______, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______,
|
||||||
|
_______, _______, KC_VOLD, KC_VOLU, KC_MPLY, KC_MNXT, KC_MUTE, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, _______,
|
||||||
|
_______, _______, KC_TILD, _______, _______, KC_MPRV, _______, _______, _______, KC_PIPE, KC_DQT, _______,
|
||||||
|
_______, _______, _______, _______, _______, _______,
|
||||||
|
_______, _______, _______, _______, _______, _______, _______, _______
|
||||||
|
),
|
||||||
|
|
||||||
|
[_ADJUST] = LAYOUT( /* Shifted number/function layout, for per-key control. Only active when shift is held, and number is toggled or held */
|
||||||
|
KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_PSLS, KC_P7, KC_P8, KC_P9, KC_PMNS, _______,
|
||||||
|
KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PAST, KC_P4, KC_P5, KC_P6, KC_PPLS, _______,
|
||||||
|
_______, _______, _______, LGUI(KC_L), KC_PSCR, KC_APP, KC_PCMM, KC_P1, KC_P2, KC_P3, KC_PEQL, _______,
|
||||||
|
_______, _______, _______, _______, KC_P0, KC_PDOT,
|
||||||
|
_______, _______, _______, _______, _______, _______, _______, _______
|
||||||
|
),
|
||||||
|
|
||||||
|
[_MOUSE] = LAYOUT( /* Mouse layer, including buttons for clicking. */
|
||||||
|
_______, _______, _______, _______, _______, _______, KC_VOLU, KC_HOME, KC_WH_U, KC_PGUP, _______, _______,
|
||||||
|
_______, _______, MS_BTN2, MS_BTN3, MS_BTN1, _______, KC_VOLD, MS_BTN1, MS_BTN3, MS_BTN2, _______, _______,
|
||||||
|
_______, _______, _______, _______, _______, _______, KC_HOME, KC_END, KC_WH_D, KC_PGDN, _______, _______,
|
||||||
|
_______, KC_UP, _______, _______, KC_UP, _______,
|
||||||
|
_______, KC_LEFT, KC_DOWN, KC_RGHT, KC_LEFT, KC_DOWN, KC_RGHT, _______
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
layer_state_t layer_state_set_user(layer_state_t state) {
|
||||||
|
red_led(layer_state_cmp(state, _LOWER));
|
||||||
|
grn_led(layer_state_cmp(state, _RAISE));
|
||||||
|
blu_led(layer_state_cmp(state, _MOUSE));
|
||||||
|
return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define SetBitMask(variable, mask, on) if (on) variable |= mask; else variable &= ~mask
|
||||||
|
|
||||||
|
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
|
report_mouse_t currentReport;
|
||||||
|
switch (keycode) {
|
||||||
|
//mouse buttons, for 1-3, to update the mouse report:
|
||||||
|
//MOUSE_BTN1-3 are consts defined in report.h
|
||||||
|
case MS_BTN1:
|
||||||
|
currentReport = pointing_device_get_report();
|
||||||
|
SetBitMask(currentReport.buttons, MOUSE_BTN1, record->event.pressed);
|
||||||
|
pointing_device_set_report(currentReport);
|
||||||
|
return false;
|
||||||
|
case MS_BTN2:
|
||||||
|
currentReport = pointing_device_get_report();
|
||||||
|
SetBitMask(currentReport.buttons, MOUSE_BTN2, record->event.pressed);
|
||||||
|
pointing_device_set_report(currentReport);
|
||||||
|
return false;
|
||||||
|
case MS_BTN3:
|
||||||
|
currentReport = pointing_device_get_report();
|
||||||
|
SetBitMask(currentReport.buttons, MOUSE_BTN3, record->event.pressed);
|
||||||
|
pointing_device_set_report(currentReport);
|
||||||
|
return false;
|
||||||
|
case KC_WH_U:
|
||||||
|
currentReport = pointing_device_get_report();
|
||||||
|
if(record->event.pressed) {
|
||||||
|
currentReport.v += 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
currentReport.v = 0;
|
||||||
|
}
|
||||||
|
pointing_device_set_report(currentReport);
|
||||||
|
return false;
|
||||||
|
case KC_WH_D:
|
||||||
|
currentReport = pointing_device_get_report();
|
||||||
|
if(record->event.pressed) {
|
||||||
|
currentReport.v -= 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
currentReport.v = 0;
|
||||||
|
}
|
||||||
|
pointing_device_set_report(currentReport);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
@@ -92,9 +92,6 @@ uint8_t matrix_cols(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void matrix_init(void) {
|
void matrix_init(void) {
|
||||||
DDRF |= (1<<6);
|
|
||||||
DDRF |= (1<<5);
|
|
||||||
DDRD |= (1<<1);
|
|
||||||
matrix_init_quantum();
|
matrix_init_quantum();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,4 +48,4 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* VIA related config */
|
/* VIA related config */
|
||||||
#define VIA_EEPROM_LAYOUT_OPTIONS_SIZE 2
|
#define VIA_EEPROM_LAYOUT_OPTIONS_SIZE 2
|
||||||
@@ -4,4 +4,4 @@
|
|||||||
# dfu-programmer atmega32u4 reset
|
# dfu-programmer atmega32u4 reset
|
||||||
|
|
||||||
# run this in the qmk_firmware directory
|
# run this in the qmk_firmware directory
|
||||||
make dz60:chrisae9:flash
|
make dz60:chrisae9:flash
|
||||||
@@ -17,10 +17,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||||||
|
|
||||||
LAYOUT(
|
LAYOUT(
|
||||||
KC_GRV, 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_NO, KC_DEL,
|
KC_GRV, 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_NO, KC_DEL,
|
||||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
KC_INS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||||
TG(4), KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
TG(4), KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||||
KC_TRNS, KC_NO, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_RSFT, KC_TRNS,
|
KC_TRNS, KC_NO, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_TRNS,
|
||||||
KC_TRNS, KC_TRNS, KC_TRNS, TG(1), TG(1), TG(1), MO(3), KC_RALT, KC_NO, KC_RGUI, KC_RCTL),
|
KC_TRNS, KC_TRNS, KC_TRNS, TG(1), TG(1), TG(1), MO(3), KC_HOME, KC_NO, KC_PGDN, KC_END),
|
||||||
|
|
||||||
LAYOUT(
|
LAYOUT(
|
||||||
KC_PWR, RESET, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_BRID, KC_BRIU, KC_NO, KC_PSCR,
|
KC_PWR, RESET, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_BRID, KC_BRIU, KC_NO, KC_PSCR,
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ This is a custom keymap for the layout of the DZ60.
|
|||||||
|
|
||||||
## Keyboard Picture
|
## Keyboard Picture
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Keyboard Layout
|
## Keyboard Layout
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,221 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 Duckle
|
||||||
|
|
||||||
|
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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "config_common.h"
|
||||||
|
|
||||||
|
/* USB Device descriptor parameter */
|
||||||
|
#define VENDOR_ID 0x03A8
|
||||||
|
#define PRODUCT_ID 0x0000
|
||||||
|
#define DEVICE_VER 0x0001
|
||||||
|
#define MANUFACTURER keebwerk.
|
||||||
|
#define PRODUCT nano. slider
|
||||||
|
#define DESCRIPTION A small eight key macropad
|
||||||
|
|
||||||
|
/* key matrix size */
|
||||||
|
#define MATRIX_ROWS 2
|
||||||
|
#define MATRIX_COLS 4
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Keyboard Matrix Assignments
|
||||||
|
*/
|
||||||
|
#define MATRIX_ROW_PINS { F0, F1 }
|
||||||
|
#define MATRIX_COL_PINS { B0, B1, B2, B3 }
|
||||||
|
#define UNUSED_PINS
|
||||||
|
|
||||||
|
#define SLIDER_PIN D4
|
||||||
|
|
||||||
|
/* COL2ROW, ROW2COL*/
|
||||||
|
#define DIODE_DIRECTION COL2ROW
|
||||||
|
|
||||||
|
#define BACKLIGHT_PIN B7
|
||||||
|
#define BACKLIGHT_BREATHING
|
||||||
|
#define BACKLIGHT_LEVELS 3
|
||||||
|
|
||||||
|
#define RGB_DI_PIN F6
|
||||||
|
#ifdef RGB_DI_PIN
|
||||||
|
# define RGBLED_NUM 4
|
||||||
|
# define RGBLIGHT_HUE_STEP 8
|
||||||
|
# define RGBLIGHT_SAT_STEP 8
|
||||||
|
# define RGBLIGHT_VAL_STEP 8
|
||||||
|
# define RGBLIGHT_LIMIT_VAL 255 /* The maximum brightness level */
|
||||||
|
# define RGBLIGHT_SLEEP /* If defined, the RGB lighting will be switched off when the host goes to sleep */
|
||||||
|
/*== all animations enable ==*/
|
||||||
|
# define RGBLIGHT_ANIMATIONS
|
||||||
|
// /*== or choose animations ==*/
|
||||||
|
// #define RGBLIGHT_EFFECT_BREATHING
|
||||||
|
// #define RGBLIGHT_EFFECT_RAINBOW_MOOD
|
||||||
|
// #define RGBLIGHT_EFFECT_RAINBOW_SWIRL
|
||||||
|
// #define RGBLIGHT_EFFECT_SNAKE
|
||||||
|
// #define RGBLIGHT_EFFECT_KNIGHT
|
||||||
|
// #define RGBLIGHT_EFFECT_CHRISTMAS
|
||||||
|
// #define RGBLIGHT_EFFECT_STATIC_GRADIENT
|
||||||
|
// #define RGBLIGHT_EFFECT_RGB_TEST
|
||||||
|
// #define RGBLIGHT_EFFECT_ALTERNATING
|
||||||
|
// /*== customize breathing effect ==*/
|
||||||
|
// /*==== (DEFAULT) use fixed table instead of exp() and sin() ====*/
|
||||||
|
// #define RGBLIGHT_BREATHE_TABLE_SIZE 256 // 256(default) or 128 or 64
|
||||||
|
// /*==== use exp() and sin() ====*/
|
||||||
|
// #define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 // 1 to 2.7
|
||||||
|
// #define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0 to 255
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
|
||||||
|
#define DEBOUNCE 5
|
||||||
|
|
||||||
|
/* define if matrix has ghost (lacks anti-ghosting diodes) */
|
||||||
|
//#define MATRIX_HAS_GHOST
|
||||||
|
|
||||||
|
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
|
||||||
|
#define LOCKING_SUPPORT_ENABLE
|
||||||
|
/* Locking resynchronize hack */
|
||||||
|
#define LOCKING_RESYNC_ENABLE
|
||||||
|
|
||||||
|
/* If defined, GRAVE_ESC will always act as ESC when CTRL is held.
|
||||||
|
* This is userful for the Windows task manager shortcut (ctrl+shift+esc).
|
||||||
|
*/
|
||||||
|
// #define GRAVE_ESC_CTRL_OVERRIDE
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Magic Key Options
|
||||||
|
*
|
||||||
|
* Magic keys are hotkey commands that allow control over firmware functions of
|
||||||
|
* the keyboard. They are best used in combination with the HID Listen program,
|
||||||
|
* found here: https://www.pjrc.com/teensy/hid_listen.html
|
||||||
|
*
|
||||||
|
* The options below allow the magic key functionality to be changed. This is
|
||||||
|
* useful if your keyboard/keypad is missing keys and you want magic key support.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* key combination for magic key command */
|
||||||
|
/* defined by default; to change, uncomment and set to the combination you want */
|
||||||
|
// #define IS_COMMAND() (get_mods() == MOD_MASK_SHIFT)
|
||||||
|
|
||||||
|
/* control how magic key switches layers */
|
||||||
|
//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true
|
||||||
|
//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS true
|
||||||
|
//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM false
|
||||||
|
|
||||||
|
/* override magic key keymap */
|
||||||
|
//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS
|
||||||
|
//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS
|
||||||
|
//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM
|
||||||
|
//#define MAGIC_KEY_HELP H
|
||||||
|
//#define MAGIC_KEY_HELP_ALT SLASH
|
||||||
|
//#define MAGIC_KEY_DEBUG D
|
||||||
|
//#define MAGIC_KEY_DEBUG_MATRIX X
|
||||||
|
//#define MAGIC_KEY_DEBUG_KBD K
|
||||||
|
//#define MAGIC_KEY_DEBUG_MOUSE M
|
||||||
|
//#define MAGIC_KEY_VERSION V
|
||||||
|
//#define MAGIC_KEY_STATUS S
|
||||||
|
//#define MAGIC_KEY_CONSOLE C
|
||||||
|
//#define MAGIC_KEY_LAYER0 0
|
||||||
|
//#define MAGIC_KEY_LAYER0_ALT GRAVE
|
||||||
|
//#define MAGIC_KEY_LAYER1 1
|
||||||
|
//#define MAGIC_KEY_LAYER2 2
|
||||||
|
//#define MAGIC_KEY_LAYER3 3
|
||||||
|
//#define MAGIC_KEY_LAYER4 4
|
||||||
|
//#define MAGIC_KEY_LAYER5 5
|
||||||
|
//#define MAGIC_KEY_LAYER6 6
|
||||||
|
//#define MAGIC_KEY_LAYER7 7
|
||||||
|
//#define MAGIC_KEY_LAYER8 8
|
||||||
|
//#define MAGIC_KEY_LAYER9 9
|
||||||
|
//#define MAGIC_KEY_BOOTLOADER B
|
||||||
|
//#define MAGIC_KEY_BOOTLOADER_ALT ESC
|
||||||
|
//#define MAGIC_KEY_LOCK CAPS
|
||||||
|
//#define MAGIC_KEY_EEPROM E
|
||||||
|
//#define MAGIC_KEY_EEPROM_CLEAR BSPACE
|
||||||
|
//#define MAGIC_KEY_NKRO N
|
||||||
|
//#define MAGIC_KEY_SLEEP_LED Z
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature disable options
|
||||||
|
* These options are also useful to firmware size reduction.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* disable debug print */
|
||||||
|
//#define NO_DEBUG
|
||||||
|
|
||||||
|
/* disable print */
|
||||||
|
//#define NO_PRINT
|
||||||
|
|
||||||
|
/* disable action features */
|
||||||
|
//#define NO_ACTION_LAYER
|
||||||
|
//#define NO_ACTION_TAPPING
|
||||||
|
//#define NO_ACTION_ONESHOT
|
||||||
|
|
||||||
|
/* disable these deprecated features by default */
|
||||||
|
#ifndef LINK_TIME_OPTIMIZATION_ENABLE
|
||||||
|
# define NO_ACTION_MACRO
|
||||||
|
# define NO_ACTION_FUNCTION
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* 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 1
|
||||||
|
|
||||||
|
/*
|
||||||
|
* HD44780 LCD Display Configuration
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
#define LCD_LINES 2 //< number of visible lines of the display
|
||||||
|
#define LCD_DISP_LENGTH 16 //< visibles characters per line of the display
|
||||||
|
|
||||||
|
#define LCD_IO_MODE 1 //< 0: memory mapped mode, 1: IO port mode
|
||||||
|
|
||||||
|
#if LCD_IO_MODE
|
||||||
|
#define LCD_PORT PORTB //< port for the LCD lines
|
||||||
|
#define LCD_DATA0_PORT LCD_PORT //< port for 4bit data bit 0
|
||||||
|
#define LCD_DATA1_PORT LCD_PORT //< port for 4bit data bit 1
|
||||||
|
#define LCD_DATA2_PORT LCD_PORT //< port for 4bit data bit 2
|
||||||
|
#define LCD_DATA3_PORT LCD_PORT //< port for 4bit data bit 3
|
||||||
|
#define LCD_DATA0_PIN 4 //< pin for 4bit data bit 0
|
||||||
|
#define LCD_DATA1_PIN 5 //< pin for 4bit data bit 1
|
||||||
|
#define LCD_DATA2_PIN 6 //< pin for 4bit data bit 2
|
||||||
|
#define LCD_DATA3_PIN 7 //< pin for 4bit data bit 3
|
||||||
|
#define LCD_RS_PORT LCD_PORT //< port for RS line
|
||||||
|
#define LCD_RS_PIN 3 //< pin for RS line
|
||||||
|
#define LCD_RW_PORT LCD_PORT //< port for RW line
|
||||||
|
#define LCD_RW_PIN 2 //< pin for RW line
|
||||||
|
#define LCD_E_PORT LCD_PORT //< port for Enable line
|
||||||
|
#define LCD_E_PIN 1 //< pin for Enable line
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Bootmagic Lite key configuration */
|
||||||
|
// #define BOOTMAGIC_LITE_ROW 0
|
||||||
|
// #define BOOTMAGIC_LITE_COLUMN 0
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"keyboard_name": "nano. slider",
|
||||||
|
"url": "",
|
||||||
|
"maintainer": "qmk",
|
||||||
|
"width": 4,
|
||||||
|
"height": 3.25,
|
||||||
|
"layouts": {
|
||||||
|
"LAYOUT": {
|
||||||
|
"layout": [
|
||||||
|
{"x":0, "y":0},
|
||||||
|
{"x":0, "y":1.25},
|
||||||
|
{"x":1, "y":1.25},
|
||||||
|
{"x":2, "y":1.25},
|
||||||
|
{"x":0, "y":2.25},
|
||||||
|
{"x":1, "y":2.25},
|
||||||
|
{"x":2, "y":2.25},
|
||||||
|
{"x":3, "y":1.25, "h":2}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
/* Copyright 2020 Duckle
|
||||||
|
*
|
||||||
|
* 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 QMK_KEYBOARD_H
|
||||||
|
#include "analog.h"
|
||||||
|
#include "qmk_midi.h"
|
||||||
|
|
||||||
|
// Defines names for use in layer keycodes and the keymap
|
||||||
|
enum layer_names {
|
||||||
|
_BASE,
|
||||||
|
_FN,
|
||||||
|
_DEMO
|
||||||
|
};
|
||||||
|
|
||||||
|
// Defines the keycodes used by our macros in process_record_user
|
||||||
|
enum custom_keycodes {
|
||||||
|
QMKBEST = SAFE_RANGE,
|
||||||
|
QMKURL
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
|
/* Base */
|
||||||
|
[_BASE] = LAYOUT(
|
||||||
|
TO(_FN),
|
||||||
|
KC_1, KC_2, KC_3,
|
||||||
|
KC_4, KC_5, KC_6, KC_0
|
||||||
|
),
|
||||||
|
[_FN] = LAYOUT(
|
||||||
|
TO(_DEMO),
|
||||||
|
RGB_TOG, RGB_MOD, RGB_VAI,
|
||||||
|
_______, _______, _______, _______
|
||||||
|
),
|
||||||
|
[_DEMO] = LAYOUT(
|
||||||
|
TO(_BASE),
|
||||||
|
QMKBEST, _______, _______,
|
||||||
|
_______, _______, _______, QMKURL
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
|
switch (keycode) {
|
||||||
|
case QMKBEST:
|
||||||
|
if (record->event.pressed) {
|
||||||
|
// when keycode QMKBEST is pressed
|
||||||
|
SEND_STRING("QMK is the best thing ever!");
|
||||||
|
} else {
|
||||||
|
// when keycode QMKBEST is released
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case QMKURL:
|
||||||
|
if (record->event.pressed) {
|
||||||
|
// when keycode QMKURL is pressed
|
||||||
|
SEND_STRING("https://qmk.fm/\n");
|
||||||
|
} else {
|
||||||
|
// when keycode QMKURL is released
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t divisor = 0;
|
||||||
|
|
||||||
|
void slider(void) {
|
||||||
|
if (divisor++) { // only run the slider function 1/256 times it's called
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
midi_send_cc(&midi_device, 2, 0x3E, 0x7F - (analogReadPin(SLIDER_PIN) >> 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
void matrix_scan_user(void) {
|
||||||
|
slider();
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
# The default keymap for nano_slider
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
/* Copyright 2020 Duckle
|
||||||
|
*
|
||||||
|
* 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 "nano_slider.h"
|
||||||
|
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
/* Copyright 2020 Duckle
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "quantum.h"
|
||||||
|
|
||||||
|
/* This is a shortcut to help you visually see your layout.
|
||||||
|
*
|
||||||
|
* The first section contains all of the arguments representing the physical
|
||||||
|
* layout of the board and position of the keys.
|
||||||
|
*
|
||||||
|
* The second converts the arguments into a two-dimensional array which
|
||||||
|
* represents the switch matrix.
|
||||||
|
*/
|
||||||
|
#define LAYOUT( \
|
||||||
|
K11, \
|
||||||
|
K12, K10, K00, \
|
||||||
|
K01, K02, K03, K13 \
|
||||||
|
) { \
|
||||||
|
{ K00, K01, K02, K03 }, \
|
||||||
|
{ K10, K11, K12, K13 } \
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
# nano. slider
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
A small eight key macropad with slider.
|
||||||
|
|
||||||
|
* Keyboard Maintainer: [Duckle29](https://github.com/Duckle29)
|
||||||
|
* Hardware Supported: nano. slider PCB, ATmega32U4
|
||||||
|
* Hardware Availability: [keebwerk.](https://www.keebwerk.com/product/nano-slider-keyboard/)
|
||||||
|
|
||||||
|
Make example for this keyboard (after setting up your build environment):
|
||||||
|
|
||||||
|
make keebwerk/nano_slider:default
|
||||||
|
|
||||||
|
See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# MCU name
|
||||||
|
MCU = atmega32u4
|
||||||
|
|
||||||
|
# Bootloader selection
|
||||||
|
# Teensy halfkay
|
||||||
|
# Pro Micro caterina
|
||||||
|
# Atmel DFU atmel-dfu
|
||||||
|
# LUFA DFU lufa-dfu
|
||||||
|
# QMK DFU qmk-dfu
|
||||||
|
# ATmega32A bootloadHID
|
||||||
|
# ATmega328P USBasp
|
||||||
|
BOOTLOADER = atmel-dfu
|
||||||
|
|
||||||
|
# Build Options
|
||||||
|
BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration
|
||||||
|
MOUSEKEY_ENABLE = yes # Mouse keys
|
||||||
|
EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||||
|
CONSOLE_ENABLE = no # Console for debug
|
||||||
|
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||||
|
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
|
||||||
|
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
|
||||||
|
# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
|
||||||
|
NKRO_ENABLE = yes # USB Nkey Rollover
|
||||||
|
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
|
||||||
|
RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow
|
||||||
|
MIDI_ENABLE = yes # MIDI support
|
||||||
|
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
|
||||||
|
AUDIO_ENABLE = no # Audio output on port C6
|
||||||
|
LTO_ENABLE = yes
|
||||||
|
|
||||||
|
SRC += analog.c
|
||||||
@@ -3,8 +3,8 @@
|
|||||||
#include "config_common.h"
|
#include "config_common.h"
|
||||||
|
|
||||||
/* USB Device descriptor parameter */
|
/* USB Device descriptor parameter */
|
||||||
#define VENDOR_ID 0xFEED
|
#define VENDOR_ID 0x5742 // WB
|
||||||
#define PRODUCT_ID 0x62AC
|
#define PRODUCT_ID 0x6E75 // NU
|
||||||
#define DEVICE_VER 0x0001
|
#define DEVICE_VER 0x0001
|
||||||
#define MANUFACTURER Walletburner
|
#define MANUFACTURER Walletburner
|
||||||
#define PRODUCT Neuron
|
#define PRODUCT Neuron
|
||||||
@@ -47,4 +47,3 @@
|
|||||||
#define RGBLIGHT_SAT_STEP 8
|
#define RGBLIGHT_SAT_STEP 8
|
||||||
#define RGBLIGHT_VAL_STEP 8
|
#define RGBLIGHT_VAL_STEP 8
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
#include QMK_KEYBOARD_H
|
||||||
|
|
||||||
|
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
|
|
||||||
|
[0] = LAYOUT(
|
||||||
|
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_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_ENT,
|
||||||
|
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, MO(1),
|
||||||
|
KC_LGUI, KC_RALT, KC_SPC, KC_SPC, KC_SPC, KC_RALT, KC_RGUI),
|
||||||
|
|
||||||
|
[1] = LAYOUT(
|
||||||
|
RESET, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||||
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||||
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||||
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
|
||||||
|
|
||||||
|
[2] = LAYOUT(
|
||||||
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||||
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||||
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||||
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
|
||||||
|
|
||||||
|
[3] = LAYOUT(
|
||||||
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||||
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||||
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||||
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS)
|
||||||
|
};
|
||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
VIA_ENABLE = yes
|
||||||
@@ -14,7 +14,7 @@ BOOTLOADER = atmel-dfu
|
|||||||
# Build Options
|
# Build Options
|
||||||
# comment out to disable the options.
|
# comment out to disable the options.
|
||||||
#
|
#
|
||||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration
|
BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration
|
||||||
MOUSEKEY_ENABLE = yes # Mouse keys
|
MOUSEKEY_ENABLE = yes # Mouse keys
|
||||||
EXTRAKEY_ENABLE = yes # Audio control and System control
|
EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||||
CONSOLE_ENABLE = no # Console for debug
|
CONSOLE_ENABLE = no # Console for debug
|
||||||
|
|||||||
@@ -15,14 +15,62 @@ You should have received a copy of the GNU General Public License
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "quantum.h"
|
||||||
#include "backlight.h"
|
#include "backlight.h"
|
||||||
#include "eeconfig.h"
|
#include "eeconfig.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
backlight_config_t backlight_config;
|
backlight_config_t backlight_config;
|
||||||
|
|
||||||
|
#ifdef BACKLIGHT_BREATHING
|
||||||
// TODO: migrate to backlight_config_t
|
// TODO: migrate to backlight_config_t
|
||||||
static uint8_t breathing_period = BREATHING_PERIOD;
|
static uint8_t breathing_period = BREATHING_PERIOD;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BACKLIGHT_CUSTOM_DRIVER
|
||||||
|
# if defined(BACKLIGHT_PINS)
|
||||||
|
static const pin_t backlight_pins[] = BACKLIGHT_PINS;
|
||||||
|
# ifndef BACKLIGHT_LED_COUNT
|
||||||
|
# define BACKLIGHT_LED_COUNT (sizeof(backlight_pins) / sizeof(pin_t))
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# define FOR_EACH_LED(x) \
|
||||||
|
for (uint8_t i = 0; i < BACKLIGHT_LED_COUNT; i++) { \
|
||||||
|
pin_t backlight_pin = backlight_pins[i]; \
|
||||||
|
{ x } \
|
||||||
|
}
|
||||||
|
# else
|
||||||
|
// we support only one backlight pin
|
||||||
|
static const pin_t backlight_pin = BACKLIGHT_PIN;
|
||||||
|
# define FOR_EACH_LED(x) x
|
||||||
|
# endif
|
||||||
|
|
||||||
|
static inline void backlight_on(pin_t backlight_pin) {
|
||||||
|
# if BACKLIGHT_ON_STATE == 0
|
||||||
|
writePinLow(backlight_pin);
|
||||||
|
# else
|
||||||
|
writePinHigh(backlight_pin);
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void backlight_off(pin_t backlight_pin) {
|
||||||
|
# if BACKLIGHT_ON_STATE == 0
|
||||||
|
writePinHigh(backlight_pin);
|
||||||
|
# else
|
||||||
|
writePinLow(backlight_pin);
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void backlight_pins_init(void) {
|
||||||
|
// Setup backlight pin as output and output to off state.
|
||||||
|
FOR_EACH_LED(setPinOutput(backlight_pin); backlight_off(backlight_pin);)
|
||||||
|
}
|
||||||
|
|
||||||
|
void backlight_pins_on(void) { FOR_EACH_LED(backlight_on(backlight_pin);) }
|
||||||
|
|
||||||
|
void backlight_pins_off(void) { FOR_EACH_LED(backlight_off(backlight_pin);) }
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/** \brief Backlight initialization
|
/** \brief Backlight initialization
|
||||||
*
|
*
|
||||||
@@ -205,7 +253,6 @@ void backlight_disable_breathing(void) {
|
|||||||
* FIXME: needs doc
|
* FIXME: needs doc
|
||||||
*/
|
*/
|
||||||
bool is_backlight_breathing(void) { return backlight_config.breathing; }
|
bool is_backlight_breathing(void) { return backlight_config.breathing; }
|
||||||
#endif
|
|
||||||
|
|
||||||
// following are marked as weak purely for backwards compatibility
|
// following are marked as weak purely for backwards compatibility
|
||||||
__attribute__((weak)) void breathing_period_set(uint8_t value) { breathing_period = value ? value : 1; }
|
__attribute__((weak)) void breathing_period_set(uint8_t value) { breathing_period = value ? value : 1; }
|
||||||
@@ -218,6 +265,15 @@ __attribute__((weak)) void breathing_period_inc(void) { breathing_period_set(bre
|
|||||||
|
|
||||||
__attribute__((weak)) void breathing_period_dec(void) { breathing_period_set(breathing_period - 1); }
|
__attribute__((weak)) void breathing_period_dec(void) { breathing_period_set(breathing_period - 1); }
|
||||||
|
|
||||||
|
__attribute__((weak)) void breathing_toggle(void) {
|
||||||
|
if (is_breathing())
|
||||||
|
breathing_disable();
|
||||||
|
else
|
||||||
|
breathing_enable();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// defaults for backlight api
|
// defaults for backlight api
|
||||||
__attribute__((weak)) void backlight_init_ports(void) {}
|
__attribute__((weak)) void backlight_init_ports(void) {}
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
# error "Maximum value of BACKLIGHT_LEVELS is 31"
|
# error "Maximum value of BACKLIGHT_LEVELS is 31"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef BACKLIGHT_ON_STATE
|
||||||
|
# define BACKLIGHT_ON_STATE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef BREATHING_PERIOD
|
#ifndef BREATHING_PERIOD
|
||||||
# define BREATHING_PERIOD 6
|
# define BREATHING_PERIOD 6
|
||||||
#endif
|
#endif
|
||||||
@@ -40,6 +44,10 @@ typedef union {
|
|||||||
};
|
};
|
||||||
} backlight_config_t;
|
} backlight_config_t;
|
||||||
|
|
||||||
|
void backlight_pins_init(void);
|
||||||
|
void backlight_pins_on(void);
|
||||||
|
void backlight_pins_off(void);
|
||||||
|
|
||||||
void backlight_init(void);
|
void backlight_init(void);
|
||||||
void backlight_toggle(void);
|
void backlight_toggle(void);
|
||||||
void backlight_enable(void);
|
void backlight_enable(void);
|
||||||
|
|||||||
@@ -158,13 +158,6 @@ void breathing_self_disable(void) {
|
|||||||
breathing_halt = BREATHING_HALT_ON;
|
breathing_halt = BREATHING_HALT_ON;
|
||||||
}
|
}
|
||||||
|
|
||||||
void breathing_toggle(void) {
|
|
||||||
if (is_breathing())
|
|
||||||
breathing_disable();
|
|
||||||
else
|
|
||||||
breathing_enable();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* To generate breathing curve in python:
|
/* To generate breathing curve in python:
|
||||||
* from math import sin, pi; [int(sin(x/128.0*pi)**4*255) for x in range(128)]
|
* from math import sin, pi; [int(sin(x/128.0*pi)**4*255) for x in range(128)]
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -164,49 +164,7 @@ error("Please set 'BACKLIGHT_DRIVER = custom' within rules.mk")
|
|||||||
error("Please set 'BACKLIGHT_DRIVER = software' within rules.mk")
|
error("Please set 'BACKLIGHT_DRIVER = software' within rules.mk")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef BACKLIGHT_ON_STATE
|
#ifndef BACKLIGHT_PWM_TIMER // pwm through software
|
||||||
# define BACKLIGHT_ON_STATE 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void backlight_on(pin_t backlight_pin) {
|
|
||||||
#if BACKLIGHT_ON_STATE == 1
|
|
||||||
writePinHigh(backlight_pin);
|
|
||||||
#else
|
|
||||||
writePinLow(backlight_pin);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void backlight_off(pin_t backlight_pin) {
|
|
||||||
#if BACKLIGHT_ON_STATE == 1
|
|
||||||
writePinLow(backlight_pin);
|
|
||||||
#else
|
|
||||||
writePinHigh(backlight_pin);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef BACKLIGHT_PWM_TIMER // pwm through software
|
|
||||||
|
|
||||||
// we support multiple backlight pins
|
|
||||||
# ifndef BACKLIGHT_LED_COUNT
|
|
||||||
# define BACKLIGHT_LED_COUNT 1
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# if BACKLIGHT_LED_COUNT == 1
|
|
||||||
# define BACKLIGHT_PIN_INIT \
|
|
||||||
{ BACKLIGHT_PIN }
|
|
||||||
# else
|
|
||||||
# define BACKLIGHT_PIN_INIT BACKLIGHT_PINS
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# define FOR_EACH_LED(x) \
|
|
||||||
for (uint8_t i = 0; i < BACKLIGHT_LED_COUNT; i++) { \
|
|
||||||
pin_t backlight_pin = backlight_pins[i]; \
|
|
||||||
{ x } \
|
|
||||||
}
|
|
||||||
|
|
||||||
static const pin_t backlight_pins[BACKLIGHT_LED_COUNT] = BACKLIGHT_PIN_INIT;
|
|
||||||
|
|
||||||
#else // full hardware PWM
|
|
||||||
|
|
||||||
static inline void enable_pwm(void) {
|
static inline void enable_pwm(void) {
|
||||||
# if BACKLIGHT_ON_STATE == 1
|
# if BACKLIGHT_ON_STATE == 1
|
||||||
@@ -224,10 +182,6 @@ static inline void disable_pwm(void) {
|
|||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// we support only one backlight pin
|
|
||||||
static const pin_t backlight_pin = BACKLIGHT_PIN;
|
|
||||||
# define FOR_EACH_LED(x) x
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef BACKLIGHT_PWM_TIMER
|
#ifdef BACKLIGHT_PWM_TIMER
|
||||||
@@ -246,7 +200,7 @@ static const pin_t backlight_pin = BACKLIGHT_PIN;
|
|||||||
// The LED will then be on for OCRxx/0xFFFF time, adjusted every 244Hz.
|
// The LED will then be on for OCRxx/0xFFFF time, adjusted every 244Hz.
|
||||||
|
|
||||||
// Triggered when the counter reaches the OCRx value
|
// Triggered when the counter reaches the OCRx value
|
||||||
ISR(TIMERx_COMPA_vect) { FOR_EACH_LED(backlight_off(backlight_pin);) }
|
ISR(TIMERx_COMPA_vect) { backlight_pins_off(); }
|
||||||
|
|
||||||
// Triggered when the counter reaches the TOP value
|
// Triggered when the counter reaches the TOP value
|
||||||
// this one triggers at F_CPU/65536 =~ 244 Hz
|
// this one triggers at F_CPU/65536 =~ 244 Hz
|
||||||
@@ -265,7 +219,7 @@ ISR(TIMERx_OVF_vect) {
|
|||||||
// takes many computation cycles).
|
// takes many computation cycles).
|
||||||
// so better not turn them on while the counter TOP is very low.
|
// so better not turn them on while the counter TOP is very low.
|
||||||
if (OCRxx > 256) {
|
if (OCRxx > 256) {
|
||||||
FOR_EACH_LED(backlight_on(backlight_pin);)
|
backlight_pins_on();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,7 +259,7 @@ void backlight_set(uint8_t level) {
|
|||||||
// Turn off PWM control on backlight pin
|
// Turn off PWM control on backlight pin
|
||||||
disable_pwm();
|
disable_pwm();
|
||||||
#endif
|
#endif
|
||||||
FOR_EACH_LED(backlight_off(backlight_pin);)
|
backlight_pins_off();
|
||||||
} else {
|
} else {
|
||||||
#ifdef BACKLIGHT_PWM_TIMER
|
#ifdef BACKLIGHT_PWM_TIMER
|
||||||
if (!OCRxx) {
|
if (!OCRxx) {
|
||||||
@@ -397,13 +351,6 @@ void breathing_self_disable(void) {
|
|||||||
breathing_halt = BREATHING_HALT_ON;
|
breathing_halt = BREATHING_HALT_ON;
|
||||||
}
|
}
|
||||||
|
|
||||||
void breathing_toggle(void) {
|
|
||||||
if (is_breathing())
|
|
||||||
breathing_disable();
|
|
||||||
else
|
|
||||||
breathing_enable();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* To generate breathing curve in python:
|
/* To generate breathing curve in python:
|
||||||
* from math import sin, pi; [int(sin(x/128.0*pi)**4*255) for x in range(128)]
|
* from math import sin, pi; [int(sin(x/128.0*pi)**4*255) for x in range(128)]
|
||||||
*/
|
*/
|
||||||
@@ -438,7 +385,7 @@ ISR(TIMERx_OVF_vect)
|
|||||||
|
|
||||||
void backlight_init_ports(void) {
|
void backlight_init_ports(void) {
|
||||||
// Setup backlight pin as output and output to on state.
|
// Setup backlight pin as output and output to on state.
|
||||||
FOR_EACH_LED(setPinOutput(backlight_pin); backlight_on(backlight_pin);)
|
backlight_pins_init();
|
||||||
|
|
||||||
// I could write a wall of text here to explain... but TL;DW
|
// I could write a wall of text here to explain... but TL;DW
|
||||||
// Go read the ATmega32u4 datasheet.
|
// Go read the ATmega32u4 datasheet.
|
||||||
|
|||||||
@@ -9,47 +9,7 @@
|
|||||||
# error "Backlight breathing is not available for software PWM. Please disable."
|
# error "Backlight breathing is not available for software PWM. Please disable."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef BACKLIGHT_ON_STATE
|
static uint16_t s_duty_pattern = 0;
|
||||||
# define BACKLIGHT_ON_STATE 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef BACKLIGHT_PINS
|
|
||||||
# define BACKLIGHT_PIN_INIT BACKLIGHT_PINS
|
|
||||||
#else
|
|
||||||
# define BACKLIGHT_PIN_INIT \
|
|
||||||
{ BACKLIGHT_PIN }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static uint16_t s_duty_pattern = 0;
|
|
||||||
static const pin_t backlight_pins[] = BACKLIGHT_PIN_INIT;
|
|
||||||
#define BACKLIGHT_LED_COUNT (sizeof(backlight_pins) / sizeof(pin_t))
|
|
||||||
|
|
||||||
#define FOR_EACH_LED(x) \
|
|
||||||
for (uint8_t i = 0; i < BACKLIGHT_LED_COUNT; i++) { \
|
|
||||||
pin_t backlight_pin = backlight_pins[i]; \
|
|
||||||
{ x } \
|
|
||||||
}
|
|
||||||
|
|
||||||
void backlight_on(pin_t backlight_pin) {
|
|
||||||
#if BACKLIGHT_ON_STATE == 0
|
|
||||||
writePinLow(backlight_pin);
|
|
||||||
#else
|
|
||||||
writePinHigh(backlight_pin);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void backlight_off(pin_t backlight_pin) {
|
|
||||||
#if BACKLIGHT_ON_STATE == 0
|
|
||||||
writePinHigh(backlight_pin);
|
|
||||||
#else
|
|
||||||
writePinLow(backlight_pin);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void backlight_init_ports(void) {
|
|
||||||
// Setup backlight pin as output and output to off state.
|
|
||||||
FOR_EACH_LED(setPinOutput(backlight_pin); backlight_off(backlight_pin);)
|
|
||||||
}
|
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
|
||||||
@@ -58,7 +18,7 @@ void backlight_init_ports(void) {
|
|||||||
* We scale the current backlight level to an index within this array. This allows
|
* We scale the current backlight level to an index within this array. This allows
|
||||||
* backlight_task to focus on just switching LEDs on/off, and we can predict the duty pattern
|
* backlight_task to focus on just switching LEDs on/off, and we can predict the duty pattern
|
||||||
*/
|
*/
|
||||||
static uint16_t backlight_duty_table[] = {
|
static const uint16_t backlight_duty_table[] = {
|
||||||
0b0000000000000000,
|
0b0000000000000000,
|
||||||
0b1000000000000000,
|
0b1000000000000000,
|
||||||
0b1000000010000000,
|
0b1000000010000000,
|
||||||
@@ -75,15 +35,17 @@ static uint16_t backlight_duty_table[] = {
|
|||||||
|
|
||||||
static uint8_t scale_backlight(uint8_t v) { return v * (backlight_duty_table_size - 1) / BACKLIGHT_LEVELS; }
|
static uint8_t scale_backlight(uint8_t v) { return v * (backlight_duty_table_size - 1) / BACKLIGHT_LEVELS; }
|
||||||
|
|
||||||
|
void backlight_init_ports(void) { backlight_pins_init(); }
|
||||||
|
|
||||||
|
void backlight_set(uint8_t level) { s_duty_pattern = backlight_duty_table[scale_backlight(level)]; }
|
||||||
|
|
||||||
void backlight_task(void) {
|
void backlight_task(void) {
|
||||||
static uint8_t backlight_tick = 0;
|
static uint8_t backlight_tick = 0;
|
||||||
|
|
||||||
if (s_duty_pattern & ((uint16_t)1 << backlight_tick)) {
|
if (s_duty_pattern & ((uint16_t)1 << backlight_tick)) {
|
||||||
FOR_EACH_LED(backlight_on(backlight_pin);)
|
backlight_pins_on();
|
||||||
} else {
|
} else {
|
||||||
FOR_EACH_LED(backlight_off(backlight_pin);)
|
backlight_pins_off();
|
||||||
}
|
}
|
||||||
backlight_tick = (backlight_tick + 1) % 16;
|
backlight_tick = (backlight_tick + 1) % 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
void backlight_set(uint8_t level) { s_duty_pattern = backlight_duty_table[scale_backlight(level)]; }
|
|
||||||
@@ -45,6 +45,6 @@ stdenv.mkDerivation {
|
|||||||
++ lib.optional arm [ gcc-arm-embedded ]
|
++ lib.optional arm [ gcc-arm-embedded ]
|
||||||
++ lib.optional teensy [ teensy-loader-cli ];
|
++ lib.optional teensy [ teensy-loader-cli ];
|
||||||
|
|
||||||
CFLAGS = lib.optional avr avr_incflags;
|
AVR_CFLAGS = lib.optional avr avr_incflags;
|
||||||
ASFLAGS = lib.optional avr avr_incflags;
|
AVR_ASFLAGS = lib.optional avr avr_incflags;
|
||||||
}
|
}
|
||||||
+3
-1
@@ -21,7 +21,9 @@ COMPILEFLAGS += -fdata-sections
|
|||||||
COMPILEFLAGS += -fpack-struct
|
COMPILEFLAGS += -fpack-struct
|
||||||
COMPILEFLAGS += -fshort-enums
|
COMPILEFLAGS += -fshort-enums
|
||||||
|
|
||||||
CFLAGS += $(COMPILEFLAGS)
|
ASFLAGS += $(AVR_ASFLAGS)
|
||||||
|
|
||||||
|
CFLAGS += $(COMPILEFLAGS) $(AVR_CFLAGS)
|
||||||
CFLAGS += -fno-inline-small-functions
|
CFLAGS += -fno-inline-small-functions
|
||||||
CFLAGS += -fno-strict-aliasing
|
CFLAGS += -fno-strict-aliasing
|
||||||
|
|
||||||
|
|||||||
+27
-12
@@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__)
|
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__)
|
||||||
# define UDRn UDR0
|
# define UDRn UDR0
|
||||||
# define UBRRn UBRR0
|
# define UBRRnL UBRR0L
|
||||||
# define UCSRnA UCSR0A
|
# define UCSRnA UCSR0A
|
||||||
# define UCSRnB UCSR0B
|
# define UCSRnB UCSR0B
|
||||||
# define UCSRnC UCSR0C
|
# define UCSRnC UCSR0C
|
||||||
@@ -44,11 +44,11 @@
|
|||||||
# define UCSZn1 UCSZ01
|
# define UCSZn1 UCSZ01
|
||||||
# define UCSZn0 UCSZ00
|
# define UCSZn0 UCSZ00
|
||||||
# define UDRIEn UDRIE0
|
# define UDRIEn UDRIE0
|
||||||
# define UDRE_vect USART_UDRE_vect
|
# define USARTn_UDRE_vect USART_UDRE_vect
|
||||||
# define RX_vect USART_RX_vect
|
# define USARTn_RX_vect USART_RX_vect
|
||||||
#elif defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega32U2__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__)
|
#elif defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega32U2__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__)
|
||||||
# define UDRn UDR1
|
# define UDRn UDR1
|
||||||
# define UBRRn UBRR1
|
# define UBRRnL UBRR1L
|
||||||
# define UCSRnA UCSR1A
|
# define UCSRnA UCSR1A
|
||||||
# define UCSRnB UCSR1B
|
# define UCSRnB UCSR1B
|
||||||
# define UCSRnC UCSR1C
|
# define UCSRnC UCSR1C
|
||||||
@@ -59,8 +59,23 @@
|
|||||||
# define UCSZn1 UCSZ11
|
# define UCSZn1 UCSZ11
|
||||||
# define UCSZn0 UCSZ10
|
# define UCSZn0 UCSZ10
|
||||||
# define UDRIEn UDRIE1
|
# define UDRIEn UDRIE1
|
||||||
# define UDRE_vect USART1_UDRE_vect
|
# define USARTn_UDRE_vect USART1_UDRE_vect
|
||||||
# define RX_vect USART1_RX_vect
|
# define USARTn_RX_vect USART1_RX_vect
|
||||||
|
#elif defined(__AVR_ATmega32A__)
|
||||||
|
# define UDRn UDR
|
||||||
|
# define UBRRnL UBRRL
|
||||||
|
# define UCSRnA UCSRA
|
||||||
|
# define UCSRnB UCSRB
|
||||||
|
# define UCSRnC UCSRC
|
||||||
|
# define U2Xn U2X
|
||||||
|
# define RXENn RXEN
|
||||||
|
# define TXENn TXEN
|
||||||
|
# define RXCIEn RXCIE
|
||||||
|
# define UCSZn1 UCSZ1
|
||||||
|
# define UCSZn0 UCSZ0
|
||||||
|
# define UDRIEn UDRIE
|
||||||
|
# define USARTn_UDRE_vect USART_UDRE_vect
|
||||||
|
# define USARTn_RX_vect USART_RX_vect
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// These buffers may be any size from 2 to 256 bytes.
|
// These buffers may be any size from 2 to 256 bytes.
|
||||||
@@ -77,7 +92,7 @@ static volatile uint8_t rx_buffer_tail;
|
|||||||
// Initialize the UART
|
// Initialize the UART
|
||||||
void uart_init(uint32_t baud) {
|
void uart_init(uint32_t baud) {
|
||||||
cli();
|
cli();
|
||||||
UBRRn = (F_CPU / 4 / baud - 1) / 2;
|
UBRRnL = (F_CPU / 4 / baud - 1) / 2;
|
||||||
UCSRnA = (1 << U2Xn);
|
UCSRnA = (1 << U2Xn);
|
||||||
UCSRnB = (1 << RXENn) | (1 << TXENn) | (1 << RXCIEn);
|
UCSRnB = (1 << RXENn) | (1 << TXENn) | (1 << RXCIEn);
|
||||||
UCSRnC = (1 << UCSZn1) | (1 << UCSZn0);
|
UCSRnC = (1 << UCSZn1) | (1 << UCSZn0);
|
||||||
@@ -99,7 +114,7 @@ void uart_putchar(uint8_t c) {
|
|||||||
// cli();
|
// cli();
|
||||||
tx_buffer[i] = c;
|
tx_buffer[i] = c;
|
||||||
tx_buffer_head = i;
|
tx_buffer_head = i;
|
||||||
UCSRB = (1 << RXENn) | (1 << TXENn) | (1 << RXCIEn) | (1 << UDRIEn);
|
UCSRnB = (1 << RXENn) | (1 << TXENn) | (1 << RXCIEn) | (1 << UDRIEn);
|
||||||
// sei();
|
// sei();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +144,7 @@ uint8_t uart_available(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Transmit Interrupt
|
// Transmit Interrupt
|
||||||
ISR(UDRE_vect) {
|
ISR(USARTn_UDRE_vect) {
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
|
|
||||||
if (tx_buffer_head == tx_buffer_tail) {
|
if (tx_buffer_head == tx_buffer_tail) {
|
||||||
@@ -138,13 +153,13 @@ ISR(UDRE_vect) {
|
|||||||
} else {
|
} else {
|
||||||
i = tx_buffer_tail + 1;
|
i = tx_buffer_tail + 1;
|
||||||
if (i >= TX_BUFFER_SIZE) i = 0;
|
if (i >= TX_BUFFER_SIZE) i = 0;
|
||||||
UDR0 = tx_buffer[i];
|
UDRn = tx_buffer[i];
|
||||||
tx_buffer_tail = i;
|
tx_buffer_tail = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Receive Interrupt
|
// Receive Interrupt
|
||||||
ISR(RX_vect) {
|
ISR(USARTn_RX_vect) {
|
||||||
uint8_t c, i;
|
uint8_t c, i;
|
||||||
|
|
||||||
c = UDRn;
|
c = UDRn;
|
||||||
|
|||||||
Reference in new issue
Block a user