mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-09-09 19:56:34 +00:00
Compare commits
28 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
daf0cc60bf | ||
![]() |
20a10bd084 | ||
![]() |
3d767e4aab | ||
![]() |
ab83aedfab | ||
![]() |
239f02408e | ||
![]() |
e2dee054d0 | ||
![]() |
e4eeb1eb23 | ||
![]() |
cb468e0307 | ||
![]() |
f1b2d46eaf | ||
![]() |
daa11dc414 | ||
![]() |
7fe03d085c | ||
![]() |
fa47f5fb15 | ||
![]() |
8454fa5e9f | ||
![]() |
9ade35a9fe | ||
![]() |
ebc143297c | ||
![]() |
8847b2abbf | ||
![]() |
a4bdab6837 | ||
![]() |
31afdd81a1 | ||
![]() |
a173eda6d2 | ||
![]() |
b382076ad1 | ||
![]() |
7d2d0c6795 | ||
![]() |
96c9ebc2e4 | ||
![]() |
baebbc0967 | ||
![]() |
edeace279b | ||
![]() |
246d539f29 | ||
![]() |
a65085a893 | ||
![]() |
8ef747accf | ||
![]() |
8b2591c707 |
@@ -115,7 +115,7 @@ ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
|
||||
endif
|
||||
|
||||
RGB_MATRIX_ENABLE ?= no
|
||||
VALID_MATRIX_TYPES := yes IS31FL3731L IS31FL3733L custom
|
||||
VALID_MATRIX_TYPES := yes IS31FL3731 IS31FL3733 custom
|
||||
ifneq ($(strip $(RGB_MATRIX_ENABLE)), no)
|
||||
ifeq ($(filter $(RGB_MATRIX_ENABLE),$(VALID_MATRIX_TYPES)),)
|
||||
$(error RGB_MATRIX_ENABLE="$(RGB_MATRIX_ENABLE)" is not a valid matrix type)
|
||||
|
@@ -36,7 +36,7 @@ Make example for this keyboard (after setting up your build environment):
|
||||
|
||||
make planck/rev4:default
|
||||
|
||||
See [build environment setup](https://docs.qmk.fm/build_environment_setup.html) then the [make instructions](https://docs.qmk.fm/make_instructions.html) for more information.
|
||||
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).
|
||||
```
|
||||
|
||||
There needs to be two spaces at the end of the `Keyboard Maintainer` and `Hardware Supported` lines for it to render correctly with Markdown.
|
||||
|
@@ -5,15 +5,12 @@ If you use more than one keyboard with a similar keymap, you might see the benef
|
||||
* `/users/<name>/` (added to the path automatically)
|
||||
* `readme.md` (optional, recommended)
|
||||
* `rules.mk` (included automatically)
|
||||
* `config.h` (included automatically)
|
||||
* `<name>.h` (optional)
|
||||
* `<name>.c` (optional)
|
||||
* `config.h` (optional)
|
||||
* `cool_rgb_stuff.c` (optional)
|
||||
* `cool_rgb_stuff.h` (optional)
|
||||
|
||||
`<name>.c` will need to be added to the SRC in `rules.mk` like this:
|
||||
|
||||
SRC += <name>.c
|
||||
|
||||
Additional files may be added in the same way - it's recommended you have one named `<name>`.c/.h though.
|
||||
|
||||
All this only happens when you build a keymap named `<name>`, like this:
|
||||
|
||||
@@ -23,82 +20,179 @@ For example,
|
||||
|
||||
make planck:jack
|
||||
|
||||
Will include the `/users/jack/` folder in the path, along with `/users/jack/rules.mk`.
|
||||
Will include the `/users/jack/` folder in the path, along with `/users/jack/rules.mk`.
|
||||
|
||||
!> This `name` can be [overridden](#override-default-userspace), if needed.
|
||||
|
||||
## `Rules.mk`
|
||||
|
||||
The `rules.mk` is one of the two files that gets processed automatically. This is how you add additional source files (such as `<name>.c`) will be added when compiling.
|
||||
|
||||
It's highly recommended that you use `<name>.c` as the default source file to be added. And to add it, you need to add it the SRC in `rules.mk` like this:
|
||||
|
||||
SRC += <name>.c
|
||||
|
||||
Additional files may be added in the same way - it's recommended you have one named `<name>`.c/.h to start off with, though.
|
||||
|
||||
The `/users/<name>/rules.mk` file will be included in the build _after_ the `rules.mk` from your keymap. This allows you to have features in your userspace `rules.mk` that depend on individual QMK features that may or may not be available on a specific keyboard.
|
||||
|
||||
For example, if you have RGB control features shared between all your keyboards that support RGB lighting, you can add support for that if the RGBLIGHT feature is enabled:
|
||||
```make
|
||||
ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
|
||||
# Include my fancy rgb functions source here
|
||||
SRC += cool_rgb_stuff.c
|
||||
endif
|
||||
```
|
||||
|
||||
Alternatively, you can `define RGB_ENABLE` in your keymap's `rules.mk` and then check for the variable in your userspace's `rules.mk` like this:
|
||||
```make
|
||||
ifdef RGB_ENABLE
|
||||
# Include my fancy rgb functions source here
|
||||
SRC += cool_rgb_stuff.c
|
||||
endif
|
||||
```
|
||||
|
||||
### Override default userspace
|
||||
|
||||
By default the userspace used will be the same as the keymap name. In some situations this isn't desirable. For instance, if you use the [layout](feature_layouts.md) feature you can't use the same name for different keymaps (e.g. ANSI and ISO). You can name your layouts `mylayout-ansi` and `mylayout-iso` and add the following line to your layout's `rules.mk`:
|
||||
|
||||
```
|
||||
USER_NAME := mylayout
|
||||
```
|
||||
|
||||
This is also useful if you have multiple different keyboards with different features physically present on the board (such as one with RGB Lights, and one with Audio, or different number of LEDs, or connected to a different PIN on the controller).
|
||||
|
||||
## Configuration Options (`config.h`)
|
||||
|
||||
Additionally, `config.h` here will be processed like the same file in your keymap folder. This is handled separately from the `<name>.h` file.
|
||||
|
||||
The reason for this, is that `<name>.h` won't be added in time to add settings (such as `#define TAPPING_TERM 100`), and including the `<name.h>` file in any `config.h` files will result in compile issues.
|
||||
|
||||
So you should use the `config.h` for QMK settings, and the `<name>.h` file for user or keymap specific settings.
|
||||
!>You should use the `config.h` for [configuration options](config_options.md), and the `<name>.h` file for user or keymap specific settings (such as the enum for layer or keycodes)
|
||||
|
||||
`/users/<name>/rules.mk` will be included in the build _after_ the `rules.mk` from your keymap. This allows you to have features in your userspace `rules.mk` that depend on individual QMK features that may or may not be available on a specific keyboard. For example, if you have RGB control features shared between all your keyboards that support RGB lighting, you can `define RGB_ENABLE` in your keymap `rules.mk` and then check for the variable in your userspace `rules.mk` like this:
|
||||
```make
|
||||
ifdef RGB_ENABLE
|
||||
# Include my fancy rgb functions source here
|
||||
endif
|
||||
```
|
||||
Because of this, any time you turn on QMK features in your `users/<name>/rules.mk`, you should conditionally enable them only if the flag isn't already defined, like this:
|
||||
```make
|
||||
ifndef TAP_DANCE_ENABLE
|
||||
TAP_DANCE_ENABLE = yes
|
||||
endif
|
||||
```
|
||||
This will ensure that you can explicitly turn off features for an individual keymap.
|
||||
|
||||
## Readme
|
||||
## Readme (`readme.md`)
|
||||
|
||||
Please include authorship (your name, github username, email), and optionally [a license that's GPL compatible](https://www.gnu.org/licenses/license-list.html#GPLCompatibleLicenses).
|
||||
|
||||
## `Config.h`
|
||||
You can use this as a template:
|
||||
```
|
||||
Copyright <year> <name> <email> @<github_username>
|
||||
|
||||
If you do add a `config,h` file, you want to make sure that it only gets processed once. So you may want to start off with something like this:
|
||||
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.
|
||||
|
||||
```c
|
||||
#ifndef USERSPACE_CONFIG_H
|
||||
#define USERSPACE_CONFIG_H
|
||||
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.
|
||||
|
||||
// Put normal config.h settings here:
|
||||
|
||||
#endif // !USERSPACE_CONFIG_H
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
```
|
||||
|
||||
You can use any option hre that you could use in your keymap's `config.h` file. You can find a list of vales [here](config_options.md).
|
||||
You'd want to replace the year, name, email and github username with your info.
|
||||
|
||||
## Example
|
||||
Additionally, this is a good place to document your code, if you wish to share it with others.
|
||||
|
||||
For a brief example, checkout `/users/_example/` , or for a more detailed examples check out [`template.h`](https://github.com/qmk/qmk_firmware/blob/master/users/drashna/template.h) and [`template.c`](https://github.com/qmk/qmk_firmware/blob/master/users/drashna/template.c) in `/users/drashna/` .
|
||||
# Examples
|
||||
|
||||
### Consolidated Macros
|
||||
For a brief example, checkout [`/users/_example/`](https://github.com/qmk/qmk_firmware/tree/master/users/drashna).
|
||||
For a more complicated example, checkout [`/users/drashna/`](https://github.com/qmk/qmk_firmware/tree/master/users/drashna)'s userspace.
|
||||
|
||||
If you wanted to consolidate macros and other functions into your userspace for all of your keymaps, you can do that. The issue is that you then cannot call any function defined in your userspace, or it gets complicated. To better handle this, you can call the functions here and create new functions to use in individual keymaps.
|
||||
|
||||
## Customized Functions
|
||||
|
||||
QMK has a bunch of [functions](custom_quantum_functions.md) that have [`_quantum`, `_kb`, and `_user` versions](custom_quantum_functions.md#a-word-on-core-vs-keyboards-vs-keymap) that you can use. You will pretty much always want to use the user version of these functions. But the problem is that if you use them in your userspace, then you don't have a version that you can use in your keymap.
|
||||
|
||||
However, you can actually add support for keymap version, so that you can use it in both your userspace and your keymap!
|
||||
|
||||
|
||||
For instance, lets looks at the `layer_state_set_user` function. Lets enable the [Tri Layer State](ref_functions.md#olkb-tri-layers) functionalitly to all of our boards, and then still have your `keymap.c` still able to use this functionality.
|
||||
|
||||
In your `<name.c>` file, you'd want to add this:
|
||||
```c
|
||||
__attribute__ ((weak))
|
||||
uint32_t layer_state_set_keymap (uint32_t state) {
|
||||
return state;
|
||||
}
|
||||
|
||||
uint32_t layer_state_set_user (uint32_t state) {
|
||||
state = update_tri_layer_state(state, 2, 3, 5);
|
||||
return layer_state_set_keymap (state);
|
||||
}
|
||||
```
|
||||
The `__attribute__ ((weak))` part tells the compiler that this is a placeholder function that can then be replaced by a version in your `keymap.c`. That way, you don't need to add it to your `keymap.c`, but if you do, you won't get any conflicts because the function is the same name.
|
||||
|
||||
The `_keymap` part here doesn't matter, it just needs to be something other than `_quantum`, `_kb`, or `_user`, since those are already in use. So you could use `layer_state_set_mine`, `layer_state_set_fn`, or anything else.
|
||||
|
||||
You can see a list of this and other common functions in [`template.c`](https://github.com/qmk/qmk_firmware/blob/master/users/drashna/template.c) in [`users/drashna`](https://github.com/qmk/qmk_firmware/tree/master/users/drashna).
|
||||
|
||||
## Custom Features
|
||||
|
||||
Since the Userspace feature can support a staggering number of boards, you may have boards that you want to enable certain functionality for, but not for others. And you can actually create "features" that you can enable or disable in your own userspace.
|
||||
|
||||
For instance, if you wanted to have a bunch of macros available, but only on certain boards (to save space), you could "hide" them being a `#ifdef MACROS_ENABLED`, and then enable it per board. To do this, add this to your rules.mk
|
||||
```make
|
||||
ifeq ($(strip $(MACROS_ENABLED)), yes)
|
||||
OPT_DEFS += -DMACROS_ENABLED
|
||||
endif
|
||||
```
|
||||
The `OPT_DEFS` setting causes `MACROS_ENABLED` to be defined for your keyboards (note the `-D` in front of the name), and you could use `#ifdef MACROS_ENABLED` to check the status in your c/h files, and handle that code based on that.
|
||||
|
||||
Then you add `MACROS_ENABLED = yes` to the `rules.mk` for you keymap to enable this feature and the code in your userspace.
|
||||
|
||||
And in your `process_record_user` function, you'd do something like this:
|
||||
```c
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
switch (keycode) {
|
||||
#ifdef MACROS_ENABLED
|
||||
case MACRO1:
|
||||
if (!record->event.pressed) {
|
||||
SEND_STRING("This is macro 1!");
|
||||
}
|
||||
break;
|
||||
case MACRO2:
|
||||
if (!record->event.pressed) {
|
||||
SEND_STRING("This is macro 2!");
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Consolidated Macros
|
||||
|
||||
If you wanted to consolidate macros and other functions into your userspace for all of your keymaps, you can do that. This builds upon the [Customized Functions](#customized-functions) example above. This lets you maintain a bunch of macros that are shared between the different keyboards, and allow for keyboard specific macros, too.
|
||||
|
||||
First, you'd want to go through all of your `keymap.c` files and replace `process_record_user` with `process_record_keymap` instead. This way, you can still use keyboard specific codes on those boards, and use your custom "global" keycodes as well. You'll also want to replace `SAFE_RANGE` with `NEW_SAFE_RANGE` so that you wont have any overlapping keycodes
|
||||
|
||||
Then add `#include <name.h>` to all of your keymap.c files. This allows you to use these new keycodes without having to redefine them in each keymap.
|
||||
|
||||
Once you've done that, you'll want to set the keycode definitions that you need to the `<name>.h` file. For instance:
|
||||
```
|
||||
#ifndef USERSPACE
|
||||
#define USERSPACE
|
||||
```c
|
||||
#pragma once
|
||||
|
||||
#include "quantum.h"
|
||||
#include "action.h"
|
||||
#include "version.h"
|
||||
|
||||
// Define all of
|
||||
enum custom_keycodes {
|
||||
KC_MAKE = SAFE_RANGE,
|
||||
NEW_SAFE_RANGE //use "NEW_SAFE_RANGE" for keymap specific codes
|
||||
};
|
||||
|
||||
#endif
|
||||
```
|
||||
|
||||
Now you want to create the `<name>.c` file, and add this content to it:
|
||||
|
||||
```
|
||||
```c
|
||||
#include "<name>.h"
|
||||
#include "quantum.h"
|
||||
#include "action.h"
|
||||
#include "version.h"
|
||||
|
||||
__attribute__ ((weak))
|
||||
bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
|
||||
@@ -126,14 +220,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
}
|
||||
```
|
||||
|
||||
This will add a new `KC_MAKE` keycode that can be used in any of your keymaps. And this keycode will output `make <keyboard>:<keymap">`, making frequent compiling easier. And this will work with any keyboard and any keymap as it will output the current boards info, so that you don't have to type this out every time.
|
||||
This will add a new `KC_MAKE` keycode that can be used in any of your keymaps. And this keycode will output `make <keyboard>:<keymap>`, making frequent compiling easier. And this will work with any keyboard and any keymap as it will output the current boards info, so that you don't have to type this out every time.
|
||||
|
||||
Additionally, this should flash the newly compiled firmware automatically, using the correct utility, based on the bootloader settings (or default to just generating the HEX file). However, it should be noted that this may not work on all systems. AVRDUDE doesn't work on WSL, namely (and will dump the HEX in the ".build" folder instead).
|
||||
|
||||
## Override default userspace
|
||||
|
||||
By default the userspace used will be the same as the keymap name. In some situations this isn't desirable. For instance, if you use the [layout](feature_layouts.md) feature you can't use the same name for different keymaps (e.g. ANSI and ISO). You can name your layouts `mylayout-ansi` and `mylayout-iso` and add the following line to your layout's `rules.mk`:
|
||||
|
||||
```
|
||||
USER_NAME := mylayout
|
||||
```
|
||||
|
@@ -78,6 +78,12 @@ or
|
||||
|
||||
make <keyboard>:<keymap>:avrdude
|
||||
|
||||
or if you want to flash multiple boards, use the following command
|
||||
|
||||
make <keyboard>:<keymap>:avrdude-loop
|
||||
|
||||
When you're done flashing boards, you'll need to hit Ctrl + C or whatever the correct keystroke is for your operating system to break the loop.
|
||||
|
||||
## Halfkay
|
||||
|
||||
Halfkay is a super-slim protocol developed by PJRC that uses HID, and come on all Teensys (namely the 2.0).
|
||||
|
23
docs/internals_gpio_control.md
Normal file
23
docs/internals_gpio_control.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# GPIO Control
|
||||
|
||||
QMK has a GPIO control abstraction layer which is micro-controller agnostic. This is done to allow easy access to pin control across different platforms.
|
||||
|
||||
## Functions
|
||||
|
||||
The following functions can provide basic control of GPIOs and are found in `quantum/quantum.h`.
|
||||
|
||||
|Function |Description |
|
||||
|----------------------|------------------------------------------------------------------|
|
||||
|`setPinInput(pin)` |Set pin as input with high impedance (High-Z) |
|
||||
|`setPinInputHigh(pin)`|Set pin as input with build in pull-up |
|
||||
|`setPinInputLow(pin)` |Set pin as input with build in pull-down (Supported only on STM32)|
|
||||
|`setPinOutput(pin)` |Set pin as output |
|
||||
|`writePinHige(pin)` |Set pin level as high, assuming it is an output |
|
||||
|`writePinLow(pin)` |Set pin level as low, assuming it is an output |
|
||||
|`writePin(pin, level)`|Set pin level, assuming it is an output |
|
||||
|`readPin(pin)` |Returns the level of the pin |
|
||||
|
||||
## Advance settings
|
||||
|
||||
Each micro-controller can have multiple advance settings regarding its GPIO. This abstraction layer does not limit the use of architecture specific functions. Advance users should consult the datasheet of there desired device and include any needed libraries. For AVR the standard avr/io.h library is used and for STM32 the Chibios [PAL library](http://chibios.sourceforge.net/docs3/hal/group___p_a_l.html) is used.
|
||||
|
@@ -1,13 +1,15 @@
|
||||
#ifndef CONFIG_BLE_H
|
||||
#define CONFIG_BLE_H
|
||||
#pragma once
|
||||
|
||||
#undef PRODUCT
|
||||
#define PRODUCT QMK BLE Adapter
|
||||
#undef DESCRIPTION
|
||||
#define DESCRIPTION
|
||||
#define DESCRIPTION
|
||||
|
||||
// Turn off the mode leds on the BLE module
|
||||
#define ADAFRUIT_BLE_ENABLE_MODE_LEDS 0
|
||||
#define ADAFRUIT_BLE_ENABLE_POWER_LED 0
|
||||
|
||||
#endif
|
||||
#define NO_ACTION_MACRO
|
||||
#define NO_ACTION_FUNCTION
|
||||
#define NO_ACTION_ONESHOT
|
||||
|
||||
|
@@ -1,3 +1,23 @@
|
||||
BLUETOOTH = AdafruitBLE
|
||||
ADAFRUIT_BLE_ENABLE = yes
|
||||
F_CPU = 8000000
|
||||
|
||||
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
|
||||
MOUSEKEY_ENABLE = no # Mouse keys(+4700)
|
||||
EXTRAKEY_ENABLE = no # Audio control and System control(+450)
|
||||
CONSOLE_ENABLE = no # Console for debug(+400)
|
||||
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 = no # USB Nkey Rollover
|
||||
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality on B7 by default
|
||||
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
|
||||
MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config)
|
||||
UNICODE_ENABLE = no # Unicode
|
||||
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
|
||||
AUDIO_ENABLE = no # Audio output on port C6
|
||||
FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches
|
||||
HD44780_ENABLE = no # Enable support for HD44780 based LCDs (+400)
|
||||
|
||||
EXTRAFLAGS += -flto
|
||||
|
@@ -1,288 +0,0 @@
|
||||
/*
|
||||
Copyright 2017 Balz Guenat <balz.guenat@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 "keymap_common.h"
|
||||
|
||||
|
||||
const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
|
||||
/* 0: plain Qwerty without layer switching
|
||||
* ,---------------. ,---------------. ,---------------.
|
||||
* |F13|F14|F15|F16| |F17|F18|F19|F20| |F21|F22|F23|F24|
|
||||
* ,---. |---------------| |---------------| |---------------| ,-----------. ,---------------. ,-------.
|
||||
* |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |VDn|VUp|Mut|Pwr| | Help |
|
||||
* `---' `---------------' `---------------' `---------------' `-----------' `---------------' `-------'
|
||||
* ,-----------------------------------------------------------. ,-----------. ,---------------. ,-------.
|
||||
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|JPY|Bsp| |Ins|Hom|PgU| |NmL| /| *| -| |Stp|Agn|
|
||||
* |-----------------------------------------------------------| |-----------| |---------------| |-------|
|
||||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ | |Del|End|PgD| | 7| 8| 9| +| |Mnu|Und|
|
||||
* |-----------------------------------------------------------| `-----------' |---------------| |-------|
|
||||
* |CapsL | A| S| D| F| G| H| J| K| L| ;| :| #|Retn| | 4| 5| 6|KP,| |Sel|Cpy|
|
||||
* |-----------------------------------------------------------| ,---. |---------------| |-------|
|
||||
* |Shft| <| Z| X| C| V| B| N| M| ,| ,| /| RO|Shift | |Up | | 1| 2| 3|KP=| |Exe|Pst|
|
||||
* |-----------------------------------------------------------| ,-----------. |---------------| |-------|
|
||||
* |Ctl|Gui|Alt|MHEN|HNJ| Space |H/E|HENK|KANA|Alt|Gui|App|Ctl| |Lef|Dow|Rig| | 0 | .|Ent| |Fnd|Cut|
|
||||
* `-----------------------------------------------------------' `-----------' `---------------' `-------'
|
||||
*/
|
||||
// KEYMAP_ALL(
|
||||
// F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24,
|
||||
// ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, VOLD,VOLU,MUTE,PWR, HELP,
|
||||
// GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, STOP,AGIN,
|
||||
// TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, BSLS, DEL, END, PGDN, P7, P8, P9, PPLS, MENU,UNDO,
|
||||
// CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, NUHS,ENT, P4, P5, P6, PCMM, SLCT,COPY,
|
||||
// LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RO, RSFT, UP, P1, P2, P3, PEQL, EXEC,PSTE,
|
||||
// LCTL,LGUI,LALT,MHEN,HANJ, SPC, HAEN,HENK,KANA,RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT, FIND,CUT
|
||||
// ),
|
||||
KEYMAP_ALL(
|
||||
F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24,
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, VOLD,VOLU,MUTE,PWR, HELP,
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, STOP,AGIN,
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, BSLS, DEL, END, PGDN, P7, P8, P9, PPLS, MENU,UNDO,
|
||||
FN0, A, S, D, F, G, H, J, K, L, SCLN,QUOT, NUHS,ENT, P4, P5, P6, PCMM, SLCT,COPY,
|
||||
LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RO, RSFT, UP, P1, P2, P3, PEQL, EXEC,PSTE,
|
||||
LCTL,LGUI,LALT,MHEN,HANJ, SPC, HAEN,HENK,KANA,RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT, FIND,CUT
|
||||
),
|
||||
KEYMAP_ALL(
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
|
||||
TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,
|
||||
GRV, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,
|
||||
CAPS,MPRV,VOLU,MNXT,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,
|
||||
TRNS,MUTE,VOLD,MPLY,TRNS,TRNS,LEFT,DOWN,UP, RGHT,TRNS,TRNS, TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS, TRNS,TRNS, TRNS,TRNS
|
||||
),
|
||||
};
|
||||
|
||||
// const action_t fn_actions[] PROGMEM = {};
|
||||
|
||||
const action_t PROGMEM fn_actions[] = {
|
||||
[0] = ACTION_LAYER_MOMENTARY(1),
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Keymap samples
|
||||
*/
|
||||
#if 0
|
||||
/* ANSI layout
|
||||
* ,---. ,---------------. ,---------------. ,---------------. ,-----------.
|
||||
* |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
|
||||
* `---' `---------------' `---------------' `---------------' `-----------'
|
||||
* ,-----------------------------------------------------------. ,-----------. ,---------------.
|
||||
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| Bsp| |Ins|Hom|PgU| |NmL| /| *| -|
|
||||
* |-----------------------------------------------------------| |-----------| |---------------|
|
||||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ | |Del|End|PgD| | 7| 8| 9| +|
|
||||
* |-----------------------------------------------------------| `-----------' |-----------| |
|
||||
* |CapsL | A| S| D| F| G| H| J| K| L| ;| '| Return| | 4| 5| 6| |
|
||||
* |-----------------------------------------------------------| ,---. |---------------|
|
||||
* |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| |
|
||||
* |-----------------------------------------------------------| ,-----------. |-----------| |
|
||||
* |Ctl|Gui|Alt| Space |Alt|Gui|App|Ctl| |Lef|Dow|Rig| | 0| .|Ent|
|
||||
* `-----------------------------------------------------------' `-----------' `---------------'
|
||||
*/
|
||||
KEYMAP(
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK,
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS,
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9,
|
||||
LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS,
|
||||
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3,
|
||||
LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT
|
||||
),
|
||||
|
||||
/* ISO layout
|
||||
* ,---. ,---------------. ,---------------. ,---------------. ,-----------.
|
||||
* |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
|
||||
* `---' `---------------' `---------------' `---------------' `-----------'
|
||||
* ,-----------------------------------------------------------. ,-----------. ,---------------.
|
||||
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| ^| Bsp| |Ins|Hom|PgU| |NmL| /| *| -|
|
||||
* |-----------------------------------------------------------| |-----------| |---------------|
|
||||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| Retn| |Del|End|PgD| | 7| 8| 9| +|
|
||||
* |------------------------------------------------------` | `-----------' |-----------| |
|
||||
* |CapsL | A| S| D| F| G| H| J| K| L| ;| '| #| | | 4| 5| 6| |
|
||||
* |-----------------------------------------------------------| ,---. |---------------|
|
||||
* |Shft|\ | Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3|Ent|
|
||||
* |-----------------------------------------------------------| ,-----------. |-----------| |
|
||||
* |Ctl|Gui|Alt| Space |HNK|KNA|Alt|Gui|App|Ctl| |Lef|Dow|Rig| | 0| .| |
|
||||
* `-----------------------------------------------------------' `-----------' `---------------'
|
||||
*/
|
||||
KEYMAP_ISO(
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK,
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS,
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,ENT, DEL, END, PGDN, P7, P8, P9, PPLS,
|
||||
LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,NUHS, P4, P5, P6,
|
||||
LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, PENT,
|
||||
LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT
|
||||
),
|
||||
|
||||
/* JIS layout
|
||||
* ,---. ,---------------. ,---------------. ,---------------. ,-----------.
|
||||
* |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
|
||||
* `---' `---------------' `---------------' `---------------' `-----------'
|
||||
* ,-----------------------------------------------------------. ,-----------. ,---------------.
|
||||
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| ^|JPY|Bsp| |Ins|Hom|PgU| |NmL| /| *| -|
|
||||
* |-----------------------------------------------------------| |-----------| |---------------|
|
||||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| @| [| Retn| |Del|End|PgD| | 7| 8| 9| +|
|
||||
* |------------------------------------------------------` | `-----------' |-----------| |
|
||||
* |CapsL | A| S| D| F| G| H| J| K| L| ;| :| ]| | | 4| 5| 6| |
|
||||
* |-----------------------------------------------------------| ,---. |---------------|
|
||||
* |Shft | Z| X| C| V| B| N| M| ,| ,| /| RO|Shift | |Up | | 1| 2| 3|Ent|
|
||||
* |-----------------------------------------------------------| ,-----------. |-----------| |
|
||||
* |Ctl|Gui|Alt|MHEN| Space |HENK|KNA|Alt|Gui|App|Ctl| |Lef|Dow|Rig| | 0| .| |
|
||||
* `-----------------------------------------------------------' `-----------' `---------------'
|
||||
*/
|
||||
KEYMAP_JIS(
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK,
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JPY, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS,
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, ENT, DEL, END, PGDN, P7, P8, P9, PPLS,
|
||||
LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,NUHS, P4, P5, P6,
|
||||
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RO, RSFT, UP, P1, P2, P3, PENT,
|
||||
LCTL,LGUI,LALT,MHEN, SPC, HENK,KANA,RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT
|
||||
),
|
||||
|
||||
/* Colemak http://colemak.com
|
||||
* ,-----------------------------------------------------------.
|
||||
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Tab | Q| W| F| P| G| J| L| U| Y| ;| [| ]| \|
|
||||
* |-----------------------------------------------------------|
|
||||
* |BackSp| A| R| S| T| D| H| N| E| I| O| '|Return |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Shift | Z| X| C| V| B| K| M| ,| ,| /|Shift |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl|
|
||||
* `----------------------------------------------------------'
|
||||
*/
|
||||
KEYMAP_ALL(
|
||||
F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24,
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, VOLD,VOLU,MUTE,PWR, HELP,
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, STOP,AGIN,
|
||||
TAB, Q, W, F, P, G, J, L, U, Y, SCLN,LBRC,RBRC, BSLS, DEL, END, PGDN, P7, P8, P9, PPLS, MENU,UNDO,
|
||||
BSPC,A, R, S, T, D, H, N, E, I, O, QUOT, NUHS,ENT, P4, P5, P6, PCMM, SLCT,COPY,
|
||||
LSFT,NUBS,Z, X, C, V, B, K, M, COMM,DOT, SLSH, RO, RSFT, UP, P1, P2, P3, PEQL, EXEC,PSTE,
|
||||
LCTL,LGUI,LALT,MHEN,HANJ, SPC, HAEN,HENK,KANA,RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT, FIND,CUT
|
||||
),
|
||||
|
||||
/* Dvorak http://en.wikipedia.org/wiki/Dvorak_Simplified_Keyboard
|
||||
* ,-----------------------------------------------------------.
|
||||
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| [| ]|Backspa|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Tab | '| ,| .| P| Y| F| G| C| R| L| /| =| \|
|
||||
* |-----------------------------------------------------------|
|
||||
* |BackSp| A| O| E| U| I| D| H| T| N| S| -|Return |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Shift | ;| Q| J| K| X| B| M| Wl V| Z|Shift |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl|
|
||||
* `-----------------------------------------------------------'
|
||||
*/
|
||||
KEYMAP_ALL(
|
||||
F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24,
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, VOLD,VOLU,MUTE,PWR, HELP,
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, LBRC,RBRC,JYEN,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, STOP,AGIN,
|
||||
TAB, QUOT,COMM,DOT, P, Y, F, G, C, R, L, SLSH,EQL, BSLS, DEL, END, PGDN, P7, P8, P9, PPLS, MENU,UNDO,
|
||||
CAPS,A, O, E, U, I, D, H, T, N, S, MINS, NUHS,ENT, P4, P5, P6, PCMM, SLCT,COPY,
|
||||
LSFT,NUBS,SCLN,Q, J, K, X, B, M, W, V, Z, RO, RSFT, UP, P1, P2, P3, PEQL, EXEC,PSTE,
|
||||
LCTL,LGUI,LALT,MHEN,HANJ, SPC, HAEN,HENK,KANA,RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT, FIND,CUT
|
||||
),
|
||||
|
||||
/* Workman http://viralintrospection.wordpress.com/2010/09/06/a-different-philosophy-in-designing-keyboard-layouts/
|
||||
* ,-----------------------------------------------------------.
|
||||
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Tab | Q| D| R| W| B| J| F| U| P| ;| [| ]| \|
|
||||
* |-----------------------------------------------------------|
|
||||
* |CapsLo| A| S| H| T| G| Y| N| E| O| I| '|Return |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Shift | Z| X| M| C| V| K| L| ,| ,| /|Shift |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl|
|
||||
* `-----------------------------------------------------------'
|
||||
*/
|
||||
KEYMAP_ALL(
|
||||
F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24,
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, VOLD,VOLU,MUTE,PWR, HELP,
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, STOP,AGIN,
|
||||
TAB, Q, D, R, W, B, J, F, U, P, SCLN,LBRC,RBRC, BSLS, DEL, END, PGDN, P7, P8, P9, PPLS, MENU,UNDO,
|
||||
CAPS,A, S, H, T, G, Y, N, E, O, I, QUOT, NUHS,ENT, P4, P5, P6, PCMM, SLCT,COPY,
|
||||
LSFT,NUBS,Z, X, M, C, V, K, L, COMM,DOT, SLSH, RO, RSFT, UP, P1, P2, P3, PEQL, EXEC,PSTE,
|
||||
LCTL,LGUI,LALT,MHEN,HANJ, SPC, HAEN,HENK,KANA,RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT, FIND,CUT
|
||||
),
|
||||
|
||||
|
||||
/*
|
||||
* SpaceFN layout
|
||||
* http://geekhack.org/index.php?topic=51069.0
|
||||
*/
|
||||
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* 0: plain Qwerty
|
||||
* ,---------------. ,---------------. ,---------------.
|
||||
* |F13|F14|F15|F16| |F17|F18|F19|F20| |F21|F22|F23|F24|
|
||||
* ,---. |---------------| |---------------| |---------------| ,-----------. ,---------------. ,-------.
|
||||
* |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |VDn|VUp|Mut|Pwr| | Help |
|
||||
* `---' `---------------' `---------------' `---------------' `-----------' `---------------' `-------'
|
||||
* ,-----------------------------------------------------------. ,-----------. ,---------------. ,-------.
|
||||
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|JPY|Bsp| |Ins|Hom|PgU| |NmL| /| *| -| |Stp|Agn|
|
||||
* |-----------------------------------------------------------| |-----------| |---------------| |-------|
|
||||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ | |Del|End|PgD| | 7| 8| 9| +| |Mnu|Und|
|
||||
* |-----------------------------------------------------------| `-----------' |---------------| |-------|
|
||||
* |LCtrl | A| S| D| F| G| H| J| K| L| ;| :| #|Retn| | 4| 5| 6|KP,| |Sel|Cpy|
|
||||
* |-----------------------------------------------------------| ,---. |---------------| |-------|
|
||||
* |Shft| <| Z| X| C| V| B| N| M| ,| ,| /| RO|Shift | |Up | | 1| 2| 3|KP=| |Exe|Pst|
|
||||
* |-----------------------------------------------------------| ,-----------. |---------------| |-------|
|
||||
* |Ctl|Gui|Alt|MHEN|HNJ| Space |H/E|HENK|KANA|Alt|Gui|App|Ctl| |Lef|Dow|Rig| | 0 | .|Ent| |Fnd|Cut|
|
||||
* `-----------------------------------------------------------' `-----------' `---------------' `-------'
|
||||
*/
|
||||
[0] = KEYMAP_ALL(
|
||||
F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24,
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, VOLD,VOLU,MUTE,PWR, HELP,
|
||||
ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, STOP,AGIN,
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, BSLS, DEL, END, PGDN, P7, P8, P9, PPLS, MENU,UNDO,
|
||||
LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT, NUHS,ENT, P4, P5, P6, PCMM, SLCT,COPY,
|
||||
LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RO, RSFT, UP, P1, P2, P3, PEQL, EXEC,PSTE,
|
||||
LCTL,LGUI,LALT,MHEN,HANJ, FN0, HAEN,HENK,KANA,RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT, FIND,CUT
|
||||
),
|
||||
|
||||
/* 1: SpaceFN
|
||||
* ,-----------------------------------------------------------.
|
||||
* |` | F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Caps | | |Esc| | | |Hom|Up |End|Psc|Slk|Pau|Ins |
|
||||
* |-----------------------------------------------------------|
|
||||
* | | | | | | |PgU|Lef|Dow|Rig| | | |
|
||||
* |-----------------------------------------------------------|
|
||||
* | | | | | |Spc|PgD|` |~ | |Men| |
|
||||
* |-----------------------------------------------------------|
|
||||
* | | | | | | | | |
|
||||
* `-----------------------------------------------------------'
|
||||
*/
|
||||
[1] = KEYMAP_ALL(
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
|
||||
TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,
|
||||
GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, TRNS,DEL, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,
|
||||
CAPS,TRNS,TRNS,ESC, TRNS,TRNS,TRNS,HOME,UP, END, PSCR,SLCK,PAUS, INS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PGUP,LEFT,DOWN,RGHT,TRNS,TRNS, TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,SPC, PGDN,GRV, FN1, TRNS,APP, TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS, TRNS,TRNS, TRNS,TRNS
|
||||
),
|
||||
};
|
||||
|
||||
const action_t PROGMEM fn_actions[] = {
|
||||
[0] = ACTION_LAYER_TAP_KEY(1, KC_SPACE),
|
||||
[1] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV), // tilde
|
||||
};
|
||||
|
||||
#endif
|
@@ -19,5 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#define CONFIG_H
|
||||
|
||||
#include "config_common.h"
|
||||
#include <serial_config.h>
|
||||
|
||||
#endif // CONFIG_H
|
||||
|
@@ -28,7 +28,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// #define MASTER_RIGHT
|
||||
#define EE_HANDS
|
||||
|
||||
#define USE_SERIAL_PD2
|
||||
/* #undef RGBLED_NUM */
|
||||
/* #define RGBLIGHT_ANIMATIONS */
|
||||
/* #define RGBLED_NUM 12 */
|
||||
|
@@ -119,9 +119,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
* ,-----------------------------------------. ,-----------------------------------------.
|
||||
* | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Del |
|
||||
* |------+------+------+------+------+------. ,------+------+------+------+------+------|
|
||||
* | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Bksp |
|
||||
* | ` | 1 | ↑ | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Bksp |
|
||||
* |------+------+------+------+------+------. ,------+------+------+------+------+------|
|
||||
* | Del | F1 | F2 | F3 | F4 | F5 | | F6 | - | = | [ | ] | | |
|
||||
* | Del | ← | ↓ | → | F4 | F5 | | F6 | - | = | [ | ] | | |
|
||||
* |------+------+------+------+------+------+-------------+------+------+------+------+------+------|
|
||||
* | | F7 | F8 | F9 | F10 | F11 | | | F12 |ISO # |ISO / | | | |
|
||||
* `-------------+------+------+------+------+------+------+------+------+------+------+-------------'
|
||||
|
@@ -1 +1,2 @@
|
||||
RGBLIGHT_ENABLE = no
|
||||
BACKLIGHT_ENABLE = no
|
@@ -64,12 +64,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
)
|
||||
|
||||
/* ws2812 RGB LED */
|
||||
/* #define RGB_DI_PIN D3 */
|
||||
/* #define RGBLIGHT_TIMER */
|
||||
/* #define RGBLED_NUM 16 // Number of LEDs */
|
||||
/* #define ws2812_PORTREG PORTD */
|
||||
/* #define ws2812_DDRREG DDRD */
|
||||
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
#define RGB_DI_PIN B5
|
||||
#define RGBLIGHT_TIMER
|
||||
#define RGBLED_NUM 18 // Number of LEDs */
|
||||
#endif
|
||||
/*
|
||||
* Feature disable options
|
||||
* These options are also useful to firmware size reduction.
|
||||
|
@@ -1 +0,0 @@
|
||||
BACKLIGHT_ENABLE = yes
|
||||
|
@@ -9,34 +9,128 @@
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <util/delay.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include "serial.h"
|
||||
//#include <pro_micro.h>
|
||||
|
||||
#ifndef USE_I2C
|
||||
#ifdef USE_SERIAL
|
||||
|
||||
// Serial pulse period in microseconds. Its probably a bad idea to lower this
|
||||
// value.
|
||||
#define SERIAL_DELAY 24
|
||||
#ifndef SERIAL_USE_MULTI_TRANSACTION
|
||||
/* --- USE Simple API (OLD API, compatible with let's split serial.c) */
|
||||
#if SERIAL_SLAVE_BUFFER_LENGTH > 0
|
||||
uint8_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0};
|
||||
#endif
|
||||
#if SERIAL_MASTER_BUFFER_LENGTH > 0
|
||||
uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0};
|
||||
#endif
|
||||
uint8_t volatile status0 = 0;
|
||||
|
||||
uint8_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0};
|
||||
uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0};
|
||||
SSTD_t transactions[] = {
|
||||
{ (uint8_t *)&status0,
|
||||
#if SERIAL_MASTER_BUFFER_LENGTH > 0
|
||||
sizeof(serial_master_buffer), (uint8_t *)serial_master_buffer,
|
||||
#else
|
||||
0, (uint8_t *)NULL,
|
||||
#endif
|
||||
#if SERIAL_SLAVE_BUFFER_LENGTH > 0
|
||||
sizeof(serial_slave_buffer), (uint8_t *)serial_slave_buffer
|
||||
#else
|
||||
0, (uint8_t *)NULL,
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
#define SLAVE_DATA_CORRUPT (1<<0)
|
||||
volatile uint8_t status = 0;
|
||||
void serial_master_init(void)
|
||||
{ soft_serial_initiator_init(transactions); }
|
||||
|
||||
void serial_slave_init(void)
|
||||
{ soft_serial_target_init(transactions); }
|
||||
|
||||
// 0 => no error
|
||||
// 1 => slave did not respond
|
||||
// 2 => checksum error
|
||||
int serial_update_buffers()
|
||||
{ return soft_serial_transaction(); }
|
||||
|
||||
#endif // Simple API (OLD API, compatible with let's split serial.c)
|
||||
|
||||
#define ALWAYS_INLINE __attribute__((always_inline))
|
||||
#define NO_INLINE __attribute__((noinline))
|
||||
#define _delay_sub_us(x) __builtin_avr_delay_cycles(x)
|
||||
|
||||
// Serial pulse period in microseconds.
|
||||
#define TID_SEND_ADJUST 14
|
||||
|
||||
#define SELECT_SERIAL_SPEED 1
|
||||
#if SELECT_SERIAL_SPEED == 0
|
||||
// Very High speed
|
||||
#define SERIAL_DELAY 4 // micro sec
|
||||
#define READ_WRITE_START_ADJUST 33 // cycles
|
||||
#define READ_WRITE_WIDTH_ADJUST 3 // cycles
|
||||
#elif SELECT_SERIAL_SPEED == 1
|
||||
// High speed
|
||||
#define SERIAL_DELAY 6 // micro sec
|
||||
#define READ_WRITE_START_ADJUST 30 // cycles
|
||||
#define READ_WRITE_WIDTH_ADJUST 3 // cycles
|
||||
#elif SELECT_SERIAL_SPEED == 2
|
||||
// Middle speed
|
||||
#define SERIAL_DELAY 12 // micro sec
|
||||
#define READ_WRITE_START_ADJUST 30 // cycles
|
||||
#define READ_WRITE_WIDTH_ADJUST 3 // cycles
|
||||
#elif SELECT_SERIAL_SPEED == 3
|
||||
// Low speed
|
||||
#define SERIAL_DELAY 24 // micro sec
|
||||
#define READ_WRITE_START_ADJUST 30 // cycles
|
||||
#define READ_WRITE_WIDTH_ADJUST 3 // cycles
|
||||
#elif SELECT_SERIAL_SPEED == 4
|
||||
// Very Low speed
|
||||
#define SERIAL_DELAY 50 // micro sec
|
||||
#define READ_WRITE_START_ADJUST 30 // cycles
|
||||
#define READ_WRITE_WIDTH_ADJUST 3 // cycles
|
||||
#else
|
||||
#error Illegal Serial Speed
|
||||
#endif
|
||||
|
||||
|
||||
#define SERIAL_DELAY_HALF1 (SERIAL_DELAY/2)
|
||||
#define SERIAL_DELAY_HALF2 (SERIAL_DELAY - SERIAL_DELAY/2)
|
||||
|
||||
#define SLAVE_INT_WIDTH_US 1
|
||||
#ifndef SERIAL_USE_MULTI_TRANSACTION
|
||||
#define SLAVE_INT_RESPONSE_TIME SERIAL_DELAY
|
||||
#else
|
||||
#define SLAVE_INT_ACK_WIDTH_UNIT 2
|
||||
#define SLAVE_INT_ACK_WIDTH 4
|
||||
#endif
|
||||
|
||||
static SSTD_t *Transaction_table = NULL;
|
||||
|
||||
inline static
|
||||
void serial_delay(void) {
|
||||
_delay_us(SERIAL_DELAY);
|
||||
}
|
||||
|
||||
inline static
|
||||
void serial_delay_half1(void) {
|
||||
_delay_us(SERIAL_DELAY_HALF1);
|
||||
}
|
||||
|
||||
inline static
|
||||
void serial_delay_half2(void) {
|
||||
_delay_us(SERIAL_DELAY_HALF2);
|
||||
}
|
||||
|
||||
inline static void serial_output(void) ALWAYS_INLINE;
|
||||
inline static
|
||||
void serial_output(void) {
|
||||
SERIAL_PIN_DDR |= SERIAL_PIN_MASK;
|
||||
}
|
||||
|
||||
// make the serial pin an input with pull-up resistor
|
||||
inline static void serial_input_with_pullup(void) ALWAYS_INLINE;
|
||||
inline static
|
||||
void serial_input(void) {
|
||||
void serial_input_with_pullup(void) {
|
||||
SERIAL_PIN_DDR &= ~SERIAL_PIN_MASK;
|
||||
SERIAL_PIN_PORT |= SERIAL_PIN_MASK;
|
||||
}
|
||||
@@ -46,190 +140,305 @@ uint8_t serial_read_pin(void) {
|
||||
return !!(SERIAL_PIN_INPUT & SERIAL_PIN_MASK);
|
||||
}
|
||||
|
||||
inline static void serial_low(void) ALWAYS_INLINE;
|
||||
inline static
|
||||
void serial_low(void) {
|
||||
SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK;
|
||||
}
|
||||
|
||||
inline static void serial_high(void) ALWAYS_INLINE;
|
||||
inline static
|
||||
void serial_high(void) {
|
||||
SERIAL_PIN_PORT |= SERIAL_PIN_MASK;
|
||||
}
|
||||
|
||||
void serial_master_init(void) {
|
||||
serial_output();
|
||||
serial_high();
|
||||
void soft_serial_initiator_init(SSTD_t *sstd_table)
|
||||
{
|
||||
Transaction_table = sstd_table;
|
||||
serial_output();
|
||||
serial_high();
|
||||
}
|
||||
|
||||
void serial_slave_init(void) {
|
||||
serial_input();
|
||||
void soft_serial_target_init(SSTD_t *sstd_table)
|
||||
{
|
||||
Transaction_table = sstd_table;
|
||||
serial_input_with_pullup();
|
||||
|
||||
#ifndef USE_SERIAL_PD2
|
||||
// Enable INT0
|
||||
EIMSK |= _BV(INT0);
|
||||
// Trigger on falling edge of INT0
|
||||
EICRA &= ~(_BV(ISC00) | _BV(ISC01));
|
||||
#if SERIAL_PIN_MASK == _BV(PD0)
|
||||
// Enable INT0
|
||||
EIMSK |= _BV(INT0);
|
||||
// Trigger on falling edge of INT0
|
||||
EICRA &= ~(_BV(ISC00) | _BV(ISC01));
|
||||
#elif SERIAL_PIN_MASK == _BV(PD2)
|
||||
// Enable INT2
|
||||
EIMSK |= _BV(INT2);
|
||||
// Trigger on falling edge of INT2
|
||||
EICRA &= ~(_BV(ISC20) | _BV(ISC21));
|
||||
#else
|
||||
// Enable INT2
|
||||
EIMSK |= _BV(INT2);
|
||||
// Trigger on falling edge of INT2
|
||||
EICRA &= ~(_BV(ISC20) | _BV(ISC21));
|
||||
#error unknown SERIAL_PIN_MASK value
|
||||
#endif
|
||||
}
|
||||
|
||||
// Used by the master to synchronize timing with the slave.
|
||||
// Used by the sender to synchronize timing with the reciver.
|
||||
static void sync_recv(void) NO_INLINE;
|
||||
static
|
||||
void sync_recv(void) {
|
||||
serial_input();
|
||||
// This shouldn't hang if the slave disconnects because the
|
||||
// serial line will float to high if the slave does disconnect.
|
||||
for (uint8_t i = 0; i < SERIAL_DELAY*5 && serial_read_pin(); i++ ) {
|
||||
}
|
||||
// This shouldn't hang if the target disconnects because the
|
||||
// serial line will float to high if the target does disconnect.
|
||||
while (!serial_read_pin());
|
||||
serial_delay();
|
||||
}
|
||||
|
||||
// Used by the slave to send a synchronization signal to the master.
|
||||
// Used by the reciver to send a synchronization signal to the sender.
|
||||
static void sync_send(void)NO_INLINE;
|
||||
static
|
||||
void sync_send(void) {
|
||||
serial_output();
|
||||
|
||||
serial_low();
|
||||
serial_delay();
|
||||
|
||||
serial_high();
|
||||
}
|
||||
|
||||
// Reads a byte from the serial line
|
||||
static
|
||||
uint8_t serial_read_byte(void) {
|
||||
uint8_t byte = 0;
|
||||
serial_input();
|
||||
for ( uint8_t i = 0; i < 8; ++i) {
|
||||
byte = (byte << 1) | serial_read_pin();
|
||||
serial_delay();
|
||||
_delay_us(1);
|
||||
static uint8_t serial_read_chunk(uint8_t *pterrcount, uint8_t bit) NO_INLINE;
|
||||
static uint8_t serial_read_chunk(uint8_t *pterrcount, uint8_t bit) {
|
||||
uint8_t byte, i, p, pb;
|
||||
|
||||
_delay_sub_us(READ_WRITE_START_ADJUST);
|
||||
for( i = 0, byte = 0, p = 0; i < bit; i++ ) {
|
||||
serial_delay_half1(); // read the middle of pulses
|
||||
if( serial_read_pin() ) {
|
||||
byte = (byte << 1) | 1; p ^= 1;
|
||||
} else {
|
||||
byte = (byte << 1) | 0; p ^= 0;
|
||||
}
|
||||
_delay_sub_us(READ_WRITE_WIDTH_ADJUST);
|
||||
serial_delay_half2();
|
||||
}
|
||||
/* recive parity bit */
|
||||
serial_delay_half1(); // read the middle of pulses
|
||||
pb = serial_read_pin();
|
||||
_delay_sub_us(READ_WRITE_WIDTH_ADJUST);
|
||||
serial_delay_half2();
|
||||
|
||||
*pterrcount += (p != pb)? 1 : 0;
|
||||
|
||||
return byte;
|
||||
}
|
||||
|
||||
// Sends a byte with MSB ordering
|
||||
static
|
||||
void serial_write_byte(uint8_t data) {
|
||||
uint8_t b = 8;
|
||||
serial_output();
|
||||
while( b-- ) {
|
||||
if(data & (1 << b)) {
|
||||
serial_high();
|
||||
} else {
|
||||
serial_low();
|
||||
void serial_write_chunk(uint8_t data, uint8_t bit) NO_INLINE;
|
||||
void serial_write_chunk(uint8_t data, uint8_t bit) {
|
||||
uint8_t b, p;
|
||||
for( p = 0, b = 1<<(bit-1); b ; b >>= 1) {
|
||||
if(data & b) {
|
||||
serial_high(); p ^= 1;
|
||||
} else {
|
||||
serial_low(); p ^= 0;
|
||||
}
|
||||
serial_delay();
|
||||
}
|
||||
/* send parity bit */
|
||||
if(p & 1) { serial_high(); }
|
||||
else { serial_low(); }
|
||||
serial_delay();
|
||||
|
||||
serial_low(); // sync_send() / senc_recv() need raise edge
|
||||
}
|
||||
|
||||
static void serial_send_packet(uint8_t *buffer, uint8_t size) NO_INLINE;
|
||||
static
|
||||
void serial_send_packet(uint8_t *buffer, uint8_t size) {
|
||||
for (uint8_t i = 0; i < size; ++i) {
|
||||
uint8_t data;
|
||||
data = buffer[i];
|
||||
sync_send();
|
||||
serial_write_chunk(data,8);
|
||||
}
|
||||
}
|
||||
|
||||
// interrupt handle to be used by the slave device
|
||||
static uint8_t serial_recive_packet(uint8_t *buffer, uint8_t size) NO_INLINE;
|
||||
static
|
||||
uint8_t serial_recive_packet(uint8_t *buffer, uint8_t size) {
|
||||
uint8_t pecount = 0;
|
||||
for (uint8_t i = 0; i < size; ++i) {
|
||||
uint8_t data;
|
||||
sync_recv();
|
||||
data = serial_read_chunk(&pecount, 8);
|
||||
buffer[i] = data;
|
||||
}
|
||||
return pecount == 0;
|
||||
}
|
||||
|
||||
inline static
|
||||
void change_sender2reciver(void) {
|
||||
sync_send(); //0
|
||||
serial_delay_half1(); //1
|
||||
serial_low(); //2
|
||||
serial_input_with_pullup(); //2
|
||||
serial_delay_half1(); //3
|
||||
}
|
||||
|
||||
inline static
|
||||
void change_reciver2sender(void) {
|
||||
sync_recv(); //0
|
||||
serial_delay(); //1
|
||||
serial_low(); //3
|
||||
serial_output(); //3
|
||||
serial_delay_half1(); //4
|
||||
}
|
||||
|
||||
// interrupt handle to be used by the target device
|
||||
ISR(SERIAL_PIN_INTERRUPT) {
|
||||
sync_send();
|
||||
|
||||
uint8_t checksum = 0;
|
||||
for (int i = 0; i < SERIAL_SLAVE_BUFFER_LENGTH; ++i) {
|
||||
serial_write_byte(serial_slave_buffer[i]);
|
||||
sync_send();
|
||||
checksum += serial_slave_buffer[i];
|
||||
}
|
||||
serial_write_byte(checksum);
|
||||
sync_send();
|
||||
#ifndef SERIAL_USE_MULTI_TRANSACTION
|
||||
serial_low();
|
||||
serial_output();
|
||||
SSTD_t *trans = Transaction_table;
|
||||
#else
|
||||
// recive transaction table index
|
||||
uint8_t tid;
|
||||
uint8_t pecount = 0;
|
||||
sync_recv();
|
||||
tid = serial_read_chunk(&pecount,4);
|
||||
if(pecount> 0)
|
||||
return;
|
||||
serial_delay_half1();
|
||||
|
||||
// wait for the sync to finish sending
|
||||
serial_delay();
|
||||
serial_high(); // response step1 low->high
|
||||
serial_output();
|
||||
_delay_sub_us(SLAVE_INT_ACK_WIDTH_UNIT*SLAVE_INT_ACK_WIDTH);
|
||||
SSTD_t *trans = &Transaction_table[tid];
|
||||
serial_low(); // response step2 ack high->low
|
||||
#endif
|
||||
|
||||
// read the middle of pulses
|
||||
_delay_us(SERIAL_DELAY/2);
|
||||
// target send phase
|
||||
if( trans->target2initiator_buffer_size > 0 )
|
||||
serial_send_packet((uint8_t *)trans->target2initiator_buffer,
|
||||
trans->target2initiator_buffer_size);
|
||||
// target switch to input
|
||||
change_sender2reciver();
|
||||
|
||||
uint8_t checksum_computed = 0;
|
||||
for (int i = 0; i < SERIAL_MASTER_BUFFER_LENGTH; ++i) {
|
||||
serial_master_buffer[i] = serial_read_byte();
|
||||
sync_send();
|
||||
checksum_computed += serial_master_buffer[i];
|
||||
}
|
||||
uint8_t checksum_received = serial_read_byte();
|
||||
sync_send();
|
||||
|
||||
serial_input(); // end transaction
|
||||
|
||||
if ( checksum_computed != checksum_received ) {
|
||||
status |= SLAVE_DATA_CORRUPT;
|
||||
// target recive phase
|
||||
if( trans->initiator2target_buffer_size > 0 ) {
|
||||
if (serial_recive_packet((uint8_t *)trans->initiator2target_buffer,
|
||||
trans->initiator2target_buffer_size) ) {
|
||||
*trans->status = TRANSACTION_ACCEPTED;
|
||||
} else {
|
||||
*trans->status = TRANSACTION_DATA_ERROR;
|
||||
}
|
||||
} else {
|
||||
status &= ~SLAVE_DATA_CORRUPT;
|
||||
*trans->status = TRANSACTION_ACCEPTED;
|
||||
}
|
||||
|
||||
sync_recv(); //weit initiator output to high
|
||||
}
|
||||
|
||||
inline
|
||||
bool serial_slave_DATA_CORRUPT(void) {
|
||||
return status & SLAVE_DATA_CORRUPT;
|
||||
}
|
||||
|
||||
// Copies the serial_slave_buffer to the master and sends the
|
||||
// serial_master_buffer to the slave.
|
||||
/////////
|
||||
// start transaction by initiator
|
||||
//
|
||||
// int soft_serial_transaction(int sstd_index)
|
||||
//
|
||||
// Returns:
|
||||
// 0 => no error
|
||||
// 1 => slave did not respond
|
||||
int serial_update_buffers(void) {
|
||||
// this code is very time dependent, so we need to disable interrupts
|
||||
// TRANSACTION_END
|
||||
// TRANSACTION_NO_RESPONSE
|
||||
// TRANSACTION_DATA_ERROR
|
||||
// this code is very time dependent, so we need to disable interrupts
|
||||
#ifndef SERIAL_USE_MULTI_TRANSACTION
|
||||
int soft_serial_transaction(void) {
|
||||
SSTD_t *trans = Transaction_table;
|
||||
#else
|
||||
int soft_serial_transaction(int sstd_index) {
|
||||
SSTD_t *trans = &Transaction_table[sstd_index];
|
||||
#endif
|
||||
cli();
|
||||
|
||||
// signal to the slave that we want to start a transaction
|
||||
// signal to the target that we want to start a transaction
|
||||
serial_output();
|
||||
serial_low();
|
||||
_delay_us(1);
|
||||
_delay_us(SLAVE_INT_WIDTH_US);
|
||||
|
||||
// wait for the slaves response
|
||||
serial_input();
|
||||
serial_high();
|
||||
_delay_us(SERIAL_DELAY);
|
||||
#ifndef SERIAL_USE_MULTI_TRANSACTION
|
||||
// wait for the target response
|
||||
serial_input_with_pullup();
|
||||
_delay_us(SLAVE_INT_RESPONSE_TIME);
|
||||
|
||||
// check if the slave is present
|
||||
// check if the target is present
|
||||
if (serial_read_pin()) {
|
||||
// slave failed to pull the line low, assume not present
|
||||
// target failed to pull the line low, assume not present
|
||||
serial_output();
|
||||
serial_high();
|
||||
*trans->status = TRANSACTION_NO_RESPONSE;
|
||||
sei();
|
||||
return 1;
|
||||
return TRANSACTION_NO_RESPONSE;
|
||||
}
|
||||
|
||||
// if the slave is present syncronize with it
|
||||
sync_recv();
|
||||
#else
|
||||
// send transaction table index
|
||||
sync_send();
|
||||
_delay_sub_us(TID_SEND_ADJUST);
|
||||
serial_write_chunk(sstd_index, 4);
|
||||
serial_delay_half1();
|
||||
|
||||
uint8_t checksum_computed = 0;
|
||||
// receive data from the slave
|
||||
for (int i = 0; i < SERIAL_SLAVE_BUFFER_LENGTH; ++i) {
|
||||
serial_slave_buffer[i] = serial_read_byte();
|
||||
sync_recv();
|
||||
checksum_computed += serial_slave_buffer[i];
|
||||
}
|
||||
uint8_t checksum_received = serial_read_byte();
|
||||
sync_recv();
|
||||
|
||||
if (checksum_computed != checksum_received) {
|
||||
sei();
|
||||
return 2;
|
||||
// wait for the target response (step1 low->high)
|
||||
serial_input_with_pullup();
|
||||
while( !serial_read_pin() ) {
|
||||
_delay_sub_us(2);
|
||||
}
|
||||
|
||||
uint8_t checksum = 0;
|
||||
// send data to the slave
|
||||
for (int i = 0; i < SERIAL_MASTER_BUFFER_LENGTH; ++i) {
|
||||
serial_write_byte(serial_master_buffer[i]);
|
||||
sync_recv();
|
||||
checksum += serial_master_buffer[i];
|
||||
// check if the target is present (step2 high->low)
|
||||
for( int i = 0; serial_read_pin(); i++ ) {
|
||||
if (i > SLAVE_INT_ACK_WIDTH + 1) {
|
||||
// slave failed to pull the line low, assume not present
|
||||
serial_output();
|
||||
serial_high();
|
||||
*trans->status = TRANSACTION_NO_RESPONSE;
|
||||
sei();
|
||||
return TRANSACTION_NO_RESPONSE;
|
||||
}
|
||||
_delay_sub_us(SLAVE_INT_ACK_WIDTH_UNIT);
|
||||
}
|
||||
#endif
|
||||
|
||||
// initiator recive phase
|
||||
// if the target is present syncronize with it
|
||||
if( trans->target2initiator_buffer_size > 0 ) {
|
||||
if (!serial_recive_packet((uint8_t *)trans->target2initiator_buffer,
|
||||
trans->target2initiator_buffer_size) ) {
|
||||
serial_output();
|
||||
serial_high();
|
||||
*trans->status = TRANSACTION_DATA_ERROR;
|
||||
sei();
|
||||
return TRANSACTION_DATA_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// initiator switch to output
|
||||
change_reciver2sender();
|
||||
|
||||
// initiator send phase
|
||||
if( trans->initiator2target_buffer_size > 0 ) {
|
||||
serial_send_packet((uint8_t *)trans->initiator2target_buffer,
|
||||
trans->initiator2target_buffer_size);
|
||||
}
|
||||
serial_write_byte(checksum);
|
||||
sync_recv();
|
||||
|
||||
// always, release the line when not in use
|
||||
serial_output();
|
||||
serial_high();
|
||||
sync_send();
|
||||
|
||||
*trans->status = TRANSACTION_END;
|
||||
sei();
|
||||
return 0;
|
||||
return TRANSACTION_END;
|
||||
}
|
||||
|
||||
#ifdef SERIAL_USE_MULTI_TRANSACTION
|
||||
int soft_serial_get_and_clean_status(int sstd_index) {
|
||||
SSTD_t *trans = &Transaction_table[sstd_index];
|
||||
cli();
|
||||
int retval = *trans->status;
|
||||
*trans->status = 0;;
|
||||
sei();
|
||||
return retval;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@@ -1,32 +1,80 @@
|
||||
#ifndef MY_SERIAL_H
|
||||
#define MY_SERIAL_H
|
||||
#ifndef SOFT_SERIAL_H
|
||||
#define SOFT_SERIAL_H
|
||||
|
||||
#include "config.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
/* TODO: some defines for interrupt setup */
|
||||
#define SERIAL_PIN_DDR DDRD
|
||||
#define SERIAL_PIN_PORT PORTD
|
||||
#define SERIAL_PIN_INPUT PIND
|
||||
// /////////////////////////////////////////////////////////////////
|
||||
// Need Soft Serial defines in serial_config.h
|
||||
// /////////////////////////////////////////////////////////////////
|
||||
// ex.
|
||||
// #define SERIAL_PIN_DDR DDRD
|
||||
// #define SERIAL_PIN_PORT PORTD
|
||||
// #define SERIAL_PIN_INPUT PIND
|
||||
// #define SERIAL_PIN_MASK _BV(PD?) ?=0,2
|
||||
// #define SERIAL_PIN_INTERRUPT INT?_vect ?=0,2
|
||||
//
|
||||
// //// USE Simple API (OLD API, compatible with let's split serial.c)
|
||||
// ex.
|
||||
// #define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2
|
||||
// #define SERIAL_MASTER_BUFFER_LENGTH 1
|
||||
//
|
||||
// //// USE flexible API (using multi-type transaction function)
|
||||
// #define SERIAL_USE_MULTI_TRANSACTION
|
||||
//
|
||||
// /////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef USE_SERIAL_PD2
|
||||
#define SERIAL_PIN_MASK _BV(PD0)
|
||||
#define SERIAL_PIN_INTERRUPT INT0_vect
|
||||
#else
|
||||
#define SERIAL_PIN_MASK _BV(PD2)
|
||||
#define SERIAL_PIN_INTERRUPT INT2_vect
|
||||
#endif
|
||||
|
||||
#define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2
|
||||
#define SERIAL_MASTER_BUFFER_LENGTH 1
|
||||
|
||||
// Buffers for master - slave communication
|
||||
#ifndef SERIAL_USE_MULTI_TRANSACTION
|
||||
/* --- USE Simple API (OLD API, compatible with let's split serial.c) */
|
||||
#if SERIAL_SLAVE_BUFFER_LENGTH > 0
|
||||
extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH];
|
||||
#endif
|
||||
#if SERIAL_MASTER_BUFFER_LENGTH > 0
|
||||
extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH];
|
||||
#endif
|
||||
|
||||
void serial_master_init(void);
|
||||
void serial_slave_init(void);
|
||||
int serial_update_buffers(void);
|
||||
bool serial_slave_data_corrupt(void);
|
||||
|
||||
#endif // USE Simple API
|
||||
|
||||
// Soft Serial Transaction Descriptor
|
||||
typedef struct _SSTD_t {
|
||||
uint8_t *status;
|
||||
uint8_t initiator2target_buffer_size;
|
||||
uint8_t *initiator2target_buffer;
|
||||
uint8_t target2initiator_buffer_size;
|
||||
uint8_t *target2initiator_buffer;
|
||||
} SSTD_t;
|
||||
|
||||
// initiator is transaction start side
|
||||
void soft_serial_initiator_init(SSTD_t *sstd_table);
|
||||
// target is interrupt accept side
|
||||
void soft_serial_target_init(SSTD_t *sstd_table);
|
||||
|
||||
// initiator resullt
|
||||
#define TRANSACTION_END 0
|
||||
#define TRANSACTION_NO_RESPONSE 0x1
|
||||
#define TRANSACTION_DATA_ERROR 0x2
|
||||
#ifndef SERIAL_USE_MULTI_TRANSACTION
|
||||
int soft_serial_transaction(void);
|
||||
#else
|
||||
int soft_serial_transaction(int sstd_index);
|
||||
#endif
|
||||
|
||||
// target status
|
||||
// *SSTD_t.status has
|
||||
// initiator:
|
||||
// TRANSACTION_END
|
||||
// or TRANSACTION_NO_RESPONSE
|
||||
// or TRANSACTION_DATA_ERROR
|
||||
// target:
|
||||
// TRANSACTION_DATA_ERROR
|
||||
// or TRANSACTION_ACCEPTED
|
||||
#define TRANSACTION_ACCEPTED 0x4
|
||||
#ifdef SERIAL_USE_MULTI_TRANSACTION
|
||||
int soft_serial_get_and_clean_status(int sstd_index);
|
||||
#endif
|
||||
|
||||
#endif /* SOFT_SERIAL_H */
|
14
keyboards/fortitude60/serial_config.h
Normal file
14
keyboards/fortitude60/serial_config.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef SOFT_SERIAL_CONFIG_H
|
||||
#define SOFT_SERIAL_CONFIG_H
|
||||
|
||||
/* Soft Serial defines */
|
||||
#define SERIAL_PIN_DDR DDRD
|
||||
#define SERIAL_PIN_PORT PORTD
|
||||
#define SERIAL_PIN_INPUT PIND
|
||||
#define SERIAL_PIN_MASK _BV(PD2)
|
||||
#define SERIAL_PIN_INTERRUPT INT2_vect
|
||||
|
||||
#define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2
|
||||
#define SERIAL_MASTER_BUFFER_LENGTH 1
|
||||
|
||||
#endif /* SOFT_SERIAL_CONFIG_H */
|
@@ -15,8 +15,7 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
#pragma once
|
||||
|
||||
#include "config_common.h"
|
||||
|
||||
@@ -30,7 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
//#define AUDIO_VOICES
|
||||
//#define AUDIO_VOICES
|
||||
|
||||
//#define BACKLIGHT_PIN B7
|
||||
|
||||
@@ -71,13 +70,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//#define NO_ACTION_LAYER
|
||||
//#define NO_ACTION_TAPPING
|
||||
//#define NO_ACTION_ONESHOT
|
||||
//#define NO_ACTION_MACRO
|
||||
//#define NO_ACTION_FUNCTION
|
||||
#ifdef SUBPROJECT_ver0
|
||||
#include "ver0/config.h"
|
||||
#endif
|
||||
#ifdef SUBPROJECT_ver2
|
||||
#include "ver2/config.h"
|
||||
#endif
|
||||
#define NO_ACTION_MACRO
|
||||
#define NO_ACTION_FUNCTION
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -5,7 +5,7 @@
|
||||
# the appropriate keymap folder that will get included automatically
|
||||
#
|
||||
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
|
||||
MOUSEKEY_ENABLE = no # Mouse keys(+4700)
|
||||
EXTRAKEY_ENABLE = no # Audio control and System control(+450)
|
||||
CONSOLE_ENABLE = no # Console for debug(+400)
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
@@ -21,6 +21,4 @@ SWAP_HANDS_ENABLE = no # Enable one-hand typing
|
||||
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
|
||||
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
|
||||
|
||||
ifndef QUANTUM_DIR
|
||||
include ../../../../Makefile
|
||||
endif
|
||||
EXTRAFLAGS += -flto
|
||||
|
@@ -44,30 +44,32 @@ OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
|
||||
# Atmel DFU loader 4096
|
||||
# LUFA bootloader 4096
|
||||
# USBaspLoader 2048
|
||||
OPT_DEFS += -DBOOTLOADER_SIZE=512
|
||||
BOOTLOADER = halfkay
|
||||
|
||||
# Build Options
|
||||
# change to "no" to disable the options, or define them in the Makefile in
|
||||
# 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 ?= 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
|
||||
NKRO_ENABLE ?= no # 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 ?= 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.
|
||||
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
|
||||
NKRO_ENABLE = no # 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 = 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.
|
||||
API_SYSEX_ENABLE = yes
|
||||
|
||||
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
|
||||
SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend
|
||||
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
|
||||
|
||||
SRC = i2c.c \
|
||||
ssd1306.c
|
||||
|
||||
DEFAULT_FOLDER = hadron/ver2
|
||||
DEFAULT_FOLDER = hadron/ver2
|
||||
|
||||
EXTRAFLAGS += -flto
|
||||
|
@@ -14,10 +14,7 @@ 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/>.
|
||||
*/
|
||||
#ifndef VER0_CONFIG_H
|
||||
#define VER0_CONFIG_H
|
||||
|
||||
#include "../config.h"
|
||||
#pragma once
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define DEVICE_VER 0x0001
|
||||
@@ -32,4 +29,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#define UNUSED_PINS
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -14,10 +14,7 @@ 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/>.
|
||||
*/
|
||||
#ifndef VER2_CONFIG_H
|
||||
#define VER2_CONFIG_H
|
||||
|
||||
#include "../config.h"
|
||||
#pragma once
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define DEVICE_VER 0x0002
|
||||
@@ -32,4 +29,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#define UNUSED_PINS
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -1 +1 @@
|
||||
#AUDIO_ENABLE ?= yes # Audio output on port C6
|
||||
#AUDIO_ENABLE = yes # Audio output on port C6
|
||||
|
@@ -15,8 +15,7 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
#pragma once
|
||||
|
||||
#include "config_common.h"
|
||||
|
||||
@@ -43,4 +42,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/* key combination for command */
|
||||
#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)))
|
||||
|
||||
#endif
|
||||
#define NO_ACTION_MACRO
|
||||
#define NO_ACTION_FUNCTION
|
||||
|
||||
|
@@ -26,7 +26,7 @@ F_CPU = 12000000
|
||||
|
||||
# Bootloader
|
||||
# This definition is optional, and if your keyboard supports multiple bootloaders of
|
||||
# different sizes, comment this out, and the correct address will be loaded
|
||||
# different sizes, comment this out, and the correct address will be loaded
|
||||
# automatically (+60). See bootloader.mk for all options.
|
||||
BOOTLOADER = bootloadHID
|
||||
|
||||
|
@@ -22,3 +22,13 @@
|
||||
{ K45, KC_NO, K46, K47, K48, K49, K50, K51, K52, K53, K54, K55, K56, K57, K58, }, \
|
||||
{ K59, K60, K61, KC_NO, KC_NO, KC_NO, K62, KC_NO, KC_NO, KC_NO, K63, K64, K65, K66, K67, }, \
|
||||
}
|
||||
|
||||
#define TOGGLE_FLAG_AND_PRINT(var, name) { \
|
||||
if (var) { \
|
||||
dprintf(name " disabled\r\n"); \
|
||||
var = !var; \
|
||||
} else { \
|
||||
var = !var; \
|
||||
dprintf(name " enabled\r\n"); \
|
||||
} \
|
||||
}
|
||||
|
@@ -136,8 +136,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
case L_T_BR:
|
||||
if (record->event.pressed) {
|
||||
led_animation_breathing = !led_animation_breathing;
|
||||
if (led_animation_breathing)
|
||||
{
|
||||
if (led_animation_breathing) {
|
||||
gcr_breathe = gcr_desired;
|
||||
led_animation_breathe_cur = BREATHE_MIN_STEP;
|
||||
breathe_dir = 1;
|
||||
@@ -151,50 +150,32 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
return false;
|
||||
case U_T_AUTO:
|
||||
if (record->event.pressed && MODS_SHIFT && MODS_CTRL) {
|
||||
usb_extra_manual = !usb_extra_manual;
|
||||
CDC_print("USB extra port manual mode ");
|
||||
CDC_print(usb_extra_manual ? "enabled" : "disabled");
|
||||
CDC_print("\r\n");
|
||||
TOGGLE_FLAG_AND_PRINT(usb_extra_manual, "USB extra port manual mode");
|
||||
}
|
||||
return false;
|
||||
case U_T_AGCR:
|
||||
if (record->event.pressed && MODS_SHIFT && MODS_CTRL) {
|
||||
usb_gcr_auto = !usb_gcr_auto;
|
||||
CDC_print("USB GCR auto mode ");
|
||||
CDC_print(usb_gcr_auto ? "enabled" : "disabled");
|
||||
CDC_print("\r\n");
|
||||
TOGGLE_FLAG_AND_PRINT(usb_gcr_auto, "USB GCR auto mode");
|
||||
}
|
||||
return false;
|
||||
case DBG_TOG:
|
||||
if (record->event.pressed) {
|
||||
debug_enable = !debug_enable;
|
||||
CDC_print("Debug mode ");
|
||||
CDC_print(debug_enable ? "enabled" : "disabled");
|
||||
CDC_print("\r\n");
|
||||
TOGGLE_FLAG_AND_PRINT(debug_enable, "Debug mode");
|
||||
}
|
||||
return false;
|
||||
case DBG_MTRX:
|
||||
if (record->event.pressed) {
|
||||
debug_matrix = !debug_matrix;
|
||||
CDC_print("Debug matrix ");
|
||||
CDC_print(debug_matrix ? "enabled" : "disabled");
|
||||
CDC_print("\r\n");
|
||||
TOGGLE_FLAG_AND_PRINT(debug_matrix, "Debug matrix");
|
||||
}
|
||||
return false;
|
||||
case DBG_KBD:
|
||||
if (record->event.pressed) {
|
||||
debug_keyboard = !debug_keyboard;
|
||||
CDC_print("Debug keyboard ");
|
||||
CDC_print(debug_keyboard ? "enabled" : "disabled");
|
||||
CDC_print("\r\n");
|
||||
TOGGLE_FLAG_AND_PRINT(debug_keyboard, "Debug keyboard");
|
||||
}
|
||||
return false;
|
||||
case DBG_MOU:
|
||||
if (record->event.pressed) {
|
||||
debug_mouse = !debug_mouse;
|
||||
CDC_print("Debug mouse ");
|
||||
CDC_print(debug_mouse ? "enabled" : "disabled");
|
||||
CDC_print("\r\n");
|
||||
TOGGLE_FLAG_AND_PRINT(debug_mouse, "Debug mouse");
|
||||
}
|
||||
return false;
|
||||
case MD_BOOT:
|
||||
@@ -209,4 +190,4 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
default:
|
||||
return true; //Process all other keycodes normally
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -136,8 +136,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
case L_T_BR:
|
||||
if (record->event.pressed) {
|
||||
led_animation_breathing = !led_animation_breathing;
|
||||
if (led_animation_breathing)
|
||||
{
|
||||
if (led_animation_breathing) {
|
||||
gcr_breathe = gcr_desired;
|
||||
led_animation_breathe_cur = BREATHE_MIN_STEP;
|
||||
breathe_dir = 1;
|
||||
@@ -151,50 +150,32 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
return false;
|
||||
case U_T_AUTO:
|
||||
if (record->event.pressed && MODS_SHIFT && MODS_CTRL) {
|
||||
usb_extra_manual = !usb_extra_manual;
|
||||
CDC_print("USB extra port manual mode ");
|
||||
CDC_print(usb_extra_manual ? "enabled" : "disabled");
|
||||
CDC_print("\r\n");
|
||||
TOGGLE_FLAG_AND_PRINT(usb_extra_manual, "USB extra port manual mode");
|
||||
}
|
||||
return false;
|
||||
case U_T_AGCR:
|
||||
if (record->event.pressed && MODS_SHIFT && MODS_CTRL) {
|
||||
usb_gcr_auto = !usb_gcr_auto;
|
||||
CDC_print("USB GCR auto mode ");
|
||||
CDC_print(usb_gcr_auto ? "enabled" : "disabled");
|
||||
CDC_print("\r\n");
|
||||
TOGGLE_FLAG_AND_PRINT(usb_gcr_auto, "USB GCR auto mode");
|
||||
}
|
||||
return false;
|
||||
case DBG_TOG:
|
||||
if (record->event.pressed) {
|
||||
debug_enable = !debug_enable;
|
||||
CDC_print("Debug mode ");
|
||||
CDC_print(debug_enable ? "enabled" : "disabled");
|
||||
CDC_print("\r\n");
|
||||
TOGGLE_FLAG_AND_PRINT(debug_enable, "Debug mode");
|
||||
}
|
||||
return false;
|
||||
case DBG_MTRX:
|
||||
if (record->event.pressed) {
|
||||
debug_matrix = !debug_matrix;
|
||||
CDC_print("Debug matrix ");
|
||||
CDC_print(debug_matrix ? "enabled" : "disabled");
|
||||
CDC_print("\r\n");
|
||||
TOGGLE_FLAG_AND_PRINT(debug_matrix, "Debug matrix");
|
||||
}
|
||||
return false;
|
||||
case DBG_KBD:
|
||||
if (record->event.pressed) {
|
||||
debug_keyboard = !debug_keyboard;
|
||||
CDC_print("Debug keyboard ");
|
||||
CDC_print(debug_keyboard ? "enabled" : "disabled");
|
||||
CDC_print("\r\n");
|
||||
TOGGLE_FLAG_AND_PRINT(debug_keyboard, "Debug keyboard");
|
||||
}
|
||||
return false;
|
||||
case DBG_MOU:
|
||||
if (record->event.pressed) {
|
||||
debug_mouse = !debug_mouse;
|
||||
CDC_print("Debug mouse ");
|
||||
CDC_print(debug_mouse ? "enabled" : "disabled");
|
||||
CDC_print("\r\n");
|
||||
TOGGLE_FLAG_AND_PRINT(debug_mouse, "Debug mouse");
|
||||
}
|
||||
return false;
|
||||
case MD_BOOT:
|
||||
|
@@ -30,3 +30,4 @@ FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches
|
||||
HD44780_ENABLE = no # Enable support for HD44780 based LCDs (+400)
|
||||
VIRTSER_ENABLE = no # USB Serial Driver
|
||||
RAW_ENABLE = no # Raw device
|
||||
AUTO_SHIFT_ENABLE = no # Auto Shift
|
||||
|
@@ -30,3 +30,13 @@
|
||||
{ K59, K60, K61, K62, K63, K76, K50, K33 }, \
|
||||
{ K72, K73, K74, K75, K85, K86, K87, }, \
|
||||
}
|
||||
|
||||
#define TOGGLE_FLAG_AND_PRINT(var, name) { \
|
||||
if (var) { \
|
||||
dprintf(name " disabled\r\n"); \
|
||||
var = !var; \
|
||||
} else { \
|
||||
var = !var; \
|
||||
dprintf(name " enabled\r\n"); \
|
||||
} \
|
||||
}
|
||||
|
@@ -33,7 +33,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
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, KC_END, KC_PGDN, \
|
||||
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, \
|
||||
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(1), KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT \
|
||||
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(1), KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT \
|
||||
),
|
||||
[1] = 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_MUTE, KC_TRNS, KC_TRNS, \
|
||||
@@ -41,7 +41,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
L_T_BR, L_PSD, L_BRI, L_PSI, KC_TRNS, KC_TRNS, KC_TRNS, U_T_AUTO,U_T_AGCR,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPRV, KC_MNXT, KC_VOLD, \
|
||||
L_T_PTD, L_PTP, L_BRD, L_PTN, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \
|
||||
KC_TRNS, L_T_MD, L_T_ONF, KC_TRNS, KC_TRNS, MD_BOOT, TG_NKRO, 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 \
|
||||
),
|
||||
/*
|
||||
[X] = LAYOUT(
|
||||
@@ -50,7 +50,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
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, TG_NKRO, 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 \
|
||||
),
|
||||
*/
|
||||
};
|
||||
@@ -139,8 +139,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
case L_T_BR:
|
||||
if (record->event.pressed) {
|
||||
led_animation_breathing = !led_animation_breathing;
|
||||
if (led_animation_breathing)
|
||||
{
|
||||
if (led_animation_breathing) {
|
||||
gcr_breathe = gcr_desired;
|
||||
led_animation_breathe_cur = BREATHE_MIN_STEP;
|
||||
breathe_dir = 1;
|
||||
@@ -154,50 +153,32 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
return false;
|
||||
case U_T_AUTO:
|
||||
if (record->event.pressed && MODS_SHIFT && MODS_CTRL) {
|
||||
usb_extra_manual = !usb_extra_manual;
|
||||
CDC_print("USB extra port manual mode ");
|
||||
CDC_print(usb_extra_manual ? "enabled" : "disabled");
|
||||
CDC_print("\r\n");
|
||||
TOGGLE_FLAG_AND_PRINT(usb_extra_manual, "USB extra port manual mode");
|
||||
}
|
||||
return false;
|
||||
case U_T_AGCR:
|
||||
if (record->event.pressed && MODS_SHIFT && MODS_CTRL) {
|
||||
usb_gcr_auto = !usb_gcr_auto;
|
||||
CDC_print("USB GCR auto mode ");
|
||||
CDC_print(usb_gcr_auto ? "enabled" : "disabled");
|
||||
CDC_print("\r\n");
|
||||
TOGGLE_FLAG_AND_PRINT(usb_gcr_auto, "USB GCR auto mode");
|
||||
}
|
||||
return false;
|
||||
case DBG_TOG:
|
||||
if (record->event.pressed) {
|
||||
debug_enable = !debug_enable;
|
||||
CDC_print("Debug mode ");
|
||||
CDC_print(debug_enable ? "enabled" : "disabled");
|
||||
CDC_print("\r\n");
|
||||
TOGGLE_FLAG_AND_PRINT(debug_enable, "Debug mode");
|
||||
}
|
||||
return false;
|
||||
case DBG_MTRX:
|
||||
if (record->event.pressed) {
|
||||
debug_matrix = !debug_matrix;
|
||||
CDC_print("Debug matrix ");
|
||||
CDC_print(debug_matrix ? "enabled" : "disabled");
|
||||
CDC_print("\r\n");
|
||||
TOGGLE_FLAG_AND_PRINT(debug_matrix, "Debug matrix");
|
||||
}
|
||||
return false;
|
||||
case DBG_KBD:
|
||||
if (record->event.pressed) {
|
||||
debug_keyboard = !debug_keyboard;
|
||||
CDC_print("Debug keyboard ");
|
||||
CDC_print(debug_keyboard ? "enabled" : "disabled");
|
||||
CDC_print("\r\n");
|
||||
TOGGLE_FLAG_AND_PRINT(debug_keyboard, "Debug keyboard");
|
||||
}
|
||||
return false;
|
||||
case DBG_MOU:
|
||||
if (record->event.pressed) {
|
||||
debug_mouse = !debug_mouse;
|
||||
CDC_print("Debug mouse ");
|
||||
CDC_print(debug_mouse ? "enabled" : "disabled");
|
||||
CDC_print("\r\n");
|
||||
TOGGLE_FLAG_AND_PRINT(debug_mouse, "Debug mouse");
|
||||
}
|
||||
return false;
|
||||
case MD_BOOT:
|
||||
|
@@ -33,15 +33,15 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
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, KC_END, KC_PGDN, \
|
||||
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, \
|
||||
KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_RGUI, MO(1), KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT \
|
||||
KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_RGUI, MO(1), KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT \
|
||||
),
|
||||
[1] = 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_MUTE, 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_MPLY, KC_MSTP, KC_VOLU, \
|
||||
L_T_BR, L_PSD, L_BRI, L_PSI, KC_TRNS, KC_TRNS, KC_TRNS, U_T_AUTO,U_T_AGCR,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPRV, KC_MNXT, KC_VOLD, \
|
||||
L_T_PTD, L_PTP, L_BRD, L_PTN, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \
|
||||
KC_TRNS, L_T_MD, L_T_ONF, KC_TRNS, KC_TRNS, KC_TRNS, TG_NKRO, 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, L_T_MD, L_T_ONF, KC_TRNS, KC_TRNS, MD_BOOT, TG_NKRO, 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 \
|
||||
),
|
||||
/*
|
||||
[X] = LAYOUT(
|
||||
@@ -50,7 +50,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
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, TG_NKRO, 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 \
|
||||
),
|
||||
*/
|
||||
};
|
||||
@@ -139,8 +139,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
case L_T_BR:
|
||||
if (record->event.pressed) {
|
||||
led_animation_breathing = !led_animation_breathing;
|
||||
if (led_animation_breathing)
|
||||
{
|
||||
if (led_animation_breathing) {
|
||||
gcr_breathe = gcr_desired;
|
||||
led_animation_breathe_cur = BREATHE_MIN_STEP;
|
||||
breathe_dir = 1;
|
||||
@@ -154,50 +153,32 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
return false;
|
||||
case U_T_AUTO:
|
||||
if (record->event.pressed && MODS_SHIFT && MODS_CTRL) {
|
||||
usb_extra_manual = !usb_extra_manual;
|
||||
CDC_print("USB extra port manual mode ");
|
||||
CDC_print(usb_extra_manual ? "enabled" : "disabled");
|
||||
CDC_print("\r\n");
|
||||
TOGGLE_FLAG_AND_PRINT(usb_extra_manual, "USB extra port manual mode");
|
||||
}
|
||||
return false;
|
||||
case U_T_AGCR:
|
||||
if (record->event.pressed && MODS_SHIFT && MODS_CTRL) {
|
||||
usb_gcr_auto = !usb_gcr_auto;
|
||||
CDC_print("USB GCR auto mode ");
|
||||
CDC_print(usb_gcr_auto ? "enabled" : "disabled");
|
||||
CDC_print("\r\n");
|
||||
TOGGLE_FLAG_AND_PRINT(usb_gcr_auto, "USB GCR auto mode");
|
||||
}
|
||||
return false;
|
||||
case DBG_TOG:
|
||||
if (record->event.pressed) {
|
||||
debug_enable = !debug_enable;
|
||||
CDC_print("Debug mode ");
|
||||
CDC_print(debug_enable ? "enabled" : "disabled");
|
||||
CDC_print("\r\n");
|
||||
TOGGLE_FLAG_AND_PRINT(debug_enable, "Debug mode");
|
||||
}
|
||||
return false;
|
||||
case DBG_MTRX:
|
||||
if (record->event.pressed) {
|
||||
debug_matrix = !debug_matrix;
|
||||
CDC_print("Debug matrix ");
|
||||
CDC_print(debug_matrix ? "enabled" : "disabled");
|
||||
CDC_print("\r\n");
|
||||
TOGGLE_FLAG_AND_PRINT(debug_matrix, "Debug matrix");
|
||||
}
|
||||
return false;
|
||||
case DBG_KBD:
|
||||
if (record->event.pressed) {
|
||||
debug_keyboard = !debug_keyboard;
|
||||
CDC_print("Debug keyboard ");
|
||||
CDC_print(debug_keyboard ? "enabled" : "disabled");
|
||||
CDC_print("\r\n");
|
||||
TOGGLE_FLAG_AND_PRINT(debug_keyboard, "Debug keyboard");
|
||||
}
|
||||
return false;
|
||||
case DBG_MOU:
|
||||
if (record->event.pressed) {
|
||||
debug_mouse = !debug_mouse;
|
||||
CDC_print("Debug mouse ");
|
||||
CDC_print(debug_mouse ? "enabled" : "disabled");
|
||||
CDC_print("\r\n");
|
||||
TOGGLE_FLAG_AND_PRINT(debug_mouse, "Debug mouse");
|
||||
}
|
||||
return false;
|
||||
case MD_BOOT:
|
||||
|
@@ -30,3 +30,4 @@ FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches
|
||||
HD44780_ENABLE = no # Enable support for HD44780 based LCDs (+400)
|
||||
VIRTSER_ENABLE = no # USB Serial Driver
|
||||
RAW_ENABLE = no # Raw device
|
||||
AUTO_SHIFT_ENABLE = no # Auto Shift
|
||||
|
@@ -33,3 +33,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/* The scanners already debounce for us */
|
||||
#define DEBOUNCING_DELAY 0
|
||||
|
||||
/* RGB matrix constants */
|
||||
#define DRIVER_LED_TOTAL 64
|
||||
|
@@ -26,7 +26,7 @@ enum {
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[DEF] = LAYOUT(
|
||||
RESET , KC_1 , KC_2 , KC_3 , KC_4 , KC_5 , KC_6 , KC_7 , KC_8 , KC_9 , KC_0 , TG(NUM),
|
||||
KC_GRV , KC_Q , KC_W , KC_E , KC_R , KC_T , _______, _______, KC_Y , KC_U , KC_I , KC_O , KC_P , KC_EQL ,
|
||||
KC_GRV , KC_Q , KC_W , KC_E , KC_R , KC_T , RGB_MOD, _______, KC_Y , KC_U , KC_I , KC_O , KC_P , KC_EQL ,
|
||||
KC_PGUP, KC_A , KC_S , KC_D , KC_F , KC_G , KC_TAB , KC_ENT , KC_H , KC_J , KC_K , KC_L , KC_SCLN, KC_QUOT,
|
||||
KC_PGDN, KC_Z , KC_X , KC_C , KC_V , KC_B , KC_ESC , _______, KC_N , KC_M , KC_COMM, KC_DOT , KC_SLSH, KC_MINS,
|
||||
KC_LCTL, KC_RCTL,
|
||||
@@ -48,7 +48,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
),
|
||||
[FUN] = LAYOUT(
|
||||
_______, KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_F5 , KC_F6 , KC_F7 , KC_F8 , KC_F9 , KC_F10 , KC_F11 ,
|
||||
KC_TAB , _______, KC_MS_U, _______, KC_BTN3, _______, _______, KC_MPRV, KC_MNXT, KC_LCBR, KC_RCBR, KC_LBRC, KC_RBRC, KC_F12 ,
|
||||
KC_TAB , _______, KC_MS_U, _______, KC_BTN3, _______, RGB_TOG, KC_MPRV, KC_MNXT, KC_LCBR, KC_RCBR, KC_LBRC, KC_RBRC, KC_F12 ,
|
||||
KC_HOME, KC_MS_L, KC_MS_D, KC_MS_R, KC_BTN1, _______, _______, KC_MPLY, KC_LEFT, KC_DOWN, KC_UP , KC_RGHT, _______, _______,
|
||||
KC_END , KC_PSCR, KC_INS , _______, KC_BTN2, _______, _______, _______, KC_MUTE, KC_VOLD, KC_VOLU, _______, KC_BSLS, KC_PIPE,
|
||||
_______, _______,
|
||||
@@ -73,21 +73,52 @@ LAYOUT(
|
||||
)
|
||||
*/
|
||||
|
||||
static void set_numpad_colours(int on, void (*write)(int, uint8_t, uint8_t, uint8_t)) {
|
||||
if (!on) {
|
||||
for (int i=44; i<=60; i++)
|
||||
write(i, 0, 0, 0);
|
||||
write(63, 0, 0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
/* main number keys */
|
||||
for (int i=44; i<=47; i++)
|
||||
write(i, 255, 0, 0);
|
||||
for (int i=49; i<=54; i++)
|
||||
write(i, 255, 0, 0);
|
||||
|
||||
/* accessory keys */
|
||||
write(48, 128, 128, 0);
|
||||
for (int i=55; i<=59; i++)
|
||||
write(i, 128, 128, 0);
|
||||
|
||||
// enter
|
||||
write(63, 0, 128, 0);
|
||||
|
||||
// num key
|
||||
write(60, 128, 0, 128);
|
||||
}
|
||||
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
/* the RGB matrix effects will overwrite the numpad indicator.
|
||||
* this handy mechanism allows to override the matrix effects.
|
||||
*/
|
||||
void rgb_matrix_indicators_user(void) {
|
||||
if (layer_state & (1<<NUM)) {
|
||||
set_numpad_colours(1, &rgb_matrix_set_color);
|
||||
}
|
||||
}
|
||||
#else /* no RGB matrix support */
|
||||
|
||||
uint32_t layer_state_set_user(uint32_t state) {
|
||||
switch (biton32(state)) {
|
||||
case DEF:
|
||||
set_all_leds_to(0,0,0);
|
||||
break;
|
||||
case NUM:
|
||||
/* highlight the numpad keys when numlock is on */
|
||||
for (int i=44; i<=60; i++) {
|
||||
set_led_to(i, 128,0,0);
|
||||
}
|
||||
set_led_to(63, 128, 0, 0);
|
||||
break;
|
||||
if (state & (1<<NUM)) {
|
||||
set_numpad_colours(1, &set_led_to);
|
||||
} else {
|
||||
set_numpad_colours(0, &set_led_to);
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* vim: set ts=2 sw=2 et: */
|
||||
|
@@ -1,8 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define _______ KC_TRNS
|
||||
#define XXXXXXX KC_NO
|
||||
|
||||
#define USB_MAX_POWER_CONSUMPTION 100
|
||||
#define ONESHOT_TAP_TOGGLE 2
|
||||
#define ONESHOT_TIMEOUT 3000
|
||||
|
@@ -1,2 +1 @@
|
||||
# used by default keymap
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
|
||||
MOUSEKEY_ENABLE = yes
|
||||
|
@@ -16,42 +16,154 @@
|
||||
#include <quantum.h>
|
||||
#include <i2c_master.h>
|
||||
#include <led_tables.h>
|
||||
#include <rgb_matrix.h>
|
||||
#include <string.h>
|
||||
#include "model01.h"
|
||||
|
||||
#define I2C_TIMEOUT 1000
|
||||
|
||||
#define LINCOR(i) pgm_read_byte(&CIE1931_CURVE[i])
|
||||
|
||||
int set_all_leds_to_raw(uint8_t r, uint8_t g, uint8_t b) {
|
||||
void set_all_leds_to(uint8_t r, uint8_t g, uint8_t b) {
|
||||
uint8_t buf[] = {
|
||||
TWI_CMD_LED_SET_ALL_TO,
|
||||
b, g, r
|
||||
};
|
||||
int ret = 0;
|
||||
ret |= i2c_transmit(I2C_ADDR(LEFT), buf, sizeof(buf), I2C_TIMEOUT);
|
||||
ret |= i2c_transmit(I2C_ADDR(RIGHT), buf, sizeof(buf), I2C_TIMEOUT);
|
||||
i2c_transmit(I2C_ADDR(LEFT), buf, sizeof(buf), I2C_TIMEOUT);
|
||||
i2c_transmit(I2C_ADDR(RIGHT), buf, sizeof(buf), I2C_TIMEOUT);
|
||||
_delay_us(10);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int set_all_leds_to(uint8_t r, uint8_t g, uint8_t b) {
|
||||
return set_all_leds_to_raw(LINCOR(r), LINCOR(g), LINCOR(b));
|
||||
}
|
||||
|
||||
int set_led_to_raw(uint8_t led, uint8_t r, uint8_t g, uint8_t b) {
|
||||
void set_led_to(int led, uint8_t r, uint8_t g, uint8_t b) {
|
||||
uint8_t buf[] = {
|
||||
TWI_CMD_LED_SET_ONE_TO,
|
||||
led & 0x1f,
|
||||
b, g, r
|
||||
};
|
||||
int hand = (led >= 32) ? RIGHT : LEFT;
|
||||
int ret = i2c_transmit(I2C_ADDR(hand), buf, sizeof(buf), I2C_TIMEOUT);
|
||||
i2c_transmit(I2C_ADDR(hand), buf, sizeof(buf), I2C_TIMEOUT);
|
||||
_delay_us(10);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int set_led_to(uint8_t led, uint8_t r, uint8_t g, uint8_t b) {
|
||||
return set_led_to_raw(led, LINCOR(r), LINCOR(g), LINCOR(b));
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
|
||||
__attribute__ ((weak))
|
||||
const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = {
|
||||
{{0x73}, { 3, 35}, 0},
|
||||
{{0x72}, { 0, 26}, 0},
|
||||
{{0x71}, { 0, 17}, 0},
|
||||
{{0x70}, { 0, 6}, 0},
|
||||
{{0x60}, { 14, 5}, 0},
|
||||
{{0x61}, { 15, 16}, 0},
|
||||
{{0x62}, { 16, 25}, 0},
|
||||
{{0x63}, { 17, 34}, 0},
|
||||
{{0x53}, { 31, 29}, 0},
|
||||
{{0x52}, { 31, 19}, 0},
|
||||
{{0x51}, { 30, 11}, 0},
|
||||
{{0x50}, { 30, 1}, 0},
|
||||
{{0x40}, { 45, 0}, 0},
|
||||
{{0x41}, { 45, 8}, 0},
|
||||
{{0x42}, { 46, 17}, 0},
|
||||
{{0x43}, { 46, 27}, 0},
|
||||
{{0x33}, { 60, 27}, 0},
|
||||
{{0x32}, { 60, 18}, 0},
|
||||
{{0x31}, { 60, 9}, 0},
|
||||
{{0x30}, { 60, 0}, 0},
|
||||
{{0x20}, { 74, 2}, 0},
|
||||
{{0x21}, { 74, 11}, 0},
|
||||
{{0x22}, { 75, 20}, 0},
|
||||
{{0x23}, { 74, 28}, 0},
|
||||
{{0x12}, { 89, 30}, 0},
|
||||
{{0x11}, { 89, 19}, 0},
|
||||
{{0x10}, { 89, 7}, 0},
|
||||
{{0x00}, { 70, 38}, 1},
|
||||
{{0x01}, { 82, 41}, 1},
|
||||
{{0x02}, { 93, 45}, 1},
|
||||
{{0x03}, {104, 50}, 1},
|
||||
{{0x13}, { 74, 64}, 1},
|
||||
{{0x67}, {149, 64}, 1},
|
||||
{{0x77}, {119, 50}, 1},
|
||||
{{0x76}, {130, 45}, 1},
|
||||
{{0x75}, {141, 41}, 1},
|
||||
{{0x74}, {153, 38}, 1},
|
||||
{{0x64}, {134, 7}, 0},
|
||||
{{0x65}, {134, 19}, 0},
|
||||
{{0x66}, {134, 30}, 0},
|
||||
{{0x57}, {149, 28}, 0},
|
||||
{{0x56}, {148, 20}, 0},
|
||||
{{0x55}, {149, 11}, 0},
|
||||
{{0x54}, {149, 2}, 0},
|
||||
{{0x44}, {163, 0}, 0},
|
||||
{{0x45}, {163, 9}, 0},
|
||||
{{0x46}, {163, 18}, 0},
|
||||
{{0x47}, {163, 27}, 0},
|
||||
{{0x37}, {177, 27}, 0},
|
||||
{{0x36}, {177, 17}, 0},
|
||||
{{0x35}, {178, 8}, 0},
|
||||
{{0x34}, {178, 0}, 0},
|
||||
{{0x24}, {193, 1}, 0},
|
||||
{{0x25}, {193, 11}, 0},
|
||||
{{0x26}, {192, 19}, 0},
|
||||
{{0x27}, {192, 29}, 0},
|
||||
{{0x17}, {206, 34}, 0},
|
||||
{{0x16}, {207, 25}, 0},
|
||||
{{0x15}, {208, 16}, 0},
|
||||
{{0x14}, {209, 5}, 0},
|
||||
{{0x04}, {224, 6}, 0},
|
||||
{{0x05}, {223, 17}, 0},
|
||||
{{0x06}, {223, 26}, 0},
|
||||
{{0x07}, {220, 35}, 0},
|
||||
};
|
||||
|
||||
static struct {
|
||||
uint8_t b;
|
||||
uint8_t g;
|
||||
uint8_t r;
|
||||
} __attribute__((packed)) led_state[64];
|
||||
|
||||
static void set_color(int index, uint8_t r, uint8_t g, uint8_t b) {
|
||||
led_state[index].r = r;
|
||||
led_state[index].g = g;
|
||||
led_state[index].b = b;
|
||||
}
|
||||
|
||||
static void set_color_all(uint8_t r, uint8_t g, uint8_t b) {
|
||||
for (int i=0; i<DRIVER_LED_TOTAL; i++)
|
||||
set_color(i, r, g, b);
|
||||
}
|
||||
|
||||
static void init(void) {
|
||||
// Enable high current pathway to LEDs - this does violate the USB spec though! (1.6 amps...)
|
||||
DDRE |= _BV(6);
|
||||
PORTE &= ~_BV(6);
|
||||
|
||||
// Overcurrent check input
|
||||
DDRB &= ~_BV(4);
|
||||
PORTB &= ~_BV(4);
|
||||
}
|
||||
|
||||
static void flush(void) {
|
||||
uint8_t *bank_data = (uint8_t*)&led_state[0];
|
||||
uint8_t command[1 + 8*3];
|
||||
for (int hand=0; hand<2; hand++) {
|
||||
int addr = I2C_ADDR(hand);
|
||||
|
||||
for (int bank=0; bank<4; bank++) {
|
||||
command[0] = TWI_CMD_LED_BASE + bank;
|
||||
memcpy(&command[1], bank_data, 8*3);
|
||||
i2c_transmit(addr, command, sizeof(command), I2C_TIMEOUT);
|
||||
_delay_us(100);
|
||||
|
||||
bank_data += 8*3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const rgb_matrix_driver_t rgb_matrix_driver = {
|
||||
.init = init,
|
||||
.flush = flush,
|
||||
.set_color = set_color,
|
||||
.set_color_all = set_color_all
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/* vim: set ts=2 sw=2 et: */
|
||||
|
@@ -16,10 +16,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <quantum.h>
|
||||
#include <rgb_matrix.h>
|
||||
|
||||
int set_all_leds_to(uint8_t r, uint8_t g, uint8_t b);
|
||||
int set_led_to(uint8_t led, uint8_t r, uint8_t g, uint8_t b);
|
||||
|
||||
/* Raw (gamma uncorrected) LED values */
|
||||
int set_all_leds_to_raw(uint8_t r, uint8_t g, uint8_t b);
|
||||
int set_led_to_raw(uint8_t led, uint8_t r, uint8_t g, uint8_t b);
|
||||
void set_all_leds_to(uint8_t r, uint8_t g, uint8_t b);
|
||||
void set_led_to(int led, uint8_t r, uint8_t g, uint8_t b);
|
||||
|
@@ -59,4 +59,6 @@ MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config)
|
||||
UNICODE_ENABLE = no # Unicode
|
||||
|
||||
CUSTOM_MATRIX = yes
|
||||
CIE1931_CURVE = yes
|
||||
|
||||
# You can set RGB_MATRIX_ENABLE = no in your rules.mk to disable this and save the Flash
|
||||
RGB_MATRIX_ENABLE = custom # Enable RGB matrix effects (+10000).
|
||||
|
@@ -15,8 +15,7 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PEARL_CONFIG_H
|
||||
#define PEARL_CONFIG_H
|
||||
#pragma once
|
||||
|
||||
#include "config_common.h"
|
||||
|
||||
@@ -46,4 +45,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/* key combination for command */
|
||||
#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)))
|
||||
|
||||
#endif
|
||||
#define NO_ACTION_MACRO
|
||||
#define NO_ACTION_FUNCTION
|
||||
|
||||
|
@@ -1,15 +1,4 @@
|
||||
#ifndef CONFIG_USER_H
|
||||
#define CONFIG_USER_H
|
||||
|
||||
#include "../../config.h"
|
||||
|
||||
#define QMK_ESC_OUTPUT F1
|
||||
#define QMK_ESC_INPUT D5
|
||||
#define QMK_LED E6
|
||||
#define QMK_SPEAKER C6
|
||||
|
||||
#define _______ KC_TRNS
|
||||
#define XXXXXXX KC_NO
|
||||
#pragma once
|
||||
|
||||
#define USB_MAX_POWER_CONSUMPTION 100
|
||||
#define ONESHOT_TAP_TOGGLE 2
|
||||
@@ -39,5 +28,3 @@
|
||||
// mod-tap keys
|
||||
#define MT_SPC SFT_T(KC_SPC)
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -17,68 +17,24 @@ enum planck_keycodes { DYNAMIC_MACRO_RANGE = SAFE_RANGE };
|
||||
#endif
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* Default
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | Q | W | E | R | T | Esc | Bksp | Y | U | I | O | P |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | A | S | D | F | G | Tab | Enter| H | J | K | L | ; |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | Z | X | C | V | B | Shift|DmPlay| N | M | , | . | / |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | Ctrl | Super| Alt | Fun | Lower| Space | Raise| Left | Down | Up |Right |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[DEF] = LAYOUT_planck_grid(
|
||||
KC_Q, KC_W, KC_E, KC_R, KC_T, KC_ESC, KC_BSPC, KC_Y, KC_U, KC_I, KC_O, KC_P ,
|
||||
KC_A, KC_S, KC_D, KC_F, KC_G, KC_TAB, KC_ENT, KC_H, KC_J, KC_K, KC_L, KC_SCLN,
|
||||
KC_Z, KC_X, KC_C, KC_V, KC_B, OSM_SFT, DM_PLAY, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH,
|
||||
OSM_CTL, KC_LGUI, OSM_ALT, OSL_FUN, OSL_LWR, MT_SPC, MT_SPC, OSL_RSE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT
|
||||
),
|
||||
/* Lower
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | ! | @ | # | $ | % | | | ^ | & | * | ( | ) |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | ~ | | | | | | | _ | + | | { | } |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | | | | | | | | | | | " | | |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | | | | | | | | Home | PgDn | PgUp | End |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[LWR] = LAYOUT_planck_grid(
|
||||
KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, _______, _______, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN,
|
||||
KC_TILD, _______, _______, _______, _______, _______, _______, KC_UNDS, KC_PLUS, _______, KC_LCBR, KC_RCBR,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DQUO, KC_PIPE,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGDN, KC_PGUP, KC_END
|
||||
),
|
||||
/* Raise
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | 1 | 2 | 3 | 4 | 5 | | | 6 | 7 | 8 | 9 | 0 |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | ` | | | | | | | - | = | | [ | ] |
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* | | | | | | | | | | | ' | \ |
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | | | | | | | | Home | PgDn | PgUp | End |
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[RSE] = LAYOUT_planck_grid(
|
||||
KC_1, KC_2, KC_3, KC_4, KC_5, _______, _______, KC_6, KC_7, KC_8, KC_9, KC_0 ,
|
||||
KC_GRV, _______, _______, _______, _______, _______, _______, KC_MINS, KC_EQL, _______, KC_LBRC, KC_RBRC,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_QUOT, KC_BSLS,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGDN, KC_PGUP, KC_END
|
||||
),
|
||||
/* Function
|
||||
* ,-----------------------------------------------------------------------------------.
|
||||
* | F1 | F2 | F3 | F4 | F5 | Reset|Delete| F6 | F7 | F8 | F9 | F10 |
|
||||
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||
* | F11 | F12 | F13 | F14 | F15 | | | |MsWhLt|MsWhDn|MsWhUp|MsWhRt|
|
||||
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||
* |BlTggl|BlStep| | | |DmStrt|DmStop| | |MsBtn1|MsBtn2|MsBtn3|
|
||||
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||
* | | | | | | | |MsLeft|MsDown| MsUp |MsRght|
|
||||
* `-----------------------------------------------------------------------------------'
|
||||
*/
|
||||
[FUN] = LAYOUT_planck_grid(
|
||||
KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, RESET, KC_DEL, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10 ,
|
||||
KC_F11, KC_F12, KC_F13, KC_F14, KC_F15, _______, _______, _______, KC_WH_L, KC_WH_D, KC_WH_U, KC_WH_R,
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
#ifdef AUDIO_ENABLE
|
||||
#define STARTUP_SONG SONG(PLANCK_SOUND)
|
||||
#define AUDIO_CLICKY
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -30,3 +31,4 @@
|
||||
|
||||
// Most tactile encoders have detents every 4 stages
|
||||
#define ENCODER_RESOLUTION 4
|
||||
|
||||
|
@@ -188,8 +188,24 @@ uint16_t muse_counter = 0;
|
||||
uint8_t muse_offset = 70;
|
||||
uint16_t muse_tempo = 20;
|
||||
|
||||
extern float clicky_rand;
|
||||
|
||||
void encoder_update(bool clockwise) {
|
||||
if (muse_mode) {
|
||||
if (is_clicky_on()) {
|
||||
if (IS_LAYER_ON(_RAISE)) {
|
||||
if (clockwise) {
|
||||
clicky_rand += 0.5f;
|
||||
} else {
|
||||
clicky_rand -= 0.5f;
|
||||
}
|
||||
} else {
|
||||
if (clockwise) {
|
||||
clicky_freq_up();
|
||||
} else {
|
||||
clicky_freq_down();
|
||||
}
|
||||
}
|
||||
} else if (muse_mode) {
|
||||
if (IS_LAYER_ON(_RAISE)) {
|
||||
if (clockwise) {
|
||||
muse_offset++;
|
||||
@@ -248,6 +264,13 @@ void dip_update(uint8_t index, bool active) {
|
||||
stop_all_notes();
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (active) {
|
||||
clicky_on();
|
||||
} else {
|
||||
clicky_off();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -18,8 +18,8 @@
|
||||
#include "config_common.h"
|
||||
|
||||
// USB Device descriptor parameter
|
||||
#define VENDOR_ID 0xFEED // This is same as Zeal60 for now
|
||||
#define PRODUCT_ID 0x6060 // This is same as Zeal60 for now
|
||||
#define VENDOR_ID 0x5241 // "RW"
|
||||
#define PRODUCT_ID 0x060A // 60-A
|
||||
#define DEVICE_VER 0x0001
|
||||
#define MANUFACTURER RAMA.WORKS
|
||||
#define PRODUCT RAMA M60-A
|
||||
|
@@ -16,20 +16,12 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
#pragma once
|
||||
|
||||
#include "config_common.h"
|
||||
|
||||
#if !defined(NO_DEBUG) && !defined(CONSOLE_ENABLE)
|
||||
#define NO_DEBUG
|
||||
#endif // !NO_DEBUG
|
||||
#if !defined(NO_PRINT) && !defined(CONSOLE_ENABLE)
|
||||
#define NO_PRINT
|
||||
#endif // !NO_PRINT
|
||||
#define NO_ACTION_MACRO
|
||||
#define NO_ACTION_FUNCTION
|
||||
|
||||
#define DISABLE_LEADER
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -18,10 +18,7 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_USER_H
|
||||
#define CONFIG_USER_H
|
||||
|
||||
#include "../../config.h"
|
||||
#pragma once
|
||||
|
||||
/* Use I2C or Serial, not both */
|
||||
|
||||
@@ -40,5 +37,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
SONG(COLEMAK_SOUND) \
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@@ -1,6 +1,4 @@
|
||||
#include QMK_KEYBOARD_H
|
||||
#include "action_layer.h"
|
||||
#include "eeconfig.h"
|
||||
|
||||
extern keymap_config_t keymap_config;
|
||||
|
||||
@@ -141,28 +139,24 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
};
|
||||
|
||||
void persistent_default_layer_set(uint16_t default_layer) {
|
||||
eeconfig_update_default_layer(default_layer);
|
||||
default_layer_set(default_layer);
|
||||
}
|
||||
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
switch (keycode) {
|
||||
case QWERTY:
|
||||
if (record->event.pressed) {
|
||||
persistent_default_layer_set(1UL<<_QWERTY);
|
||||
set_single_persistent_default_layer(_QWERTY);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case COLEMAK:
|
||||
if (record->event.pressed) {
|
||||
persistent_default_layer_set(1UL<<_COLEMAK);
|
||||
set_single_persistent_default_layer(_COLEMAK);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case DVORAK:
|
||||
if (record->event.pressed) {
|
||||
persistent_default_layer_set(1UL<<_DVORAK);
|
||||
set_single_persistent_default_layer(_DVORAK);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
|
@@ -1,3 +1 @@
|
||||
ifndef QUANTUM_DIR
|
||||
include ../../../../Makefile
|
||||
endif
|
||||
|
||||
|
@@ -53,10 +53,10 @@ OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
|
||||
# the appropriate keymap folder that will get included automatically
|
||||
#
|
||||
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
|
||||
MOUSEKEY_ENABLE = no # 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
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
NKRO_ENABLE = no # 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 = no # MIDI controls
|
||||
@@ -64,7 +64,6 @@ 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.
|
||||
USE_I2C = no
|
||||
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
|
||||
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
|
||||
|
||||
@@ -74,4 +73,4 @@ LAYOUTS = ortho_4x12
|
||||
|
||||
DEFAULT_FOLDER = vitamins_included/rev1
|
||||
|
||||
EXTRAFLAGS += -flto
|
||||
EXTRAFLAGS += -flto
|
||||
|
@@ -38,6 +38,14 @@ void eeprom_set_valid(bool valid)
|
||||
eeprom_update_byte(((void*)EEPROM_VERSION_ADDR), valid ? EEPROM_VERSION : 0xFF);
|
||||
}
|
||||
|
||||
void eeprom_reset(void)
|
||||
{
|
||||
// Set the Zeal60 specific EEPROM state as invalid.
|
||||
eeprom_set_valid(false);
|
||||
// Set the TMK/QMK EEPROM state as invalid.
|
||||
eeconfig_disable();
|
||||
}
|
||||
|
||||
#ifdef RAW_ENABLE
|
||||
|
||||
void raw_hid_receive( uint8_t *data, uint8_t length )
|
||||
@@ -54,7 +62,7 @@ void raw_hid_receive( uint8_t *data, uint8_t length )
|
||||
}
|
||||
case id_get_keyboard_value:
|
||||
{
|
||||
if ( command_data[0] == 0x01 )
|
||||
if ( command_data[0] == id_uptime )
|
||||
{
|
||||
uint32_t value = timer_read32();
|
||||
command_data[1] = (value >> 24 ) & 0xFF;
|
||||
@@ -81,9 +89,9 @@ void raw_hid_receive( uint8_t *data, uint8_t length )
|
||||
dynamic_keymap_set_keycode( command_data[0], command_data[1], command_data[2], ( command_data[3] << 8 ) | command_data[4] );
|
||||
break;
|
||||
}
|
||||
case id_dynamic_keymap_clear_all:
|
||||
case id_dynamic_keymap_reset:
|
||||
{
|
||||
dynamic_keymap_clear_all();
|
||||
dynamic_keymap_reset();
|
||||
break;
|
||||
}
|
||||
#endif // DYNAMIC_KEYMAP_ENABLE
|
||||
@@ -104,6 +112,21 @@ void raw_hid_receive( uint8_t *data, uint8_t length )
|
||||
break;
|
||||
}
|
||||
#endif // RGB_BACKLIGHT_ENABLED
|
||||
case id_eeprom_reset:
|
||||
{
|
||||
eeprom_reset();
|
||||
break;
|
||||
}
|
||||
case id_bootloader_jump:
|
||||
{
|
||||
// Need to send data back before the jump
|
||||
// Informs host that the command is handled
|
||||
raw_hid_send( data, length );
|
||||
// Give host time to read it
|
||||
wait_ms(100);
|
||||
bootloader_jump();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
// Unhandled message.
|
||||
@@ -119,6 +142,37 @@ void raw_hid_receive( uint8_t *data, uint8_t length )
|
||||
|
||||
#endif
|
||||
|
||||
void main_init(void)
|
||||
{
|
||||
// If the EEPROM has the magic, the data is good.
|
||||
// OK to load from EEPROM.
|
||||
if (eeprom_is_valid()) {
|
||||
#if RGB_BACKLIGHT_ENABLED
|
||||
backlight_config_load();
|
||||
#endif // RGB_BACKLIGHT_ENABLED
|
||||
} else {
|
||||
#if RGB_BACKLIGHT_ENABLED
|
||||
// If the EEPROM has not been saved before, or is out of date,
|
||||
// save the default values to the EEPROM. Default values
|
||||
// come from construction of the zeal_backlight_config instance.
|
||||
backlight_config_save();
|
||||
#endif // RGB_BACKLIGHT_ENABLED
|
||||
#ifdef DYNAMIC_KEYMAP_ENABLE
|
||||
// This resets the keymaps in EEPROM to what is in flash.
|
||||
dynamic_keymap_reset();
|
||||
#endif
|
||||
// Save the magic number last, in case saving was interrupted
|
||||
eeprom_set_valid(true);
|
||||
}
|
||||
#if RGB_BACKLIGHT_ENABLED
|
||||
// Initialize LED drivers for backlight.
|
||||
backlight_init_drivers();
|
||||
|
||||
backlight_timer_init();
|
||||
backlight_timer_enable();
|
||||
#endif // RGB_BACKLIGHT_ENABLED
|
||||
}
|
||||
|
||||
void bootmagic_lite(void)
|
||||
{
|
||||
// The lite version of TMK's bootmagic.
|
||||
@@ -131,19 +185,10 @@ void bootmagic_lite(void)
|
||||
wait_ms(DEBOUNCING_DELAY);
|
||||
matrix_scan();
|
||||
|
||||
// If the Esc and space bar are held down on power up,
|
||||
// If the Esc (matrix 0,0) is held down on power up,
|
||||
// reset the EEPROM valid state and jump to bootloader.
|
||||
// Assumes Esc is at [0,0] and spacebar is at [4,7].
|
||||
// This isn't very generalized, but we need something that doesn't
|
||||
// rely on user's keymaps in firmware or EEPROM.
|
||||
if ( ( matrix_get_row(0) & (1<<0) ) &&
|
||||
( matrix_get_row(4) & (1<<7) ) )
|
||||
{
|
||||
// Set the Zeal60 specific EEPROM state as invalid.
|
||||
eeprom_set_valid(false);
|
||||
// Set the TMK/QMK EEPROM state as invalid.
|
||||
eeconfig_disable();
|
||||
// Jump to bootloader.
|
||||
if ( matrix_get_row(0) & (1<<0) ) {
|
||||
eeprom_reset();
|
||||
bootloader_jump();
|
||||
}
|
||||
}
|
||||
@@ -151,43 +196,7 @@ void bootmagic_lite(void)
|
||||
void matrix_init_kb(void)
|
||||
{
|
||||
bootmagic_lite();
|
||||
|
||||
// If the EEPROM has the magic, the data is good.
|
||||
// OK to load from EEPROM.
|
||||
if (eeprom_is_valid())
|
||||
{
|
||||
#if RGB_BACKLIGHT_ENABLED
|
||||
backlight_config_load();
|
||||
#endif // RGB_BACKLIGHT_ENABLED
|
||||
// TODO: do something to "turn on" keymaps in EEPROM?
|
||||
}
|
||||
else
|
||||
{
|
||||
#if RGB_BACKLIGHT_ENABLED
|
||||
// If the EEPROM has not been saved before, or is out of date,
|
||||
// save the default values to the EEPROM. Default values
|
||||
// come from construction of the zeal_backlight_config instance.
|
||||
backlight_config_save();
|
||||
#endif // RGB_BACKLIGHT_ENABLED
|
||||
|
||||
#ifdef DYNAMIC_KEYMAP_ENABLE
|
||||
// This saves "empty" keymaps so it falls back to the keymaps
|
||||
// in the firmware (aka. progmem/flash)
|
||||
dynamic_keymap_clear_all();
|
||||
#endif
|
||||
|
||||
// Save the magic number last, in case saving was interrupted
|
||||
eeprom_set_valid(true);
|
||||
}
|
||||
|
||||
#if RGB_BACKLIGHT_ENABLED
|
||||
// Initialize LED drivers for backlight.
|
||||
backlight_init_drivers();
|
||||
|
||||
backlight_timer_init();
|
||||
backlight_timer_enable();
|
||||
#endif // RGB_BACKLIGHT_ENABLED
|
||||
|
||||
main_init();
|
||||
matrix_init_user();
|
||||
}
|
||||
|
||||
@@ -206,29 +215,22 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record)
|
||||
process_record_backlight(keycode, record);
|
||||
#endif // BACKLIGHT_ENABLED
|
||||
|
||||
switch(keycode)
|
||||
{
|
||||
switch(keycode) {
|
||||
case FN_MO13:
|
||||
if (record->event.pressed)
|
||||
{
|
||||
if (record->event.pressed) {
|
||||
layer_on(1);
|
||||
update_tri_layer(1, 2, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
layer_off(1);
|
||||
update_tri_layer(1, 2, 3);
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case FN_MO23:
|
||||
if (record->event.pressed)
|
||||
{
|
||||
if (record->event.pressed) {
|
||||
layer_on(2);
|
||||
update_tri_layer(1, 2, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
layer_off(2);
|
||||
update_tri_layer(1, 2, 3);
|
||||
}
|
||||
@@ -248,8 +250,7 @@ uint16_t keymap_function_id_to_action( uint16_t function_id )
|
||||
if ( function_id >= 0x0F00 && function_id <= 0x0FFF )
|
||||
{
|
||||
uint8_t id = function_id & 0xFF;
|
||||
switch ( id )
|
||||
{
|
||||
switch ( id ) {
|
||||
case TRIPLE_TAP_1_3:
|
||||
case TRIPLE_TAP_2_3:
|
||||
{
|
||||
@@ -294,24 +295,16 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
|
||||
{
|
||||
case TRIPLE_TAP_1_3:
|
||||
case TRIPLE_TAP_2_3:
|
||||
if (record->event.pressed)
|
||||
{
|
||||
if (record->event.pressed) {
|
||||
layer_on( id == TRIPLE_TAP_1_3 ? 1 : 2 );
|
||||
|
||||
if (record->tap.count && !record->tap.interrupted)
|
||||
{
|
||||
if (record->tap.count >= 3)
|
||||
{
|
||||
if (record->tap.count && !record->tap.interrupted) {
|
||||
if (record->tap.count >= 3) {
|
||||
layer_invert(3);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
record->tap.count = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
layer_off( id == TRIPLE_TAP_1_3 ? 1 : 2 );
|
||||
}
|
||||
break;
|
||||
|
@@ -24,10 +24,17 @@ enum zeal60_command_id
|
||||
id_set_keyboard_value,
|
||||
id_dynamic_keymap_get_keycode,
|
||||
id_dynamic_keymap_set_keycode,
|
||||
id_dynamic_keymap_clear_all,
|
||||
id_dynamic_keymap_reset,
|
||||
id_backlight_config_set_value,
|
||||
id_backlight_config_get_value,
|
||||
id_backlight_config_save,
|
||||
|
||||
id_eeprom_reset,
|
||||
id_bootloader_jump,
|
||||
id_unhandled = 0xFF,
|
||||
};
|
||||
|
||||
enum zeal60_keyboard_value_id
|
||||
{
|
||||
id_uptime = 0x01
|
||||
};
|
||||
|
||||
|
@@ -35,7 +35,7 @@ SEARCH_DIR(.)
|
||||
/* Memory Spaces Definitions */
|
||||
MEMORY
|
||||
{
|
||||
//rom (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000
|
||||
/*rom (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000*/
|
||||
rom (rx) : ORIGIN = 0x00004000, LENGTH = 0x0003C000
|
||||
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00020000
|
||||
bkupram (rwx) : ORIGIN = 0x47000000, LENGTH = 0x00002000
|
||||
@@ -45,9 +45,15 @@ MEMORY
|
||||
/* The stack size used by the application. NOTE: you need to adjust according to your application. */
|
||||
STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x8000;
|
||||
|
||||
/* The heap size used by the application. */
|
||||
HEAP_SIZE = DEFINED(HEAP_SIZE) ? HEAP_SIZE : DEFINED(__heap_size__) ? __heap_size__ : 0x800;
|
||||
|
||||
_srom = ORIGIN(rom);
|
||||
_lrom = LENGTH(rom);
|
||||
_erom = ORIGIN(rom) + LENGTH(rom);
|
||||
_sram = ORIGIN(ram);
|
||||
_lram = LENGTH(ram);
|
||||
_eram = ORIGIN(ram) + LENGTH(ram);
|
||||
|
||||
/* Section Definitions */
|
||||
SECTIONS
|
||||
@@ -153,6 +159,17 @@ SECTIONS
|
||||
_ezero = .;
|
||||
} > ram
|
||||
|
||||
/* .heap section for syscalls */
|
||||
.heap (NOLOAD) :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_end = .;
|
||||
end = .;
|
||||
_heap_start = .;
|
||||
. = . + HEAP_SIZE;
|
||||
_heap_end = .;
|
||||
} > ram
|
||||
|
||||
/* stack section */
|
||||
.stack (NOLOAD):
|
||||
{
|
||||
|
@@ -77,6 +77,6 @@ endef
|
||||
MSG_MAKE_TEST = $(eval $(call GENERATE_MSG_MAKE_TEST))$(MSG_MAKE_TEST_ACTUAL)
|
||||
MSG_TEST = Testing $(BOLD)$(TEST_NAME)$(NO_COLOR)
|
||||
MSG_CHECK_FILESIZE = Checking file size of $(TARGET).hex
|
||||
MSG_FILE_TOO_BIG = $(ERROR_COLOR)Your file is too big!$(NO_COLOR) $(CURRENT_SIZE)/$(MAX_SIZE) ($(OVER_SIZE) over)\n
|
||||
MSG_FILE_TOO_SMALL = Your file is too small! $(CURRENT_SIZE)/$(MAX_SIZE)\n
|
||||
MSG_FILE_JUST_RIGHT = File size is fine - $(CURRENT_SIZE)/$(MAX_SIZE) ($(FREE_SIZE) free)\n
|
||||
MSG_FILE_TOO_BIG = $(ERROR_COLOR)The firmware is too large!$(NO_COLOR) $(CURRENT_SIZE)/$(MAX_SIZE) ($(OVER_SIZE) bytes over)\n
|
||||
MSG_FILE_TOO_SMALL = The firmware is too small! $(CURRENT_SIZE)/$(MAX_SIZE)\n
|
||||
MSG_FILE_JUST_RIGHT = The firmware size is fine - $(CURRENT_SIZE)/$(MAX_SIZE) ($(FREE_SIZE) bytes free)\n
|
||||
|
@@ -23,57 +23,154 @@
|
||||
#define CUSTOM_MATRIX 2 /* Disables built-in matrix scanning code */
|
||||
|
||||
#ifdef __AVR__
|
||||
/* I/O pins */
|
||||
#ifndef F0
|
||||
#define B0 0x30
|
||||
#define B1 0x31
|
||||
#define B2 0x32
|
||||
#define B3 0x33
|
||||
#define B4 0x34
|
||||
#define B5 0x35
|
||||
#define B6 0x36
|
||||
#define B7 0x37
|
||||
#define C0 0x60
|
||||
#define C1 0x61
|
||||
#define C2 0x62
|
||||
#define C3 0x63
|
||||
#define C4 0x64
|
||||
#define C5 0x65
|
||||
#define C6 0x66
|
||||
#define C7 0x67
|
||||
#define D0 0x90
|
||||
#define D1 0x91
|
||||
#define D2 0x92
|
||||
#define D3 0x93
|
||||
#define D4 0x94
|
||||
#define D5 0x95
|
||||
#define D6 0x96
|
||||
#define D7 0x97
|
||||
#define E0 0xC0
|
||||
#define E1 0xC1
|
||||
#define E2 0xC2
|
||||
#define E3 0xC3
|
||||
#define E4 0xC4
|
||||
#define E5 0xC5
|
||||
#define E6 0xC6
|
||||
#define E7 0xC7
|
||||
#define F0 0xF0
|
||||
#define F1 0xF1
|
||||
#define F2 0xF2
|
||||
#define F3 0xF3
|
||||
#define F4 0xF4
|
||||
#define F5 0xF5
|
||||
#define F6 0xF6
|
||||
#define F7 0xF7
|
||||
#define A0 0x00
|
||||
#define A1 0x01
|
||||
#define A2 0x02
|
||||
#define A3 0x03
|
||||
#define A4 0x04
|
||||
#define A5 0x05
|
||||
#define A6 0x06
|
||||
#define A7 0x07
|
||||
#endif
|
||||
/* I/O pins */
|
||||
#ifndef F0
|
||||
#define B0 0x30
|
||||
#define B1 0x31
|
||||
#define B2 0x32
|
||||
#define B3 0x33
|
||||
#define B4 0x34
|
||||
#define B5 0x35
|
||||
#define B6 0x36
|
||||
#define B7 0x37
|
||||
#define C0 0x60
|
||||
#define C1 0x61
|
||||
#define C2 0x62
|
||||
#define C3 0x63
|
||||
#define C4 0x64
|
||||
#define C5 0x65
|
||||
#define C6 0x66
|
||||
#define C7 0x67
|
||||
#define D0 0x90
|
||||
#define D1 0x91
|
||||
#define D2 0x92
|
||||
#define D3 0x93
|
||||
#define D4 0x94
|
||||
#define D5 0x95
|
||||
#define D6 0x96
|
||||
#define D7 0x97
|
||||
#define E0 0xC0
|
||||
#define E1 0xC1
|
||||
#define E2 0xC2
|
||||
#define E3 0xC3
|
||||
#define E4 0xC4
|
||||
#define E5 0xC5
|
||||
#define E6 0xC6
|
||||
#define E7 0xC7
|
||||
#define F0 0xF0
|
||||
#define F1 0xF1
|
||||
#define F2 0xF2
|
||||
#define F3 0xF3
|
||||
#define F4 0xF4
|
||||
#define F5 0xF5
|
||||
#define F6 0xF6
|
||||
#define F7 0xF7
|
||||
#define A0 0x00
|
||||
#define A1 0x01
|
||||
#define A2 0x02
|
||||
#define A3 0x03
|
||||
#define A4 0x04
|
||||
#define A5 0x05
|
||||
#define A6 0x06
|
||||
#define A7 0x07
|
||||
#endif
|
||||
#elif defined(PROTOCOL_CHIBIOS)
|
||||
#define A0 PAL_LINE(GPIOA, 0)
|
||||
#define A1 PAL_LINE(GPIOA, 1)
|
||||
#define A2 PAL_LINE(GPIOA, 2)
|
||||
#define A3 PAL_LINE(GPIOA, 3)
|
||||
#define A4 PAL_LINE(GPIOA, 4)
|
||||
#define A5 PAL_LINE(GPIOA, 5)
|
||||
#define A6 PAL_LINE(GPIOA, 6)
|
||||
#define A7 PAL_LINE(GPIOA, 7)
|
||||
#define A8 PAL_LINE(GPIOA, 8)
|
||||
#define A9 PAL_LINE(GPIOA, 9)
|
||||
#define A10 PAL_LINE(GPIOA, 10)
|
||||
#define A11 PAL_LINE(GPIOA, 11)
|
||||
#define A12 PAL_LINE(GPIOA, 12)
|
||||
#define A13 PAL_LINE(GPIOA, 13)
|
||||
#define A14 PAL_LINE(GPIOA, 14)
|
||||
#define A15 PAL_LINE(GPIOA, 15)
|
||||
#define B0 PAL_LINE(GPIOB, 0)
|
||||
#define B1 PAL_LINE(GPIOB, 1)
|
||||
#define B2 PAL_LINE(GPIOB, 2)
|
||||
#define B3 PAL_LINE(GPIOB, 3)
|
||||
#define B4 PAL_LINE(GPIOB, 4)
|
||||
#define B5 PAL_LINE(GPIOB, 5)
|
||||
#define B6 PAL_LINE(GPIOB, 6)
|
||||
#define B7 PAL_LINE(GPIOB, 7)
|
||||
#define B8 PAL_LINE(GPIOB, 8)
|
||||
#define B9 PAL_LINE(GPIOB, 9)
|
||||
#define B10 PAL_LINE(GPIOB, 10)
|
||||
#define B11 PAL_LINE(GPIOB, 11)
|
||||
#define B12 PAL_LINE(GPIOB, 12)
|
||||
#define B13 PAL_LINE(GPIOB, 13)
|
||||
#define B14 PAL_LINE(GPIOB, 14)
|
||||
#define B15 PAL_LINE(GPIOB, 15)
|
||||
#define C0 PAL_LINE(GPIOC, 0)
|
||||
#define C1 PAL_LINE(GPIOC, 1)
|
||||
#define C2 PAL_LINE(GPIOC, 2)
|
||||
#define C3 PAL_LINE(GPIOC, 3)
|
||||
#define C4 PAL_LINE(GPIOC, 4)
|
||||
#define C5 PAL_LINE(GPIOC, 5)
|
||||
#define C6 PAL_LINE(GPIOC, 6)
|
||||
#define C7 PAL_LINE(GPIOC, 7)
|
||||
#define C8 PAL_LINE(GPIOC, 8)
|
||||
#define C9 PAL_LINE(GPIOC, 9)
|
||||
#define C10 PAL_LINE(GPIOC, 10)
|
||||
#define C11 PAL_LINE(GPIOC, 11)
|
||||
#define C12 PAL_LINE(GPIOC, 12)
|
||||
#define C13 PAL_LINE(GPIOC, 13)
|
||||
#define C14 PAL_LINE(GPIOC, 14)
|
||||
#define C15 PAL_LINE(GPIOC, 15)
|
||||
#define D0 PAL_LINE(GPIOD, 0)
|
||||
#define D1 PAL_LINE(GPIOD, 1)
|
||||
#define D2 PAL_LINE(GPIOD, 2)
|
||||
#define D3 PAL_LINE(GPIOD, 3)
|
||||
#define D4 PAL_LINE(GPIOD, 4)
|
||||
#define D5 PAL_LINE(GPIOD, 5)
|
||||
#define D6 PAL_LINE(GPIOD, 6)
|
||||
#define D7 PAL_LINE(GPIOD, 7)
|
||||
#define D8 PAL_LINE(GPIOD, 8)
|
||||
#define D9 PAL_LINE(GPIOD, 9)
|
||||
#define D10 PAL_LINE(GPIOD, 10)
|
||||
#define D11 PAL_LINE(GPIOD, 11)
|
||||
#define D12 PAL_LINE(GPIOD, 12)
|
||||
#define D13 PAL_LINE(GPIOD, 13)
|
||||
#define D14 PAL_LINE(GPIOD, 14)
|
||||
#define D15 PAL_LINE(GPIOD, 15)
|
||||
#define E0 PAL_LINE(GPIOE, 0)
|
||||
#define E1 PAL_LINE(GPIOE, 1)
|
||||
#define E2 PAL_LINE(GPIOE, 2)
|
||||
#define E3 PAL_LINE(GPIOE, 3)
|
||||
#define E4 PAL_LINE(GPIOE, 4)
|
||||
#define E5 PAL_LINE(GPIOE, 5)
|
||||
#define E6 PAL_LINE(GPIOE, 6)
|
||||
#define E7 PAL_LINE(GPIOE, 7)
|
||||
#define E8 PAL_LINE(GPIOE, 8)
|
||||
#define E9 PAL_LINE(GPIOE, 9)
|
||||
#define E10 PAL_LINE(GPIOE, 10)
|
||||
#define E11 PAL_LINE(GPIOE, 11)
|
||||
#define E12 PAL_LINE(GPIOE, 12)
|
||||
#define E13 PAL_LINE(GPIOE, 13)
|
||||
#define E14 PAL_LINE(GPIOE, 14)
|
||||
#define E15 PAL_LINE(GPIOE, 15)
|
||||
#define F0 PAL_LINE(GPIOF, 0)
|
||||
#define F1 PAL_LINE(GPIOF, 1)
|
||||
#define F2 PAL_LINE(GPIOF, 2)
|
||||
#define F3 PAL_LINE(GPIOF, 3)
|
||||
#define F4 PAL_LINE(GPIOF, 4)
|
||||
#define F5 PAL_LINE(GPIOF, 5)
|
||||
#define F6 PAL_LINE(GPIOF, 6)
|
||||
#define F7 PAL_LINE(GPIOF, 7)
|
||||
#define F8 PAL_LINE(GPIOF, 8)
|
||||
#define F9 PAL_LINE(GPIOF, 9)
|
||||
#define F10 PAL_LINE(GPIOF, 10)
|
||||
#define F11 PAL_LINE(GPIOF, 11)
|
||||
#define F12 PAL_LINE(GPIOF, 12)
|
||||
#define F13 PAL_LINE(GPIOF, 13)
|
||||
#define F14 PAL_LINE(GPIOF, 14)
|
||||
#define F15 PAL_LINE(GPIOF, 15)
|
||||
#endif
|
||||
|
||||
/* USART configuration */
|
||||
|
@@ -16,6 +16,8 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "keymap.h" // to get keymaps[][][]
|
||||
#include "tmk_core/common/eeprom.h"
|
||||
#include "progmem.h"// to read default from flash
|
||||
|
||||
#include "dynamic_keymap.h"
|
||||
|
||||
@@ -29,8 +31,6 @@
|
||||
#error DYNAMIC_KEYMAP_LAYER_COUNT not defined
|
||||
#endif
|
||||
|
||||
#define KC_EENULL 0xFFFF // TODO: move to enum quantum_keycodes
|
||||
|
||||
void *dynamic_keymap_key_to_eeprom_address(uint8_t layer, uint8_t row, uint8_t column)
|
||||
{
|
||||
// TODO: optimize this with some left shifts
|
||||
@@ -55,16 +55,15 @@ void dynamic_keymap_set_keycode(uint8_t layer, uint8_t row, uint8_t column, uint
|
||||
eeprom_update_byte(address+1, (uint8_t)(keycode & 0xFF));
|
||||
}
|
||||
|
||||
void dynamic_keymap_clear_all(void)
|
||||
void dynamic_keymap_reset(void)
|
||||
{
|
||||
// Save "empty" keymaps.
|
||||
for ( int layer = 0; layer < DYNAMIC_KEYMAP_LAYER_COUNT; layer++ )
|
||||
{
|
||||
for ( int row = 0; row < MATRIX_ROWS; row++ )
|
||||
{
|
||||
for ( int column = 0; column < MATRIX_COLS; column++ )
|
||||
{
|
||||
dynamic_keymap_set_keycode(layer, row, column, KC_EENULL);
|
||||
// Reset the keymaps in EEPROM to what is in flash.
|
||||
// All keyboards using dynamic keymaps should define a layout
|
||||
// for the same number of layers as DYNAMIC_KEYMAP_LAYER_COUNT.
|
||||
for ( int layer = 0; layer < DYNAMIC_KEYMAP_LAYER_COUNT; layer++ ) {
|
||||
for ( int row = 0; row < MATRIX_ROWS; row++ ) {
|
||||
for ( int column = 0; column < MATRIX_COLS; column++ ) {
|
||||
dynamic_keymap_set_keycode(layer, row, column, pgm_read_word(&keymaps[layer][row][column]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -73,24 +72,13 @@ void dynamic_keymap_clear_all(void)
|
||||
// This overrides the one in quantum/keymap_common.c
|
||||
uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
|
||||
{
|
||||
// This used to test EEPROM for magic bytes, but it was redundant.
|
||||
// Test for EEPROM usage change (fresh install, address change, etc.)
|
||||
// externally and call dynamic_keymap_default_save()
|
||||
if ( layer < DYNAMIC_KEYMAP_LAYER_COUNT &&
|
||||
key.row < MATRIX_ROWS && // possibly redundant
|
||||
key.col < MATRIX_COLS ) // possibly redundant
|
||||
{
|
||||
uint16_t keycode = dynamic_keymap_get_keycode(layer, key.row, key.col);
|
||||
|
||||
// If keycode is not "empty", return it, otherwise
|
||||
// drop down to return the one in flash
|
||||
if ( keycode != KC_EENULL)
|
||||
{
|
||||
return keycode;
|
||||
}
|
||||
key.row < MATRIX_ROWS &&
|
||||
key.col < MATRIX_COLS ) {
|
||||
return dynamic_keymap_get_keycode(layer, key.row, key.col);
|
||||
} else {
|
||||
return KC_NO;
|
||||
}
|
||||
|
||||
return pgm_read_word(&keymaps[layer][key.row][key.col]);
|
||||
}
|
||||
|
||||
#endif // DYNAMIC_KEYMAP_ENABLE
|
||||
|
@@ -13,9 +13,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef DYNAMIC_KEYMAP_H
|
||||
#define DYNAMIC_KEYMAP_H
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
@@ -23,9 +21,8 @@
|
||||
void *dynamic_keymap_key_to_eeprom_address(uint8_t layer, uint8_t row, uint8_t column);
|
||||
uint16_t dynamic_keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t column);
|
||||
void dynamic_keymap_set_keycode(uint8_t layer, uint8_t row, uint8_t column, uint16_t keycode);
|
||||
void dynamic_keymap_clear_all(void);
|
||||
void dynamic_keymap_reset(void);
|
||||
|
||||
// This overrides the one in quantum/keymap_common.c
|
||||
// uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key);
|
||||
|
||||
#endif //DYNAMIC_KEYMAP_H
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2012-2017 Jun Wako, Jack Humbert
|
||||
Copyright 2012-2018 Jun Wako, Jack Humbert, Yiancar
|
||||
|
||||
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
|
||||
@@ -16,15 +16,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#if defined(__AVR__)
|
||||
#include <avr/io.h>
|
||||
#endif
|
||||
#include "wait.h"
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "util.h"
|
||||
#include "matrix.h"
|
||||
#include "timer.h"
|
||||
#include "quantum.h"
|
||||
|
||||
|
||||
/* Set 0 if debouncing isn't needed */
|
||||
@@ -60,8 +58,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#endif
|
||||
|
||||
#if (DIODE_DIRECTION == ROW2COL) || (DIODE_DIRECTION == COL2ROW)
|
||||
static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
|
||||
static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
|
||||
static const pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
|
||||
static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
|
||||
#endif
|
||||
|
||||
/* matrix state(1:on, 0:off) */
|
||||
@@ -271,9 +269,7 @@ uint8_t matrix_key_count(void)
|
||||
static void init_cols(void)
|
||||
{
|
||||
for(uint8_t x = 0; x < MATRIX_COLS; x++) {
|
||||
uint8_t pin = col_pins[x];
|
||||
_SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN
|
||||
_SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI
|
||||
setPinInputHigh(col_pins[x]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,8 +289,7 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
|
||||
for(uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
|
||||
|
||||
// Select the col pin to read (active low)
|
||||
uint8_t pin = col_pins[col_index];
|
||||
uint8_t pin_state = (_SFR_IO8(pin >> 4) & _BV(pin & 0xF));
|
||||
uint8_t pin_state = readPin(col_pins[col_index]);
|
||||
|
||||
// Populate the matrix row with the state of the col pin
|
||||
current_matrix[current_row] |= pin_state ? 0 : (ROW_SHIFTER << col_index);
|
||||
@@ -308,24 +303,19 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
|
||||
|
||||
static void select_row(uint8_t row)
|
||||
{
|
||||
uint8_t pin = row_pins[row];
|
||||
_SFR_IO8((pin >> 4) + 1) |= _BV(pin & 0xF); // OUT
|
||||
_SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF); // LOW
|
||||
setPinOutput(row_pins[row]);
|
||||
writePinLow(row_pins[row]);
|
||||
}
|
||||
|
||||
static void unselect_row(uint8_t row)
|
||||
{
|
||||
uint8_t pin = row_pins[row];
|
||||
_SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN
|
||||
_SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI
|
||||
setPinInputHigh(row_pins[row]);
|
||||
}
|
||||
|
||||
static void unselect_rows(void)
|
||||
{
|
||||
for(uint8_t x = 0; x < MATRIX_ROWS; x++) {
|
||||
uint8_t pin = row_pins[x];
|
||||
_SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN
|
||||
_SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI
|
||||
setPinInput(row_pins[x]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,9 +324,7 @@ static void unselect_rows(void)
|
||||
static void init_rows(void)
|
||||
{
|
||||
for(uint8_t x = 0; x < MATRIX_ROWS; x++) {
|
||||
uint8_t pin = row_pins[x];
|
||||
_SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN
|
||||
_SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI
|
||||
setPinInputHigh(row_pins[x]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,7 +344,7 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
|
||||
matrix_row_t last_row_value = current_matrix[row_index];
|
||||
|
||||
// Check row pin state
|
||||
if ((_SFR_IO8(row_pins[row_index] >> 4) & _BV(row_pins[row_index] & 0xF)) == 0)
|
||||
if (readPin(row_pins[row_index]) == 0)
|
||||
{
|
||||
// Pin LO, set col bit
|
||||
current_matrix[row_index] |= (ROW_SHIFTER << current_col);
|
||||
@@ -382,24 +370,19 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
|
||||
|
||||
static void select_col(uint8_t col)
|
||||
{
|
||||
uint8_t pin = col_pins[col];
|
||||
_SFR_IO8((pin >> 4) + 1) |= _BV(pin & 0xF); // OUT
|
||||
_SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF); // LOW
|
||||
setPinOutput(col_pins[col]);
|
||||
writePinLow(col_pins[col]);
|
||||
}
|
||||
|
||||
static void unselect_col(uint8_t col)
|
||||
{
|
||||
uint8_t pin = col_pins[col];
|
||||
_SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN
|
||||
_SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI
|
||||
setPinInputHigh(col_pins[col]);
|
||||
}
|
||||
|
||||
static void unselect_cols(void)
|
||||
{
|
||||
for(uint8_t x = 0; x < MATRIX_COLS; x++) {
|
||||
uint8_t pin = col_pins[x];
|
||||
_SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN
|
||||
_SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI
|
||||
setPinInputHigh(col_pins[x]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#endif // !AUDIO_CLICKY_FREQ_RANDOMNESS
|
||||
|
||||
float clicky_freq = AUDIO_CLICKY_FREQ_DEFAULT;
|
||||
float clicky_rand = AUDIO_CLICKY_FREQ_RANDOMNESS;
|
||||
float clicky_song[][2] = {{AUDIO_CLICKY_FREQ_DEFAULT, 3}, {AUDIO_CLICKY_FREQ_DEFAULT, 1}}; // 3 and 1 --> durations
|
||||
|
||||
extern audio_config_t audio_config;
|
||||
@@ -33,8 +34,8 @@ void clicky_play(void) {
|
||||
#ifndef NO_MUSIC_MODE
|
||||
if (music_activated || midi_activated) return;
|
||||
#endif // !NO_MUSIC_MODE
|
||||
clicky_song[0][0] = 2.0f * clicky_freq * (1.0f + AUDIO_CLICKY_FREQ_RANDOMNESS * ( ((float)rand()) / ((float)(RAND_MAX)) ) );
|
||||
clicky_song[1][0] = clicky_freq * (1.0f + AUDIO_CLICKY_FREQ_RANDOMNESS * ( ((float)rand()) / ((float)(RAND_MAX)) ) );
|
||||
clicky_song[0][0] = 2.0f * clicky_freq * (1.0f + clicky_rand * ( ((float)rand()) / ((float)(RAND_MAX)) ) );
|
||||
clicky_song[1][0] = clicky_freq * (1.0f + clicky_rand * ( ((float)rand()) / ((float)(RAND_MAX)) ) );
|
||||
PLAY_SONG(clicky_song);
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2016-2017 Erez Zukerman, Jack Humbert
|
||||
/* Copyright 2016-2018 Erez Zukerman, Jack Humbert, Yiancar
|
||||
*
|
||||
* 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
|
||||
@@ -17,9 +17,12 @@
|
||||
#define QUANTUM_H
|
||||
|
||||
#if defined(__AVR__)
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#endif
|
||||
#if defined(PROTOCOL_CHIBIOS)
|
||||
#include "hal.h"
|
||||
#endif
|
||||
#include "wait.h"
|
||||
#include "matrix.h"
|
||||
@@ -33,11 +36,11 @@
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
#include "rgblight.h"
|
||||
#else
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
/* dummy define RGBLIGHT_MODE_xxxx */
|
||||
#define RGBLIGHT_H_DUMMY_DEFINE
|
||||
#include "rgblight.h"
|
||||
#endif
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
/* dummy define RGBLIGHT_MODE_xxxx */
|
||||
#define RGBLIGHT_H_DUMMY_DEFINE
|
||||
#include "rgblight.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SPLIT_KEYBOARD
|
||||
@@ -76,9 +79,9 @@ extern uint32_t default_layer_state;
|
||||
#ifdef AUDIO_ENABLE
|
||||
#include "audio.h"
|
||||
#include "process_audio.h"
|
||||
#ifdef AUDIO_CLICKY
|
||||
#include "process_clicky.h"
|
||||
#endif // AUDIO_CLICKY
|
||||
#ifdef AUDIO_CLICKY
|
||||
#include "process_clicky.h"
|
||||
#endif // AUDIO_CLICKY
|
||||
#endif
|
||||
|
||||
#ifdef STENO_ENABLE
|
||||
@@ -133,6 +136,48 @@ extern uint32_t default_layer_state;
|
||||
#include "hd44780.h"
|
||||
#endif
|
||||
|
||||
//Function substitutions to ease GPIO manipulation
|
||||
#ifdef __AVR__
|
||||
#define pin_t uint8_t
|
||||
#define setPinInput(pin) _SFR_IO8((pin >> 4) + 1) &= ~ _BV(pin & 0xF)
|
||||
#define setPinInputHigh(pin) ({\
|
||||
_SFR_IO8((pin >> 4) + 1) &= ~ _BV(pin & 0xF);\
|
||||
_SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF);\
|
||||
})
|
||||
#define setPinInputLow(pin) _Static_assert(0, "AVR Processors cannot impliment an input as pull low")
|
||||
#define setPinOutput(pin) _SFR_IO8((pin >> 4) + 1) |= _BV(pin & 0xF)
|
||||
|
||||
#define writePinHigh(pin) _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF)
|
||||
#define writePinLow(pin) _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF)
|
||||
static inline void writePin(pin_t pin, uint8_t level){
|
||||
if (level){
|
||||
_SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF);
|
||||
} else {
|
||||
_SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF);
|
||||
}
|
||||
}
|
||||
|
||||
#define readPin(pin) (_SFR_IO8(pin >> 4) & _BV(pin & 0xF))
|
||||
#elif defined(PROTOCOL_CHIBIOS)
|
||||
#define pin_t ioline_t
|
||||
#define setPinInput(pin) palSetLineMode(pin, PAL_MODE_INPUT)
|
||||
#define setPinInputHigh(pin) palSetLineMode(pin, PAL_MODE_INPUT_PULLUP)
|
||||
#define setPinInputLow(pin) palSetLineMode(pin, PAL_MODE_INPUT_PULLDOWN)
|
||||
#define setPinOutput(pin) palSetLineMode(pin, PAL_MODE_OUTPUT_PUSHPULL)
|
||||
|
||||
#define writePinHigh(pin) palSetLine(pin)
|
||||
#define writePinLow(pin) palClearLine(pin)
|
||||
static inline void writePin(pin_t pin, uint8_t level){
|
||||
if (level){
|
||||
palSetLine(pin);
|
||||
} else {
|
||||
palClearLine(pin);
|
||||
}
|
||||
}
|
||||
|
||||
#define readPin(pin) palReadLine(pin)
|
||||
#endif
|
||||
|
||||
#define STRINGIZE(z) #z
|
||||
#define ADD_SLASH_X(y) STRINGIZE(\x ## y)
|
||||
#define SYMBOL_STR(x) ADD_SLASH_X(x)
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include "progmem.h"
|
||||
#include "config.h"
|
||||
#include "eeprom.h"
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
rgb_config_t rgb_matrix_config;
|
||||
|
@@ -355,24 +355,6 @@ void matrix_slave_scan(void) {
|
||||
for (int i = 0; i < ROWS_PER_HAND; ++i) {
|
||||
serial_slave_buffer[i] = matrix[offset+i];
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_I2C
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
// Read backlight level sent from master and update level on slave
|
||||
backlight_set(i2c_slave_buffer[0]);
|
||||
#endif
|
||||
for (int i = 0; i < ROWS_PER_HAND; ++i) {
|
||||
i2c_slave_buffer[i+1] = matrix[offset+i];
|
||||
}
|
||||
#else // USE_SERIAL
|
||||
for (int i = 0; i < ROWS_PER_HAND; ++i) {
|
||||
serial_slave_buffer[i] = matrix[offset+i];
|
||||
}
|
||||
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
// Read backlight level sent from master and update level on slave
|
||||
backlight_set(serial_master_buffer[SERIAL_BACKLIT_START]);
|
||||
#endif
|
||||
#endif
|
||||
matrix_slave_scan_user();
|
||||
}
|
||||
|
@@ -106,14 +106,14 @@ void keyboard_slave_loop(void) {
|
||||
|
||||
// Read Backlight Info
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
if (BACKLIT_DIRTY) {
|
||||
#ifdef USE_I2C
|
||||
#ifdef USE_I2C
|
||||
if (BACKLIT_DIRTY) {
|
||||
backlight_set(i2c_slave_buffer[I2C_BACKLIT_START]);
|
||||
#else // USE_SERIAL
|
||||
backlight_set(serial_master_buffer[SERIAL_BACKLIT_START]);
|
||||
#endif
|
||||
BACKLIT_DIRTY = false;
|
||||
}
|
||||
BACKLIT_DIRTY = false;
|
||||
}
|
||||
#else // USE_SERIAL
|
||||
backlight_set(serial_master_buffer[SERIAL_BACKLIT_START]);
|
||||
#endif
|
||||
#endif
|
||||
// Read RGB Info
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
|
@@ -36,7 +36,7 @@ LDFLAGS +=-Wl,--gc-sections
|
||||
LDFLAGS += -Wl,-Map="%OUT%%PROJ_NAME%.map"
|
||||
LDFLAGS += -Wl,--start-group
|
||||
LDFLAGS += -Wl,--end-group
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += --specs=rdimon.specs
|
||||
LDFLAGS += -T$(LIB_PATH)/arm_atsam/packs/atmel/SAMD51_DFP/1.0.70/gcc/gcc/samd51j18a_flash.ld
|
||||
|
||||
OPT_DEFS += -DPROTOCOL_ARM_ATSAM
|
||||
|
@@ -169,7 +169,8 @@ dfu-ee: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep
|
||||
fi
|
||||
$(DFU_PROGRAMMER) $(MCU) reset
|
||||
|
||||
avrdude: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware
|
||||
define EXEC_AVRDUDE
|
||||
USB= ;\
|
||||
if $(GREP) -q -s Microsoft /proc/version; then \
|
||||
echo 'ERROR: AVR flashing cannot be automated within the Windows Subsystem for Linux (WSL) currently. Instead, take the .hex file generated and flash it using AVRDUDE, AVRDUDESS, or XLoader.'; \
|
||||
else \
|
||||
@@ -191,6 +192,15 @@ avrdude: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware
|
||||
sleep 1; \
|
||||
avrdude -p $(MCU) -c avr109 -P $$USB -U flash:w:$(BUILD_DIR)/$(TARGET).hex; \
|
||||
fi
|
||||
endef
|
||||
|
||||
avrdude: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware
|
||||
$(call EXEC_AVRDUDE)
|
||||
|
||||
avrdude-loop: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware
|
||||
while true; do \
|
||||
$(call EXEC_AVRDUDE) ; \
|
||||
done
|
||||
|
||||
# Convert hex to bin.
|
||||
bin: $(BUILD_DIR)/$(TARGET).hex
|
||||
|
@@ -198,10 +198,13 @@ ifneq ("$(SERIAL)","")
|
||||
DFU_ARGS += -S $(SERIAL)
|
||||
endif
|
||||
|
||||
ST_LINK_ARGS ?=
|
||||
|
||||
# List any extra directories to look for libraries here.
|
||||
EXTRALIBDIRS = $(RULESPATH)/ld
|
||||
|
||||
DFU_UTIL ?= dfu-util
|
||||
ST_LINK_CLI ?= st-link_cli
|
||||
|
||||
# Generate a .qmk for the QMK-FF
|
||||
qmk: $(BUILD_DIR)/$(TARGET).bin
|
||||
@@ -230,5 +233,8 @@ qmk: $(BUILD_DIR)/$(TARGET).bin
|
||||
dfu-util: $(BUILD_DIR)/$(TARGET).bin cpfirmware sizeafter
|
||||
$(DFU_UTIL) $(DFU_ARGS) -D $(BUILD_DIR)/$(TARGET).bin
|
||||
|
||||
st-link-cli: $(BUILD_DIR)/$(TARGET).hex sizeafter
|
||||
$(ST_LINK_CLI) $(ST_LINK_ARGS) -q -c SWD -p $(BUILD_DIR)/$(TARGET).hex -Rst
|
||||
|
||||
bin: $(BUILD_DIR)/$(TARGET).bin sizeafter
|
||||
$(COPY) $(BUILD_DIR)/$(TARGET).bin $(TARGET).bin;
|
||||
|
@@ -16,25 +16,27 @@
|
||||
|
||||
#include "bootloader.h"
|
||||
#include "samd51j18a.h"
|
||||
#include "md_bootloader.h"
|
||||
|
||||
//Set watchdog timer to reset. Directs the bootloader to stay in programming mode.
|
||||
void bootloader_jump(void)
|
||||
{
|
||||
//Keyboards released with certain bootloader can not enter bootloader from app until workaround is created
|
||||
uint8_t ver_no_jump[] = "v2.18Jun 22 2018 17:28:08";
|
||||
uint8_t *ver_check = ver_no_jump;
|
||||
uint8_t *boot_check = (uint8_t *)0x21A0;
|
||||
while (*ver_check && *boot_check == *ver_check)
|
||||
{
|
||||
ver_check++;
|
||||
boot_check++;
|
||||
void bootloader_jump(void) {
|
||||
#ifdef KEYBOARD_massdrop_ctrl
|
||||
//CTRL keyboards released with bootloader version below must use RAM method. Otherwise use WDT method.
|
||||
uint8_t ver_ram_method[] = "v2.18Jun 22 2018 17:28:08"; //The version to match (NULL terminated by compiler)
|
||||
uint8_t *ver_check = ver_ram_method; //Pointer to version match string for traversal
|
||||
uint8_t *ver_rom = (uint8_t *)0x21A0; //Pointer to address in ROM where this specific bootloader version would exist
|
||||
|
||||
while (*ver_check && *ver_rom == *ver_check) { //While there are check version characters to match and bootloader's version matches check's version
|
||||
ver_check++; //Move check version pointer to next character
|
||||
ver_rom++; //Move ROM version pointer to next character
|
||||
}
|
||||
if (!*ver_check)
|
||||
{
|
||||
//Version match
|
||||
//Software workaround would go here
|
||||
return; //No software restart method implemented... must use hardware reset button
|
||||
|
||||
if (!*ver_check) { //If check version pointer is NULL, all characters have matched
|
||||
*MAGIC_ADDR = BOOTLOADER_MAGIC; //Set magic number into RAM
|
||||
NVIC_SystemReset(); //Perform system reset
|
||||
while (1) {} //Won't get here
|
||||
}
|
||||
#endif
|
||||
|
||||
WDT->CTRLA.bit.ENABLE = 0;
|
||||
while (WDT->SYNCBUSY.bit.ENABLE) {}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#ifndef _PRINTF_H_
|
||||
#define _PRINTF_H_
|
||||
|
||||
#define __xprintf dpf
|
||||
int dpf(const char *_Format, ...);
|
||||
#define __xprintf dpf
|
||||
|
||||
#endif //_PRINTF_H_
|
||||
|
||||
|
@@ -29,7 +29,7 @@
|
||||
#include <stdbool.h>
|
||||
#include "util.h"
|
||||
|
||||
#if defined(PROTOCOL_CHIBIOS)
|
||||
#if defined(PROTOCOL_CHIBIOS) || defined(PROTOCOL_ARM_ATSAM)
|
||||
#define PSTR(x) x
|
||||
#endif
|
||||
|
||||
|
@@ -10,7 +10,6 @@ SRC += $(ARM_ATSAM_DIR)/spi.c
|
||||
SRC += $(ARM_ATSAM_DIR)/startup.c
|
||||
|
||||
SRC += $(ARM_ATSAM_DIR)/usb/main_usb.c
|
||||
SRC += $(ARM_ATSAM_DIR)/usb/spfssf.c
|
||||
SRC += $(ARM_ATSAM_DIR)/usb/udc.c
|
||||
SRC += $(ARM_ATSAM_DIR)/usb/udi_cdc.c
|
||||
SRC += $(ARM_ATSAM_DIR)/usb/udi_hid.c
|
||||
|
@@ -36,7 +36,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include "issi3733_driver.h"
|
||||
#include "./usb/compiler.h"
|
||||
#include "./usb/udc.h"
|
||||
#include "./usb/spfssf.h"
|
||||
#include "./usb/udi_cdc.h"
|
||||
|
||||
#endif //MD_BOOTLOADER
|
||||
|
@@ -32,6 +32,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#define m15_on REG_PORT_OUTSET1 = 0x40000000 //PB30 High
|
||||
#define m15_off REG_PORT_OUTCLR1 = 0x40000000 //PB30 Low
|
||||
|
||||
//Debug Port PB23
|
||||
#define m27_ena REG_PORT_DIRSET1 = 0x800000 //PB23 Output
|
||||
#define m27_on REG_PORT_OUTSET1 = 0x800000 //PB23 High
|
||||
#define m27_off REG_PORT_OUTCLR1 = 0x800000 //PB23 Low
|
||||
|
||||
//Debug Port PB31
|
||||
#define m28_ena REG_PORT_DIRSET1 = 0x80000000 //PB31 Output
|
||||
#define m28_on REG_PORT_OUTSET1 = 0x80000000 //PB31 High
|
||||
#define m28_off REG_PORT_OUTCLR1 = 0x80000000 //PB31 Low
|
||||
|
||||
#define m15_loop(M15X) {uint8_t M15L=M15X; while(M15L--){m15_on;CLK_delay_us(1);m15_off;}}
|
||||
|
||||
void m15_print(uint32_t x);
|
||||
|
@@ -31,6 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//From keyboard's directory
|
||||
#include "config_led.h"
|
||||
|
||||
void main_subtasks(void);
|
||||
uint8_t keyboard_leds(void);
|
||||
void send_keyboard(report_keyboard_t *report);
|
||||
void send_mouse(report_mouse_t *report);
|
||||
@@ -65,7 +66,7 @@ void send_keyboard(report_keyboard_t *report)
|
||||
if (!keymap_config.nkro)
|
||||
{
|
||||
#endif //NKRO_ENABLE
|
||||
dprint("s-kbd\r\n");
|
||||
while (udi_hid_kbd_b_report_trans_ongoing) { main_subtasks(); } //Run other tasks while waiting for USB to be free
|
||||
|
||||
irqflags = __get_PRIMASK();
|
||||
__disable_irq();
|
||||
@@ -81,7 +82,7 @@ void send_keyboard(report_keyboard_t *report)
|
||||
}
|
||||
else
|
||||
{
|
||||
dprint("s-nkro\r\n");
|
||||
while (udi_hid_nkro_b_report_trans_ongoing) { main_subtasks(); } //Run other tasks while waiting for USB to be free
|
||||
|
||||
irqflags = __get_PRIMASK();
|
||||
__disable_irq();
|
||||
@@ -102,8 +103,6 @@ void send_mouse(report_mouse_t *report)
|
||||
#ifdef MOUSEKEY_ENABLE
|
||||
uint32_t irqflags;
|
||||
|
||||
dprint("s-mou\r\n");
|
||||
|
||||
irqflags = __get_PRIMASK();
|
||||
__disable_irq();
|
||||
__DMB();
|
||||
@@ -120,8 +119,6 @@ void send_mouse(report_mouse_t *report)
|
||||
void send_system(uint16_t data)
|
||||
{
|
||||
#ifdef EXTRAKEY_ENABLE
|
||||
dprintf("s-exks %i\r\n", data);
|
||||
|
||||
uint32_t irqflags;
|
||||
|
||||
irqflags = __get_PRIMASK();
|
||||
@@ -142,8 +139,6 @@ void send_system(uint16_t data)
|
||||
void send_consumer(uint16_t data)
|
||||
{
|
||||
#ifdef EXTRAKEY_ENABLE
|
||||
dprintf("s-exkc %i\r\n",data);
|
||||
|
||||
uint32_t irqflags;
|
||||
|
||||
irqflags = __get_PRIMASK();
|
||||
@@ -160,6 +155,77 @@ void send_consumer(uint16_t data)
|
||||
#endif //EXTRAKEY_ENABLE
|
||||
}
|
||||
|
||||
uint8_t g_drvid;
|
||||
|
||||
void main_subtask_usb_state(void)
|
||||
{
|
||||
if (usb_state == USB_STATE_POWERDOWN)
|
||||
{
|
||||
uint32_t timer_led = timer_read32();
|
||||
|
||||
led_on;
|
||||
if (led_enabled)
|
||||
{
|
||||
for (g_drvid = 0; g_drvid < ISSI3733_DRIVER_COUNT; g_drvid++)
|
||||
{
|
||||
I2C3733_Control_Set(0);
|
||||
}
|
||||
}
|
||||
while (usb_state == USB_STATE_POWERDOWN)
|
||||
{
|
||||
if (timer_read32() - timer_led > 1000) led_off; //Good to indicate went to sleep, but only for a second
|
||||
}
|
||||
if (led_enabled)
|
||||
{
|
||||
for (g_drvid = 0; g_drvid < ISSI3733_DRIVER_COUNT; g_drvid++)
|
||||
{
|
||||
I2C3733_Control_Set(1);
|
||||
}
|
||||
}
|
||||
led_off;
|
||||
}
|
||||
}
|
||||
|
||||
void main_subtask_led(void)
|
||||
{
|
||||
led_matrix_task();
|
||||
}
|
||||
|
||||
void main_subtask_power_check(void)
|
||||
{
|
||||
static uint64_t next_5v_checkup = 0;
|
||||
|
||||
if (CLK_get_ms() > next_5v_checkup)
|
||||
{
|
||||
next_5v_checkup = CLK_get_ms() + 5;
|
||||
|
||||
v_5v = adc_get(ADC_5V);
|
||||
v_5v_avg = 0.9 * v_5v_avg + 0.1 * v_5v;
|
||||
|
||||
gcr_compute();
|
||||
}
|
||||
}
|
||||
|
||||
void main_subtask_usb_extra_device(void)
|
||||
{
|
||||
static uint64_t next_usb_checkup = 0;
|
||||
|
||||
if (CLK_get_ms() > next_usb_checkup)
|
||||
{
|
||||
next_usb_checkup = CLK_get_ms() + 10;
|
||||
|
||||
USB_HandleExtraDevice();
|
||||
}
|
||||
}
|
||||
|
||||
void main_subtasks(void)
|
||||
{
|
||||
main_subtask_usb_state();
|
||||
main_subtask_led();
|
||||
main_subtask_power_check();
|
||||
main_subtask_usb_extra_device();
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
led_ena;
|
||||
@@ -201,9 +267,8 @@ int main(void)
|
||||
|
||||
i2c_led_q_init();
|
||||
|
||||
uint8_t drvid;
|
||||
for (drvid=0;drvid<ISSI3733_DRIVER_COUNT;drvid++)
|
||||
I2C_LED_Q_ONOFF(drvid); //Queue data
|
||||
for (g_drvid = 0; g_drvid < ISSI3733_DRIVER_COUNT; g_drvid++)
|
||||
I2C_LED_Q_ONOFF(g_drvid); //Queue data
|
||||
|
||||
keyboard_setup();
|
||||
|
||||
@@ -214,8 +279,6 @@ int main(void)
|
||||
#ifdef VIRTSER_ENABLE
|
||||
uint64_t next_print = 0;
|
||||
#endif //VIRTSER_ENABLE
|
||||
uint64_t next_usb_checkup = 0;
|
||||
uint64_t next_5v_checkup = 0;
|
||||
|
||||
v_5v_avg = adc_get(ADC_5V);
|
||||
|
||||
@@ -223,58 +286,15 @@ int main(void)
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (usb_state == USB_STATE_POWERDOWN)
|
||||
{
|
||||
uint32_t timer_led = timer_read32();
|
||||
|
||||
led_on;
|
||||
if (led_enabled)
|
||||
{
|
||||
for (drvid=0;drvid<ISSI3733_DRIVER_COUNT;drvid++)
|
||||
{
|
||||
I2C3733_Control_Set(0);
|
||||
}
|
||||
}
|
||||
while (usb_state == USB_STATE_POWERDOWN)
|
||||
{
|
||||
if (timer_read32() - timer_led > 1000) led_off; //Good to indicate went to sleep, but only for a second
|
||||
}
|
||||
if (led_enabled)
|
||||
{
|
||||
for (drvid=0;drvid<ISSI3733_DRIVER_COUNT;drvid++)
|
||||
{
|
||||
I2C3733_Control_Set(1);
|
||||
}
|
||||
}
|
||||
led_off;
|
||||
}
|
||||
|
||||
keyboard_task();
|
||||
|
||||
led_matrix_task();
|
||||
|
||||
if (CLK_get_ms() > next_5v_checkup)
|
||||
{
|
||||
next_5v_checkup = CLK_get_ms() + 5;
|
||||
|
||||
v_5v = adc_get(ADC_5V);
|
||||
v_5v_avg = 0.9 * v_5v_avg + 0.1 * v_5v;
|
||||
|
||||
gcr_compute();
|
||||
}
|
||||
|
||||
if (CLK_get_ms() > next_usb_checkup)
|
||||
{
|
||||
next_usb_checkup = CLK_get_ms() + 10;
|
||||
|
||||
USB_HandleExtraDevice();
|
||||
}
|
||||
main_subtasks(); //Note these tasks will also be run while waiting for USB keyboard polling intervals
|
||||
|
||||
#ifdef VIRTSER_ENABLE
|
||||
if (CLK_get_ms() > next_print)
|
||||
{
|
||||
next_print = CLK_get_ms() + 250;
|
||||
//dpf("5v=%i 5vu=%i dlow=%i dhi=%i gca=%i gcd=%i\r\n",v_5v,v_5v_avg,v_5v_avg-V5_LOW,v_5v_avg-V5_HIGH,gcr_actual,gcr_desired);
|
||||
dprintf("5v=%u 5vu=%u dlow=%u dhi=%u gca=%u gcd=%u\r\n",v_5v,v_5v_avg,v_5v_avg-V5_LOW,v_5v_avg-V5_HIGH,gcr_actual,gcr_desired);
|
||||
}
|
||||
#endif //VIRTSER_ENABLE
|
||||
}
|
||||
|
@@ -7,6 +7,13 @@ extern uint32_t _erom;
|
||||
|
||||
#define BOOTLOADER_SERIAL_MAX_SIZE 20 //DO NOT MODIFY!
|
||||
|
||||
#ifdef KEYBOARD_massdrop_ctrl
|
||||
//WARNING: These are only for CTRL bootloader release "v2.18Jun 22 2018 17:28:08" for bootloader_jump support
|
||||
extern uint32_t _eram;
|
||||
#define BOOTLOADER_MAGIC 0x3B9ACA00
|
||||
#define MAGIC_ADDR (uint32_t *)(&_eram - 4)
|
||||
#endif
|
||||
|
||||
#ifdef MD_BOOTLOADER
|
||||
|
||||
#define MCU_HZ 48000000
|
||||
|
@@ -28,6 +28,7 @@
|
||||
*/
|
||||
|
||||
#include "samd51.h"
|
||||
#include "md_bootloader.h"
|
||||
|
||||
/* Initialize segments */
|
||||
extern uint32_t _sfixed;
|
||||
@@ -500,6 +501,16 @@ const DeviceVectors exception_table = {
|
||||
*/
|
||||
void Reset_Handler(void)
|
||||
{
|
||||
#ifdef KEYBOARD_massdrop_ctrl
|
||||
/* WARNING: This is only for CTRL bootloader release "v2.18Jun 22 2018 17:28:08" for bootloader_jump support */
|
||||
if (*MAGIC_ADDR == BOOTLOADER_MAGIC) {
|
||||
/* At this point, the bootloader's memory is initialized properly, so undo the jump to here, then jump back */
|
||||
*MAGIC_ADDR = 0x00000000; /* Change value to prevent potential bootloader entrance loop */
|
||||
__set_MSP(0x20008818); /* MSP according to bootloader */
|
||||
SCB->VTOR = 0x00000000; /* Vector table back to bootloader's */
|
||||
asm("bx %0"::"r"(0x00001267)); /* Jump past bootloader RCAUSE check using THUMB */
|
||||
}
|
||||
#endif
|
||||
uint32_t *pSrc, *pDest;
|
||||
|
||||
/* Initialize the relocate segment */
|
||||
|
@@ -1,268 +0,0 @@
|
||||
#include "samd51j18a.h"
|
||||
#include "stdarg.h"
|
||||
#include "spfssf.h"
|
||||
#include "usb_util.h"
|
||||
|
||||
int vspf(char *_Dest, const char *_Format, va_list va)
|
||||
{
|
||||
//va_list va; //Variable argument list variable
|
||||
char *d = _Dest; //Pointer to dest
|
||||
|
||||
//va_start(va,_Format); //Initialize the variable argument list
|
||||
while (*_Format) //While not end of format string
|
||||
{
|
||||
if (*_Format == SPF_SPEC_START) //If current format string character is the specifier start character
|
||||
{
|
||||
_Format++; //Skip over the character
|
||||
while (*_Format && *_Format <= 64) _Format++; //Forward past any options
|
||||
if (*_Format == SPF_SPEC_START) *d++ = *_Format; //If the character is the specifier start character, output the character and advance dest
|
||||
else if (*_Format == SPF_SPEC_LONG) //If the character is the long type
|
||||
{
|
||||
_Format++; //Skip over the character
|
||||
if (*_Format == SPF_SPEC_DECIMAL) //If the character is the decimal type
|
||||
{
|
||||
int64_t buf = va_arg(va,int64_t); //Get the next value from the va list
|
||||
//if (buf < 0) { *d++ = '-'; buf = -buf; } //If the given number is negative, add a negative sign to the dest and invert number
|
||||
//spf_uint2str_32_3t(&d,buf,32); //Perform the conversion
|
||||
d += UTIL_ltoa_radix(buf, d, 10);
|
||||
}
|
||||
else if (*_Format == SPF_SPEC_UNSIGNED) //If the character is the unsigned type
|
||||
{
|
||||
uint64_t num = va_arg(va,uint64_t); //Get the next value from the va list
|
||||
//spf_uint2str_32_3t(&d,num,32); //Perform the conversion
|
||||
d += UTIL_ltoa_radix(num, d, 10);
|
||||
}
|
||||
else if (*_Format == SPF_SPEC_UHINT || *_Format == SPF_SPEC_UHINT_UP) //If the character is the unsigned type
|
||||
{
|
||||
uint64_t buf = va_arg(va,uint64_t); //Get the next value from the va list
|
||||
//spf_uint2hex_32(&d,(unsigned long) buf);
|
||||
d += UTIL_ltoa_radix(buf, d, 16);
|
||||
}
|
||||
else //If the character was not a known type
|
||||
{
|
||||
*d++ = SPF_SPEC_START; //Output the start specifier
|
||||
*d++ = SPF_SPEC_LONG; //Output the long type
|
||||
*d++ = *_Format; //Output the unknown type
|
||||
}
|
||||
}
|
||||
else if (*_Format == SPF_SPEC_DECIMAL) //If the character is the decimal type
|
||||
{
|
||||
int buf = va_arg(va,int); //Get the next value from the va list
|
||||
//if (buf < 0) { *d++ = '-'; buf = -buf; } //If the given number is negative, add a negative sign to the dest and invert number
|
||||
//spf_uint2str_32_3t(&d,buf,16); //Perform the conversion
|
||||
d += UTIL_itoa(buf, d);
|
||||
}
|
||||
else if (*_Format == SPF_SPEC_INT) //If the character is the integer type
|
||||
{
|
||||
int buf = va_arg(va,int); //Get the next value from the va list
|
||||
//if (buf < 0) { *d++ = '-'; buf = -buf; } //If the given number is negative, add a negative sign to the dest and inverted number
|
||||
//spf_uint2str_32_3t(&d,buf,16); //Perform the conversion
|
||||
d += UTIL_itoa(buf, d);
|
||||
}
|
||||
else if (*_Format == SPF_SPEC_UINT) //If the character is the unsigned integer type
|
||||
{
|
||||
int buf = va_arg(va,int); //Get the next value from the va list
|
||||
//spf_uint2str_32_3t(&d,buf,16); //Perform the conversion
|
||||
d += UTIL_utoa(buf, d);
|
||||
}
|
||||
else if (*_Format == SPF_SPEC_STRING) //If the character is the string type
|
||||
{
|
||||
char *buf = va_arg(va,char*); //Get the next value from the va list
|
||||
while (*buf) *d++ = *buf++; //Perform the conversion (simply output characters and adcance pointers)
|
||||
}
|
||||
else if (*_Format == SPF_SPEC_UHINT || *_Format == SPF_SPEC_UHINT_UP) //If the character is the short type
|
||||
{
|
||||
int buf = va_arg(va,unsigned int); //Get the next value from the va list
|
||||
//spf_uint2hex_32(&d,(unsigned long) buf); //Perform the conversion
|
||||
d += UTIL_utoa(buf, d);
|
||||
}
|
||||
else //If the character type is unknown
|
||||
{
|
||||
*d++ = SPF_SPEC_START; //Output the start specifier
|
||||
*d++ = *_Format; //Output the unknown type
|
||||
}
|
||||
}
|
||||
else *d++ = *_Format; //If the character is unknown, output it to dest and advance dest
|
||||
_Format++; //Advance the format buffer pointer to next character
|
||||
}
|
||||
//va_end(va); //End the variable argument list
|
||||
|
||||
*d = '\0'; //Cap off the destination string with a zero
|
||||
|
||||
return d - _Dest; //Return the length of the destintion buffer
|
||||
}
|
||||
|
||||
int spf(char *_Dest, const char *_Format, ...)
|
||||
{
|
||||
va_list va; //Variable argument list variable
|
||||
int result;
|
||||
|
||||
va_start(va,_Format); //Initialize the variable argument list
|
||||
result = vspf(_Dest, _Format, va);
|
||||
va_end(va);
|
||||
return result;
|
||||
}
|
||||
|
||||
//sscanf string to number (integer types)
|
||||
int64_t ssf_ston(const char **_Src, uint32_t count, uint32_t *conv_count)
|
||||
{
|
||||
int64_t value = 0; //Return value accumulator
|
||||
uint32_t counter=count; //Counter to keep track of numbers converted
|
||||
const char* p; //Pointer to first non space character
|
||||
|
||||
while (*(*_Src) == SSF_SKIP_SPACE) (*_Src)++; //Forward through the whitespace to next non whitespace
|
||||
|
||||
p = (*_Src); //Set pointer to first non space character
|
||||
if (*p == '+' || *p == '-') (*_Src)++; //Skip over sign if any
|
||||
while (*(*_Src) >= ASCII_NUM_START &&
|
||||
*(*_Src) <= ASCII_NUM_END &&
|
||||
counter) //While the source character is a digit and counter is not zero
|
||||
{
|
||||
value *= 10; //Multiply result by 10 to make room for next 1's place number
|
||||
value += *(*_Src)++ - ASCII_NUM_START; //Add source number to value
|
||||
counter--; //Decrement counter
|
||||
}
|
||||
if (counter - count == 0) return 0; //If no number conversion were performed, return 0
|
||||
if (*p == '-') value = -value; //If the number given was negative, make the result negative
|
||||
|
||||
if (conv_count) (*conv_count)++; //Increment the converted count
|
||||
return value; //Return the value
|
||||
}
|
||||
|
||||
uint64_t ssf_hton(const char **_Src, uint32_t count,uint32_t *conv_count)
|
||||
{
|
||||
int64_t value=0; //Return value accumulator
|
||||
uint32_t counter=count; //Counter to keep track of numbers converted
|
||||
//const char* p; //Pointer to first non space character
|
||||
char c;
|
||||
|
||||
while (*(*_Src) == SSF_SKIP_SPACE) (*_Src)++; //Forward through the whitespace to next non whitespace
|
||||
|
||||
//p = (*_Src); //Set pointer to first non space character
|
||||
|
||||
while (counter)
|
||||
{
|
||||
c = *(*_Src)++;
|
||||
if (c >= 'a' && c <= 'f') c -= ('a'-'A'); //toupper
|
||||
if (c < '0' || (c > '9' && c < 'A') || c > 'F') break;
|
||||
value *= 16; //Multiply result by 10 to make room for next 1's place number
|
||||
c = c - '0';
|
||||
if (c > 9) c -= 7;
|
||||
value += c; //Add source number to value
|
||||
counter--; //Decrement counter
|
||||
}
|
||||
|
||||
if (counter - count == 0) return 0; //If no number conversion were performed, return 0
|
||||
//if (*p == '-') value = -value; //If the number given was negative, make the result negative
|
||||
|
||||
if (conv_count) (*conv_count)++; //Increment the converted count
|
||||
return value;
|
||||
}
|
||||
|
||||
//sscanf
|
||||
int ssf(const char *_Src, const char *_Format, ...)
|
||||
{
|
||||
va_list va; //Variable argument list variable
|
||||
unsigned char looking_for=0; //Static char specified in format to be found in source
|
||||
uint32_t conv_count=0; //Count of conversions made
|
||||
|
||||
va_start(va,_Format); //Initialize the variable argument list
|
||||
while (*_Format) //While the format string has not been fully read
|
||||
{
|
||||
if (looking_for != 0) //If we are looking for a matching character in the source string
|
||||
{
|
||||
while (*_Src != looking_for && *_Src) _Src++; //While the character is not found in the source string and not the end of the source
|
||||
// string, increment the pointer position
|
||||
if (*_Src == looking_for) _Src++; //If the character was found, step over it
|
||||
else break; //Else the end was reached and the scan is now invalid (Could not find static character)
|
||||
looking_for = 0; //Clear the looking for character
|
||||
}
|
||||
if (*_Format == SSF_SPEC_START) //If the current format character is the specifier start character
|
||||
{
|
||||
_Format++; //Step over the specifier start character
|
||||
if (*_Format == SSF_SPEC_DECIMAL) //If the decimal specifier type is found
|
||||
{
|
||||
int *value=va_arg(va,int*); //User given destination address
|
||||
//*value = (int)ssf_ston(&_Src,5,&conv_count); //Run conversion
|
||||
*value = (int)ssf_ston(&_Src,10,&conv_count); //Run conversion
|
||||
}
|
||||
else if (*_Format == SSF_SPEC_LONG) //If the long specifier type is found
|
||||
{
|
||||
_Format++; //Skip over the specifier type
|
||||
if (*_Format == SSF_SPEC_DECIMAL) //If the decimal specifier type is found
|
||||
{
|
||||
int64_t *value=va_arg(va,int64_t*); //User given destination address
|
||||
//*value = (int64_t)ssf_ston(&_Src,10,&conv_count); //Run conversion
|
||||
*value = (int64_t)ssf_ston(&_Src,19,&conv_count); //Run conversion
|
||||
}
|
||||
else if (*_Format == SSF_SPEC_UHINT) //If the decimal specifier type is found
|
||||
{
|
||||
uint64_t *value=va_arg(va,uint64_t *); //User given destination address
|
||||
//*value = (uint64_t int)ssf_hton(&_Src,12,&conv_count); //Run conversion
|
||||
*value = (uint64_t)ssf_hton(&_Src,16,&conv_count); //Run conversion
|
||||
}
|
||||
}
|
||||
else if (*_Format == SSF_SPEC_SHORTINT) //If the short int specifier type is found
|
||||
{
|
||||
_Format++; //Skip over the specifier type
|
||||
if (*_Format == SSF_SPEC_SHORTINT) //If the short int specifier type is found
|
||||
{
|
||||
_Format++; //Skip over the specifier type
|
||||
if (*_Format == SSF_SPEC_DECIMAL) //If the decimal specifier type is found
|
||||
{
|
||||
unsigned char *value=va_arg(va,unsigned char*); //User given destination address
|
||||
//*value = (unsigned char)ssf_ston(&_Src,3,&conv_count); //Run conversion
|
||||
*value = (unsigned char)ssf_ston(&_Src,5,&conv_count); //Run conversion
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (*_Format == SSF_SPEC_STRING) //If the specifier type is string
|
||||
{
|
||||
char *value=va_arg(va,char*); //User given destination address, max chars read pointer
|
||||
while (*_Src == SSF_SKIP_SPACE) _Src++; //Forward through the whitespace to next non whitespace
|
||||
while (*_Src != SSF_SKIP_SPACE && *_Src) *value++ = *_Src++; //While any character but space and not end of string and not end location, copy char to dest
|
||||
*value = 0; //Cap off the string pointer with zero
|
||||
conv_count++; //Increment the converted count
|
||||
}
|
||||
else if (*_Format == SSF_SPEC_VERSION) //If the specifier type is string
|
||||
{
|
||||
char *value=va_arg(va,char*); //User given destination address, max chars read pointer
|
||||
while (*_Src == SSF_SKIP_SPACE) _Src++; //Forward through the whitespace to next non whitespace
|
||||
while (*_Src != SSF_DELIM_COMMA && *_Src) *value++ = *_Src++; //While any character but space and not end of string and not end location, copy char to dest
|
||||
*value = 0; //Cap off the string pointer with zero
|
||||
conv_count++; //Increment the converted count
|
||||
}
|
||||
else if (*_Format >= ASCII_NUM_START && *_Format <= ASCII_NUM_END)
|
||||
{
|
||||
uint32_t len = (uint32_t)ssf_ston(&_Format,3,NULL); //Convert the given length
|
||||
if (*_Format == SSF_SPEC_STRING) //If the specifier type is string
|
||||
{
|
||||
char *value=va_arg(va,char*),*e; //User given destination address, max chars read pointer
|
||||
while (*_Src == SSF_SKIP_SPACE) _Src++; //Forward through the whitespace to next non whitespace
|
||||
e = (char*)_Src+len; //Set a maximum length pointer location
|
||||
while (*_Src != SSF_SKIP_SPACE && *_Src && _Src != e) *value++ = *_Src++; //While any character but space and not end of string and not end location, copy char to dest
|
||||
*value = 0; //Cap off the string pointer with zero
|
||||
conv_count++; //Increment the converted count
|
||||
}
|
||||
else if (*_Format == SSF_SPEC_VERSION) //If the specifier type is string
|
||||
{
|
||||
char *value=va_arg(va,char*),*e; //User given destination address, max chars read pointer
|
||||
while (*_Src == SSF_SKIP_SPACE) _Src++; //Forward through the whitespace to next non whitespace
|
||||
e = (char*)_Src+len; //Set a maximum length pointer location
|
||||
while (*_Src != SSF_DELIM_COMMA && *_Src && _Src != e) *value++ = *_Src++; //While any character but space and not end of string and not end location, copy char to dest
|
||||
*value = 0; //Cap off the string pointer with zero
|
||||
conv_count++; //Increment the converted count
|
||||
}
|
||||
}
|
||||
else if (*_Format == SSF_SPEC_START) looking_for = *_Format; //If another start specifier character is found, output a specifier character
|
||||
else break; //Scan is now invalid (Uknown type specified)
|
||||
}
|
||||
else if (*_Format == SSF_SKIP_SPACE) { } //If a space is found, ignore it
|
||||
else looking_for = *_Format; //If any other character is found, it is static and should be found in src as well
|
||||
_Format++; //Skip over current format character
|
||||
}
|
||||
|
||||
va_end(va); //End the variable argument list
|
||||
return conv_count; //Return the number of conversions made
|
||||
}
|
||||
|
@@ -1,57 +0,0 @@
|
||||
#ifndef ____spfssf_h
|
||||
#define ____spfssf_h
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#define sprintf spf
|
||||
#define sscanf ssf
|
||||
|
||||
#define SIZEOF_OFFSET 1
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#define SPF_NONE 0
|
||||
|
||||
#define SPF_SPEC_START 37 //%
|
||||
#define SPF_SPEC_DECIMAL 100 //d 16bit dec signed (-32767 to 32767) DONE same as i
|
||||
#define SPF_SPEC_INT 105 //i 16bit dec signed (-32767 to 32767) DONE same as d
|
||||
#define SPF_SPEC_UINT 117 //u 16bit dec unsigned (0 to 65535) DONE
|
||||
#define SPF_SPEC_STRING 115 //s variable length (abcd...) DONE
|
||||
#define SPF_SPEC_UHINT 120 //x 16bit hex lwrc (7fa) DONE
|
||||
#define SPF_SPEC_UHINT_UP 88 //x 16bit hex lwrc (7fa) DONE
|
||||
#define SPF_SPEC_LONG 108 //l start of either ld or lu DONE
|
||||
#define SPF_SPEC_DECIMAL 100 //ld 32bit dec signed (-2147483647 to 2147483647) DONE
|
||||
#define SPF_SPEC_UNSIGNED 117 //lu 32bit dec unsigned (0 to 4294967295) DONE
|
||||
#define SPF_SPEC_UHINT 120 //lx 32bit hex unsigned (0 to ffffffff) DONE
|
||||
|
||||
#define SSF_SPEC_START 37 //%
|
||||
#define SSF_SPEC_SHORTINT 104 //h 8bit dec signed (-127 to 127) DONE
|
||||
#define SSF_LEN_SHORTINT 3 //hhd
|
||||
#define SSF_SPEC_DECIMAL 100 //d 16bit dec signed (-32767 to 32767) DONE
|
||||
#define SSF_LEN_DECIMAL 5 //32767
|
||||
#define SSF_SPEC_INT 105 //i 16bit dec signed (-32767 to 32767) DONE
|
||||
#define SSF_LEN_INT 5 //32767
|
||||
#define SSF_SPEC_LONG 108 //l start of either ld or lu DONE
|
||||
#define SSF_SPEC_DECIMAL 100 //ld 32bit dec signed (-2147483647 to 2147483647) DONE
|
||||
#define SSF_SPEC_UHINT 120 //lx 32bit hex unsigned DONE
|
||||
#define SSF_LEN_LDECIMAL 10 //2147483647
|
||||
#define SSF_SPEC_STRING 115 //s variable length (abcd...) DONE
|
||||
#define SSF_SKIP_SPACE 32 //space
|
||||
|
||||
#define SSF_SPEC_VERSION 118 //v collect to comma delimiter - special
|
||||
#define SSF_DELIM_COMMA 44 //,
|
||||
|
||||
#define ASCII_NUM_START 48 //0
|
||||
#define ASCII_NUM_END 58 //9
|
||||
|
||||
#define T_UINT32_0_LIMIT 14
|
||||
#define T_UINT32_1_LIMIT 27
|
||||
|
||||
int vspf(char *_Dest, const char *_Format, va_list va);
|
||||
int spf(char *_Dest, const char *_Format, ...);
|
||||
int ssf(const char *_Src, const char *_Format, ...);
|
||||
|
||||
#endif //____spfssf_h
|
||||
|
@@ -54,7 +54,6 @@
|
||||
#include <string.h>
|
||||
#include "udi_cdc_conf.h"
|
||||
#include "udi_device_conf.h"
|
||||
#include "spfssf.h"
|
||||
#include "stdarg.h"
|
||||
#include "tmk_core/protocol/arm_atsam/clks.h"
|
||||
|
||||
@@ -1259,7 +1258,6 @@ uint32_t CDC_print(char *printbuf)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
char printbuf[CDC_PRINTBUF_SIZE];
|
||||
|
||||
int dpf(const char *_Format, ...)
|
||||
@@ -1267,8 +1265,8 @@ int dpf(const char *_Format, ...)
|
||||
va_list va; //Variable argument list variable
|
||||
int result;
|
||||
|
||||
va_start(va,_Format); //Initialize the variable argument list
|
||||
result = vspf(printbuf, _Format, va);
|
||||
va_start(va, _Format); //Initialize the variable argument list
|
||||
result = vsnprintf(printbuf, CDC_PRINTBUF_SIZE, _Format, va);
|
||||
va_end(va);
|
||||
|
||||
CDC_print(printbuf);
|
||||
@@ -1377,8 +1375,6 @@ void CDC_init(void)
|
||||
printbuf[0]=0;
|
||||
}
|
||||
|
||||
char printbuf[CDC_PRINTBUF_SIZE];
|
||||
|
||||
#endif //CDC line 62
|
||||
|
||||
//@}
|
||||
|
@@ -57,8 +57,8 @@
|
||||
#include "udi.h"
|
||||
|
||||
// Check the number of port
|
||||
#ifndef UDI_CDC_PORT_NB
|
||||
# define UDI_CDC_PORT_NB 1
|
||||
#ifndef UDI_CDC_PORT_NB
|
||||
# define UDI_CDC_PORT_NB 1
|
||||
#endif
|
||||
#if (UDI_CDC_PORT_NB > 1)
|
||||
# error UDI_CDC_PORT_NB must be at most 1
|
||||
@@ -86,9 +86,6 @@ extern UDC_DESC_STORAGE udi_api_t udi_api_cdc_data;
|
||||
//! CDC data endpoints size for FS speed (8B, 16B, 32B, 64B)
|
||||
#define UDI_CDC_DATA_EPS_FS_SIZE CDC_RX_SIZE
|
||||
|
||||
#define CDC_PRINT_BUF_SIZE 256
|
||||
extern char printbuf[CDC_PRINT_BUF_SIZE];
|
||||
|
||||
//@}
|
||||
|
||||
/**
|
||||
@@ -371,9 +368,6 @@ uint32_t CDC_print(char *printbuf);
|
||||
uint32_t CDC_input(void);
|
||||
void CDC_init(void);
|
||||
|
||||
#define __xprintf dpf
|
||||
int dpf(const char *_Format, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -45,6 +45,7 @@
|
||||
*/
|
||||
|
||||
#include "samd51j18a.h"
|
||||
#include "d51_util.h"
|
||||
#include "conf_usb.h"
|
||||
#include "usb_protocol.h"
|
||||
#include "udd.h"
|
||||
@@ -86,7 +87,7 @@ bool udi_hid_kbd_b_report_valid;
|
||||
COMPILER_WORD_ALIGNED
|
||||
uint8_t udi_hid_kbd_report[UDI_HID_KBD_REPORT_SIZE];
|
||||
|
||||
static bool udi_hid_kbd_b_report_trans_ongoing;
|
||||
volatile bool udi_hid_kbd_b_report_trans_ongoing;
|
||||
|
||||
COMPILER_WORD_ALIGNED
|
||||
static uint8_t udi_hid_kbd_report_trans[UDI_HID_KBD_REPORT_SIZE];
|
||||
@@ -186,8 +187,7 @@ bool udi_hid_kbd_send_report(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy(udi_hid_kbd_report_trans, udi_hid_kbd_report,
|
||||
UDI_HID_KBD_REPORT_SIZE);
|
||||
memcpy(udi_hid_kbd_report_trans, udi_hid_kbd_report, UDI_HID_KBD_REPORT_SIZE);
|
||||
udi_hid_kbd_b_report_valid = false;
|
||||
udi_hid_kbd_b_report_trans_ongoing =
|
||||
udd_ep_run(UDI_HID_KBD_EP_IN | USB_EP_DIR_IN,
|
||||
@@ -249,7 +249,7 @@ bool udi_hid_nkro_b_report_valid;
|
||||
COMPILER_WORD_ALIGNED
|
||||
uint8_t udi_hid_nkro_report[UDI_HID_NKRO_REPORT_SIZE];
|
||||
|
||||
static bool udi_hid_nkro_b_report_trans_ongoing;
|
||||
volatile bool udi_hid_nkro_b_report_trans_ongoing;
|
||||
|
||||
COMPILER_WORD_ALIGNED
|
||||
static uint8_t udi_hid_nkro_report_trans[UDI_HID_NKRO_REPORT_SIZE];
|
||||
@@ -355,7 +355,7 @@ bool udi_hid_nkro_send_report(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy(udi_hid_nkro_report_trans, udi_hid_nkro_report,UDI_HID_NKRO_REPORT_SIZE);
|
||||
memcpy(udi_hid_nkro_report_trans, udi_hid_nkro_report, UDI_HID_NKRO_REPORT_SIZE);
|
||||
udi_hid_nkro_b_report_valid = false;
|
||||
udi_hid_nkro_b_report_trans_ongoing =
|
||||
udd_ep_run(UDI_HID_NKRO_EP_IN | USB_EP_DIR_IN,
|
||||
|
@@ -60,6 +60,7 @@ extern "C" {
|
||||
#ifdef KBD
|
||||
extern UDC_DESC_STORAGE udi_api_t udi_api_hid_kbd;
|
||||
extern bool udi_hid_kbd_b_report_valid;
|
||||
extern volatile bool udi_hid_kbd_b_report_trans_ongoing;
|
||||
extern uint8_t udi_hid_kbd_report_set;
|
||||
bool udi_hid_kbd_send_report(void);
|
||||
#endif //KBD
|
||||
@@ -70,6 +71,7 @@ bool udi_hid_kbd_send_report(void);
|
||||
#ifdef NKRO
|
||||
extern UDC_DESC_STORAGE udi_api_t udi_api_hid_nkro;
|
||||
extern bool udi_hid_nkro_b_report_valid;
|
||||
extern volatile bool udi_hid_nkro_b_report_trans_ongoing;
|
||||
bool udi_hid_nkro_send_report(void);
|
||||
#endif //NKRO
|
||||
|
||||
|
@@ -378,7 +378,7 @@ check-size:
|
||||
$(eval OVER_SIZE=$(shell expr $(CURRENT_SIZE) - $(MAX_SIZE)))
|
||||
if [ $(MAX_SIZE) -gt 0 ] && [ $(CURRENT_SIZE) -gt 0 ]; then \
|
||||
$(SILENT) || printf "$(MSG_CHECK_FILESIZE)" | $(AWK_CMD); \
|
||||
if [ $(CURRENT_SIZE) -gt $(MAX_SIZE) ]; then $(PRINT_WARNING_PLAIN); $(SILENT) || printf " * $(MSG_FILE_TOO_BIG)" ; else $(PRINT_OK); $(SILENT) || printf " * $(MSG_FILE_JUST_RIGHT)"; fi \
|
||||
if [ $(CURRENT_SIZE) -gt $(MAX_SIZE) ]; then printf "\n * $(MSG_FILE_TOO_BIG)"; $(PRINT_ERROR_PLAIN); else $(PRINT_OK); $(SILENT) || printf " * $(MSG_FILE_JUST_RIGHT)"; fi \
|
||||
fi
|
||||
else
|
||||
check-size:
|
||||
|
Reference in New Issue
Block a user