mirror of
https://github.com/Keychron/qmk_firmware.git
synced 2026-02-24 10:22:35 +00:00
Add playground branch
This commit is contained in:
18
.github/workflows/auto_approve.yml
vendored
Normal file
18
.github/workflows/auto_approve.yml
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
name: Automatic Approve
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "*/5 * * * *"
|
||||
|
||||
jobs:
|
||||
automatic_approve:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
if: github.repository == 'qmk/qmk_firmware'
|
||||
|
||||
steps:
|
||||
- uses: mheap/automatic-approve-action@v1
|
||||
with:
|
||||
token: ${{ secrets.QMK_BOT_TOKEN }}
|
||||
workflows: "format.yml,lint.yml,unit_test.yml"
|
||||
dangerous_files: "lib/python/,Makefile,paths.mk,builddefs/"
|
||||
33
.github/workflows/auto_tag.yml
vendored
Normal file
33
.github/workflows/auto_tag.yml
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
name: Essential files modified
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- quantum/**/*
|
||||
- tmk_core/**/*
|
||||
- drivers/**/*
|
||||
- tests/**/*
|
||||
- util/**/*
|
||||
- platforms/**/*
|
||||
- Makefile
|
||||
- '*.mk'
|
||||
|
||||
jobs:
|
||||
tag:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# protect against those who develop with their fork on master
|
||||
if: github.repository == 'qmk/qmk_firmware'
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Bump version and push tag
|
||||
uses: anothrNick/github-tag-action@1.26.0
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
DEFAULT_BUMP: 'patch'
|
||||
35
.github/workflows/feature_branch_update.yml
vendored
Normal file
35
.github/workflows/feature_branch_update.yml
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
name: Update feature branches after develop merge
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- develop
|
||||
|
||||
jobs:
|
||||
feature_branch_update:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
if: github.repository == 'qmk/qmk_firmware'
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
branch:
|
||||
- xap
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
token: ${{ secrets.QMK_BOT_TOKEN }}
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Checkout branch
|
||||
run: |
|
||||
git fetch origin develop ${{ matrix.branch }}
|
||||
git checkout ${{ matrix.branch }}
|
||||
|
||||
- name: Update branch from develop
|
||||
run: |
|
||||
git config --global user.name "QMK Bot"
|
||||
git config --global user.email "hello@qmk.fm"
|
||||
git merge origin/develop
|
||||
git push origin ${{ matrix.branch }}
|
||||
51
.github/workflows/format.yml
vendored
Normal file
51
.github/workflows/format.yml
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
name: PR Lint Format
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- 'drivers/**'
|
||||
- 'lib/arm_atsam/**'
|
||||
- 'lib/lib8tion/**'
|
||||
- 'lib/python/**'
|
||||
- 'platforms/**'
|
||||
- 'quantum/**'
|
||||
- 'tests/**'
|
||||
- 'tmk_core/**'
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
container: qmkfm/qmk_cli
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pip3 install -r requirements-dev.txt
|
||||
|
||||
- uses: trilom/file-changes-action@v1.2.4
|
||||
id: file_changes
|
||||
with:
|
||||
output: ' '
|
||||
fileOutput: ' '
|
||||
|
||||
- name: Run qmk formatters
|
||||
shell: 'bash {0}'
|
||||
run: |
|
||||
cat ~/files_added.txt ~/files_modified.txt > ~/files_changed.txt
|
||||
qmk format-c --core-only $(< ~/files_changed.txt) || true
|
||||
qmk format-python $(< ~/files_changed.txt) || true
|
||||
qmk format-text $(< ~/files_changed.txt) || true
|
||||
|
||||
- name: Fail when formatting required
|
||||
run: |
|
||||
git diff
|
||||
for file in $(git diff --name-only); do
|
||||
echo "File '${file}' Requires Formatting"
|
||||
echo "::error file=${file}::Requires Formatting"
|
||||
done
|
||||
test -z "$(git diff --name-only)"
|
||||
49
.github/workflows/format_push.yml
vendored
Normal file
49
.github/workflows/format_push.yml
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
name: Lint Format
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
container: qmkfm/qmk_cli
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pip3 install -r requirements-dev.txt
|
||||
|
||||
- name: Run qmk formatters
|
||||
shell: 'bash {0}'
|
||||
run: |
|
||||
qmk format-c -a
|
||||
qmk format-python -a
|
||||
qmk format-text -a
|
||||
git diff
|
||||
|
||||
- uses: rlespinasse/github-slug-action@v3.x
|
||||
|
||||
- name: Become QMK Bot
|
||||
run: |
|
||||
git config user.name 'QMK Bot'
|
||||
git config user.email 'hello@qmk.fm'
|
||||
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@v3
|
||||
if: ${{ github.repository == 'qmk/qmk_firmware'}}
|
||||
with:
|
||||
token: ${{ secrets.QMK_BOT_TOKEN }}
|
||||
delete-branch: true
|
||||
branch: bugfix/format_${{ env.GITHUB_REF_SLUG }}
|
||||
author: QMK Bot <hello@qmk.fm>
|
||||
committer: QMK Bot <hello@qmk.fm>
|
||||
commit-message: Format code according to conventions
|
||||
title: '[CI] Format code according to conventions'
|
||||
10
.vscode/extensions.json
vendored
10
.vscode/extensions.json
vendored
@@ -1,10 +0,0 @@
|
||||
// Suggested extensions
|
||||
{
|
||||
"recommendations": [
|
||||
"EditorConfig.EditorConfig",
|
||||
"xaver.clang-format",
|
||||
"ms-vscode.cpptools",
|
||||
"bierner.github-markdown-preview",
|
||||
"donjayamanne.git-extension-pack"
|
||||
]
|
||||
}
|
||||
31
.vscode/settings.json
vendored
31
.vscode/settings.json
vendored
@@ -1,31 +0,0 @@
|
||||
// Place your settings in this file to overwrite default and user settings.
|
||||
{
|
||||
// Unofficially, QMK uses spaces for indentation
|
||||
"editor.insertSpaces": true,
|
||||
// Configure glob patterns for excluding files and folders.
|
||||
"files.exclude": {
|
||||
"**/.build": true,
|
||||
"**/*.hex": true,
|
||||
"**/*.bin": true
|
||||
},
|
||||
"files.associations": {
|
||||
"*.h": "c",
|
||||
"*.c": "c",
|
||||
"*.inc": "c",
|
||||
"*.cpp": "cpp",
|
||||
"*.hpp": "cpp",
|
||||
"xstddef": "c",
|
||||
"type_traits": "c",
|
||||
"utility": "c",
|
||||
"ranges": "c",
|
||||
"xlocale": "c"
|
||||
},
|
||||
"[markdown]": {
|
||||
"editor.trimAutoWhitespace": false,
|
||||
"files.trimTrailingWhitespace": false
|
||||
},
|
||||
"python.formatting.provider": "yapf",
|
||||
"[json]": {
|
||||
"editor.formatOnSave": false
|
||||
}
|
||||
}
|
||||
36
builddefs/build_full_test.mk
Normal file
36
builddefs/build_full_test.mk
Normal file
@@ -0,0 +1,36 @@
|
||||
# Copyright 2017 Fred Sundvik
|
||||
#
|
||||
# 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/>.
|
||||
|
||||
$(TEST)_INC := \
|
||||
tests/test_common/common_config.h
|
||||
|
||||
$(TEST)_SRC := \
|
||||
$(TMK_COMMON_SRC) \
|
||||
$(QUANTUM_SRC) \
|
||||
$(SRC) \
|
||||
tests/test_common/keymap.c \
|
||||
tests/test_common/matrix.c \
|
||||
tests/test_common/test_driver.cpp \
|
||||
tests/test_common/keyboard_report_util.cpp \
|
||||
tests/test_common/test_fixture.cpp \
|
||||
tests/test_common/test_keymap_key.cpp \
|
||||
tests/test_common/test_logger.cpp \
|
||||
$(patsubst $(ROOTDIR)/%,%,$(wildcard $(TEST_PATH)/*.cpp))
|
||||
|
||||
$(TEST)_DEFS := $(TMK_COMMON_DEFS) $(OPT_DEFS)
|
||||
|
||||
$(TEST)_CONFIG := $(TEST_PATH)/config.h
|
||||
|
||||
VPATH += $(TOP_DIR)/tests/test_common
|
||||
17
builddefs/build_json.mk
Normal file
17
builddefs/build_json.mk
Normal file
@@ -0,0 +1,17 @@
|
||||
# Look for a json keymap file
|
||||
ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_5)/keymap.json)","")
|
||||
KEYMAP_JSON := $(MAIN_KEYMAP_PATH_5)/keymap.json
|
||||
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_5)
|
||||
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_4)/keymap.json)","")
|
||||
KEYMAP_JSON := $(MAIN_KEYMAP_PATH_4)/keymap.json
|
||||
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_4)
|
||||
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_3)/keymap.json)","")
|
||||
KEYMAP_JSON := $(MAIN_KEYMAP_PATH_3)/keymap.json
|
||||
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_3)
|
||||
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_2)/keymap.json)","")
|
||||
KEYMAP_JSON := $(MAIN_KEYMAP_PATH_2)/keymap.json
|
||||
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_2)
|
||||
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_1)/keymap.json)","")
|
||||
KEYMAP_JSON := $(MAIN_KEYMAP_PATH_1)/keymap.json
|
||||
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_1)
|
||||
endif
|
||||
479
builddefs/build_keyboard.mk
Normal file
479
builddefs/build_keyboard.mk
Normal file
@@ -0,0 +1,479 @@
|
||||
# Determine what keyboard we are building and setup the build environment.
|
||||
#
|
||||
# We support folders up to 5 levels deep below `keyboards/`. This file is
|
||||
# responsible for determining which folder is being used and doing the
|
||||
# corresponding environment setup.
|
||||
|
||||
ifndef VERBOSE
|
||||
.SILENT:
|
||||
endif
|
||||
|
||||
.DEFAULT_GOAL := all
|
||||
|
||||
include paths.mk
|
||||
include $(BUILDDEFS_PATH)/message.mk
|
||||
|
||||
# Set the qmk cli to use
|
||||
QMK_BIN ?= qmk
|
||||
|
||||
# Set the filename for the final firmware binary
|
||||
KEYBOARD_FILESAFE := $(subst /,_,$(KEYBOARD))
|
||||
TARGET ?= $(KEYBOARD_FILESAFE)_$(KEYMAP)
|
||||
KEYBOARD_OUTPUT := $(BUILD_DIR)/obj_$(KEYBOARD_FILESAFE)
|
||||
|
||||
# Force expansion
|
||||
TARGET := $(TARGET)
|
||||
|
||||
ifneq ($(FORCE_LAYOUT),)
|
||||
TARGET := $(TARGET)_$(FORCE_LAYOUT)
|
||||
endif
|
||||
|
||||
# Object files and generated keymap directory
|
||||
# To put object files in current directory, use a dot (.), do NOT make
|
||||
# this an empty or blank macro!
|
||||
KEYMAP_OUTPUT := $(BUILD_DIR)/obj_$(TARGET)
|
||||
|
||||
ifdef SKIP_VERSION
|
||||
OPT_DEFS += -DSKIP_VERSION
|
||||
endif
|
||||
|
||||
# Generate the version.h file
|
||||
ifdef SKIP_VERSION
|
||||
VERSION_H_FLAGS := --skip-all
|
||||
endif
|
||||
ifdef SKIP_GIT
|
||||
VERSION_H_FLAGS := --skip-git
|
||||
endif
|
||||
|
||||
# Generate the board's version.h file.
|
||||
$(shell $(QMK_BIN) generate-version-h $(VERSION_H_FLAGS) -q -o $(KEYMAP_OUTPUT)/src/version.h)
|
||||
|
||||
# Determine which subfolders exist.
|
||||
KEYBOARD_FOLDER_PATH_1 := $(KEYBOARD)
|
||||
KEYBOARD_FOLDER_PATH_2 := $(patsubst %/,%,$(dir $(KEYBOARD_FOLDER_PATH_1)))
|
||||
KEYBOARD_FOLDER_PATH_3 := $(patsubst %/,%,$(dir $(KEYBOARD_FOLDER_PATH_2)))
|
||||
KEYBOARD_FOLDER_PATH_4 := $(patsubst %/,%,$(dir $(KEYBOARD_FOLDER_PATH_3)))
|
||||
KEYBOARD_FOLDER_PATH_5 := $(patsubst %/,%,$(dir $(KEYBOARD_FOLDER_PATH_4)))
|
||||
KEYBOARD_FOLDER_1 := $(notdir $(KEYBOARD_FOLDER_PATH_1))
|
||||
KEYBOARD_FOLDER_2 := $(notdir $(KEYBOARD_FOLDER_PATH_2))
|
||||
KEYBOARD_FOLDER_3 := $(notdir $(KEYBOARD_FOLDER_PATH_3))
|
||||
KEYBOARD_FOLDER_4 := $(notdir $(KEYBOARD_FOLDER_PATH_4))
|
||||
KEYBOARD_FOLDER_5 := $(notdir $(KEYBOARD_FOLDER_PATH_5))
|
||||
KEYBOARD_PATHS :=
|
||||
KEYBOARD_PATH_1 := keyboards/$(KEYBOARD_FOLDER_PATH_1)
|
||||
KEYBOARD_PATH_2 := keyboards/$(KEYBOARD_FOLDER_PATH_2)
|
||||
KEYBOARD_PATH_3 := keyboards/$(KEYBOARD_FOLDER_PATH_3)
|
||||
KEYBOARD_PATH_4 := keyboards/$(KEYBOARD_FOLDER_PATH_4)
|
||||
KEYBOARD_PATH_5 := keyboards/$(KEYBOARD_FOLDER_PATH_5)
|
||||
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_5)/)","")
|
||||
KEYBOARD_PATHS += $(KEYBOARD_PATH_5)
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_4)/)","")
|
||||
KEYBOARD_PATHS += $(KEYBOARD_PATH_4)
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_3)/)","")
|
||||
KEYBOARD_PATHS += $(KEYBOARD_PATH_3)
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_2)/)","")
|
||||
KEYBOARD_PATHS += $(KEYBOARD_PATH_2)
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_1)/)","")
|
||||
KEYBOARD_PATHS += $(KEYBOARD_PATH_1)
|
||||
endif
|
||||
|
||||
|
||||
# Pull in rules.mk files from all our subfolders
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_5)/rules.mk)","")
|
||||
include $(KEYBOARD_PATH_5)/rules.mk
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_4)/rules.mk)","")
|
||||
include $(KEYBOARD_PATH_4)/rules.mk
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_3)/rules.mk)","")
|
||||
include $(KEYBOARD_PATH_3)/rules.mk
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_2)/rules.mk)","")
|
||||
include $(KEYBOARD_PATH_2)/rules.mk
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_1)/rules.mk)","")
|
||||
include $(KEYBOARD_PATH_1)/rules.mk
|
||||
endif
|
||||
|
||||
MAIN_KEYMAP_PATH_1 := $(KEYBOARD_PATH_1)/keymaps/$(KEYMAP)
|
||||
MAIN_KEYMAP_PATH_2 := $(KEYBOARD_PATH_2)/keymaps/$(KEYMAP)
|
||||
MAIN_KEYMAP_PATH_3 := $(KEYBOARD_PATH_3)/keymaps/$(KEYMAP)
|
||||
MAIN_KEYMAP_PATH_4 := $(KEYBOARD_PATH_4)/keymaps/$(KEYMAP)
|
||||
MAIN_KEYMAP_PATH_5 := $(KEYBOARD_PATH_5)/keymaps/$(KEYMAP)
|
||||
|
||||
# Pull in rules from info.json
|
||||
INFO_RULES_MK = $(shell $(QMK_BIN) generate-rules-mk --quiet --escape --keyboard $(KEYBOARD) --output $(KEYBOARD_OUTPUT)/src/info_rules.mk)
|
||||
include $(INFO_RULES_MK)
|
||||
|
||||
# Check for keymap.json first, so we can regenerate keymap.c
|
||||
include $(BUILDDEFS_PATH)/build_json.mk
|
||||
|
||||
# Pull in keymap level rules.mk
|
||||
ifeq ("$(wildcard $(KEYMAP_PATH))", "")
|
||||
# Look through the possible keymap folders until we find a matching keymap.c
|
||||
ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_5)/keymap.c)","")
|
||||
-include $(MAIN_KEYMAP_PATH_5)/rules.mk
|
||||
KEYMAP_C := $(MAIN_KEYMAP_PATH_5)/keymap.c
|
||||
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_5)
|
||||
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_4)/keymap.c)","")
|
||||
-include $(MAIN_KEYMAP_PATH_4)/rules.mk
|
||||
KEYMAP_C := $(MAIN_KEYMAP_PATH_4)/keymap.c
|
||||
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_4)
|
||||
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_3)/keymap.c)","")
|
||||
-include $(MAIN_KEYMAP_PATH_3)/rules.mk
|
||||
KEYMAP_C := $(MAIN_KEYMAP_PATH_3)/keymap.c
|
||||
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_3)
|
||||
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_2)/keymap.c)","")
|
||||
-include $(MAIN_KEYMAP_PATH_2)/rules.mk
|
||||
KEYMAP_C := $(MAIN_KEYMAP_PATH_2)/keymap.c
|
||||
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_2)
|
||||
else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_1)/keymap.c)","")
|
||||
-include $(MAIN_KEYMAP_PATH_1)/rules.mk
|
||||
KEYMAP_C := $(MAIN_KEYMAP_PATH_1)/keymap.c
|
||||
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_1)
|
||||
else ifneq ($(LAYOUTS),)
|
||||
# If we haven't found a keymap yet fall back to community layouts
|
||||
include $(BUILDDEFS_PATH)/build_layout.mk
|
||||
else
|
||||
$(call CATASTROPHIC_ERROR,Invalid keymap,Could not find keymap)
|
||||
# this state should never be reached
|
||||
endif
|
||||
endif
|
||||
|
||||
# Have we found a keymap.json?
|
||||
ifneq ("$(wildcard $(KEYMAP_JSON))", "")
|
||||
KEYMAP_C := $(KEYMAP_OUTPUT)/src/keymap.c
|
||||
KEYMAP_H := $(KEYMAP_OUTPUT)/src/config.h
|
||||
|
||||
# Load the keymap-level rules.mk if exists
|
||||
-include $(KEYMAP_PATH)/rules.mk
|
||||
|
||||
# Load any rules.mk content from keymap.json
|
||||
INFO_RULES_MK = $(shell $(QMK_BIN) generate-rules-mk --quiet --escape --keyboard $(KEYBOARD) --keymap $(KEYMAP) --output $(KEYMAP_OUTPUT)/src/rules.mk)
|
||||
include $(INFO_RULES_MK)
|
||||
|
||||
# Add rules to generate the keymap files - indentation here is important
|
||||
$(KEYMAP_OUTPUT)/src/keymap.c: $(KEYMAP_JSON)
|
||||
@$(SILENT) || printf "$(MSG_GENERATING) $@" | $(AWK_CMD)
|
||||
$(eval CMD=$(QMK_BIN) json2c --quiet --output $(KEYMAP_C) $(KEYMAP_JSON))
|
||||
@$(BUILD_CMD)
|
||||
|
||||
$(KEYMAP_OUTPUT)/src/config.h: $(KEYMAP_JSON)
|
||||
@$(SILENT) || printf "$(MSG_GENERATING) $@" | $(AWK_CMD)
|
||||
$(eval CMD=$(QMK_BIN) generate-config-h --quiet --keyboard $(KEYBOARD) --keymap $(KEYMAP) --output $(KEYMAP_H))
|
||||
@$(BUILD_CMD)
|
||||
|
||||
generated-files: $(KEYMAP_OUTPUT)/src/config.h $(KEYMAP_OUTPUT)/src/keymap.c
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(CTPC)), yes)
|
||||
CONVERT_TO_PROTON_C=yes
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(CONVERT_TO_PROTON_C)), yes)
|
||||
include platforms/chibios/boards/QMK_PROTON_C/convert_to_proton_c.mk
|
||||
endif
|
||||
|
||||
include $(BUILDDEFS_PATH)/mcu_selection.mk
|
||||
|
||||
# Find all the C source files to be compiled in subfolders.
|
||||
KEYBOARD_SRC :=
|
||||
|
||||
KEYBOARD_C_1 := $(KEYBOARD_PATH_1)/$(KEYBOARD_FOLDER_1).c
|
||||
KEYBOARD_C_2 := $(KEYBOARD_PATH_2)/$(KEYBOARD_FOLDER_2).c
|
||||
KEYBOARD_C_3 := $(KEYBOARD_PATH_3)/$(KEYBOARD_FOLDER_3).c
|
||||
KEYBOARD_C_4 := $(KEYBOARD_PATH_4)/$(KEYBOARD_FOLDER_4).c
|
||||
KEYBOARD_C_5 := $(KEYBOARD_PATH_5)/$(KEYBOARD_FOLDER_5).c
|
||||
|
||||
ifneq ("$(wildcard $(KEYBOARD_C_5))","")
|
||||
KEYBOARD_SRC += $(KEYBOARD_C_5)
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_C_4))","")
|
||||
KEYBOARD_SRC += $(KEYBOARD_C_4)
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_C_3))","")
|
||||
KEYBOARD_SRC += $(KEYBOARD_C_3)
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_C_2))","")
|
||||
KEYBOARD_SRC += $(KEYBOARD_C_2)
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_C_1))","")
|
||||
KEYBOARD_SRC += $(KEYBOARD_C_1)
|
||||
endif
|
||||
|
||||
# Generate KEYBOARD_name_subname for all levels of the keyboard folder
|
||||
KEYBOARD_FILESAFE_1 := $(subst .,,$(subst /,_,$(KEYBOARD_FOLDER_PATH_1)))
|
||||
KEYBOARD_FILESAFE_2 := $(subst .,,$(subst /,_,$(KEYBOARD_FOLDER_PATH_2)))
|
||||
KEYBOARD_FILESAFE_3 := $(subst .,,$(subst /,_,$(KEYBOARD_FOLDER_PATH_3)))
|
||||
KEYBOARD_FILESAFE_4 := $(subst .,,$(subst /,_,$(KEYBOARD_FOLDER_PATH_4)))
|
||||
KEYBOARD_FILESAFE_5 := $(subst .,,$(subst /,_,$(KEYBOARD_FOLDER_PATH_5)))
|
||||
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_5)/)","")
|
||||
OPT_DEFS += -DKEYBOARD_$(KEYBOARD_FILESAFE_5)
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_4)/)","")
|
||||
OPT_DEFS += -DKEYBOARD_$(KEYBOARD_FILESAFE_4)
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_3)/)","")
|
||||
OPT_DEFS += -DKEYBOARD_$(KEYBOARD_FILESAFE_3)
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_2)/)","")
|
||||
OPT_DEFS += -DKEYBOARD_$(KEYBOARD_FILESAFE_2)
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_1)/)","")
|
||||
OPT_DEFS += -DKEYBOARD_$(KEYBOARD_FILESAFE_1)
|
||||
endif
|
||||
|
||||
# Setup the define for QMK_KEYBOARD_H. This is used inside of keymaps so
|
||||
# that the same keymap may be used on multiple keyboards.
|
||||
#
|
||||
# We grab the most top-level include file that we can. That file should
|
||||
# use #ifdef statements to include all the neccesary subfolder includes,
|
||||
# as described here:
|
||||
#
|
||||
# https://docs.qmk.fm/#/feature_layouts?id=tips-for-making-layouts-keyboard-agnostic
|
||||
#
|
||||
QMK_KEYBOARD_H = $(KEYBOARD_OUTPUT)/src/default_keyboard.h
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_1)/$(KEYBOARD_FOLDER_1).h)","")
|
||||
QMK_KEYBOARD_H = $(KEYBOARD_FOLDER_1).h
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_2)/$(KEYBOARD_FOLDER_2).h)","")
|
||||
QMK_KEYBOARD_H = $(KEYBOARD_FOLDER_2).h
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_3)/$(KEYBOARD_FOLDER_3).h)","")
|
||||
QMK_KEYBOARD_H = $(KEYBOARD_FOLDER_3).h
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_4)/$(KEYBOARD_FOLDER_4).h)","")
|
||||
QMK_KEYBOARD_H = $(KEYBOARD_FOLDER_4).h
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_5)/$(KEYBOARD_FOLDER_5).h)","")
|
||||
QMK_KEYBOARD_H = $(KEYBOARD_FOLDER_5).h
|
||||
endif
|
||||
|
||||
# Determine and set parameters based on the keyboard's processor family.
|
||||
# We can assume a ChibiOS target When MCU_FAMILY is defined since it's
|
||||
# not used for LUFA
|
||||
ifdef MCU_FAMILY
|
||||
PLATFORM=CHIBIOS
|
||||
PLATFORM_KEY=chibios
|
||||
FIRMWARE_FORMAT?=bin
|
||||
OPT_DEFS += -DMCU_$(MCU_FAMILY)
|
||||
else ifdef ARM_ATSAM
|
||||
PLATFORM=ARM_ATSAM
|
||||
PLATFORM_KEY=arm_atsam
|
||||
FIRMWARE_FORMAT=bin
|
||||
else
|
||||
PLATFORM=AVR
|
||||
PLATFORM_KEY=avr
|
||||
FIRMWARE_FORMAT?=hex
|
||||
endif
|
||||
|
||||
# Find all of the config.h files and add them to our CONFIG_H define.
|
||||
CONFIG_H :=
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_5)/config.h)","")
|
||||
CONFIG_H += $(KEYBOARD_PATH_5)/config.h
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_4)/config.h)","")
|
||||
CONFIG_H += $(KEYBOARD_PATH_4)/config.h
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_3)/config.h)","")
|
||||
CONFIG_H += $(KEYBOARD_PATH_3)/config.h
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_2)/config.h)","")
|
||||
CONFIG_H += $(KEYBOARD_PATH_2)/config.h
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_1)/config.h)","")
|
||||
CONFIG_H += $(KEYBOARD_PATH_1)/config.h
|
||||
endif
|
||||
|
||||
POST_CONFIG_H :=
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_1)/post_config.h)","")
|
||||
POST_CONFIG_H += $(KEYBOARD_PATH_1)/post_config.h
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_2)/post_config.h)","")
|
||||
POST_CONFIG_H += $(KEYBOARD_PATH_2)/post_config.h
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_3)/post_config.h)","")
|
||||
POST_CONFIG_H += $(KEYBOARD_PATH_3)/post_config.h
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_4)/post_config.h)","")
|
||||
POST_CONFIG_H += $(KEYBOARD_PATH_4)/post_config.h
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_5)/post_config.h)","")
|
||||
POST_CONFIG_H += $(KEYBOARD_PATH_5)/post_config.h
|
||||
endif
|
||||
|
||||
# Pull in stuff from info.json
|
||||
INFO_JSON_FILES :=
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_1)/info.json)","")
|
||||
INFO_JSON_FILES += $(KEYBOARD_PATH_1)/info.json
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_2)/info.json)","")
|
||||
INFO_JSON_FILES += $(KEYBOARD_PATH_2)/info.json
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_3)/info.json)","")
|
||||
INFO_JSON_FILES += $(KEYBOARD_PATH_3)/info.json
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_4)/info.json)","")
|
||||
INFO_JSON_FILES += $(KEYBOARD_PATH_4)/info.json
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_5)/info.json)","")
|
||||
INFO_JSON_FILES += $(KEYBOARD_PATH_5)/info.json
|
||||
endif
|
||||
|
||||
CONFIG_H += $(KEYBOARD_OUTPUT)/src/info_config.h $(KEYBOARD_OUTPUT)/src/layouts.h
|
||||
|
||||
$(KEYBOARD_OUTPUT)/src/info_config.h: $(INFO_JSON_FILES)
|
||||
@$(SILENT) || printf "$(MSG_GENERATING) $@" | $(AWK_CMD)
|
||||
$(eval CMD=$(QMK_BIN) generate-config-h --quiet --keyboard $(KEYBOARD) --output $(KEYBOARD_OUTPUT)/src/info_config.h)
|
||||
@$(BUILD_CMD)
|
||||
|
||||
$(KEYBOARD_OUTPUT)/src/default_keyboard.h: $(INFO_JSON_FILES)
|
||||
@$(SILENT) || printf "$(MSG_GENERATING) $@" | $(AWK_CMD)
|
||||
$(eval CMD=$(QMK_BIN) generate-keyboard-h --quiet --keyboard $(KEYBOARD) --output $(KEYBOARD_OUTPUT)/src/default_keyboard.h)
|
||||
@$(BUILD_CMD)
|
||||
|
||||
$(KEYBOARD_OUTPUT)/src/layouts.h: $(INFO_JSON_FILES)
|
||||
@$(SILENT) || printf "$(MSG_GENERATING) $@" | $(AWK_CMD)
|
||||
$(eval CMD=$(QMK_BIN) generate-layouts --quiet --keyboard $(KEYBOARD) --output $(KEYBOARD_OUTPUT)/src/layouts.h)
|
||||
@$(BUILD_CMD)
|
||||
|
||||
generated-files: $(KEYBOARD_OUTPUT)/src/info_config.h $(KEYBOARD_OUTPUT)/src/default_keyboard.h $(KEYBOARD_OUTPUT)/src/layouts.h
|
||||
|
||||
.INTERMEDIATE : generated-files
|
||||
|
||||
# Userspace setup and definitions
|
||||
ifeq ("$(USER_NAME)","")
|
||||
USER_NAME := $(KEYMAP)
|
||||
endif
|
||||
USER_PATH := users/$(USER_NAME)
|
||||
|
||||
# Pull in user level rules.mk
|
||||
-include $(USER_PATH)/rules.mk
|
||||
ifneq ("$(wildcard $(USER_PATH)/config.h)","")
|
||||
CONFIG_H += $(USER_PATH)/config.h
|
||||
endif
|
||||
ifneq ("$(wildcard $(USER_PATH)/post_config.h)","")
|
||||
POST_CONFIG_H += $(USER_PATH)/post_config.h
|
||||
endif
|
||||
|
||||
# Disable features that a keyboard doesn't support
|
||||
-include $(BUILDDEFS_PATH)/disable_features.mk
|
||||
|
||||
# Pull in post_rules.mk files from all our subfolders
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_1)/post_rules.mk)","")
|
||||
include $(KEYBOARD_PATH_1)/post_rules.mk
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_2)/post_rules.mk)","")
|
||||
include $(KEYBOARD_PATH_2)/post_rules.mk
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_3)/post_rules.mk)","")
|
||||
include $(KEYBOARD_PATH_3)/post_rules.mk
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_4)/post_rules.mk)","")
|
||||
include $(KEYBOARD_PATH_4)/post_rules.mk
|
||||
endif
|
||||
ifneq ("$(wildcard $(KEYBOARD_PATH_5)/post_rules.mk)","")
|
||||
include $(KEYBOARD_PATH_5)/post_rules.mk
|
||||
endif
|
||||
|
||||
ifneq ("$(wildcard $(KEYMAP_PATH)/config.h)","")
|
||||
CONFIG_H += $(KEYMAP_PATH)/config.h
|
||||
endif
|
||||
ifneq ("$(KEYMAP_H)","")
|
||||
CONFIG_H += $(KEYMAP_H)
|
||||
endif
|
||||
|
||||
# project specific files
|
||||
SRC += \
|
||||
$(KEYBOARD_SRC) \
|
||||
$(KEYMAP_C) \
|
||||
$(QUANTUM_SRC) \
|
||||
$(QUANTUM_DIR)/main.c \
|
||||
|
||||
# Optimize size but this may cause error "relocation truncated to fit"
|
||||
#EXTRALDFLAGS = -Wl,--relax
|
||||
|
||||
# Search Path
|
||||
VPATH += $(KEYMAP_PATH)
|
||||
VPATH += $(USER_PATH)
|
||||
VPATH += $(KEYBOARD_PATHS)
|
||||
VPATH += $(COMMON_VPATH)
|
||||
VPATH += $(KEYBOARD_OUTPUT)/src
|
||||
VPATH += $(KEYMAP_OUTPUT)/src
|
||||
|
||||
include $(BUILDDEFS_PATH)/common_features.mk
|
||||
include $(BUILDDEFS_PATH)/generic_features.mk
|
||||
include $(TMK_PATH)/protocol.mk
|
||||
include $(PLATFORM_PATH)/common.mk
|
||||
include $(BUILDDEFS_PATH)/bootloader.mk
|
||||
|
||||
SRC += $(patsubst %.c,%.clib,$(LIB_SRC))
|
||||
SRC += $(patsubst %.c,%.clib,$(QUANTUM_LIB_SRC))
|
||||
SRC += $(TMK_COMMON_SRC)
|
||||
OPT_DEFS += $(TMK_COMMON_DEFS)
|
||||
EXTRALDFLAGS += $(TMK_COMMON_LDFLAGS)
|
||||
|
||||
SKIP_COMPILE := no
|
||||
ifneq ($(REQUIRE_PLATFORM_KEY),)
|
||||
ifneq ($(REQUIRE_PLATFORM_KEY),$(PLATFORM_KEY))
|
||||
SKIP_COMPILE := yes
|
||||
endif
|
||||
endif
|
||||
|
||||
include $(PLATFORM_PATH)/$(PLATFORM_KEY)/platform.mk
|
||||
-include $(PLATFORM_PATH)/$(PLATFORM_KEY)/flash.mk
|
||||
|
||||
ifneq ($(strip $(PROTOCOL)),)
|
||||
include $(TMK_PATH)/protocol/$(strip $(shell echo $(PROTOCOL) | tr '[:upper:]' '[:lower:]')).mk
|
||||
else
|
||||
include $(TMK_PATH)/protocol/$(PLATFORM_KEY).mk
|
||||
endif
|
||||
|
||||
# TODO: remove this bodge?
|
||||
PROJECT_DEFS := $(OPT_DEFS)
|
||||
PROJECT_INC := $(VPATH) $(EXTRAINCDIRS) $(KEYBOARD_PATHS)
|
||||
PROJECT_CONFIG := $(CONFIG_H)
|
||||
|
||||
CONFIG_H += $(POST_CONFIG_H)
|
||||
ALL_CONFIGS := $(PROJECT_CONFIG) $(CONFIG_H)
|
||||
|
||||
OUTPUTS := $(KEYMAP_OUTPUT) $(KEYBOARD_OUTPUT)
|
||||
$(KEYMAP_OUTPUT)_SRC := $(SRC)
|
||||
$(KEYMAP_OUTPUT)_DEFS := $(OPT_DEFS) \
|
||||
-DQMK_KEYBOARD=\"$(KEYBOARD)\" -DQMK_KEYBOARD_H=\"$(QMK_KEYBOARD_H)\" \
|
||||
-DQMK_KEYMAP=\"$(KEYMAP)\" -DQMK_KEYMAP_H=\"$(KEYMAP).h\" -DQMK_KEYMAP_CONFIG_H=\"$(KEYMAP_PATH)/config.h\"
|
||||
$(KEYMAP_OUTPUT)_INC := $(VPATH) $(EXTRAINCDIRS)
|
||||
$(KEYMAP_OUTPUT)_CONFIG := $(CONFIG_H)
|
||||
$(KEYBOARD_OUTPUT)_SRC := $(PLATFORM_SRC)
|
||||
$(KEYBOARD_OUTPUT)_DEFS := $(PROJECT_DEFS)
|
||||
$(KEYBOARD_OUTPUT)_INC := $(PROJECT_INC)
|
||||
$(KEYBOARD_OUTPUT)_CONFIG := $(PROJECT_CONFIG)
|
||||
|
||||
# Default target.
|
||||
ifeq ($(SKIP_COMPILE),no)
|
||||
all: build check-size
|
||||
else
|
||||
all:
|
||||
echo "skipped" >&2
|
||||
endif
|
||||
|
||||
build: elf cpfirmware
|
||||
check-size: build
|
||||
check-md5: build
|
||||
objs-size: build
|
||||
|
||||
include $(BUILDDEFS_PATH)/show_options.mk
|
||||
include $(BUILDDEFS_PATH)/common_rules.mk
|
||||
|
||||
# Ensure we have generated files available for each of the objects
|
||||
define GEN_FILES
|
||||
$1: generated-files
|
||||
endef
|
||||
$(foreach O,$(OBJ),$(eval $(call GEN_FILES,$(patsubst %.a,%.o,$(O)))))
|
||||
32
builddefs/build_layout.mk
Normal file
32
builddefs/build_layout.mk
Normal file
@@ -0,0 +1,32 @@
|
||||
LAYOUTS_PATH := layouts
|
||||
LAYOUTS_REPOS := $(patsubst %/,%,$(sort $(dir $(wildcard $(LAYOUTS_PATH)/*/))))
|
||||
|
||||
define SEARCH_LAYOUTS_REPO
|
||||
LAYOUT_KEYMAP_PATH := $$(LAYOUTS_REPO)/$$(LAYOUT)/$$(KEYMAP)
|
||||
LAYOUT_KEYMAP_JSON := $$(LAYOUT_KEYMAP_PATH)/keymap.json
|
||||
LAYOUT_KEYMAP_C := $$(LAYOUT_KEYMAP_PATH)/keymap.c
|
||||
ifneq ("$$(wildcard $$(LAYOUT_KEYMAP_JSON))","")
|
||||
-include $$(LAYOUT_KEYMAP_PATH)/rules.mk
|
||||
KEYMAP_JSON := $$(LAYOUT_KEYMAP_JSON)
|
||||
KEYMAP_PATH := $$(LAYOUT_KEYMAP_PATH)
|
||||
else ifneq ("$$(wildcard $$(LAYOUT_KEYMAP_C))","")
|
||||
-include $$(LAYOUT_KEYMAP_PATH)/rules.mk
|
||||
KEYMAP_C := $$(LAYOUT_KEYMAP_C)
|
||||
KEYMAP_PATH := $$(LAYOUT_KEYMAP_PATH)
|
||||
endif
|
||||
endef
|
||||
|
||||
define SEARCH_LAYOUTS
|
||||
$$(foreach LAYOUTS_REPO,$$(LAYOUTS_REPOS),$$(eval $$(call SEARCH_LAYOUTS_REPO)))
|
||||
endef
|
||||
|
||||
ifneq ($(FORCE_LAYOUT),)
|
||||
ifneq (,$(findstring $(FORCE_LAYOUT),$(LAYOUTS)))
|
||||
$(info Forcing layout: $(FORCE_LAYOUT))
|
||||
LAYOUTS := $(FORCE_LAYOUT)
|
||||
else
|
||||
$(call CATASTROPHIC_ERROR,Invalid layout,Forced layout does not exist)
|
||||
endif
|
||||
endif
|
||||
|
||||
$(foreach LAYOUT,$(LAYOUTS),$(eval $(call SEARCH_LAYOUTS)))
|
||||
84
builddefs/build_test.mk
Normal file
84
builddefs/build_test.mk
Normal file
@@ -0,0 +1,84 @@
|
||||
ifndef VERBOSE
|
||||
.SILENT:
|
||||
endif
|
||||
|
||||
.DEFAULT_GOAL := all
|
||||
|
||||
include paths.mk
|
||||
include $(BUILDDEFS_PATH)/message.mk
|
||||
|
||||
TARGET=test/$(TEST)
|
||||
|
||||
GTEST_OUTPUT = $(BUILD_DIR)/gtest
|
||||
|
||||
TEST_OBJ = $(BUILD_DIR)/test_obj
|
||||
|
||||
OUTPUTS := $(TEST_OBJ)/$(TEST) $(GTEST_OUTPUT)
|
||||
|
||||
GTEST_INC := \
|
||||
$(LIB_PATH)/googletest/googletest/include \
|
||||
$(LIB_PATH)/googletest/googlemock/include
|
||||
|
||||
GTEST_INTERNAL_INC := \
|
||||
$(LIB_PATH)/googletest/googletest \
|
||||
$(LIB_PATH)/googletest/googlemock
|
||||
|
||||
$(GTEST_OUTPUT)_SRC := \
|
||||
googletest/src/gtest-all.cc\
|
||||
googlemock/src/gmock-all.cc
|
||||
|
||||
$(GTEST_OUTPUT)_DEFS :=
|
||||
$(GTEST_OUTPUT)_INC := $(GTEST_INC) $(GTEST_INTERNAL_INC)
|
||||
|
||||
LDFLAGS += -lstdc++ -lpthread -shared-libgcc
|
||||
CREATE_MAP := no
|
||||
|
||||
VPATH += \
|
||||
$(LIB_PATH)/googletest \
|
||||
$(LIB_PATH)/googlemock \
|
||||
$(LIB_PATH)/printf
|
||||
|
||||
all: elf
|
||||
|
||||
VPATH += $(COMMON_VPATH)
|
||||
PLATFORM:=TEST
|
||||
PLATFORM_KEY:=test
|
||||
BOOTLOADER_TYPE:=none
|
||||
|
||||
ifeq ($(strip $(DEBUG)), 1)
|
||||
CONSOLE_ENABLE = yes
|
||||
endif
|
||||
|
||||
ifneq ($(filter $(FULL_TESTS),$(TEST)),)
|
||||
include tests/test_common/build.mk
|
||||
include $(TEST_PATH)/test.mk
|
||||
endif
|
||||
|
||||
include $(BUILDDEFS_PATH)/common_features.mk
|
||||
include $(BUILDDEFS_PATH)/generic_features.mk
|
||||
include $(PLATFORM_PATH)/common.mk
|
||||
include $(TMK_PATH)/protocol.mk
|
||||
include $(QUANTUM_PATH)/debounce/tests/rules.mk
|
||||
include $(QUANTUM_PATH)/encoder/tests/rules.mk
|
||||
include $(QUANTUM_PATH)/sequencer/tests/rules.mk
|
||||
include $(PLATFORM_PATH)/test/rules.mk
|
||||
ifneq ($(filter $(FULL_TESTS),$(TEST)),)
|
||||
include $(BUILDDEFS_PATH)/build_full_test.mk
|
||||
endif
|
||||
|
||||
$(TEST)_SRC += \
|
||||
tests/test_common/main.c \
|
||||
$(LIB_PATH)/printf/printf.c \
|
||||
$(QUANTUM_PATH)/logging/print.c
|
||||
|
||||
$(TEST_OBJ)/$(TEST)_SRC := $($(TEST)_SRC)
|
||||
$(TEST_OBJ)/$(TEST)_INC := $($(TEST)_INC) $(VPATH) $(GTEST_INC)
|
||||
$(TEST_OBJ)/$(TEST)_DEFS := $($(TEST)_DEFS)
|
||||
$(TEST_OBJ)/$(TEST)_CONFIG := $($(TEST)_CONFIG)
|
||||
|
||||
include $(PLATFORM_PATH)/$(PLATFORM_KEY)/platform.mk
|
||||
include $(BUILDDEFS_PATH)/common_rules.mk
|
||||
|
||||
|
||||
$(shell mkdir -p $(BUILD_DIR)/test 2>/dev/null)
|
||||
$(shell mkdir -p $(TEST_OBJ) 2>/dev/null)
|
||||
816
builddefs/common_features.mk
Normal file
816
builddefs/common_features.mk
Normal file
@@ -0,0 +1,816 @@
|
||||
# Copyright 2017 Fred Sundvik
|
||||
#
|
||||
# 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/>.
|
||||
|
||||
QUANTUM_SRC += \
|
||||
$(QUANTUM_DIR)/quantum.c \
|
||||
$(QUANTUM_DIR)/send_string.c \
|
||||
$(QUANTUM_DIR)/bitwise.c \
|
||||
$(QUANTUM_DIR)/led.c \
|
||||
$(QUANTUM_DIR)/action.c \
|
||||
$(QUANTUM_DIR)/action_layer.c \
|
||||
$(QUANTUM_DIR)/action_tapping.c \
|
||||
$(QUANTUM_DIR)/action_util.c \
|
||||
$(QUANTUM_DIR)/eeconfig.c \
|
||||
$(QUANTUM_DIR)/keyboard.c \
|
||||
$(QUANTUM_DIR)/keymap_common.c \
|
||||
$(QUANTUM_DIR)/keycode_config.c \
|
||||
$(QUANTUM_DIR)/sync_timer.c \
|
||||
$(QUANTUM_DIR)/logging/debug.c \
|
||||
$(QUANTUM_DIR)/logging/sendchar.c \
|
||||
|
||||
VPATH += $(QUANTUM_DIR)/logging
|
||||
# Fall back to lib/printf if there is no platform provided print
|
||||
ifeq ("$(wildcard $(PLATFORM_PATH)/$(PLATFORM_KEY)/printf.mk)","")
|
||||
include $(QUANTUM_PATH)/logging/print.mk
|
||||
else
|
||||
include $(PLATFORM_PATH)/$(PLATFORM_KEY)/printf.mk
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(DEBUG_MATRIX_SCAN_RATE_ENABLE)), yes)
|
||||
OPT_DEFS += -DDEBUG_MATRIX_SCAN_RATE
|
||||
CONSOLE_ENABLE = yes
|
||||
else ifeq ($(strip $(DEBUG_MATRIX_SCAN_RATE_ENABLE)), api)
|
||||
OPT_DEFS += -DDEBUG_MATRIX_SCAN_RATE
|
||||
endif
|
||||
|
||||
AUDIO_ENABLE ?= no
|
||||
ifeq ($(strip $(AUDIO_ENABLE)), yes)
|
||||
ifeq ($(PLATFORM),CHIBIOS)
|
||||
AUDIO_DRIVER ?= dac_basic
|
||||
ifeq ($(strip $(AUDIO_DRIVER)), dac_basic)
|
||||
OPT_DEFS += -DAUDIO_DRIVER_DAC
|
||||
else ifeq ($(strip $(AUDIO_DRIVER)), dac_additive)
|
||||
OPT_DEFS += -DAUDIO_DRIVER_DAC
|
||||
## stm32f2 and above have a usable DAC unit, f1 do not, and need to use pwm instead
|
||||
else ifeq ($(strip $(AUDIO_DRIVER)), pwm_software)
|
||||
OPT_DEFS += -DAUDIO_DRIVER_PWM
|
||||
else ifeq ($(strip $(AUDIO_DRIVER)), pwm_hardware)
|
||||
OPT_DEFS += -DAUDIO_DRIVER_PWM
|
||||
endif
|
||||
else
|
||||
# fallback for all other platforms is pwm
|
||||
AUDIO_DRIVER ?= pwm_hardware
|
||||
OPT_DEFS += -DAUDIO_DRIVER_PWM
|
||||
endif
|
||||
OPT_DEFS += -DAUDIO_ENABLE
|
||||
MUSIC_ENABLE = yes
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_audio.c
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_clicky.c
|
||||
SRC += $(QUANTUM_DIR)/audio/audio.c ## common audio code, hardware agnostic
|
||||
SRC += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/audio_$(strip $(AUDIO_DRIVER)).c
|
||||
SRC += $(QUANTUM_DIR)/audio/voices.c
|
||||
SRC += $(QUANTUM_DIR)/audio/luts.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(SEQUENCER_ENABLE)), yes)
|
||||
OPT_DEFS += -DSEQUENCER_ENABLE
|
||||
MUSIC_ENABLE = yes
|
||||
SRC += $(QUANTUM_DIR)/sequencer/sequencer.c
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_sequencer.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(MIDI_ENABLE)), yes)
|
||||
OPT_DEFS += -DMIDI_ENABLE
|
||||
MUSIC_ENABLE = yes
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_midi.c
|
||||
endif
|
||||
|
||||
MUSIC_ENABLE ?= no
|
||||
ifeq ($(MUSIC_ENABLE), yes)
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_music.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(STENO_ENABLE)), yes)
|
||||
OPT_DEFS += -DSTENO_ENABLE
|
||||
VIRTSER_ENABLE ?= yes
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_steno.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(VIRTSER_ENABLE)), yes)
|
||||
OPT_DEFS += -DVIRTSER_ENABLE
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(MOUSEKEY_ENABLE)), yes)
|
||||
OPT_DEFS += -DMOUSEKEY_ENABLE
|
||||
MOUSE_ENABLE := yes
|
||||
SRC += $(QUANTUM_DIR)/mousekey.c
|
||||
endif
|
||||
|
||||
VALID_POINTING_DEVICE_DRIVER_TYPES := adns5050 adns9800 analog_joystick cirque_pinnacle_i2c cirque_pinnacle_spi pmw3360 pmw3389 pimoroni_trackball custom
|
||||
ifeq ($(strip $(POINTING_DEVICE_ENABLE)), yes)
|
||||
ifeq ($(filter $(POINTING_DEVICE_DRIVER),$(VALID_POINTING_DEVICE_DRIVER_TYPES)),)
|
||||
$(call CATASTROPHIC_ERROR,Invalid POINTING_DEVICE_DRIVER,POINTING_DEVICE_DRIVER="$(POINTING_DEVICE_DRIVER)" is not a valid pointing device type)
|
||||
else
|
||||
OPT_DEFS += -DPOINTING_DEVICE_ENABLE
|
||||
MOUSE_ENABLE := yes
|
||||
SRC += $(QUANTUM_DIR)/pointing_device.c
|
||||
SRC += $(QUANTUM_DIR)/pointing_device_drivers.c
|
||||
ifneq ($(strip $(POINTING_DEVICE_DRIVER)), custom)
|
||||
SRC += drivers/sensors/$(strip $(POINTING_DEVICE_DRIVER)).c
|
||||
OPT_DEFS += -DPOINTING_DEVICE_DRIVER_$(strip $(shell echo $(POINTING_DEVICE_DRIVER) | tr '[:lower:]' '[:upper:]'))
|
||||
endif
|
||||
OPT_DEFS += -DPOINTING_DEVICE_DRIVER_$(strip $(POINTING_DEVICE_DRIVER))
|
||||
ifeq ($(strip $(POINTING_DEVICE_DRIVER)), adns9800)
|
||||
OPT_DEFS += -DSTM32_SPI -DHAL_USE_SPI=TRUE
|
||||
QUANTUM_LIB_SRC += spi_master.c
|
||||
else ifeq ($(strip $(POINTING_DEVICE_DRIVER)), analog_joystick)
|
||||
OPT_DEFS += -DSTM32_ADC -DHAL_USE_ADC=TRUE
|
||||
LIB_SRC += analog.c
|
||||
else ifeq ($(strip $(POINTING_DEVICE_DRIVER)), cirque_pinnacle_i2c)
|
||||
OPT_DEFS += -DSTM32_I2C -DHAL_USE_I2C=TRUE
|
||||
SRC += drivers/sensors/cirque_pinnacle.c
|
||||
QUANTUM_LIB_SRC += i2c_master.c
|
||||
else ifeq ($(strip $(POINTING_DEVICE_DRIVER)), cirque_pinnacle_spi)
|
||||
OPT_DEFS += -DSTM32_SPI -DHAL_USE_SPI=TRUE
|
||||
SRC += drivers/sensors/cirque_pinnacle.c
|
||||
QUANTUM_LIB_SRC += spi_master.c
|
||||
else ifeq ($(strip $(POINTING_DEVICE_DRIVER)), pimoroni_trackball)
|
||||
OPT_DEFS += -DSTM32_SPI -DHAL_USE_I2C=TRUE
|
||||
QUANTUM_LIB_SRC += i2c_master.c
|
||||
else ifeq ($(strip $(POINTING_DEVICE_DRIVER)), pmw3360)
|
||||
OPT_DEFS += -DSTM32_SPI -DHAL_USE_SPI=TRUE
|
||||
QUANTUM_LIB_SRC += spi_master.c
|
||||
else ifeq ($(strip $(POINTING_DEVICE_DRIVER)), pmw3389)
|
||||
OPT_DEFS += -DSTM32_SPI -DHAL_USE_SPI=TRUE
|
||||
QUANTUM_LIB_SRC += spi_master.c
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
VALID_EEPROM_DRIVER_TYPES := vendor custom transient i2c spi
|
||||
EEPROM_DRIVER ?= vendor
|
||||
ifeq ($(filter $(EEPROM_DRIVER),$(VALID_EEPROM_DRIVER_TYPES)),)
|
||||
$(call CATASTROPHIC_ERROR,Invalid EEPROM_DRIVER,EEPROM_DRIVER="$(EEPROM_DRIVER)" is not a valid EEPROM driver)
|
||||
else
|
||||
OPT_DEFS += -DEEPROM_ENABLE
|
||||
ifeq ($(strip $(EEPROM_DRIVER)), custom)
|
||||
# Custom EEPROM implementation -- only needs to implement init/erase/read_block/write_block
|
||||
OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_CUSTOM
|
||||
COMMON_VPATH += $(DRIVER_PATH)/eeprom
|
||||
SRC += eeprom_driver.c
|
||||
else ifeq ($(strip $(EEPROM_DRIVER)), i2c)
|
||||
# External I2C EEPROM implementation
|
||||
OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_I2C
|
||||
COMMON_VPATH += $(DRIVER_PATH)/eeprom
|
||||
QUANTUM_LIB_SRC += i2c_master.c
|
||||
SRC += eeprom_driver.c eeprom_i2c.c
|
||||
else ifeq ($(strip $(EEPROM_DRIVER)), spi)
|
||||
# External SPI EEPROM implementation
|
||||
OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_SPI
|
||||
COMMON_VPATH += $(DRIVER_PATH)/eeprom
|
||||
QUANTUM_LIB_SRC += spi_master.c
|
||||
SRC += eeprom_driver.c eeprom_spi.c
|
||||
else ifeq ($(strip $(EEPROM_DRIVER)), transient)
|
||||
# Transient EEPROM implementation -- no data storage but provides runtime area for it
|
||||
OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_TRANSIENT
|
||||
COMMON_VPATH += $(DRIVER_PATH)/eeprom
|
||||
SRC += eeprom_driver.c eeprom_transient.c
|
||||
else ifeq ($(strip $(EEPROM_DRIVER)), vendor)
|
||||
# Vendor-implemented EEPROM
|
||||
OPT_DEFS += -DEEPROM_VENDOR
|
||||
ifeq ($(PLATFORM),AVR)
|
||||
# Automatically provided by avr-libc, nothing required
|
||||
else ifeq ($(PLATFORM),CHIBIOS)
|
||||
ifneq ($(filter STM32F3xx_% STM32F1xx_% %_STM32F401xC %_STM32F401xE %_STM32F405xG %_STM32F411xE %_STM32F072xB %_STM32F042x6 %_GD32VF103xB %_GD32VF103x8, $(MCU_SERIES)_$(MCU_LDSCRIPT)),)
|
||||
# Emulated EEPROM
|
||||
OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_STM32_FLASH_EMULATED
|
||||
COMMON_VPATH += $(DRIVER_PATH)/eeprom
|
||||
SRC += eeprom_driver.c
|
||||
SRC += $(PLATFORM_COMMON_DIR)/eeprom_stm32.c
|
||||
SRC += $(PLATFORM_COMMON_DIR)/flash_stm32.c
|
||||
else ifneq ($(filter $(MCU_SERIES),STM32L0xx STM32L1xx),)
|
||||
# True EEPROM on STM32L0xx, L1xx
|
||||
OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_STM32_L0_L1
|
||||
COMMON_VPATH += $(DRIVER_PATH)/eeprom
|
||||
COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/eeprom
|
||||
SRC += eeprom_driver.c
|
||||
SRC += eeprom_stm32_L0_L1.c
|
||||
else ifneq ($(filter $(MCU_SERIES),KL2x K20x),)
|
||||
# Teensy EEPROM implementations
|
||||
OPT_DEFS += -DEEPROM_TEENSY
|
||||
SRC += eeprom_teensy.c
|
||||
else
|
||||
# Fall back to transient, i.e. non-persistent
|
||||
OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_TRANSIENT
|
||||
COMMON_VPATH += $(DRIVER_PATH)/eeprom
|
||||
SRC += eeprom_driver.c eeprom_transient.c
|
||||
endif
|
||||
else ifeq ($(PLATFORM),ARM_ATSAM)
|
||||
# arm_atsam EEPROM
|
||||
OPT_DEFS += -DEEPROM_SAMD
|
||||
SRC += $(PLATFORM_COMMON_DIR)/eeprom_samd.c
|
||||
else ifeq ($(PLATFORM),TEST)
|
||||
# Test harness "EEPROM"
|
||||
OPT_DEFS += -DEEPROM_TEST_HARNESS
|
||||
SRC += $(PLATFORM_COMMON_DIR)/eeprom.c
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
VALID_FLASH_DRIVER_TYPES := spi
|
||||
FLASH_DRIVER ?= no
|
||||
ifneq ($(strip $(FLASH_DRIVER)), no)
|
||||
ifeq ($(filter $(FLASH_DRIVER),$(VALID_FLASH_DRIVER_TYPES)),)
|
||||
$(error FLASH_DRIVER="$(FLASH_DRIVER)" is not a valid FLASH driver)
|
||||
else
|
||||
OPT_DEFS += -DFLASH_ENABLE
|
||||
ifeq ($(strip $(FLASH_DRIVER)), spi)
|
||||
OPT_DEFS += -DFLASH_DRIVER -DFLASH_SPI
|
||||
COMMON_VPATH += $(DRIVER_PATH)/flash
|
||||
SRC += flash_spi.c
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
RGBLIGHT_ENABLE ?= no
|
||||
VALID_RGBLIGHT_TYPES := WS2812 APA102 custom
|
||||
|
||||
ifeq ($(strip $(RGBLIGHT_CUSTOM_DRIVER)), yes)
|
||||
RGBLIGHT_DRIVER ?= custom
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
|
||||
RGBLIGHT_DRIVER ?= WS2812
|
||||
|
||||
ifeq ($(filter $(RGBLIGHT_DRIVER),$(VALID_RGBLIGHT_TYPES)),)
|
||||
$(call CATASTROPHIC_ERROR,Invalid RGBLIGHT_DRIVER,RGBLIGHT_DRIVER="$(RGBLIGHT_DRIVER)" is not a valid RGB type)
|
||||
else
|
||||
COMMON_VPATH += $(QUANTUM_DIR)/rgblight
|
||||
POST_CONFIG_H += $(QUANTUM_DIR)/rgblight/rgblight_post_config.h
|
||||
OPT_DEFS += -DRGBLIGHT_ENABLE
|
||||
SRC += $(QUANTUM_DIR)/color.c
|
||||
SRC += $(QUANTUM_DIR)/rgblight/rgblight.c
|
||||
CIE1931_CURVE := yes
|
||||
RGB_KEYCODES_ENABLE := yes
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(RGBLIGHT_DRIVER)), WS2812)
|
||||
WS2812_DRIVER_REQUIRED := yes
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(RGBLIGHT_DRIVER)), APA102)
|
||||
APA102_DRIVER_REQUIRED := yes
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(RGBLIGHT_DRIVER)), custom)
|
||||
OPT_DEFS += -DRGBLIGHT_CUSTOM_DRIVER
|
||||
endif
|
||||
endif
|
||||
|
||||
LED_MATRIX_ENABLE ?= no
|
||||
VALID_LED_MATRIX_TYPES := IS31FL3731 IS31FL3742A IS31FL3743A IS31FL3745 IS31FL3746A custom
|
||||
# TODO: IS31FL3733 IS31FL3737 IS31FL3741
|
||||
|
||||
ifeq ($(strip $(LED_MATRIX_ENABLE)), yes)
|
||||
ifeq ($(filter $(LED_MATRIX_DRIVER),$(VALID_LED_MATRIX_TYPES)),)
|
||||
$(call CATASTROPHIC_ERROR,Invalid LED_MATRIX_DRIVER,LED_MATRIX_DRIVER="$(LED_MATRIX_DRIVER)" is not a valid matrix type)
|
||||
endif
|
||||
OPT_DEFS += -DLED_MATRIX_ENABLE
|
||||
ifneq (,$(filter $(MCU), atmega16u2 atmega32u2 at90usb162))
|
||||
# ATmegaxxU2 does not have hardware MUL instruction - lib8tion must be told to use software multiplication routines
|
||||
OPT_DEFS += -DLIB8_ATTINY
|
||||
endif
|
||||
COMMON_VPATH += $(QUANTUM_DIR)/led_matrix
|
||||
COMMON_VPATH += $(QUANTUM_DIR)/led_matrix/animations
|
||||
COMMON_VPATH += $(QUANTUM_DIR)/led_matrix/animations/runners
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_backlight.c
|
||||
SRC += $(QUANTUM_DIR)/led_matrix/led_matrix.c
|
||||
SRC += $(QUANTUM_DIR)/led_matrix/led_matrix_drivers.c
|
||||
SRC += $(LIB_PATH)/lib8tion/lib8tion.c
|
||||
CIE1931_CURVE := yes
|
||||
|
||||
ifeq ($(strip $(LED_MATRIX_DRIVER)), IS31FL3731)
|
||||
OPT_DEFS += -DIS31FL3731 -DSTM32_I2C -DHAL_USE_I2C=TRUE
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31fl3731-simple.c
|
||||
QUANTUM_LIB_SRC += i2c_master.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(LED_MATRIX_DRIVER)), IS31FL3742A)
|
||||
OPT_DEFS += -DIS31FLCOMMON -DIS31FL3742A -DSTM32_I2C -DHAL_USE_I2C=TRUE
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31flcommon.c
|
||||
QUANTUM_LIB_SRC += i2c_master.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(LED_MATRIX_DRIVER)), IS31FL3743A)
|
||||
OPT_DEFS += -DIS31FLCOMMON -DIS31FL3743A -DSTM32_I2C -DHAL_USE_I2C=TRUE
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31flcommon.c
|
||||
QUANTUM_LIB_SRC += i2c_master.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(LED_MATRIX_DRIVER)), IS31FL3745)
|
||||
OPT_DEFS += -DIS31FLCOMMON -DIS31FL3745 -DSTM32_I2C -DHAL_USE_I2C=TRUE
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31flcommon.c
|
||||
QUANTUM_LIB_SRC += i2c_master.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(LED_MATRIX_DRIVER)), IS31FL3746A)
|
||||
OPT_DEFS += -DIS31FLCOMMON -DIS31FL3746A -DSTM32_I2C -DHAL_USE_I2C=TRUE
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31flcommon.c
|
||||
QUANTUM_LIB_SRC += i2c_master.c
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
RGB_MATRIX_ENABLE ?= no
|
||||
|
||||
VALID_RGB_MATRIX_TYPES := AW20216 IS31FL3731 IS31FL3733 IS31FL3737 IS31FL3741 IS31FL3742A IS31FL3743A IS31FL3745 IS31FL3746A CKLED2001 WS2812 custom
|
||||
ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes)
|
||||
ifeq ($(filter $(RGB_MATRIX_DRIVER),$(VALID_RGB_MATRIX_TYPES)),)
|
||||
$(call CATASTROPHIC_ERROR,Invalid RGB_MATRIX_DRIVER,RGB_MATRIX_DRIVER="$(RGB_MATRIX_DRIVER)" is not a valid matrix type)
|
||||
endif
|
||||
OPT_DEFS += -DRGB_MATRIX_ENABLE
|
||||
ifneq (,$(filter $(MCU), atmega16u2 atmega32u2 at90usb162))
|
||||
# ATmegaxxU2 does not have hardware MUL instruction - lib8tion must be told to use software multiplication routines
|
||||
OPT_DEFS += -DLIB8_ATTINY
|
||||
endif
|
||||
COMMON_VPATH += $(QUANTUM_DIR)/rgb_matrix
|
||||
COMMON_VPATH += $(QUANTUM_DIR)/rgb_matrix/animations
|
||||
COMMON_VPATH += $(QUANTUM_DIR)/rgb_matrix/animations/runners
|
||||
SRC += $(QUANTUM_DIR)/color.c
|
||||
SRC += $(QUANTUM_DIR)/rgb_matrix/rgb_matrix.c
|
||||
SRC += $(QUANTUM_DIR)/rgb_matrix/rgb_matrix_drivers.c
|
||||
SRC += $(LIB_PATH)/lib8tion/lib8tion.c
|
||||
CIE1931_CURVE := yes
|
||||
RGB_KEYCODES_ENABLE := yes
|
||||
|
||||
ifeq ($(strip $(RGB_MATRIX_DRIVER)), AW20216)
|
||||
OPT_DEFS += -DAW20216 -DSTM32_SPI -DHAL_USE_SPI=TRUE
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led
|
||||
SRC += aw20216.c
|
||||
QUANTUM_LIB_SRC += spi_master.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(RGB_MATRIX_DRIVER)), IS31FL3731)
|
||||
OPT_DEFS += -DIS31FL3731 -DSTM32_I2C -DHAL_USE_I2C=TRUE
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31fl3731.c
|
||||
QUANTUM_LIB_SRC += i2c_master.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(RGB_MATRIX_DRIVER)), IS31FL3733)
|
||||
OPT_DEFS += -DIS31FL3733 -DSTM32_I2C -DHAL_USE_I2C=TRUE
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31fl3733.c
|
||||
QUANTUM_LIB_SRC += i2c_master.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(RGB_MATRIX_DRIVER)), IS31FL3737)
|
||||
OPT_DEFS += -DIS31FL3737 -DSTM32_I2C -DHAL_USE_I2C=TRUE
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31fl3737.c
|
||||
QUANTUM_LIB_SRC += i2c_master.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(RGB_MATRIX_DRIVER)), IS31FL3741)
|
||||
OPT_DEFS += -DIS31FL3741 -DSTM32_I2C -DHAL_USE_I2C=TRUE
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31fl3741.c
|
||||
QUANTUM_LIB_SRC += i2c_master.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(RGB_MATRIX_DRIVER)), IS31FL3742A)
|
||||
OPT_DEFS += -DIS31FLCOMMON -DIS31FL3742A -DSTM32_I2C -DHAL_USE_I2C=TRUE
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31flcommon.c
|
||||
QUANTUM_LIB_SRC += i2c_master.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(RGB_MATRIX_DRIVER)), IS31FL3743A)
|
||||
OPT_DEFS += -DIS31FLCOMMON -DIS31FL3743A -DSTM32_I2C -DHAL_USE_I2C=TRUE
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31flcommon.c
|
||||
QUANTUM_LIB_SRC += i2c_master.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(RGB_MATRIX_DRIVER)), IS31FL3745)
|
||||
OPT_DEFS += -DIS31FLCOMMON -DIS31FL3745 -DSTM32_I2C -DHAL_USE_I2C=TRUE
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31flcommon.c
|
||||
QUANTUM_LIB_SRC += i2c_master.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(RGB_MATRIX_DRIVER)), IS31FL3746A)
|
||||
OPT_DEFS += -DIS31FLCOMMON -DIS31FL3746A -DSTM32_I2C -DHAL_USE_I2C=TRUE
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led/issi
|
||||
SRC += is31flcommon.c
|
||||
QUANTUM_LIB_SRC += i2c_master.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(RGB_MATRIX_DRIVER)), CKLED2001)
|
||||
OPT_DEFS += -DCKLED2001 -DSTM32_I2C -DHAL_USE_I2C=TRUE
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led
|
||||
SRC += ckled2001.c
|
||||
QUANTUM_LIB_SRC += i2c_master.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(RGB_MATRIX_DRIVER)), WS2812)
|
||||
OPT_DEFS += -DWS2812
|
||||
WS2812_DRIVER_REQUIRED := yes
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(RGB_MATRIX_DRIVER)), APA102)
|
||||
OPT_DEFS += -DAPA102
|
||||
APA102_DRIVER_REQUIRED := yes
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(RGB_MATRIX_CUSTOM_KB)), yes)
|
||||
OPT_DEFS += -DRGB_MATRIX_CUSTOM_KB
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(RGB_MATRIX_CUSTOM_USER)), yes)
|
||||
OPT_DEFS += -DRGB_MATRIX_CUSTOM_USER
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(RGB_KEYCODES_ENABLE)), yes)
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_rgb.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(PRINTING_ENABLE)), yes)
|
||||
OPT_DEFS += -DPRINTING_ENABLE
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_printer.c
|
||||
QUANTUM_LIB_SRC += uart.c
|
||||
endif
|
||||
|
||||
VARIABLE_TRACE ?= no
|
||||
ifneq ($(strip $(VARIABLE_TRACE)),no)
|
||||
SRC += $(QUANTUM_DIR)/variable_trace.c
|
||||
OPT_DEFS += -DNUM_TRACED_VARIABLES=$(strip $(VARIABLE_TRACE))
|
||||
ifneq ($(strip $(MAX_VARIABLE_TRACE_SIZE)),)
|
||||
OPT_DEFS += -DMAX_VARIABLE_TRACE_SIZE=$(strip $(MAX_VARIABLE_TRACE_SIZE))
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(SLEEP_LED_ENABLE)), yes)
|
||||
SRC += $(PLATFORM_COMMON_DIR)/sleep_led.c
|
||||
OPT_DEFS += -DSLEEP_LED_ENABLE
|
||||
|
||||
NO_SUSPEND_POWER_DOWN := yes
|
||||
endif
|
||||
|
||||
VALID_BACKLIGHT_TYPES := pwm timer software custom
|
||||
|
||||
BACKLIGHT_ENABLE ?= no
|
||||
ifeq ($(strip $(CONVERT_TO_PROTON_C)), yes)
|
||||
BACKLIGHT_DRIVER ?= software
|
||||
else
|
||||
BACKLIGHT_DRIVER ?= pwm
|
||||
endif
|
||||
ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
|
||||
ifeq ($(filter $(BACKLIGHT_DRIVER),$(VALID_BACKLIGHT_TYPES)),)
|
||||
$(call CATASTROPHIC_ERROR,Invalid BACKLIGHT_DRIVER,BACKLIGHT_DRIVER="$(BACKLIGHT_DRIVER)" is not a valid backlight type)
|
||||
endif
|
||||
|
||||
COMMON_VPATH += $(QUANTUM_DIR)/backlight
|
||||
SRC += $(QUANTUM_DIR)/backlight/backlight.c
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_backlight.c
|
||||
OPT_DEFS += -DBACKLIGHT_ENABLE
|
||||
|
||||
ifeq ($(strip $(BACKLIGHT_DRIVER)), custom)
|
||||
OPT_DEFS += -DBACKLIGHT_CUSTOM_DRIVER
|
||||
else
|
||||
SRC += $(QUANTUM_DIR)/backlight/backlight_driver_common.c
|
||||
ifeq ($(strip $(BACKLIGHT_DRIVER)), pwm)
|
||||
SRC += $(QUANTUM_DIR)/backlight/backlight_$(PLATFORM_KEY).c
|
||||
else
|
||||
SRC += $(QUANTUM_DIR)/backlight/backlight_$(strip $(BACKLIGHT_DRIVER)).c
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
VALID_WS2812_DRIVER_TYPES := bitbang pwm spi i2c
|
||||
|
||||
WS2812_DRIVER ?= bitbang
|
||||
ifeq ($(strip $(WS2812_DRIVER_REQUIRED)), yes)
|
||||
ifeq ($(filter $(WS2812_DRIVER),$(VALID_WS2812_DRIVER_TYPES)),)
|
||||
$(call CATASTROPHIC_ERROR,Invalid WS2812_DRIVER,WS2812_DRIVER="$(WS2812_DRIVER)" is not a valid WS2812 driver)
|
||||
endif
|
||||
|
||||
OPT_DEFS += -DWS2812_DRIVER_$(strip $(shell echo $(WS2812_DRIVER) | tr '[:lower:]' '[:upper:]'))
|
||||
|
||||
ifeq ($(strip $(WS2812_DRIVER)), bitbang)
|
||||
SRC += ws2812.c
|
||||
else
|
||||
SRC += ws2812_$(strip $(WS2812_DRIVER)).c
|
||||
|
||||
ifeq ($(strip $(PLATFORM)), CHIBIOS)
|
||||
ifeq ($(strip $(WS2812_DRIVER)), pwm)
|
||||
OPT_DEFS += -DSTM32_DMA_REQUIRED=TRUE
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# add extra deps
|
||||
ifeq ($(strip $(WS2812_DRIVER)), i2c)
|
||||
QUANTUM_LIB_SRC += i2c_master.c
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(APA102_DRIVER_REQUIRED)), yes)
|
||||
COMMON_VPATH += $(DRIVER_PATH)/led
|
||||
SRC += apa102.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(CIE1931_CURVE)), yes)
|
||||
OPT_DEFS += -DUSE_CIE1931_CURVE
|
||||
LED_TABLES := yes
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(LED_TABLES)), yes)
|
||||
SRC += $(QUANTUM_DIR)/led_tables.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(TERMINAL_ENABLE)), yes)
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_terminal.c
|
||||
OPT_DEFS += -DTERMINAL_ENABLE
|
||||
OPT_DEFS += -DUSER_PRINT
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(VIA_ENABLE)), yes)
|
||||
DYNAMIC_KEYMAP_ENABLE := yes
|
||||
RAW_ENABLE := yes
|
||||
BOOTMAGIC_ENABLE := yes
|
||||
SRC += $(QUANTUM_DIR)/via.c
|
||||
OPT_DEFS += -DVIA_ENABLE
|
||||
endif
|
||||
|
||||
VALID_MAGIC_TYPES := yes
|
||||
BOOTMAGIC_ENABLE ?= no
|
||||
ifneq ($(strip $(BOOTMAGIC_ENABLE)), no)
|
||||
ifeq ($(filter $(BOOTMAGIC_ENABLE),$(VALID_MAGIC_TYPES)),)
|
||||
$(call CATASTROPHIC_ERROR,Invalid BOOTMAGIC_ENABLE,BOOTMAGIC_ENABLE="$(BOOTMAGIC_ENABLE)" is not a valid type of magic)
|
||||
endif
|
||||
ifneq ($(strip $(BOOTMAGIC_ENABLE)), no)
|
||||
OPT_DEFS += -DBOOTMAGIC_LITE
|
||||
QUANTUM_SRC += $(QUANTUM_DIR)/bootmagic/bootmagic_lite.c
|
||||
endif
|
||||
endif
|
||||
COMMON_VPATH += $(QUANTUM_DIR)/bootmagic
|
||||
QUANTUM_SRC += $(QUANTUM_DIR)/bootmagic/magic.c
|
||||
|
||||
VALID_CUSTOM_MATRIX_TYPES:= yes lite no
|
||||
|
||||
CUSTOM_MATRIX ?= no
|
||||
|
||||
ifneq ($(strip $(CUSTOM_MATRIX)), yes)
|
||||
ifeq ($(filter $(CUSTOM_MATRIX),$(VALID_CUSTOM_MATRIX_TYPES)),)
|
||||
$(call CATASTROPHIC_ERROR,Invalid CUSTOM_MATRIX,CUSTOM_MATRIX="$(CUSTOM_MATRIX)" is not a valid custom matrix type)
|
||||
endif
|
||||
|
||||
# Include common stuff for all non custom matrix users
|
||||
QUANTUM_SRC += $(QUANTUM_DIR)/matrix_common.c
|
||||
|
||||
# if 'lite' then skip the actual matrix implementation
|
||||
ifneq ($(strip $(CUSTOM_MATRIX)), lite)
|
||||
# Include the standard or split matrix code if needed
|
||||
QUANTUM_SRC += $(QUANTUM_DIR)/matrix.c
|
||||
endif
|
||||
endif
|
||||
|
||||
# Debounce Modules. Set DEBOUNCE_TYPE=custom if including one manually.
|
||||
DEBOUNCE_TYPE ?= sym_defer_g
|
||||
ifneq ($(strip $(DEBOUNCE_TYPE)), custom)
|
||||
QUANTUM_SRC += $(QUANTUM_DIR)/debounce/$(strip $(DEBOUNCE_TYPE)).c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
|
||||
POST_CONFIG_H += $(QUANTUM_DIR)/split_common/post_config.h
|
||||
OPT_DEFS += -DSPLIT_KEYBOARD
|
||||
CRC_ENABLE := yes
|
||||
|
||||
# Include files used by all split keyboards
|
||||
QUANTUM_SRC += $(QUANTUM_DIR)/split_common/split_util.c
|
||||
|
||||
# Determine which (if any) transport files are required
|
||||
ifneq ($(strip $(SPLIT_TRANSPORT)), custom)
|
||||
QUANTUM_SRC += $(QUANTUM_DIR)/split_common/transport.c \
|
||||
$(QUANTUM_DIR)/split_common/transactions.c
|
||||
|
||||
OPT_DEFS += -DSPLIT_COMMON_TRANSACTIONS
|
||||
|
||||
# Functions added via QUANTUM_LIB_SRC are only included in the final binary if they're called.
|
||||
# Unused functions are pruned away, which is why we can add multiple drivers here without bloat.
|
||||
ifeq ($(PLATFORM),AVR)
|
||||
ifneq ($(NO_I2C),yes)
|
||||
QUANTUM_LIB_SRC += i2c_master.c \
|
||||
i2c_slave.c
|
||||
endif
|
||||
endif
|
||||
|
||||
SERIAL_DRIVER ?= bitbang
|
||||
OPT_DEFS += -DSERIAL_DRIVER_$(strip $(shell echo $(SERIAL_DRIVER) | tr '[:lower:]' '[:upper:]'))
|
||||
ifeq ($(strip $(SERIAL_DRIVER)), bitbang)
|
||||
QUANTUM_LIB_SRC += serial.c
|
||||
else
|
||||
QUANTUM_LIB_SRC += serial_$(strip $(SERIAL_DRIVER)).c
|
||||
endif
|
||||
endif
|
||||
COMMON_VPATH += $(QUANTUM_PATH)/split_common
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(CRC_ENABLE)), yes)
|
||||
OPT_DEFS += -DCRC_ENABLE
|
||||
SRC += crc.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(HAPTIC_ENABLE)),yes)
|
||||
COMMON_VPATH += $(DRIVER_PATH)/haptic
|
||||
|
||||
ifneq ($(filter DRV2605L, $(HAPTIC_DRIVER)), )
|
||||
SRC += DRV2605L.c
|
||||
QUANTUM_LIB_SRC += i2c_master.c
|
||||
OPT_DEFS += -DDRV2605L
|
||||
endif
|
||||
|
||||
ifneq ($(filter SOLENOID, $(HAPTIC_DRIVER)), )
|
||||
SRC += solenoid.c
|
||||
OPT_DEFS += -DSOLENOID_ENABLE
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(HD44780_ENABLE)), yes)
|
||||
SRC += platforms/avr/drivers/hd44780.c
|
||||
OPT_DEFS += -DHD44780_ENABLE
|
||||
endif
|
||||
|
||||
VALID_OLED_DRIVER_TYPES := SSD1306 custom
|
||||
OLED_DRIVER ?= SSD1306
|
||||
ifeq ($(strip $(OLED_ENABLE)), yes)
|
||||
ifeq ($(filter $(OLED_DRIVER),$(VALID_OLED_DRIVER_TYPES)),)
|
||||
$(call CATASTROPHIC_ERROR,Invalid OLED_DRIVER,OLED_DRIVER="$(OLED_DRIVER)" is not a valid OLED driver)
|
||||
else
|
||||
OPT_DEFS += -DOLED_ENABLE
|
||||
COMMON_VPATH += $(DRIVER_PATH)/oled
|
||||
|
||||
OPT_DEFS += -DOLED_DRIVER_$(strip $(shell echo $(OLED_DRIVER) | tr '[:lower:]' '[:upper:]'))
|
||||
ifeq ($(strip $(OLED_DRIVER)), SSD1306)
|
||||
SRC += ssd1306_sh1106.c
|
||||
QUANTUM_LIB_SRC += i2c_master.c
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(ST7565_ENABLE)), yes)
|
||||
OPT_DEFS += -DST7565_ENABLE
|
||||
COMMON_VPATH += $(DRIVER_PATH)/oled # For glcdfont.h
|
||||
COMMON_VPATH += $(DRIVER_PATH)/lcd
|
||||
QUANTUM_LIB_SRC += spi_master.c
|
||||
SRC += st7565.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(UCIS_ENABLE)), yes)
|
||||
OPT_DEFS += -DUCIS_ENABLE
|
||||
UNICODE_COMMON := yes
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_ucis.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(UNICODEMAP_ENABLE)), yes)
|
||||
OPT_DEFS += -DUNICODEMAP_ENABLE
|
||||
UNICODE_COMMON := yes
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_unicodemap.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(UNICODE_ENABLE)), yes)
|
||||
OPT_DEFS += -DUNICODE_ENABLE
|
||||
UNICODE_COMMON := yes
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_unicode.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(UNICODE_COMMON)), yes)
|
||||
OPT_DEFS += -DUNICODE_COMMON_ENABLE
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_unicode_common.c
|
||||
endif
|
||||
|
||||
MAGIC_ENABLE ?= yes
|
||||
ifeq ($(strip $(MAGIC_ENABLE)), yes)
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_magic.c
|
||||
OPT_DEFS += -DMAGIC_KEYCODE_ENABLE
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(AUTO_SHIFT_ENABLE)), yes)
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_auto_shift.c
|
||||
OPT_DEFS += -DAUTO_SHIFT_ENABLE
|
||||
ifeq ($(strip $(AUTO_SHIFT_MODIFIERS)), yes)
|
||||
OPT_DEFS += -DAUTO_SHIFT_MODIFIERS
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(PS2_MOUSE_ENABLE)), yes)
|
||||
PS2_ENABLE := yes
|
||||
SRC += ps2_mouse.c
|
||||
OPT_DEFS += -DPS2_MOUSE_ENABLE
|
||||
OPT_DEFS += -DMOUSE_ENABLE
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(PS2_USE_BUSYWAIT)), yes)
|
||||
PS2_ENABLE := yes
|
||||
SRC += ps2_busywait.c
|
||||
SRC += ps2_io.c
|
||||
OPT_DEFS += -DPS2_USE_BUSYWAIT
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(PS2_USE_INT)), yes)
|
||||
PS2_ENABLE := yes
|
||||
SRC += ps2_interrupt.c
|
||||
SRC += ps2_io.c
|
||||
OPT_DEFS += -DPS2_USE_INT
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(PS2_USE_USART)), yes)
|
||||
PS2_ENABLE := yes
|
||||
SRC += ps2_usart.c
|
||||
SRC += ps2_io.c
|
||||
OPT_DEFS += -DPS2_USE_USART
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(PS2_ENABLE)), yes)
|
||||
COMMON_VPATH += $(DRIVER_PATH)/ps2
|
||||
COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/ps2
|
||||
OPT_DEFS += -DPS2_ENABLE
|
||||
endif
|
||||
|
||||
JOYSTICK_ENABLE ?= no
|
||||
VALID_JOYSTICK_TYPES := analog digital
|
||||
JOYSTICK_DRIVER ?= analog
|
||||
ifeq ($(strip $(JOYSTICK_ENABLE)), yes)
|
||||
ifeq ($(filter $(JOYSTICK_DRIVER),$(VALID_JOYSTICK_TYPES)),)
|
||||
$(call CATASTROPHIC_ERROR,Invalid JOYSTICK_DRIVER,JOYSTICK_DRIVER="$(JOYSTICK_DRIVER)" is not a valid joystick driver)
|
||||
endif
|
||||
OPT_DEFS += -DJOYSTICK_ENABLE
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_joystick.c
|
||||
SRC += $(QUANTUM_DIR)/joystick.c
|
||||
|
||||
ifeq ($(strip $(JOYSTICK_DRIVER)), analog)
|
||||
OPT_DEFS += -DANALOG_JOYSTICK_ENABLE
|
||||
SRC += analog.c
|
||||
endif
|
||||
ifeq ($(strip $(JOYSTICK_DRIVER)), digital)
|
||||
OPT_DEFS += -DDIGITAL_JOYSTICK_ENABLE
|
||||
endif
|
||||
endif
|
||||
|
||||
USBPD_ENABLE ?= no
|
||||
VALID_USBPD_DRIVER_TYPES = custom vendor
|
||||
USBPD_DRIVER ?= vendor
|
||||
ifeq ($(strip $(USBPD_ENABLE)), yes)
|
||||
ifeq ($(filter $(strip $(USBPD_DRIVER)),$(VALID_USBPD_DRIVER_TYPES)),)
|
||||
$(call CATASTROPHIC_ERROR,Invalid USBPD_DRIVER,USBPD_DRIVER="$(USBPD_DRIVER)" is not a valid USBPD driver)
|
||||
else
|
||||
OPT_DEFS += -DUSBPD_ENABLE
|
||||
ifeq ($(strip $(USBPD_DRIVER)), vendor)
|
||||
# Vendor-specific implementations
|
||||
OPT_DEFS += -DUSBPD_VENDOR
|
||||
ifeq ($(strip $(MCU_SERIES)), STM32G4xx)
|
||||
OPT_DEFS += -DUSBPD_STM32G4
|
||||
SRC += usbpd_stm32g4.c
|
||||
else
|
||||
$(call CATASTROPHIC_ERROR,Invalid USBPD_DRIVER,There is no vendor-provided USBPD driver available)
|
||||
endif
|
||||
else ifeq ($(strip $(USBPD_DRIVER)), custom)
|
||||
OPT_DEFS += -DUSBPD_CUSTOM
|
||||
# Board designers can add their own driver to $(SRC)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
BLUETOOTH_ENABLE ?= no
|
||||
VALID_BLUETOOTH_DRIVER_TYPES := BluefruitLE RN42 custom
|
||||
ifeq ($(strip $(BLUETOOTH_ENABLE)), yes)
|
||||
ifeq ($(filter $(strip $(BLUETOOTH_DRIVER)),$(VALID_BLUETOOTH_DRIVER_TYPES)),)
|
||||
$(call CATASTROPHIC_ERROR,Invalid BLUETOOTH_DRIVER,BLUETOOTH_DRIVER="$(BLUETOOTH_DRIVER)" is not a valid Bluetooth driver type)
|
||||
endif
|
||||
OPT_DEFS += -DBLUETOOTH_ENABLE
|
||||
NO_USB_STARTUP_CHECK := yes
|
||||
COMMON_VPATH += $(DRIVER_PATH)/bluetooth
|
||||
SRC += outputselect.c
|
||||
|
||||
ifeq ($(strip $(BLUETOOTH_DRIVER)), BluefruitLE)
|
||||
OPT_DEFS += -DBLUETOOTH_BLUEFRUIT_LE
|
||||
SRC += analog.c
|
||||
SRC += $(DRIVER_PATH)/bluetooth/bluefruit_le.cpp
|
||||
QUANTUM_LIB_SRC += spi_master.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(BLUETOOTH_DRIVER)), RN42)
|
||||
OPT_DEFS += -DBLUETOOTH_RN42
|
||||
SRC += $(DRIVER_PATH)/bluetooth/rn42.c
|
||||
QUANTUM_LIB_SRC += uart.c
|
||||
endif
|
||||
endif
|
||||
523
builddefs/common_rules.mk
Normal file
523
builddefs/common_rules.mk
Normal file
@@ -0,0 +1,523 @@
|
||||
# Hey Emacs, this is a -*- makefile -*-
|
||||
#----------------------------------------------------------------------------
|
||||
# WinAVR Makefile Template written by Eric B. Weddington, Jg Wunsch, et al.
|
||||
#
|
||||
# Released to the Public Domain
|
||||
#
|
||||
# Additional material for this makefile was written by:
|
||||
# Peter Fleury
|
||||
# Tim Henigan
|
||||
# Colin O'Flynn
|
||||
# Reiner Patommel
|
||||
# Markus Pfaff
|
||||
# Sander Pool
|
||||
# Frederik Rouleau
|
||||
# Carlos Lamas
|
||||
#
|
||||
|
||||
# Enable vpath seraching for source files only
|
||||
# Without this, output files, could be read from the wrong .build directories
|
||||
VPATH_SRC := $(VPATH)
|
||||
vpath %.c $(VPATH_SRC)
|
||||
vpath %.h $(VPATH_SRC)
|
||||
vpath %.cpp $(VPATH_SRC)
|
||||
vpath %.cc $(VPATH_SRC)
|
||||
vpath %.hpp $(VPATH_SRC)
|
||||
vpath %.S $(VPATH_SRC)
|
||||
VPATH :=
|
||||
|
||||
# Convert all SRC to OBJ
|
||||
define OBJ_FROM_SRC
|
||||
$(patsubst %.c,$1/%.o,$(patsubst %.cpp,$1/%.o,$(patsubst %.cc,$1/%.o,$(patsubst %.S,$1/%.o,$(patsubst %.clib,$1/%.a,$($1_SRC))))))
|
||||
endef
|
||||
$(foreach OUTPUT,$(OUTPUTS),$(eval $(OUTPUT)_OBJ +=$(call OBJ_FROM_SRC,$(OUTPUT))))
|
||||
|
||||
# Define a list of all objects
|
||||
OBJ := $(foreach OUTPUT,$(OUTPUTS),$($(OUTPUT)_OBJ))
|
||||
NO_LTO_OBJ := $(filter %.a,$(OBJ))
|
||||
|
||||
MASTER_OUTPUT := $(firstword $(OUTPUTS))
|
||||
|
||||
|
||||
|
||||
# Output format. (can be srec, ihex, binary)
|
||||
FORMAT = ihex
|
||||
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# 0 = turn off optimization. s = optimize for size.
|
||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||
OPT ?= s
|
||||
|
||||
# Compiler flag to set the C Standard level.
|
||||
# c89 = "ANSI" C
|
||||
# gnu89 = c89 plus GCC extensions
|
||||
# c99 = ISO C99 standard (not yet fully implemented)
|
||||
# gnu99 = c99 plus GCC extensions
|
||||
CSTANDARD = -std=gnu99
|
||||
|
||||
|
||||
# Place -D or -U options here for C sources
|
||||
#CDEFS +=
|
||||
|
||||
|
||||
# Place -D or -U options here for ASM sources
|
||||
#ADEFS +=
|
||||
|
||||
|
||||
# Place -D or -U options here for C++ sources
|
||||
#CXXDEFS += -D__STDC_LIMIT_MACROS
|
||||
#CXXDEFS += -D__STDC_CONSTANT_MACROS
|
||||
#CXXDEFS +=
|
||||
|
||||
# Speed up recompilations by opt-in usage of ccache
|
||||
USE_CCACHE ?= no
|
||||
ifneq ($(USE_CCACHE),no)
|
||||
CC_PREFIX ?= ccache
|
||||
endif
|
||||
|
||||
#---------------- Compiler Options C ----------------
|
||||
# -g*: generate debugging information
|
||||
# -O*: optimization level
|
||||
# -f...: tuning, see GCC manual and avr-libc documentation
|
||||
# -Wall...: warning level
|
||||
# -Wa,...: tell GCC to pass this to the assembler.
|
||||
ifeq ($(strip $(LTO_ENABLE)), yes)
|
||||
ifeq ($(PLATFORM),CHIBIOS)
|
||||
$(info Enabling LTO on ChibiOS-targeting boards is known to have a high likelihood of failure.)
|
||||
$(info If unsure, set LTO_ENABLE = no.)
|
||||
endif
|
||||
CDEFS += -flto
|
||||
CDEFS += -DLTO_ENABLE
|
||||
endif
|
||||
|
||||
DEBUG_ENABLE ?= yes
|
||||
ifeq ($(strip $(SKIP_DEBUG_INFO)),yes)
|
||||
DEBUG_ENABLE=no
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(DEBUG_ENABLE)),yes)
|
||||
CFLAGS += -g$(DEBUG)
|
||||
endif
|
||||
CFLAGS += $(CDEFS)
|
||||
CFLAGS += -O$(OPT)
|
||||
# add color
|
||||
ifeq ($(COLOR),true)
|
||||
ifeq ("$(shell echo "int main(){}" | $(CC) -fdiagnostics-color -x c - -o /dev/null 2>&1)", "")
|
||||
CFLAGS+= -fdiagnostics-color
|
||||
endif
|
||||
endif
|
||||
CFLAGS += -Wall
|
||||
CFLAGS += -Wstrict-prototypes
|
||||
ifneq ($(strip $(ALLOW_WARNINGS)), yes)
|
||||
CFLAGS += -Werror
|
||||
endif
|
||||
#CFLAGS += -mshort-calls
|
||||
#CFLAGS += -fno-unit-at-a-time
|
||||
#CFLAGS += -Wundef
|
||||
#CFLAGS += -Wunreachable-code
|
||||
#CFLAGS += -Wsign-compare
|
||||
CFLAGS += $(CSTANDARD)
|
||||
|
||||
# This fixes lots of keyboards linking errors but SHOULDN'T BE A FINAL SOLUTION
|
||||
# Fixing of multiple variable definitions must be made.
|
||||
CFLAGS += -fcommon
|
||||
|
||||
#---------------- Compiler Options C++ ----------------
|
||||
# -g*: generate debugging information
|
||||
# -O*: optimization level
|
||||
# -f...: tuning, see GCC manual and avr-libc documentation
|
||||
# -Wall...: warning level
|
||||
# -Wa,...: tell GCC to pass this to the assembler.
|
||||
ifeq ($(strip $(DEBUG_ENABLE)),yes)
|
||||
CXXFLAGS += -g$(DEBUG)
|
||||
endif
|
||||
CXXFLAGS += $(CXXDEFS)
|
||||
CXXFLAGS += -O$(OPT)
|
||||
# to supress "warning: only initialized variables can be placed into program memory area"
|
||||
CXXFLAGS += -w
|
||||
CXXFLAGS += -Wall
|
||||
CXXFLAGS += -Wundef
|
||||
|
||||
ifneq ($(strip $(ALLOW_WARNINGS)), yes)
|
||||
CXXFLAGS += -Werror
|
||||
endif
|
||||
#CXXFLAGS += -mshort-calls
|
||||
#CXXFLAGS += -fno-unit-at-a-time
|
||||
#CXXFLAGS += -Wstrict-prototypes
|
||||
#CXXFLAGS += -Wunreachable-code
|
||||
#CXXFLAGS += -Wsign-compare
|
||||
#CXXFLAGS += $(CSTANDARD)
|
||||
|
||||
#---------------- Assembler Options ----------------
|
||||
ASFLAGS += $(ADEFS)
|
||||
ifeq ($(VERBOSE_AS_CMD),yes)
|
||||
ASFLAGS += -v
|
||||
endif
|
||||
|
||||
#---------------- Library Options ----------------
|
||||
# Minimalistic printf version
|
||||
PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
||||
|
||||
# Floating point printf version (requires MATH_LIB = -lm below)
|
||||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard printf version.
|
||||
PRINTF_LIB =
|
||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||
|
||||
|
||||
# Minimalistic scanf version
|
||||
SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
||||
|
||||
# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
|
||||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard scanf version.
|
||||
SCANF_LIB =
|
||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||
|
||||
|
||||
MATH_LIB = -lm
|
||||
CREATE_MAP ?= yes
|
||||
|
||||
|
||||
#---------------- Linker Options ----------------
|
||||
# -Wl,...: tell GCC to pass this to linker.
|
||||
# -Map: create map file
|
||||
# --cref: add cross reference to map file
|
||||
#
|
||||
# Comennt out "--relax" option to avoid a error such:
|
||||
# (.vectors+0x30): relocation truncated to fit: R_AVR_13_PCREL against symbol `__vector_12'
|
||||
#
|
||||
|
||||
ifeq ($(CREATE_MAP),yes)
|
||||
LDFLAGS += -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref
|
||||
endif
|
||||
ifeq ($(VERBOSE_LD_CMD),yes)
|
||||
LDFLAGS += -v
|
||||
endif
|
||||
#LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
|
||||
#LDFLAGS += -T linker_script.x
|
||||
# You can give EXTRALDFLAGS at 'make' command line.
|
||||
LDFLAGS += $(EXTRALDFLAGS)
|
||||
|
||||
#---------------- Assembler Listings ----------------
|
||||
# -Wa,...: tell GCC to pass this to the assembler.
|
||||
# -adhlns: create listing
|
||||
# -gstabs: have the assembler create line number information; note that
|
||||
# for use in COFF files, additional information about filenames
|
||||
# and function names needs to be present in the assembler source
|
||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# dump that will be displayed for a given single line of source input.
|
||||
|
||||
ADHLNS_ENABLE ?= no
|
||||
ifeq ($(ADHLNS_ENABLE),yes)
|
||||
# Avoid "Options to '-Xassembler' do not match" - only specify assembler options at LTO link time
|
||||
ifeq ($(strip $(LTO_ENABLE)), yes)
|
||||
LDFLAGS += -Wa,-adhlns=$(BUILD_DIR)/$(TARGET).lst
|
||||
else
|
||||
CFLAGS += -Wa,-adhlns=$(@:%.o=%.lst)
|
||||
CXXFLAGS += -Wa,-adhlns=$(@:%.o=%.lst)
|
||||
ifeq ($(strip $(DEBUG_ENABLE)),yes)
|
||||
ASFLAGS = -Wa,-adhlns=$(@:%.o=%.lst),-gstabs,--listing-cont-lines=100
|
||||
else
|
||||
ASFLAGS = -Wa,-adhlns=$(@:%.o=%.lst),--listing-cont-lines=100
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# Define programs and commands.
|
||||
SHELL = sh
|
||||
SED = sed
|
||||
REMOVE = rm -f
|
||||
REMOVEDIR = rmdir
|
||||
COPY = cp
|
||||
WINSHELL = cmd
|
||||
SECHO = $(SILENT) || echo
|
||||
MD5SUM ?= md5sum
|
||||
ifneq ($(filter Darwin FreeBSD,$(shell uname -s)),)
|
||||
MD5SUM = md5
|
||||
endif
|
||||
|
||||
# UF2 format settings
|
||||
# To produce a UF2 file in your build, add to your keyboard's rules.mk:
|
||||
# FIRMWARE_FORMAT = uf2
|
||||
UF2CONV = $(TOP_DIR)/util/uf2conv.py
|
||||
UF2_FAMILY ?= 0x0
|
||||
|
||||
# Compiler flags to generate dependency files.
|
||||
#GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d
|
||||
GENDEPFLAGS = -MMD -MP -MF $(patsubst %.o,%.td,$@)
|
||||
|
||||
|
||||
# Combine all necessary flags and optional flags.
|
||||
# Add target processor to flags.
|
||||
# You can give extra flags at 'make' command line like: make EXTRAFLAGS=-DFOO=bar
|
||||
ALL_CFLAGS = $(MCUFLAGS) $(CFLAGS) $(EXTRAFLAGS)
|
||||
ALL_CXXFLAGS = $(MCUFLAGS) -x c++ $(CXXFLAGS) $(EXTRAFLAGS)
|
||||
ALL_ASFLAGS = $(MCUFLAGS) -x assembler-with-cpp $(ASFLAGS) $(EXTRAFLAGS)
|
||||
|
||||
define NO_LTO
|
||||
$(patsubst %.a,%.o,$1): NOLTO_CFLAGS += -fno-lto
|
||||
endef
|
||||
$(foreach LOBJ, $(NO_LTO_OBJ), $(eval $(call NO_LTO,$(LOBJ))))
|
||||
|
||||
MOVE_DEP = mv -f $(patsubst %.o,%.td,$@) $(patsubst %.o,%.d,$@)
|
||||
|
||||
# For a ChibiOS build, ensure that the board files have the hook overrides injected
|
||||
define BOARDSRC_INJECT_HOOKS
|
||||
$(KEYBOARD_OUTPUT)/$(patsubst %.c,%.o,$(patsubst ./%,%,$1)): INIT_HOOK_CFLAGS += -include $(TOP_DIR)/tmk_core/protocol/chibios/init_hooks.h
|
||||
endef
|
||||
$(foreach LOBJ, $(BOARDSRC), $(eval $(call BOARDSRC_INJECT_HOOKS,$(LOBJ))))
|
||||
|
||||
# Add QMK specific flags
|
||||
DFU_SUFFIX ?= dfu-suffix
|
||||
DFU_SUFFIX_ARGS ?=
|
||||
|
||||
|
||||
elf: $(BUILD_DIR)/$(TARGET).elf
|
||||
hex: $(BUILD_DIR)/$(TARGET).hex
|
||||
uf2: $(BUILD_DIR)/$(TARGET).uf2
|
||||
cpfirmware: $(FIRMWARE_FORMAT)
|
||||
$(SILENT) || printf "Copying $(TARGET).$(FIRMWARE_FORMAT) to qmk_firmware folder" | $(AWK_CMD)
|
||||
$(COPY) $(BUILD_DIR)/$(TARGET).$(FIRMWARE_FORMAT) $(TARGET).$(FIRMWARE_FORMAT) && $(PRINT_OK)
|
||||
eep: $(BUILD_DIR)/$(TARGET).eep
|
||||
lss: $(BUILD_DIR)/$(TARGET).lss
|
||||
sym: $(BUILD_DIR)/$(TARGET).sym
|
||||
LIBNAME=lib$(TARGET).a
|
||||
lib: $(LIBNAME)
|
||||
|
||||
# Display size of file, modifying the output so people don't mistakenly grab the hex output
|
||||
BINARY_SIZE = $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex | $(SED) -e 's/\.build\/.*$$/$(TARGET).$(FIRMWARE_FORMAT)/g'
|
||||
|
||||
sizebefore:
|
||||
@if test -f $(BUILD_DIR)/$(TARGET).hex; then $(SECHO) $(MSG_SIZE_BEFORE); $(SILENT) || $(BINARY_SIZE); \
|
||||
2>/dev/null; $(SECHO); fi
|
||||
|
||||
sizeafter: $(BUILD_DIR)/$(TARGET).hex
|
||||
@if test -f $(BUILD_DIR)/$(TARGET).hex; then $(SECHO); $(SECHO) $(MSG_SIZE_AFTER); $(SILENT) || $(BINARY_SIZE); \
|
||||
2>/dev/null; $(SECHO); fi
|
||||
|
||||
# Display compiler version information.
|
||||
gccversion :
|
||||
@$(SILENT) || $(CC) --version
|
||||
|
||||
# Create final output files (.hex, .eep) from ELF output file.
|
||||
%.hex: %.elf
|
||||
$(eval CMD=$(HEX) $< $@)
|
||||
#@$(SILENT) || printf "$(MSG_EXECUTING) '$(CMD)':\n"
|
||||
@$(SILENT) || printf "$(MSG_FLASH) $@" | $(AWK_CMD)
|
||||
@$(BUILD_CMD)
|
||||
|
||||
%.uf2: %.hex
|
||||
$(eval CMD=$(UF2CONV) $(BUILD_DIR)/$(TARGET).hex -o $(BUILD_DIR)/$(TARGET).uf2 -c -f $(UF2_FAMILY) >/dev/null 2>&1)
|
||||
#@$(SILENT) || printf "$(MSG_EXECUTING) '$(CMD)':\n"
|
||||
@$(SILENT) || printf "$(MSG_UF2) $@" | $(AWK_CMD)
|
||||
@$(BUILD_CMD)
|
||||
|
||||
%.eep: %.elf
|
||||
$(eval CMD=$(EEP) $< $@ || exit 0)
|
||||
#@$(SILENT) || printf "$(MSG_EXECUTING) '$(CMD)':\n"
|
||||
@$(SILENT) || printf "$(MSG_EEPROM) $@" | $(AWK_CMD)
|
||||
@$(BUILD_CMD)
|
||||
|
||||
# Create extended listing file from ELF output file.
|
||||
%.lss: %.elf
|
||||
$(eval CMD=$(OBJDUMP) -h -S -z $< > $@)
|
||||
#@$(SILENT) || printf "$(MSG_EXECUTING) '$(CMD)':\n"
|
||||
@$(SILENT) || printf "$(MSG_EXTENDED_LISTING) $@" | $(AWK_CMD)
|
||||
@$(BUILD_CMD)
|
||||
|
||||
# Create a symbol table from ELF output file.
|
||||
%.sym: %.elf
|
||||
$(eval CMD=$(NM) -n $< > $@ )
|
||||
#@$(SILENT) || printf "$(MSG_EXECUTING) '$(CMD)':\n"
|
||||
@$(SILENT) || printf "$(MSG_SYMBOL_TABLE) $@" | $(AWK_CMD)
|
||||
@$(BUILD_CMD)
|
||||
|
||||
%.bin: %.elf
|
||||
$(eval CMD=$(BIN) $< $@ || exit 0)
|
||||
#@$(SILENT) || printf "$(MSG_EXECUTING) '$(CMD)':\n"
|
||||
@$(SILENT) || printf "$(MSG_BIN) $@" | $(AWK_CMD)
|
||||
@$(BUILD_CMD)
|
||||
if [ ! -z "$(DFU_SUFFIX_ARGS)" ]; then \
|
||||
$(DFU_SUFFIX) $(DFU_SUFFIX_ARGS) -a $(BUILD_DIR)/$(TARGET).bin 1>/dev/null ;\
|
||||
fi
|
||||
#$(SILENT) || printf "$(MSG_EXECUTING) '$(DFU_SUFFIX) $(DFU_SUFFIX_ARGS) -a $(BUILD_DIR)/$(TARGET).bin 1>/dev/null':\n" ;\
|
||||
$(COPY) $(BUILD_DIR)/$(TARGET).bin $(TARGET).bin;
|
||||
|
||||
BEGIN = gccversion sizebefore
|
||||
|
||||
# Link: create ELF output file from object files.
|
||||
.SECONDARY : $(BUILD_DIR)/$(TARGET).elf
|
||||
.PRECIOUS : $(OBJ)
|
||||
# Note the obj.txt depeendency is there to force linking if a source file is deleted
|
||||
%.elf: $(OBJ) $(MASTER_OUTPUT)/cflags.txt $(MASTER_OUTPUT)/ldflags.txt $(MASTER_OUTPUT)/obj.txt | $(BEGIN)
|
||||
@$(SILENT) || printf "$(MSG_LINKING) $@" | $(AWK_CMD)
|
||||
$(eval CMD=MAKE=$(MAKE) $(CC) $(ALL_CFLAGS) $(filter-out %.txt,$^) --output $@ $(LDFLAGS))
|
||||
@$(BUILD_CMD)
|
||||
|
||||
|
||||
define GEN_OBJRULE
|
||||
$1_INCFLAGS := $$(patsubst %,-I%,$$($1_INC))
|
||||
ifdef $1_CONFIG
|
||||
$1_CONFIG_FLAGS += $$(patsubst %,-include %,$$($1_CONFIG))
|
||||
endif
|
||||
$1_CFLAGS = $$(ALL_CFLAGS) $$($1_DEFS) $$($1_INCFLAGS) $$($1_CONFIG_FLAGS) $$(NOLTO_CFLAGS)
|
||||
$1_CXXFLAGS = $$(ALL_CXXFLAGS) $$($1_DEFS) $$($1_INCFLAGS) $$($1_CONFIG_FLAGS) $$(NOLTO_CFLAGS)
|
||||
$1_ASFLAGS = $$(ALL_ASFLAGS) $$($1_DEFS) $$($1_INCFLAGS) $$($1_CONFIG_FLAGS)
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
$1/%.o : %.c $1/%.d $1/cflags.txt $1/compiler.txt | $(BEGIN)
|
||||
@mkdir -p $$(@D)
|
||||
@$$(SILENT) || printf "$$(MSG_COMPILING) $$<" | $$(AWK_CMD)
|
||||
$$(eval CC_EXEC := $$(CC))
|
||||
ifneq ($$(VERBOSE_C_CMD),)
|
||||
$$(if $$(filter $$(notdir $$(VERBOSE_C_CMD)),$$(notdir $$<)),$$(eval CC_EXEC += -v))
|
||||
endif
|
||||
ifneq ($$(VERBOSE_C_INCLUDE),)
|
||||
$$(if $$(filter $$(notdir $$(VERBOSE_C_INCLUDE)),$$(notdir $$<)),$$(eval CC_EXEC += -H))
|
||||
endif
|
||||
$$(eval CMD := $$(CC_EXEC) -c $$($1_CFLAGS) $$(INIT_HOOK_CFLAGS) $$(GENDEPFLAGS) $$< -o $$@ && $$(MOVE_DEP))
|
||||
@$$(BUILD_CMD)
|
||||
ifneq ($$(DUMP_C_MACROS),)
|
||||
$$(eval CMD := $$(CC) -E -dM $$($1_CFLAGS) $$(INIT_HOOK_CFLAGS) $$(GENDEPFLAGS) $$<)
|
||||
@$$(if $$(filter $$(notdir $$(DUMP_C_MACROS)),$$(notdir $$<)),$$(BUILD_CMD))
|
||||
endif
|
||||
|
||||
# Compile: create object files from C++ source files.
|
||||
$1/%.o : %.cpp $1/%.d $1/cxxflags.txt $1/compiler.txt | $(BEGIN)
|
||||
@mkdir -p $$(@D)
|
||||
@$$(SILENT) || printf "$$(MSG_COMPILING_CXX) $$<" | $$(AWK_CMD)
|
||||
$$(eval CMD=$$(CC) -c $$($1_CXXFLAGS) $$(INIT_HOOK_CFLAGS) $$(GENDEPFLAGS) $$< -o $$@ && $$(MOVE_DEP))
|
||||
@$$(BUILD_CMD)
|
||||
|
||||
$1/%.o : %.cc $1/%.d $1/cxxflags.txt $1/compiler.txt | $(BEGIN)
|
||||
@mkdir -p $$(@D)
|
||||
@$$(SILENT) || printf "$$(MSG_COMPILING_CXX) $$<" | $$(AWK_CMD)
|
||||
$$(eval CMD=$$(CC) -c $$($1_CXXFLAGS) $$(INIT_HOOK_CFLAGS) $$(GENDEPFLAGS) $$< -o $$@ && $$(MOVE_DEP))
|
||||
@$$(BUILD_CMD)
|
||||
|
||||
# Assemble: create object files from assembler source files.
|
||||
$1/%.o : %.S $1/asflags.txt $1/compiler.txt | $(BEGIN)
|
||||
@mkdir -p $$(@D)
|
||||
@$(SILENT) || printf "$$(MSG_ASSEMBLING) $$<" | $$(AWK_CMD)
|
||||
$$(eval CMD=$$(CC) -c $$($1_ASFLAGS) $$< -o $$@)
|
||||
@$$(BUILD_CMD)
|
||||
|
||||
$1/%.a : $1/%.o
|
||||
@mkdir -p $$(@D)
|
||||
@$(SILENT) || printf "Archiving: $$<" | $$(AWK_CMD)
|
||||
$$(eval CMD=$$(AR) rcs $$@ $$<)
|
||||
@$$(BUILD_CMD)
|
||||
|
||||
$1/force:
|
||||
|
||||
$1/cflags.txt: $1/force
|
||||
echo '$$($1_CFLAGS)' | cmp -s - $$@ || echo '$$($1_CFLAGS)' > $$@
|
||||
|
||||
$1/cxxflags.txt: $1/force
|
||||
echo '$$($1_CXXFLAGS)' | cmp -s - $$@ || echo '$$($1_CXXFLAGS)' > $$@
|
||||
|
||||
$1/asflags.txt: $1/force
|
||||
echo '$$($1_ASFLAGS)' | cmp -s - $$@ || echo '$$($1_ASFLAGS)' > $$@
|
||||
|
||||
$1/compiler.txt: $1/force
|
||||
$$(CC) --version | cmp -s - $$@ || $$(CC) --version > $$@
|
||||
endef
|
||||
|
||||
.PRECIOUS: $(MASTER_OUTPUT)/obj.txt
|
||||
$(MASTER_OUTPUT)/obj.txt: $(MASTER_OUTPUT)/force
|
||||
echo '$(OBJ)' | cmp -s - $@ || echo '$(OBJ)' > $@
|
||||
|
||||
.PRECIOUS: $(MASTER_OUTPUT)/ldflags.txt
|
||||
$(MASTER_OUTPUT)/ldflags.txt: $(MASTER_OUTPUT)/force
|
||||
echo '$(LDFLAGS)' | cmp -s - $@ || echo '$(LDFLAGS)' > $@
|
||||
|
||||
|
||||
# We have to use static rules for the .d files for some reason
|
||||
DEPS = $(patsubst %.o,%.d,$(patsubst %.a,%.o,$(OBJ)))
|
||||
# Keep the .d files
|
||||
.PRECIOUS: $(DEPS)
|
||||
# Empty rule to force recompilation if the .d file is missing
|
||||
$(DEPS):
|
||||
|
||||
|
||||
$(foreach OUTPUT,$(OUTPUTS),$(eval $(call GEN_OBJRULE,$(OUTPUT))))
|
||||
|
||||
# Create preprocessed source for use in sending a bug report.
|
||||
%.i : %.c | $(BEGIN)
|
||||
$(CC) -E -mmcu=$(MCU) $(CFLAGS) $< -o $@
|
||||
|
||||
# Target: clean project.
|
||||
clean:
|
||||
$(foreach OUTPUT,$(OUTPUTS), $(REMOVE) -r $(OUTPUT) 2>/dev/null)
|
||||
$(REMOVE) $(BUILD_DIR)/$(TARGET).*
|
||||
|
||||
show_path:
|
||||
@echo VPATH=$(VPATH)
|
||||
@echo SRC=$(SRC)
|
||||
@echo OBJ=$(OBJ)
|
||||
|
||||
dump_vars: ERROR_IF_EMPTY=""
|
||||
dump_vars: ERROR_IF_NONBOOL=""
|
||||
dump_vars: ERROR_IF_UNSET=""
|
||||
dump_vars:
|
||||
@$(foreach V,$(sort $(.VARIABLES)),$(if $(filter-out environment% default automatic,$(origin $V)),$(info $V=$($V))))
|
||||
|
||||
objs-size:
|
||||
for i in $(OBJ); do echo $$i; done | sort | xargs $(SIZE)
|
||||
|
||||
ifeq ($(findstring avr-gcc,$(CC)),avr-gcc)
|
||||
SIZE_MARGIN = 1024
|
||||
|
||||
check-size:
|
||||
$(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) -D__ASSEMBLER__ $(CFLAGS) $(OPT_DEFS) platforms/avr/bootloader_size.c 2> /dev/null | $(SED) -ne 's/\r//;/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0))
|
||||
$(eval CURRENT_SIZE=$(shell if [ -f $(BUILD_DIR)/$(TARGET).hex ]; then $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex | $(AWK) 'NR==2 {print $$4}'; else printf 0; fi))
|
||||
$(eval FREE_SIZE=$(shell expr $(MAX_SIZE) - $(CURRENT_SIZE)))
|
||||
$(eval OVER_SIZE=$(shell expr $(CURRENT_SIZE) - $(MAX_SIZE)))
|
||||
$(eval PERCENT_SIZE=$(shell expr $(CURRENT_SIZE) \* 100 / $(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 \
|
||||
printf "\n * $(MSG_FILE_TOO_BIG)"; $(PRINT_ERROR_PLAIN); \
|
||||
else \
|
||||
if [ $(FREE_SIZE) -lt $(SIZE_MARGIN) ]; then \
|
||||
$(PRINT_WARNING_PLAIN); printf " * $(MSG_FILE_NEAR_LIMIT)"; \
|
||||
else \
|
||||
$(PRINT_OK); $(SILENT) || printf " * $(MSG_FILE_JUST_RIGHT)"; \
|
||||
fi ; \
|
||||
fi ; \
|
||||
fi
|
||||
else
|
||||
check-size:
|
||||
$(SILENT) || echo "$(MSG_CHECK_FILESIZE_SKIPPED)"
|
||||
endif
|
||||
|
||||
check-md5:
|
||||
$(MD5SUM) $(BUILD_DIR)/$(TARGET).$(FIRMWARE_FORMAT)
|
||||
|
||||
# Create build directory
|
||||
$(shell mkdir -p $(BUILD_DIR) 2>/dev/null)
|
||||
|
||||
# Create object files directory
|
||||
$(eval $(foreach OUTPUT,$(OUTPUTS),$(shell mkdir -p $(OUTPUT) 2>/dev/null)))
|
||||
|
||||
# Include the dependency files.
|
||||
-include $(patsubst %.o,%.d,$(patsubst %.a,%.o,$(OBJ)))
|
||||
|
||||
|
||||
# Listing of phony targets.
|
||||
.PHONY : all dump_vars finish sizebefore sizeafter qmkversion \
|
||||
gccversion build elf hex uf2 eep lss sym coff extcoff \
|
||||
clean clean_list debug gdb-config show_path \
|
||||
program teensy dfu dfu-ee dfu-start \
|
||||
flash dfu-split-left dfu-split-right \
|
||||
avrdude-split-left avrdude-split-right \
|
||||
avrdude-loop usbasp
|
||||
19
builddefs/testlist.mk
Normal file
19
builddefs/testlist.mk
Normal file
@@ -0,0 +1,19 @@
|
||||
TEST_LIST = $(sort $(patsubst %/test.mk,%, $(shell find $(ROOT_DIR)tests -type f -name test.mk)))
|
||||
FULL_TESTS := $(notdir $(TEST_LIST))
|
||||
|
||||
include $(QUANTUM_PATH)/debounce/tests/testlist.mk
|
||||
include $(QUANTUM_PATH)/sequencer/tests/testlist.mk
|
||||
include $(PLATFORM_PATH)/test/testlist.mk
|
||||
|
||||
define VALIDATE_TEST_LIST
|
||||
ifneq ($1,)
|
||||
ifeq ($$(findstring -,$1),-)
|
||||
$$(call CATASTROPHIC_ERROR,Invalid test name,Test names can't contain '-', but '$1' does.)
|
||||
else
|
||||
$$(eval $$(call VALIDATE_TEST_LIST,$$(firstword $2),$$(wordlist 2,9999,$2)))
|
||||
endif
|
||||
endif
|
||||
endef
|
||||
|
||||
|
||||
$(eval $(call VALIDATE_TEST_LIST,$(firstword $(TEST_LIST)),$(wordlist 2,9999,$(TEST_LIST))))
|
||||
20
data/templates/keyboard/config.h
Normal file
20
data/templates/keyboard/config.h
Normal file
@@ -0,0 +1,20 @@
|
||||
// Copyright %YEAR% %REAL_NAME% (@%USER_NAME%)
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
* Feature disable options
|
||||
* These options are also useful to firmware size reduction.
|
||||
*/
|
||||
|
||||
/* disable debug print */
|
||||
//#define NO_DEBUG
|
||||
|
||||
/* disable print */
|
||||
//#define NO_PRINT
|
||||
|
||||
/* disable action features */
|
||||
//#define NO_ACTION_LAYER
|
||||
//#define NO_ACTION_TAPPING
|
||||
//#define NO_ACTION_ONESHOT
|
||||
25
data/templates/keyboard/info.json
Normal file
25
data/templates/keyboard/info.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"keyboard_name": "%KEYBOARD%",
|
||||
"maintainer": "%USER_NAME%",
|
||||
"manufacturer": "%REAL_NAME%",
|
||||
"processor": "%MCU%",
|
||||
"bootloader": "%BOOTLOADER%",
|
||||
"diode_direction": "COL2ROW",
|
||||
"matrix_pins": {
|
||||
"cols": ["C2"],
|
||||
"rows": ["D1"]
|
||||
},
|
||||
"usb": {
|
||||
"vid": "0xFEED",
|
||||
"pid": "0x0000",
|
||||
"device_version": "1.0.0"
|
||||
},
|
||||
"features": {
|
||||
"bootmagic": true,
|
||||
"command": false,
|
||||
"console": false,
|
||||
"extrakey": true,
|
||||
"mousekey": true,
|
||||
"nkro": true
|
||||
}
|
||||
}
|
||||
27
data/templates/keyboard/readme.md
Normal file
27
data/templates/keyboard/readme.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# %KEYBOARD%
|
||||
|
||||

|
||||
|
||||
*A short description of the keyboard/project*
|
||||
|
||||
* Keyboard Maintainer: [%REAL_NAME%](https://github.com/%USER_NAME%)
|
||||
* Hardware Supported: *The PCBs, controllers supported*
|
||||
* Hardware Availability: *Links to where you can find this hardware*
|
||||
|
||||
Make example for this keyboard (after setting up your build environment):
|
||||
|
||||
make %KEYBOARD%:default
|
||||
|
||||
Flashing example for this keyboard:
|
||||
|
||||
make %KEYBOARD%:default:flash
|
||||
|
||||
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).
|
||||
|
||||
## Bootloader
|
||||
|
||||
Enter the bootloader in 3 ways:
|
||||
|
||||
* **Bootmagic reset**: Hold down the key at (0,0) in the matrix (usually the top left key or Escape) and plug in the keyboard
|
||||
* **Physical reset button**: Briefly press the button on the back of the PCB - some may have pads you must short instead
|
||||
* **Keycode in layout**: Press the key mapped to `RESET` if it is available
|
||||
1
data/templates/keyboard/rules.mk
Normal file
1
data/templates/keyboard/rules.mk
Normal file
@@ -0,0 +1 @@
|
||||
# This file intentionally left blank
|
||||
489
docs/ChangeLog/20220226.md
Normal file
489
docs/ChangeLog/20220226.md
Normal file
@@ -0,0 +1,489 @@
|
||||
# QMK Breaking Changes - 2022 February 26 Changelog
|
||||
|
||||
## Notable Features :id=notable-features
|
||||
|
||||
### Default USB Polling rate now 1kHz ([#15352](https://github.com/qmk/qmk_firmware/pull/15352))
|
||||
|
||||
The default USB Polling rate has been aligned across supported platforms to now be 1ms/1kHz.
|
||||
|
||||
Something something *Lets go gamers!*
|
||||
|
||||
### Split support for pointing devices ([#15304](https://github.com/qmk/qmk_firmware/pull/15304))
|
||||
|
||||
Pointing devices can now be shared across a split keyboard with support for a single pointing device or a pointing device on each side.
|
||||
|
||||
See the [Pointing Device](feature_pointing_device.md) documentation for further configuration options.
|
||||
|
||||
## Changes Requiring User Action :id=changes-requiring-user-action
|
||||
|
||||
### Legacy macro and action_function system removed ([#16025](https://github.com/qmk/qmk_firmware/pull/16025))
|
||||
|
||||
The long time deprecated `MACRO()` and `action_get_macro` methods have been removed. Where possible, existing usages have been migrated over to core [Macros](feature_macros.md).
|
||||
|
||||
### Create a build error if no bootloader is specified ([#16181](https://github.com/qmk/qmk_firmware/pull/16181))
|
||||
|
||||
Bootloader configuration is no longer assumed. Keyboards must now set either:
|
||||
|
||||
* `BOOTLOADER` within `rules.mk`
|
||||
* `bootloader` within `info.json`
|
||||
|
||||
### Rename `AdafruitBLE` to `BluefruitLE` ([#16127](https://github.com/qmk/qmk_firmware/pull/16127))
|
||||
|
||||
In preparation of future bluetooth work, the `AdafruitBLE` integration has been renamed to allow potential for any other Adafruit BLE products.
|
||||
|
||||
### Updated Keyboard Codebases :id=updated-keyboard-codebases
|
||||
|
||||
The following keyboards have had their source moved within QMK:
|
||||
|
||||
| Old Keyboard Name | New Keyboard Name |
|
||||
|----------------------------|------------------------------------|
|
||||
| 6ball | maple_computing/6ball |
|
||||
| 7skb | salicylic_acid3/7skb |
|
||||
| 7splus | salicylic_acid3/7splus |
|
||||
| acr60 | mechkeys/acr60 |
|
||||
| adalyn | tominabox1/adalyn |
|
||||
| ajisai74 | salicylic_acid3/ajisai74 |
|
||||
| aleth42 | 25keys/aleth42 |
|
||||
| alicia_cook | ibnuda/alicia_cook |
|
||||
| allison_numpad | prototypist/allison_numpad |
|
||||
| allison | prototypist/allison |
|
||||
| alu84 | mechkeys/alu84 |
|
||||
| angel17 | kakunpc/angel17 |
|
||||
| angel64/alpha | kakunpc/angel64/alpha |
|
||||
| angel64/rev1 | kakunpc/angel64/rev1 |
|
||||
| arch_36 | obosob/arch_36 |
|
||||
| bakeneko60 | kkatano/bakeneko60 |
|
||||
| bakeneko65/rev2 | kkatano/bakeneko65/rev2 |
|
||||
| bakeneko65/rev3 | kkatano/bakeneko65/rev3 |
|
||||
| bakeneko80 | kkatano/bakeneko80 |
|
||||
| barleycorn | yiancardesigns/barleycorn |
|
||||
| bat43/rev1 | dailycraft/bat43/rev1 |
|
||||
| bat43/rev2 | dailycraft/bat43/rev2 |
|
||||
| bigseries/1key | woodkeys/bigseries/1key |
|
||||
| bigseries/2key | woodkeys/bigseries/2key |
|
||||
| bigseries/3key | woodkeys/bigseries/3key |
|
||||
| bigseries/4key | woodkeys/bigseries/4key |
|
||||
| bkf | drhigsby/bkf |
|
||||
| business_card/alpha | kakunpc/business_card/alpha |
|
||||
| business_card/beta | kakunpc/business_card/beta |
|
||||
| butterstick | gboards/butterstick |
|
||||
| c39 | maple_computing/c39 |
|
||||
| cassette42 | 25keys/cassette42 |
|
||||
| chidori | kagizaraya/chidori |
|
||||
| chili | ydkb/chili |
|
||||
| chimera_ergo | glenpickle/chimera_ergo |
|
||||
| chimera_ls | glenpickle/chimera_ls |
|
||||
| chimera_ortho | glenpickle/chimera_ortho |
|
||||
| chimera_ortho_plus | glenpickle/chimera_ortho_plus |
|
||||
| choco60 | recompile_keys/choco60 |
|
||||
| choc_taro | kakunpc/choc_taro |
|
||||
| christmas_tree | maple_computing/christmas_tree |
|
||||
| claw44/rev1 | dailycraft/claw44/rev1 |
|
||||
| cocoa40 | recompile_keys/cocoa40 |
|
||||
| comet46 | satt/comet46 |
|
||||
| cu24 | capsunlocked/cu24 |
|
||||
| cu75 | capsunlocked/cu75 |
|
||||
| cu80 | capsunlocked/cu80/v1 |
|
||||
| delilah | rainkeebs/delilah |
|
||||
| diverge3 | unikeyboard/diverge3 |
|
||||
| divergetm2 | unikeyboard/divergetm2 |
|
||||
| dozen0 | yynmt/dozen0 |
|
||||
| dubba175 | drhigsby/dubba175 |
|
||||
| eggman | qpockets/eggman |
|
||||
| ergo42 | biacco42/ergo42 |
|
||||
| ergoarrows | salicylic_acid3/ergoarrows |
|
||||
| ergodash/mini | omkbd/ergodash/mini |
|
||||
| ergodash/rev1 | omkbd/ergodash/rev1 |
|
||||
| ergodox_infinity | input_club/ergodox_infinity |
|
||||
| ergotaco | gboards/ergotaco |
|
||||
| espectro | mechkeys/espectro |
|
||||
| felix | unikeyboard/felix |
|
||||
| four_banger | bpiphany/four_banger |
|
||||
| freyr | hnahkb/freyr |
|
||||
| geminate60 | weirdo/geminate60 |
|
||||
| georgi | gboards/georgi |
|
||||
| gergo | gboards/gergo |
|
||||
| getta25 | salicylic_acid3/getta25 |
|
||||
| gingham | yiancardesigns/gingham |
|
||||
| gurindam | ibnuda/gurindam |
|
||||
| halberd | kagizaraya/halberd |
|
||||
| hecomi/alpha | takashiski/hecomi/alpha |
|
||||
| hid_liber | bpiphany/hid_liber |
|
||||
| id67/default_rgb | idobao/id67/default_rgb |
|
||||
| id67/rgb | idobao/id67/rgb |
|
||||
| id80 | idobao/id80/v1 |
|
||||
| id87 | idobao/id87/v1 |
|
||||
| idobo | idobao/id75/v1 |
|
||||
| infinity60 | input_club/infinity60 |
|
||||
| ivy/rev1 | maple_computing/ivy/rev1 |
|
||||
| jisplit89 | salicylic_acid3/jisplit89 |
|
||||
| jnao | maple_computing/jnao |
|
||||
| just60 | ydkb/just60 |
|
||||
| kagamidget | yynmt/kagamidget |
|
||||
| kelowna/rgb64 | weirdo/kelowna/rgb64 |
|
||||
| kprepublic/bm65hsrgb_iso | kprepublic/bm65hsrgb_iso/rev1 |
|
||||
| kprepublic/bm68hsrgb | kprepublic/bm68hsrgb/rev1 |
|
||||
| k_type | input_club/k_type |
|
||||
| latin17rgb | latincompass/latin17rgb |
|
||||
| latin47ble | latincompass/latin47ble |
|
||||
| latin60rgb | latincompass/latin60rgb |
|
||||
| latin64ble | latincompass/latin64ble |
|
||||
| latin6rgb | latincompass/latin6rgb |
|
||||
| latinpadble | latincompass/latinpadble |
|
||||
| latinpad | latincompass/latinpad |
|
||||
| launchpad/rev1 | maple_computing/launchpad/rev1 |
|
||||
| lck75 | lyso1/lck75 |
|
||||
| le_chiffre | tominabox1/le_chiffre |
|
||||
| lefishe | lyso1/lefishe |
|
||||
| lets_split_eh/eh | maple_computing/lets_split_eh/eh |
|
||||
| ls_60 | weirdo/ls_60 |
|
||||
| m3n3van | matthewdias/m3n3van |
|
||||
| mechmini/v1 | mechkeys/mechmini/v1 |
|
||||
| mechmini/v2 | mechkeys/mechmini/v2 |
|
||||
| meira | woodkeys/meira |
|
||||
| meishi2 | biacco42/meishi2 |
|
||||
| meishi | biacco42/meishi |
|
||||
| minidox/rev1 | maple_computing/minidox/rev1 |
|
||||
| minim | matthewdias/minim |
|
||||
| mio | recompile_keys/mio |
|
||||
| model_v | matthewdias/model_v |
|
||||
| montex | idobao/montex/v1 |
|
||||
| nafuda | salicylic_acid3/nafuda |
|
||||
| naiping/np64 | weirdo/naiping/np64 |
|
||||
| naiping/nphhkb | weirdo/naiping/nphhkb |
|
||||
| naiping/npminila | weirdo/naiping/npminila |
|
||||
| naked48 | salicylic_acid3/naked48 |
|
||||
| naked60 | salicylic_acid3/naked60 |
|
||||
| naked64 | salicylic_acid3/naked64 |
|
||||
| namecard2x4 | takashiski/namecard2x4 |
|
||||
| nebula12 | spaceholdings/nebula12 |
|
||||
| nebula68b | spaceholdings/nebula68b |
|
||||
| nebula68 | spaceholdings/nebula68 |
|
||||
| niu_mini | kbdfans/niu_mini |
|
||||
| nk1 | novelkeys/nk1 |
|
||||
| nk65 | novelkeys/nk65 |
|
||||
| nk87 | novelkeys/nk87 |
|
||||
| nknl7en | salicylic_acid3/nknl7en |
|
||||
| nknl7jp | salicylic_acid3/nknl7jp |
|
||||
| nomu30 | recompile_keys/nomu30 |
|
||||
| novelpad | novelkeys/novelpad |
|
||||
| ogurec | drhigsby/ogurec |
|
||||
| otaku_split/rev0 | takashiski/otaku_split/rev0 |
|
||||
| otaku_split/rev1 | takashiski/otaku_split/rev1 |
|
||||
| owl8 | dailycraft/owl8 |
|
||||
| packrat | drhigsby/packrat |
|
||||
| pistachio_mp | rate/pistachio_mp |
|
||||
| pistachio_pro | rate/pistachio_pro |
|
||||
| pistachio | rate/pistachio |
|
||||
| plexus75 | checkerboards/plexus75 |
|
||||
| pursuit40 | checkerboards/pursuit40 |
|
||||
| qaz | tominabox1/qaz |
|
||||
| quark | checkerboards/quark |
|
||||
| rabbit_capture_plan | kakunpc/rabbit_capture_plan |
|
||||
| rainkeeb | rainkeebs/rainkeeb |
|
||||
| reviung33 | reviung/reviung33 |
|
||||
| reviung34 | reviung/reviung34 |
|
||||
| reviung39 | reviung/reviung39 |
|
||||
| reviung41 | reviung/reviung41 |
|
||||
| reviung53 | reviung/reviung53 |
|
||||
| reviung5 | reviung/reviung5 |
|
||||
| reviung61 | reviung/reviung61 |
|
||||
| runner3680/3x6 | omkbd/runner3680/3x6 |
|
||||
| runner3680/3x7 | omkbd/runner3680/3x7 |
|
||||
| runner3680/3x8 | omkbd/runner3680/3x8 |
|
||||
| runner3680/4x6 | omkbd/runner3680/4x6 |
|
||||
| runner3680/4x7 | omkbd/runner3680/4x7 |
|
||||
| runner3680/4x8 | omkbd/runner3680/4x8 |
|
||||
| runner3680/5x6_5x8 | omkbd/runner3680/5x6_5x8 |
|
||||
| runner3680/5x6 | omkbd/runner3680/5x6 |
|
||||
| runner3680/5x7 | omkbd/runner3680/5x7 |
|
||||
| runner3680/5x8 | omkbd/runner3680/5x8 |
|
||||
| scarletbandana | woodkeys/scarletbandana |
|
||||
| scythe | kagizaraya/scythe |
|
||||
| seigaiha | yiancardesigns/seigaiha |
|
||||
| setta21 | salicylic_acid3/setta21 |
|
||||
| space_space/rev1 | qpockets/space_space/rev1 |
|
||||
| space_space/rev2 | qpockets/space_space/rev2 |
|
||||
| spiderisland/winry25tc | winry/winry25tc |
|
||||
| splitreus62 | nacly/splitreus62 |
|
||||
| squiggle/rev1 | ibnuda/squiggle/rev1 |
|
||||
| standaside | edi/standaside |
|
||||
| steal_this_keyboard | obosob/steal_this_keyboard |
|
||||
| stella | hnahkb/stella |
|
||||
| suihankey/alpha | kakunpc/suihankey/alpha |
|
||||
| suihankey/rev1 | kakunpc/suihankey/rev1 |
|
||||
| suihankey/split | kakunpc/suihankey/split |
|
||||
| thedogkeyboard | kakunpc/thedogkeyboard |
|
||||
| the_ruler | maple_computing/the_ruler |
|
||||
| tiger910 | weirdo/tiger910 |
|
||||
| treadstone32 | marksard/treadstone32 |
|
||||
| treadstone48/rev1 | marksard/treadstone48/rev1 |
|
||||
| treadstone48/rev2 | marksard/treadstone48/rev2 |
|
||||
| txuu | matthewdias/txuu |
|
||||
| ua62 | nacly/ua62 |
|
||||
| underscore33/rev1 | tominabox1/underscore33/rev1 |
|
||||
| underscore33/rev2 | tominabox1/underscore33/rev2 |
|
||||
| vn66 | hnahkb/vn66 |
|
||||
| wallaby | kkatano/wallaby |
|
||||
| wanten | qpockets/wanten |
|
||||
| whitefox | input_club/whitefox |
|
||||
| wings42/rev1 | dailycraft/wings42/rev1 |
|
||||
| wings42/rev1_extkeys | dailycraft/wings42/rev1_extkeys |
|
||||
| wings42/rev2 | dailycraft/wings42/rev2 |
|
||||
| yasui | rainkeebs/yasui |
|
||||
| yd60mq | ymdk/yd60mq |
|
||||
| yd68 | ydkb/yd68 |
|
||||
| ymd75 | ymdk/ymd75 |
|
||||
| ymd96 | ymdk/ymd96 |
|
||||
| ymdk_np21 | ymdk/np21 |
|
||||
| yurei | kkatano/yurei |
|
||||
| zinc | 25keys/zinc |
|
||||
| zinc/rev1 | 25keys/zinc/rev1 |
|
||||
| zinc/reva | 25keys/zinc/reva |
|
||||
|
||||
## Notable core changes :id=notable-core
|
||||
|
||||
### New MCU Support :id=new-mcu-support
|
||||
|
||||
Building on previous cycles, QMK firmware picked up support for a couple extra MCU variants:
|
||||
|
||||
* STM32L432
|
||||
* STM32L442
|
||||
|
||||
### New Drivers
|
||||
|
||||
QMK now has core-supplied support for the following device peripherals:
|
||||
|
||||
#### LED
|
||||
|
||||
* IS31FL3742A
|
||||
* IS31FL3743A
|
||||
* IS31FL3745
|
||||
* IS31FL3746A
|
||||
|
||||
#### GPIO
|
||||
|
||||
* SN74x138
|
||||
* mcp23018
|
||||
|
||||
---
|
||||
|
||||
## Full changelist
|
||||
|
||||
Core:
|
||||
* Initial pass at data driven new-keyboard subcommand ([#12795](https://github.com/qmk/qmk_firmware/pull/12795))
|
||||
* Don't send keyboard reports that propagate no changes to the host ([#14065](https://github.com/qmk/qmk_firmware/pull/14065))
|
||||
* Custom matrix lite support for split keyboards ([#14674](https://github.com/qmk/qmk_firmware/pull/14674))
|
||||
* Add sym_defer_pr debouncer type ([#14948](https://github.com/qmk/qmk_firmware/pull/14948))
|
||||
* Add RGB matrix & LED Matrix support for IS31FL3742A, IS31FL3743A, IS31FL3745, IS31FL3746A ([#14989](https://github.com/qmk/qmk_firmware/pull/14989))
|
||||
* New combo configuration options ([#15083](https://github.com/qmk/qmk_firmware/pull/15083))
|
||||
* IS31FL3733 driver for LED Matrix ([#15088](https://github.com/qmk/qmk_firmware/pull/15088))
|
||||
* Add open-drain GPIO support. ([#15282](https://github.com/qmk/qmk_firmware/pull/15282))
|
||||
* Make (un)register code functions weak ([#15285](https://github.com/qmk/qmk_firmware/pull/15285))
|
||||
* Split support for pointing devices. ([#15304](https://github.com/qmk/qmk_firmware/pull/15304))
|
||||
* Added cancel_key_lock function ([#15321](https://github.com/qmk/qmk_firmware/pull/15321))
|
||||
* Remove matrix_is_modified() and debounce_is_active() ([#15349](https://github.com/qmk/qmk_firmware/pull/15349))
|
||||
* Change default USB Polling rate to 1kHz ([#15352](https://github.com/qmk/qmk_firmware/pull/15352))
|
||||
* Implement MAGIC_TOGGLE_CONTROL_CAPSLOCK ([#15368](https://github.com/qmk/qmk_firmware/pull/15368))
|
||||
* Tidy up existing i2c_master implementations ([#15376](https://github.com/qmk/qmk_firmware/pull/15376))
|
||||
* Generalize Unicode defines ([#15409](https://github.com/qmk/qmk_firmware/pull/15409))
|
||||
* Added external spi flash driver. ([#15419](https://github.com/qmk/qmk_firmware/pull/15419))
|
||||
* Remove Deprecated USB Polling comment from vusb.c ([#15420](https://github.com/qmk/qmk_firmware/pull/15420))
|
||||
* Expand rotational range for PMW3360 Optical Sensor ([#15431](https://github.com/qmk/qmk_firmware/pull/15431))
|
||||
* ChibiOS SVN mirror script update ([#15435](https://github.com/qmk/qmk_firmware/pull/15435))
|
||||
* Refactor `bootloader_jump()` implementations ([#15450](https://github.com/qmk/qmk_firmware/pull/15450))
|
||||
* added missing audio_off_user() callback ([#15457](https://github.com/qmk/qmk_firmware/pull/15457))
|
||||
* Migrate serial_uart usages to UART driver ([#15479](https://github.com/qmk/qmk_firmware/pull/15479))
|
||||
* Migrate RN42 to UART driver and refactor ([#15492](https://github.com/qmk/qmk_firmware/pull/15492))
|
||||
* pwm3360 driver cleanup and diff reduction to adns9800 ([#15559](https://github.com/qmk/qmk_firmware/pull/15559))
|
||||
* Advanced deferred_exec for core-side code. ([#15579](https://github.com/qmk/qmk_firmware/pull/15579))
|
||||
* Adjust tap_code16 to account for TAP_HOLD_CAPS_DELAY ([#15635](https://github.com/qmk/qmk_firmware/pull/15635))
|
||||
* Slight tidy up of keyboard task loop ([#15725](https://github.com/qmk/qmk_firmware/pull/15725))
|
||||
* Unify the key up/down behaviour of RGB keycodes ([#15730](https://github.com/qmk/qmk_firmware/pull/15730))
|
||||
* Add PMW3389 optical sensor Support (Updated) ([#15740](https://github.com/qmk/qmk_firmware/pull/15740))
|
||||
* ChibiOS: add support for HID Programmable Buttons ([#15787](https://github.com/qmk/qmk_firmware/pull/15787))
|
||||
* ChibiOS: shorten USB disconnect state on boot to 50ms ([#15805](https://github.com/qmk/qmk_firmware/pull/15805))
|
||||
* Add init function to clear previous matrix effect ([#15815](https://github.com/qmk/qmk_firmware/pull/15815))
|
||||
* Optimize initialization of PMW3360 Sensor ([#15821](https://github.com/qmk/qmk_firmware/pull/15821))
|
||||
* Add Pixel Flow RGB matrix effect ([#15829](https://github.com/qmk/qmk_firmware/pull/15829))
|
||||
* PMW3389 Revert Firmware load during Initilization ([#15859](https://github.com/qmk/qmk_firmware/pull/15859))
|
||||
* Combo `TAP_CODE_DELAY` and `clear_weak_mods` ([#15866](https://github.com/qmk/qmk_firmware/pull/15866))
|
||||
* Relocate matrix_scan_quantum tasks ([#15882](https://github.com/qmk/qmk_firmware/pull/15882))
|
||||
* Adjust mouse key defaults ([#15883](https://github.com/qmk/qmk_firmware/pull/15883))
|
||||
* RGB Matrix: Reload from EEPROM ([#15923](https://github.com/qmk/qmk_firmware/pull/15923))
|
||||
* Enable a default task throttle for split pointing. ([#15925](https://github.com/qmk/qmk_firmware/pull/15925))
|
||||
* Move mcp23018 driver to core ([#15944](https://github.com/qmk/qmk_firmware/pull/15944))
|
||||
* Relocate matrix_init_quantum content ([#15953](https://github.com/qmk/qmk_firmware/pull/15953))
|
||||
* Align location of some host led logic ([#15954](https://github.com/qmk/qmk_firmware/pull/15954))
|
||||
* Rename some Quantum keycodes ([#15968](https://github.com/qmk/qmk_firmware/pull/15968))
|
||||
* Migrate more makefile utilities to builddefs sub-directory ([#16002](https://github.com/qmk/qmk_firmware/pull/16002))
|
||||
* Various Makefile optimisations ([#16015](https://github.com/qmk/qmk_firmware/pull/16015))
|
||||
* Add support for STM32L432, STM32L442. ([#16016](https://github.com/qmk/qmk_firmware/pull/16016))
|
||||
* EEPROM refactor: remove `eeprom_teensy.c` by default, use transient instead ([#16020](https://github.com/qmk/qmk_firmware/pull/16020))
|
||||
* Deprecate Split Transaction status field ([#16023](https://github.com/qmk/qmk_firmware/pull/16023))
|
||||
* Rip out old macro and action_function system ([#16025](https://github.com/qmk/qmk_firmware/pull/16025))
|
||||
* Add a script that simplifies running commands under docker. ([#16028](https://github.com/qmk/qmk_firmware/pull/16028))
|
||||
* Add support for Q-series on the ckled2001 LED driver ([#16051](https://github.com/qmk/qmk_firmware/pull/16051))
|
||||
* Remove unused suspend_idle ([#16063](https://github.com/qmk/qmk_firmware/pull/16063))
|
||||
* Initial migration of suspend callbacks ([#16067](https://github.com/qmk/qmk_firmware/pull/16067))
|
||||
* Add layout change callbacks to VIA ([#16087](https://github.com/qmk/qmk_firmware/pull/16087))
|
||||
* Rename `AdafruitBLE` to `BluefruitLE` ([#16127](https://github.com/qmk/qmk_firmware/pull/16127))
|
||||
* Update outputselect to use platform connected state API ([#16185](https://github.com/qmk/qmk_firmware/pull/16185))
|
||||
* Remove default pointing device driver. ([#16190](https://github.com/qmk/qmk_firmware/pull/16190))
|
||||
* Add SN74x138 demultiplexer driver ([#16217](https://github.com/qmk/qmk_firmware/pull/16217))
|
||||
* Standardise error output. ([#16220](https://github.com/qmk/qmk_firmware/pull/16220))
|
||||
* Followup to #16220, more test error output. ([#16221](https://github.com/qmk/qmk_firmware/pull/16221))
|
||||
* Misc size regression script improvements. ([#16268](https://github.com/qmk/qmk_firmware/pull/16268))
|
||||
* Align existing pca9555 driver to better match mcp23018 API ([#16277](https://github.com/qmk/qmk_firmware/pull/16277))
|
||||
* Size checks print out target firmware file instead ([#16290](https://github.com/qmk/qmk_firmware/pull/16290))
|
||||
|
||||
CLI:
|
||||
* `develop` changelog generator: use the PR title instead ([#15537](https://github.com/qmk/qmk_firmware/pull/15537))
|
||||
* `develop` changelog generator: skip code formatting in listing ([#16215](https://github.com/qmk/qmk_firmware/pull/16215))
|
||||
|
||||
Keyboards:
|
||||
* Durgod: Increase scan rate by using wait_us timer ([#14091](https://github.com/qmk/qmk_firmware/pull/14091))
|
||||
* Add another GMMK Pro ANSI Keymap with custom RGB. ([#14243](https://github.com/qmk/qmk_firmware/pull/14243))
|
||||
* Parse USB device version BCD ([#14580](https://github.com/qmk/qmk_firmware/pull/14580))
|
||||
* Add vitoni keymap for GMMK Pro (ISO) ([#15006](https://github.com/qmk/qmk_firmware/pull/15006))
|
||||
* Move bm65hsrgb_iso and bm68hsrgb to rev1/ to prepare for updates to the boards ([#15132](https://github.com/qmk/qmk_firmware/pull/15132))
|
||||
* Convert ergoinu to SPLIT_KEYBOARD ([#15305](https://github.com/qmk/qmk_firmware/pull/15305))
|
||||
* Convert not_so_minidox to SPLIT_KEYBOARD ([#15306](https://github.com/qmk/qmk_firmware/pull/15306))
|
||||
* Added new handwired keyboard Wakizashi 40 ([#15336](https://github.com/qmk/qmk_firmware/pull/15336))
|
||||
* Convert ai03/orbit to SPLIT_KEYBOARD ([#15340](https://github.com/qmk/qmk_firmware/pull/15340))
|
||||
* Remove manual enable of LTO within user keymaps ([#15378](https://github.com/qmk/qmk_firmware/pull/15378))
|
||||
* Move to organization folder ([#15481](https://github.com/qmk/qmk_firmware/pull/15481))
|
||||
* Convert some more boards to Matrix Lite ([#15489](https://github.com/qmk/qmk_firmware/pull/15489))
|
||||
* Organize Reviung boards into a directory ([#15636](https://github.com/qmk/qmk_firmware/pull/15636))
|
||||
* move winry25tc to winry/ ([#15637](https://github.com/qmk/qmk_firmware/pull/15637))
|
||||
* Rename ymdk_np21 to np21 + move to ymdk vendor folder ([#15641](https://github.com/qmk/qmk_firmware/pull/15641))
|
||||
* move ymd96 to ymdk vendor folder ([#15643](https://github.com/qmk/qmk_firmware/pull/15643))
|
||||
* move ymd75 to ymdk vendor folder ([#15645](https://github.com/qmk/qmk_firmware/pull/15645))
|
||||
* move yd60mq to ymdk vendor folder ([#15647](https://github.com/qmk/qmk_firmware/pull/15647))
|
||||
* rename idobo to idobao/id75, move to vendor folder ([#15661](https://github.com/qmk/qmk_firmware/pull/15661))
|
||||
* move ID67 to IDOBAO vendor folder ([#15662](https://github.com/qmk/qmk_firmware/pull/15662))
|
||||
* move ID80 to IDOBAO vendor folder ([#15665](https://github.com/qmk/qmk_firmware/pull/15665))
|
||||
* move ID87 to IDOBAO vendor folder ([#15667](https://github.com/qmk/qmk_firmware/pull/15667))
|
||||
* move montex to IDOBAO vendor folder ([#15668](https://github.com/qmk/qmk_firmware/pull/15668))
|
||||
* move @yangdigi 's keyboards to a YDKB folder ([#15681](https://github.com/qmk/qmk_firmware/pull/15681))
|
||||
* move @kkatano 's keyboards to kkatano user folder ([#15684](https://github.com/qmk/qmk_firmware/pull/15684))
|
||||
* Sol 3 Keyboard from RGBKB ([#15687](https://github.com/qmk/qmk_firmware/pull/15687))
|
||||
* move cu24, cu75, cu80/v1 into capsunlocked folder ([#15758](https://github.com/qmk/qmk_firmware/pull/15758))
|
||||
* move mechkeys keyboards into the mechkeys/ vendor folder ([#15760](https://github.com/qmk/qmk_firmware/pull/15760))
|
||||
* move @lyso1 's boards into lyso1/ ([#15767](https://github.com/qmk/qmk_firmware/pull/15767))
|
||||
* move prototypist boards into vendor folder ([#15780](https://github.com/qmk/qmk_firmware/pull/15780))
|
||||
* move @yiancar 's boards into yiancardesigns/ ([#15781](https://github.com/qmk/qmk_firmware/pull/15781))
|
||||
* move novelkeys keyboards to vendor folder ([#15783](https://github.com/qmk/qmk_firmware/pull/15783))
|
||||
* move @weirdo-f 's keyboards into weirdo/ ([#15785](https://github.com/qmk/qmk_firmware/pull/15785))
|
||||
* move @marksard 's boards to marksard/ ([#15786](https://github.com/qmk/qmk_firmware/pull/15786))
|
||||
* move input club keyboards into vendor folder ([#15788](https://github.com/qmk/qmk_firmware/pull/15788))
|
||||
* move @monksoffunk 's boards into 25keys/ ([#15789](https://github.com/qmk/qmk_firmware/pull/15789))
|
||||
* move @Salicylic-acid3 's keyboards to salicylic-acid3/ ([#15791](https://github.com/qmk/qmk_firmware/pull/15791))
|
||||
* move @rainkeebs 's keyboards to rainkeebs/ ([#15797](https://github.com/qmk/qmk_firmware/pull/15797))
|
||||
* move standaside into edi/ ([#15798](https://github.com/qmk/qmk_firmware/pull/15798))
|
||||
* move @obosob 's boards into obosob/ ([#15799](https://github.com/qmk/qmk_firmware/pull/15799))
|
||||
* move @nacly 's boards to nacly/ ([#15801](https://github.com/qmk/qmk_firmware/pull/15801))
|
||||
* move @kakunpc 's keebs into kakunpc/ ([#15814](https://github.com/qmk/qmk_firmware/pull/15814))
|
||||
* move @qpocket 's keyboards to qpocket/ ([#15827](https://github.com/qmk/qmk_firmware/pull/15827))
|
||||
* BDN9 keymap ([#15924](https://github.com/qmk/qmk_firmware/pull/15924))
|
||||
* move @matthewdias 's keebs into matthewdias/ ([#15991](https://github.com/qmk/qmk_firmware/pull/15991))
|
||||
* move id80 and id75 to v1 to accommodate for id75 v2 and id80 v3 ([#15992](https://github.com/qmk/qmk_firmware/pull/15992))
|
||||
* Remove `action_function()` from LFKeyboards boards ([#15993](https://github.com/qmk/qmk_firmware/pull/15993))
|
||||
* move @latincompass (aka @18438880 , @haierwangwei2005)'s boards to /latincompass ([#16039](https://github.com/qmk/qmk_firmware/pull/16039))
|
||||
* move g heavy industry boards into /gboards ([#16040](https://github.com/qmk/qmk_firmware/pull/16040))
|
||||
* move @drhigsby 's boards into /drhigsby ([#16041](https://github.com/qmk/qmk_firmware/pull/16041))
|
||||
* More keyboard rules.mk cleanups ([#16044](https://github.com/qmk/qmk_firmware/pull/16044))
|
||||
* move @That-Canadian 's boards into /maple_computing ([#16050](https://github.com/qmk/qmk_firmware/pull/16050))
|
||||
* move @takai 's keyboards into /recompile_keys ([#16053](https://github.com/qmk/qmk_firmware/pull/16053))
|
||||
* move @satt99 's comet46 to satt/ ([#16059](https://github.com/qmk/qmk_firmware/pull/16059))
|
||||
* move @ka2hiro 's boards into /kagizaraya ([#16070](https://github.com/qmk/qmk_firmware/pull/16070))
|
||||
* move @GlenPickle 's chimera* boards into a folder ([#16072](https://github.com/qmk/qmk_firmware/pull/16072))
|
||||
* move @yynmt 's boards into /yynmt ([#16075](https://github.com/qmk/qmk_firmware/pull/16075))
|
||||
* move @Biacco42 's keebs into /biacco42 ([#16080](https://github.com/qmk/qmk_firmware/pull/16080))
|
||||
* move unikeyboard boards to /unikeyboard ([#16081](https://github.com/qmk/qmk_firmware/pull/16081))
|
||||
* move four_banger to bpiphany ([#16082](https://github.com/qmk/qmk_firmware/pull/16082))
|
||||
* move @takashiski 's keebs into /takashiski ([#16089](https://github.com/qmk/qmk_firmware/pull/16089))
|
||||
* move hid_liber to /bpiphany ([#16091](https://github.com/qmk/qmk_firmware/pull/16091))
|
||||
* move spaceholdings boards into /spaceholdings ([#16096](https://github.com/qmk/qmk_firmware/pull/16096))
|
||||
* move @7-rate 's keebs to /rate ([#16099](https://github.com/qmk/qmk_firmware/pull/16099))
|
||||
* move @npspears 's boards into /checkerboards ([#16100](https://github.com/qmk/qmk_firmware/pull/16100))
|
||||
* move @vuhopkep 's keebs into /hnahkb ([#16102](https://github.com/qmk/qmk_firmware/pull/16102))
|
||||
* move @ibnuda 's keebs into /ibnuda ([#16108](https://github.com/qmk/qmk_firmware/pull/16108))
|
||||
* move @tominabox1 's keebs into /tominabox1 ([#16109](https://github.com/qmk/qmk_firmware/pull/16109))
|
||||
* move niu_mini to /kbdfans ([#16112](https://github.com/qmk/qmk_firmware/pull/16112))
|
||||
* move woodkeys.click keyboards to /woodkeys ([#16113](https://github.com/qmk/qmk_firmware/pull/16113))
|
||||
* move @omkbd 's boards to /omkbd ([#16116](https://github.com/qmk/qmk_firmware/pull/16116))
|
||||
* Overhaul Tractyl Manuform ([#16134](https://github.com/qmk/qmk_firmware/pull/16134))
|
||||
* Reduce firmware size for dztech/dz60rgb_wkl/v2_1:via ([#16254](https://github.com/qmk/qmk_firmware/pull/16254))
|
||||
|
||||
Keyboard fixes:
|
||||
* Fix build failure for UT47 ([#15483](https://github.com/qmk/qmk_firmware/pull/15483))
|
||||
* Update grs_70ec to use newer custom matrix ([#15609](https://github.com/qmk/qmk_firmware/pull/15609))
|
||||
* fix compiler issue with Tractyl Manuform 4x6 ([#15646](https://github.com/qmk/qmk_firmware/pull/15646))
|
||||
* Fix CI. ([#15828](https://github.com/qmk/qmk_firmware/pull/15828))
|
||||
* Yet another bad `DEFAULT_FOLDER` fix. ([#15904](https://github.com/qmk/qmk_firmware/pull/15904))
|
||||
* Fix build failures for `mschwingen/modelm` ([#15987](https://github.com/qmk/qmk_firmware/pull/15987))
|
||||
* `rocketboard_16`: Fix mismatched LUT sizes ([#15997](https://github.com/qmk/qmk_firmware/pull/15997))
|
||||
* Fix erroneous SRC for Clueboard 66 hotswap ([#16007](https://github.com/qmk/qmk_firmware/pull/16007))
|
||||
* Fix handwired/ms_sculpt_mobile default keymap ([#16032](https://github.com/qmk/qmk_firmware/pull/16032))
|
||||
* Re-org Hillside folders as new model prep. Fix default keymap. ([#16128](https://github.com/qmk/qmk_firmware/pull/16128))
|
||||
* Fix up default folder locations. Again. ([#16135](https://github.com/qmk/qmk_firmware/pull/16135))
|
||||
* Sol3 rgb fix ([#16157](https://github.com/qmk/qmk_firmware/pull/16157))
|
||||
* Add missing `BOOTLOADER` for a handful of boards ([#16225](https://github.com/qmk/qmk_firmware/pull/16225))
|
||||
* Remove half implemented micronucleus bootloader support ([#16252](https://github.com/qmk/qmk_firmware/pull/16252))
|
||||
* Fixup bootloaders. ([#16256](https://github.com/qmk/qmk_firmware/pull/16256))
|
||||
* Fix idobao/id80/v3 compilation errors ([#16280](https://github.com/qmk/qmk_firmware/pull/16280))
|
||||
* Remove parent-relative paths from keyboards. ([#16282](https://github.com/qmk/qmk_firmware/pull/16282))
|
||||
* Bodge for helix build failures ([#16376](https://github.com/qmk/qmk_firmware/pull/16376))
|
||||
|
||||
Others:
|
||||
* Add a clarification to an error message ([#15207](https://github.com/qmk/qmk_firmware/pull/15207))
|
||||
* Clang-format tweaks ([#15906](https://github.com/qmk/qmk_firmware/pull/15906))
|
||||
* Add example implementations for compatible MCUs list ([#15935](https://github.com/qmk/qmk_firmware/pull/15935))
|
||||
* Add version.h to gitignore ([#16222](https://github.com/qmk/qmk_firmware/pull/16222))
|
||||
* Update keyboard mapping for all moved boards this cycle ([#16312](https://github.com/qmk/qmk_firmware/pull/16312))
|
||||
* Align docs to new-keyboard behaviour ([#16357](https://github.com/qmk/qmk_firmware/pull/16357))
|
||||
* Align new-keyboard with recent schema updates ([#16378](https://github.com/qmk/qmk_firmware/pull/16378))
|
||||
|
||||
Bugs:
|
||||
* Fixes potential wpm sampling overflow, along with code comment fixes ([#15277](https://github.com/qmk/qmk_firmware/pull/15277))
|
||||
* Add missing define for unicode common ([#15416](https://github.com/qmk/qmk_firmware/pull/15416))
|
||||
* Fix for SPI write timing in PMW3360 driver ([#15519](https://github.com/qmk/qmk_firmware/pull/15519))
|
||||
* Documentation Typo fix ([#15538](https://github.com/qmk/qmk_firmware/pull/15538))
|
||||
* fix a typo ([#15557](https://github.com/qmk/qmk_firmware/pull/15557))
|
||||
* Fix avr serial compile ([#15589](https://github.com/qmk/qmk_firmware/pull/15589))
|
||||
* More AVR GPIO compilation fixes. ([#15592](https://github.com/qmk/qmk_firmware/pull/15592))
|
||||
* Fix bug and code regression for Split Common ([#15603](https://github.com/qmk/qmk_firmware/pull/15603))
|
||||
* Include missing string.h include in split ([#15606](https://github.com/qmk/qmk_firmware/pull/15606))
|
||||
* Fixes for bootloader refactor build failures ([#15638](https://github.com/qmk/qmk_firmware/pull/15638))
|
||||
* Update pmw3360 driver after reading the datasheet top to bottom. Fix some outdated refs. ([#15682](https://github.com/qmk/qmk_firmware/pull/15682))
|
||||
* Fix split pointing for analog joystick ([#15691](https://github.com/qmk/qmk_firmware/pull/15691))
|
||||
* Fix broken bootloader builds in develop. ([#15880](https://github.com/qmk/qmk_firmware/pull/15880))
|
||||
* Fix optical sensor firmware upload ([#15919](https://github.com/qmk/qmk_firmware/pull/15919))
|
||||
* Pass in the keyrecord_t of the dual-role/tapping key when calling per-key tap hold functions ([#15938](https://github.com/qmk/qmk_firmware/pull/15938))
|
||||
* fixed typo in orange HSV colors decalartion ([#15976](https://github.com/qmk/qmk_firmware/pull/15976))
|
||||
* Fix hack for chibiOS reset name ([#15984](https://github.com/qmk/qmk_firmware/pull/15984))
|
||||
* Fix right side ws2812 leds having two indices ([#15985](https://github.com/qmk/qmk_firmware/pull/15985))
|
||||
* Workaround in Makefile for recursive rule matching ([#15988](https://github.com/qmk/qmk_firmware/pull/15988))
|
||||
* Fix BACKLIGHT_CAPS_LOCK warning ([#15999](https://github.com/qmk/qmk_firmware/pull/15999))
|
||||
* Fix compilation issues for led indicators ([#16001](https://github.com/qmk/qmk_firmware/pull/16001))
|
||||
* ChibiOS timer fixes ([#16017](https://github.com/qmk/qmk_firmware/pull/16017))
|
||||
* Fix bootloader_jump for certain CTRL boards ([#16026](https://github.com/qmk/qmk_firmware/pull/16026))
|
||||
* Fix up issue with PROGMEM and hand_swap_config ([#16027](https://github.com/qmk/qmk_firmware/pull/16027))
|
||||
* Don't make EEPROM size assumptions with dynamic keymaps. ([#16054](https://github.com/qmk/qmk_firmware/pull/16054))
|
||||
* fix missed .noci in reviung move ([#16107](https://github.com/qmk/qmk_firmware/pull/16107))
|
||||
* Fix issues with Python Tests ([#16162](https://github.com/qmk/qmk_firmware/pull/16162))
|
||||
* Fixup multibuild filegen ([#16166](https://github.com/qmk/qmk_firmware/pull/16166))
|
||||
* Remove old .gitignore entry. Add more macOS junk exclusions. ([#16167](https://github.com/qmk/qmk_firmware/pull/16167))
|
||||
* Fixup builds so that teensy EEPROM knows which MCU it's targeting. ([#16168](https://github.com/qmk/qmk_firmware/pull/16168))
|
||||
* Create a build error if no bootloader is specified. ([#16181](https://github.com/qmk/qmk_firmware/pull/16181))
|
||||
* Ensure `version.h` is recreated each build. ([#16188](https://github.com/qmk/qmk_firmware/pull/16188))
|
||||
* Add `custom` to list of valid bootloader types in info.json ([#16228](https://github.com/qmk/qmk_firmware/pull/16228))
|
||||
* Fix `layer_state` restoration at end of dynamic macro feature #16208 ([#16230](https://github.com/qmk/qmk_firmware/pull/16230))
|
||||
* Minor additions #12795 ([#16276](https://github.com/qmk/qmk_firmware/pull/16276))
|
||||
* Various fixes for matrix _RIGHT handling ([#16292](https://github.com/qmk/qmk_firmware/pull/16292))
|
||||
* Fix slashes in build_full_test.mk ([#16300](https://github.com/qmk/qmk_firmware/pull/16300))
|
||||
* ps2/avr: use the correct file name ([#16316](https://github.com/qmk/qmk_firmware/pull/16316))
|
||||
* Fix compilation of ChibiOS UART driver ([#16348](https://github.com/qmk/qmk_firmware/pull/16348))
|
||||
* Various fixes for new-keyboard ([#16358](https://github.com/qmk/qmk_firmware/pull/16358))
|
||||
* Allow NO_PIN within data driven configuration ([#16359](https://github.com/qmk/qmk_firmware/pull/16359))
|
||||
24
docs/flash_driver.md
Normal file
24
docs/flash_driver.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# FLASH Driver Configuration :id=flash-driver-configuration
|
||||
|
||||
The FLASH driver can be swapped out depending on the needs of the keyboard, or whether extra hardware is present.
|
||||
|
||||
Driver | Description
|
||||
-----------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
`FLASH_DRIVER = spi` | Supports writing to almost all NOR Flash chips. See the driver section below.
|
||||
|
||||
|
||||
## SPI FLASH Driver Configuration :id=spi-flash-driver-configuration
|
||||
|
||||
Currently QMK supports almost all NOR Flash chips over SPI. As such, requires a working spi_master driver configuration. You can override the driver configuration via your config.h:
|
||||
|
||||
`config.h` override | Description | Default Value
|
||||
-----------------------------------------------|--------------------------------------------------------------------------------------|-----------------
|
||||
`#define EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN` | SPI Slave select pin in order to inform that the FLASH is currently being addressed | _none_
|
||||
`#define EXTERNAL_FLASH_SPI_CLOCK_DIVISOR` | Clock divisor used to divide the peripheral clock to derive the SPI frequency | `8`
|
||||
`#define EXTERNAL_FLASH_PAGE_SIZE` | The Page size of the FLASH in bytes, as specified in the datasheet | `256`
|
||||
`#define EXTERNAL_FLASH_SECTOR_SIZE` | The sector size of the FLASH in bytes, as specified in the datasheet | `(4 * 1024)`
|
||||
`#define EXTERNAL_FLASH_BLOCK_SIZE` | The block size of the FLASH in bytes, as specified in the datasheet | `(64 * 1024)`
|
||||
`#define EXTERNAL_FLASH_SIZE` | The total size of the FLASH in bytes, as specified in the datasheet | `(512 * 1024)`
|
||||
`#define EXTERNAL_FLASH_ADDRESS_SIZE` | The Flash address size in bytes, as specified in datasheet | `3`
|
||||
|
||||
!> All the above default configurations are based on MX25L4006E NOR Flash.
|
||||
163
docs/porting_your_keyboard_to_qmk.md
Normal file
163
docs/porting_your_keyboard_to_qmk.md
Normal file
@@ -0,0 +1,163 @@
|
||||
# Adding Your Keyboard to QMK
|
||||
|
||||
This page describes the support for [Compatible Microcontrollers](compatible_microcontrollers.md) in QMK.
|
||||
|
||||
If you have not yet you should read the [Keyboard Guidelines](hardware_keyboard_guidelines.md) to get a sense of how keyboards fit into QMK.
|
||||
|
||||
|
||||
QMK has a number of features to simplify working with keyboards. For most, you don't have to write a single line of code. To get started, run `qmk new-keyboard`:
|
||||
|
||||
```
|
||||
$ qmk new-keyboard
|
||||
Ψ Generating a new QMK keyboard directory
|
||||
|
||||
Name Your Keyboard Project
|
||||
For more infomation, see:
|
||||
https://docs.qmk.fm/#/hardware_keyboard_guidelines?id=naming-your-keyboardproject
|
||||
|
||||
keyboard Name? mycoolkeeb
|
||||
|
||||
Attribution
|
||||
Used for maintainer, copyright, etc
|
||||
|
||||
Your GitHub Username? [jsmith]
|
||||
|
||||
More Attribution
|
||||
Used for maintainer, copyright, etc
|
||||
|
||||
Your Real Name? [John Smith]
|
||||
|
||||
Pick Base Layout
|
||||
As a starting point, one of the common layouts can be used to bootstrap the process
|
||||
|
||||
Default Layout?
|
||||
1. 60_ansi
|
||||
...
|
||||
50. tkl_iso
|
||||
51. none of the above
|
||||
Please enter your choice: [51]
|
||||
|
||||
What Powers Your Project
|
||||
For more infomation, see:
|
||||
https://docs.qmk.fm/#/compatible_microcontrollers
|
||||
|
||||
MCU?
|
||||
1. atmega32u4
|
||||
...
|
||||
22. STM32F303
|
||||
Please enter your choice: [12]
|
||||
Ψ Created a new keyboard called mycoolkeeb.
|
||||
Ψ To start working on things, `cd` into keyboards/mycoolkeeb,
|
||||
Ψ or open the directory in your preferred text editor.
|
||||
Ψ And build with qmk compile -kb mycoolkeeb -km default.
|
||||
```
|
||||
|
||||
This will create all the files needed to support your new keyboard, and populate the settings with default values. Now you just need to customize it for your keyboard.
|
||||
|
||||
## `readme.md`
|
||||
|
||||
This is where you'll describe your keyboard. Please follow the [Keyboard Readme Template](documentation_templates.md#keyboard-readmemd-template) when writing your `readme.md`. You're encouraged to place an image at the top of your `readme.md`, please use an external service such as [Imgur](https://imgur.com) to host the images.
|
||||
|
||||
## `info.json`
|
||||
|
||||
The `info.json` file is where you configure the hardware and feature set for your keyboard. There are a lot of options that can be placed in that file, too many to list here. For a complete overview of available options see the [Data Driven Configuration Options](reference_info_json.md) page.
|
||||
|
||||
### Hardware Configuration
|
||||
|
||||
At the top of the `info.json` you'll find USB related settings. These control how your keyboard appears to the Operating System. If you don't have a good reason to change you should leave the `usb.vid` as `0xFEED`. For the `usb.pid` you should pick a number that is not yet in use.
|
||||
|
||||
Do change the `manufacturer` and `keyboard_name` lines to accurately reflect your keyboard.
|
||||
|
||||
```json
|
||||
"keyboard_name": "my_awesome_keyboard",
|
||||
"maintainer": "You",
|
||||
"usb": {
|
||||
"vid": "0xFEED",
|
||||
"pid": "0x0000",
|
||||
"device_version": "1.0.0"
|
||||
},
|
||||
```
|
||||
|
||||
?> Windows and macOS will display the `manufacturer` and `keyboard_name` in the list of USB devices. `lsusb` on Linux instead prefers the values in the list maintained by the [USB ID Repository](http://www.linux-usb.org/usb-ids.html). By default, it will only use `manufacturer` and `keyboard_name` if the list does not contain that `usb.vid` / `usb.pid`. `sudo lsusb -v` will show the values reported by the device, and they are also present in kernel logs after plugging it in.
|
||||
|
||||
|
||||
### Matrix Configuration
|
||||
|
||||
The next section of the `info` file deals with your keyboard's matrix. The first thing you should define is which pins on your MCU are connected to rows and columns. To do so simply specify the names of those pins:
|
||||
|
||||
```json
|
||||
"matrix_pins": {
|
||||
"cols": ["C1", "C2", "C3", "C4"],
|
||||
"rows": ["D1", "D2", "D3", "D4"]
|
||||
},
|
||||
```
|
||||
|
||||
The size of the `matrix_pins.cols` and `matrix_pins.rows` arrays infer the size of the matrix (previously `MATRIX_ROWS` and `MATRIX_COLS`).
|
||||
|
||||
Finally, you can specify the direction your diodes point. This can be `COL2ROW` or `ROW2COL`.
|
||||
|
||||
```json
|
||||
"diode_direction": "ROW2COL",
|
||||
```
|
||||
|
||||
#### Direct Pin Matrix
|
||||
To configure a keyboard where each switch is connected to a separate pin and ground instead of sharing row and column pins, use `matrix_pins.direct`. The mapping defines the pins of each switch in rows and columns, from left to right. The size of the `matrix_pins.direct` array infers the size of the matrix. Use `NO_PIN` to fill in blank spaces. Overrides the behaviour of `diode_direction`, `matrix_pins.cols` and `matrix_pins.rows`.
|
||||
|
||||
```json
|
||||
"matrix_pins": {
|
||||
"direct": [
|
||||
["F1", "E6", "B0", "B2", "B3" ],
|
||||
["F5", "F0", "B1", "B7", "D2" ],
|
||||
["F6", "F7", "C7", "D5", "D3" ],
|
||||
["B5", "C6", "B6", "NO_PIN", "NO_PIN"]
|
||||
]
|
||||
},
|
||||
```
|
||||
|
||||
### Layout macros
|
||||
|
||||
Next is configuring Layout Macro(s). These define the physical arrangement of keys, and its position within the matrix that a switch are connected to. This allows you to have a physical arrangement of keys that differs from the wiring matrix.
|
||||
|
||||
```json
|
||||
"layouts": {
|
||||
"LAYOUT_ortho_4x4": {
|
||||
"layout": [
|
||||
{ "matrix": [0, 0], "x": 0, "y": 0 },
|
||||
{ "matrix": [0, 1], "x": 1, "y": 0 },
|
||||
{ "matrix": [0, 2], "x": 2, "y": 0 },
|
||||
{ "matrix": [0, 3], "x": 3, "y": 0 },
|
||||
{ "matrix": [1, 0], "x": 0, "y": 1 },
|
||||
{ "matrix": [1, 1], "x": 1, "y": 1 },
|
||||
{ "matrix": [1, 2], "x": 2, "y": 1 },
|
||||
{ "matrix": [1, 3], "x": 3, "y": 1 },
|
||||
{ "matrix": [2, 0], "x": 0, "y": 2 },
|
||||
{ "matrix": [2, 1], "x": 1, "y": 2 },
|
||||
{ "matrix": [2, 2], "x": 2, "y": 2 },
|
||||
{ "matrix": [2, 3], "x": 3, "y": 2 },
|
||||
{ "matrix": [3, 0], "x": 0, "y": 3 },
|
||||
{ "matrix": [3, 1], "x": 1, "y": 3 },
|
||||
{ "matrix": [3, 2], "x": 2, "y": 3 },
|
||||
{ "matrix": [3, 3], "x": 3, "y": 3 }
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
In the above example,
|
||||
|
||||
* `LAYOUT_ortho_4x4` defines the name of the layout macro
|
||||
* It must conform to [hardware_keyboard_guidelines.md#ltkeyboard_namehgt]
|
||||
* `"matrix": [0, 0]` defines the electrical position
|
||||
|
||||
## Additional Configuration
|
||||
|
||||
There are a lot of features that can be turned on or off, configured or tuned. Some of these have yet to be migrated over to [Data Driven Configuration](data_driven_config.md). The following sections cover the process for when an `info.json` option is unavailable.
|
||||
|
||||
### Configuration Options
|
||||
|
||||
For available options for `config.h`, you should see the [Config Options](config_options.md) page for more details.
|
||||
|
||||
### Build Options
|
||||
|
||||
For available options for `rules.mk`, see the [Config Options](config_options.md#feature-options) page for a detailed list and description.
|
||||
73
docs/zh-cn/api_docs.md
Normal file
73
docs/zh-cn/api_docs.md
Normal file
@@ -0,0 +1,73 @@
|
||||
# QMK API
|
||||
|
||||
<!---
|
||||
original document: 0.15.12:docs/api_docs.md
|
||||
git diff 0.15.12 HEAD -- docs/api_docs.md | cat
|
||||
-->
|
||||
|
||||
本章节详述了QMK API的使用方法,若您是应用开发者,使用这套API可以实现[QMK](https://qmk.fm)键盘固件的编译支持。
|
||||
|
||||
## 总览
|
||||
|
||||
本服务提供了一套用于编译自定义键映射的异步API,通过POST方式发送JSON参数到API,定期检查执行状态,待固件编译完成后,即可下载生成的固件文件和固件的源文件(如果需要的话)。
|
||||
|
||||
#### 荷载JSON参数示例:
|
||||
|
||||
```json
|
||||
{
|
||||
"keyboard": "clueboard/66/rev2",
|
||||
"keymap": "my_awesome_keymap",
|
||||
"layout": "LAYOUT_all",
|
||||
"layers": [
|
||||
["KC_GRV","KC_1","KC_2","KC_3","KC_4","KC_5","KC_6","KC_7","KC_8","KC_9","KC_0","KC_MINS","KC_EQL","KC_GRV","KC_BSPC","KC_PGUP","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_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_NUHS","KC_ENT","KC_LSFT","KC_NUBS","KC_Z","KC_X","KC_C","KC_V","KC_B","KC_N","KC_M","KC_COMM","KC_DOT","KC_SLSH","KC_RO","KC_RSFT","KC_UP","KC_LCTL","KC_LGUI","KC_LALT","KC_MHEN","KC_SPC","KC_SPC","KC_HENK","KC_RALT","KC_RCTL","MO(1)","KC_LEFT","KC_DOWN","KC_RIGHT"],
|
||||
["KC_ESC","KC_F1","KC_F2","KC_F3","KC_F4","KC_F5","KC_F6","KC_F7","KC_F8","KC_F9","KC_F10","KC_F11","KC_F12","KC_TRNS","KC_DEL","BL_STEP","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","_______","KC_TRNS","KC_PSCR","KC_SLCK","KC_PAUS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","MO(2)","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_PGUP","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","MO(1)","KC_LEFT","KC_PGDN","KC_RGHT"],
|
||||
["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","RESET","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","KC_TRNS","MO(2)","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","MO(1)","KC_TRNS","KC_TRNS","KC_TRNS"]
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
如上可见,荷载参数里有用于生成固件文件的所有键盘信息。每一个层定义都包含了与键盘 `LAYOUT` 宏定义一致的QMK键码列表数据,若该键盘有多个支持的 `LAYOUT` 宏定义,也可以指定使用的是哪一个。
|
||||
|
||||
## 提交一个编译job
|
||||
|
||||
若要将键映射配置编译成固件文件,仅需将JSON参数通过POST发送至 `/v1/compile` 节点。下面的示例中我们假设JSON荷载参数已存放在 `json_data` 文件中。
|
||||
|
||||
```
|
||||
$ curl -H "Content-Type: application/json" -X POST -d "$(< json_data)" https://api.qmk.fm/v1/compile
|
||||
{
|
||||
"enqueued": true,
|
||||
"job_id": "ea1514b3-bdfc-4a7b-9b5c-08752684f7f6"
|
||||
}
|
||||
```
|
||||
|
||||
## 检查状态
|
||||
|
||||
键映射配置提交后,可以简单地通过 HTTP GET 请求来查询job状态:
|
||||
|
||||
```
|
||||
$ curl https://api.qmk.fm/v1/compile/ea1514b3-bdfc-4a7b-9b5c-08752684f7f6
|
||||
{
|
||||
"created_at": "Sat, 19 Aug 2017 21:39:12 GMT",
|
||||
"enqueued_at": "Sat, 19 Aug 2017 21:39:12 GMT",
|
||||
"id": "f5f9b992-73b4-479b-8236-df1deb37c163",
|
||||
"status": "running",
|
||||
"result": null
|
||||
}
|
||||
```
|
||||
|
||||
这份信息告诉我们编译job已经提交到队列中且正在执行。job的状态有5种:
|
||||
|
||||
* **failed(失败)**: 编译服务出现问题。
|
||||
* **finished(完成)**: 编译已完成,`result` 字段中保存了编译结果。
|
||||
* **queued(排队中)**: 键映射job在等待可用的编译服务器。
|
||||
* **running(执行中)**: 编译进行中,应当很快就会结束。
|
||||
* **unknown(未知)**: 出现了较严重的错误,请给我们[提交一个bug](https://github.com/qmk/qmk_compiler/issues).
|
||||
|
||||
## 确认编译产出
|
||||
|
||||
编译job完成后请查看 `result` 字段,该字段下保存了如下信息项的哈希表数据:
|
||||
|
||||
* `firmware_binary_url`: 用于刷写的固件文件URL列表
|
||||
* `firmware_keymap_url`: `keymap.c` 文件URL列表
|
||||
* `firmware_source_url`: 完整的固件源代码URL列表
|
||||
* `output`: 编译job的stdout及stderr输出信息,所有错误信息都会在这里。
|
||||
20
docs/zh-cn/api_overview.md
Normal file
20
docs/zh-cn/api_overview.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# QMK API
|
||||
|
||||
<!---
|
||||
original document: 0.15.12:docs/api_overview.md
|
||||
git diff 0.15.12 HEAD -- docs/api_overview.md | cat
|
||||
-->
|
||||
|
||||
QMK API提供了一套可用于Web及GUI工具可用的异步API,用于实现将任何[QMK](https://qmk.fm/)支持的键盘的键映射方案进行编译。已有的键映射模板支持所有的QMK键码并且不需要额外的C代码需求。键盘的维护团队可以提供新的模板来启用更多功能的支持。
|
||||
|
||||
## App开发者
|
||||
|
||||
若您是一位意愿将这套API引入您的程序中的移动端App开发者,请参阅[API使用指引](zh-cn/api_docs.md)。
|
||||
|
||||
## 键盘维护团队
|
||||
|
||||
若您希望强化您维护的键盘方案在QMK编译API中的支持,请参阅[键盘支持](zh-cn/reference_configurator_support.md)。
|
||||
|
||||
## 后端开发者
|
||||
|
||||
若您对这套API系统本身感兴趣,请参阅[开发环境](zh-cn/api_development_environment.md)搭建环境并继续深入探索[架构总览](zh-cn/api_development_overview.md)。
|
||||
43
docs/zh-cn/cli.md
Normal file
43
docs/zh-cn/cli.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# QMK CLI :id=qmk-cli
|
||||
|
||||
<!---
|
||||
original document: 0.15.12:docs/cli.md
|
||||
git diff 0.15.12 HEAD -- docs/cli.md | cat
|
||||
-->
|
||||
|
||||
## 总览 :id=overview
|
||||
|
||||
QMK CLI可以让构建QMK键盘的过程更轻松一些,我们已提供的一批指令可用于简化及流式化地处理一些常见工作,如获取并编译QMK固件,创建新的键映射等。
|
||||
|
||||
### 依赖项 :id=requirements
|
||||
|
||||
QMK依赖Python 3.6或更高版本。我们已经尽力缩减依赖项,但在[`requirements.txt`](https://github.com/qmk/qmk_firmware/blob/master/requirements.txt)中的依赖项是需安装的包。在安装QMK CLI时这些依赖项也会自动完成安装。
|
||||
|
||||
### 通过 Homebrew 安装(macOS 及部分 Linux) :id=install-using-homebrew
|
||||
|
||||
若已安装[Homebrew](https://brew.sh),可以按如下方法安装QMK:
|
||||
|
||||
```
|
||||
brew install qmk/qmk/qmk
|
||||
export QMK_HOME='~/qmk_firmware' # 可选,指定 `qmk_firmware` 的路径
|
||||
qmk setup # 拉取 `qmk/qmk_firmware` 并选择性地配置构建环境
|
||||
```
|
||||
|
||||
### 通过 pip 安装 :id=install-using-easy_install-or-pip
|
||||
|
||||
未在以上列出的操作系统可以手动安装QMK。首先确认已安装Python 3.6(或更高版本)及 pip,然后通过如下指令安装QMK:
|
||||
|
||||
```
|
||||
python3 -m pip install qmk
|
||||
export QMK_HOME='~/qmk_firmware' # 可选,指定 `qmk_firmware` 的路径
|
||||
qmk setup # 拉取 `qmk/qmk_firmware` 并选择性地配置构建环境
|
||||
```
|
||||
|
||||
### 其它操作系统的安装包 :id=packaging-for-other-operating-systems
|
||||
|
||||
我们正在寻求可以制作维护更多操作系统下可用的 `qmk` 安装包的开发者,若您愿意为您的操作系统制作安装包,请遵循如下指引:
|
||||
|
||||
* 当该系统下的最佳实践与本指引冲突时,请遵循系统的最佳实践方案
|
||||
* 但请在注释中列明此处违反这份指引的原因
|
||||
* 在 virtualenv 下安装
|
||||
* 指引用户去设置 `QMK_HOME` 环境变量,使得固件源文件拉取路径不再是默认的 `~/qmk_firmware`
|
||||
503
docs/zh-cn/cli_commands.md
Normal file
503
docs/zh-cn/cli_commands.md
Normal file
@@ -0,0 +1,503 @@
|
||||
# QMK CLI 命令
|
||||
|
||||
<!---
|
||||
original document: 0.15.12:docs/cli_commands.md
|
||||
git diff 0.15.12 HEAD -- docs/cli_commands.md | cat
|
||||
-->
|
||||
|
||||
# 用户命令
|
||||
|
||||
## `qmk compile`
|
||||
|
||||
该命令用于在指定目录下编译固件,可用于构建<https://config.qmk.fm>导出的JSON数据,代码库中的键映射,或是当前目录下的键盘。
|
||||
|
||||
该命令会尝试感知目录路径,当你在键盘或键映射目录下执行时,KEYBOARD及KEYMAP参数将被自动填入。
|
||||
|
||||
**用于配置器导出的数据时**:
|
||||
|
||||
```
|
||||
qmk compile [-c] <configuratorExport.json>
|
||||
```
|
||||
|
||||
**用于键映射时**:
|
||||
|
||||
```
|
||||
qmk compile [-c] [-e <var>=<value>] [-j <num_jobs>] -kb <keyboard_name> -km <keymap_name>
|
||||
```
|
||||
|
||||
**在键盘目录下时**:
|
||||
|
||||
须在存在默认键映射的键盘目录下执行,或是在键盘的键映射子目录下,否则须指定参数 `--keymap <keymap_name>`
|
||||
```
|
||||
qmk compile
|
||||
```
|
||||
|
||||
**构建所有支持该键映射的键盘时**:
|
||||
|
||||
```
|
||||
qmk compile -kb all -km <keymap_name>
|
||||
```
|
||||
|
||||
**示例**:
|
||||
```
|
||||
$ qmk config compile.keymap=default
|
||||
$ cd ~/qmk_firmware/keyboards/planck/rev6
|
||||
$ qmk compile
|
||||
Ψ Compiling keymap with make planck/rev6:default
|
||||
...
|
||||
```
|
||||
指定键映射参数时
|
||||
|
||||
```
|
||||
$ cd ~/qmk_firmware/keyboards/clueboard/66/rev4
|
||||
$ qmk compile -km 66_iso
|
||||
Ψ Compiling keymap with make clueboard/66/rev4:66_iso
|
||||
...
|
||||
```
|
||||
位于键盘目录下时
|
||||
|
||||
```
|
||||
$ cd ~/qmk_firmware/keyboards/gh60/satan/keymaps/colemak
|
||||
$ qmk compile
|
||||
Ψ Compiling keymap with make gh60/satan:colemak
|
||||
...
|
||||
```
|
||||
|
||||
**在配列目录下时**:
|
||||
|
||||
必须是在 `qmk_firmware/layouts/` 下的键映射目录下。
|
||||
```
|
||||
qmk compile -kb <keyboard_name>
|
||||
```
|
||||
|
||||
**示例**:
|
||||
```
|
||||
$ cd ~/qmk_firmware/layouts/community/60_ansi/mechmerlin-ansi
|
||||
$ qmk compile -kb dz60
|
||||
Ψ Compiling keymap with make dz60:mechmerlin-ansi
|
||||
...
|
||||
```
|
||||
|
||||
**并行编译**:
|
||||
|
||||
在编译时添加 `-j`/`--parallel` 开关可能有助于加快编译速度。
|
||||
```
|
||||
qmk compile -j <num_jobs> -kb <keyboard_name>
|
||||
```
|
||||
`num_jobs` 用于指定并行的job上限,将其设置为0可以实现无限制的并行编译。
|
||||
```
|
||||
qmk compile -j 0 -kb <keyboard_name>
|
||||
```
|
||||
|
||||
## `qmk flash` :id=qmk-flash
|
||||
|
||||
该命令与 `qmk compile` 类似,但额外地可以指定bootloader。bootloader参数是可选的,默认会指定为 `:flash`。可通过 `-bl <bootloader>` 来指定bootloader。请查阅[刷写固件](zh-cn/flashing.md)指引以深入了解可用的bootloader信息。
|
||||
|
||||
该命令会尝试感知目录路径,当你在键盘或键映射目录下执行时,KEYBOARD及KEYMAP参数将被自动填入。
|
||||
|
||||
**用于配置器导出的数据时**:
|
||||
|
||||
```
|
||||
qmk flash [-bl <bootloader>] [-c] [-e <var>=<value>] [-j <num_jobs>] <configuratorExport.json>
|
||||
```
|
||||
|
||||
**用于键映射时**:
|
||||
|
||||
```
|
||||
qmk flash -kb <keyboard_name> -km <keymap_name> [-bl <bootloader>] [-c] [-e <var>=<value>] [-j <num_jobs>]
|
||||
```
|
||||
|
||||
**列出所有bootloader**
|
||||
|
||||
```
|
||||
qmk flash -b
|
||||
```
|
||||
|
||||
## `qmk config`
|
||||
|
||||
该命令用于配置QMK功能,完整的 `qmk config` 文档参见[CLI配置](zh-cn/cli_configuration.md)。
|
||||
|
||||
**使用方法**:
|
||||
|
||||
```
|
||||
qmk config [-ro] [config_token1] [config_token2] [...] [config_tokenN]
|
||||
```
|
||||
|
||||
## `qmk cd`
|
||||
|
||||
该命令会启动一个新的 shell 会话并定位到 `qmk_firmware` 所在目录。
|
||||
|
||||
须留意如果你已经位于 `QMK_HOME` 下的某个位置(比如 `keyboards/` 目录中),该指令不会生效。
|
||||
|
||||
若要退回到原来的 shell 会话,只需要执行 `exit`。
|
||||
|
||||
**使用方法**:
|
||||
|
||||
```
|
||||
qmk cd
|
||||
```
|
||||
|
||||
## `qmk console`
|
||||
|
||||
该命令用于连接键盘终端并展示调试信息。仅当键盘固件通过 `CONSOLE_ENABLE=yes` 编译时有效。
|
||||
|
||||
**用法**:
|
||||
|
||||
```
|
||||
qmk console [-d <pid>:<vid>[:<index>]] [-l] [-n] [-t] [-w <seconds>]
|
||||
```
|
||||
|
||||
**示例**:
|
||||
|
||||
连接到所有可用的键盘并输出终端信息:
|
||||
|
||||
```
|
||||
qmk console
|
||||
```
|
||||
|
||||
列出所有设备:
|
||||
|
||||
```
|
||||
qmk console -l
|
||||
```
|
||||
|
||||
仅输出 clueboard/66/rev3 键盘的信息:
|
||||
|
||||
```
|
||||
qmk console -d C1ED:2370
|
||||
```
|
||||
|
||||
仅输出第二把 clueboard/66/rev3 键盘的信息:
|
||||
|
||||
```
|
||||
qmk console -d C1ED:2370:2
|
||||
```
|
||||
|
||||
输出时间戳及VID:PID以替代键盘名:
|
||||
|
||||
```
|
||||
qmk console -n -t
|
||||
```
|
||||
|
||||
屏蔽bootloader的消息:
|
||||
|
||||
```
|
||||
qmk console --no-bootloaders
|
||||
```
|
||||
|
||||
## `qmk doctor`
|
||||
|
||||
该命令用以检查你的开发环境并对发现的潜在的构建及刷写问题进行提醒,如果您乐意,它也可以修复其中大部分问题。
|
||||
|
||||
**用法**:
|
||||
|
||||
```
|
||||
qmk doctor [-y] [-n]
|
||||
```
|
||||
|
||||
**示例**:
|
||||
|
||||
检查开发环境中的问题并提示是否修复:
|
||||
|
||||
qmk doctor
|
||||
|
||||
检查开发环境中的问题并自动进行修复:
|
||||
|
||||
qmk doctor -y
|
||||
|
||||
检查开发环境中的问题,仅生成报告:
|
||||
|
||||
qmk doctor -n
|
||||
|
||||
## `qmk format-json`
|
||||
|
||||
将JSON文件格式化为(尽量)便于阅读的形式。会自动分辨JSON结构类型(info.json还是keymap.json),必要时也可以通过 `--format` 指定。
|
||||
|
||||
**用法**:
|
||||
|
||||
```
|
||||
qmk format-json [-f FORMAT] <json_file>
|
||||
```
|
||||
|
||||
## `qmk info`
|
||||
|
||||
展示QMK中的键盘及键映射信息,该命令用来获取键盘信息,输出配列,展示底层按键矩阵,及格式化地输出键映射JSON数据。
|
||||
|
||||
**用法**:
|
||||
|
||||
```
|
||||
qmk info [-f FORMAT] [-m] [-l] [-km KEYMAP] [-kb KEYBOARD]
|
||||
```
|
||||
|
||||
该命令会尝试感知目录路径,当你在键盘或键映射目录下执行时,KEYBOARD及KEYMAP参数将被自动填入。
|
||||
|
||||
**示例**:
|
||||
|
||||
输出键盘的基础信息:
|
||||
|
||||
qmk info -kb planck/rev5
|
||||
|
||||
输出键盘的矩阵信息:
|
||||
|
||||
qmk info -kb ergodox_ez -m
|
||||
|
||||
输出键盘的键映射JSON数据:
|
||||
|
||||
qmk info -kb clueboard/california -km default
|
||||
|
||||
## `qmk json2c`
|
||||
|
||||
从QMK配置器导出的数据中生成 keymap.c 文件
|
||||
Creates a keymap.c from a QMK Configurator export.
|
||||
|
||||
**用法**:
|
||||
|
||||
```
|
||||
qmk json2c [-o OUTPUT] filename
|
||||
```
|
||||
|
||||
## `qmk c2json`
|
||||
|
||||
从 keymap.c 文件中生成 keymap.json
|
||||
**注意:** 解析C代码文件并不容易,该命令有可能无法对你的键映射文件生效,不使用C预处理代码有时可以解决问题。
|
||||
|
||||
**用法**:
|
||||
|
||||
```
|
||||
qmk c2json -km KEYMAP -kb KEYBOARD [-q] [--no-cpp] [-o OUTPUT] filename
|
||||
```
|
||||
|
||||
## `qmk lint`
|
||||
|
||||
检查键盘及键映射数据并提示出常见错误与问题,以及不符合模板规范的地方。
|
||||
|
||||
**用法**:
|
||||
|
||||
```
|
||||
qmk lint [-km KEYMAP] [-kb KEYBOARD] [--strict]
|
||||
```
|
||||
|
||||
该命令会尝试感知目录路径,当你在键盘或键映射目录下执行时,KEYBOARD及KEYMAP参数将被自动填入。
|
||||
|
||||
**示例**:
|
||||
|
||||
基本的lint检查:
|
||||
|
||||
qmk lint -kb rominronin/katana60/rev2
|
||||
|
||||
## `qmk list-keyboards`
|
||||
|
||||
该命令可以列出 `qmk_firmware` 中所有的键盘
|
||||
|
||||
**用法**:
|
||||
|
||||
```
|
||||
qmk list-keyboards
|
||||
```
|
||||
|
||||
## `qmk list-keymaps`
|
||||
|
||||
该命令可以列出指定键盘(及指定版本)下的所有键映射。
|
||||
|
||||
该命令会尝试感知目录路径,当你在键盘或键映射目录下执行时,KEYBOARD及KEYMAP参数将被自动填入。
|
||||
|
||||
**用法**:
|
||||
|
||||
```
|
||||
qmk list-keymaps -kb planck/ez
|
||||
```
|
||||
|
||||
## `qmk new-keyboard`
|
||||
|
||||
该命令可基于现有模板创建出新的键盘定义。
|
||||
|
||||
对于未给出的参数,会提示你输入,若未传入 `-u` 参数且 .gitconfig 中设置了 `user.name`,则会提示你使用该值作为默认用户名。
|
||||
|
||||
**用法**:
|
||||
|
||||
```
|
||||
qmk new-keyboard [-kb KEYBOARD] [-t {avr,ps2avrgb}] -u USERNAME
|
||||
```
|
||||
|
||||
## `qmk new-keymap`
|
||||
|
||||
该命令可基于键盘已有的默认键映射创建新的键映射。
|
||||
|
||||
该命令会尝试感知目录路径,当你在键盘或键映射目录下执行时,KEYBOARD及KEYMAP参数将被自动填入。
|
||||
|
||||
**用法**:
|
||||
|
||||
```
|
||||
qmk new-keymap [-kb KEYBOARD] [-km KEYMAP]
|
||||
```
|
||||
|
||||
## `qmk clean`
|
||||
|
||||
该命令会清理 `.build` 目录,若传入 `--all` 开关,在 `qmk_firmware` 下的所有.hex及.bin文件也会一并删除。
|
||||
|
||||
**用法**:
|
||||
|
||||
```
|
||||
qmk clean [-a]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# 面向开发者的命令
|
||||
|
||||
## `qmk format-text`
|
||||
|
||||
该命令会重新格式化并统一文件的换行符。
|
||||
|
||||
代码库下所有的文件须使用Unix换行符(LF)。
|
||||
若你在**Windows**下进行开发,必须确保文件中的换行符是正确的,才能让你的PR被允许合入。
|
||||
|
||||
```
|
||||
qmk format-text
|
||||
```
|
||||
|
||||
## `qmk format-c`
|
||||
|
||||
该命令会使用clang-format来格式化C代码。
|
||||
|
||||
不带参数地执行该命令以用来格式化核心代码相关的改动,默认会通过 `git diff` 来检查 `origin/master`, 可以通过 `-b <分支名>` 来改变检查的分支。
|
||||
|
||||
带着 `-a` 开关执行命令会格式化所有的核心代码,也可以在命令行中传入文件名来指定格式化某个文件。
|
||||
|
||||
**用以处理指定文件时**:
|
||||
|
||||
```
|
||||
qmk format-c [file1] [file2] [...] [fileN]
|
||||
```
|
||||
|
||||
**用以处理所有的核心代码时**:
|
||||
|
||||
```
|
||||
qmk format-c -a
|
||||
```
|
||||
|
||||
**用以处理 origin/master 下的所有改动时**:
|
||||
|
||||
```
|
||||
qmk format-c
|
||||
```
|
||||
|
||||
**用以处理指定分支下的所有改动时**:
|
||||
|
||||
```
|
||||
qmk format-c -b branch_name
|
||||
```
|
||||
|
||||
## `qmk generate-compilation-database`
|
||||
|
||||
**用法**:
|
||||
|
||||
```
|
||||
qmk generate-compilation-database [-kb KEYBOARD] [-km KEYMAP]
|
||||
```
|
||||
|
||||
创建新 `compile_commands.json` 文件。
|
||||
|
||||
你的IDE/编辑器是否使用了“编程语言本地服务器”(language server)且 _总是_ 无法找到全部的包含文件(include files)?是不是很讨厌红色的波浪线?想不想让你的编辑器看得懂 `#include QMK_KEYBOARD_H`?你需要的是一个[编译数据库](https://clang.llvm.org/docs/JSONCompilationDatabase.html)!而 QMK 可以帮助你构建出一个。
|
||||
|
||||
该命令需要知道你在构建的是哪个键盘及键映射,它使用与 `qmk compile` 命令一样的选项:参数、当前目录以及配置文件。
|
||||
|
||||
**示例:**
|
||||
|
||||
```
|
||||
$ cd ~/qmk_firmware/keyboards/gh60/satan/keymaps/colemak
|
||||
$ qmk generate-compilation-database
|
||||
Ψ Making clean
|
||||
Ψ Gathering build instructions from make -n gh60/satan:colemak
|
||||
Ψ Found 50 compile commands
|
||||
Ψ Writing build database to /Users/you/src/qmk_firmware/compile_commands.json
|
||||
```
|
||||
|
||||
现在可以打开你的开发环境并享受没有波浪线的日子了。
|
||||
|
||||
## `qmk docs`
|
||||
|
||||
该命令会在本地启动一个HTTP服务,从而你可以浏览及改进文档,默认端口号为8936,使用 `-b`/`--browser` 开关可以让该命令自动通过默认浏览器打开链接地址。
|
||||
|
||||
**用法**:
|
||||
|
||||
```
|
||||
qmk docs [-b] [-p PORT]
|
||||
```
|
||||
|
||||
## `qmk generate-docs`
|
||||
|
||||
该命令可以在本地生成QMK文档,用以文档的常规浏览使用,或进行文档改进工作。可以使用类似[serve](https://www.npmjs.com/package/serve)这样的工具来浏览生成的文档文件。
|
||||
|
||||
**用法**:
|
||||
|
||||
```
|
||||
qmk generate-docs
|
||||
```
|
||||
|
||||
## `qmk generate-rgb-breathe-table`
|
||||
|
||||
该命令可以生成用于[RGB灯光](zh-cn/feature_rgblight.md)的呼吸效果的查询表(LUT)头文件。将该文件命名为 `rgblight_breathe_table.h` 并放入键盘或键映射目录下,可以覆盖替换 `quantum/rgblight/` 下的默认LUT。
|
||||
|
||||
**用法**:
|
||||
|
||||
```
|
||||
qmk generate-rgb-breathe-table [-q] [-o OUTPUT] [-m MAX] [-c CENTER]
|
||||
```
|
||||
|
||||
## `qmk kle2json`
|
||||
|
||||
该命令可以将KLE原始数据转换成QMK配置器的JSON数据,可接受的输入可以是文件绝对路径,或当前目录下的文件名。若 `info.json` 文件存在,默认不会进行覆盖,通过指定 `-f` 或 `--force` 开关可以允许覆盖。
|
||||
|
||||
**用法**:
|
||||
|
||||
```
|
||||
qmk kle2json [-f] <filename>
|
||||
```
|
||||
|
||||
**示例**:
|
||||
|
||||
```
|
||||
$ qmk kle2json kle.txt
|
||||
☒ File info.json already exists, use -f or --force to overwrite.
|
||||
```
|
||||
|
||||
```
|
||||
$ qmk kle2json -f kle.txt -f
|
||||
Ψ Wrote out to info.json
|
||||
```
|
||||
|
||||
## `qmk format-python`
|
||||
|
||||
该命令可以对 `qmk_firmware` 下的python代码进行格式化。
|
||||
|
||||
**用法**:
|
||||
|
||||
```
|
||||
qmk format-python
|
||||
```
|
||||
|
||||
## `qmk pytest`
|
||||
|
||||
该命令会执行python测试框架,在你更改了python代码后,应确保该命令可以成功执行。
|
||||
|
||||
**用法**:
|
||||
|
||||
```
|
||||
qmk pytest
|
||||
```
|
||||
|
||||
**示例**:
|
||||
|
||||
执行全部的测试套件:
|
||||
|
||||
qmk pytest
|
||||
|
||||
执行指定的测试用例组:
|
||||
|
||||
qmk pytest -t qmk.tests.test_cli_commands
|
||||
|
||||
执行单个测试用例:
|
||||
|
||||
qmk pytest -t qmk.tests.test_cli_commands.test_c2json
|
||||
qmk pytest -t qmk.tests.test_qmk_path
|
||||
126
docs/zh-cn/cli_configuration.md
Normal file
126
docs/zh-cn/cli_configuration.md
Normal file
@@ -0,0 +1,126 @@
|
||||
# QMK CLI 配置
|
||||
|
||||
<!---
|
||||
original document: 0.15.12:docs/cli_configuration.md
|
||||
git diff 0.15.12 HEAD -- docs/cli_configuration.md | cat
|
||||
-->
|
||||
|
||||
本文详述了 `qmk config` 功能及作用。
|
||||
|
||||
# 介绍
|
||||
|
||||
QMK CLI的配置系统是一套键/值(key/value)数据系统,每个键由一个子指令和一个参数名组成,通过点号(英文句号)分隔。这使得配置项可以简单直接地映射到命令行参数上。
|
||||
|
||||
## 简单示例
|
||||
|
||||
作为一个示例,对于指令 `qmk compile --keyboard clueboard/66/rev4 --keymap default`
|
||||
|
||||
其存在两个命令行参数,可以通过如下方式从配置中读取:
|
||||
|
||||
* `compile.keyboard`
|
||||
* `compile.keymap`
|
||||
|
||||
可以这样设置:
|
||||
|
||||
```
|
||||
$ qmk config compile.keyboard=clueboard/66/rev4 compile.keymap=default
|
||||
compile.keyboard: None -> clueboard/66/rev4
|
||||
compile.keymap: None -> default
|
||||
Ψ Wrote configuration to '/Users/example/Library/Application Support/qmk/qmk.ini'
|
||||
```
|
||||
|
||||
现在每次执行 `qmk compile` 时都不需要指定键盘及键映射参数了。
|
||||
|
||||
## 设置用户级的默认配置
|
||||
|
||||
当你需要在多个命令中使用一致的配置项时,比如很多命令都需要的 `--keyboard` 参数,相比于每次执行命令都去指定该参数值,你可以直接设置用户级的配置值,即可将该配置用于所有的命令。
|
||||
|
||||
示例:
|
||||
|
||||
```
|
||||
$ qmk config user.keyboard=clueboard/66/rev4 user.keymap=default
|
||||
user.keyboard: None -> clueboard/66/rev4
|
||||
user.keymap: None -> default
|
||||
Ψ Wrote configuration to '/Users/example/Library/Application Support/qmk/qmk.ini'
|
||||
```
|
||||
|
||||
# CLI文档 (`qmk config`)
|
||||
|
||||
`qmk config` 命令可以管理配置数据。当不带额外参数执行时,会输出所有已有配置。存在参数时这些参数将被视为配置项参数,其格式须满足如下形式且无空格分隔:
|
||||
|
||||
<subcommand|general|default>[.<key>][=<value>]
|
||||
|
||||
## 设置配置值
|
||||
|
||||
在配置项的键后加 = 号进行值的设置,配置项的键必须是 `<section>.<key>` 的完整形式。
|
||||
|
||||
举例:
|
||||
|
||||
```
|
||||
$ qmk config default.keymap=default
|
||||
default.keymap: None -> default
|
||||
Ψ Wrote configuration to '/Users/example/Library/Application Support/qmk/qmk.ini'
|
||||
```
|
||||
|
||||
## 读取配置值
|
||||
|
||||
可以读取整个配置文件、单独配置键或是一整个配置系列,也可以同时指定读取多个配置项。
|
||||
|
||||
### 全量配置读取示例
|
||||
|
||||
qmk config
|
||||
|
||||
### 单系列配置读取示例
|
||||
|
||||
qmk config compile
|
||||
|
||||
### 单配置项读取示例
|
||||
|
||||
qmk config compile.keyboard
|
||||
|
||||
### 多配置项读取示例
|
||||
|
||||
qmk config user compile.keyboard compile.keymap
|
||||
|
||||
## 删除配置值
|
||||
|
||||
将配置值设置为 `None` 即可删除该配置值。
|
||||
|
||||
示例:
|
||||
|
||||
```
|
||||
$ qmk config default.keymap=None
|
||||
default.keymap: default -> None
|
||||
Ψ Wrote configuration to '/Users/example/Library/Application Support/qmk/qmk.ini'
|
||||
```
|
||||
|
||||
## 批量操作
|
||||
|
||||
一个指令中可以合并执行多个读写操作,将依序进行执行输出:
|
||||
|
||||
```
|
||||
$ qmk config compile default.keymap=default compile.keymap=None
|
||||
compile.keymap=skully
|
||||
compile.keyboard=clueboard/66_hotswap/gen1
|
||||
default.keymap: None -> default
|
||||
compile.keymap: skully -> None
|
||||
Ψ Wrote configuration to '/Users/example/Library/Application Support/qmk/qmk.ini'
|
||||
```
|
||||
|
||||
# 用户配置相关的配置项
|
||||
|
||||
| 配置项 | 默认值 | 描述 |
|
||||
|-------|-------|------|
|
||||
| user.keyboard | None | 键盘路径(举例:`clueboard/66/rev4`) |
|
||||
| user.keymap | None | 键盘名称(举例:`default`) |
|
||||
| user.name | None | 用户的Github用户名 |
|
||||
|
||||
# 所有配置项
|
||||
|
||||
| 配置项 | 默认值 | 描述 |
|
||||
|-------|-------|------|
|
||||
| compile.keyboard | None | 键盘路径(举例:`clueboard/66/rev4`) |
|
||||
| compile.keymap | None | 键盘名称(举例:`default`) |
|
||||
| hello.name | None | 执行时展示的欢迎信息 |
|
||||
| new_keyboard.keyboard | None | 键盘路径(举例:`clueboard/66/rev4`) |
|
||||
| new_keyboard.keymap | None | 键盘名称(举例:`default`) |
|
||||
32
docs/zh-cn/cli_tab_complete.md
Normal file
32
docs/zh-cn/cli_tab_complete.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# QMK Tab补全
|
||||
|
||||
<!---
|
||||
original document: 0.15.12:docs/cli_tab_complete.md
|
||||
git diff 0.15.12 HEAD -- docs/cli_tab_complete.md | cat
|
||||
-->
|
||||
|
||||
在使用Bash 4.2及更高版本、Zsh或FiSH时,可以启用QMK CLI的Tab补全功能,可以实现对 `qmk` 参数中的开关、键盘、文件等参数的自动补全。
|
||||
|
||||
## 设置
|
||||
|
||||
有以下几种启用Tab补全的方法。
|
||||
|
||||
### 仅当前用户生效
|
||||
|
||||
将以下内容添加到文件 `.profile` 或 `.bashrc` 的末尾:
|
||||
|
||||
source ~/qmk_firmware/util/qmk_tab_complete.sh
|
||||
|
||||
若你的 `qmk_firmware` 存放在其它路径,以上路径也需要调整。
|
||||
|
||||
### 系统级的符号关联
|
||||
|
||||
若想让所有本地用户都可以实现Tab补全,可以按如下方法添加符号连接到 `qmk_tab_complete.sh` 脚本:
|
||||
|
||||
`ln -s ~/qmk_firmware/util/qmk_tab_complete.sh /etc/profile.d/qmk_tab_complete.sh`
|
||||
|
||||
### 系统级的脚本拷贝
|
||||
|
||||
有时符号连接的方案无效,可以改用拷贝文件到指定位置的方案。但须留意该Tab补全脚本可能会不定时更新,你需要定期重新拷贝一次该脚本。
|
||||
|
||||
cp util/qmk_tab_complete.sh /etc/profile.d
|
||||
66
docs/zh-cn/configurator_architecture.md
Normal file
66
docs/zh-cn/configurator_architecture.md
Normal file
@@ -0,0 +1,66 @@
|
||||
# QMK配置器框架
|
||||
|
||||
<!---
|
||||
original document: 0.15.12:docs/configurator_architecture.md
|
||||
git diff 0.15.12 HEAD -- docs/configurator_architecture.md | cat
|
||||
-->
|
||||
|
||||
本章节提供了QMK配置器前端技术框架信息,若你对QMK配置器前端工程本身感兴趣,可以从[QMK配置器](https://github.com/qmk/qmk_configurator)代码库开始。
|
||||
|
||||
# 总览
|
||||
|
||||

|
||||
|
||||
# 详述
|
||||
|
||||
QMK配置器基于[单页面框架](https://en.wikipedia.org/wiki/Single-page_application)实现,供使用者创建兼容QMK键盘的自定义键映射方案。键映射方案可以导出为JSON格式的数据,也可以编译出可通过[QMK工具箱](https://github.com/qmk/qmk_toolbox)刷写到键盘中的固件文件。
|
||||
|
||||
配置器从“键盘元数据仓库(Keyboard Metadata store)”获取键盘元数据,编译请求通过QMK API提交,编译产出放在S3兼容的数据仓库[Digital Ocean空间](https://www.digitalocean.com/products/spaces/)中。
|
||||
|
||||
## 配置器前端
|
||||
|
||||
地址:<https://config.qmk.fm>
|
||||
|
||||
[配置器前端](https://config.qmk.fm)会编译并产出一些静态文件并通过Github Pages托管,每当[QMK配置器 `master`](https://github.com/qmk/qmk_configurator)分支收到推送的提交时都会触发。可以通过[QMK配置器 actions页面](https://github.com/qmk/qmk_configurator/actions/workflows/build.yml)查看这些job的状态。
|
||||
|
||||
## 键盘元数据
|
||||
|
||||
地址:<https://keyboards.qmk.fm>
|
||||
|
||||
每当[qmk_firmware](https://github.com/qmk/qmk_firmware)仓库中的键盘定义变化时,会生成JSON格式的键盘元数据,并上传到指定空间用于配置器生成每种键盘的UI展现。可以在[QMK固件 actions页面](https://github.com/qmk/qmk_firmware/actions/workflows/api.yml)查看相关job的状态。如果你是QMK开发团队成员(Collaborator),可以使用 `workflow_dispatch` 事件触发器来手动执行该job。
|
||||
|
||||
## QMK API
|
||||
|
||||
地址:<http://api.qmk.fm>
|
||||
|
||||
QMK API接受 `keymap.json` 文件输入并进行编译,这和你在 `qmk compile` 和 `qmk flash` 中使用的文件一样。当 `keymap.json` 文件被提交后,浏览器中的页面将定时查看job状态(每2秒一次,有时更久一些)直到job完成。最终产出的JSON描述信息里包含了键映射方案的源文件,及编译出的二进制的可下载链接地址。
|
||||
|
||||
为遵循GPL协议,QMK API会确保源文件及编译产出总是同时提供的。
|
||||
|
||||
API有3种非异常的回应状态-
|
||||
|
||||
1. 编译job排队中
|
||||
2. 编译job执行中
|
||||
3. 编译job已完成
|
||||
|
||||
### 编译job排队中
|
||||
|
||||
此状态表明[QMK编译器](#QMK编译器)节点还未选中该job,在配置器页面此时会显示“等待一个可用的烤炉(Waiting for an oven)”。
|
||||
|
||||
### 编译job执行中
|
||||
|
||||
此状态说明编译job已经在执行中,配置器页面会显示为“烤制中”(Baking)。
|
||||
|
||||
### 编译job已完成
|
||||
|
||||
此状态说明编译job已经执行完毕,输出的JSON格式的状态信息里有源文件及编译产出的二进制文件的下载链接项。
|
||||
|
||||
## Redis/RQ
|
||||
|
||||
QMK API通过Redis队列分发job到可用的[QMK编译器](#QMK编译器)节点。接收到的 `keymap.json` 文件先送到RQ队列,而 `qmk_compiler` 节点则从中拉取执行。
|
||||
|
||||
## QMK编译器
|
||||
|
||||
[QMK编译器](https://github.com/qmk/qmk_compiler)负责执行 `keymap.json` 文件的实际编译工作。它的工作逻辑是先拉取有请求的 `qmk_firmware` 分支代码,执行 `qmk compile keymap.json`,最后上传源文件及二进制产出到Digital Ocean空间中。
|
||||
|
||||
当用户需要下载源代码/二进制文件时,API会给出重定向后的已鉴权地址链接。
|
||||
198
docs/zh-cn/configurator_default_keymaps.md
Normal file
198
docs/zh-cn/configurator_default_keymaps.md
Normal file
@@ -0,0 +1,198 @@
|
||||
# 向QMK配置器中添加默认键映射 :id=adding-default-keymaps
|
||||
|
||||
<!---
|
||||
original document: 0.15.12:docs/configurator_default_keymaps.md
|
||||
git diff 0.15.12 HEAD -- docs/configurator_default_keymaps.md | cat
|
||||
-->
|
||||
|
||||
本章节描述了如何向QMK配置器中添加一款键盘的默认键映射
|
||||
|
||||
|
||||
## 技术信息 :id=technical-information
|
||||
|
||||
QMK配置器使用JSON作为键映射的本地文件格式。我们尽力确保其行为与在 `qmk_firmware` 中 执行 `make <keyboard>:default` 时一致。
|
||||
|
||||
该目录下的键映射需要定义四个键值对:
|
||||
|
||||
* `keyboard` (字符串)
|
||||
* 键盘名称,与执行 `make` 进行编译时使用的一致(如 `make 1upkeyboards/1up60rgb:default`)。
|
||||
* `keymap` (字符串)
|
||||
* 应设置为 `default`.
|
||||
* `layout` (字符串)
|
||||
* 默认键映射应使用的配列宏定义。
|
||||
* `layers` (数组)
|
||||
* 键映射数据。此键下的每行元素对应一个层定义,层定义中包含该层的键码组成信息。
|
||||
|
||||
额外地,大部分键映射中还有一个 `commit` 项,该项并不是QMK配置器后端服务API所需,而是用于告知配置器维护者这份JSON键映射数据来源于代码库中的哪个版本的键映射。该值为 `qmk_firmware` 代码库中最后一次修改键盘默认 `keymap.c` 文件提交的commit的SHA标记。该SHA值的获取方式是拉取[`qmk/qmk_firmware` 库的 `master`分支](https://github.com/qmk/qmk_firmware/tree/master/)后,执行 `git log -1 --pretty=oneline -- keyboards/<keyboard>/keymaps/default/keymap.c`(若键盘有什么问题且存在 `keymap.json` 文件,则用之作为替代),执行结果应类似于:
|
||||
|
||||
```
|
||||
f14629ed1cd7c7ec9089604d64f29a99981558e8 Remove/migrate action_get_macro()s from default keymaps (#5625)
|
||||
```
|
||||
|
||||
本例中,`f14629ed1cd7c7ec9089604d64f29a99981558e8` 即应为 `commit` 的值。
|
||||
|
||||
|
||||
## 示例 :id=example
|
||||
|
||||
若某人想添加H87a Hineybush键盘的默认键映射方案,应到 `qmk_firmware` 下H87a的默认键映射下执行上述 `git log` 命令:
|
||||
|
||||
```
|
||||
user ~/qmk_firmware (master)
|
||||
$ git log -1 --pretty=oneline master -- keyboards/hineybush/h87a/keymaps/default/keymap.c
|
||||
ef8878fba5d3786e3f9c66436da63a560cd36ac9 Hineybush h87a lock indicators (#8237)
|
||||
```
|
||||
|
||||
在我们获取了commit哈希值后,还需要键映射定义(为加强可读性进行了编辑处理):
|
||||
|
||||
```c
|
||||
...
|
||||
#include QMK_KEYBOARD_H
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
[0] = LAYOUT_all(
|
||||
KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR, KC_SLCK, KC_PAUS,
|
||||
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_BSPC, KC_INS, KC_HOME, KC_PGUP,
|
||||
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_NUHS, KC_ENT,
|
||||
KC_LSFT, KC_NUBS, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_TRNS, KC_UP,
|
||||
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(1), KC_RGUI, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),
|
||||
|
||||
[1] = LAYOUT_all(
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_TOG, RGB_MOD, RGB_HUD, RGB_HUI, RGB_SAD, RGB_SAI, RGB_VAD, RGB_VAI, BL_TOGG, BL_DEC, BL_INC,
|
||||
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_VOLU,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RESET, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPLY, KC_MNXT, KC_VOLD,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
|
||||
|
||||
};
|
||||
```
|
||||
|
||||
默认键映射使用了 `LAYOUT_all` 宏,最后其会成为 `layout` 项的值。编译为QMK配置器的JSON键映射数据后,输出文件应为:
|
||||
|
||||
```json
|
||||
{
|
||||
"keyboard": "hineybush/h87a",
|
||||
"keymap": "default",
|
||||
"commit": "ef8878fba5d3786e3f9c66436da63a560cd36ac9",
|
||||
"layout": "LAYOUT_all",
|
||||
"layers": [
|
||||
[
|
||||
"KC_ESC", "KC_F1", "KC_F2", "KC_F3", "KC_F4", "KC_F5", "KC_F6", "KC_F7", "KC_F8", "KC_F9", "KC_F10", "KC_F11", "KC_F12", "KC_PSCR", "KC_SLCK", "KC_PAUS",
|
||||
"KC_GRV", "KC_1", "KC_2", "KC_3", "KC_4", "KC_5", "KC_6", "KC_7", "KC_8", "KC_9", "KC_0", "KC_MINS", "KC_EQL", "KC_BSPC", "KC_BSPC", "KC_INS", "KC_HOME", "KC_PGUP",
|
||||
"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_NUHS", "KC_ENT",
|
||||
"KC_LSFT", "KC_NUBS", "KC_Z", "KC_X", "KC_C", "KC_V", "KC_B", "KC_N", "KC_M", "KC_COMM", "KC_DOT", "KC_SLSH", "KC_RSFT", "KC_TRNS", "KC_UP",
|
||||
"KC_LCTL", "KC_LGUI", "KC_LALT", "KC_SPC", "KC_RALT", "MO(1)", "KC_RGUI", "KC_RCTL", "KC_LEFT", "KC_DOWN", "KC_RGHT"
|
||||
],
|
||||
[
|
||||
"KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "RGB_TOG", "RGB_MOD", "RGB_HUD", "RGB_HUI", "RGB_SAD", "RGB_SAI", "RGB_VAD", "RGB_VAI", "BL_TOGG", "BL_DEC", "BL_INC",
|
||||
"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_VOLU",
|
||||
"KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "RESET", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_MPLY", "KC_MNXT", "KC_VOLD",
|
||||
"KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS",
|
||||
"KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS",
|
||||
"KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS", "KC_TRNS"
|
||||
]
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
`layers` 数组中的空白区域不影响键映射功能,仅为了方便阅读。
|
||||
|
||||
|
||||
## 附加说明 :id=caveats
|
||||
|
||||
### 层定义只能通过序号进行引用 :id=layer-references
|
||||
|
||||
QMK中常见的一种做法是通过一系列 `#define` 或 `enum` 类型声明来对层定义进行命名:
|
||||
|
||||
```c
|
||||
enum layer_names {
|
||||
_BASE,
|
||||
_MEDIA,
|
||||
_FN
|
||||
};
|
||||
```
|
||||
|
||||
对于C代码来讲可行,但对于配置器来讲,你*必须*使用层序号 - 上例中的`MO(_FN)` 应使用 `MO(2)`。
|
||||
|
||||
### 不支持任何形式的定制化代码 :id=custom-code
|
||||
|
||||
需要在 keymap.c 文件中添加函数代码的功能,如Tap Dance或是Unicode,都*完全*无法在配置器中构建。即便是在 `qmk_firmware` 代码库中在键盘定义中设置了 `TAP_DANCE_ENABLE = yes`,也只会导致*任何*固件构建在配置器中行不通。这是由API及JSON格式的键映射数据同时造成的限制。
|
||||
|
||||
### 对自定义键码的不完全支持 :id=custom-keycodes
|
||||
|
||||
仅有一个方案可以支持自定义键码:若自定义键码的逻辑实现是在 qmk_firmware 下的键盘定义中完成的,而非在键映射中,那么这个键码*可以*在配置器中使用且*可以*编译运行。(因此,)相对于在 `keymap.c` 中使用如下代码段:
|
||||
|
||||
```c
|
||||
enum custom_keycodes {
|
||||
MACRO_1 = SAFE_RANGE,
|
||||
MACRO_2,
|
||||
MACRO_3
|
||||
};
|
||||
...
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
switch(keycode) {
|
||||
case MACRO_1:
|
||||
if (record->event.pressed) {
|
||||
SEND_STRING("This is macro #1.");
|
||||
}
|
||||
return false;
|
||||
case MACRO_2:
|
||||
if (record->event.pressed) {
|
||||
SEND_STRING("This is macro #2.");
|
||||
}
|
||||
return false;
|
||||
case MACRO_3:
|
||||
if (record->event.pressed) {
|
||||
SEND_STRING("This is macro #3.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
```
|
||||
|
||||
... 请将键码的 `enum` 定义块添加到键盘的头文件(`<keyboard.h>`)中,例如(留意 `enum` 在这里命名为 `keyboard_keycodes`):
|
||||
|
||||
```c
|
||||
enum keyboard_keycodes {
|
||||
MACRO_1 = SAFE_RANGE,
|
||||
MACRO_2,
|
||||
MACRO_3,
|
||||
NEW_SAFE_RANGE // 重要!
|
||||
};
|
||||
```
|
||||
|
||||
... 之后在 `<keyboard>.c` 中的 `process_record_kb()` 代码逻辑应为:
|
||||
|
||||
```c
|
||||
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
||||
switch(keycode) {
|
||||
case MACRO_1:
|
||||
if (record->event.pressed) {
|
||||
SEND_STRING("This is macro #1.");
|
||||
}
|
||||
return false;
|
||||
case MACRO_2:
|
||||
if (record->event.pressed) {
|
||||
SEND_STRING("This is macro #2.");
|
||||
}
|
||||
return false;
|
||||
case MACRO_3:
|
||||
if (record->event.pressed) {
|
||||
SEND_STRING("This is macro #3.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return process_record_user(keycode, record);
|
||||
};
|
||||
```
|
||||
|
||||
注意最后的 `process_record_user()` 调用,若用户需要添加自定义键码到键映射中,须使用 `NEW_SAFE_RANGE` 替代 `SAFE_RANGE`,而其定义来自于上面键盘层定义中。
|
||||
|
||||
|
||||
## 更多资料 :id=additional-reading
|
||||
|
||||
为了让QMK配置器支持你的键盘,你的键盘定义必须存在于 `qmk_firmware` 代码库的 `master` 分支中。相关操作指引,请参见[在QMK配置器中支持你的键盘](zh-cn/reference_configurator_support.md).
|
||||
63
docs/zh-cn/configurator_step_by_step.md
Normal file
63
docs/zh-cn/configurator_step_by_step.md
Normal file
@@ -0,0 +1,63 @@
|
||||
# QMK 配置器: 入门
|
||||
|
||||
<!---
|
||||
original document: 0.15.12:docs/configurator_step_by_step.md
|
||||
git diff 0.15.12 HEAD -- docs/configurator_step_by_step.md | cat
|
||||
-->
|
||||
|
||||
本章节描述了如何使用QMK配置器构建出固件文件的过程。
|
||||
|
||||
## 第一步:选择键盘
|
||||
|
||||
从下拉列表中选择一款用于创建键映射的键盘。
|
||||
|
||||
?> 当键盘有多个版本可选择时,请确保选择正确。
|
||||
|
||||
因为很重要,这里我再次说一遍:
|
||||
|
||||
!> **请选择正确的版本!**
|
||||
|
||||
如果你的键盘声称是基于QMK的但未在列表中,可能是开发者还未提交给我们,或者提交还未被合并进来。若在[Pull Request](https://github.com/qmk/qmk_firmware/pulls?q=is%3Aopen+is%3Apr+label%3Akeyboard)中没有找到请求支持该键盘的issue,请到[QMK固件](https://github.com/qmk/qmk_firmware/issues)提交一个issue。也有一些基于QMK的键盘是由制造商自己的GitHub账号在维护着,请也确认一下。 <!-- FIXME(skullydazed): This feels too wordy and I'm not sure we want to encourage these kinds of issues. Also, should we prompt them to bug the manufacutrer? -->
|
||||
|
||||
## 第二部:选择键盘配列
|
||||
|
||||
选择最适合你要创建的键映射的配列,一些键盘的配列不完整或有问题,后续会逐渐支持。
|
||||
|
||||
!> 有时会遇到没有特别适合的配列的情况,请选择 `LAYOUT_all`。
|
||||
|
||||
## 第三步:命名你的键映射
|
||||
|
||||
如何起名完全取决于你。
|
||||
|
||||
?> 如果编译时遇到了问题,可能是因为QMK固件代码库中已经有了同名项,可以尝试改一下名字。
|
||||
|
||||
## 第四步:设计你的键映射
|
||||
|
||||
以下三种方法可以添加键码:
|
||||
|
||||
1. 拖拽
|
||||
2. 点击布局上的空白项,再点击所需的键码
|
||||
3. 点击布局上的空白项, 再点击你物理键盘上的按键
|
||||
|
||||
?> 鼠标在键上悬停时会有一个键码值的提示出现,详细描述信息请参见:
|
||||
|
||||
* [基础键码资料](zh-cn/keycodes_basic.md)
|
||||
* [进阶键码资料](zh-cn/feature_advanced_keycodes.md)
|
||||
|
||||
!> 如果你选择的配列与物理实机有出入,请将不需要的按键留空。如果不清楚应该用哪个键,例如,你只需要一个退格键,但 `LAYOUT_all` 中有两个退格键,须将两个键都放上一样的键码。
|
||||
|
||||
## 第五步:保存键映射留待后续修订
|
||||
|
||||
当你调整完毕键映射方案,或打算以后继续编辑,点击 `导出Keymap JSON文件(Download this QMK Keymap JSON File)` 按钮,当前键映射方案将保存到你的计算机中,之后可以点击 `导入Keymap JSON文件(Upload a QMK Keymap JSON File)` 按钮导入后继续编辑。
|
||||
|
||||
!> **注意:** 导出的.json文件与 kbfirmware.com 和其它工具软件生成的并不兼容,如果你将导出的数据放到那些工具中,或尝试导入那些工具生成的.json文件,是不可行的。
|
||||
|
||||
## 第六步:编译固件
|
||||
|
||||
点击绿色的 `编译(Compile)` 按钮。
|
||||
|
||||
编译完成后,可以点击绿色的 `固件(Download Firmware)` 下载固件文件。
|
||||
|
||||
## 下一步:刷写到键盘中
|
||||
|
||||
参见[刷写固件](zh-cn/newbs_flashing.md).
|
||||
31
docs/zh-cn/configurator_troubleshooting.md
Normal file
31
docs/zh-cn/configurator_troubleshooting.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# 配置器问题排查
|
||||
|
||||
<!---
|
||||
original document: 0.15.12:docs/configurator_troubleshooting.md
|
||||
git diff 0.15.12 HEAD -- docs/configurator_troubleshooting.md | cat
|
||||
-->
|
||||
|
||||
## 我的 .json 文件不可用
|
||||
|
||||
如果该 .json 文件确实是QMK配置器中导出的,恭喜你遇到bug了,请在[QMK配置器](https://github.com/qmk/qmk_configurator/issues)库中提交一个issue。
|
||||
|
||||
如果不是……那么页面顶部加大加粗的提示让你不要使用其它 .json 文件,你是怎么错过的?
|
||||
|
||||
## 我的配列中有好多空格键,我应该怎么处理?
|
||||
|
||||
如果你是说有三个空格键栏,最好的做法是都放上空格键。这个处理方案也适用于退格键和Shift键。
|
||||
|
||||
## 用于...的键码是什么?
|
||||
|
||||
参见:
|
||||
|
||||
* [基础键码资料](zh-cn/keycodes_basic.md)
|
||||
* [进阶键码资料](zh-cn/feature_advanced_keycodes.md)
|
||||
|
||||
## 无法编译
|
||||
|
||||
请检查键映射中所有的层,确保没有随机(random)键。
|
||||
|
||||
## Bug及其它问题
|
||||
|
||||
我们很乐意倾听你的需求及bug报告,请到[QMK配置器](https://github.com/qmk/qmk_configurator/issues)代码库中提交吧。
|
||||
102
docs/zh-cn/driver_installation_zadig.md
Normal file
102
docs/zh-cn/driver_installation_zadig.md
Normal file
@@ -0,0 +1,102 @@
|
||||
# 利用Zadig安装Bootloader驱动
|
||||
|
||||
<!---
|
||||
original document: 0.15.12:docs/driver_installation_zadig.md
|
||||
git diff 0.15.12 HEAD -- docs/driver_installation_zadig.md | cat
|
||||
-->
|
||||
|
||||
QMK在主机侧会展现为一台HID键盘设备,因此不需要额外的驱动。但若要在Windows下刷写键盘固件,重置主控板时出现的bootloader设备则通常需要一些驱动程序。
|
||||
|
||||
已知的特例有两个:常见于Pro Micro的Caterina bootloader,以及PJRC Teensys上的HalfKay bootloader, 会同时提供一个串行端口设备及一个HID设备,因此不需要额外的驱动。
|
||||
|
||||
这里我们推荐使用[Zadig](https://zadig.akeo.ie/)工具软件。若你在MSYS2中配置了开发环境,`qmk_install.sh` 脚本已经替你安装了相关驱动。
|
||||
|
||||
## 安装
|
||||
|
||||
将键盘重置为bootloader模式,点击 `RESET` 键码(可能在别的层中),或按一下通常在主控板背面上的重置开关,如果你的键盘上没有前两者,尝试在按住Esc键或空格+`B`键时插上键盘(更多信息参见[Bootmagic](zh-cn/feature_bootmagic.md))。有些键盘使用[指令](zh-cn/feature_command.md)功能来代替Bootmagic,这种情况下,可以在键盘插入状态下点击 左Shift+右Shift+`B` 或 左Shift+右Shift+Esc组合键来进入bootloader模式。
|
||||
也有一些键盘需要特别的操作才能进入bootloader状态。例如,[Bootmagic](zh-cn/feature_bootmagic.md)键(默认为:Esc键)在其它键上,比如左Control;或是指令组合键(默认为:左Shift+右Shift)为其它组合,如左Control+右Control。当不确定的时候,可以查阅一下主控板的README文件。
|
||||
|
||||
若要将USBaspLoader设备置为bootloader模式,请在按住 `BOOT` 按钮时点击 `RESET` 按钮,或是在按住 `BOOT` 按钮时插入USB线缆。
|
||||
|
||||
Zadig可以自动检测到bootloader设备,但有时你需要在 **Options(选项) → List All Devices(列出所有设备)** 的下拉列表中选择正确的设备。
|
||||
|
||||
!> 如果Zadig中列出的一个或多个设备为 `HidUsb` 驱动的,那么你的键盘应该没有进入bootloader模式,此时箭头会标记成橙色并会询问你确认是否要修改系统驱动,此时**不要**允许该操作。
|
||||
|
||||
如果箭头呈现绿色,选择所需的驱动,点击**Install Driver(安装驱动)**。如何选择正确的驱动进行安装请参见[已知驱动列表](#list-of-known-bootloaders)。
|
||||
|
||||

|
||||
|
||||
最后,重新拔插一次键盘,确认驱动可以正常加载。如果你在使用QMK工具箱进行刷写,记得也重启一下,因为有时它不会检测到驱动的变化。
|
||||
|
||||
## 从错误的驱动安装中恢复
|
||||
|
||||
如果你发现键盘无法输入了,应当是因为错误地替换了键盘本身的驱动,而不是bootloader的驱动,你的键盘没有进入bootloader模式就进行安装时就会遇到这个问题。在Zadig中很容易看出这个问题 - 正常的键盘在其所有的接口上都应该有 `HidUsb` 驱动:
|
||||
|
||||

|
||||
|
||||
打开Device Manager(设备管理器),选择**View(查看) → Devices by container(依类型排序设备)**,并定位到你键盘名所在的节点。
|
||||
|
||||

|
||||
|
||||
在这些节点上右键,选择**Uninstall device(卸载)**。如果出现了**Delete the driver software for this device(同时卸载该设备驱动文件)**也请勾选上。
|
||||
|
||||

|
||||
|
||||
点击 **Action(操作) → Scan for hardware changes(扫描检测硬件改动)**。此时,键盘应该恢复可用状态了。再确认一下Zadig中键盘是否在使用 `HidUsb` 驱动,如果是,键盘即完全恢复可用状态了,如果不是,重复这一步直到Zadig中报告了正确的驱动。
|
||||
|
||||
?> 在这一步有时需要重启电脑,以便Windows可以选用新驱动文件。
|
||||
|
||||
## 卸载
|
||||
|
||||
卸载bootloadeer设备要比安装过程复杂一些。
|
||||
|
||||
打开设备管理器,选择**查看 → 依类型排序设备**,并找到bootloader设备,寻找USB VID和PID与Zadig的[该表格](#list-of-known-bootloaders)中一致的项。
|
||||
|
||||
在设备属性的详细信息tab中,找到 `Inf name(INF名称)` 值,通常该值类似于 `oemXX.inf`:
|
||||
|
||||

|
||||
|
||||
之后使用管理员权限打开一个命令行窗口(在开始菜单处输出 `cmd` 并点击Ctrl+Shift+回车)。执行 `pnputil /enum-drivers` 并找到 `INF名称` 与 `Published Name(发布名称)` 一致的项:
|
||||
|
||||

|
||||
|
||||
执行 `pnputil /delete-driver oemXX.inf /uninstall`,之后该驱动会被删除,相关设备也不再使用该驱动,但设备是不会被移除的。
|
||||
|
||||
与上一节相似,本流程也可能需要执行多次,因为一个设备可能会有多个可用的驱动。
|
||||
|
||||
!> **警告:** 操作过程中*务必非常小心*!以免不小心卸载掉其它关键驱动。如果你对操作不是很确定,多次检查 `/enum-drivers`的输出信息,也可以考虑执行 `/delete-driver` 时不添加 `/uninstall` 开关\。
|
||||
|
||||
## 已知驱动列表 :id=list-of-known-bootloaders
|
||||
|
||||
该表列出了已知的bootloader设备及其USB VID(厂商ID)和PID(产品ID),以及可用于QMK刷写固件的驱动。留意usbser及HidUsb驱动是随Windows附带的,无法通过Zadig安装 - 如果你的设备驱动不符,请参照上节来卸载这些驱动。
|
||||
|
||||
此处列出的设备名应与Zadig中的一致,但不一定与设备管理器及QMK工具箱展示的一致。
|
||||
|
||||
|Bootloader |设备名 |VID/PID |驱动 |
|
||||
|--------------|------------------------------|--------------|-------|
|
||||
|`atmel-dfu` |ATmega16u2 DFU |`03EB:2FEF` |libusb0|
|
||||
|`atmel-dfu` |ATmega32U2 DFU |`03EB:2FF0` |libusb0|
|
||||
|`atmel-dfu` |ATm16U4 DFU V1.0.2 |`03EB:2FF3` |libusb0|
|
||||
|`atmel-dfu` |ATm32U4DFU |`03EB:2FF4` |libusb0|
|
||||
|`atmel-dfu` |*none* (AT90USB64) |`03EB:2FF9` |libusb0|
|
||||
|`atmel-dfu` |AT90USB128 DFU |`03EB:2FFB` |libusb0|
|
||||
|`qmk-dfu` |(键盘名) Bootloader |同`atmel-dfu` |libusb0|
|
||||
|`halfkay` |*none* |`16C0:0478` |HidUsb |
|
||||
|`caterina` |Pro Micro 3.3V |`1B4F:9203` |usbser |
|
||||
|`caterina` |Pro Micro 5V |`1B4F:9205` |usbser |
|
||||
|`caterina` |LilyPadUSB |`1B4F:9207` |usbser |
|
||||
|`caterina` |Pololu A-Star 32U4 Bootloader |`1FFB:0101` |usbser |
|
||||
|`caterina` |Arduino Leonardo |`2341:0036` |usbser |
|
||||
|`caterina` |Arduino Micro |`2341:0037` |usbser |
|
||||
|`caterina` |Adafruit Feather 32u4 |`239A:000C` |usbser |
|
||||
|`caterina` |Adafruit ItsyBitsy 32u4 3V |`239A:000D` |usbser |
|
||||
|`caterina` |Adafruit ItsyBitsy 32u4 5V |`239A:000E` |usbser |
|
||||
|`caterina` |Arduino Leonardo |`2A03:0036` |usbser |
|
||||
|`caterina` |Arduino Micro |`2A03:0037` |usbser |
|
||||
|`bootloadhid` |HIDBoot |`16C0:05DF` |HidUsb |
|
||||
|`usbasploader`|USBasp |`16C0:05DC` |libusbK|
|
||||
|`apm32-dfu` |APM32 DFU ISP Mode |`314B:0106` |WinUSB |
|
||||
|`stm32-dfu` |STM32 BOOTLOADER |`0483:DF11` |WinUSB |
|
||||
|`kiibohd` |Kiibohd DFU Bootloader |`1C11:B007` |WinUSB |
|
||||
|`stm32duino` |Maple 003 |`1EAF:0003` |WinUSB |
|
||||
|`qmk-hid` |(键盘名) Bootloader |`03EB:2067` |HidUsb |
|
||||
37
docs/zh-cn/easy_maker.md
Normal file
37
docs/zh-cn/easy_maker.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# 极简式制作 - 通过配置器进行一次性的工程构建
|
||||
|
||||
<!---
|
||||
original document: 0.15.12:docs/easy_maker.md
|
||||
git diff 0.15.12 HEAD -- docs/easy_maker.md | cat
|
||||
-->
|
||||
|
||||
你是否需要一种极简的控制器编程方案,类似Proton C或Teensy 2.0,以进行一次性的工程构建?QMK提供了极简制作器,通过QMK配置器可以在几分钟内制作一个固件。
|
||||
|
||||
有几种极简制作器,取决于你需要什么样的:
|
||||
|
||||
* [引脚直连](https://config.qmk.fm/#/?filter=ez_maker/direct) - 将每个开关独立直连到一个引脚
|
||||
* 引脚直连 + 背光 (即将可用) - 类似引脚直连,单独加一个引脚连接到[背光](zh-cn/feature_backlight.md)控制器上
|
||||
* 引脚直连 + 小键盘锁 (即将可用) - 类似引脚直连,单独加一个引脚连接到Numlock LED上
|
||||
* 引脚直连 + 大写锁 (即将可用) - 类似引脚直连, 单独加一个引脚连接到Capslock LED上
|
||||
* 引脚直连 + 编码器 (即将可用) - 类似引脚直连, 再加两个引脚用于连接一个旋钮编码器
|
||||
|
||||
## 快速指引
|
||||
|
||||
最简单的情况是使用一个引脚直连的主控板,将每个引脚连接到一个开关,另一端再接地即可,从以下键盘列表中可以选择一款支持的MCU:
|
||||
|
||||
* <https://config.qmk.fm/#/?filter=ez_maker/direct>
|
||||
|
||||
更多信息请参见[引脚直连](#direct-pin)一节。
|
||||
|
||||
# 引脚直连 :id=direct-pin
|
||||
|
||||
与其名字表意相同,它的原理是一个引脚连接一个开关,每个开关的另一端接地(VSS或GND),不需要额外的部件,通常MCU内部自带上拉电阻,因此可以感知开关动作。
|
||||
|
||||
|
||||
这里有一个示意图,展示了如何将一个按钮连接到ProMicro的A3引脚上:
|
||||
|
||||

|
||||
|
||||
在开关连接到各自的引脚后,在键盘下拉列表中选择所使用的MCU,将键码指定到对应的引脚上即可构建出固件。以下链接仅展示支持引脚直连的极简式制作:
|
||||
|
||||
* <https://config.qmk.fm/#/?filter=ez_maker/direct>
|
||||
108
docs/zh-cn/faq_misc.md
Normal file
108
docs/zh-cn/faq_misc.md
Normal file
@@ -0,0 +1,108 @@
|
||||
# 其它 FAQ
|
||||
|
||||
<!---
|
||||
original document: 0.15.12:docs/faq_misc.md
|
||||
git diff 0.15.12 HEAD -- docs/faq_misc.md | cat
|
||||
-->
|
||||
|
||||
## 怎么对键盘进行测试? :id=testing
|
||||
|
||||
测试键盘就简单直接,把每个按键按一遍后确认发送的是正确的就行。也可以使用[QMK配置器](https://config.qmk.fm/#/test/)的测试模式检查键盘,即便这键盘没有运行着QMK。
|
||||
|
||||
## 安全措施
|
||||
|
||||
你应该不想见到键盘变砖,变得不能再刷写固件。这里给出了一些非常危险(或相反不太危险)的因素。
|
||||
|
||||
- 如果你的键盘没有RESET键,在你需要进入DFU模式时,不得不需要用螺丝刀打开后盖去按PCB上的RESET键。
|
||||
- 把 tmk_core/common 下的文件搞乱的话,容易导致键盘无法使用
|
||||
- .hex文件太大的话也会引起问题。`make dfu` 会先擦除存储块,再检查固件大小(哎呀,顺序错了),此时发现错误进而导致刷写失败,键盘停留在DFU模式下。
|
||||
- 因此,请留意.hex文件尺寸有大小限制,例如在Planck上是十六进制7000(十进制的28672)
|
||||
|
||||
```
|
||||
Linking: .build/planck_rev4_cbbrowne.elf [OK]
|
||||
Creating load file for Flash: .build/planck_rev4_cbbrowne.hex [OK]
|
||||
|
||||
Size after:
|
||||
text data bss dec hex filename
|
||||
0 22396 0 22396 577c planck_rev4_cbbrowne.hex
|
||||
```
|
||||
|
||||
- 上面的文件大小是22396/577ch, 小于28672/7000h
|
||||
- 任何合适的其它.hex文件,都可以尝试加载
|
||||
- 在键盘的Makefile中你添加的一些配置也会额外占用空间,在使用BOOTMAGIC_ENABLE,
|
||||
MOUSEKEY_ENABLE, EXTRAKEY_ENABLE, CONSOLE_ENABLE, API_SYSEX_ENABLE
|
||||
时请留意
|
||||
- DFU工具/不会/允许bootloader被覆写(除非你往DFU工具上塞自己的东西),这个风险不大。
|
||||
- EEPROM的写循环一般是 100000(100k)次,不应不停地持续重复地刷写固件,不然很快就烧毁了。
|
||||
|
||||
## NKRO 不好使
|
||||
首先请确保在编译固件时有在**Makefile**中启用 `NKRO_ENABLE`
|
||||
|
||||
如果依旧不行,尝试一下 `Magic` **N** 指令(默认是左Shift+右Shift+N),这个指令可以让键盘在**NKRO**和**6KRO**模式间临时切换。有的场景下**NKRO**无法工作必须切换到**6KRO**模式,比如在BIOS中操作时。
|
||||
|
||||
如果你的固件编译时指定了 `BOOTMAGIC_ENABLE` ,则需要使用 `BootMagic`**N** 指令(默认是空格+N)。这个配置保存在EEPROM中,断电也会留存。
|
||||
|
||||
https://github.com/tmk/tmk_keyboard#boot-magic-configuration---virtual-dip-switch
|
||||
|
||||
|
||||
## 轨迹球需要复位电路 (PS/2鼠标支持)
|
||||
缺失复位电路的情况下,由于不正确的硬件初始化,可能会导致设备不稳定,具体请参阅TPM754的电路原理图:
|
||||
|
||||
- https://geekhack.org/index.php?topic=50176.msg1127447#msg1127447
|
||||
- https://www.mikrocontroller.net/attachment/52583/tpm754.pdf
|
||||
|
||||
|
||||
## 无法读到大于16的矩阵列
|
||||
当列数大于16时,在 [matrix.h] 中的 `read_cols()` 中请用 `1UL<<16` 替代 `1<<16`。
|
||||
|
||||
在C语言中,对于AVR上的 `1`,会被视作一种[16位]的[整形(int)]类型,因此无法左移超过15位。因此 `1<<16` 的计算结果会错误地变成0。解决办法就是将类型改为[无符号长整形(unsigned long)]类型的 `1UL`。
|
||||
|
||||
https://deskthority.net/workshop-f7/rebuilding-and-redesigning-a-classic-thinkpad-keyboard-t6181-60.html#p146279
|
||||
|
||||
## 有些额外的按键不好使(系统,音频控制键)
|
||||
在QMK的 `rules.mk` 中须定义 `EXTRAKEY_ENABLE`
|
||||
|
||||
```
|
||||
EXTRAKEY_ENABLE = yes # 音频及系统控制
|
||||
```
|
||||
|
||||
## 无法从休眠唤醒
|
||||
|
||||
在Windows的**电源管理**的**设备管理**中,检查 `允许该设备唤醒计算机` 选项,同时检查一下BIOS中的相关设置,任意一个按键都应该能将计算机从休眠状态唤醒。
|
||||
|
||||
## 在使用Arduino?
|
||||
|
||||
**注意Arduino的引脚编号与芯片的引脚编号是不同的**。例如,Arduino的 `D0` 引脚并不是 `PD0`,请对照其电路图检查电路。
|
||||
|
||||
- https://arduino.cc/en/uploads/Main/arduino-leonardo-schematic_3b.pdf
|
||||
- https://arduino.cc/en/uploads/Main/arduino-micro-schematic.pdf
|
||||
|
||||
Arduino Leonardo 以及 micro 使用的是**ATMega32U4**因此可以用TMK,但bootloader可能会是个麻烦的问题。
|
||||
|
||||
## 启用JTAG
|
||||
|
||||
默认情况下,键盘启动后JTAG调试接口就被禁用了。支持JTAG的MCU出场时会带着 `JTAGEN` 保险丝,而键盘因为需要这部分MCU的引脚去控制开关矩阵、LED等功能。
|
||||
|
||||
如果你希望启用JTAG,在 `config.h` 中添加定义:
|
||||
|
||||
```c
|
||||
#define NO_JTAG_DISABLE
|
||||
```
|
||||
|
||||
## USB 3兼容性问题
|
||||
将设备从USB 3.x端口改插到USB 2.0端口能解决一些问题。
|
||||
|
||||
|
||||
## Mac相关兼容性问题
|
||||
### OS X 10.11 和 Hub
|
||||
参见: https://geekhack.org/index.php?topic=14290.msg1884034#msg1884034
|
||||
|
||||
|
||||
## BIOS (UEFI) 配置/恢复 (休眠 & 唤醒)/电源循环
|
||||
有人反馈过他们的键盘在BIOS下或是从休眠状态唤醒后会不可用。
|
||||
|
||||
目前这个问题的原因还不清楚,但一些编译选项应该和这个问题有关,你可以在Makefile中禁用 `CONSOLE_ENABLE`, `NKRO_ENABLE`, `SLEEP_LED_ENABLE` 或其他的试一试。
|
||||
|
||||
更多信息:
|
||||
- https://github.com/tmk/tmk_keyboard/issues/266
|
||||
- https://geekhack.org/index.php?topic=41989.msg1967778#msg1967778
|
||||
39
docs/zh-cn/feature_grave_esc.md
Normal file
39
docs/zh-cn/feature_grave_esc.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# Grave Escape
|
||||
|
||||
<!---
|
||||
original document: 0.15.12:docs/feature_grave_esc.md
|
||||
git diff 0.15.12 HEAD -- docs/feature_grave_esc.md | cat
|
||||
-->
|
||||
|
||||
*译注:Grave键即标准键盘中Tab键上方的 <code>`</code> 键,该符号用于英法语等西语体系,辅助调整发音,中文中没有对应概念;Escape即Esc键*
|
||||
|
||||
若你使用60%或其它没有Fn键配列的键盘,会留意到没有独立的Escape键。Grave Escape功能可以让Grave键(<code>`</code>及`~`)与Escape共享一个按键
|
||||
|
||||
## 使用方法
|
||||
|
||||
在配列中使用 `KC_GESC` 替换 `KC_GRAVE` (一般都在`1`键左边)。默认点击会输出 `KC_ESC`,按下Shift或GUI键时,点击会输出 `KC_GRV`
|
||||
|
||||
## 操作系统视角
|
||||
|
||||
假如翠花按下GESC键,系统接收到的是KC_ESC字符。若翠花按住Shift再按下GESC,将输出 `~` 或是反引号。若翠花按住GUI/CMD/Win键,将仅输出<code>`</code>字符
|
||||
|
||||
## 键码
|
||||
|
||||
|键 |别名 |描述 |
|
||||
|---------|-----------|------------------------------------------------------------------|
|
||||
|`KC_GESC`|`GRAVE_ESC`|单击输出Escape, 按住Shift或GUI时输出<code>`</code> |
|
||||
|
||||
### 须留意
|
||||
|
||||
在macOS上 Command+<code>`</code>默认行为是“移动焦点到下一个窗口”,因此不会输出反引号。另外,即便在键盘配置中更改过快捷键,终端程序(Terminal)也通常会将这个操作视为循环切换窗口
|
||||
|
||||
## 配置
|
||||
|
||||
有几种键组合可以变更这种行为,如Windows下的Control+Shift+Escape、macOS下的Command+Option+Escape。若要调整,可以在 `config.h` 中通过 `#define` 配置
|
||||
|
||||
|定义 |描述 |
|
||||
|--------------------------|-----------------------------------------|
|
||||
|`GRAVE_ESC_ALT_OVERRIDE` |按住Alt时输出Escape |
|
||||
|`GRAVE_ESC_CTRL_OVERRIDE` |按住Control时输出Escape |
|
||||
|`GRAVE_ESC_GUI_OVERRIDE` |按住GUI时输出Escape |
|
||||
|`GRAVE_ESC_SHIFT_OVERRIDE`|按住Shift时输出Escape |
|
||||
70
docs/zh-cn/feature_space_cadet.md
Normal file
70
docs/zh-cn/feature_space_cadet.md
Normal file
@@ -0,0 +1,70 @@
|
||||
# Space Cadet: The Future, Built In
|
||||
<!-- Deliberately not translated, leave it to a suitable translation -->
|
||||
|
||||
<!---
|
||||
original document: 0.15.12:docs/feature_space_cadet.md
|
||||
git diff 0.15.12 HEAD -- docs/feature_space_cadet.md | cat
|
||||
-->
|
||||
|
||||
*译注:Space Cadet来源于(在西方早期程序员中)著名的键盘Space Cadet Keyboard,具体信息参见下面的链接或[维基百科](https://en.wikipedia.org/wiki/Space-cadet_keyboard)*
|
||||
|
||||
Steve Losh 在 [Space Cadet Shift](https://stevelosh.com/blog/2012/10/a-modern-space-cadet/) 详细地描述了该功能. 简而言之,点击左Shift时,会输出左括号;点击右Shift时,会输出右括号。如果按住Shift键,常规的Shift将正常工作。这功能实际上和听起来的一样爽,更爽的是现在连Control和Alt也支持!
|
||||
|
||||
## 使用指南
|
||||
|
||||
首先,在你的配列中完成以下任一项:
|
||||
- 替换左Shift为 `KC_LSPO`(左Shift,左括号),替换右Shift为 `KC_RSPC`(右Shift,右括号)。
|
||||
- 替换左Control为 `KC_LCPO`(左Control,左括号),替换右Control为 `KC_RCPC`(右Control,右括号)。
|
||||
- 替换左Alt为 `KC_LAPO`(左Alt,左括号),替换右Alt为 `KC_RAPC`(右Alt,右括号)。
|
||||
- 替换任意一个Shift为 `KC_SFTENT`(右Shift,回车)。
|
||||
|
||||
## 键码
|
||||
|
||||
|键码 |描述 |
|
||||
|-----------|-----------------------------|
|
||||
|`KC_LSPO` |按住时左Shift,点击时 `(` |
|
||||
|`KC_RSPC` |按住时右Shift,点击时 `)` |
|
||||
|`KC_LCPO` |按住时左Control,点击时 `(` |
|
||||
|`KC_RCPC` |按住时右Control,点击时 `)` |
|
||||
|`KC_LAPO` |按住时左Alt,点击时 `(` |
|
||||
|`KC_RAPC` |按住时右Alt,点击时 `)` |
|
||||
|`KC_SFTENT`|按住时右Shift,点击时回车 |
|
||||
|
||||
## 须留意
|
||||
|
||||
同时按下两边的Shift键时会与Space Cadet功能冲突。请参见[指令功能](zh-cn/feature_command.md)以了解如何解决,也可以在 `rules.mk` 中禁用指令:
|
||||
|
||||
```make
|
||||
COMMAND_ENABLE = no
|
||||
```
|
||||
|
||||
## 配置
|
||||
|
||||
默认情况下Space Cadet假设键盘布局为US ANSI,如果你的布局使用不同的括号符,可以在 `config.h` 中重定义。可以修改修饰键点击时发送的字符,亦或阻止修饰键工作。这个新的配置项依次绑定了三个键码:按住或组合其它键使用时的修饰键;点击时发送的修饰键点击(`Tap Modifier`)(在 `KC_TRNS` 中没有修饰键时);最后是点击时发送的键码。请记住,例如'KC_RSFT'按住时点击 `KC_KSPO` 及 `KC_TRNS` 时,修饰键依旧会对键码生效,即属于修饰键点击。
|
||||
|
||||
|定义 |默认值 |描述 |
|
||||
|----------------|-------------------------------|----------------------------------------------------------------|
|
||||
|`LSPO_KEYS` |`KC_LSFT, LSPO_MOD, LSPO_KEY` |按住时发送`KC_LSFT`,点击时发送 `LSPO_MOD` 及 `LSPO_KEY` 定义的键码. |
|
||||
|`RSPC_KEYS` |`KC_RSFT, RSPC_MOD, RSPC_KEY` |按住时发送`KC_RSFT`,点击时发送 `RSPC_MOD` 及 `RSPC_KEY` 定义的键码. |
|
||||
|`LCPO_KEYS` |`KC_LCTL, KC_LSFT, KC_9` |按住时发送`KC_LCTL`,点击时发送 `KC_LSFT` 及 `KC_9`. |
|
||||
|`RCPC_KEYS` |`KC_RCTL, KC_RSFT, KC_0` |按住时发送`KC_RCTL`,点击时发送 `KC_RSFT` 及 `KC_0`. |
|
||||
|`LAPO_KEYS` |`KC_LALT, KC_LSFT, KC_9` |按住时发送`KC_LALT`,点击时发送 `KC_LSFT` 及 `KC_9`. |
|
||||
|`RAPC_KEYS` |`KC_RALT, KC_RSFT, KC_0` |按住时发送`KC_RALT`,点击时发送 `KC_RSFT` 及 `KC_0`. |
|
||||
|`SFTENT_KEYS` |`KC_RSFT, KC_TRNS, SFTENT_KEY` |按住时发送`KC_RSFT`,点击时发送 `SFTENT_KEY`. |
|
||||
|`SPACE_CADET_MODIFIER_CARRYOVER` |*未定义* |在尝试触发其它修饰键的修饰键点击前,暂存目前的修饰键。这在尝试触发Space Cadet前频繁发生修饰键提前松开时会有用。(译注[^1]) |
|
||||
|
||||
|
||||
## 过时的配置项
|
||||
|
||||
以下是一些内部用于向后兼容的定义,目前仍可以使用,但上面的定义适用性要强得多。例如,若你点击 `KC_LSPO` 时不想按住修饰键,在旧定义中只有一个办法,使用 `DISABLE_SPACE_CADET_MODIFIER`。但现在可以定义为:`#define LSPO_KEYS KC_LSFT, KC_TRNS, KC_9`,效果是在按住按键时触发左Shift,点击则发送 `KC_9`。
|
||||
|
||||
|定义 |默认值 |描述 |
|
||||
|------------------------------|-------------|-------------------------------------|
|
||||
|`LSPO_KEY` |`KC_9` |点击左Shift时发送的键码 |
|
||||
|`RSPC_KEY` |`KC_0` |点击右Shift时发送的键码 |
|
||||
|`LSPO_MOD` |`KC_LSFT` |应用在 `LSPO_KEY` 上的修饰键 |
|
||||
|`RSPC_MOD` |`KC_RSFT` |应用在 `RSPC_KEY` 上的修饰键 |
|
||||
|`SFTENT_KEY` |`KC_ENT` |点击Shift时发送的键码 |
|
||||
|`DISABLE_SPACE_CADET_MODIFIER`|*未定义* |定义时将阻止修饰键应用在Space Cadet上 |
|
||||
|
||||
[^1]这句实在是绕,不能确保翻译到位,请参考英文文档
|
||||
329
docs/zh-cn/flashing.md
Normal file
329
docs/zh-cn/flashing.md
Normal file
@@ -0,0 +1,329 @@
|
||||
# 刷写指引及Bootloader资料
|
||||
|
||||
<!---
|
||||
original document: 0.15.12:docs/flashing.md
|
||||
git diff 0.15.12 HEAD -- docs/flashing.md | cat
|
||||
-->
|
||||
|
||||
用于键盘的bootloader有很多种,几乎每一种都在使用私有的刷写协议及工具。幸运的是,形如[QMK工具箱](https://github.com/qmk/qmk_toolbox/releases)这样的工程目标就是尽量支持这些工具,本文会探讨各种bootloader的差异,以及可用的刷写方案。
|
||||
|
||||
针对基于AVR的键盘,QMK会自动检查所要刷写的 `.hex` 文件大小是否与在 `rules.mk` 中设置的 `BOOTLOADER` 值所匹配,同时会输出字节大小信息(及最大限制)。
|
||||
|
||||
同时也可以使用CLI工具刷写键盘,执行:
|
||||
```
|
||||
$ qmk flash -kb <keyboard> -km <keymap>
|
||||
```
|
||||
更多信息参见文档[`qmk flash`](zh-cn/cli_commands.md#qmk-flash)。
|
||||
|
||||
## Atmel DFU
|
||||
|
||||
Atmel系列的DFU bootloader默认配备在所有USB AVR系列上(16/32U4RC除外),广泛用于一些PCB上具备私有集成电路模块(IC)的键盘上(老款OLKB、Clueboards等)。有些使用的是LUFA实现的DFU bootloader,或是QMK的分支版本(新款OLKB),后者对硬件功能进行了扩充加强。
|
||||
|
||||
为保证对DFU bootloader的兼容性,请确保在 `rules.mk` 中存在如下部分内容(可选的值还有 `lufa-dfu` 或 `qmk-dfu`):
|
||||
|
||||
```make
|
||||
# 选择Bootloader
|
||||
BOOTLOADER = atmel-dfu
|
||||
```
|
||||
|
||||
兼容的刷写工具:
|
||||
|
||||
* [QMK工具箱](https://github.com/qmk/qmk_toolbox/releases)(推荐的图形化工具)
|
||||
* [dfu-programmer](https://github.com/dfu-programmer/dfu-programmer) / QMK中将构建目标设为 `:dfu`(推荐的命令行工具)
|
||||
|
||||
刷写过程:
|
||||
|
||||
1. 使用如下任一方式进入bootloader模式:
|
||||
* 点击 `RESET` 键码
|
||||
* 如果PCB上有 `RESET` 键,点击之
|
||||
* 快速短接一下RST到GND
|
||||
2. 等待操作系统识别到设备
|
||||
3. 清空flash存储数据(如果使用QMK工具箱或CLI的 `make`会自动进行)
|
||||
4. 将.hex文件刷写进去
|
||||
5. 重置设备进入应用模式(如上,会自动进行)
|
||||
|
||||
### QMK DFU
|
||||
|
||||
QMK维护了[一个LUFA DFU bootloader的分支版本](https://github.com/qmk/lufa/tree/master/Bootloaders/DFU),其可以进行一次矩阵扫描来退出bootloader进入应用模式,同时会让LED闪烁或蜂鸣器响一声。若要启用该功能,将以下定义添加到 `config.h`:
|
||||
|
||||
```c
|
||||
#define QMK_ESC_OUTPUT F1 // COL pin if COL2ROW
|
||||
#define QMK_ESC_INPUT D5 // ROW pin if COL2ROW
|
||||
// 可选:
|
||||
//#define QMK_LED E6
|
||||
//#define QMK_SPEAKER C6
|
||||
```
|
||||
目前来讲不推荐将 `QMK_ESC` 键设置成与[Bootmagic](zh-cn/feature_bootmagic.md)同一个键,否则按下该键时只会让MCU在bootloader模式上反复进出。
|
||||
|
||||
制造商及型号字符串自动从 `config.h` 中获取,并会在型号后追加 " Bootloader"。
|
||||
|
||||
要生成该bootloader,需指定 `bootloader` 构建目标,即 `make planck/rev4:default:bootloader`。要生成可部署到正式产品的.hex文件(同时包含QMK及bootloader),使用 `production` 构建目标,即 `make planck/rev4:default:production`。
|
||||
|
||||
### `make` 构建目标
|
||||
|
||||
* `:dfu`: 每5秒检测一次直到发现可用的DFU设备,然后进行固件刷写。
|
||||
* `:dfu-split-left` 和 `:dfu-split-right`: 同 `:dfu` 一样会刷写固件,但额外地会设置手性设置到EEPROM中,对于基于Elite-C的分体式键盘这是理想的方法。
|
||||
|
||||
## Caterina
|
||||
|
||||
Arduino及其仿制板使用[Caterina bootloader](https://github.com/arduino/ArduinoCore-avr/tree/master/bootloaders/caterina)或某种变体(使用Pro Micro或其仿制芯片、Pololu A-Star等构建的所有键盘),并基于虚拟串口使用AVR109协议进行通信。
|
||||
|
||||
为确保对Caterina bootloader的兼容性,请添加如下代码块至 `rules.mk`:
|
||||
|
||||
```make
|
||||
# 选择Bootloader
|
||||
BOOTLOADER = caterina
|
||||
```
|
||||
|
||||
兼容的刷写工具:
|
||||
|
||||
* [QMK工具箱](https://github.com/qmk/qmk_toolbox/releases) (推荐的图形化工具)
|
||||
* [avrdude](https://www.nongnu.org/avrdude/) QMK中须基于 `avr109` 编程器 / `:avrdude` 构建目标 (推荐的命令行工具)
|
||||
* [AVRDUDESS](https://github.com/zkemble/AVRDUDESS)
|
||||
|
||||
刷写过程:
|
||||
|
||||
1. 使用如下任一方式进入bootloader模式(进入该模式后只有7秒时间可以刷写;一些型号需要你在750ms内重置两次):
|
||||
* 点击 `RESET` 键码
|
||||
* 如果PCB上有 `RESET` 键,点击之
|
||||
* 快速短接一下RST到GND
|
||||
2. 等待操作系统识别到设备
|
||||
3. 将.hex文件刷写进去
|
||||
4. 等待设备自动重置
|
||||
|
||||
### `make` 构建目标
|
||||
|
||||
* `:avrdude`: 每5秒检测一次直到发现可用的Caterina设备(通过检测新COM端口),然后进行固件刷写。
|
||||
* `:avrdude-loop`: 同 `:avrdude` 一样刷写固件,但会在一个设备刷写完后再次尝试刷写。主要用于批量刷写设备。按 Ctrl+C 以终止循环检测。
|
||||
* `:avrdude-split-left` 和 `:avrdude-split-right`: 同 `:avrdude` 一样会刷写固件,但额外地会设置手性设置到EEPROM中,对于基于Pro Micro的分体式键盘这是理想的方法。
|
||||
|
||||
## HalfKay
|
||||
|
||||
HalfKay是一款由PJRC开发的超精简的bootloader,且呈现为HID设备(因此不需要额外的驱动),在所有的Teensys,即"the 2.0",上已经预刷写过。该bootloader目前是闭源的,因此一旦覆写(即通过ISP刷入其它bootloader)掉,就无法复原了。
|
||||
|
||||
为确保对Halfkay bootloader的兼容性,请添加如下代码块至 `rules.mk`:
|
||||
|
||||
```make
|
||||
# 选择Bootloader
|
||||
BOOTLOADER = halfkay
|
||||
```
|
||||
|
||||
兼容的刷写工具:
|
||||
|
||||
* [QMK工具箱](https://github.com/qmk/qmk_toolbox/releases)(推荐的图形化工具)
|
||||
* [Teensy Loader Command Line](https://www.pjrc.com/teensy/loader_cli.html) / QMK中将构建目标设为 `:teensy`(推荐的命令行工具)
|
||||
* [Teensy Loader](https://www.pjrc.com/teensy/loader.html)
|
||||
|
||||
刷写过程:
|
||||
|
||||
1. 使用如下任一方式进入bootloader模式(进入该模式后只有7秒时间可以刷写):
|
||||
* 点击 `RESET` 键码
|
||||
* 如果Teensy上或PCB上有 `RESET` 键,点击之
|
||||
* 快速短接一下RST到GND
|
||||
2. 等待操作系统识别到设备
|
||||
3. 将.hex文件刷写进去
|
||||
4. 重置设备进入应用模式(可能会自动进行)
|
||||
|
||||
## USBasploader
|
||||
|
||||
USBasploader是一款来源于[Objective Development](https://www.obdev.at/products/vusb/usbasploader.html)的bootloader。它通过模拟出一个USBasp ISP编程器来运行V-USB以用于一些形如ATmega328P这样的“非USB AVR芯片”。
|
||||
|
||||
为确保对USBasploader bootloader的兼容性,请添加如下代码块至 `rules.mk`:
|
||||
|
||||
```make
|
||||
# 选择Bootloader
|
||||
BOOTLOADER = usbasploader
|
||||
```
|
||||
|
||||
兼容的刷写工具:
|
||||
|
||||
* [QMK工具箱](https://github.com/qmk/qmk_toolbox/releases)(推荐的图形化工具)
|
||||
* [avrdude](https://www.nongnu.org/avrdude/) QMK中须基于 `usbasp` 编程器 / `:usbasp` 构建目标(推荐的命令行工具)
|
||||
* [AVRDUDESS](https://github.com/zkemble/AVRDUDESS)
|
||||
|
||||
刷写过程:
|
||||
|
||||
1. 使用如下任一方式进入bootloader模式:
|
||||
* 点击 `RESET` 键码
|
||||
* 在按住 `BOOT` 按钮时,快速点击一下PCB上的 `RESET`
|
||||
2. 等待操作系统识别到设备
|
||||
3. 将.hex文件刷写进去
|
||||
4. 点击PCB上的 `RESET` 按钮或将RST短接至GND一下。
|
||||
|
||||
## BootloadHID
|
||||
|
||||
BootloadHID是一款用于AVR微控制器的bootloader,其呈现为HID输入设备,和HalkKay很像,因此在Windows下也无需安装驱动。
|
||||
|
||||
为确保对bootloadHID bootloader的兼容性,请添加如下代码块至 `rules.mk`:
|
||||
|
||||
```make
|
||||
# 选择Bootloader
|
||||
BOOTLOADER = bootloadhid
|
||||
```
|
||||
|
||||
兼容的刷写工具:
|
||||
|
||||
* [QMK工具箱](https://github.com/qmk/qmk_toolbox/releases)(推荐的图形化工具)
|
||||
* [bootloadHID CLI](https://www.obdev.at/products/vusb/bootloadhid.html) / QMK中将构建目标设为 `:bootloadhid`(推荐的命令行工具)
|
||||
* [HIDBootFlash](http://vusb.wikidot.com/project:hidbootflash)
|
||||
|
||||
|
||||
刷写过程:
|
||||
|
||||
1. 使用如下任一方式进入bootloader模式:
|
||||
* 点击 `RESET` 键码
|
||||
* 在按住“盐键”(salt key)时插入键盘 - 在PS2AVRGB板上,通常在MCU的A0及B0引脚上有这个按键,否则请查看键盘的使用说明。
|
||||
2. 等待操作系统识别到设备
|
||||
3. 将.hex文件刷写进去
|
||||
4. 重置设备到应用模式(可能会自动进行)
|
||||
|
||||
### QMK HID
|
||||
|
||||
QMK维护了[一个LUFA HID bootloader的分支版本](https://github.com/qmk/lufa/tree/master/Bootloaders/HID),通过USB HID节点设备进行刷写,工作模式类似于PJRC的Teensy Loader刷写器以及HalfKay bootloader。其可以进行一次矩阵扫描来退出bootloader进入应用模式,同时会让LED闪烁或蜂鸣器响一声。
|
||||
|
||||
为确保对QMK HID bootloader的兼容性,请添加如下代码块至 `rules.mk`:
|
||||
|
||||
```make
|
||||
# 选择Bootloader
|
||||
BOOTLOADER = qmk-hid
|
||||
```
|
||||
|
||||
要启用额外的功能支持,请添加如下定义至 `config.h`:
|
||||
|
||||
```c
|
||||
#define QMK_ESC_OUTPUT F1 // COL pin if COL2ROW
|
||||
#define QMK_ESC_INPUT D5 // ROW pin if COL2ROW
|
||||
// 可选:
|
||||
//#define QMK_LED E6
|
||||
//#define QMK_SPEAKER C6
|
||||
```
|
||||
|
||||
目前来讲不推荐将 `QMK_ESC` 键设置成与[Bootmagic Lite](zh-cn/feature_bootmagic.md)同一个键,否则按下该键时只会让MCU在bootloader模式上反复进出。
|
||||
|
||||
制造商及型号字符串自动从 `config.h` 中获取,并会在型号后追加 " Bootloader"。
|
||||
|
||||
要生成该bootloader,需指定 `bootloader` 构建目标,即 `make planck/rev4:default:bootloader`。要生成可部署到正式产品的.hex文件(同时包含QMK及bootloader),使用 `production` 构建目标,即 `make planck/rev4:default:production`。
|
||||
|
||||
兼容的刷写工具:
|
||||
|
||||
* TBD
|
||||
* 目前只能选择使用该 [Python脚本](https://github.com/qmk/lufa/tree/master/Bootloaders/HID/HostLoaderApp_python), 或从LUFA仓库中构建[`hid_bootloader_cli`](https://github.com/qmk/lufa/tree/master/Bootloaders/HID/HostLoaderApp)。Homebrew也许(即将)能直接支持(通过 `brew install qmk/qmk/hid_bootloader_cli`)。
|
||||
|
||||
刷写过程:
|
||||
|
||||
1. 使用如下任一方式进入bootloader模式:
|
||||
* 点击 `RESET` 键码
|
||||
* 如果PCB上有 `RESET` 键,点击之
|
||||
* 快速短接一下RST到GND
|
||||
2. 等待操作系统识别到设备
|
||||
4. 将.hex文件刷写进去
|
||||
5. 重置设备进入应用模式(可能会自动进行)
|
||||
|
||||
### `make` 构建目标
|
||||
|
||||
* `:qmk-hid`: 每5秒检测一次直到发现可用的DFU设备,然后进行固件刷写。
|
||||
|
||||
## STM32/APM32 DFU
|
||||
|
||||
所有的STM32及APM32 MCU系列,除F103型号外(参见[STM32duino小节](#stm32duino))都在出场时预装了bootloader且无法修改或删除。
|
||||
|
||||
为确保对STM32-DFU bootloader的兼容性,请添加如下代码块至 `rules.mk`(可选替代项为 `apm32-dfu`):
|
||||
|
||||
```make
|
||||
# 选择Bootloader
|
||||
BOOTLOADER = stm32-dfu
|
||||
```
|
||||
|
||||
兼容的刷写工具:
|
||||
|
||||
* [QMK工具箱](https://github.com/qmk/qmk_toolbox/releases) (推荐的图形化工具)
|
||||
* [dfu-util](https://dfu-util.sourceforge.net/) / QMK中将构建目标设为 `:dfu-util`(推荐的命令行工具)
|
||||
|
||||
刷写过程:
|
||||
|
||||
1. 使用如下任一方式进入bootloader模式(进入该模式后只有7秒时间可以刷写):
|
||||
* 点击 `RESET` 键码(对STM32F042设备可能无效)
|
||||
* 如果有重置电路,点击PCB上的 `RESET` 键;有些主控板上可能会有一个开关需要先打开
|
||||
* 否则,你需要将 `BOOT0` 接线到VCC(通过 `BOOT0` 按钮或跳线),短接 `RESET` 至GND(通过 `RESET` 按钮或条线),然后断开 `BOOT0` 的接线。
|
||||
2. 等待操作系统识别到设备
|
||||
3. 将.bin文件刷写进去
|
||||
4. 重置设备进入应用模式(可能会自动进行)
|
||||
|
||||
### `make` 构建目标
|
||||
|
||||
* `:dfu-util`: 每5秒检测一次直到发现可用的STM32 bootloader设备,然后进行固件刷写。
|
||||
* `:dfu-util-split-left` 和 `:dfu-util-split-right`: 同 `:avrdude` 一样会刷写固件,但额外地会设置手性设置到EEPROM中,对于基于Proton-C的分体式键盘这是理想的方法。
|
||||
* `:st-link-cli`: 通过ST-Link CLI工具集而非dfu-util进行刷写,需要有ST-Link电子狗。
|
||||
* `:st-flash`: 通过[STLink工具](https://github.com/stlink-org/stlink)内的 `st-flash` 工具而非dfu-util进行刷写,需要有ST-Link电子狗。
|
||||
|
||||
## STM32duino :id=stm32duino
|
||||
|
||||
该bootloader几乎是STM32F103板专用,该型号出厂不带USB DFU bootloader。其源代码及预编译好的二进制文件[在这里](https://github.com/rogerclarkmelbourne/STM32duino-bootloader)。
|
||||
|
||||
为确保对STM32duino bootloader的兼容性,请添加如下代码块至 `rules.mk`:
|
||||
|
||||
```make
|
||||
# 选择Bootloader
|
||||
BOOTLOADER = stm32duino
|
||||
```
|
||||
|
||||
兼容的刷写工具:
|
||||
|
||||
* [QMK工具箱](https://github.com/qmk/qmk_toolbox/releases) (推荐的图形化工具)
|
||||
* [dfu-util](https://dfu-util.sourceforge.net/) / QMK中将构建目标设为 `:dfu-util`(推荐的命令行工具)
|
||||
|
||||
刷写过程:
|
||||
|
||||
1. 使用如下任一方式进入bootloader模式(进入该模式后只有7秒时间可以刷写):
|
||||
* 点击 `RESET` 键码(对STM32F042设备可能无效)
|
||||
* 如果有重置电路,点击PCB上的 `RESET` 键;有些主控板上可能会有一个开关需要先打开
|
||||
* 否则,你需要将 `BOOT0` 接线到VCC(通过 `BOOT0` 按钮或跳线),短接 `RESET` 至GND(通过 `RESET` 按钮或条线),然后断开 `BOOT0` 的接线。
|
||||
2. 等待操作系统识别到设备
|
||||
3. 将.bin文件刷写进去
|
||||
4. 重置设备进入应用模式(可能会自动进行)
|
||||
|
||||
## Kiibohd DFU
|
||||
|
||||
Input Club出品的键盘使用NXP Kinetis微控制器而非STM32,并使用了独有的[自制bootloader](https://github.com/kiibohd/controller/tree/master/Bootloader),然而处理器 及协议上两者大部分是一致的。
|
||||
|
||||
在 `rules.mk` 中该bootloader的设置项为 `kiibohd`,但既然该bootloader仅用在Input Club主控板上,就不必要设置到键映射或是用户级<!--译:不清楚这里的“user level”是个啥……-->了。
|
||||
|
||||
兼容的刷写工具:
|
||||
|
||||
* [QMK工具箱](https://github.com/qmk/qmk_toolbox/releases)(推荐的图形化工具)
|
||||
* [dfu-util](https://dfu-util.sourceforge.net/) / QMK中将构建目标设为 `:dfu-util`(推荐的命令行工具)
|
||||
|
||||
刷写过程:
|
||||
|
||||
1. 使用如下任一方式进入bootloader模式:
|
||||
* 点击 `RESET` 键码(有可能只能进入到“安全”bootloader模式,参见[这里](https://github.com/qmk/qmk_firmware/issues/6112))
|
||||
* 如果PCB上有 `RESET` 键,点击之
|
||||
2. 等待操作系统识别到设备
|
||||
3. 将.bin文件刷写进去
|
||||
4. 重置设备进入应用模式(可能会自动进行)
|
||||
|
||||
## tinyuf2
|
||||
|
||||
键盘可以考虑支持tinyuf2 bootloader,目前唯一支持的设备是F401/F411 blackpill。
|
||||
|
||||
在 `rules.mk` 中该bootloader的设置项为 `tinyuf2`,也可指定到键映射及用户级中。
|
||||
|
||||
为确保对tinyuf2 bootloader的兼容性,请添加如下代码块至 `rules.mk`:
|
||||
|
||||
```make
|
||||
# 选择Bootloader
|
||||
BOOTLOADER = tinyuf2
|
||||
```
|
||||
|
||||
兼容的刷写工具:
|
||||
|
||||
* 任何具备文件拷贝能力的程序,如 _macOS Finder_ 或 _Windows Explorer_ *。
|
||||
|
||||
刷写过程:
|
||||
|
||||
1. 使用如下任一方式进入bootloader模式:
|
||||
* 点击 `RESET` 键码
|
||||
* 双击PCB上的 `nRST` 键
|
||||
2. 等待操作系统识别到设备
|
||||
3. 将.uf2文件拷贝到新出现的USB存储设备上
|
||||
4. 等待设备恢复可用状态
|
||||
75
docs/zh-cn/flashing_bootloadhid.md
Normal file
75
docs/zh-cn/flashing_bootloadhid.md
Normal file
@@ -0,0 +1,75 @@
|
||||
# BootloadHID刷写指引及资料
|
||||
|
||||
<!---
|
||||
original document: 0.15.12:docs/flashing_bootloadhid.md
|
||||
git diff 0.15.12 HEAD -- docs/flashing_bootloadhid.md | cat
|
||||
-->
|
||||
|
||||
ps2avr(GB)基于一片ATmega32A微控制器及特殊的bootloader,无法使用常规的QMK方法进行刷写。
|
||||
|
||||
常规刷写过程:
|
||||
|
||||
1. 使用如下任一方式进入bootloader模式:
|
||||
* 点击 `RESET` 键码(一些设备上不管用)
|
||||
* 在按住“盐键”(salt key)时插入键盘(该键一般会在键盘使用说明上写明)
|
||||
2. 等待操作系统识别到设备
|
||||
3. 将.hex文件刷写进去
|
||||
4. 重置设备到应用模式(可能会自动进行)
|
||||
|
||||
## 用于bootloadHID刷写的构建目标
|
||||
|
||||
?> 使用QMK安装脚本,具体[参见这里](zh-cn/newbs_getting_started.md),所需的bootloadHID工具应自动被安装上。
|
||||
|
||||
若希望通过命令行进行刷写,通过如下命令指定 `:bootloadhid` 构建目标:
|
||||
|
||||
make <keyboard>:<keymap>:bootloadhid
|
||||
|
||||
## 基于图形化界面的刷写方法
|
||||
|
||||
### Windows
|
||||
1. 下载[HIDBootFlash](http://vusb.wikidot.com/project:hidbootflash)
|
||||
2. 重置键盘
|
||||
3. 确认VID为 `16c0` 且PID为 `05df`
|
||||
4. 点击 `查找设备(Find Device)` 并确认目标键盘可见
|
||||
5. 点击 `打开.hex文件(Open .hex File)` 并定位到你创建的.hex文件
|
||||
6. 点击 `刷写设备(Flash Device)` 并等待刷写完毕
|
||||
|
||||
## 在命令行中进行刷写
|
||||
|
||||
1. 重置键盘
|
||||
2. 通过输入 `bootloadHID -r` 并追加 `.hex` 文件的路径进行主控板的刷写
|
||||
|
||||
### Windows系统上手动安装
|
||||
针对MSYS2:
|
||||
1. 下载BootloadHID固件包:https://www.obdev.at/downloads/vusb/bootloadHID.2012-12-08.tar.gz
|
||||
2. 使用合适的工具解压,如7-Zip
|
||||
3. 将解压出的 `commandline/bootloadHID.exe` 拷贝至MSYS目录下,一般是 `C:\msys64\usr\bin`
|
||||
|
||||
针对Windows本地环境刷写,`bootloadHID.exe` 可以直接在非MSYS2环境下执行。
|
||||
|
||||
### Linux系统上手动安装
|
||||
1. 安装libusb开发依赖项:
|
||||
```bash
|
||||
# 该操作具体取决于系统 - Debian下可以这样
|
||||
sudo apt-get install libusb-dev
|
||||
```
|
||||
2. 下载BootloadHID固件包:
|
||||
```
|
||||
wget https://www.obdev.at/downloads/vusb/bootloadHID.2012-12-08.tar.gz -O - | tar -xz -C /tmp
|
||||
```
|
||||
3. 构建bootloadHID可执行程序:
|
||||
```
|
||||
cd /tmp/bootloadHID.2012-12-08/commandline/
|
||||
make
|
||||
sudo cp bootloadHID /usr/local/bin
|
||||
```
|
||||
|
||||
### MacOS系统上手动安装
|
||||
1. 执行以下命令安装Homebrew:
|
||||
```
|
||||
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
||||
```
|
||||
2. 安装以下包:
|
||||
```
|
||||
brew install --HEAD https://raw.githubusercontent.com/robertgzr/homebrew-tap/master/bootloadhid.rb
|
||||
```
|
||||
59
docs/zh-cn/getting_started_docker.md
Normal file
59
docs/zh-cn/getting_started_docker.md
Normal file
@@ -0,0 +1,59 @@
|
||||
# Docker快速上手指引
|
||||
|
||||
<!---
|
||||
original document: 0.15.12:docs/getting_started_docker.md
|
||||
git diff 0.15.12 HEAD -- docs/getting_started_docker.md | cat
|
||||
-->
|
||||
|
||||
本工程包含了一套Docker工作流,可以方便地在不更改你主系统环境情况下完成新固件文件的构建工作。这同时也保证了在你拉取该工程代码后的编译环境与其他人以及QMK开发者的一致。当你需要其他人协助你排查遇到的问题时会方便很多。
|
||||
|
||||
## 需求
|
||||
|
||||
核心需求是一个已安装的可用的 `docker` 或 `podman`。
|
||||
* [Docker CE](https://docs.docker.com/install/#supported-platforms)
|
||||
* [Podman](https://podman.io/getting-started/installation)
|
||||
|
||||
## 用法
|
||||
|
||||
拉取QMK仓库到本地(包括所有的子模块):
|
||||
|
||||
```bash
|
||||
git clone --recurse-submodules https://github.com/qmk/qmk_firmware.git
|
||||
cd qmk_firmware
|
||||
```
|
||||
|
||||
执行以下命令构建键映射:
|
||||
```bash
|
||||
util/docker_build.sh <keyboard>:<keymap>
|
||||
# 例: util/docker_build.sh planck/rev6:default
|
||||
```
|
||||
|
||||
如上可以构建所需的键盘/键映射,可用于刷写的 `.hex` 及 `.bin` 输出文件存放在QMK目录下。如果省略了 `:keymap` 参数,所有的键映射都会被编译。留意编译参数格式与 `make` 构建时的一致。
|
||||
|
||||
同时也支持直接从Docker中编译和刷写,只需要指定 `target`:
|
||||
|
||||
```bash
|
||||
util/docker_build.sh keyboard:keymap:target
|
||||
# 例: util/docker_build.sh planck/rev6:default:flash
|
||||
```
|
||||
|
||||
可以不带参数地执行该脚本,其会依次要求你输入这些参数,也许你会觉得这样更好用:
|
||||
|
||||
```bash
|
||||
util/docker_build.sh
|
||||
# 从输入中读取参数 (留空则构建所有的键盘/键映射)
|
||||
```
|
||||
|
||||
可以通过设置环境变量 `RUNTIME` 为想使用的容器运行时的名称或路径来指定运行时,默认其会检测并自动选取docker或podman,相比于podman会更倾向于用docker。
|
||||
|
||||
```bash
|
||||
RUNTIME="podman" util/docker_build.sh keyboard:keymap:target
|
||||
```
|
||||
|
||||
## FAQ
|
||||
|
||||
### 为什么我无法在我的Windows/macOS下刷写固件
|
||||
|
||||
在Windows及macOS上,需要有[Docker Machine](http://gw.tnode.com/docker/docker-machine-with-usb-support-on-windows-macos/)运行着,配置过程很繁琐,因此我们没有做推荐。请考虑使用[QMK工具箱](https://github.com/qmk/qmk_toolbox)。
|
||||
|
||||
!> Windows下需要启用[Hyper-V](https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v)才能运行Docker,这也意味着它无法运行在没有Hyper-V的Windows版本下,如Windows 7,Windows 8及**Windows 10家庭版**。
|
||||
61
docs/zh-cn/getting_started_vagrant.md
Normal file
61
docs/zh-cn/getting_started_vagrant.md
Normal file
@@ -0,0 +1,61 @@
|
||||
# Vagrant快速上手指引
|
||||
|
||||
<!---
|
||||
original document: 0.15.12:docs/getting_started_vagrant.md
|
||||
git diff 0.15.12 HEAD -- docs/getting_started_vagrant.md | cat
|
||||
-->
|
||||
|
||||
本工程包含一份 `Vagrantfile`,可以方便地在不更改你系统环境情况下完成新固件文件的构建工作。这同时也保证了在你拉取该工程代码后的编译环境与也使用Vagrantfile的其它人的一致。当你需要其他人协助你排查遇到的问题时会方便很多。
|
||||
|
||||
## 需求
|
||||
|
||||
本工程中的 `Vagrantfile` 需要安装[Vagrant](https://www.vagrantup.com/)以及可用的虚拟机服务:
|
||||
|
||||
* [VirtualBox](https://www.virtualbox.org/) (5.0.12及以后版本)
|
||||
* 卖点是'最适用于Vagrant的平台'
|
||||
* [VMware Workstation](https://www.vmware.com/products/workstation) 及 [Vagrant VMware插件](https://www.vagrantup.com/vmware)
|
||||
* (付费购买的)VMware插件需要在经过正版授权的VMware Workstation/Fusion上运行
|
||||
* [Docker](https://www.docker.com/)
|
||||
|
||||
安装了Vagrant之后,在安装合适的虚拟机服务后可能需要重启机器。拉取本工程后在工程目录下执行 'vagrant up' 将启动一个包含了所有本工程所需工具的构建环境(虚拟机或是容器)。最后会有一个vagrant启动提示告知你一切正常就绪,否则你也可以参考一下下面的构建文档。
|
||||
|
||||
## 刷写固件
|
||||
|
||||
比较“简单”的方案是在你的宿主系统上借助以下工具刷写固件:
|
||||
|
||||
* [QMK工具箱](https://github.com/qmk/qmk_toolbox) (推荐)
|
||||
* [Teensy Loader](https://www.pjrc.com/teensy/loader.html)
|
||||
|
||||
如果你希望通过命令行进行编程工作,可以在Vagrantfile中取消掉['modifyvm']的注释以允许USB直通到Linux环境,既可以使用dfu-util/dfu-programmer之类的命令行工具进行编程工作,或是安装Teensy的命令行版本。
|
||||
|
||||
## Vagrantfile概览
|
||||
开发环境被配置为运行QMK Docker镜像 `qmkfm/qmk_cli`,不仅让各系统下的功能预期一致,也是我们CI环境的镜像。
|
||||
|
||||
## FAQ
|
||||
|
||||
### 为什么我的VirtualBox环境会有问题?
|
||||
VirtualBox 5的某些版本与工程中Vagrantfile中指定的VirtualBox扩展存在兼容问题。如果你遇到了/vagrant挂载不成功的问题,请升级VirtualBox至5.0.12或更高版本。**或者,可以尝试执行如下命令:**
|
||||
|
||||
```console
|
||||
vagrant plugin install vagrant-vbguest
|
||||
```
|
||||
|
||||
### 如何移除一个现有环境?
|
||||
不再需要这个环境了是吗?在本工程目录下的任何位置,执行:
|
||||
|
||||
```console
|
||||
vagrant destroy
|
||||
```
|
||||
|
||||
### 如果我是想直接用Docker呢?
|
||||
想在不使用虚拟机技术的情况下也能使用Vagrant工作流?Vagrangfile已配置为允许绕过运行虚拟机,直接运行容器。通过如下方式执行命令可以强制使用Docker来启动环境:
|
||||
```console
|
||||
vagrant up --provider=docker
|
||||
```
|
||||
|
||||
### 如何访问虚拟机环境而非Docker容器?
|
||||
通过如下方法跳过 `vagrant` 的用户初始化过程以在QMK构建镜像中直接执行:
|
||||
|
||||
```console
|
||||
vagrant ssh -c 'sudo -i'
|
||||
```
|
||||
255
docs/zh-cn/hand_wire.md
Normal file
255
docs/zh-cn/hand_wire.md
Normal file
@@ -0,0 +1,255 @@
|
||||
# 手工搭建指南
|
||||
|
||||
<!---
|
||||
original document: 0.15.17:docs/hand_wire.md
|
||||
git diff 0.15.17 HEAD -- docs/hand_wire.md | cat
|
||||
-->
|
||||
|
||||
## 模块清单
|
||||
|
||||
你需要的模块有:(*x*为你设计的键盘的键数)
|
||||
|
||||
* QMK所兼容的主控板(Teensy, Pro-Micro, QMK Proton C 等)
|
||||
* *x* 个键轴 (MX, Matias, Gateron 等)
|
||||
* *x* 个通孔二极管(译注:即普通的直插二极管)
|
||||
* 定位板及卫星轴
|
||||
* 电线
|
||||
* 电烙铁
|
||||
* 松香/焊油
|
||||
* 通风的环境/风扇通风
|
||||
* 剪线钳
|
||||
|
||||
可选地但比较有用的:
|
||||
|
||||
* 剥线钳/一把锋利的剪刀
|
||||
* 镊子及小尖嘴钳
|
||||
* 焊台/一位助手
|
||||
|
||||
## 前期工作
|
||||
|
||||
组装PCB矩阵的方法多种多样,这份指引会描述一些基础信息并给出一些推荐方案。
|
||||
|
||||
既然我们要进行手工飞线搭建,这里就假设你已经有了定位板。如果你想构建完全定制化的配列,有 [ai03 Plate Generator](https://kbplate.ai03.me/) 以及 [Swillkb Plate & Case Builder](http://builder.swillkb.com/) 这样的工具可以助你设计出一个新的。
|
||||
|
||||
首先从安装键轴及卫星轴开始,考虑厚度及材质的影响,可能需要热熔胶来固定。
|
||||
|
||||
## 设计矩阵 :id=planning-the-matrix
|
||||
|
||||
如果你在参考已有的手工搭建指南(比如[自制键盘固件目录](https://github.com/qmk/qmk_firmware/tree/master/keyboards/handwired)下的键盘),可以跳过该步骤,确保是按照文中的矩阵方案连线即可。
|
||||
|
||||
如果你的方案是将每个开关的一个引脚与两边的开关相连(行方向),另一个引脚与上下的开关相连(列方向),并串联一个二极管到一端,最常用的方案是二极管背对着连接到行方向的引脚(列向行)。即让远离二极管黑线一端连接到开关上(电流只能从一个方向通过二极管)。
|
||||
|
||||
可以很容易地设计出正交连接的键盘(如Planck)。
|
||||
(译注:这里的“正交”意思是行列方向连接规整)
|
||||
|
||||

|
||||
[作者:RoastPotatoe "如何手工搭建Planck键盘"](https://blog.roastpotatoes.co/guide/2015/11/04/how-to-handwire-a-planck/) (英文)内的图例
|
||||
|
||||
键盘配列越大,功能越丰富,则矩阵也会更复杂。[Keyboard Firmware Builder](https://kbfirmware.com/) 可以帮助你设计矩阵配列(下图为通过 [Keyboard Layout Editor](https://www.keyboard-layout-editor.com) 导出的全尺寸ISO键盘)。
|
||||
|
||||

|
||||
|
||||
必须时刻留意矩阵的行列数总和不能超出控制器的IO引脚数,因此上图的方案可以使用 Proton C 或 Teensy++ 控制器,但常规 Teensy 或 Pro Micro 不行。
|
||||
|
||||
### 常见微控制器板 :id=common-microcontroller-boards
|
||||
|
||||
| 控制器板 | 控制器方案 | # I/O引脚数 | 引脚图 |
|
||||
| :------------ |:-------------:| ------:| ------ |
|
||||
| Pro Micro* | ATmega32u4 | 20 | [链接](https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide/hardware-overview-pro-micro#Teensy++_2.0) |
|
||||
| Teensy 2.0 | ATmega32u4 | 25 | [链接](https://www.pjrc.com/teensy/pinout.html) |
|
||||
| [QMK Proton C](https://qmk.fm/proton-c/) | STM32F303xC | 36 | [链接 1](https://i.imgur.com/RhtrAlc.png), [2](https://deskthority.net/wiki/QMK_Proton_C) |
|
||||
| Teensy++ 2.0 | AT90USB1286 | 46 | [链接](https://www.pjrc.com/teensy/pinout.html#Teensy_2.0) |
|
||||
|
||||
*Elite C 与 Pro Micro 除将 Micro USB 替换为 USB-C 外其余无差别。
|
||||
|
||||
一些主控板专门为手工接线设计,除可直接连接少量开关外还有额外的引脚,但这些通常会更贵一些,也更难掌控。
|
||||
|
||||
<img src="https://i.imgur.com/QiA3ta6.jpg" alt="实装的 Postage mini 主控板" width="500"/>
|
||||
|
||||
| 控制器板 | 控制器方案 | # I/O引脚数 |
|
||||
| :------------ |:-------------:| ------:|
|
||||
| [Swiss helper](https://www.reddit.com/r/MechanicalKeyboards/comments/8jg5d6/hand_wiring_this_might_help/) | ATmega32u4 | 20 |
|
||||
| [Postage 主控板](https://github.com/LifeIsOnTheWire/Postage-Board/)| ATmega32u4| 25 |
|
||||
| [Postage mini 主控板](https://geekhack.org/index.php?topic=101460.0)| ATmega32u4| 25 |
|
||||
|
||||
## 矩阵布线
|
||||
|
||||
布线方案不是唯一的,要达成的效果是可以正确连接所有的焊点并不会出现预期外的短路。
|
||||
|
||||
公开的材料和技术方案:
|
||||
|
||||
(译注:链接文章及标题恕不翻译)
|
||||
|
||||
| 技术方案 | 示例 | 优点 | 缺点 | 图片
|
||||
| :-----------| :------- | :------ | :--- | :---
|
||||
| 间断开口的线缆 | [Sasha Solomon's Dactyl](https://medium.com/@sachee/building-my-first-keyboard-and-you-can-too-512c0f8a4c5f) 以及 [Cribbit's modern hand wire](https://geekhack.org/index.php?topic=87689.0) | 整洁 | 线缆开口的操作会有些困难 | 
|
||||
| 适宜长度的线缆 | [u/xicolinguada's ortho build](https://www.reddit.com/r/MechanicalKeyboards/comments/c39k4f/my_first_hand_wired_keyboard_its_not_perfect_but/) | 剥线容易 | 较难固定位置 | 
|
||||
| 漆包线 | [fknraiden's custom board](https://geekhack.org/index.php?topic=74223.0) | 可以直接焊接(烧掉绝缘层) | 外观差? | 
|
||||
| 弯折二极管引脚作为行方向连线 | [Matt3o's Brownfox](https://deskthority.net/viewtopic.php?f=7&t=6050) | 焊点更少 | 绝缘性差 | 
|
||||
| 硬线(如铜管) | [u/d_stilgar's invisible hardline](https://www.reddit.com/r/MechanicalKeyboards/comments/8aw5j2/invisible_hardline_keyboard_progress_update_april/) 以及 [u/jonasfasler's first attempt](https://www.reddit.com/r/MechanicalKeyboards/comments/de1jyv/my_first_attempt_at_handwiring_a_keyboard/) | 非常漂亮 | 难度高,没有物理绝缘 | 
|
||||
| 用绝缘胶带(如高温胶带*)隔离开的裸线 | [Matt3o's 65% on his website](https://matt3o.com/hand-wiring-a-custom-keyboard/) | 简单(不用剥线) | 丑拒 | 
|
||||
| 铜箔胶带 | [ManuForm Dactyl](https://github.com/tshort/dactyl-keyboard) | 非常简单 | 只适用于定位板/外壳与开关底部平齐的情况 | 
|
||||
|
||||
(*译注:原文是聚酰亚胺胶带,在中国通常叫高温胶带)
|
||||
|
||||
|
||||
以上方案可以结合使用,在焊接前请准备好各种长度的线缆。
|
||||
|
||||
|
||||
### 分体键盘的注意事项
|
||||
|
||||
如果你想制作的是分体键盘(如Dactyl),每一半边都需要一个控制器以及连通两方的通信用线(如TRRS或硬连接线)。更多资料参见[QMK分体键盘文档](zh-cn/feature_split_keyboard.md)。
|
||||
(译注:TRRS即一种常用的4线耳机线插口,具体信息请查阅维基百科或[这份知乎文章](https://zhuanlan.zhihu.com/p/144233538))
|
||||
|
||||
|
||||
### 焊接
|
||||
|
||||
你可以找到很多焊接指导及技巧,这里列出了最相关及最关键的部分:
|
||||
|
||||
要想焊接的牢固需要确保焊料与焊接两端的金属面充分地接触,一个好办法(也不是必须)是上锡前先(将线缆)在针脚上绕一圈或先拧在一起。
|
||||
|
||||
<img src="https://i.imgur.com/eHJjmnU.jpg" alt="杆上绕圈" width="200"/> <img src="https://i.imgur.com/8nbxmmr.jpg?1" alt="绕环的二极管引脚" width="200"/>
|
||||
|
||||
如果二极管还在包装条上且需要弯折(作为绕圈的起点处或用于连接到邻接处),一个简便的办法是找一个盒子、桌子或尺子的直边上进行弯折。由于弯折统一在二极管一侧,也有助于区分二极管的方向。
|
||||
|
||||
<img src="https://i.imgur.com/oITudbX.jpg" alt="弯折二极管引脚" width="200"/>
|
||||
|
||||
如果你的电烙铁有温控功能,将其设置在 315ºC(600ºF)。
|
||||
|
||||
热起来后,给电烙铁上锡 - 即融化一部分锡料到烙铁头上然后立刻用湿海绵或烙铁头海绵擦掉,这样烙铁头上会有一层光滑明亮的焊料,以防止氧化且有助于焊料的焊接操作。
|
||||
|
||||
接下来进行焊接,先将烙铁头在焊接面上接触一会儿进行加热,然后上焊料焊接两侧。加热焊接面的目的是为了确保焊料可以粘附且不会过早冷却下来。
|
||||
|
||||
不能让焊料/焊点加热过度,热量会通过接触面烧毁原件(融毁开关外壳等)。并且,由于焊锡中有帮助[“浸润”](https://en.m.wikipedia.org/wiki/Wetting)(即上锡)的助焊剂,加热的越久助焊剂蒸发掉的越多,最终导致焊接点虚焊,除了看起来糟糕外,还有导致电路短路的风险。
|
||||
|
||||
#### 焊接二极管
|
||||
|
||||
从左上角的那个开关开始,将二极管放到开关上(用镊子,如果有的话)并纵向放直,有黑线的一端朝向你。让二极管间并联(二极管的阴极不应连接到其它二极管的阳极),二极管的阳极应连接到开关的左引脚上,而弯曲的阴极应朝向右边放置,如图:
|
||||
|
||||

|
||||
|
||||
在放稳二极管后,拿起焊锡,将其与左轴脚同时接触到电烙铁上 - 在松香的帮助下焊锡会很容易地覆盖在二极管及轴脚上。二极管可能会有些位移,此时你可以抓住二极管另外一端弯折过的引脚,小心地放回到位置上 - 但请留意另一端是会迅速变得烫手的。如果二极管容易乱跑,可以使用尖嘴钳之类的东西在焊接时辅助保持稳固。
|
||||
|
||||
松香加热时升起的烟有害,注意保护口鼻,不要熏到眼睛或皮肤。
|
||||
|
||||
焊接到位时,可以将焊点升起的烟吹走以免熏脸,也能帮助焊点快速降温。焊点在冷却后会形成沙哑状(无光泽)的表面,但请注意此时它依旧非常烫,需要几分钟时间的冷却才可以触摸,多吹吹有助于快速冷却。
|
||||
|
||||
在第一个二极管焊接完毕后,第二个二极管需要焊接轴脚以及上一个二极管弯折的那一端,看起来像这样:
|
||||
|
||||

|
||||
|
||||
在焊接完毕一整行后,用剪线钳剪掉二极管上方(绕轴脚后多出的部分),以及这一行最后侧多出来的引脚部分。在每一行焊接完毕后都要记得这一步。
|
||||
|
||||
在你完成了所有的二极管的焊接工作后,最好是逐一测试一下以确保焊接牢固稳定 - 再往后不是不能回头修正,但会越来越困难。
|
||||
|
||||
#### 纵向上的焊接
|
||||
|
||||
这一步你有几个可选项需考虑 - 给横向电缆进行绝缘处理是个好主意(毕竟二极管没有绝缘层),但如果你足够小心,横向电缆裸露着也行 - 但仍旧不建议这么做。如果你用的是单芯线,先将外皮整个褪下来再酌情装回去可能是最好的办法,但会因尺寸及材质原因造成操作困难,你可以将线缆上需要焊接到开关轴的部分裸露出来。
|
||||
|
||||
如果你使用多股线/铜绞线,可能最简单的方案就是用不固定长度的小段电线来纵向连接开关。通过融化掉焊接点的外皮的方式来用一整根线不是不可以,但这里不推荐这样做,这种操作会产生更多的有害烟尘,也会毁掉你的电烙铁。
|
||||
|
||||
在进行焊接操作前,先预弯折好线缆(如果是单芯线),或至少心中已经规划好焊接路线顺序(特别是你要做的设计是错列的时)。实际上焊接顺序不是特别重要,因为我们是通过焊接方案来确定键映射定义的 - 只要确保一行上的所有按键都有独自的列,且从左到右依次排列。
|
||||
|
||||
如果你不做任何的绝缘处理,可以将纵向的线升高一些,焊接在轴脚尖端上 - 如果线缆本身足够稳固,不会短路到连接着二极管的横线线缆上。
|
||||
|
||||
## 连接控制器
|
||||
|
||||
在矩阵焊接完成后,可以将其焊接到微控制器板上了。
|
||||
|
||||
将微控制器放在预期的位置上,同时要考虑到安装及外壳对齐问题。须记得USB槽的位置是可以与微控制器分开的,只需使用一小段公对母线接驳下即可。
|
||||
|
||||
找到微控制器板的引脚定义/文档([链接](#common-microcontroller-boards))并将所有的I/O引脚标出来(留意像teensy这种的控制器,模拟I/O引脚可能是数字I/O引脚的两倍),将线缆连接到这些引脚上。
|
||||
|
||||
----
|
||||
|
||||
### 针对 Teensy 2.0 的特殊说明
|
||||
|
||||
Teensy 上的部分引脚有点特殊,像 D6(片上LED),及一些 UART、SPI、I2C或PWM通道,不过只是在你计划着在键盘上还有其它功能设计时才需避免使用。如果你还不是很确定以后会不会增加什么功能上去,引脚应该还是足够充足到可以剩一部分出来的。
|
||||
|
||||
那些无论在什么控制器上都不应去使用的引脚,有:GND、VCC、AREF以及RST - 其它所有引脚都是可以用且也能在固件中访问的到的。
|
||||
|
||||
----
|
||||
|
||||
|
||||
将电线切割为控制器到各行/列上某一点距离的长度。可以焊到各行的任意位置上,只需要确保是在二极管之后 - 焊接到二极管前面(轴脚侧)的话该行将无法正常使用。
|
||||
|
||||
这里用排线的话会显得非常整洁,你也可以考虑如何排布线缆以连接到各行/列的近处。
|
||||
|
||||
<img src="https://i.imgur.com/z2QlKfB.jpg" alt="排线" width="350"/>
|
||||
|
||||
在往控制器上焊接电线时,请记住各引脚连接的是哪一行/列,在后续制作固件时我们需要用到这些信息来定义矩阵。
|
||||
|
||||
在你往下继续以前,请确保控制器已装配到位 - 切掉线缆再重新焊接非常麻烦!
|
||||
|
||||
|
||||
## 一些基础的固件配置
|
||||
|
||||
至此,在你构建好固件后,键盘就应该能正常工作了。
|
||||
|
||||
通过 [Keyboard Firmware Builder](https://kbfirmware.com/) 网站可以轻松地创建一个简单的固件。通过 [Keyboard Layout Editor](https://www.keyboard-layout-editor.com) 可以自己制作配列数据,之后就可以导入进来并重新构建矩阵信息(如果你没有在先前的 [设计矩阵](#planning-the-matrix) 完成的话)。
|
||||
|
||||
继续完成剩下的步骤,在逐一配置完所有的按键后就可以编译下载固件了。其中 .hex 文件可以用来直接刷写到键盘上,而 .zip 包中的源代码可以用来添加高级功能并通过 [构建第一个固件](zh-cn/newbs_building_firmware?id=build-your-firmware) 中详述的方法进行本地构建。
|
||||
|
||||
Keyboard Firmware Builder提供的源代码是QMK的,但版本是2017年初的。如果要用现今版本的QMK来构建 .zip 中的源代码,需要在打开 .zip 后遵循以下几步:
|
||||
|
||||
1. 解压 `kb` 目录到 `qmk_firmware/keyboards/handwired/`。
|
||||
2. 进入解压的 `kb` 目录,转到 `keymaps/default/` 目录下,打开 `keymap.c`。
|
||||
3. 找到并删除 `action_get_macro` 代码段:
|
||||
```
|
||||
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
|
||||
...
|
||||
return MACRO_NONE;
|
||||
}
|
||||
```
|
||||
4. 保存并关闭 `keymap.c`。
|
||||
|
||||
## 刷写固件
|
||||
|
||||
安装 [QMK Toolbox](https://github.com/qmk/qmk_toolbox).
|
||||
|
||||

|
||||
|
||||
在 “Local File” 栏处定位到你新创建的 .hex 文件,在 “MicroController” 中选择你的控制器板(常见型号[这里](#common-microcontroller-boards)有)。
|
||||
|
||||
插上你的键盘后在QMK Toolbox中点击reset(重置)按钮(如果没有重置按钮,短接一下Reset和接地引脚)再点击“Flash”(刷写)按钮。
|
||||
|
||||
|
||||
## 测试固件
|
||||
|
||||
可以用 [QMK配置器的键盘测试器](https://config.qmk.fm/#/test)、[Keyboard Tester](https://www.keyboardtester.com/tester.html) 或 [Keyboard Checker](https://keyboardchecker.com/) 进行测试,也可以打开一个文本编辑器并试着输入 - 你应该能成功输入键映射方案中的所有字符。对每个按键进行测试,并记录下不能正常工作的按键。对这些不能正常工作的按键,这里有一个快速排查指引:
|
||||
|
||||
1. 将键盘翻过来,用一段金属物短接一下轴脚 - 这么做可以排除掉需要更换掉的坏轴的可能性。
|
||||
2. 检查轴脚上的焊点 - 应该是饱满且完整覆盖的。如果你稍加用力就能将其弄下来,那么就是焊接不到位。
|
||||
3. 检查二极管的焊点 - 如果二极管虚焊了,部分行可以使用,但其它的可能就不行了。
|
||||
4. 检查连接到各行的焊点 - 如果这里虚焊了,这些行就无法正常使用。
|
||||
5. 检查 Teensy 两侧的进/出线的焊点 - 两侧的线缆都必须确保已被良好地焊接。
|
||||
6. 检查 `<project_name>.h` 文件中是否有错误或不当的 `KC_NO` - 如果不确定在哪里,用已有的 k*xy* 变量替换一下。
|
||||
7. 检查固件文件确实经过编译且正确刷写到Teensy上了。除非你在终端看到了错误消息,或是刷写时出现了弹框,否则一切应该是正常的。
|
||||
8. 使用万用表实测一下,触发开关时是否成功闭合(按下时可以连通电路)。
|
||||
|
||||
如果你完成了上述所有检查,应当留意有时可能是多种因素共同造成了开关的异常,因此最后将其短路掉来排查问题并没有什么害处。
|
||||
|
||||
## 即将完成
|
||||
|
||||
在确认键盘可以正常使用后,如果你用的是独立的控制器模块(非手工构建用),须将其固定好。办法有很多,比如热熔胶、双面胶带、3D打印的盒子、电工胶带等。
|
||||
|
||||
如果你觉得成就感满满,可以试着增加一些额外的功能,比如 [轴内LED](https://geekhack.org/index.php?topic=94258.0),[轴内RGB](https://www.reddit.com/r/MechanicalKeyboards/comments/5s1l5u/photoskeyboard_science_i_made_a_handwired_rgb/),[RGB背光](https://medium.com/@DavidNZ/hand-wired-custom-keyboard-cdd14429c7b3#.7a1ovebsk) 甚至可以是 [OLED显示屏!](https://www.reddit.com/r/olkb/comments/5zy7og/adding_ssd1306_oled_display_to_your_build/)
|
||||
|
||||
固件的潜力非常大 - 阅览 [docs.qmk.fm](https://docs.qmk.fm) 可以看到全部功能的列表,也能深入了解人们是如何使用那些五花八门的键盘的。随时欢迎到 [OLKB subreddit](https://reddit.com/r/olkb) 或 [QMK Discord](https://discord.gg/Uq7gcHh) 上寻求帮助!
|
||||
|
||||
## 其它指引链接
|
||||
|
||||
- [matt3o 的分步指引 (BrownFox build)](https://deskthority.net/viewtopic.php?f=7&t=6050) 以及他的 [个人站点](https://matt3o.com/hand-wiring-a-custom-keyboard/) 和 [指导视频](https://www.youtube.com/watch?v=LVzpsjFWPP4)
|
||||
- [Cribbit:“现代化的手工搭建指南 - 强大,简洁,友好”](https://geekhack.org/index.php?topic=87689.0)
|
||||
- [Sasha Solomon:“打造我的第一把键盘”](https://medium.com/@sachee/building-my-first-keyboard-and-you-can-too-512c0f8a4c5f)
|
||||
- [RoastPotatoe: “如何手工搭建Planck键盘”](https://blog.roastpotatoes.co/guide/2015/11/04/how-to-handwire-a-planck/)
|
||||
- [Masterzen:“手工搭建键盘记录”](https://www.masterzen.fr/2018/12/16/handwired-keyboard-build-log-part-1/)
|
||||
|
||||
|
||||
# 遗留内容
|
||||
|
||||
以前本页内还有其它内容,现在我们已经将他们单独分离出去了。以下的内容是一些重定向链接,以供那些从老链接地址过来的人能找到自己要找的内容。
|
||||
|
||||
## 序: 键盘矩阵是如何工作的(以及为什么需要二极管) :id=preamble-how-a-keyboard-matrix-works-and-why-we-need-diodes
|
||||
|
||||
* [键盘矩阵是如何工作的](zh-cn/how_a_matrix_works.md)
|
||||
209
docs/zh-cn/keymap.md
Normal file
209
docs/zh-cn/keymap.md
Normal file
@@ -0,0 +1,209 @@
|
||||
# 键映射总览
|
||||
|
||||
<!---
|
||||
original document: 0.15.12:docs/keymap.md
|
||||
git diff 0.15.12 HEAD -- docs/keymap.md | cat
|
||||
-->
|
||||
|
||||
QMK键映射定义在C源文件中,其数据结构上是一个容纳了数组的数组。外层数组容纳了各个层,内层各数组则为层内的键列表。基本所有键盘都通过定义 `LAYOUT()` 宏来创建该两级数组。
|
||||
|
||||
|
||||
## 键映射与配列 :id=keymap-and-layers
|
||||
在QMK中, **`const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS]`** 容纳了多个 **层**, 每个**层**下包含了由**16位**的**动作码**所组成的键映射信息。 最多可以定义**32个层**。
|
||||
|
||||
对于常规键的定义,其**动作码**的高8位皆为0,低8位保存了USB HID中使用的各个键对应的**键码**。
|
||||
|
||||
不同的层可以同时生效,层的编号从0至31,编号越高的层优先级越高。
|
||||
(译注:由于是ascii图,掺杂中文会导致排版错乱,各翻译标注在图下方。下同)
|
||||
|
||||
Keymap: 32 Layers Layer: action code matrix
|
||||
----------------- ---------------------
|
||||
stack of layers array_of_action_code[row][column]
|
||||
____________ precedence _______________________
|
||||
/ / | high / ESC / F1 / F2 / F3 ....
|
||||
31 /___________// | /-----/-----/-----/-----
|
||||
30 /___________// | / TAB / Q / W / E ....
|
||||
29 /___________/ | /-----/-----/-----/-----
|
||||
: _:_:_:_:_:__ | : /LCtrl/ A / S / D ....
|
||||
: / : : : : : / | : / : : : :
|
||||
2 /___________// | 2 `--------------------------
|
||||
1 /___________// | 1 `--------------------------
|
||||
0 /___________/ V low 0 `--------------------------
|
||||
翻译:
|
||||
|
||||
|原文 |译文 |
|
||||
|--------------------------|-------------|
|
||||
|Keymap: 32 Layers | 键映射:32个层|
|
||||
|stack of layers | 层堆栈 |
|
||||
|precedence | 优先级 |
|
||||
|high/low | 高/低 |
|
||||
|layer: action code matrix | 层:动作码矩阵|
|
||||
|row/column | 行/列 |
|
||||
|
||||
有时,键映射中存储的动作码在一些文档中也被称作键码,主要是由TMK沿袭而来的习惯。
|
||||
|
||||
### 键映射的层状态 :id=keymap-layer-status
|
||||
|
||||
键映射的层状态由两个32位参数决定:
|
||||
|
||||
* **`default_layer_state`** 指向一个总是可用的键映射层(0-31)(即默认层)。
|
||||
* **`layer_state`** 每一位标记对应层的启用/停用状态。
|
||||
|
||||
通常键映射中的'0'层为 `default_layer(默认层)`,其它层在启动时会被固件置为停用状态,不过这些可以通过 `config.h` 进行配置。当你换了一个按键布局时可用于更改 `default_layer`,比如从Qwerty布局切换到了Colemak布局。
|
||||
|
||||
Initial state of Keymap Change base layout
|
||||
----------------------- ------------------
|
||||
|
||||
31 31
|
||||
30 30
|
||||
29 29
|
||||
: :
|
||||
: : ____________
|
||||
2 ____________ 2 / /
|
||||
1 / / ,->1 /___________/
|
||||
,->0 /___________/ | 0
|
||||
| |
|
||||
`--- default_layer = 0 `--- default_layer = 1
|
||||
layer_state = 0x00000001 layer_state = 0x00000002
|
||||
翻译:
|
||||
|
||||
|原文 |译文 |
|
||||
|-----------------------|-------------|
|
||||
|Initial state of Keymap| 键映射原始状态|
|
||||
|Change base layout | 更改了基础层 |
|
||||
|
||||
另外,可以通过修改 `layer_state` 做到其他层对基础层的覆盖,以实现诸如导航键、功能键(F1-F12)、多媒体键等特殊动作。
|
||||
|
||||
Overlay feature layer
|
||||
--------------------- bit|status
|
||||
____________ ---+------
|
||||
31 / / 31 | 0
|
||||
30 /___________// -----> 30 | 1
|
||||
29 /___________/ -----> 29 | 1
|
||||
: : | :
|
||||
: ____________ : | :
|
||||
2 / / 2 | 0
|
||||
,->1 /___________/ -----> 1 | 1
|
||||
| 0 0 | 0
|
||||
| +
|
||||
`--- default_layer = 1 |
|
||||
layer_state = 0x60000002 <-'
|
||||
|
||||
|
||||
|
||||
### 层优先级及穿透
|
||||
须记住**层堆栈中更高的层有着更高的优先级**。固件会从最高的活跃层开始向下找键码,一旦固件在活跃层上找到了一个非 `KC_TRNS`(穿透)键码,就会停止查找,再往下的层级不会被查看。
|
||||
|
||||
____________
|
||||
/ / <--- 较高的层
|
||||
/ KC_TRNS //
|
||||
/___________// <--- 较低的层 (KC_A)
|
||||
/___________/
|
||||
|
||||
这个场景中,较高层级中的非穿透键是可用的,如果定义为 `KC_TRNS`(及同等效果的),较低层级的键码 `KC_A` 将被采纳。
|
||||
|
||||
**注意:** 在层中定义合法的穿透键的方法有:
|
||||
* `KC_TRANSPARENT`
|
||||
* `KC_TRNS`(别名)
|
||||
* `_______`(别名)
|
||||
|
||||
这些键码允许在搜索非穿透键码时可以穿透当前层下落到更低层去。
|
||||
|
||||
## `keymap.c` 文件解析
|
||||
|
||||
本例中我们将深入到[Clueboard 66%的一款旧版的默认键映射](https://github.com/qmk/qmk_firmware/blob/ca01d94005f67ec4fa9528353481faa622d949ae/keyboards/clueboard/keymaps/default/keymap.c)方案中去。将该文件在另一个浏览器窗口中打开,以便对照本文进行同步阅览。
|
||||
|
||||
在一个 `keymap.c` 文件中会有三个你可能会关心的部分:
|
||||
|
||||
* [预定义](#definitions)
|
||||
* [层/键映射数据结构](#layers-and-keymaps)
|
||||
* [自定义函数](#custom-functions),若有的话
|
||||
|
||||
### 预定义
|
||||
|
||||
文件头部可以看到:
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
|
||||
// Helpful defines
|
||||
// 译:便捷性的宏定义
|
||||
#define GRAVE_MODS (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT)|MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI)|MOD_BIT(KC_LALT)|MOD_BIT(KC_RALT))
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* You can use _______ in place for KC_TRNS (transparent) *
|
||||
* Or you can use XXXXXXX for KC_NO (NOOP) *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
// 译:可以用 _______ 替代 KC_TRNS(穿透),用 XXXXXXX 替代 KC_NO (空操作)
|
||||
|
||||
// Each layer gets a name for readability.
|
||||
// The underscores don't mean anything - you can
|
||||
// have a layer called STUFF or any other name.
|
||||
// Layer names don't all need to be of the same
|
||||
// length, and you can also skip them entirely
|
||||
// and just use numbers.
|
||||
// 译:每一层为了便于识别可以起一个名字,下划线没有实际意义 - 叫STUFF之类的也行的,
|
||||
// 译:层名不需要都一样长,甚至不定义这些直接用层号也是可以的
|
||||
#define _BL 0
|
||||
#define _FL 1
|
||||
#define _CL 2
|
||||
|
||||
以上是一些便于编写键映射及自定义函数时可用的预定义,`GRAVE_MODS` 后续会用在自定义函数中,之后的 `_BL`, `_FL` 及 `_CL` 便于我们在代码中引用这些层。
|
||||
|
||||
注:在一些更早的键映射文件中,你可能会发现一些形如 `_______` 或 `XXXXXXX` 的定义,这些可以分别代替 `KC_TRNS` 及 `KC_NO`,这样可以更清楚地分辨出各层中定义了哪些键的键值。现在这些定义是不需要的,因为我们默认已经提供了这些定义。
|
||||
|
||||
### 层和键映射
|
||||
|
||||
这个文件中最主要的部分是 `keymaps[]` 定义,这里须列出你的层以及层中的内容。这一部分应该以如下定义起始:
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
之后是一个LAYOUT()宏组成的列表,一个LAYOUT()下定义了一个层中的键列表,一般你需要至少一个“基础层”(如QWERTY、Dvorak或Colemak),之后是在其之上的多个“功能”层。受限于对层的处理顺序,较低的层无法覆盖在较高的层上。
|
||||
|
||||
QMK在 `keymaps[][MATRIX_ROWS][MATRIX_COLS]` 中保存着16位的动作码(有些时候也被称作键码),对于与常规键一致的键码,其高字节为0,低字节为USB HID 键盘所使用的键码值。
|
||||
|
||||
> QMK的前身TMK中使用 `const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS]` 来存储8位的键码,一些键码被保留用于引用执行 `fn_actions[]` 数组中的特定功能。
|
||||
|
||||
#### 基础层
|
||||
|
||||
以下示例是Clueboard的基础层定义:
|
||||
|
||||
/* Keymap _BL: Base Layer (Default Layer)
|
||||
*/
|
||||
[_BL] = LAYOUT(
|
||||
F(0), KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_GRV, KC_BSPC, KC_PGUP, \
|
||||
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_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_NUHS, KC_ENT, \
|
||||
KC_LSFT, KC_NUBS, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RO, KC_RSFT, KC_UP, \
|
||||
KC_LCTL, KC_LGUI, KC_LALT, KC_MHEN, KC_SPC,KC_SPC, KC_HENK, KC_RALT, KC_RCTL, MO(_FL), KC_LEFT, KC_DOWN, KC_RGHT),
|
||||
|
||||
这里有一些值得留意的地方:
|
||||
|
||||
* 站在C语言源代码的角度看,这只是一个数组,但我们掺杂了大量括号使得每个键可以在视觉上与物理设备对齐。
|
||||
* 常规的键盘扫描码以KC_起始,而那些“特殊”键则不是。
|
||||
* 最左上的键可以触发自定义函数0(`F(0)`)
|
||||
* "Fn"键定义为 `MO(_FL)`,当按住该键时会切换到 `_FL` 层。
|
||||
|
||||
#### 功能覆盖层
|
||||
|
||||
对于功能层,从代码角度讲与基础层没有任何区别。但在概念上讲,应该将其作为覆盖层而非替代层来定义。对大部分人来讲这个区别不重要,但当你构建越来越复杂的层结构时,其重要性会越来越凸显。
|
||||
|
||||
[_FL] = LAYOUT(
|
||||
KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, KC_DEL, BL_STEP, \
|
||||
_______, _______, _______,_______,_______,_______,_______,_______,KC_PSCR,KC_SLCK, KC_PAUS, _______, _______, _______, _______, \
|
||||
_______, _______, MO(_CL),_______,_______,_______,_______,_______,_______,_______, _______, _______, _______, _______, \
|
||||
_______, _______, _______,_______,_______,_______,_______,_______,_______,_______, _______, _______, _______, _______, KC_PGUP, \
|
||||
_______, _______, _______, _______, _______,_______, _______, _______, _______, MO(_FL), KC_HOME, KC_PGDN, KC_END),
|
||||
|
||||
这里值得留意的有:
|
||||
|
||||
* 我们使用 `_______` 定义来替代 `KC_TRNS`, 以便凸显在该层中有变化的那些键。
|
||||
* 对于这一层来讲,如果点击的是一个 `_______` 键,实际生效的将是其下的活跃层中的键。
|
||||
|
||||
# 核心细节
|
||||
|
||||
在阅读完本节后,你应该掌握了构建自己的键映射的基础能力,更多的资料请参见:
|
||||
|
||||
* [键码](zh-cn/keycodes.md)
|
||||
* [键映射FAQ](zh-cn/faq_keymap.md)
|
||||
|
||||
我们仍在优化这份文档,如果你有更好的优化建议,请[提交一份issue](https://github.com/qmk/qmk_firmware/issues/new)!
|
||||
143
docs/zh-cn/mod_tap.md
Normal file
143
docs/zh-cn/mod_tap.md
Normal file
@@ -0,0 +1,143 @@
|
||||
# Mod-Tap
|
||||
|
||||
<!---
|
||||
original document: 0.15.12:docs/mod_tap.md
|
||||
git diff 0.15.12 HEAD -- docs/mod_tap.md | cat
|
||||
-->
|
||||
|
||||
Mod-Tap键 `MT(mod, kc)` 在按住时功能为修饰键,在点击时则是常规键码。举例来讲,可以设计出一个按键,当点击时发送Escape,按下时则作为Control或Shift
|
||||
|
||||
修饰键码及`OSM()`将会被缀以`MOD_`前缀,而非`KC_`
|
||||
|
||||
|修饰键码 |描述 |
|
||||
|----------|------------------------------------------|
|
||||
|`MOD_LCTL`|左Control |
|
||||
|`MOD_LSFT`|左Shift |
|
||||
|`MOD_LALT`|左Alt |
|
||||
|`MOD_LGUI`|左GUI (Windows/Command/Meta键) |
|
||||
|`MOD_RCTL`|右Control |
|
||||
|`MOD_RSFT`|右Shift |
|
||||
|`MOD_RALT`|右Alt (AltGr) |
|
||||
|`MOD_RGUI`|右GUI (Windows/Command/Meta键) |
|
||||
|`MOD_HYPR`|Hyper (左Control, Shift, Alt 及 GUI同时按下)|
|
||||
|`MOD_MEH` |Meh (左Control, Shift, 及 Alt同时按下) |
|
||||
|
||||
可以通过逻辑或进行组合:
|
||||
|
||||
```c
|
||||
MT(MOD_LCTL | MOD_LSFT, KC_ESC)
|
||||
```
|
||||
|
||||
此时按住该键将触发左Control及左Shift,点击将发送Escape。
|
||||
|
||||
为了方便配列,QMK已包含一些常见的Mod-Tap:
|
||||
|
||||
|键 |别名 |描述 |
|
||||
|------------|-----------------------------------------------------------------|---------------------------------------------|
|
||||
|`LCTL_T(kc)`|`CTL_T(kc)` |按住时为左Control,点击时为 `kc` |
|
||||
|`LSFT_T(kc)`|`SFT_T(kc)` |按住时为左Shift,点击时为 `kc` |
|
||||
|`LALT_T(kc)`|`LOPT_T(kc)`, `ALT_T(kc)`, `OPT_T(kc)` |按住时为左Alt,点击时为 `kc` |
|
||||
|`LGUI_T(kc)`|`LCMD_T(kc)`, `LWIN_T(kc)`, `GUI_T(kc)`, `CMD_T(kc)`, `WIN_T(kc)`|按住时为左GUI,点击时为 `kc` |
|
||||
|`RCTL_T(kc)`| |按住时为右 Control,点击时为 `kc` |
|
||||
|`RSFT_T(kc)`| |按住时为右 Shift,点击时为 `kc` |
|
||||
|`RALT_T(kc)`|`ROPT_T(kc)`, `ALGR_T(kc)` |按住时为右 Alt,点击时为 `kc` |
|
||||
|`RGUI_T(kc)`|`RCMD_T(kc)`, `RWIN_T(kc)` |按住时为右 GUI,点击时为 `kc` |
|
||||
|`LSG_T(kc)` |`SGUI_T(kc)`, `SCMD_T(kc)`, `SWIN_T(kc)` |按住时为左Shift及GUI,点击时为 `kc` |
|
||||
|`LAG_T(kc)` | |按住时为左Alt及GUI,点击时为 `kc` |
|
||||
|`RSG_T(kc)` | |按住时为右 Shift及GUI,点击时为 `kc` |
|
||||
|`RAG_T(kc)` | |按住时为右 Alt及GUI,点击时为 `kc` |
|
||||
|`LCA_T(kc)` | |按住时为左Control及Alt,点击时为 `kc` |
|
||||
|`LSA_T(kc)` | |按住时为左Shift及Alt,点击时为 `kc` |
|
||||
|`RSA_T(kc)` |`SAGR_T(kc)` |按住时为右 Shift及右 Alt (AltGr),点击时为 `kc` |
|
||||
|`RCS_T(kc)` | |按住时为右 Control及右 Shift,点击时为 `kc` |
|
||||
|`LCAG_T(kc)`| |按住时为左Control,Alt及GUI,点击时为 `kc` |
|
||||
|`RCAG_T(kc)`| |按住时为右 Control,Alt及GUI,点击时为 `kc` |
|
||||
|`C_S_T(kc)` | |按住时为左Control及Shift,点击时为 `kc` |
|
||||
|`MEH_T(kc)` | |按住时为左Control,Shift及Alt,点击时为 `kc` |
|
||||
|`HYPR_T(kc)`|`ALL_T(kc)` |按住时为左Control,Shift,Alt及GUI,点击时为 `kc` - 更多[参见这里](https://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/)|
|
||||
|
||||
## 注意
|
||||
|
||||
目前 `MT()` 的 `kc`参数限制在[基础键码集](zh-cn/keycodes_basic.md)中,因此不能使用 `LCTL()`,`KC_TILD` 及其它大于 `0xFF` 的键码。原因是,QMK使用16位的键码,其中3位是功能标记,1位标记左右修饰键,4位存储修饰键码,仅剩8位存储键码。当一次Mod-Tap触发时,只要有一个右修饰键被激发,其它的修饰键也都被视为右修饰键,因此无法混搭形如左Control+右Shift的形式,会被视为右Control+右Shift
|
||||
|
||||
若展开讲就比较复杂了。迁移到32位的键码可以很大程度解决这个问题,但同时会招致配列矩阵大小翻倍,也可能会有其它未知问题。若是想用修饰键配合按键,可以考虑使用[Tap Dance/多击键](zh-cn/feature_tap_dance.md#example-5-using-tap-dance-for-advanced-mod-tap-and-layer-tap-keys)
|
||||
|
||||
在使用Windows远程桌面时你可能会发现有些问题,这是因为远程桌面对键码响应过快。若要修复,可以打开远程桌面的“配置”,在“本地资源”页中的键盘属性,调整为“本地计算器”,此时功能即可恢复正常。另一个办法是加大[`TAP_CODE_DELAY`](zh-cn/config_options.md#behaviors-that-can-be-configured)。
|
||||
|
||||
## 截获Mod-Taps
|
||||
|
||||
### 改变点击功能
|
||||
|
||||
若要在Mod-Tap中突破基础键码的限制,可以在 `process_record_user` 中实现。如,上档键码 `KC_DQUO` 无法与 `MT()` 共用,因为它实际上是 `LSFT(KC_QUOT)` 的别名,`KC_DQUO` 上的修饰键码会被 `MT()` 覆盖。但可以使用如下代码截获点击,手动发送 `KC_DQUO`:
|
||||
|
||||
```c
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
switch (keycode) {
|
||||
case LCTL_T(KC_DQUO):
|
||||
if (record->tap.count && record->event.pressed) {
|
||||
tap_code16(KC_DQUO); // 点击时发送 KC_DQUO
|
||||
return false; // 通过返回false阻止对该键的其它处理
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
```
|
||||
|
||||
### 改变按住功能
|
||||
|
||||
类似地,同样可以使用这段自定义代码改变按住功能。下面的例子会在 `LT(0, kc)` (layer-tap键无实际意义,因为layer 0默认被激活)按住时对X,C和V键附加剪切,复制和粘贴功能:
|
||||
|
||||
```c
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
switch (keycode) {
|
||||
case LT(0,KC_X):
|
||||
if (record->tap.count && record->event.pressed) {
|
||||
return true; // 返回true来发送常规键码
|
||||
} else if (record->event.pressed) {
|
||||
tap_code16(C(KC_X)); // 截获按住功能来发送Ctrl-X
|
||||
}
|
||||
return false;
|
||||
case LT(0,KC_C):
|
||||
if (record->tap.count && record->event.pressed) {
|
||||
return true; // 返回true来发送常规键码
|
||||
} else if (record->event.pressed) {
|
||||
tap_code16(C(KC_C)); // 截获按住功能来发送Ctrl-C
|
||||
}
|
||||
return false;
|
||||
case LT(0,KC_V):
|
||||
if (record->tap.count && record->event.pressed) {
|
||||
return true; // 返回true来发送常规键码
|
||||
} else if (record->event.pressed) {
|
||||
tap_code16(C(KC_V)); // 截获按住功能来发送Ctrl-V
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
```
|
||||
|
||||
在数字及字母键上使用Mod-Tap时推荐启用 `IGNORE_MOD_TAP_INTERRUPT`,以避免在快速按下下一个键时保持功能优先级。参见[忽略Mod Tap中断](zh-cn/tap_hold.md#ignore-mod-tap-interrupt)。
|
||||
|
||||
### 同时改变点击和按住功能
|
||||
|
||||
最后一个例子通过 `LT(0,KC_NO)` 实现了点击复制,按住粘贴的功能:
|
||||
|
||||
```c
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
switch (keycode) {
|
||||
case LT(0,KC_NO):
|
||||
if (record->tap.count && record->event.pressed) {
|
||||
tap_code16(C(KC_C)); // 截获点击来发送Ctrl-C
|
||||
} else if (record->event.pressed) {
|
||||
tap_code16(C(KC_V)); // 截获按住功能来发送Ctrl-V
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
```
|
||||
|
||||
## 其它信息
|
||||
|
||||
在[点按配置](zh-cn/tap_hold.md)中描述了影响Mod-Tap行为的标记。
|
||||
18
docs/zh-cn/newbs_building_firmware_configurator.md
Normal file
18
docs/zh-cn/newbs_building_firmware_configurator.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# QMK配置器
|
||||
|
||||
<!---
|
||||
original document: 0.15.12:docs/newbs_building_firmware_configurator.md
|
||||
git diff 0.15.12 HEAD -- docs/newbs_building_firmware_configurator.md | cat
|
||||
-->
|
||||
|
||||
[](https://config.qmk.fm/)
|
||||
|
||||
[QMK配置器](https://config.qmk.fm)是一个可用于生成`.hex`和`.bin`格式的QMK固件文件的在线交互页面。
|
||||
|
||||
这里有[视频教程](https://www.youtube.com/watch?v=-imgglzDMdY). 很多人给我们反馈该视频包含了足够多的知识可以用来开始编写自己的键盘程序。
|
||||
|
||||
QMK配置器在Chrome及Firefox中工作良好。
|
||||
|
||||
!> **来自于第三方工具的文件数据无法保证与QMK兼容,如Keyboard Layout Editor(KLE)或kbfirmware,请不要加载或导入这些文件。QMK配置器是一个独立的工具。**
|
||||
|
||||
更多信息请参见[QMK配置器: 入门](zh-cn/configurator_step_by_step.md)。
|
||||
90
docs/zh-cn/other_eclipse.md
Normal file
90
docs/zh-cn/other_eclipse.md
Normal file
@@ -0,0 +1,90 @@
|
||||
# 在Eclipse中设置QMK开发环境
|
||||
|
||||
<!---
|
||||
original document: 0.15.16:docs/other_eclipse.md
|
||||
git diff 0.15.16 HEAD -- docs/other_eclipse.md | cat
|
||||
-->
|
||||
|
||||
|
||||
[Eclipse][1]是一款广泛用于Java开发的[集成开发环境](https://en.wikipedia.org/wiki/Integrated_development_environment)(IDE),但有着强大的插件体系允许自定义开发其它语言及用途。
|
||||
|
||||
相对于使用普通的文本编辑器,使用形如Eclipse这样的IDE有着诸多好处,例如:
|
||||
* 智能代码补全
|
||||
* 快速代码跳转
|
||||
* 重构工具
|
||||
* 构建自动化(无需使用命令行)
|
||||
* 图形化交互的GIT
|
||||
* 静态代码分析
|
||||
* 以及大量其它工具,如调试器,代码格式化,显示调用链等。
|
||||
|
||||
本文专注于阐述如何将Eclipse配置为AVR软件开发环境,并用于基于QMK代码的开发工作。
|
||||
|
||||
注意,在本文编写时,仅在Ubuntu 16.04环境中进行过验证。
|
||||
|
||||
# 需求
|
||||
## 构建环境
|
||||
在开始之前,你需要确保遵循了新手教程中的[新手指引](zh-cn/newbs_getting_started.md)一节。通常,此时你应该具备了[通过 `qmk complile` 命令](zh-cn/newbs_building_firmware.md#build-your-firmware)构建固件文件的能力。
|
||||
|
||||
## Java
|
||||
Eclipse为Java程序,因此需要安装Java 8或更高版本才能运行。你可以选择JRE或JDK,后者在进行Java开发时需要用到。
|
||||
|
||||
# 安装Eclipse及插件
|
||||
Eclipse有[多种可选安装方式](https://www.eclipse.org/downloads/eclipse-packages/),取决于你的使用目标。目前没有完备的AVR开发栈安装包,所以我们需要从Eclipse CDT(C/C++ 开发工具环境)开始并安装对应的插件。
|
||||
|
||||
## 下载安装Eclipse CDT
|
||||
如果系统中已安装了Eclipse CDT,可以跳过本步骤。同时,为了确保版本支持情况,我们推荐保持其更新至最新版。
|
||||
|
||||
如果你已安装了Eclipse包,通常也可以[在上面再安装CDT插件](https://eclipse.org/cdt/downloads.php)。但是可能更好的方案是重新全新安装一下,以确保环境轻量,以及防止已安装的工具对后续的工程开发工作产生干扰。
|
||||
|
||||
安装很简单:遵循[Eclipse安装5步走](https://eclipse.org/downloads/eclipse-packages/?show_instructions=TRUE),并在第三步选择 **用于C/C++开发者的Eclipse IDE(Eclipse IDE for C/C++ Developers)**。
|
||||
|
||||
此外,也可以选择直接[下载 用于C/C++开发者的Eclipse IDE](https://www.eclipse.org/downloads/eclipse-packages/)([最新版直达链接](https://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers/neonr))并解压至任意目录下(会生成 `eclipse` 目录)。
|
||||
|
||||
## 首次运行
|
||||
在安装完毕后,点击<kbd>运行</kbd>按钮。(如果是手动解压的,请在安装目录下双击 `eclipse` 可执行程序
|
||||
|
||||
在提示你选择工作区目录时,选择一个可用于存储Eclipse元数据及工程的目录。**不要选择 `qmk_firmware` 目录**,这是你的项目目录。可以使用其父目录,或其它(最好是空)目录(默认目标目录如果未作他用亦可使用)。
|
||||
|
||||
启动后,点击右上角的<kbd>工作台(Workbench)</kbd>按钮切换到工作台视图(启动时的欢迎页最下方有个确认框可以在下次启动时不再展示欢迎页)。
|
||||
|
||||
## 安装必要的插件
|
||||
注意:无需在每个插件安装完成时重启Eclipse,全部安装完毕后重启一次即可。
|
||||
|
||||
### [AVR插件](https://avr-eclipse.sourceforge.net/)
|
||||
这是最重要的一个插件,可以帮助Eclipse理解AVR下的C语言代码。参照执行[更新网址使用指引](https://avr-eclipse.sourceforge.net/wiki/index.php/Plugin_Download#Update_Site),并允许那些未签名内容产生的警告。
|
||||
|
||||
### [ANSI Escape in Console(命令行下的ANSI转义符)](https://marketplace.eclipse.org/content/ansi-escape-console)
|
||||
该插件可以允许QMK makefile产生的具有颜色标记的构建输出信息能够正确显示。
|
||||
|
||||
1. 打开<kbd>帮助</kbd> > <kbd>Eclipse插件市场…</kbd>
|
||||
2. 搜索_ANSI Escape in Console_
|
||||
3. 点击插件的<samp>安装</samp>按钮
|
||||
4. 跟随安装指引并再次允许那些未签名的内容产生的警告。
|
||||
|
||||
在插件皆安装完毕后,依照提示重启Eclipse。
|
||||
|
||||
# 配置Eclipse QMK环境
|
||||
## 导入工程
|
||||
1. 点击<kbd>文件</kbd> > <kbd>新建</kbd> > <kbd>现有的Makefile工程代码</kbd>
|
||||
2. 在之后这一页中:
|
||||
* 选择仓库所克隆到的目录位置作为 _现有代码位置_;
|
||||
* (可选地)指定一个不同的工程名,如 _QMK_ 或 _Quantum_ ;
|
||||
* 选择 _AVR-GCC Toolchain_;
|
||||
* 其它选项保留不动,点击<kbd>完成</kbd>
|
||||
|
||||

|
||||
|
||||
3. 工程即完成加载及分析,其下的文件可以方便地在左侧的 _Project Explorer_ 中查看了。
|
||||
|
||||
¹ 导入工程时若自定义名称有时会遇到些问题,如果行不通,保留默认的工程名(即目录名,通常是 `qmk_firmware`)再试一次。
|
||||
|
||||
## 构建你的键盘
|
||||
|
||||
我们将默认构建目标从 `all` 调整到我们期望构建的键盘及键映射组合上,即 `kinesis/kint36:stapelberg`。此时,形如清理、构建等工程级别的操作可以很快地执行完毕,而不至于耗费大量时间且导致Eclipse卡住。
|
||||
|
||||
1. 焦点置于工程下的任一编辑器tab中
|
||||
2. 打开`工程` > `属性`窗口, 选择 `C/C++构建` 菜单项并切至 `Behavior` 标签。
|
||||
3. 将 `Make build target`选项中的全量构建 `all` 改为 `kinesis/kint41:stapelberg`。
|
||||
4. 点击 `工程` > `清理...` 以确认配置正确。
|
||||
|
||||
[1]: https://en.wikipedia.org/wiki/Eclipse_(software)
|
||||
122
docs/zh-cn/other_vscode.md
Normal file
122
docs/zh-cn/other_vscode.md
Normal file
@@ -0,0 +1,122 @@
|
||||
# 在Visual Studio Code中设置QMK开发环境
|
||||
|
||||
<!---
|
||||
original document: 0.15.12:docs/other_vscode.md
|
||||
git diff 0.15.12 HEAD -- docs/other_vscode.md | cat
|
||||
-->
|
||||
|
||||
[Visual Studio Code](https://code.visualstudio.com/) (VS Code) 是一款支援非常多种不同编程语言的开源编辑器。
|
||||
|
||||
相比于使用简陋的文本编辑器,形如VS Code这样的多功能编辑器有诸多优势,比如:
|
||||
* 智能的代码补全
|
||||
* 便捷的代码导航
|
||||
* 重构工具
|
||||
* 自动化构建支持(不再需要命令行操作)
|
||||
* 图形化的GIT界面
|
||||
* 调试器、代码格式化、显示调用层级等多种工具
|
||||
|
||||
本章节旨在阐述如何配置VS Code以在其上进行QMK固件开发。
|
||||
|
||||
这份指引提供了在Windows及Ubuntu 18.04下所有的配置方法。
|
||||
|
||||
# 配置VS Code
|
||||
一开始,你需要首先确认所有的构建工具已经安装配置完成,且QMK Firmware仓库已拷贝至本地。前往参阅[新人指引](zh-cn/newbs_getting_started.md)确保已完成初始配置。
|
||||
|
||||
## Windows
|
||||
|
||||
### 依赖项
|
||||
|
||||
* [Git for Windows](https://git-scm.com/download/win) (该链接会自动提示你保存或运行安装包)
|
||||
|
||||
1. 除 `Git LFS (Large File Support)(大文件支援)` 及 `Check daily for Git for Windows updates(每天检查更新)` 外取消所有可选项。
|
||||
2. 将默认编辑器改为 `Use Visual Studio Code as Git's default editor(将VS Code作为默认编辑器)`
|
||||
3. 选择 `Use Git from Git Bash only(仅在Git Bash中使用Git)`,这是应使用的方案。
|
||||
4. 在 `Choosing HTTPS transport backend(选择HTTPS传输服务)` 选项上,皆可。
|
||||
5. 选择 `Checkout as-is, commit Unix-style line endings(检出不作更改,提交时使用Unix风格换行符)`,QMK仓库使用的是Unix style提交。
|
||||
6. 在额外选项页,保持默认选择即可。
|
||||
|
||||
该软件是VS Code支持Git的所需项目,是有可能不去使用它,但直接用它会省很多事。
|
||||
|
||||
* [Git Credential Manager for Windows(Windows版Git凭据管理器)](https://github.com/Microsoft/Git-Credential-Manager-for-Windows/releases) (可选)
|
||||
|
||||
该软件提供了更好的git 凭据加密存储、多因素身份认证(MFA)及私有访问token生成器。
|
||||
|
||||
这个不是严格必须的,但我们依旧推荐使用。
|
||||
|
||||
|
||||
### 安装VS Code
|
||||
|
||||
1. 到[VS Code](https://code.visualstudio.com/)下载安装包
|
||||
2. 运行安装包
|
||||
|
||||
很简单的操作。然而,仍有一些配置我们需要确保是设置正确的。
|
||||
|
||||
### VS Code设置
|
||||
|
||||
首先来配置IntelliSense,虽不是严格必要的,但能让你后续使用便捷**很多**。首先,在QMK Firmware目录下创建文件 `.vscode/c_cpp_properties.json`,之后的操作可以手动完成,但我已经完成了大部分。
|
||||
|
||||
获取[这份文件](https://gist.github.com/drashna/48e2c49ce877be592a1650f91f8473e8),如果你的MSYS2没有安装在默认路径,或在用WSL/LxSS,你可能需要做一下编辑修改。
|
||||
|
||||
在保存妥当后,如果你有已打开的VS Code,你需要reload一下。
|
||||
|
||||
?> 在 `.vscode` 目录下你应该还能看到 `extensions.json` 和 `settings.json` 文件。
|
||||
|
||||
现在,我们配置MSYS2作为VSCode的集成终端。这么做有很多好处,最主要的是可以通过按住control点击错误消息直接跳转到文件,调试起来会简单得多,另外的好处是,你不用在窗口间切换。
|
||||
|
||||
1. 点击 <kbd><kbd>文件</kbd> > <kbd>首选项 ></kbd> > <kbd>设置</kbd> </kbd>
|
||||
2. 点击上方右侧的 <kbd>{}</kbd> 按钮,打开 `settings.json` 文件。
|
||||
3. 将文件改为:
|
||||
|
||||
```json
|
||||
{
|
||||
"terminal.integrated.profiles.windows": {
|
||||
"QMK_MSYS": {
|
||||
"path": "C:/QMK_MSYS/usr/bin/bash.exe",
|
||||
"env": {
|
||||
"MSYSTEM": "MINGW64",
|
||||
"CHERE_INVOKING": "1"
|
||||
},
|
||||
"args": ["--login"]
|
||||
}
|
||||
},
|
||||
|
||||
"terminal.integrated.cursorStyle": "line"
|
||||
}
|
||||
```
|
||||
|
||||
如果该文件内已经有一些配置项,将上面的内容粘贴在最外层的花括号内,并用一个逗号将新旧内容分隔开。
|
||||
|
||||
?> 如果你的MSYS2安装在不同的目录下,你需要将 `terminal.integrated.shell.windows` 更改为你系统中正确的目录。
|
||||
|
||||
4. 点击Ctrl-<code>`</code> (Grave) 或在 <kbd><kbd>视图</kbd> > <kbd>终端</kbd></kbd> 可以打开终端界面 (`workbench.action.terminal.toggleTerminal` 命令)。如果没有终端它会自动打开一个。
|
||||
|
||||
终端应启动于工程目录中(即 `qmk_firmware` 目录),之后你可以构建键盘了。
|
||||
|
||||
|
||||
## 其它系统
|
||||
|
||||
1. 到[VS Code](https://code.visualstudio.com/)下载安装包
|
||||
2. 运行安装包
|
||||
3. 搞定
|
||||
|
||||
是的,确实是搞定了。安装的时候所有所需的路径配置都会被包含进来,在检查当前工程文件并进行IntelliSense解析上表现也会更好。
|
||||
|
||||
## 插件
|
||||
|
||||
有一些你可能感兴趣的扩展可以安装:<!-- 老外自己也分不清plugin和extension啊-_-||| -->
|
||||
|
||||
* [Git Extension Pack](https://marketplace.visualstudio.com/items?itemName=donjayamanne.git-extension-pack) - 提供了一系列的Git工具可以让你在QMK Firmware中使用Git便捷一些。
|
||||
* [EditorConfig for VS Code](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig) - _[可选]_ - 可以让你的代码更符合QMK规范。
|
||||
* [Bracket Pair Colorizer 2](https://marketplace.visualstudio.com/items?itemName=CoenraadS.bracket-pair-colorizer-2) - _[可选]_ - 可以给大括号着色,可以更好地阅读嵌套代码。
|
||||
* [GitHub Markdown Preview](https://marketplace.visualstudio.com/items?itemName=bierner.github-markdown-preview) - _[可选]_ - 使得VS Code下的markdown预览更符合Github的效果。
|
||||
* [VS Live Share Extension Pack](https://marketplace.visualstudio.com/items?itemName=MS-vsliveshare.vsliveshare-pack) - _[可选]_ - 这个扩展允许他人访问你的工作区(或反之)进行协作,在你遇到问题需要他人帮助时挺有用。
|
||||
* [VIM Keymap](https://marketplace.visualstudio.com/items?itemName=GiuseppeCesarano.vim-keymap) - _[可选]_ - 为那些更喜欢VIM风格的按键操作的人所准备。这样的扩展还有挺多。
|
||||
|
||||
安装扩展后需要重启VS Code。
|
||||
|
||||
# 配置VS Code下的QMK
|
||||
1. 点击 <kbd><kbd>文件</kbd> > <kbd>打开目录</kbd></kbd>
|
||||
2. 打开你从Github克隆的QMK固件仓库所在目录。
|
||||
3. 点击 <kbd><kbd>文件</kbd> > <kbd>保存工作区为...</kbd></kbd>
|
||||
|
||||
此时你已完成了在VS Code下编写QMK固件的准备工作。
|
||||
200
docs/zh-cn/reference_configurator_support.md
Normal file
200
docs/zh-cn/reference_configurator_support.md
Normal file
@@ -0,0 +1,200 @@
|
||||
# 在QMK配置器中支持您的键盘
|
||||
|
||||
<!---
|
||||
original document: 0.15.12:docs/reference_configurator_support.md
|
||||
git diff 0.15.12 HEAD -- docs/reference_configurator_support.md | cat
|
||||
-->
|
||||
|
||||
本章节详述了如何在[QMK配置器](https://config.qmk.fm/)中对键盘进行支持。
|
||||
|
||||
|
||||
## 配置器如何理解键盘
|
||||
|
||||
若要了解配置器如何理解键盘,须先理解配列的宏定义。这里有一份练习,假设这里有一个17键的小键盘PCB方案,就叫做 `numpad`。
|
||||
|
||||
```
|
||||
|---------------|
|
||||
|NLk| / | * | - |
|
||||
|---+---+---+---|
|
||||
|7 |8 |9 | + |
|
||||
|---+---+---| |
|
||||
|4 |5 |6 | |
|
||||
|---+---+---+---|
|
||||
|1 |2 |3 |Ent|
|
||||
|-------+---| |
|
||||
|0 | . | |
|
||||
|---------------|
|
||||
```
|
||||
|
||||
?> 配列宏定义的更多资料,参见[理解QMK:矩阵扫描](zh-cn/understanding_qmk.md?id=matrix-scanning)及[理解QMK:矩阵到物理配列的映射](zh-cn/understanding_qmk.md?id=matrix-to-physical-layout-map)。
|
||||
|
||||
配置器的API会从 `qmk_firmware/keyboards/<keyboard>/<keyboard>.h` 中读取键盘定义的 `.h` 文件。在上面的小键盘示例中,对应文件应为 `qmk_firmware/keyboards/numpad/numpad.h`:
|
||||
|
||||
```c
|
||||
#pragma once
|
||||
|
||||
#define LAYOUT( \
|
||||
k00, k01, k02, k03, \
|
||||
k10, k11, k12, k13, \
|
||||
k20, k21, k22, \
|
||||
k30, k31, k32, k33, \
|
||||
k40, k42 \
|
||||
) { \
|
||||
{ k00, k01, k02, k03 }, \
|
||||
{ k10, k11, k12, k13 }, \
|
||||
{ k20, k21, k22, KC_NO }, \
|
||||
{ k30, k31, k32, k33 }, \
|
||||
{ k40, KC_NO, k42, KC_NO } \
|
||||
}
|
||||
```
|
||||
|
||||
QMK使用 `KC_NO` 去标记开关矩阵中的空位。有时也会因方便或调试用途而使用 `XXX`,`___` 或 `____` 来替代。通产定义写在 `.h` 文件起始位置附近:
|
||||
|
||||
```c
|
||||
#pragma once
|
||||
|
||||
#define XXX KC_NO
|
||||
|
||||
#define LAYOUT( \
|
||||
k00, k01, k02, k03, \
|
||||
k10, k11, k12, k13, \
|
||||
k20, k21, k22, \
|
||||
k30, k31, k32, k33, \
|
||||
k40, k42 \
|
||||
) { \
|
||||
{ k00, k01, k02, k03 }, \
|
||||
{ k10, k11, k12, k13 }, \
|
||||
{ k20, k21, k22, XXX }, \
|
||||
{ k30, k31, k32, k33 }, \
|
||||
{ k40, XXX, k42, XXX } \
|
||||
}
|
||||
```
|
||||
|
||||
!> 注意这里的使用模式与键映射中的宏完全不同,后者几乎都在用 `XXXXXXX`(7个大写X)替代 `KC_NO`,用 `_______`(7个下划线)替代 `KC_TRNS`。
|
||||
|
||||
!> 为避免混淆,推荐使用 `KC_NO`。
|
||||
|
||||
配列宏定义描述该键盘有17个按键,分布在五行四列。我们将这些开关命名为 `k<行号><列号>`,从0计起。命名成什么不太重要,但须确保负责从键映射中接收键码的上半段,与描述矩阵中按键位置的下半段定义匹配一致。
|
||||
|
||||
为了能够重现键盘的物理组成样式,须构建并提供一份用于描述按键物理位置和尺寸与开关矩阵绑定关系的JSON文件,以告知配置器程序这些信息。
|
||||
|
||||
## 构建JSON文件
|
||||
|
||||
构建该JSON描述文件最简便的办法是使用[Keyboard Layout Editor](https://www.keyboard-layout-editor.com/) ("KLE"), 从中获取的原始数据(Raw Data)可以经QMK工具转换为配置器可用的JSON格式数据。由于KLE默认打开显示的是一个小键盘配列,请移除新手引导部分,从剩余部分开始使用。
|
||||
|
||||
在配列编辑完毕后,从KLE的原始数据(Raw Data tab)页中拷贝类似如下的内容:
|
||||
|
||||
```
|
||||
["Num Lock","/","*","-"],
|
||||
["7\nHome","8\n↑","9\nPgUp",{h:2},"+"],
|
||||
["4\n←","5","6\n→"],
|
||||
["1\nEnd","2\n↓","3\nPgDn",{h:2},"Enter"],
|
||||
[{w:2},"0\nIns",".\nDel"]
|
||||
```
|
||||
|
||||
要将这份数据转换为我们可用的JSON格式,请跳转至[QMK KLE-JSON转换工具](https://qmk.fm/converter/)页面并粘贴到输入框,点击转换按钮。稍后输出框中即可看到所需的JSON数据。将输出数据拷贝到文本文档中,并命名为 `info.json`,保存到 `numpad.h` 所在目录。
|
||||
|
||||
可以通过 `keyboard_name` 元素来指定键盘名称。这里为了演示,会将每个按键独立分行,以更方便于阅读,这不影响配置器的功能。
|
||||
|
||||
```json
|
||||
{
|
||||
"keyboard_name": "Numpad",
|
||||
"url": "",
|
||||
"maintainer": "qmk",
|
||||
"tags": {
|
||||
"form_factor": "numpad"
|
||||
},
|
||||
"layouts": {
|
||||
"LAYOUT": {
|
||||
"layout": [
|
||||
{"label":"Num Lock", "x":0, "y":0},
|
||||
{"label":"/", "x":1, "y":0},
|
||||
{"label":"*", "x":2, "y":0},
|
||||
{"label":"-", "x":3, "y":0},
|
||||
{"label":"7", "x":0, "y":1},
|
||||
{"label":"8", "x":1, "y":1},
|
||||
{"label":"9", "x":2, "y":1},
|
||||
{"label":"+", "x":3, "y":1, "h":2},
|
||||
{"label":"4", "x":0, "y":2},
|
||||
{"label":"5", "x":1, "y":2},
|
||||
{"label":"6", "x":2, "y":2},
|
||||
{"label":"1", "x":0, "y":3},
|
||||
{"label":"2", "x":1, "y":3},
|
||||
{"label":"3", "x":2, "y":3},
|
||||
{"label":"Enter", "x":3, "y":3, "h":2},
|
||||
{"label":"0", "x":0, "y":4, "w":2},
|
||||
{"label":".", "x":2, "y":4}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`layouts` 对象描述了键盘的物理配列信息,其下的 `LAYOUT` 对象命名须与 `numpad.h` 中的一致,而 `LAYOUT` 下的 `layout` 对象,其下每个JSON对象描述了各物理按键,格式如下:
|
||||
|
||||
```
|
||||
按键名,不会在配置器中展现。
|
||||
|
|
||||
| 按键的X坐标,从键盘左侧开始数。
|
||||
| |
|
||||
| |
|
||||
| | 按键的Y坐标,从键盘上侧(后视角)开始数。
|
||||
| | |
|
||||
↓ ↓ ↓
|
||||
{"label":"Num Lock", "x":0, "y":0},
|
||||
```
|
||||
|
||||
部分对象包含 `"w"` 和 `"h"` 字段,用以描述按键的宽高值。
|
||||
|
||||
?> 关于 `info.json` 文件的详细信息,参见[`info.json` 文件格式](zh-cn/reference_info_json.md)。
|
||||
|
||||
|
||||
## 配置器如何配置按键
|
||||
|
||||
配置器API基于配列宏定义及JSON描述文件创建出键盘的可视化展现,并将每个可视化元素依序绑定到指定的按键:
|
||||
|
||||
配列宏定义中的键 | 所使用的JSON对象
|
||||
:---: | :----
|
||||
k00 | {"label":"Num Lock", "x":0, "y":0}
|
||||
k01 | {"label":"/", "x":1, "y":0}
|
||||
k02 | {"label":"*", "x":2, "y":0}
|
||||
k03 | {"label":"-", "x":3, "y":0}
|
||||
k10 | {"label":"7", "x":0, "y":1}
|
||||
k11 | {"label":"8", "x":1, "y":1}
|
||||
k12 | {"label":"9", "x":2, "y":1}
|
||||
k13 | {"label":"+", "x":3, "y":1, "h":2}
|
||||
k20 | {"label":"4", "x":0, "y":2}
|
||||
k21 | {"label":"5", "x":1, "y":2}
|
||||
k22 | {"label":"6", "x":2, "y":2}
|
||||
k30 | {"label":"1", "x":0, "y":3}
|
||||
k31 | {"label":"2", "x":1, "y":3}
|
||||
k32 | {"label":"3", "x":2, "y":3}
|
||||
k33 | {"label":"Enter", "x":3, "y":3, "h":2}
|
||||
k40 | {"label":"0", "x":0, "y":4, "w":2}
|
||||
k42 | {"label":".", "x":2, "y":4}
|
||||
|
||||
当用户在配置器中选中左上角的按键,并赋予数字区锁定键(NumLock)时,配置器会将 `KC_NLCK` 作为第一个按键进行键映射文件的构建工作,其它按键逻辑类似。其中 `label` 键值未被用到,其用于用户在调试 `info.json` 文件时,可以参考辨认出各按键。
|
||||
|
||||
|
||||
## 问题及副作用
|
||||
|
||||
目前配置器还不支持按键偏转及类似ISO回车键这种非矩形按键。另外,对于纵向上偏离其行的按键 — 特别是像[TKC1800](https://github.com/qmk/qmk_firmware/tree/4ac48a61a66206beaf2fdd5f2939d8bbedd0004c/keyboards/tkc1800/)这种1800配列的键盘中的方向键 — 如果 `info.json` 文件的贡献者没有做出修正,KLE转JSON数据工具将会不知如何处理。
|
||||
|
||||
### 解决方案
|
||||
|
||||
#### 非矩阵形状的按键
|
||||
|
||||
针对ISO回车键的情况,QMK会将其定制化显示成一个矩形键,宽1.25u高2u,按键矩阵的右边与字母区的右边对齐。
|
||||
|
||||

|
||||
*一款60% ISO配列的键盘, 在QMK配置器中的渲染样式。*
|
||||
|
||||
#### 纵向偏移的按键
|
||||
|
||||
对于纵向偏移的按键,将其视作未偏移的样子放入KLE,最后在转换后的JSON文件中,按需编辑其Y偏移值。
|
||||
|
||||

|
||||
*一款1800配列键盘在KLE中的渲染样式,方向键未进行纵向偏移移动。*
|
||||
|
||||

|
||||
*这份Unix差异文件,展示了我们需要在JSON文件中进行的纵向偏移改动。*
|
||||
22
docs/zh-cn/support.md
Normal file
22
docs/zh-cn/support.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# 寻求帮助
|
||||
|
||||
<!---
|
||||
original document: 0.15.12:docs/support.md
|
||||
git diff 0.15.12 HEAD -- docs/support.md | cat
|
||||
-->
|
||||
|
||||
你可以从很多渠道获取QMK帮助。
|
||||
|
||||
在你前往社区进行沟通前,请先阅览我们的社区[行为守则](https://qmk.fm/coc/)
|
||||
|
||||
## 实时沟通
|
||||
|
||||
在你需要帮助时,最便捷的办法是通过我们的[Discord服务器](https://discord.gg/Uq7gcHh)进行沟通,通常会有人在线,也有很多乐于助人的人。
|
||||
|
||||
## OLKB Subreddit
|
||||
|
||||
QMK的官方论坛是[reddit.com](https://reddit.com)上的[/r/olkb](https://reddit.com/r/olkb).
|
||||
|
||||
## GitHub Issues
|
||||
|
||||
你可以在[Github上发Issue](https://github.com/qmk/qmk_firmware/issues),对于需要深入讨论或需要调试的问题,会方便得多。
|
||||
77
docs/zh-cn/syllabus.md
Normal file
77
docs/zh-cn/syllabus.md
Normal file
@@ -0,0 +1,77 @@
|
||||
# QMK大纲
|
||||
|
||||
<!---
|
||||
original document: 0.15.12:docs/syllabus.md
|
||||
git diff 0.15.12 HEAD -- docs/syllabus.md | cat
|
||||
-->
|
||||
|
||||
这一页旨在帮你建立关于QMK的相关基础知识,并提供能引导你成为QMK大师所需的所有概念。
|
||||
|
||||
# 基本概念
|
||||
|
||||
如果你还没有看其它部分,先阅读这一节吧。在阅读了[介绍](zh-cn/newbs.md)之后,你可以制作、编译、刷写一个简单的键映射了,以下文档可以助你充实各系列的知识。
|
||||
|
||||
* **了解如何使用QMK**
|
||||
* [介绍](zh-cn/newbs.md)
|
||||
* [CLI](zh-cn/cli.md)
|
||||
* [GIT](zh-cn/newbs_git_best_practices.md)
|
||||
* **了解键映射**
|
||||
* [层](zh-cn/feature_layers.md)
|
||||
* [键码](zh-cn/keycodes.md)
|
||||
* 含所有可用键码,一些会涉及进阶或高级的话题。
|
||||
* **配置IDE** - 可选的
|
||||
* [Eclipse](zh-cn/other_eclipse.md)
|
||||
* [VS Code](zh-cn/other_vscode.md)
|
||||
|
||||
# 进阶话题
|
||||
|
||||
包含窥探QMK主要功能内部原理的话题。你可以不用阅读这些,然而,跳过这些话题的话,去看高级话题的时候会让你很迷惑。
|
||||
|
||||
* **各功能的配置**
|
||||
<!-- * Configuration Overview FIXME(skullydazed/anyone): write this document -->
|
||||
* [音频](zh-cn/feature_audio.md)
|
||||
* 灯光
|
||||
* [背光](zh-cn/feature_backlight.md)
|
||||
* [LED矩阵](zh-cn/feature_led_matrix.md)
|
||||
* [RGB灯光](zh-cn/feature_rgblight.md)
|
||||
* [RGB矩阵](zh-cn/feature_rgb_matrix.md)
|
||||
* [点按配置](zh-cn/tap_hold.md)
|
||||
* [充分利用AVR的存储空间](zh-cn/squeezing_avr.md)
|
||||
* **深入键映射**
|
||||
* [键映射](zh-cn/keymap.md)
|
||||
* [键码与自定义函数](zh-cn/custom_quantum_functions.md)
|
||||
* 宏
|
||||
* [动态宏](zh-cn/feature_dynamic_macros.md)
|
||||
* [宏](zh-cn/feature_macros.md)
|
||||
* [Tap Dance](zh-cn/feature_tap_dance.md)
|
||||
* [组合键](zh-cn/feature_combo.md)
|
||||
* [用户空间](zh-cn/feature_userspace.md)
|
||||
* [按键重定义](zh-cn/feature_key_overrides.md)
|
||||
|
||||
# 高级话题
|
||||
|
||||
这些话题需要较多基础知识,使用这些高级功能前,你应该对如何通过 `config.h` 和 `rules.mk` 来配置键盘选项非常熟悉。
|
||||
|
||||
* **维护QMK键盘**
|
||||
* [飞线指南](zh-cn/hand_wire.md)
|
||||
* [键盘开发指引](zh-cn/hardware_keyboard_guidelines.md)
|
||||
* [info.json参考资料](zh-cn/reference_info_json.md)
|
||||
* [防抖API](zh-cn/feature_debounce_type.md)
|
||||
* **高级功能**
|
||||
* [Unicode](zh-cn/feature_unicode.md)
|
||||
* [API](zh-cn/api_overview.md)
|
||||
* [Bootmagic Lite](zh-cn/feature_bootmagic.md)
|
||||
* **硬件相关**
|
||||
* [键盘工作原理](zh-cn/how_keyboards_work.md)
|
||||
* [键盘矩阵原理](zh-cn/how_a_matrix_works.md)
|
||||
* [分体键盘](zh-cn/feature_split_keyboard.md)
|
||||
* [速记](zh-cn/feature_stenography.md)
|
||||
* [光标设备](zh-cn/feature_pointing_device.md)
|
||||
* **开发核心知识**
|
||||
* [C编码规范](zh-cn/coding_conventions_c.md)
|
||||
* [兼容的微处理器](zh-cn/compatible_microcontrollers.md)
|
||||
* [自定义矩阵](zh-cn/custom_matrix.md)
|
||||
* [理解QMK](zh-cn/understanding_qmk.md)
|
||||
* **CLI开发**
|
||||
* [编码规范](zh-cn/coding_conventions_python.md)
|
||||
* [CLI开发总览](zh-cn/cli_development.md)
|
||||
60
docs/zh-cn/translating.md
Normal file
60
docs/zh-cn/translating.md
Normal file
@@ -0,0 +1,60 @@
|
||||
# 翻译QMK文档
|
||||
|
||||
<!---
|
||||
original document: 0.15.12:docs/translating.md
|
||||
git diff 0.15.12 HEAD -- docs/translating.md | cat
|
||||
-->
|
||||
|
||||
根目录下(`docs/`)的所有文件应当是英语的 - 其它语言应使用 ISO 639-1 中定义的语言编码建立子目录,后跟随一个 `-` 以及必要的国家编码。[常见的语言编码可见这里](https://www.andiamo.co.uk/resources/iso-language-codes/)。如果此目录不存在,可以新建。每个翻译过的文件的文件名,都应保持与英语版本的一致,以确保超链接的退化兼容性。
|
||||
|
||||
文件夹下的 `_summary.md` 文件中,有链接向其它文件的地址,在翻译过的名称后,跟随的链接前应添加该语言的目录名:
|
||||
|
||||
```markdown
|
||||
* [QMK简介](zh-cn/getting_started_introduction.md)
|
||||
```
|
||||
|
||||
所有导向其它文档页面的链接也必须有语言目录名前缀,若还指向了页面指定位置(即特定的标题),必须使用标题的英文ID,如:
|
||||
|
||||
```markdown
|
||||
[建立你的环境](zh-cn/newbs-getting-started.md#set-up-your-environment)
|
||||
|
||||
## 建立你的环境 :id=set-up-your-environment
|
||||
```
|
||||
|
||||
在翻译后,以下文件也需要进行修改:
|
||||
|
||||
* [`docs/_langs.md`](https://github.com/qmk/qmk_firmware/blob/master/docs/_langs.md)
|
||||
中的每一行应包含该语言国家国旗的[GitHub emoji编码](https://github.com/ikatyang/emoji-cheat-sheet/blob/master/README.md#country-flag)标志:
|
||||
|
||||
```markdown
|
||||
- [:cn: 中文](/zh-cn/)
|
||||
```
|
||||
|
||||
* [`docs/index.html`](https://github.com/qmk/qmk_firmware/blob/master/docs/index.html)
|
||||
`placeholder` 及 `noData` 对象应有一个指向对应语言的入口项:
|
||||
|
||||
```js
|
||||
'/zh-cn/': '没有结果!',
|
||||
```
|
||||
|
||||
用于 "QMK固件" 边栏标题链接的 `nameLink` 同样需要添加对应配置:
|
||||
|
||||
```js
|
||||
'/zh-cn/': '/#/zh-cn/',
|
||||
```
|
||||
|
||||
最后确保在 `fallbackLanguages` 列表中添加该语言项,这样未翻译的文档链接将回退到英文版,而不是出现404页面:
|
||||
|
||||
```js
|
||||
fallbackLanguages: [
|
||||
// ...
|
||||
'zh-cn',
|
||||
// ...
|
||||
],
|
||||
```
|
||||
|
||||
## 预览你的翻译成果
|
||||
|
||||
请阅读[文档预览](zh-cn/contributing.md#previewing-the-documentation)来设置文档的本地预览 - 在页面右上角的 "Translations" 菜单中应当可以看到你翻译的语言的入口。
|
||||
|
||||
当你觉得一切就绪了,请发起pull request给我们吧!
|
||||
35
docs/zh-cn/zh_cn_doc_status.sh
Normal file
35
docs/zh-cn/zh_cn_doc_status.sh
Normal file
@@ -0,0 +1,35 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# Script to display Simplified Chinese translation status of documents
|
||||
# Copied from the japanese one
|
||||
#
|
||||
if [ ! -d docs/zh-cn ]; then
|
||||
echo "'docs/zh-cn' not found."
|
||||
echo "do:"
|
||||
echo " cd \$(QMK_TOP)"
|
||||
echo " ./docs/zh-cn/zh-cn_doc_status.sh"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
en_docs=`cd docs;ls -1 [a-z]*.md`
|
||||
zh_cn_docs=`cd docs/zh-cn;ls -1 [a-z]*.md`
|
||||
en_count=`echo $en_docs | wc -w`
|
||||
zh_cn_count=`echo $zh_cn_docs | wc -w`
|
||||
echo "English documents $en_count files."
|
||||
echo "Simplified Chinese documents $zh_cn_count files."
|
||||
|
||||
echo "Files that have not been translated yet:"
|
||||
for docfile in $en_docs
|
||||
do
|
||||
if [ ! -f docs/zh-cn/$docfile ]; then
|
||||
wc docs/$docfile
|
||||
fi
|
||||
done | sort
|
||||
echo "Files that have not been updated yet:"
|
||||
grep --no-filename "^[ ]*git diff" docs/zh-cn/*.md | while read cmd
|
||||
do
|
||||
cline=`echo $cmd | sh | wc -l`
|
||||
if [ $cline -gt 0 ]; then
|
||||
echo "$cline $cmd"
|
||||
fi
|
||||
done | sort
|
||||
705
drivers/bluetooth/bluefruit_le.cpp
Normal file
705
drivers/bluetooth/bluefruit_le.cpp
Normal file
@@ -0,0 +1,705 @@
|
||||
#include "bluefruit_le.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <alloca.h>
|
||||
#include "debug.h"
|
||||
#include "timer.h"
|
||||
#include "action_util.h"
|
||||
#include "ringbuffer.hpp"
|
||||
#include <string.h>
|
||||
#include "spi_master.h"
|
||||
#include "wait.h"
|
||||
#include "analog.h"
|
||||
#include "progmem.h"
|
||||
|
||||
// These are the pin assignments for the 32u4 boards.
|
||||
// You may define them to something else in your config.h
|
||||
// if yours is wired up differently.
|
||||
#ifndef BLUEFRUIT_LE_RST_PIN
|
||||
# define BLUEFRUIT_LE_RST_PIN D4
|
||||
#endif
|
||||
|
||||
#ifndef BLUEFRUIT_LE_CS_PIN
|
||||
# define BLUEFRUIT_LE_CS_PIN B4
|
||||
#endif
|
||||
|
||||
#ifndef BLUEFRUIT_LE_IRQ_PIN
|
||||
# define BLUEFRUIT_LE_IRQ_PIN E6
|
||||
#endif
|
||||
|
||||
#ifndef BLUEFRUIT_LE_SCK_DIVISOR
|
||||
# define BLUEFRUIT_LE_SCK_DIVISOR 2 // 4MHz SCK/8MHz CPU, calculated for Feather 32U4 BLE
|
||||
#endif
|
||||
|
||||
#define SAMPLE_BATTERY
|
||||
#define ConnectionUpdateInterval 1000 /* milliseconds */
|
||||
|
||||
#ifndef BATTERY_LEVEL_PIN
|
||||
# define BATTERY_LEVEL_PIN B5
|
||||
#endif
|
||||
|
||||
static struct {
|
||||
bool is_connected;
|
||||
bool initialized;
|
||||
bool configured;
|
||||
|
||||
#define ProbedEvents 1
|
||||
#define UsingEvents 2
|
||||
bool event_flags;
|
||||
|
||||
#ifdef SAMPLE_BATTERY
|
||||
uint16_t last_battery_update;
|
||||
uint32_t vbat;
|
||||
#endif
|
||||
uint16_t last_connection_update;
|
||||
} state;
|
||||
|
||||
// Commands are encoded using SDEP and sent via SPI
|
||||
// https://github.com/adafruit/Adafruit_BluefruitLE_nRF51/blob/master/SDEP.md
|
||||
|
||||
#define SdepMaxPayload 16
|
||||
struct sdep_msg {
|
||||
uint8_t type;
|
||||
uint8_t cmd_low;
|
||||
uint8_t cmd_high;
|
||||
struct __attribute__((packed)) {
|
||||
uint8_t len : 7;
|
||||
uint8_t more : 1;
|
||||
};
|
||||
uint8_t payload[SdepMaxPayload];
|
||||
} __attribute__((packed));
|
||||
|
||||
// The recv latency is relatively high, so when we're hammering keys quickly,
|
||||
// we want to avoid waiting for the responses in the matrix loop. We maintain
|
||||
// a short queue for that. Since there is quite a lot of space overhead for
|
||||
// the AT command representation wrapped up in SDEP, we queue the minimal
|
||||
// information here.
|
||||
|
||||
enum queue_type {
|
||||
QTKeyReport, // 1-byte modifier + 6-byte key report
|
||||
QTConsumer, // 16-bit key code
|
||||
#ifdef MOUSE_ENABLE
|
||||
QTMouseMove, // 4-byte mouse report
|
||||
#endif
|
||||
};
|
||||
|
||||
struct queue_item {
|
||||
enum queue_type queue_type;
|
||||
uint16_t added;
|
||||
union __attribute__((packed)) {
|
||||
struct __attribute__((packed)) {
|
||||
uint8_t modifier;
|
||||
uint8_t keys[6];
|
||||
} key;
|
||||
|
||||
uint16_t consumer;
|
||||
struct __attribute__((packed)) {
|
||||
int8_t x, y, scroll, pan;
|
||||
uint8_t buttons;
|
||||
} mousemove;
|
||||
};
|
||||
};
|
||||
|
||||
// Items that we wish to send
|
||||
static RingBuffer<queue_item, 40> send_buf;
|
||||
// Pending response; while pending, we can't send any more requests.
|
||||
// This records the time at which we sent the command for which we
|
||||
// are expecting a response.
|
||||
static RingBuffer<uint16_t, 2> resp_buf;
|
||||
|
||||
static bool process_queue_item(struct queue_item *item, uint16_t timeout);
|
||||
|
||||
enum sdep_type {
|
||||
SdepCommand = 0x10,
|
||||
SdepResponse = 0x20,
|
||||
SdepAlert = 0x40,
|
||||
SdepError = 0x80,
|
||||
SdepSlaveNotReady = 0xFE, // Try again later
|
||||
SdepSlaveOverflow = 0xFF, // You read more data than is available
|
||||
};
|
||||
|
||||
enum ble_cmd {
|
||||
BleInitialize = 0xBEEF,
|
||||
BleAtWrapper = 0x0A00,
|
||||
BleUartTx = 0x0A01,
|
||||
BleUartRx = 0x0A02,
|
||||
};
|
||||
|
||||
enum ble_system_event_bits {
|
||||
BleSystemConnected = 0,
|
||||
BleSystemDisconnected = 1,
|
||||
BleSystemUartRx = 8,
|
||||
BleSystemMidiRx = 10,
|
||||
};
|
||||
|
||||
#define SdepTimeout 150 /* milliseconds */
|
||||
#define SdepShortTimeout 10 /* milliseconds */
|
||||
#define SdepBackOff 25 /* microseconds */
|
||||
#define BatteryUpdateInterval 10000 /* milliseconds */
|
||||
|
||||
static bool at_command(const char *cmd, char *resp, uint16_t resplen, bool verbose, uint16_t timeout = SdepTimeout);
|
||||
static bool at_command_P(const char *cmd, char *resp, uint16_t resplen, bool verbose = false);
|
||||
|
||||
// Send a single SDEP packet
|
||||
static bool sdep_send_pkt(const struct sdep_msg *msg, uint16_t timeout) {
|
||||
spi_start(BLUEFRUIT_LE_CS_PIN, false, 0, BLUEFRUIT_LE_SCK_DIVISOR);
|
||||
uint16_t timerStart = timer_read();
|
||||
bool success = false;
|
||||
bool ready = false;
|
||||
|
||||
do {
|
||||
ready = spi_write(msg->type) != SdepSlaveNotReady;
|
||||
if (ready) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Release it and let it initialize
|
||||
spi_stop();
|
||||
wait_us(SdepBackOff);
|
||||
spi_start(BLUEFRUIT_LE_CS_PIN, false, 0, BLUEFRUIT_LE_SCK_DIVISOR);
|
||||
} while (timer_elapsed(timerStart) < timeout);
|
||||
|
||||
if (ready) {
|
||||
// Slave is ready; send the rest of the packet
|
||||
spi_transmit(&msg->cmd_low, sizeof(*msg) - (1 + sizeof(msg->payload)) + msg->len);
|
||||
success = true;
|
||||
}
|
||||
|
||||
spi_stop();
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
static inline void sdep_build_pkt(struct sdep_msg *msg, uint16_t command, const uint8_t *payload, uint8_t len, bool moredata) {
|
||||
msg->type = SdepCommand;
|
||||
msg->cmd_low = command & 0xFF;
|
||||
msg->cmd_high = command >> 8;
|
||||
msg->len = len;
|
||||
msg->more = (moredata && len == SdepMaxPayload) ? 1 : 0;
|
||||
|
||||
static_assert(sizeof(*msg) == 20, "msg is correctly packed");
|
||||
|
||||
memcpy(msg->payload, payload, len);
|
||||
}
|
||||
|
||||
// Read a single SDEP packet
|
||||
static bool sdep_recv_pkt(struct sdep_msg *msg, uint16_t timeout) {
|
||||
bool success = false;
|
||||
uint16_t timerStart = timer_read();
|
||||
bool ready = false;
|
||||
|
||||
do {
|
||||
ready = readPin(BLUEFRUIT_LE_IRQ_PIN);
|
||||
if (ready) {
|
||||
break;
|
||||
}
|
||||
wait_us(1);
|
||||
} while (timer_elapsed(timerStart) < timeout);
|
||||
|
||||
if (ready) {
|
||||
spi_start(BLUEFRUIT_LE_CS_PIN, false, 0, BLUEFRUIT_LE_SCK_DIVISOR);
|
||||
|
||||
do {
|
||||
// Read the command type, waiting for the data to be ready
|
||||
msg->type = spi_read();
|
||||
if (msg->type == SdepSlaveNotReady || msg->type == SdepSlaveOverflow) {
|
||||
// Release it and let it initialize
|
||||
spi_stop();
|
||||
wait_us(SdepBackOff);
|
||||
spi_start(BLUEFRUIT_LE_CS_PIN, false, 0, BLUEFRUIT_LE_SCK_DIVISOR);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Read the rest of the header
|
||||
spi_receive(&msg->cmd_low, sizeof(*msg) - (1 + sizeof(msg->payload)));
|
||||
|
||||
// and get the payload if there is any
|
||||
if (msg->len <= SdepMaxPayload) {
|
||||
spi_receive(msg->payload, msg->len);
|
||||
}
|
||||
success = true;
|
||||
break;
|
||||
} while (timer_elapsed(timerStart) < timeout);
|
||||
|
||||
spi_stop();
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
static void resp_buf_read_one(bool greedy) {
|
||||
uint16_t last_send;
|
||||
if (!resp_buf.peek(last_send)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (readPin(BLUEFRUIT_LE_IRQ_PIN)) {
|
||||
struct sdep_msg msg;
|
||||
|
||||
again:
|
||||
if (sdep_recv_pkt(&msg, SdepTimeout)) {
|
||||
if (!msg.more) {
|
||||
// We got it; consume this entry
|
||||
resp_buf.get(last_send);
|
||||
dprintf("recv latency %dms\n", TIMER_DIFF_16(timer_read(), last_send));
|
||||
}
|
||||
|
||||
if (greedy && resp_buf.peek(last_send) && readPin(BLUEFRUIT_LE_IRQ_PIN)) {
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (timer_elapsed(last_send) > SdepTimeout * 2) {
|
||||
dprintf("waiting_for_result: timeout, resp_buf size %d\n", (int)resp_buf.size());
|
||||
|
||||
// Timed out: consume this entry
|
||||
resp_buf.get(last_send);
|
||||
}
|
||||
}
|
||||
|
||||
static void send_buf_send_one(uint16_t timeout = SdepTimeout) {
|
||||
struct queue_item item;
|
||||
|
||||
// Don't send anything more until we get an ACK
|
||||
if (!resp_buf.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!send_buf.peek(item)) {
|
||||
return;
|
||||
}
|
||||
if (process_queue_item(&item, timeout)) {
|
||||
// commit that peek
|
||||
send_buf.get(item);
|
||||
dprintf("send_buf_send_one: have %d remaining\n", (int)send_buf.size());
|
||||
} else {
|
||||
dprint("failed to send, will retry\n");
|
||||
wait_ms(SdepTimeout);
|
||||
resp_buf_read_one(true);
|
||||
}
|
||||
}
|
||||
|
||||
static void resp_buf_wait(const char *cmd) {
|
||||
bool didPrint = false;
|
||||
while (!resp_buf.empty()) {
|
||||
if (!didPrint) {
|
||||
dprintf("wait on buf for %s\n", cmd);
|
||||
didPrint = true;
|
||||
}
|
||||
resp_buf_read_one(true);
|
||||
}
|
||||
}
|
||||
|
||||
static bool ble_init(void) {
|
||||
state.initialized = false;
|
||||
state.configured = false;
|
||||
state.is_connected = false;
|
||||
|
||||
setPinInput(BLUEFRUIT_LE_IRQ_PIN);
|
||||
|
||||
spi_init();
|
||||
|
||||
// Perform a hardware reset
|
||||
setPinOutput(BLUEFRUIT_LE_RST_PIN);
|
||||
writePinHigh(BLUEFRUIT_LE_RST_PIN);
|
||||
writePinLow(BLUEFRUIT_LE_RST_PIN);
|
||||
wait_ms(10);
|
||||
writePinHigh(BLUEFRUIT_LE_RST_PIN);
|
||||
|
||||
wait_ms(1000); // Give it a second to initialize
|
||||
|
||||
state.initialized = true;
|
||||
return state.initialized;
|
||||
}
|
||||
|
||||
static inline uint8_t min(uint8_t a, uint8_t b) {
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
||||
static bool read_response(char *resp, uint16_t resplen, bool verbose) {
|
||||
char *dest = resp;
|
||||
char *end = dest + resplen;
|
||||
|
||||
while (true) {
|
||||
struct sdep_msg msg;
|
||||
|
||||
if (!sdep_recv_pkt(&msg, 2 * SdepTimeout)) {
|
||||
dprint("sdep_recv_pkt failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (msg.type != SdepResponse) {
|
||||
*resp = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t len = min(msg.len, end - dest);
|
||||
if (len > 0) {
|
||||
memcpy(dest, msg.payload, len);
|
||||
dest += len;
|
||||
}
|
||||
|
||||
if (!msg.more) {
|
||||
// No more data is expected!
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure the response is NUL terminated
|
||||
*dest = 0;
|
||||
|
||||
// "Parse" the result text; we want to snip off the trailing OK or ERROR line
|
||||
// Rewind past the possible trailing CRLF so that we can strip it
|
||||
--dest;
|
||||
while (dest > resp && (dest[0] == '\n' || dest[0] == '\r')) {
|
||||
*dest = 0;
|
||||
--dest;
|
||||
}
|
||||
|
||||
// Look back for start of preceeding line
|
||||
char *last_line = strrchr(resp, '\n');
|
||||
if (last_line) {
|
||||
++last_line;
|
||||
} else {
|
||||
last_line = resp;
|
||||
}
|
||||
|
||||
bool success = false;
|
||||
static const char kOK[] PROGMEM = "OK";
|
||||
|
||||
success = !strcmp_P(last_line, kOK);
|
||||
|
||||
if (verbose || !success) {
|
||||
dprintf("result: %s\n", resp);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
static bool at_command(const char *cmd, char *resp, uint16_t resplen, bool verbose, uint16_t timeout) {
|
||||
const char * end = cmd + strlen(cmd);
|
||||
struct sdep_msg msg;
|
||||
|
||||
if (verbose) {
|
||||
dprintf("ble send: %s\n", cmd);
|
||||
}
|
||||
|
||||
if (resp) {
|
||||
// They want to decode the response, so we need to flush and wait
|
||||
// for all pending I/O to finish before we start this one, so
|
||||
// that we don't confuse the results
|
||||
resp_buf_wait(cmd);
|
||||
*resp = 0;
|
||||
}
|
||||
|
||||
// Fragment the command into a series of SDEP packets
|
||||
while (end - cmd > SdepMaxPayload) {
|
||||
sdep_build_pkt(&msg, BleAtWrapper, (uint8_t *)cmd, SdepMaxPayload, true);
|
||||
if (!sdep_send_pkt(&msg, timeout)) {
|
||||
return false;
|
||||
}
|
||||
cmd += SdepMaxPayload;
|
||||
}
|
||||
|
||||
sdep_build_pkt(&msg, BleAtWrapper, (uint8_t *)cmd, end - cmd, false);
|
||||
if (!sdep_send_pkt(&msg, timeout)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (resp == NULL) {
|
||||
uint16_t now = timer_read();
|
||||
while (!resp_buf.enqueue(now)) {
|
||||
resp_buf_read_one(false);
|
||||
}
|
||||
uint16_t later = timer_read();
|
||||
if (TIMER_DIFF_16(later, now) > 0) {
|
||||
dprintf("waited %dms for resp_buf\n", TIMER_DIFF_16(later, now));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return read_response(resp, resplen, verbose);
|
||||
}
|
||||
|
||||
bool at_command_P(const char *cmd, char *resp, uint16_t resplen, bool verbose) {
|
||||
char *cmdbuf = (char *)alloca(strlen_P(cmd) + 1);
|
||||
strcpy_P(cmdbuf, cmd);
|
||||
return at_command(cmdbuf, resp, resplen, verbose);
|
||||
}
|
||||
|
||||
bool bluefruit_le_is_connected(void) {
|
||||
return state.is_connected;
|
||||
}
|
||||
|
||||
bool bluefruit_le_enable_keyboard(void) {
|
||||
char resbuf[128];
|
||||
|
||||
if (!state.initialized && !ble_init()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
state.configured = false;
|
||||
|
||||
// Disable command echo
|
||||
static const char kEcho[] PROGMEM = "ATE=0";
|
||||
// Make the advertised name match the keyboard
|
||||
static const char kGapDevName[] PROGMEM = "AT+GAPDEVNAME=" STR(PRODUCT);
|
||||
// Turn on keyboard support
|
||||
static const char kHidEnOn[] PROGMEM = "AT+BLEHIDEN=1";
|
||||
|
||||
// Adjust intervals to improve latency. This causes the "central"
|
||||
// system (computer/tablet) to poll us every 10-30 ms. We can't
|
||||
// set a smaller value than 10ms, and 30ms seems to be the natural
|
||||
// processing time on my macbook. Keeping it constrained to that
|
||||
// feels reasonable to type to.
|
||||
static const char kGapIntervals[] PROGMEM = "AT+GAPINTERVALS=10,30,,";
|
||||
|
||||
// Reset the device so that it picks up the above changes
|
||||
static const char kATZ[] PROGMEM = "ATZ";
|
||||
|
||||
// Turn down the power level a bit
|
||||
static const char kPower[] PROGMEM = "AT+BLEPOWERLEVEL=-12";
|
||||
static PGM_P const configure_commands[] PROGMEM = {
|
||||
kEcho, kGapIntervals, kGapDevName, kHidEnOn, kPower, kATZ,
|
||||
};
|
||||
|
||||
uint8_t i;
|
||||
for (i = 0; i < sizeof(configure_commands) / sizeof(configure_commands[0]); ++i) {
|
||||
PGM_P cmd;
|
||||
memcpy_P(&cmd, configure_commands + i, sizeof(cmd));
|
||||
|
||||
if (!at_command_P(cmd, resbuf, sizeof(resbuf))) {
|
||||
dprintf("failed BLE command: %S: %s\n", cmd, resbuf);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
state.configured = true;
|
||||
|
||||
// Check connection status in a little while; allow the ATZ time
|
||||
// to kick in.
|
||||
state.last_connection_update = timer_read();
|
||||
fail:
|
||||
return state.configured;
|
||||
}
|
||||
|
||||
static void set_connected(bool connected) {
|
||||
if (connected != state.is_connected) {
|
||||
if (connected) {
|
||||
dprint("BLE connected\n");
|
||||
} else {
|
||||
dprint("BLE disconnected\n");
|
||||
}
|
||||
state.is_connected = connected;
|
||||
|
||||
// TODO: if modifiers are down on the USB interface and
|
||||
// we cut over to BLE or vice versa, they will remain stuck.
|
||||
// This feels like a good point to do something like clearing
|
||||
// the keyboard and/or generating a fake all keys up message.
|
||||
// However, I've noticed that it takes a couple of seconds
|
||||
// for macOS to to start recognizing key presses after BLE
|
||||
// is in the connected state, so I worry that doing that
|
||||
// here may not be good enough.
|
||||
}
|
||||
}
|
||||
|
||||
void bluefruit_le_task(void) {
|
||||
char resbuf[48];
|
||||
|
||||
if (!state.configured && !bluefruit_le_enable_keyboard()) {
|
||||
return;
|
||||
}
|
||||
resp_buf_read_one(true);
|
||||
send_buf_send_one(SdepShortTimeout);
|
||||
|
||||
if (resp_buf.empty() && (state.event_flags & UsingEvents) && readPin(BLUEFRUIT_LE_IRQ_PIN)) {
|
||||
// Must be an event update
|
||||
if (at_command_P(PSTR("AT+EVENTSTATUS"), resbuf, sizeof(resbuf))) {
|
||||
uint32_t mask = strtoul(resbuf, NULL, 16);
|
||||
|
||||
if (mask & BleSystemConnected) {
|
||||
set_connected(true);
|
||||
} else if (mask & BleSystemDisconnected) {
|
||||
set_connected(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (timer_elapsed(state.last_connection_update) > ConnectionUpdateInterval) {
|
||||
bool shouldPoll = true;
|
||||
if (!(state.event_flags & ProbedEvents)) {
|
||||
// Request notifications about connection status changes.
|
||||
// This only works in SPIFRIEND firmware > 0.6.7, which is why
|
||||
// we check for this conditionally here.
|
||||
// Note that at the time of writing, HID reports only work correctly
|
||||
// with Apple products on firmware version 0.6.7!
|
||||
// https://forums.adafruit.com/viewtopic.php?f=8&t=104052
|
||||
if (at_command_P(PSTR("AT+EVENTENABLE=0x1"), resbuf, sizeof(resbuf))) {
|
||||
at_command_P(PSTR("AT+EVENTENABLE=0x2"), resbuf, sizeof(resbuf));
|
||||
state.event_flags |= UsingEvents;
|
||||
}
|
||||
state.event_flags |= ProbedEvents;
|
||||
|
||||
// leave shouldPoll == true so that we check at least once
|
||||
// before relying solely on events
|
||||
} else {
|
||||
shouldPoll = false;
|
||||
}
|
||||
|
||||
static const char kGetConn[] PROGMEM = "AT+GAPGETCONN";
|
||||
state.last_connection_update = timer_read();
|
||||
|
||||
if (at_command_P(kGetConn, resbuf, sizeof(resbuf))) {
|
||||
set_connected(atoi(resbuf));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SAMPLE_BATTERY
|
||||
if (timer_elapsed(state.last_battery_update) > BatteryUpdateInterval && resp_buf.empty()) {
|
||||
state.last_battery_update = timer_read();
|
||||
|
||||
state.vbat = analogReadPin(BATTERY_LEVEL_PIN);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool process_queue_item(struct queue_item *item, uint16_t timeout) {
|
||||
char cmdbuf[48];
|
||||
char fmtbuf[64];
|
||||
|
||||
// Arrange to re-check connection after keys have settled
|
||||
state.last_connection_update = timer_read();
|
||||
|
||||
#if 1
|
||||
if (TIMER_DIFF_16(state.last_connection_update, item->added) > 0) {
|
||||
dprintf("send latency %dms\n", TIMER_DIFF_16(state.last_connection_update, item->added));
|
||||
}
|
||||
#endif
|
||||
|
||||
switch (item->queue_type) {
|
||||
case QTKeyReport:
|
||||
strcpy_P(fmtbuf, PSTR("AT+BLEKEYBOARDCODE=%02x-00-%02x-%02x-%02x-%02x-%02x-%02x"));
|
||||
snprintf(cmdbuf, sizeof(cmdbuf), fmtbuf, item->key.modifier, item->key.keys[0], item->key.keys[1], item->key.keys[2], item->key.keys[3], item->key.keys[4], item->key.keys[5]);
|
||||
return at_command(cmdbuf, NULL, 0, true, timeout);
|
||||
|
||||
case QTConsumer:
|
||||
strcpy_P(fmtbuf, PSTR("AT+BLEHIDCONTROLKEY=0x%04x"));
|
||||
snprintf(cmdbuf, sizeof(cmdbuf), fmtbuf, item->consumer);
|
||||
return at_command(cmdbuf, NULL, 0, true, timeout);
|
||||
|
||||
#ifdef MOUSE_ENABLE
|
||||
case QTMouseMove:
|
||||
strcpy_P(fmtbuf, PSTR("AT+BLEHIDMOUSEMOVE=%d,%d,%d,%d"));
|
||||
snprintf(cmdbuf, sizeof(cmdbuf), fmtbuf, item->mousemove.x, item->mousemove.y, item->mousemove.scroll, item->mousemove.pan);
|
||||
if (!at_command(cmdbuf, NULL, 0, true, timeout)) {
|
||||
return false;
|
||||
}
|
||||
strcpy_P(cmdbuf, PSTR("AT+BLEHIDMOUSEBUTTON="));
|
||||
if (item->mousemove.buttons & MOUSE_BTN1) {
|
||||
strcat(cmdbuf, "L");
|
||||
}
|
||||
if (item->mousemove.buttons & MOUSE_BTN2) {
|
||||
strcat(cmdbuf, "R");
|
||||
}
|
||||
if (item->mousemove.buttons & MOUSE_BTN3) {
|
||||
strcat(cmdbuf, "M");
|
||||
}
|
||||
if (item->mousemove.buttons == 0) {
|
||||
strcat(cmdbuf, "0");
|
||||
}
|
||||
return at_command(cmdbuf, NULL, 0, true, timeout);
|
||||
#endif
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void bluefruit_le_send_keys(uint8_t hid_modifier_mask, uint8_t *keys, uint8_t nkeys) {
|
||||
struct queue_item item;
|
||||
bool didWait = false;
|
||||
|
||||
item.queue_type = QTKeyReport;
|
||||
item.key.modifier = hid_modifier_mask;
|
||||
item.added = timer_read();
|
||||
|
||||
while (nkeys >= 0) {
|
||||
item.key.keys[0] = keys[0];
|
||||
item.key.keys[1] = nkeys >= 1 ? keys[1] : 0;
|
||||
item.key.keys[2] = nkeys >= 2 ? keys[2] : 0;
|
||||
item.key.keys[3] = nkeys >= 3 ? keys[3] : 0;
|
||||
item.key.keys[4] = nkeys >= 4 ? keys[4] : 0;
|
||||
item.key.keys[5] = nkeys >= 5 ? keys[5] : 0;
|
||||
|
||||
if (!send_buf.enqueue(item)) {
|
||||
if (!didWait) {
|
||||
dprint("wait for buf space\n");
|
||||
didWait = true;
|
||||
}
|
||||
send_buf_send_one();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (nkeys <= 6) {
|
||||
return;
|
||||
}
|
||||
|
||||
nkeys -= 6;
|
||||
keys += 6;
|
||||
}
|
||||
}
|
||||
|
||||
void bluefruit_le_send_consumer_key(uint16_t usage) {
|
||||
struct queue_item item;
|
||||
|
||||
item.queue_type = QTConsumer;
|
||||
item.consumer = usage;
|
||||
|
||||
while (!send_buf.enqueue(item)) {
|
||||
send_buf_send_one();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MOUSE_ENABLE
|
||||
void bluefruit_le_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan, uint8_t buttons) {
|
||||
struct queue_item item;
|
||||
|
||||
item.queue_type = QTMouseMove;
|
||||
item.mousemove.x = x;
|
||||
item.mousemove.y = y;
|
||||
item.mousemove.scroll = scroll;
|
||||
item.mousemove.pan = pan;
|
||||
item.mousemove.buttons = buttons;
|
||||
|
||||
while (!send_buf.enqueue(item)) {
|
||||
send_buf_send_one();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
uint32_t bluefruit_le_read_battery_voltage(void) {
|
||||
return state.vbat;
|
||||
}
|
||||
|
||||
bool bluefruit_le_set_mode_leds(bool on) {
|
||||
if (!state.configured) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// The "mode" led is the red blinky one
|
||||
at_command_P(on ? PSTR("AT+HWMODELED=1") : PSTR("AT+HWMODELED=0"), NULL, 0);
|
||||
|
||||
// Pin 19 is the blue "connected" LED; turn that off too.
|
||||
// When turning LEDs back on, don't turn that LED on if we're
|
||||
// not connected, as that would be confusing.
|
||||
at_command_P(on && state.is_connected ? PSTR("AT+HWGPIO=19,1") : PSTR("AT+HWGPIO=19,0"), NULL, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
// https://learn.adafruit.com/adafruit-feather-32u4-bluefruit-le/ble-generic#at-plus-blepowerlevel
|
||||
bool bluefruit_le_set_power_level(int8_t level) {
|
||||
char cmd[46];
|
||||
if (!state.configured) {
|
||||
return false;
|
||||
}
|
||||
snprintf(cmd, sizeof(cmd), "AT+BLEPOWERLEVEL=%d", level);
|
||||
return at_command(cmd, NULL, 0, false);
|
||||
}
|
||||
59
drivers/bluetooth/bluefruit_le.h
Normal file
59
drivers/bluetooth/bluefruit_le.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/* Bluetooth Low Energy Protocol for QMK.
|
||||
* Author: Wez Furlong, 2016
|
||||
* Supports the Adafruit BLE board built around the nRF51822 chip.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "config_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Instruct the module to enable HID keyboard support and reset */
|
||||
extern bool bluefruit_le_enable_keyboard(void);
|
||||
|
||||
/* Query to see if the BLE module is connected */
|
||||
extern bool bluefruit_le_query_is_connected(void);
|
||||
|
||||
/* Returns true if we believe that the BLE module is connected.
|
||||
* This uses our cached understanding that is maintained by
|
||||
* calling ble_task() periodically. */
|
||||
extern bool bluefruit_le_is_connected(void);
|
||||
|
||||
/* Call this periodically to process BLE-originated things */
|
||||
extern void bluefruit_le_task(void);
|
||||
|
||||
/* Generates keypress events for a set of keys.
|
||||
* The hid modifier mask specifies the state of the modifier keys for
|
||||
* this set of keys.
|
||||
* Also sends a key release indicator, so that the keys do not remain
|
||||
* held down. */
|
||||
extern void bluefruit_le_send_keys(uint8_t hid_modifier_mask, uint8_t *keys, uint8_t nkeys);
|
||||
|
||||
/* Send a consumer usage.
|
||||
* (milliseconds) */
|
||||
extern void bluefruit_le_send_consumer_key(uint16_t usage);
|
||||
|
||||
#ifdef MOUSE_ENABLE
|
||||
/* Send a mouse/wheel movement report.
|
||||
* The parameters are signed and indicate positive or negative direction
|
||||
* change. */
|
||||
extern void bluefruit_le_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan, uint8_t buttons);
|
||||
#endif
|
||||
|
||||
/* Compute battery voltage by reading an analog pin.
|
||||
* Returns the integer number of millivolts */
|
||||
extern uint32_t bluefruit_le_read_battery_voltage(void);
|
||||
|
||||
extern bool bluefruit_le_set_mode_leds(bool on);
|
||||
extern bool bluefruit_le_set_power_level(int8_t level);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
101
drivers/bluetooth/rn42.c
Normal file
101
drivers/bluetooth/rn42.c
Normal file
@@ -0,0 +1,101 @@
|
||||
/* Copyright 2021
|
||||
*
|
||||
* 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 "report.h"
|
||||
#include "uart.h"
|
||||
|
||||
#ifndef RN42_BAUD_RATE
|
||||
# define RN42_BAUD_RATE 115200
|
||||
#endif
|
||||
|
||||
// https://cdn.sparkfun.com/datasheets/Wireless/Bluetooth/bluetooth_cr_UG-v1.0r.pdf#G7.663734
|
||||
static inline uint16_t rn42_consumer_usage_to_bitmap(uint16_t usage) {
|
||||
switch (usage) {
|
||||
case AC_HOME:
|
||||
return 0x0001;
|
||||
case AL_EMAIL:
|
||||
return 0x0002;
|
||||
case AC_SEARCH:
|
||||
return 0x0004;
|
||||
case AL_KEYBOARD_LAYOUT:
|
||||
return 0x0008;
|
||||
case AUDIO_VOL_UP:
|
||||
return 0x0010;
|
||||
case AUDIO_VOL_DOWN:
|
||||
return 0x0020;
|
||||
case AUDIO_MUTE:
|
||||
return 0x0040;
|
||||
case TRANSPORT_PLAY_PAUSE:
|
||||
return 0x0080;
|
||||
case TRANSPORT_NEXT_TRACK:
|
||||
return 0x0100;
|
||||
case TRANSPORT_PREV_TRACK:
|
||||
return 0x0200;
|
||||
case TRANSPORT_STOP:
|
||||
return 0x0400;
|
||||
case TRANSPORT_EJECT:
|
||||
return 0x0800;
|
||||
case TRANSPORT_FAST_FORWARD:
|
||||
return 0x1000;
|
||||
case TRANSPORT_REWIND:
|
||||
return 0x2000;
|
||||
case TRANSPORT_STOP_EJECT:
|
||||
return 0x4000;
|
||||
case AL_LOCAL_BROWSER:
|
||||
return 0x8000;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void rn42_init(void) {
|
||||
uart_init(RN42_BAUD_RATE);
|
||||
}
|
||||
|
||||
void rn42_send_keyboard(report_keyboard_t *report) {
|
||||
uart_write(0xFD);
|
||||
uart_write(0x09);
|
||||
uart_write(0x01);
|
||||
uart_write(report->mods);
|
||||
uart_write(0x00);
|
||||
for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) {
|
||||
uart_write(report->keys[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void rn42_send_mouse(report_mouse_t *report) {
|
||||
uart_write(0xFD);
|
||||
uart_write(0x00);
|
||||
uart_write(0x03);
|
||||
uart_write(report->buttons);
|
||||
uart_write(report->x);
|
||||
uart_write(report->y);
|
||||
uart_write(report->v); // should try sending the wheel v here
|
||||
uart_write(report->h); // should try sending the wheel h here
|
||||
uart_write(0x00);
|
||||
}
|
||||
|
||||
void rn42_send_consumer(uint16_t data) {
|
||||
static uint16_t last_data = 0;
|
||||
if (data == last_data) return;
|
||||
last_data = data;
|
||||
uint16_t bitmap = rn42_consumer_usage_to_bitmap(data);
|
||||
uart_write(0xFD);
|
||||
uart_write(0x03);
|
||||
uart_write(0x03);
|
||||
uart_write(bitmap & 0xFF);
|
||||
uart_write((bitmap >> 8) & 0xFF);
|
||||
}
|
||||
25
drivers/bluetooth/rn42.h
Normal file
25
drivers/bluetooth/rn42.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/* Copyright 2021
|
||||
*
|
||||
* 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 "report.h"
|
||||
|
||||
void rn42_init(void);
|
||||
|
||||
void rn42_send_keyboard(report_keyboard_t *report);
|
||||
|
||||
void rn42_send_mouse(report_mouse_t *report);
|
||||
|
||||
void rn42_send_consumer(uint16_t data);
|
||||
376
drivers/flash/flash_spi.c
Normal file
376
drivers/flash/flash_spi.c
Normal file
@@ -0,0 +1,376 @@
|
||||
/*
|
||||
Copyright (C) 2021 Westberry Technology (ChangZhou) Corp., Ltd
|
||||
|
||||
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 <string.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "wait.h"
|
||||
#include "debug.h"
|
||||
#include "timer.h"
|
||||
#include "flash_spi.h"
|
||||
#include "spi_master.h"
|
||||
|
||||
/*
|
||||
The time-out time of spi flash transmission.
|
||||
*/
|
||||
#ifndef EXTERNAL_FLASH_SPI_TIMEOUT
|
||||
# define EXTERNAL_FLASH_SPI_TIMEOUT 1000
|
||||
#endif
|
||||
|
||||
/* ID comands */
|
||||
#define FLASH_CMD_RDID 0x9F /* RDID (Read Identification) */
|
||||
#define FLASH_CMD_RES 0xAB /* RES (Read Electronic ID) */
|
||||
#define FLASH_CMD_REMS 0x90 /* REMS (Read Electronic & Device ID) */
|
||||
|
||||
/* register comands */
|
||||
#define FLASH_CMD_WRSR 0x01 /* WRSR (Write Status register) */
|
||||
#define FLASH_CMD_RDSR 0x05 /* RDSR (Read Status register) */
|
||||
|
||||
/* READ comands */
|
||||
#define FLASH_CMD_READ 0x03 /* READ (1 x I/O) */
|
||||
#define FLASH_CMD_FASTREAD 0x0B /* FAST READ (Fast read data) */
|
||||
#define FLASH_CMD_DREAD 0x3B /* DREAD (1In/2 Out fast read) */
|
||||
|
||||
/* Program comands */
|
||||
#define FLASH_CMD_WREN 0x06 /* WREN (Write Enable) */
|
||||
#define FLASH_CMD_WRDI 0x04 /* WRDI (Write Disable) */
|
||||
#define FLASH_CMD_PP 0x02 /* PP (page program) */
|
||||
|
||||
/* Erase comands */
|
||||
#define FLASH_CMD_SE 0x20 /* SE (Sector Erase) */
|
||||
#define FLASH_CMD_BE 0xD8 /* BE (Block Erase) */
|
||||
#define FLASH_CMD_CE 0x60 /* CE (Chip Erase) hex code: 60 or C7 */
|
||||
|
||||
/* Mode setting comands */
|
||||
#define FLASH_CMD_DP 0xB9 /* DP (Deep Power Down) */
|
||||
#define FLASH_CMD_RDP 0xAB /* RDP (Release from Deep Power Down) */
|
||||
|
||||
/* Status register */
|
||||
#define FLASH_FLAG_WIP 0x01 /* Write in progress bit */
|
||||
#define FLASH_FLAG_WEL 0x02 /* Write enable latch bit */
|
||||
|
||||
// #define DEBUG_FLASH_SPI_OUTPUT
|
||||
|
||||
static bool spi_flash_start(void) {
|
||||
return spi_start(EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN, EXTERNAL_FLASH_SPI_LSBFIRST, EXTERNAL_FLASH_SPI_MODE, EXTERNAL_FLASH_SPI_CLOCK_DIVISOR);
|
||||
}
|
||||
|
||||
static flash_status_t spi_flash_wait_while_busy(void) {
|
||||
uint32_t deadline = timer_read32() + EXTERNAL_FLASH_SPI_TIMEOUT;
|
||||
flash_status_t response = FLASH_STATUS_SUCCESS;
|
||||
uint8_t retval;
|
||||
|
||||
do {
|
||||
bool res = spi_flash_start();
|
||||
if (!res) {
|
||||
dprint("Failed to start SPI! [spi flash wait while busy]\n");
|
||||
return FLASH_STATUS_ERROR;
|
||||
}
|
||||
|
||||
spi_write(FLASH_CMD_RDSR);
|
||||
|
||||
retval = (uint8_t)spi_read();
|
||||
|
||||
spi_stop();
|
||||
|
||||
if (timer_read32() >= deadline) {
|
||||
response = FLASH_STATUS_TIMEOUT;
|
||||
break;
|
||||
}
|
||||
} while (retval & FLASH_FLAG_WIP);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
static flash_status_t spi_flash_write_enable(void) {
|
||||
bool res = spi_flash_start();
|
||||
if (!res) {
|
||||
dprint("Failed to start SPI! [spi flash write enable]\n");
|
||||
return FLASH_STATUS_ERROR;
|
||||
}
|
||||
|
||||
spi_write(FLASH_CMD_WREN);
|
||||
|
||||
spi_stop();
|
||||
|
||||
return FLASH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static flash_status_t spi_flash_write_disable(void) {
|
||||
bool res = spi_flash_start();
|
||||
if (!res) {
|
||||
dprint("Failed to start SPI! [spi flash write disable]\n");
|
||||
return FLASH_STATUS_ERROR;
|
||||
}
|
||||
|
||||
spi_write(FLASH_CMD_WRDI);
|
||||
|
||||
spi_stop();
|
||||
|
||||
return FLASH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* This function is used for read transfer, write transfer and erase transfer. */
|
||||
static flash_status_t spi_flash_transaction(uint8_t cmd, uint32_t addr, uint8_t *data, size_t len) {
|
||||
flash_status_t response = FLASH_STATUS_SUCCESS;
|
||||
uint8_t buffer[EXTERNAL_FLASH_ADDRESS_SIZE + 1];
|
||||
|
||||
buffer[0] = cmd;
|
||||
for (int i = 0; i < EXTERNAL_FLASH_ADDRESS_SIZE; ++i) {
|
||||
buffer[EXTERNAL_FLASH_ADDRESS_SIZE - i] = addr & 0xFF;
|
||||
addr >>= 8;
|
||||
}
|
||||
|
||||
bool res = spi_flash_start();
|
||||
if (!res) {
|
||||
dprint("Failed to start SPI! [spi flash transmit]\n");
|
||||
return FLASH_STATUS_ERROR;
|
||||
}
|
||||
|
||||
response = spi_transmit(buffer, sizeof(buffer));
|
||||
|
||||
if ((!response) && (data != NULL)) {
|
||||
switch (cmd) {
|
||||
case FLASH_CMD_READ:
|
||||
response = spi_receive(data, len);
|
||||
break;
|
||||
case FLASH_CMD_PP:
|
||||
response = spi_transmit(data, len);
|
||||
break;
|
||||
default:
|
||||
response = FLASH_STATUS_ERROR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
spi_stop();
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
void flash_init(void) {
|
||||
spi_init();
|
||||
}
|
||||
|
||||
flash_status_t flash_erase_chip(void) {
|
||||
flash_status_t response = FLASH_STATUS_SUCCESS;
|
||||
|
||||
/* Wait for the write-in-progress bit to be cleared. */
|
||||
response = spi_flash_wait_while_busy();
|
||||
if (response != FLASH_STATUS_SUCCESS) {
|
||||
dprint("Failed to check WIP flag! [spi flash erase chip]\n");
|
||||
return response;
|
||||
}
|
||||
|
||||
/* Enable writes. */
|
||||
response = spi_flash_write_enable();
|
||||
if (response != FLASH_STATUS_SUCCESS) {
|
||||
dprint("Failed to write-enable! [spi flash erase chip]\n");
|
||||
return response;
|
||||
}
|
||||
|
||||
/* Erase Chip. */
|
||||
bool res = spi_flash_start();
|
||||
if (!res) {
|
||||
dprint("Failed to start SPI! [spi flash erase chip]\n");
|
||||
return FLASH_STATUS_ERROR;
|
||||
}
|
||||
spi_write(FLASH_CMD_CE);
|
||||
spi_stop();
|
||||
|
||||
/* Wait for the write-in-progress bit to be cleared.*/
|
||||
response = spi_flash_wait_while_busy();
|
||||
if (response != FLASH_STATUS_SUCCESS) {
|
||||
dprint("Failed to check WIP flag! [spi flash erase chip]\n");
|
||||
return response;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
flash_status_t flash_erase_sector(uint32_t addr) {
|
||||
flash_status_t response = FLASH_STATUS_SUCCESS;
|
||||
|
||||
/* Check that the address exceeds the limit. */
|
||||
if ((addr + (EXTERNAL_FLASH_SECTOR_SIZE)) >= (EXTERNAL_FLASH_SIZE) || ((addr % (EXTERNAL_FLASH_SECTOR_SIZE)) != 0)) {
|
||||
dprintf("Flash erase sector address over limit! [addr:0x%x]\n", (uint32_t)addr);
|
||||
return FLASH_STATUS_ERROR;
|
||||
}
|
||||
|
||||
/* Wait for the write-in-progress bit to be cleared. */
|
||||
response = spi_flash_wait_while_busy();
|
||||
if (response != FLASH_STATUS_SUCCESS) {
|
||||
dprint("Failed to check WIP flag! [spi flash erase sector]\n");
|
||||
return response;
|
||||
}
|
||||
|
||||
/* Enable writes. */
|
||||
response = spi_flash_write_enable();
|
||||
if (response != FLASH_STATUS_SUCCESS) {
|
||||
dprint("Failed to write-enable! [spi flash erase sector]\n");
|
||||
return response;
|
||||
}
|
||||
|
||||
/* Erase Sector. */
|
||||
response = spi_flash_transaction(FLASH_CMD_SE, addr, NULL, 0);
|
||||
if (response != FLASH_STATUS_SUCCESS) {
|
||||
dprint("Failed to erase sector! [spi flash erase sector]\n");
|
||||
return response;
|
||||
}
|
||||
|
||||
/* Wait for the write-in-progress bit to be cleared.*/
|
||||
response = spi_flash_wait_while_busy();
|
||||
if (response != FLASH_STATUS_SUCCESS) {
|
||||
dprint("Failed to check WIP flag! [spi flash erase sector]\n");
|
||||
return response;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
flash_status_t flash_erase_block(uint32_t addr) {
|
||||
flash_status_t response = FLASH_STATUS_SUCCESS;
|
||||
|
||||
/* Check that the address exceeds the limit. */
|
||||
if ((addr + (EXTERNAL_FLASH_BLOCK_SIZE)) >= (EXTERNAL_FLASH_SIZE) || ((addr % (EXTERNAL_FLASH_BLOCK_SIZE)) != 0)) {
|
||||
dprintf("Flash erase block address over limit! [addr:0x%x]\n", (uint32_t)addr);
|
||||
return FLASH_STATUS_ERROR;
|
||||
}
|
||||
|
||||
/* Wait for the write-in-progress bit to be cleared. */
|
||||
response = spi_flash_wait_while_busy();
|
||||
if (response != FLASH_STATUS_SUCCESS) {
|
||||
dprint("Failed to check WIP flag! [spi flash erase block]\n");
|
||||
return response;
|
||||
}
|
||||
|
||||
/* Enable writes. */
|
||||
response = spi_flash_write_enable();
|
||||
if (response != FLASH_STATUS_SUCCESS) {
|
||||
dprint("Failed to write-enable! [spi flash erase block]\n");
|
||||
return response;
|
||||
}
|
||||
|
||||
/* Erase Block. */
|
||||
response = spi_flash_transaction(FLASH_CMD_BE, addr, NULL, 0);
|
||||
if (response != FLASH_STATUS_SUCCESS) {
|
||||
dprint("Failed to erase block! [spi flash erase block]\n");
|
||||
return response;
|
||||
}
|
||||
|
||||
/* Wait for the write-in-progress bit to be cleared.*/
|
||||
response = spi_flash_wait_while_busy();
|
||||
if (response != FLASH_STATUS_SUCCESS) {
|
||||
dprint("Failed to check WIP flag! [spi flash erase block]\n");
|
||||
return response;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
flash_status_t flash_read_block(uint32_t addr, void *buf, size_t len) {
|
||||
flash_status_t response = FLASH_STATUS_SUCCESS;
|
||||
uint8_t * read_buf = (uint8_t *)buf;
|
||||
|
||||
/* Wait for the write-in-progress bit to be cleared. */
|
||||
response = spi_flash_wait_while_busy();
|
||||
if (response != FLASH_STATUS_SUCCESS) {
|
||||
dprint("Failed to check WIP flag! [spi flash read block]\n");
|
||||
memset(read_buf, 0, len);
|
||||
return response;
|
||||
}
|
||||
|
||||
/* Perform read. */
|
||||
response = spi_flash_transaction(FLASH_CMD_READ, addr, read_buf, len);
|
||||
if (response != FLASH_STATUS_SUCCESS) {
|
||||
dprint("Failed to read block! [spi flash read block]\n");
|
||||
memset(read_buf, 0, len);
|
||||
return response;
|
||||
}
|
||||
|
||||
#if defined(CONSOLE_ENABLE) && defined(DEBUG_FLASH_SPI_OUTPUT)
|
||||
dprintf("[SPI FLASH R] 0x%08lX: ", addr);
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
dprintf(" %02X", (int)(((uint8_t *)read_buf)[i]));
|
||||
}
|
||||
dprintf("\n");
|
||||
#endif // DEBUG_FLASH_SPI_OUTPUT
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
flash_status_t flash_write_block(uint32_t addr, const void *buf, size_t len) {
|
||||
flash_status_t response = FLASH_STATUS_SUCCESS;
|
||||
uint8_t * write_buf = (uint8_t *)buf;
|
||||
|
||||
while (len > 0) {
|
||||
uint32_t page_offset = addr % EXTERNAL_FLASH_PAGE_SIZE;
|
||||
size_t write_length = EXTERNAL_FLASH_PAGE_SIZE - page_offset;
|
||||
if (write_length > len) {
|
||||
write_length = len;
|
||||
}
|
||||
|
||||
/* Wait for the write-in-progress bit to be cleared. */
|
||||
response = spi_flash_wait_while_busy();
|
||||
if (response != FLASH_STATUS_SUCCESS) {
|
||||
dprint("Failed to check WIP flag! [spi flash write block]\n");
|
||||
return response;
|
||||
}
|
||||
|
||||
/* Enable writes. */
|
||||
response = spi_flash_write_enable();
|
||||
if (response != FLASH_STATUS_SUCCESS) {
|
||||
dprint("Failed to write-enable! [spi flash write block]\n");
|
||||
return response;
|
||||
}
|
||||
|
||||
#if defined(CONSOLE_ENABLE) && defined(DEBUG_FLASH_SPI_OUTPUT)
|
||||
dprintf("[SPI FLASH W] 0x%08lX: ", addr);
|
||||
for (size_t i = 0; i < write_length; i++) {
|
||||
dprintf(" %02X", (int)(uint8_t)(write_buf[i]));
|
||||
}
|
||||
dprintf("\n");
|
||||
#endif // DEBUG_FLASH_SPI_OUTPUT
|
||||
|
||||
/* Perform the write. */
|
||||
response = spi_flash_transaction(FLASH_CMD_PP, addr, write_buf, write_length);
|
||||
if (response != FLASH_STATUS_SUCCESS) {
|
||||
dprint("Failed to write block! [spi flash write block]\n");
|
||||
return response;
|
||||
}
|
||||
|
||||
write_buf += write_length;
|
||||
addr += write_length;
|
||||
len -= write_length;
|
||||
}
|
||||
|
||||
/* Wait for the write-in-progress bit to be cleared. */
|
||||
response = spi_flash_wait_while_busy();
|
||||
if (response != FLASH_STATUS_SUCCESS) {
|
||||
dprint("Failed to check WIP flag! [spi flash write block]\n");
|
||||
return response;
|
||||
}
|
||||
|
||||
/* Disable writes. */
|
||||
response = spi_flash_write_disable();
|
||||
if (response != FLASH_STATUS_SUCCESS) {
|
||||
dprint("Failed to write-disable! [spi flash write block]\n");
|
||||
return response;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
136
drivers/flash/flash_spi.h
Normal file
136
drivers/flash/flash_spi.h
Normal file
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
Copyright (C) 2021 Westberry Technology (ChangZhou) Corp., Ltd
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/* All the following default configurations are based on MX25L4006E Nor FLASH. */
|
||||
|
||||
/*
|
||||
The slave select pin of the FLASH.
|
||||
This needs to be a normal GPIO pin_t value, such as B14.
|
||||
*/
|
||||
#ifndef EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN
|
||||
# error "No chip select pin defined -- missing EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN"
|
||||
#endif
|
||||
|
||||
/*
|
||||
The clock divisor for SPI to ensure that the MCU is within the
|
||||
specifications of the FLASH chip. Generally this will be PCLK divided by
|
||||
the intended divisor -- check your clock settings and the datasheet of
|
||||
your FLASH.
|
||||
*/
|
||||
#ifndef EXTERNAL_FLASH_SPI_CLOCK_DIVISOR
|
||||
# ifdef __AVR__
|
||||
# define EXTERNAL_FLASH_SPI_CLOCK_DIVISOR 4
|
||||
# else
|
||||
# define EXTERNAL_FLASH_SPI_CLOCK_DIVISOR 8
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
The SPI mode to communicate with the FLASH.
|
||||
*/
|
||||
#ifndef EXTERNAL_FLASH_SPI_MODE
|
||||
# define EXTERNAL_FLASH_SPI_MODE 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
Whether or not the SPI communication between the MCU and FLASH should be
|
||||
LSB-first.
|
||||
*/
|
||||
#ifndef EXTERNAL_FLASH_SPI_LSBFIRST
|
||||
# define EXTERNAL_FLASH_SPI_LSBFIRST false
|
||||
#endif
|
||||
|
||||
/*
|
||||
The Flash address size in bytes, as specified in datasheet.
|
||||
*/
|
||||
#ifndef EXTERNAL_FLASH_ADDRESS_SIZE
|
||||
# define EXTERNAL_FLASH_ADDRESS_SIZE 3
|
||||
#endif
|
||||
|
||||
/*
|
||||
The page size of the FLASH in bytes, as specified in the datasheet.
|
||||
*/
|
||||
#ifndef EXTERNAL_FLASH_PAGE_SIZE
|
||||
# define EXTERNAL_FLASH_PAGE_SIZE 256
|
||||
#endif
|
||||
|
||||
/*
|
||||
The sector size of the FLASH in bytes, as specified in the datasheet.
|
||||
*/
|
||||
#ifndef EXTERNAL_FLASH_SECTOR_SIZE
|
||||
# define EXTERNAL_FLASH_SECTOR_SIZE (4 * 1024L)
|
||||
#endif
|
||||
|
||||
/*
|
||||
The block size of the FLASH in bytes, as specified in the datasheet.
|
||||
*/
|
||||
#ifndef EXTERNAL_FLASH_BLOCK_SIZE
|
||||
# define EXTERNAL_FLASH_BLOCK_SIZE (64 * 1024L)
|
||||
#endif
|
||||
|
||||
/*
|
||||
The total size of the FLASH in bytes, as specified in the datasheet.
|
||||
*/
|
||||
#ifndef EXTERNAL_FLASH_SIZE
|
||||
# define EXTERNAL_FLASH_SIZE (512 * 1024L)
|
||||
#endif
|
||||
|
||||
/*
|
||||
The block count of the FLASH, calculated by total FLASH size and block size.
|
||||
*/
|
||||
#define EXTERNAL_FLASH_BLOCK_COUNT ((EXTERNAL_FLASH_SIZE) / (EXTERNAL_FLASH_BLOCK_SIZE))
|
||||
|
||||
/*
|
||||
The sector count of the FLASH, calculated by total FLASH size and sector size.
|
||||
*/
|
||||
#define EXTERNAL_FLASH_SECTOR_COUNT ((EXTERNAL_FLASH_SIZE) / (EXTERNAL_FLASH_SECTOR_SIZE))
|
||||
|
||||
/*
|
||||
The page count of the FLASH, calculated by total FLASH size and page size.
|
||||
*/
|
||||
#define EXTERNAL_FLASH_PAGE_COUNT ((EXTERNAL_FLASH_SIZE) / (EXTERNAL_FLASH_PAGE_SIZE))
|
||||
|
||||
typedef int16_t flash_status_t;
|
||||
|
||||
#define FLASH_STATUS_SUCCESS (0)
|
||||
#define FLASH_STATUS_ERROR (-1)
|
||||
#define FLASH_STATUS_TIMEOUT (-2)
|
||||
#define FLASH_STATUS_BAD_ADDRESS (-3)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void flash_init(void);
|
||||
|
||||
flash_status_t flash_erase_chip(void);
|
||||
|
||||
flash_status_t flash_erase_block(uint32_t addr);
|
||||
|
||||
flash_status_t flash_erase_sector(uint32_t addr);
|
||||
|
||||
flash_status_t flash_read_block(uint32_t addr, void *buf, size_t len);
|
||||
|
||||
flash_status_t flash_write_block(uint32_t addr, const void *buf, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
108
drivers/gpio/mcp23018.c
Normal file
108
drivers/gpio/mcp23018.c
Normal file
@@ -0,0 +1,108 @@
|
||||
// Copyright 2022 zvecr<git@zvecr.com>
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "mcp23018.h"
|
||||
#include "i2c_master.h"
|
||||
#include "wait.h"
|
||||
#include "debug.h"
|
||||
|
||||
#define SLAVE_TO_ADDR(n) (n << 1)
|
||||
#define TIMEOUT 100
|
||||
|
||||
enum {
|
||||
CMD_IODIRA = 0x00, // i/o direction register
|
||||
CMD_IODIRB = 0x01,
|
||||
CMD_GPPUA = 0x0C, // GPIO pull-up resistor register
|
||||
CMD_GPPUB = 0x0D,
|
||||
CMD_GPIOA = 0x12, // general purpose i/o port register (write modifies OLAT)
|
||||
CMD_GPIOB = 0x13,
|
||||
};
|
||||
|
||||
void mcp23018_init(uint8_t addr) {
|
||||
static uint8_t s_init = 0;
|
||||
if (!s_init) {
|
||||
i2c_init();
|
||||
wait_ms(1000);
|
||||
|
||||
s_init = 1;
|
||||
}
|
||||
}
|
||||
|
||||
bool mcp23018_set_config(uint8_t slave_addr, mcp23018_port_t port, uint8_t conf) {
|
||||
uint8_t addr = SLAVE_TO_ADDR(slave_addr);
|
||||
uint8_t cmdDirection = port ? CMD_IODIRB : CMD_IODIRA;
|
||||
uint8_t cmdPullup = port ? CMD_GPPUB : CMD_GPPUA;
|
||||
|
||||
i2c_status_t ret = i2c_writeReg(addr, cmdDirection, &conf, sizeof(conf), TIMEOUT);
|
||||
if (ret != I2C_STATUS_SUCCESS) {
|
||||
dprintf("mcp23018_set_config::directionFAILED::%u\n", ret);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = i2c_writeReg(addr, cmdPullup, &conf, sizeof(conf), TIMEOUT);
|
||||
if (ret != I2C_STATUS_SUCCESS) {
|
||||
dprintf("mcp23018_set_config::pullupFAILED::%u\n", ret);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool mcp23018_set_output(uint8_t slave_addr, mcp23018_port_t port, uint8_t conf) {
|
||||
uint8_t addr = SLAVE_TO_ADDR(slave_addr);
|
||||
uint8_t cmd = port ? CMD_GPIOB : CMD_GPIOA;
|
||||
|
||||
i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
|
||||
if (ret != I2C_STATUS_SUCCESS) {
|
||||
dprintf("mcp23018_set_output::FAILED::%u\n", ret);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool mcp23018_set_output_all(uint8_t slave_addr, uint8_t confA, uint8_t confB) {
|
||||
uint8_t addr = SLAVE_TO_ADDR(slave_addr);
|
||||
uint8_t conf[2] = {confA, confB};
|
||||
|
||||
i2c_status_t ret = i2c_writeReg(addr, CMD_GPIOA, &conf[0], sizeof(conf), TIMEOUT);
|
||||
if (ret != I2C_STATUS_SUCCESS) {
|
||||
dprintf("mcp23018_set_output::FAILED::%u\n", ret);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool mcp23018_readPins(uint8_t slave_addr, mcp23018_port_t port, uint8_t* out) {
|
||||
uint8_t addr = SLAVE_TO_ADDR(slave_addr);
|
||||
uint8_t cmd = port ? CMD_GPIOB : CMD_GPIOA;
|
||||
|
||||
i2c_status_t ret = i2c_readReg(addr, cmd, out, sizeof(uint8_t), TIMEOUT);
|
||||
if (ret != I2C_STATUS_SUCCESS) {
|
||||
dprintf("mcp23018_readPins::FAILED::%u\n", ret);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool mcp23018_readPins_all(uint8_t slave_addr, uint16_t* out) {
|
||||
uint8_t addr = SLAVE_TO_ADDR(slave_addr);
|
||||
|
||||
typedef union {
|
||||
uint8_t u8[2];
|
||||
uint16_t u16;
|
||||
} data16;
|
||||
|
||||
data16 data = {.u16 = 0};
|
||||
|
||||
i2c_status_t ret = i2c_readReg(addr, CMD_GPIOA, &data.u8[0], sizeof(data), TIMEOUT);
|
||||
if (ret != I2C_STATUS_SUCCESS) {
|
||||
dprintf("mcp23018_readPins::FAILED::%u\n", ret);
|
||||
return false;
|
||||
}
|
||||
|
||||
*out = data.u16;
|
||||
return true;
|
||||
}
|
||||
65
drivers/gpio/mcp23018.h
Normal file
65
drivers/gpio/mcp23018.h
Normal file
@@ -0,0 +1,65 @@
|
||||
// Copyright 2022 zvecr<git@zvecr.com>
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/**
|
||||
* Port ID
|
||||
*/
|
||||
typedef enum {
|
||||
mcp23018_PORTA,
|
||||
mcp23018_PORTB,
|
||||
} mcp23018_port_t;
|
||||
|
||||
/**
|
||||
* Helpers for set_config
|
||||
*/
|
||||
enum {
|
||||
ALL_OUTPUT = 0,
|
||||
ALL_INPUT = 0xFF,
|
||||
};
|
||||
|
||||
/**
|
||||
* Helpers for set_output
|
||||
*/
|
||||
enum {
|
||||
ALL_LOW = 0,
|
||||
ALL_HIGH = 0xFF,
|
||||
};
|
||||
|
||||
/**
|
||||
* Init expander and any other dependent drivers
|
||||
*/
|
||||
void mcp23018_init(uint8_t slave_addr);
|
||||
|
||||
/**
|
||||
* Configure input/output to a given port
|
||||
*/
|
||||
bool mcp23018_set_config(uint8_t slave_addr, mcp23018_port_t port, uint8_t conf);
|
||||
|
||||
/**
|
||||
* Write high/low to a given port
|
||||
*/
|
||||
bool mcp23018_set_output(uint8_t slave_addr, mcp23018_port_t port, uint8_t conf);
|
||||
|
||||
/**
|
||||
* Write high/low to both ports sequentially
|
||||
*
|
||||
* - slightly faster than multiple set_output
|
||||
*/
|
||||
bool mcp23018_set_output_all(uint8_t slave_addr, uint8_t confA, uint8_t confB);
|
||||
|
||||
/**
|
||||
* Read state of a given port
|
||||
*/
|
||||
bool mcp23018_readPins(uint8_t slave_addr, mcp23018_port_t port, uint8_t* ret);
|
||||
|
||||
/**
|
||||
* Read state of both ports sequentially
|
||||
*
|
||||
* - slightly faster than multiple readPins
|
||||
*/
|
||||
bool mcp23018_readPins_all(uint8_t slave_addr, uint16_t* ret);
|
||||
65
drivers/gpio/sn74x138.c
Normal file
65
drivers/gpio/sn74x138.c
Normal file
@@ -0,0 +1,65 @@
|
||||
/* Copyright 2022
|
||||
*
|
||||
* 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 "sn74x138.h"
|
||||
#include "gpio.h"
|
||||
|
||||
#define ADDRESS_PIN_COUNT 3
|
||||
|
||||
#ifndef SN74X138_ADDRESS_PINS
|
||||
# error sn74x138: no address pins defined!
|
||||
#endif
|
||||
|
||||
static const pin_t address_pins[ADDRESS_PIN_COUNT] = SN74X138_ADDRESS_PINS;
|
||||
|
||||
void sn74x138_init(void) {
|
||||
for (int i = 0; i < ADDRESS_PIN_COUNT; i++) {
|
||||
setPinOutput(address_pins[i]);
|
||||
writePinLow(address_pins[i]);
|
||||
}
|
||||
|
||||
#if defined(SN74X138_E1_PIN)
|
||||
setPinOutput(SN74X138_E1_PIN);
|
||||
writePinHigh(SN74X138_E1_PIN);
|
||||
#endif
|
||||
|
||||
#if defined(SN74X138_E2_PIN)
|
||||
setPinOutput(SN74X138_E2_PIN);
|
||||
writePinHigh(SN74X138_E2_PIN);
|
||||
#endif
|
||||
#if defined(SN74X138_E3_PIN)
|
||||
setPinOutput(SN74X138_E3_PIN);
|
||||
writePinLow(SN74X138_E3_PIN);
|
||||
#endif
|
||||
}
|
||||
|
||||
void sn74x138_set_enabled(bool enabled) {
|
||||
#if defined(SN74X138_E1_PIN)
|
||||
writePin(SN74X138_E1_PIN, !enabled);
|
||||
#endif
|
||||
#if defined(SN74X138_E2_PIN)
|
||||
writePin(SN74X138_E2_PIN, !enabled);
|
||||
#endif
|
||||
#if defined(SN74X138_E3_PIN)
|
||||
writePin(SN74X138_E3_PIN, enabled);
|
||||
#endif
|
||||
}
|
||||
|
||||
void sn74x138_set_addr(uint8_t address) {
|
||||
for (int i = 0; i < ADDRESS_PIN_COUNT; i++) {
|
||||
writePin(address_pins[i], address & (1 << i));
|
||||
}
|
||||
}
|
||||
48
drivers/gpio/sn74x138.h
Normal file
48
drivers/gpio/sn74x138.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/* Copyright 2022
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/**
|
||||
* Driver for 74x138 3-to-8 decoder/demultiplexer with inverting outputs
|
||||
* https://assets.nexperia.com/documents/data-sheet/74HC_HCT138.pdf
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initialize the address and output enable pins.
|
||||
*/
|
||||
void sn74x138_init(void);
|
||||
|
||||
/**
|
||||
* Set the enabled state.
|
||||
*
|
||||
* When enabled is true, pulls the E1 and E2 pins low, and the E3 pin high.
|
||||
*
|
||||
* \param enabled The enable state to set.
|
||||
*/
|
||||
void sn74x138_set_enabled(bool enabled);
|
||||
|
||||
/**
|
||||
* Set the output pin address.
|
||||
*
|
||||
* The selected output pin will be pulled low, while the remaining output pins will be high.
|
||||
*
|
||||
* \param address The address to set, from 0 to 7.
|
||||
*/
|
||||
void sn74x138_set_addr(uint8_t address);
|
||||
248
drivers/led/issi/is31fl3733-simple.c
Normal file
248
drivers/led/issi/is31fl3733-simple.c
Normal file
@@ -0,0 +1,248 @@
|
||||
/* Copyright 2017 Jason Williams
|
||||
* Copyright 2018 Jack Humbert
|
||||
* Copyright 2018 Yiancar
|
||||
* Copyright 2021 Doni Crosby
|
||||
* Copyright 2021 Leo Deng
|
||||
*
|
||||
* 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 "is31fl3733-simple.h"
|
||||
#include "i2c_master.h"
|
||||
#include "wait.h"
|
||||
|
||||
// This is a 7-bit address, that gets left-shifted and bit 0
|
||||
// set to 0 for write, 1 for read (as per I2C protocol)
|
||||
// The address will vary depending on your wiring:
|
||||
// 00 <-> GND
|
||||
// 01 <-> SCL
|
||||
// 10 <-> SDA
|
||||
// 11 <-> VCC
|
||||
// ADDR1 represents A1:A0 of the 7-bit address.
|
||||
// ADDR2 represents A3:A2 of the 7-bit address.
|
||||
// The result is: 0b101(ADDR2)(ADDR1)
|
||||
#define ISSI_ADDR_DEFAULT 0x50
|
||||
|
||||
#define ISSI_COMMANDREGISTER 0xFD
|
||||
#define ISSI_COMMANDREGISTER_WRITELOCK 0xFE
|
||||
#define ISSI_INTERRUPTMASKREGISTER 0xF0
|
||||
#define ISSI_INTERRUPTSTATUSREGISTER 0xF1
|
||||
|
||||
#define ISSI_PAGE_LEDCONTROL 0x00 // PG0
|
||||
#define ISSI_PAGE_PWM 0x01 // PG1
|
||||
#define ISSI_PAGE_AUTOBREATH 0x02 // PG2
|
||||
#define ISSI_PAGE_FUNCTION 0x03 // PG3
|
||||
|
||||
#define ISSI_REG_CONFIGURATION 0x00 // PG3
|
||||
#define ISSI_REG_GLOBALCURRENT 0x01 // PG3
|
||||
#define ISSI_REG_RESET 0x11 // PG3
|
||||
#define ISSI_REG_SWPULLUP 0x0F // PG3
|
||||
#define ISSI_REG_CSPULLUP 0x10 // PG3
|
||||
|
||||
#ifndef ISSI_TIMEOUT
|
||||
# define ISSI_TIMEOUT 100
|
||||
#endif
|
||||
|
||||
#ifndef ISSI_PERSISTENCE
|
||||
# define ISSI_PERSISTENCE 0
|
||||
#endif
|
||||
|
||||
#ifndef ISSI_PWM_FREQUENCY
|
||||
# define ISSI_PWM_FREQUENCY 0b000 // PFS - IS31FL3733B only
|
||||
#endif
|
||||
|
||||
#ifndef ISSI_SWPULLUP
|
||||
# define ISSI_SWPULLUP PUR_0R
|
||||
#endif
|
||||
|
||||
#ifndef ISSI_CSPULLUP
|
||||
# define ISSI_CSPULLUP PUR_0R
|
||||
#endif
|
||||
|
||||
// Transfer buffer for TWITransmitData()
|
||||
uint8_t g_twi_transfer_buffer[20];
|
||||
|
||||
// These buffers match the IS31FL3733 PWM registers.
|
||||
// The control buffers match the PG0 LED On/Off registers.
|
||||
// Storing them like this is optimal for I2C transfers to the registers.
|
||||
// We could optimize this and take out the unused registers from these
|
||||
// buffers and the transfers in IS31FL3733_write_pwm_buffer() but it's
|
||||
// probably not worth the extra complexity.
|
||||
uint8_t g_pwm_buffer[LED_DRIVER_COUNT][192];
|
||||
bool g_pwm_buffer_update_required[LED_DRIVER_COUNT] = {false};
|
||||
|
||||
/* There's probably a better way to init this... */
|
||||
#if LED_DRIVER_COUNT == 1
|
||||
uint8_t g_led_control_registers[LED_DRIVER_COUNT][24] = {{0}};
|
||||
#elif LED_DRIVER_COUNT == 2
|
||||
uint8_t g_led_control_registers[LED_DRIVER_COUNT][24] = {{0}, {0}};
|
||||
#elif LED_DRIVER_COUNT == 3
|
||||
uint8_t g_led_control_registers[LED_DRIVER_COUNT][24] = {{0}, {0}, {0}};
|
||||
#elif LED_DRIVER_COUNT == 4
|
||||
uint8_t g_led_control_registers[LED_DRIVER_COUNT][24] = {{0}, {0}, {0}, {0}};
|
||||
#endif
|
||||
bool g_led_control_registers_update_required[LED_DRIVER_COUNT] = {false};
|
||||
|
||||
bool IS31FL3733_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
|
||||
// If the transaction fails function returns false.
|
||||
g_twi_transfer_buffer[0] = reg;
|
||||
g_twi_transfer_buffer[1] = data;
|
||||
|
||||
#if ISSI_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) != 0) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IS31FL3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
|
||||
// Assumes PG1 is already selected.
|
||||
// If any of the transactions fails function returns false.
|
||||
// Transmit PWM registers in 12 transfers of 16 bytes.
|
||||
// g_twi_transfer_buffer[] is 20 bytes
|
||||
|
||||
// Iterate over the pwm_buffer contents at 16 byte intervals.
|
||||
for (int i = 0; i < 192; i += 16) {
|
||||
g_twi_transfer_buffer[0] = i;
|
||||
// Copy the data from i to i+15.
|
||||
// Device will auto-increment register for data after the first byte
|
||||
// Thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer.
|
||||
for (int j = 0; j < 16; j++) {
|
||||
g_twi_transfer_buffer[1 + j] = pwm_buffer[i + j];
|
||||
}
|
||||
|
||||
#if ISSI_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) != 0) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void IS31FL3733_init(uint8_t addr, uint8_t sync) {
|
||||
// In order to avoid the LEDs being driven with garbage data
|
||||
// in the LED driver's PWM registers, shutdown is enabled last.
|
||||
// Set up the mode and other settings, clear the PWM registers,
|
||||
// then disable software shutdown.
|
||||
// Sync is passed so set it according to the datasheet.
|
||||
|
||||
// Unlock the command register.
|
||||
IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
|
||||
|
||||
// Select PG0
|
||||
IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL);
|
||||
// Turn off all LEDs.
|
||||
for (int i = 0x00; i <= 0x17; i++) {
|
||||
IS31FL3733_write_register(addr, i, 0x00);
|
||||
}
|
||||
|
||||
// Unlock the command register.
|
||||
IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
|
||||
|
||||
// Select PG1
|
||||
IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM);
|
||||
// Set PWM on all LEDs to 0
|
||||
// No need to setup Breath registers to PWM as that is the default.
|
||||
for (int i = 0x00; i <= 0xBF; i++) {
|
||||
IS31FL3733_write_register(addr, i, 0x00);
|
||||
}
|
||||
|
||||
// Unlock the command register.
|
||||
IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
|
||||
|
||||
// Select PG3
|
||||
IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_FUNCTION);
|
||||
// Set de-ghost pull-up resistors (SWx)
|
||||
IS31FL3733_write_register(addr, ISSI_REG_SWPULLUP, ISSI_SWPULLUP);
|
||||
// Set de-ghost pull-down resistors (CSx)
|
||||
IS31FL3733_write_register(addr, ISSI_REG_CSPULLUP, ISSI_CSPULLUP);
|
||||
// Set global current to maximum.
|
||||
IS31FL3733_write_register(addr, ISSI_REG_GLOBALCURRENT, 0xFF);
|
||||
// Disable software shutdown.
|
||||
IS31FL3733_write_register(addr, ISSI_REG_CONFIGURATION, ((sync & 0b11) << 6) | ((ISSI_PWM_FREQUENCY & 0b111) << 3) | 0x01);
|
||||
|
||||
// Wait 10ms to ensure the device has woken up.
|
||||
wait_ms(10);
|
||||
}
|
||||
|
||||
void IS31FL3733_set_value(int index, uint8_t value) {
|
||||
if (index >= 0 && index < DRIVER_LED_TOTAL) {
|
||||
is31_led led = g_is31_leds[index];
|
||||
|
||||
g_pwm_buffer[led.driver][led.v] = value;
|
||||
g_pwm_buffer_update_required[led.driver] = true;
|
||||
}
|
||||
}
|
||||
|
||||
void IS31FL3733_set_value_all(uint8_t value) {
|
||||
for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
|
||||
IS31FL3733_set_value(i, value);
|
||||
}
|
||||
}
|
||||
|
||||
void IS31FL3733_set_led_control_register(uint8_t index, bool value) {
|
||||
is31_led led = g_is31_leds[index];
|
||||
|
||||
uint8_t control_register = led.v / 8;
|
||||
uint8_t bit_value = led.v % 8;
|
||||
|
||||
if (value) {
|
||||
g_led_control_registers[led.driver][control_register] |= (1 << bit_value);
|
||||
} else {
|
||||
g_led_control_registers[led.driver][control_register] &= ~(1 << bit_value);
|
||||
}
|
||||
|
||||
g_led_control_registers_update_required[led.driver] = true;
|
||||
}
|
||||
|
||||
void IS31FL3733_update_pwm_buffers(uint8_t addr, uint8_t index) {
|
||||
if (g_pwm_buffer_update_required[index]) {
|
||||
// Firstly we need to unlock the command register and select PG1.
|
||||
IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
|
||||
IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM);
|
||||
|
||||
// If any of the transactions fail we risk writing dirty PG0,
|
||||
// refresh page 0 just in case.
|
||||
if (!IS31FL3733_write_pwm_buffer(addr, g_pwm_buffer[index])) {
|
||||
g_led_control_registers_update_required[index] = true;
|
||||
}
|
||||
g_pwm_buffer_update_required[index] = false;
|
||||
}
|
||||
}
|
||||
|
||||
void IS31FL3733_update_led_control_registers(uint8_t addr, uint8_t index) {
|
||||
if (g_led_control_registers_update_required[index]) {
|
||||
// Firstly we need to unlock the command register and select PG0
|
||||
IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
|
||||
IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL);
|
||||
for (int i = 0; i < 24; i++) {
|
||||
IS31FL3733_write_register(addr, i, g_led_control_registers[index][i]);
|
||||
}
|
||||
g_led_control_registers_update_required[index] = false;
|
||||
}
|
||||
}
|
||||
260
drivers/led/issi/is31fl3733-simple.h
Normal file
260
drivers/led/issi/is31fl3733-simple.h
Normal file
@@ -0,0 +1,260 @@
|
||||
/* Copyright 2017 Jason Williams
|
||||
* Copyright 2018 Jack Humbert
|
||||
* Copyright 2018 Yiancar
|
||||
* Copyright 2021 Doni Crosby
|
||||
* Copyright 2021 Leo Deng
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "progmem.h"
|
||||
|
||||
typedef struct is31_led {
|
||||
uint8_t driver : 2;
|
||||
uint8_t v;
|
||||
} __attribute__((packed)) is31_led;
|
||||
|
||||
extern const is31_led __flash g_is31_leds[DRIVER_LED_TOTAL];
|
||||
|
||||
void IS31FL3733_init(uint8_t addr, uint8_t sync);
|
||||
bool IS31FL3733_write_register(uint8_t addr, uint8_t reg, uint8_t data);
|
||||
bool IS31FL3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
|
||||
|
||||
void IS31FL3733_set_value(int index, uint8_t value);
|
||||
void IS31FL3733_set_value_all(uint8_t value);
|
||||
|
||||
void IS31FL3733_set_led_control_register(uint8_t index, bool value);
|
||||
|
||||
// This should not be called from an interrupt
|
||||
// (eg. from a timer interrupt).
|
||||
// Call this while idle (in between matrix scans).
|
||||
// If the buffer is dirty, it will update the driver with the buffer.
|
||||
void IS31FL3733_update_pwm_buffers(uint8_t addr, uint8_t index);
|
||||
void IS31FL3733_update_led_control_registers(uint8_t addr, uint8_t index);
|
||||
|
||||
#define PUR_0R 0x00 // No PUR resistor
|
||||
#define PUR_05KR 0x02 // 0.5k Ohm resistor in t_NOL
|
||||
#define PUR_3KR 0x03 // 3.0k Ohm resistor on all the time
|
||||
#define PUR_4KR 0x04 // 4.0k Ohm resistor on all the time
|
||||
#define PUR_8KR 0x05 // 8.0k Ohm resistor on all the time
|
||||
#define PUR_16KR 0x06 // 16k Ohm resistor on all the time
|
||||
#define PUR_32KR 0x07 // 32k Ohm resistor in t_NOL
|
||||
|
||||
#define A_1 0x00
|
||||
#define A_2 0x01
|
||||
#define A_3 0x02
|
||||
#define A_4 0x03
|
||||
#define A_5 0x04
|
||||
#define A_6 0x05
|
||||
#define A_7 0x06
|
||||
#define A_8 0x07
|
||||
#define A_9 0x08
|
||||
#define A_10 0x09
|
||||
#define A_11 0x0A
|
||||
#define A_12 0x0B
|
||||
#define A_13 0x0C
|
||||
#define A_14 0x0D
|
||||
#define A_15 0x0E
|
||||
#define A_16 0x0F
|
||||
|
||||
#define B_1 0x10
|
||||
#define B_2 0x11
|
||||
#define B_3 0x12
|
||||
#define B_4 0x13
|
||||
#define B_5 0x14
|
||||
#define B_6 0x15
|
||||
#define B_7 0x16
|
||||
#define B_8 0x17
|
||||
#define B_9 0x18
|
||||
#define B_10 0x19
|
||||
#define B_11 0x1A
|
||||
#define B_12 0x1B
|
||||
#define B_13 0x1C
|
||||
#define B_14 0x1D
|
||||
#define B_15 0x1E
|
||||
#define B_16 0x1F
|
||||
|
||||
#define C_1 0x20
|
||||
#define C_2 0x21
|
||||
#define C_3 0x22
|
||||
#define C_4 0x23
|
||||
#define C_5 0x24
|
||||
#define C_6 0x25
|
||||
#define C_7 0x26
|
||||
#define C_8 0x27
|
||||
#define C_9 0x28
|
||||
#define C_10 0x29
|
||||
#define C_11 0x2A
|
||||
#define C_12 0x2B
|
||||
#define C_13 0x2C
|
||||
#define C_14 0x2D
|
||||
#define C_15 0x2E
|
||||
#define C_16 0x2F
|
||||
|
||||
#define D_1 0x30
|
||||
#define D_2 0x31
|
||||
#define D_3 0x32
|
||||
#define D_4 0x33
|
||||
#define D_5 0x34
|
||||
#define D_6 0x35
|
||||
#define D_7 0x36
|
||||
#define D_8 0x37
|
||||
#define D_9 0x38
|
||||
#define D_10 0x39
|
||||
#define D_11 0x3A
|
||||
#define D_12 0x3B
|
||||
#define D_13 0x3C
|
||||
#define D_14 0x3D
|
||||
#define D_15 0x3E
|
||||
#define D_16 0x3F
|
||||
|
||||
#define E_1 0x40
|
||||
#define E_2 0x41
|
||||
#define E_3 0x42
|
||||
#define E_4 0x43
|
||||
#define E_5 0x44
|
||||
#define E_6 0x45
|
||||
#define E_7 0x46
|
||||
#define E_8 0x47
|
||||
#define E_9 0x48
|
||||
#define E_10 0x49
|
||||
#define E_11 0x4A
|
||||
#define E_12 0x4B
|
||||
#define E_13 0x4C
|
||||
#define E_14 0x4D
|
||||
#define E_15 0x4E
|
||||
#define E_16 0x4F
|
||||
|
||||
#define F_1 0x50
|
||||
#define F_2 0x51
|
||||
#define F_3 0x52
|
||||
#define F_4 0x53
|
||||
#define F_5 0x54
|
||||
#define F_6 0x55
|
||||
#define F_7 0x56
|
||||
#define F_8 0x57
|
||||
#define F_9 0x58
|
||||
#define F_10 0x59
|
||||
#define F_11 0x5A
|
||||
#define F_12 0x5B
|
||||
#define F_13 0x5C
|
||||
#define F_14 0x5D
|
||||
#define F_15 0x5E
|
||||
#define F_16 0x5F
|
||||
|
||||
#define G_1 0x60
|
||||
#define G_2 0x61
|
||||
#define G_3 0x62
|
||||
#define G_4 0x63
|
||||
#define G_5 0x64
|
||||
#define G_6 0x65
|
||||
#define G_7 0x66
|
||||
#define G_8 0x67
|
||||
#define G_9 0x68
|
||||
#define G_10 0x69
|
||||
#define G_11 0x6A
|
||||
#define G_12 0x6B
|
||||
#define G_13 0x6C
|
||||
#define G_14 0x6D
|
||||
#define G_15 0x6E
|
||||
#define G_16 0x6F
|
||||
|
||||
#define H_1 0x70
|
||||
#define H_2 0x71
|
||||
#define H_3 0x72
|
||||
#define H_4 0x73
|
||||
#define H_5 0x74
|
||||
#define H_6 0x75
|
||||
#define H_7 0x76
|
||||
#define H_8 0x77
|
||||
#define H_9 0x78
|
||||
#define H_10 0x79
|
||||
#define H_11 0x7A
|
||||
#define H_12 0x7B
|
||||
#define H_13 0x7C
|
||||
#define H_14 0x7D
|
||||
#define H_15 0x7E
|
||||
#define H_16 0x7F
|
||||
|
||||
#define I_1 0x80
|
||||
#define I_2 0x81
|
||||
#define I_3 0x82
|
||||
#define I_4 0x83
|
||||
#define I_5 0x84
|
||||
#define I_6 0x85
|
||||
#define I_7 0x86
|
||||
#define I_8 0x87
|
||||
#define I_9 0x88
|
||||
#define I_10 0x89
|
||||
#define I_11 0x8A
|
||||
#define I_12 0x8B
|
||||
#define I_13 0x8C
|
||||
#define I_14 0x8D
|
||||
#define I_15 0x8E
|
||||
#define I_16 0x8F
|
||||
|
||||
#define J_1 0x90
|
||||
#define J_2 0x91
|
||||
#define J_3 0x92
|
||||
#define J_4 0x93
|
||||
#define J_5 0x94
|
||||
#define J_6 0x95
|
||||
#define J_7 0x96
|
||||
#define J_8 0x97
|
||||
#define J_9 0x98
|
||||
#define J_10 0x99
|
||||
#define J_11 0x9A
|
||||
#define J_12 0x9B
|
||||
#define J_13 0x9C
|
||||
#define J_14 0x9D
|
||||
#define J_15 0x9E
|
||||
#define J_16 0x9F
|
||||
|
||||
#define K_1 0xA0
|
||||
#define K_2 0xA1
|
||||
#define K_3 0xA2
|
||||
#define K_4 0xA3
|
||||
#define K_5 0xA4
|
||||
#define K_6 0xA5
|
||||
#define K_7 0xA6
|
||||
#define K_8 0xA7
|
||||
#define K_9 0xA8
|
||||
#define K_10 0xA9
|
||||
#define K_11 0xAA
|
||||
#define K_12 0xAB
|
||||
#define K_13 0xAC
|
||||
#define K_14 0xAD
|
||||
#define K_15 0xAE
|
||||
#define K_16 0xAF
|
||||
|
||||
#define L_1 0xB0
|
||||
#define L_2 0xB1
|
||||
#define L_3 0xB2
|
||||
#define L_4 0xB3
|
||||
#define L_5 0xB4
|
||||
#define L_6 0xB5
|
||||
#define L_7 0xB6
|
||||
#define L_8 0xB7
|
||||
#define L_9 0xB8
|
||||
#define L_10 0xB9
|
||||
#define L_11 0xBA
|
||||
#define L_12 0xBB
|
||||
#define L_13 0xBC
|
||||
#define L_14 0xBD
|
||||
#define L_15 0xBE
|
||||
#define L_16 0xBF
|
||||
299
drivers/led/issi/is31fl3742.h
Normal file
299
drivers/led/issi/is31fl3742.h
Normal file
@@ -0,0 +1,299 @@
|
||||
/* Copyright 2017 Jason Williams
|
||||
* Copyright 2018 Jack Humbert
|
||||
* Copyright 2018 Yiancar
|
||||
* Copyright 2020 MelGeek
|
||||
* Copyright 2021 MasterSpoon
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// This is a 7-bit address, that gets left-shifted and bit 0
|
||||
// set to 0 for write, 1 for read (as per I2C protocol)
|
||||
// The address will vary depending on your wiring:
|
||||
// 00 <-> GND
|
||||
// 01 <-> SCL
|
||||
// 10 <-> SDA
|
||||
// 11 <-> VCC
|
||||
// ADDR represents A1:A0 of the 7-bit address.
|
||||
// The result is: 0b01100(ADDR)
|
||||
#ifndef DRIVER_ADDR_1
|
||||
# define DRIVER_ADDR_1 0b0110000
|
||||
#endif
|
||||
|
||||
// Command Registers
|
||||
#define ISSI_COMMANDREGISTER_WRITELOCK 0xFE
|
||||
#define ISSI_COMMANDREGISTER 0xFD
|
||||
#define ISSI_IDREGISTER 0xFC
|
||||
#define ISSI_REGISTER_UNLOCK 0xC5
|
||||
|
||||
// Response Registers
|
||||
#define ISSI_PAGE_PWM 0x00
|
||||
#define ISSI_PAGE_SCALING 0x02
|
||||
#define ISSI_PAGE_FUNCTION 0x04
|
||||
|
||||
// Registers under Function Register
|
||||
#define ISSI_REG_CONFIGURATION 0x00
|
||||
#define ISSI_REG_GLOBALCURRENT 0x01
|
||||
#define ISSI_REG_PULLDOWNUP 0x02
|
||||
#define ISSI_REG_SSR 0x41
|
||||
#define ISSI_REG_RESET 0x3F
|
||||
#define ISSI_REG_PWM_SET 0x36
|
||||
|
||||
// Set defaults for Function Registers
|
||||
#ifndef ISSI_CONFIGURATION
|
||||
# define ISSI_CONFIGURATION 0x31
|
||||
#endif
|
||||
#ifndef ISSI_GLOBALCURRENT
|
||||
# define ISSI_GLOBALCURRENT 0xFF
|
||||
#endif
|
||||
#ifndef ISSI_PULLDOWNUP
|
||||
# define ISSI_PULLDOWNUP 0x55
|
||||
#endif
|
||||
#ifndef ISSI_PWM_SET
|
||||
# define ISSI_PWM_SET 0x00
|
||||
#endif
|
||||
|
||||
// Set defaults for Spread Spectrum Register
|
||||
#ifndef ISSI_SSR_1
|
||||
# define ISSI_SSR_1 0x00
|
||||
#endif
|
||||
#ifndef ISSI_SSR_2
|
||||
# define ISSI_SSR_2 0x00
|
||||
#endif
|
||||
#ifndef ISSI_SSR_3
|
||||
# define ISSI_SSR_3 0x00
|
||||
#endif
|
||||
#ifndef ISSI_SSR_4
|
||||
# define ISSI_SSR_4 0x00
|
||||
#endif
|
||||
|
||||
// Set defaults for Scaling registers
|
||||
#ifndef ISSI_SCAL_RED
|
||||
# define ISSI_SCAL_RED 0xFF
|
||||
#endif
|
||||
#ifndef ISSI_SCAL_BLUE
|
||||
# define ISSI_SCAL_BLUE 0xFF
|
||||
#endif
|
||||
#ifndef ISSI_SCAL_GREEN
|
||||
# define ISSI_SCAL_GREEN 0xFF
|
||||
#endif
|
||||
#define ISSI_SCAL_RED_OFF 0x00
|
||||
#define ISSI_SCAL_GREEN_OFF 0x00
|
||||
#define ISSI_SCAL_BLUE_OFF 0x00
|
||||
|
||||
#ifndef ISSI_SCAL_LED
|
||||
# define ISSI_SCAL_LED 0xFF
|
||||
#endif
|
||||
#define ISSI_SCAL_LED_OFF 0x00
|
||||
|
||||
// Set buffer sizes
|
||||
#define ISSI_MAX_LEDS 180
|
||||
#define ISSI_SCALING_SIZE 180
|
||||
#define ISSI_PWM_TRF_SIZE 18
|
||||
#define ISSI_SCALING_TRF_SIZE 18
|
||||
|
||||
// Location of 1st bit for PWM and Scaling registers
|
||||
#define ISSI_PWM_REG_1ST 0x00
|
||||
#define ISSI_SCL_REG_1ST 0x00
|
||||
|
||||
// Map CS SW locations to order in PWM / Scaling buffers
|
||||
// This matches the ORDER in the Datasheet Register not the POSITION
|
||||
// It will always count from 0x00 to (ISSI_MAX_LEDS - 1)
|
||||
#define CS1_SW1 0x00
|
||||
#define CS2_SW1 0x01
|
||||
#define CS3_SW1 0x02
|
||||
#define CS4_SW1 0x03
|
||||
#define CS5_SW1 0x04
|
||||
#define CS6_SW1 0x05
|
||||
#define CS7_SW1 0x06
|
||||
#define CS8_SW1 0x07
|
||||
#define CS9_SW1 0x08
|
||||
#define CS10_SW1 0x09
|
||||
#define CS11_SW1 0x0A
|
||||
#define CS12_SW1 0x0B
|
||||
#define CS13_SW1 0x0C
|
||||
#define CS14_SW1 0x0D
|
||||
#define CS15_SW1 0x0E
|
||||
#define CS16_SW1 0x0F
|
||||
#define CS17_SW1 0x10
|
||||
#define CS18_SW1 0x11
|
||||
#define CS19_SW1 0x12
|
||||
#define CS20_SW1 0x13
|
||||
#define CS21_SW1 0x14
|
||||
#define CS22_SW1 0x15
|
||||
#define CS23_SW1 0x16
|
||||
#define CS24_SW1 0x17
|
||||
#define CS25_SW1 0x18
|
||||
#define CS26_SW1 0x19
|
||||
#define CS27_SW1 0x1A
|
||||
#define CS28_SW1 0x1B
|
||||
#define CS29_SW1 0x1C
|
||||
#define CS30_SW1 0x1D
|
||||
|
||||
#define CS1_SW2 0x1E
|
||||
#define CS2_SW2 0x1F
|
||||
#define CS3_SW2 0x20
|
||||
#define CS4_SW2 0x21
|
||||
#define CS5_SW2 0x22
|
||||
#define CS6_SW2 0x23
|
||||
#define CS7_SW2 0x24
|
||||
#define CS8_SW2 0x25
|
||||
#define CS9_SW2 0x26
|
||||
#define CS10_SW2 0x27
|
||||
#define CS11_SW2 0x28
|
||||
#define CS12_SW2 0x29
|
||||
#define CS13_SW2 0x2A
|
||||
#define CS14_SW2 0x2B
|
||||
#define CS15_SW2 0x2C
|
||||
#define CS16_SW2 0x2D
|
||||
#define CS17_SW2 0x2E
|
||||
#define CS18_SW2 0x2F
|
||||
#define CS19_SW2 0x30
|
||||
#define CS20_SW2 0x31
|
||||
#define CS21_SW2 0x32
|
||||
#define CS22_SW2 0x33
|
||||
#define CS23_SW2 0x34
|
||||
#define CS24_SW2 0x35
|
||||
#define CS25_SW2 0x36
|
||||
#define CS26_SW2 0x37
|
||||
#define CS27_SW2 0x38
|
||||
#define CS28_SW2 0x39
|
||||
#define CS29_SW2 0x3A
|
||||
#define CS30_SW2 0x3B
|
||||
|
||||
#define CS1_SW3 0x3C
|
||||
#define CS2_SW3 0x3D
|
||||
#define CS3_SW3 0x3E
|
||||
#define CS4_SW3 0x3F
|
||||
#define CS5_SW3 0x40
|
||||
#define CS6_SW3 0x41
|
||||
#define CS7_SW3 0x42
|
||||
#define CS8_SW3 0x43
|
||||
#define CS9_SW3 0x44
|
||||
#define CS10_SW3 0x45
|
||||
#define CS11_SW3 0x46
|
||||
#define CS12_SW3 0x47
|
||||
#define CS13_SW3 0x48
|
||||
#define CS14_SW3 0x49
|
||||
#define CS15_SW3 0x4A
|
||||
#define CS16_SW3 0x4B
|
||||
#define CS17_SW3 0x4C
|
||||
#define CS18_SW3 0x4D
|
||||
#define CS19_SW3 0x4E
|
||||
#define CS20_SW3 0x4F
|
||||
#define CS21_SW3 0x50
|
||||
#define CS22_SW3 0x51
|
||||
#define CS23_SW3 0x52
|
||||
#define CS24_SW3 0x53
|
||||
#define CS25_SW3 0x54
|
||||
#define CS26_SW3 0x55
|
||||
#define CS27_SW3 0x56
|
||||
#define CS28_SW3 0x57
|
||||
#define CS29_SW3 0x58
|
||||
#define CS30_SW3 0x59
|
||||
|
||||
#define CS1_SW4 0x5A
|
||||
#define CS2_SW4 0x5B
|
||||
#define CS3_SW4 0x5C
|
||||
#define CS4_SW4 0x5D
|
||||
#define CS5_SW4 0x5E
|
||||
#define CS6_SW4 0x5F
|
||||
#define CS7_SW4 0x60
|
||||
#define CS8_SW4 0x61
|
||||
#define CS9_SW4 0x62
|
||||
#define CS10_SW4 0x63
|
||||
#define CS11_SW4 0x64
|
||||
#define CS12_SW4 0x65
|
||||
#define CS13_SW4 0x66
|
||||
#define CS14_SW4 0x67
|
||||
#define CS15_SW4 0x68
|
||||
#define CS16_SW4 0x69
|
||||
#define CS17_SW4 0x6A
|
||||
#define CS18_SW4 0x6B
|
||||
#define CS19_SW4 0x6C
|
||||
#define CS20_SW4 0x6D
|
||||
#define CS21_SW4 0x6E
|
||||
#define CS22_SW4 0x6F
|
||||
#define CS23_SW4 0x70
|
||||
#define CS24_SW4 0x71
|
||||
#define CS25_SW4 0x72
|
||||
#define CS26_SW4 0x73
|
||||
#define CS27_SW4 0x74
|
||||
#define CS28_SW4 0x75
|
||||
#define CS29_SW4 0x76
|
||||
#define CS30_SW4 0x77
|
||||
|
||||
#define CS1_SW5 0x78
|
||||
#define CS2_SW5 0x79
|
||||
#define CS3_SW5 0x7A
|
||||
#define CS4_SW5 0x7B
|
||||
#define CS5_SW5 0x7C
|
||||
#define CS6_SW5 0x7D
|
||||
#define CS7_SW5 0x7E
|
||||
#define CS8_SW5 0x7F
|
||||
#define CS9_SW5 0x80
|
||||
#define CS10_SW5 0x81
|
||||
#define CS11_SW5 0x82
|
||||
#define CS12_SW5 0x83
|
||||
#define CS13_SW5 0x84
|
||||
#define CS14_SW5 0x85
|
||||
#define CS15_SW5 0x86
|
||||
#define CS16_SW5 0x87
|
||||
#define CS17_SW5 0x88
|
||||
#define CS18_SW5 0x89
|
||||
#define CS19_SW5 0x8A
|
||||
#define CS20_SW5 0x8B
|
||||
#define CS21_SW5 0x8C
|
||||
#define CS22_SW5 0x8D
|
||||
#define CS23_SW5 0x8E
|
||||
#define CS24_SW5 0x8F
|
||||
#define CS25_SW5 0x90
|
||||
#define CS26_SW5 0x91
|
||||
#define CS27_SW5 0x92
|
||||
#define CS28_SW5 0x93
|
||||
#define CS29_SW5 0x94
|
||||
#define CS30_SW5 0x95
|
||||
|
||||
#define CS1_SW6 0x96
|
||||
#define CS2_SW6 0x97
|
||||
#define CS3_SW6 0x98
|
||||
#define CS4_SW6 0x99
|
||||
#define CS5_SW6 0x9A
|
||||
#define CS6_SW6 0x9B
|
||||
#define CS7_SW6 0x9C
|
||||
#define CS8_SW6 0x9D
|
||||
#define CS9_SW6 0x9E
|
||||
#define CS10_SW6 0x9F
|
||||
#define CS11_SW6 0xA0
|
||||
#define CS12_SW6 0xA1
|
||||
#define CS13_SW6 0xA2
|
||||
#define CS14_SW6 0xA3
|
||||
#define CS15_SW6 0xA4
|
||||
#define CS16_SW6 0xA5
|
||||
#define CS17_SW6 0xA6
|
||||
#define CS18_SW6 0xA7
|
||||
#define CS19_SW6 0xA8
|
||||
#define CS20_SW6 0xA9
|
||||
#define CS21_SW6 0xAA
|
||||
#define CS22_SW6 0xAB
|
||||
#define CS23_SW6 0xAC
|
||||
#define CS24_SW6 0xAD
|
||||
#define CS25_SW6 0xAE
|
||||
#define CS26_SW6 0xAF
|
||||
#define CS27_SW6 0xB0
|
||||
#define CS28_SW6 0xB1
|
||||
#define CS29_SW6 0xB2
|
||||
#define CS30_SW6 0xB3
|
||||
327
drivers/led/issi/is31fl3743.h
Normal file
327
drivers/led/issi/is31fl3743.h
Normal file
@@ -0,0 +1,327 @@
|
||||
/* Copyright 2017 Jason Williams
|
||||
* Copyright 2018 Jack Humbert
|
||||
* Copyright 2018 Yiancar
|
||||
* Copyright 2020 MelGeek
|
||||
* Copyright 2021 MasterSpoon
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// This is a 7-bit address, that gets left-shifted and bit 0
|
||||
// set to 0 for write, 1 for read (as per I2C protocol)
|
||||
// The address will vary depending on your wiring:
|
||||
// 00 <-> GND
|
||||
// 01 <-> SCL
|
||||
// 10 <-> SDA
|
||||
// 11 <-> VCC
|
||||
// ADDR1 represents A1:A0 of the 7-bit address.
|
||||
// ADDR2 represents A3:A2 of the 7-bit address.
|
||||
// The result is: 0b010(ADDR2)(ADDR1)
|
||||
#ifndef DRIVER_ADDR_1
|
||||
# define DRIVER_ADDR_1 0b0100000
|
||||
#endif
|
||||
|
||||
// Set defaults for Spread Spectrum Register
|
||||
#ifndef ISSI_SSR_1
|
||||
# if DRIVER_COUNT == 1
|
||||
# define ISSI_SSR_1 0x00
|
||||
# else
|
||||
# define ISSI_SSR_1 0xC0
|
||||
# endif
|
||||
#endif
|
||||
#ifndef ISSI_SSR_2
|
||||
# define ISSI_SSR_2 0x80
|
||||
#endif
|
||||
#ifndef ISSI_SSR_3
|
||||
# define ISSI_SSR_3 0x80
|
||||
#endif
|
||||
#ifndef ISSI_SSR_4
|
||||
# define ISSI_SSR_4 0x80
|
||||
#endif
|
||||
|
||||
// Command Registers
|
||||
#define ISSI_COMMANDREGISTER_WRITELOCK 0xFE
|
||||
#define ISSI_COMMANDREGISTER 0xFD
|
||||
#define ISSI_IDREGISTER 0xFC
|
||||
#define ISSI_REGISTER_UNLOCK 0xC5
|
||||
|
||||
// Response Registers
|
||||
#define ISSI_PAGE_PWM 0x00
|
||||
#define ISSI_PAGE_SCALING 0x01
|
||||
#define ISSI_PAGE_FUNCTION 0x02
|
||||
|
||||
// Registers under Function Register
|
||||
#define ISSI_REG_CONFIGURATION 0x00
|
||||
#define ISSI_REG_GLOBALCURRENT 0x01
|
||||
#define ISSI_REG_PULLDOWNUP 0x02
|
||||
#define ISSI_REG_TEMP 0x24
|
||||
#define ISSI_REG_SSR 0x25
|
||||
#define ISSI_REG_RESET 0x2F
|
||||
|
||||
// Set defaults for Function Registers
|
||||
#ifndef ISSI_CONFIGURATION
|
||||
# define ISSI_CONFIGURATION 0x01
|
||||
#endif
|
||||
#ifndef ISSI_GLOBALCURRENT
|
||||
# define ISSI_GLOBALCURRENT 0xFF
|
||||
#endif
|
||||
#ifndef ISSI_PULLDOWNUP
|
||||
# define ISSI_PULLDOWNUP 0x33
|
||||
#endif
|
||||
#ifndef ISSI_TEMP
|
||||
# define ISSI_TEMP 0x00
|
||||
#endif
|
||||
|
||||
// Set defaults for Scaling registers
|
||||
#ifndef ISSI_SCAL_RED
|
||||
# define ISSI_SCAL_RED 0xFF
|
||||
#endif
|
||||
#ifndef ISSI_SCAL_BLUE
|
||||
# define ISSI_SCAL_BLUE 0xFF
|
||||
#endif
|
||||
#ifndef ISSI_SCAL_GREEN
|
||||
# define ISSI_SCAL_GREEN 0xFF
|
||||
#endif
|
||||
#define ISSI_SCAL_RED_OFF 0x00
|
||||
#define ISSI_SCAL_GREEN_OFF 0x00
|
||||
#define ISSI_SCAL_BLUE_OFF 0x00
|
||||
|
||||
#ifndef ISSI_SCAL_LED
|
||||
# define ISSI_SCAL_LED 0xFF
|
||||
#endif
|
||||
#define ISSI_SCAL_LED_OFF 0x00
|
||||
|
||||
// Set buffer sizes
|
||||
#define ISSI_MAX_LEDS 198
|
||||
#define ISSI_SCALING_SIZE 198
|
||||
#define ISSI_PWM_TRF_SIZE 18
|
||||
#define ISSI_SCALING_TRF_SIZE 18
|
||||
|
||||
// Location of 1st bit for PWM and Scaling registers
|
||||
#define ISSI_PWM_REG_1ST 0x01
|
||||
#define ISSI_SCL_REG_1ST 0x01
|
||||
|
||||
// Map CS SW locations to order in PWM / Scaling buffers
|
||||
// This matches the ORDER in the Datasheet Register not the POSITION
|
||||
// It will always count from 0x00 to (ISSI_MAX_LEDS - 1)
|
||||
#define CS1_SW1 0x00
|
||||
#define CS2_SW1 0x01
|
||||
#define CS3_SW1 0x02
|
||||
#define CS4_SW1 0x03
|
||||
#define CS5_SW1 0x04
|
||||
#define CS6_SW1 0x05
|
||||
#define CS7_SW1 0x06
|
||||
#define CS8_SW1 0x07
|
||||
#define CS9_SW1 0x08
|
||||
#define CS10_SW1 0x09
|
||||
#define CS11_SW1 0x0A
|
||||
#define CS12_SW1 0x0B
|
||||
#define CS13_SW1 0x0C
|
||||
#define CS14_SW1 0x0D
|
||||
#define CS15_SW1 0x0E
|
||||
#define CS16_SW1 0x0F
|
||||
#define CS17_SW1 0x10
|
||||
#define CS18_SW1 0x11
|
||||
|
||||
#define CS1_SW2 0x12
|
||||
#define CS2_SW2 0x13
|
||||
#define CS3_SW2 0x14
|
||||
#define CS4_SW2 0x15
|
||||
#define CS5_SW2 0x16
|
||||
#define CS6_SW2 0x17
|
||||
#define CS7_SW2 0x18
|
||||
#define CS8_SW2 0x19
|
||||
#define CS9_SW2 0x1A
|
||||
#define CS10_SW2 0x1B
|
||||
#define CS11_SW2 0x1C
|
||||
#define CS12_SW2 0x1D
|
||||
#define CS13_SW2 0x1E
|
||||
#define CS14_SW2 0x1F
|
||||
#define CS15_SW2 0x20
|
||||
#define CS16_SW2 0x21
|
||||
#define CS17_SW2 0x22
|
||||
#define CS18_SW2 0x23
|
||||
|
||||
#define CS1_SW3 0x24
|
||||
#define CS2_SW3 0x25
|
||||
#define CS3_SW3 0x26
|
||||
#define CS4_SW3 0x27
|
||||
#define CS5_SW3 0x28
|
||||
#define CS6_SW3 0x29
|
||||
#define CS7_SW3 0x2A
|
||||
#define CS8_SW3 0x2B
|
||||
#define CS9_SW3 0x2C
|
||||
#define CS10_SW3 0x2D
|
||||
#define CS11_SW3 0x2E
|
||||
#define CS12_SW3 0x2F
|
||||
#define CS13_SW3 0x30
|
||||
#define CS14_SW3 0x31
|
||||
#define CS15_SW3 0x32
|
||||
#define CS16_SW3 0x33
|
||||
#define CS17_SW3 0x34
|
||||
#define CS18_SW3 0x35
|
||||
|
||||
#define CS1_SW4 0x36
|
||||
#define CS2_SW4 0x37
|
||||
#define CS3_SW4 0x38
|
||||
#define CS4_SW4 0x39
|
||||
#define CS5_SW4 0x3A
|
||||
#define CS6_SW4 0x3B
|
||||
#define CS7_SW4 0x3C
|
||||
#define CS8_SW4 0x3D
|
||||
#define CS9_SW4 0x3E
|
||||
#define CS10_SW4 0x3F
|
||||
#define CS11_SW4 0x40
|
||||
#define CS12_SW4 0x41
|
||||
#define CS13_SW4 0x42
|
||||
#define CS14_SW4 0x43
|
||||
#define CS15_SW4 0x44
|
||||
#define CS16_SW4 0x45
|
||||
#define CS17_SW4 0x46
|
||||
#define CS18_SW4 0x47
|
||||
|
||||
#define CS1_SW5 0x48
|
||||
#define CS2_SW5 0x49
|
||||
#define CS3_SW5 0x4A
|
||||
#define CS4_SW5 0x4B
|
||||
#define CS5_SW5 0x4C
|
||||
#define CS6_SW5 0x4D
|
||||
#define CS7_SW5 0x4E
|
||||
#define CS8_SW5 0x4F
|
||||
#define CS9_SW5 0x50
|
||||
#define CS10_SW5 0x51
|
||||
#define CS11_SW5 0x52
|
||||
#define CS12_SW5 0x53
|
||||
#define CS13_SW5 0x54
|
||||
#define CS14_SW5 0x55
|
||||
#define CS15_SW5 0x56
|
||||
#define CS16_SW5 0x57
|
||||
#define CS17_SW5 0x58
|
||||
#define CS18_SW5 0x59
|
||||
|
||||
#define CS1_SW6 0x5A
|
||||
#define CS2_SW6 0x5B
|
||||
#define CS3_SW6 0x5C
|
||||
#define CS4_SW6 0x5D
|
||||
#define CS5_SW6 0x5E
|
||||
#define CS6_SW6 0x5F
|
||||
#define CS7_SW6 0x60
|
||||
#define CS8_SW6 0x61
|
||||
#define CS9_SW6 0x62
|
||||
#define CS10_SW6 0x63
|
||||
#define CS11_SW6 0x64
|
||||
#define CS12_SW6 0x65
|
||||
#define CS13_SW6 0x66
|
||||
#define CS14_SW6 0x67
|
||||
#define CS15_SW6 0x68
|
||||
#define CS16_SW6 0x69
|
||||
#define CS17_SW6 0x6A
|
||||
#define CS18_SW6 0x6B
|
||||
|
||||
#define CS1_SW7 0x6C
|
||||
#define CS2_SW7 0x6D
|
||||
#define CS3_SW7 0x6E
|
||||
#define CS4_SW7 0x6F
|
||||
#define CS5_SW7 0x70
|
||||
#define CS6_SW7 0x71
|
||||
#define CS7_SW7 0x72
|
||||
#define CS8_SW7 0x73
|
||||
#define CS9_SW7 0x74
|
||||
#define CS10_SW7 0x75
|
||||
#define CS11_SW7 0x76
|
||||
#define CS12_SW7 0x77
|
||||
#define CS13_SW7 0x78
|
||||
#define CS14_SW7 0x79
|
||||
#define CS15_SW7 0x7A
|
||||
#define CS16_SW7 0x7B
|
||||
#define CS17_SW7 0x7C
|
||||
#define CS18_SW7 0x7D
|
||||
|
||||
#define CS1_SW8 0x7E
|
||||
#define CS2_SW8 0x7F
|
||||
#define CS3_SW8 0x80
|
||||
#define CS4_SW8 0x81
|
||||
#define CS5_SW8 0x82
|
||||
#define CS6_SW8 0x83
|
||||
#define CS7_SW8 0x84
|
||||
#define CS8_SW8 0x85
|
||||
#define CS9_SW8 0x86
|
||||
#define CS10_SW8 0x87
|
||||
#define CS11_SW8 0x88
|
||||
#define CS12_SW8 0x89
|
||||
#define CS13_SW8 0x8A
|
||||
#define CS14_SW8 0x8B
|
||||
#define CS15_SW8 0x8C
|
||||
#define CS16_SW8 0x8D
|
||||
#define CS17_SW8 0x8E
|
||||
#define CS18_SW8 0x8F
|
||||
|
||||
#define CS1_SW9 0x90
|
||||
#define CS2_SW9 0x91
|
||||
#define CS3_SW9 0x92
|
||||
#define CS4_SW9 0x93
|
||||
#define CS5_SW9 0x94
|
||||
#define CS6_SW9 0x95
|
||||
#define CS7_SW9 0x96
|
||||
#define CS8_SW9 0x97
|
||||
#define CS9_SW9 0x98
|
||||
#define CS10_SW9 0x99
|
||||
#define CS11_SW9 0x9A
|
||||
#define CS12_SW9 0x9B
|
||||
#define CS13_SW9 0x9C
|
||||
#define CS14_SW9 0x9D
|
||||
#define CS15_SW9 0x9E
|
||||
#define CS16_SW9 0x9F
|
||||
#define CS17_SW9 0xA0
|
||||
#define CS18_SW9 0xA1
|
||||
|
||||
#define CS1_SW10 0xA2
|
||||
#define CS2_SW10 0xA3
|
||||
#define CS3_SW10 0xA4
|
||||
#define CS4_SW10 0xA5
|
||||
#define CS5_SW10 0xA6
|
||||
#define CS6_SW10 0xA7
|
||||
#define CS7_SW10 0xA8
|
||||
#define CS8_SW10 0xA9
|
||||
#define CS9_SW10 0xAA
|
||||
#define CS10_SW10 0xAB
|
||||
#define CS11_SW10 0xAC
|
||||
#define CS12_SW10 0xAD
|
||||
#define CS13_SW10 0xAE
|
||||
#define CS14_SW10 0xAF
|
||||
#define CS15_SW10 0xB0
|
||||
#define CS16_SW10 0xB1
|
||||
#define CS17_SW10 0xB2
|
||||
#define CS18_SW10 0xB3
|
||||
|
||||
#define CS1_SW11 0xB4
|
||||
#define CS2_SW11 0xB5
|
||||
#define CS3_SW11 0xB6
|
||||
#define CS4_SW11 0xB7
|
||||
#define CS5_SW11 0xB8
|
||||
#define CS6_SW11 0xB9
|
||||
#define CS7_SW11 0xBA
|
||||
#define CS8_SW11 0xBB
|
||||
#define CS9_SW11 0xBC
|
||||
#define CS10_SW11 0xBD
|
||||
#define CS11_SW11 0xBE
|
||||
#define CS12_SW11 0xBF
|
||||
#define CS13_SW11 0xC0
|
||||
#define CS14_SW11 0xC1
|
||||
#define CS15_SW11 0xC2
|
||||
#define CS16_SW11 0xC3
|
||||
#define CS17_SW11 0xC4
|
||||
#define CS18_SW11 0xC5
|
||||
270
drivers/led/issi/is31fl3745.h
Normal file
270
drivers/led/issi/is31fl3745.h
Normal file
@@ -0,0 +1,270 @@
|
||||
/* Copyright 2017 Jason Williams
|
||||
* Copyright 2018 Jack Humbert
|
||||
* Copyright 2018 Yiancar
|
||||
* Copyright 2020 MelGeek
|
||||
* Copyright 2021 MasterSpoon
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// This is a 7-bit address, that gets left-shifted and bit 0
|
||||
// set to 0 for write, 1 for read (as per I2C protocol)
|
||||
// The address will vary depending on your wiring:
|
||||
// 00 <-> GND
|
||||
// 01 <-> SCL
|
||||
// 10 <-> SDA
|
||||
// 11 <-> VCC
|
||||
// ADDR1 represents A1:A0 of the 7-bit address.
|
||||
// ADDR2 represents A3:A2 of the 7-bit address.
|
||||
// The result is: 0b010(ADDR2)(ADDR1)
|
||||
#ifndef DRIVER_ADDR_1
|
||||
# define DRIVER_ADDR_1 0b0100000
|
||||
#endif
|
||||
|
||||
// Set defaults for Spread Spectrum Register
|
||||
#ifndef ISSI_SSR_1
|
||||
# if DRIVER_COUNT == 1
|
||||
# define ISSI_SSR_1 0x00
|
||||
# else
|
||||
# define ISSI_SSR_1 0xC0
|
||||
# endif
|
||||
#endif
|
||||
#ifndef ISSI_SSR_2
|
||||
# define ISSI_SSR_2 0x80
|
||||
#endif
|
||||
#ifndef ISSI_SSR_3
|
||||
# define ISSI_SSR_3 0x80
|
||||
#endif
|
||||
#ifndef ISSI_SSR_4
|
||||
# define ISSI_SSR_4 0x80
|
||||
#endif
|
||||
|
||||
// Command Registers
|
||||
#define ISSI_COMMANDREGISTER_WRITELOCK 0xFE
|
||||
#define ISSI_COMMANDREGISTER 0xFD
|
||||
#define ISSI_IDREGISTER 0xFC
|
||||
#define ISSI_REGISTER_UNLOCK 0xC5
|
||||
|
||||
// Response Registers
|
||||
#define ISSI_PAGE_PWM 0x00
|
||||
#define ISSI_PAGE_SCALING 0x01
|
||||
#define ISSI_PAGE_FUNCTION 0x02
|
||||
|
||||
// Registers under Function Register
|
||||
#define ISSI_REG_CONFIGURATION 0x00
|
||||
#define ISSI_REG_GLOBALCURRENT 0x01
|
||||
#define ISSI_REG_PULLDOWNUP 0x02
|
||||
#define ISSI_REG_TEMP 0x24
|
||||
#define ISSI_REG_SSR 0x25
|
||||
#define ISSI_REG_RESET 0x2F
|
||||
|
||||
// Set defaults for Function Registers
|
||||
#ifndef ISSI_CONFIGURATION
|
||||
# define ISSI_CONFIGURATION 0x31
|
||||
#endif
|
||||
#ifndef ISSI_GLOBALCURRENT
|
||||
# define ISSI_GLOBALCURRENT 0xFF
|
||||
#endif
|
||||
#ifndef ISSI_PULLDOWNUP
|
||||
# define ISSI_PULLDOWNUP 0x33
|
||||
#endif
|
||||
#ifndef ISSI_TEMP
|
||||
# define ISSI_TEMP 0x00
|
||||
#endif
|
||||
|
||||
// Set defaults for Scaling registers
|
||||
#ifndef ISSI_SCAL_RED
|
||||
# define ISSI_SCAL_RED 0xFF
|
||||
#endif
|
||||
#ifndef ISSI_SCAL_BLUE
|
||||
# define ISSI_SCAL_BLUE 0xFF
|
||||
#endif
|
||||
#ifndef ISSI_SCAL_GREEN
|
||||
# define ISSI_SCAL_GREEN 0xFF
|
||||
#endif
|
||||
#define ISSI_SCAL_RED_OFF 0x00
|
||||
#define ISSI_SCAL_GREEN_OFF 0x00
|
||||
#define ISSI_SCAL_BLUE_OFF 0x00
|
||||
|
||||
#ifndef ISSI_SCAL_LED
|
||||
# define ISSI_SCAL_LED 0xFF
|
||||
#endif
|
||||
#define ISSI_SCAL_LED_OFF 0x00
|
||||
|
||||
// Set buffer sizes
|
||||
#define ISSI_MAX_LEDS 144
|
||||
#define ISSI_SCALING_SIZE 144
|
||||
#define ISSI_PWM_TRF_SIZE 18
|
||||
#define ISSI_SCALING_TRF_SIZE 18
|
||||
|
||||
// Location of 1st bit for PWM and Scaling registers
|
||||
#define ISSI_PWM_REG_1ST 0x01
|
||||
#define ISSI_SCL_REG_1ST 0x01
|
||||
|
||||
// Map CS SW locations to order in PWM / Scaling buffers
|
||||
// This matches the ORDER in the Datasheet Register not the POSITION
|
||||
// It will always count from 0x00 to (ISSI_MAX_LEDS - 1)
|
||||
#define CS1_SW1 0x00
|
||||
#define CS2_SW1 0x01
|
||||
#define CS3_SW1 0x02
|
||||
#define CS4_SW1 0x03
|
||||
#define CS5_SW1 0x04
|
||||
#define CS6_SW1 0x05
|
||||
#define CS7_SW1 0x06
|
||||
#define CS8_SW1 0x07
|
||||
#define CS9_SW1 0x08
|
||||
#define CS10_SW1 0x09
|
||||
#define CS11_SW1 0x0A
|
||||
#define CS12_SW1 0x0B
|
||||
#define CS13_SW1 0x0C
|
||||
#define CS14_SW1 0x0D
|
||||
#define CS15_SW1 0x0E
|
||||
#define CS16_SW1 0x0F
|
||||
#define CS17_SW1 0x10
|
||||
#define CS18_SW1 0x11
|
||||
|
||||
#define CS1_SW2 0x12
|
||||
#define CS2_SW2 0x13
|
||||
#define CS3_SW2 0x14
|
||||
#define CS4_SW2 0x15
|
||||
#define CS5_SW2 0x16
|
||||
#define CS6_SW2 0x17
|
||||
#define CS7_SW2 0x18
|
||||
#define CS8_SW2 0x19
|
||||
#define CS9_SW2 0x1A
|
||||
#define CS10_SW2 0x1B
|
||||
#define CS11_SW2 0x1C
|
||||
#define CS12_SW2 0x1D
|
||||
#define CS13_SW2 0x1E
|
||||
#define CS14_SW2 0x1F
|
||||
#define CS15_SW2 0x20
|
||||
#define CS16_SW2 0x21
|
||||
#define CS17_SW2 0x22
|
||||
#define CS18_SW2 0x23
|
||||
|
||||
#define CS1_SW3 0x24
|
||||
#define CS2_SW3 0x25
|
||||
#define CS3_SW3 0x26
|
||||
#define CS4_SW3 0x27
|
||||
#define CS5_SW3 0x28
|
||||
#define CS6_SW3 0x29
|
||||
#define CS7_SW3 0x2A
|
||||
#define CS8_SW3 0x2B
|
||||
#define CS9_SW3 0x2C
|
||||
#define CS10_SW3 0x2D
|
||||
#define CS11_SW3 0x2E
|
||||
#define CS12_SW3 0x2F
|
||||
#define CS13_SW3 0x30
|
||||
#define CS14_SW3 0x31
|
||||
#define CS15_SW3 0x32
|
||||
#define CS16_SW3 0x33
|
||||
#define CS17_SW3 0x34
|
||||
#define CS18_SW3 0x35
|
||||
|
||||
#define CS1_SW4 0x36
|
||||
#define CS2_SW4 0x37
|
||||
#define CS3_SW4 0x38
|
||||
#define CS4_SW4 0x39
|
||||
#define CS5_SW4 0x3A
|
||||
#define CS6_SW4 0x3B
|
||||
#define CS7_SW4 0x3C
|
||||
#define CS8_SW4 0x3D
|
||||
#define CS9_SW4 0x3E
|
||||
#define CS10_SW4 0x3F
|
||||
#define CS11_SW4 0x40
|
||||
#define CS12_SW4 0x41
|
||||
#define CS13_SW4 0x42
|
||||
#define CS14_SW4 0x43
|
||||
#define CS15_SW4 0x44
|
||||
#define CS16_SW4 0x45
|
||||
#define CS17_SW4 0x46
|
||||
#define CS18_SW4 0x47
|
||||
|
||||
#define CS1_SW5 0x48
|
||||
#define CS2_SW5 0x49
|
||||
#define CS3_SW5 0x4A
|
||||
#define CS4_SW5 0x4B
|
||||
#define CS5_SW5 0x4C
|
||||
#define CS6_SW5 0x4D
|
||||
#define CS7_SW5 0x4E
|
||||
#define CS8_SW5 0x4F
|
||||
#define CS9_SW5 0x50
|
||||
#define CS10_SW5 0x51
|
||||
#define CS11_SW5 0x52
|
||||
#define CS12_SW5 0x53
|
||||
#define CS13_SW5 0x54
|
||||
#define CS14_SW5 0x55
|
||||
#define CS15_SW5 0x56
|
||||
#define CS16_SW5 0x57
|
||||
#define CS17_SW5 0x58
|
||||
#define CS18_SW5 0x59
|
||||
|
||||
#define CS1_SW6 0x5A
|
||||
#define CS2_SW6 0x5B
|
||||
#define CS3_SW6 0x5C
|
||||
#define CS4_SW6 0x5D
|
||||
#define CS5_SW6 0x5E
|
||||
#define CS6_SW6 0x5F
|
||||
#define CS7_SW6 0x60
|
||||
#define CS8_SW6 0x61
|
||||
#define CS9_SW6 0x62
|
||||
#define CS10_SW6 0x63
|
||||
#define CS11_SW6 0x64
|
||||
#define CS12_SW6 0x65
|
||||
#define CS13_SW6 0x66
|
||||
#define CS14_SW6 0x67
|
||||
#define CS15_SW6 0x68
|
||||
#define CS16_SW6 0x69
|
||||
#define CS17_SW6 0x6A
|
||||
#define CS18_SW6 0x6B
|
||||
|
||||
#define CS1_SW7 0x6C
|
||||
#define CS2_SW7 0x6D
|
||||
#define CS3_SW7 0x6E
|
||||
#define CS4_SW7 0x6F
|
||||
#define CS5_SW7 0x70
|
||||
#define CS6_SW7 0x71
|
||||
#define CS7_SW7 0x72
|
||||
#define CS8_SW7 0x73
|
||||
#define CS9_SW7 0x74
|
||||
#define CS10_SW7 0x75
|
||||
#define CS11_SW7 0x76
|
||||
#define CS12_SW7 0x77
|
||||
#define CS13_SW7 0x78
|
||||
#define CS14_SW7 0x79
|
||||
#define CS15_SW7 0x7A
|
||||
#define CS16_SW7 0x7B
|
||||
#define CS17_SW7 0x7C
|
||||
#define CS18_SW7 0x7D
|
||||
|
||||
#define CS1_SW8 0x7E
|
||||
#define CS2_SW8 0x7F
|
||||
#define CS3_SW8 0x80
|
||||
#define CS4_SW8 0x81
|
||||
#define CS5_SW8 0x82
|
||||
#define CS6_SW8 0x83
|
||||
#define CS7_SW8 0x84
|
||||
#define CS8_SW8 0x85
|
||||
#define CS9_SW8 0x86
|
||||
#define CS10_SW8 0x87
|
||||
#define CS11_SW8 0x88
|
||||
#define CS12_SW8 0x89
|
||||
#define CS13_SW8 0x8A
|
||||
#define CS14_SW8 0x8B
|
||||
#define CS15_SW8 0x8C
|
||||
#define CS16_SW8 0x8D
|
||||
#define CS17_SW8 0x8E
|
||||
#define CS18_SW8 0x8F
|
||||
198
drivers/led/issi/is31fl3746.h
Normal file
198
drivers/led/issi/is31fl3746.h
Normal file
@@ -0,0 +1,198 @@
|
||||
/* Copyright 2017 Jason Williams
|
||||
* Copyright 2018 Jack Humbert
|
||||
* Copyright 2018 Yiancar
|
||||
* Copyright 2020 MelGeek
|
||||
* Copyright 2021 MasterSpoon
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// This is a 7-bit address, that gets left-shifted and bit 0
|
||||
// set to 0 for write, 1 for read (as per I2C protocol)
|
||||
// The address will vary depending on your wiring:
|
||||
// 00 <-> GND
|
||||
// 01 <-> SCL
|
||||
// 10 <-> SDA
|
||||
// 11 <-> VCC
|
||||
// ADDR1 represents A1:A0 of the 7-bit address.
|
||||
// ADDR2 represents A3:A2 of the 7-bit address.
|
||||
// The result is: 0b110(ADDR2)(ADDR1)
|
||||
#ifndef DRIVER_ADDR_1
|
||||
# define DRIVER_ADDR_1 0b1100000
|
||||
#endif
|
||||
|
||||
// Set defaults for Spread Spectrum Register
|
||||
#ifndef ISSI_SSR_1
|
||||
# define ISSI_SSR_1 0x00
|
||||
#endif
|
||||
#ifndef ISSI_SSR_2
|
||||
# define ISSI_SSR_2 0x00
|
||||
#endif
|
||||
#ifndef ISSI_SSR_3
|
||||
# define ISSI_SSR_3 0x00
|
||||
#endif
|
||||
#ifndef ISSI_SSR_4
|
||||
# define ISSI_SSR_4 0x00
|
||||
#endif
|
||||
|
||||
// Command Registers
|
||||
#define ISSI_COMMANDREGISTER_WRITELOCK 0xFE
|
||||
#define ISSI_COMMANDREGISTER 0xFD
|
||||
#define ISSI_IDREGISTER 0xFC
|
||||
#define ISSI_REGISTER_UNLOCK 0xC5
|
||||
|
||||
// Response Registers
|
||||
#define ISSI_PAGE_PWM 0x00
|
||||
#define ISSI_PAGE_SCALING 0x01
|
||||
#define ISSI_PAGE_FUNCTION 0x01
|
||||
|
||||
// Registers under Function Register
|
||||
#define ISSI_REG_CONFIGURATION 0x50
|
||||
#define ISSI_REG_GLOBALCURRENT 0x51
|
||||
#define ISSI_REG_PULLDOWNUP 0x52
|
||||
#define ISSI_REG_TEMP 0x5F
|
||||
#define ISSI_REG_SSR 0x60
|
||||
#define ISSI_REG_RESET 0x8F
|
||||
#define ISSI_REG_PWM_ENABLE 0xE0
|
||||
#define ISSI_REG_PWM_SET 0xE2
|
||||
|
||||
// Set defaults for Function Registers
|
||||
#ifndef ISSI_CONFIGURATION
|
||||
# define ISSI_CONFIGURATION 0x01
|
||||
#endif
|
||||
#ifndef ISSI_GLOBALCURRENT
|
||||
# define ISSI_GLOBALCURRENT 0xFF
|
||||
#endif
|
||||
#ifndef ISSI_PULLDOWNUP
|
||||
# define ISSI_PULLDOWNUP 0x33
|
||||
#endif
|
||||
#ifndef ISSI_TEMP
|
||||
# define ISSI_TEMP 0x00
|
||||
#endif
|
||||
#ifndef ISSI_PWM_ENABLE
|
||||
# define ISSI_PWM_ENABLE 0x00
|
||||
#endif
|
||||
#ifndef ISSI_PWM_SET
|
||||
# define ISSI_PWM_SET 0x00
|
||||
#endif
|
||||
|
||||
// Set defaults for Scaling registers
|
||||
#ifndef ISSI_SCAL_RED
|
||||
# define ISSI_SCAL_RED 0xFF
|
||||
#endif
|
||||
#ifndef ISSI_SCAL_BLUE
|
||||
# define ISSI_SCAL_BLUE 0xFF
|
||||
#endif
|
||||
#ifndef ISSI_SCAL_GREEN
|
||||
# define ISSI_SCAL_GREEN 0xFF
|
||||
#endif
|
||||
#define ISSI_SCAL_RED_OFF 0x00
|
||||
#define ISSI_SCAL_GREEN_OFF 0x00
|
||||
#define ISSI_SCAL_BLUE_OFF 0x00
|
||||
|
||||
#ifndef ISSI_SCAL_LED
|
||||
# define ISSI_SCAL_LED 0xFF
|
||||
#endif
|
||||
#define ISSI_SCAL_LED_OFF 0x00
|
||||
|
||||
// Set buffer sizes
|
||||
#define ISSI_MAX_LEDS 72
|
||||
#define ISSI_SCALING_SIZE 72
|
||||
#define ISSI_PWM_TRF_SIZE 18
|
||||
#define ISSI_SCALING_TRF_SIZE 18
|
||||
|
||||
// Location of 1st bit for PWM and Scaling registers
|
||||
#define ISSI_PWM_REG_1ST 0x01
|
||||
#define ISSI_SCL_REG_1ST 0x01
|
||||
|
||||
// Map CS SW locations to order in PWM / Scaling buffers
|
||||
// This matches the ORDER in the Datasheet Register not the POSITION
|
||||
// It will always count from 0x00 to (ISSI_MAX_LEDS - 1)
|
||||
#define CS1_SW1 0x00
|
||||
#define CS2_SW1 0x01
|
||||
#define CS3_SW1 0x02
|
||||
#define CS4_SW1 0x03
|
||||
#define CS5_SW1 0x04
|
||||
#define CS6_SW1 0x05
|
||||
#define CS7_SW1 0x06
|
||||
#define CS8_SW1 0x07
|
||||
#define CS9_SW1 0x08
|
||||
#define CS10_SW1 0x09
|
||||
#define CS11_SW1 0x0A
|
||||
#define CS12_SW1 0x0B
|
||||
#define CS13_SW1 0x0C
|
||||
#define CS14_SW1 0x0D
|
||||
#define CS15_SW1 0x0E
|
||||
#define CS16_SW1 0x0F
|
||||
#define CS17_SW1 0x10
|
||||
#define CS18_SW1 0x11
|
||||
|
||||
#define CS1_SW2 0x12
|
||||
#define CS2_SW2 0x13
|
||||
#define CS3_SW2 0x14
|
||||
#define CS4_SW2 0x15
|
||||
#define CS5_SW2 0x16
|
||||
#define CS6_SW2 0x17
|
||||
#define CS7_SW2 0x18
|
||||
#define CS8_SW2 0x19
|
||||
#define CS9_SW2 0x1A
|
||||
#define CS10_SW2 0x1B
|
||||
#define CS11_SW2 0x1C
|
||||
#define CS12_SW2 0x1D
|
||||
#define CS13_SW2 0x1E
|
||||
#define CS14_SW2 0x1F
|
||||
#define CS15_SW2 0x20
|
||||
#define CS16_SW2 0x21
|
||||
#define CS17_SW2 0x22
|
||||
#define CS18_SW2 0x23
|
||||
|
||||
#define CS1_SW3 0x24
|
||||
#define CS2_SW3 0x25
|
||||
#define CS3_SW3 0x26
|
||||
#define CS4_SW3 0x27
|
||||
#define CS5_SW3 0x28
|
||||
#define CS6_SW3 0x29
|
||||
#define CS7_SW3 0x2A
|
||||
#define CS8_SW3 0x2B
|
||||
#define CS9_SW3 0x2C
|
||||
#define CS10_SW3 0x2D
|
||||
#define CS11_SW3 0x2E
|
||||
#define CS12_SW3 0x2F
|
||||
#define CS13_SW3 0x30
|
||||
#define CS14_SW3 0x31
|
||||
#define CS15_SW3 0x32
|
||||
#define CS16_SW3 0x33
|
||||
#define CS17_SW3 0x34
|
||||
#define CS18_SW3 0x35
|
||||
|
||||
#define CS1_SW4 0x36
|
||||
#define CS2_SW4 0x37
|
||||
#define CS3_SW4 0x38
|
||||
#define CS4_SW4 0x39
|
||||
#define CS5_SW4 0x3A
|
||||
#define CS6_SW4 0x3B
|
||||
#define CS7_SW4 0x3C
|
||||
#define CS8_SW4 0x3D
|
||||
#define CS9_SW4 0x3E
|
||||
#define CS10_SW4 0x3F
|
||||
#define CS11_SW4 0x40
|
||||
#define CS12_SW4 0x41
|
||||
#define CS13_SW4 0x42
|
||||
#define CS14_SW4 0x43
|
||||
#define CS15_SW4 0x44
|
||||
#define CS16_SW4 0x45
|
||||
#define CS17_SW4 0x46
|
||||
#define CS18_SW4 0x47
|
||||
230
drivers/led/issi/is31flcommon.c
Normal file
230
drivers/led/issi/is31flcommon.c
Normal file
@@ -0,0 +1,230 @@
|
||||
/* Copyright 2017 Jason Williams
|
||||
* Copyright 2018 Jack Humbert
|
||||
* Copyright 2018 Yiancar
|
||||
* Copyright 2020 MelGeek
|
||||
* Copyright 2021 MasterSpoon
|
||||
*
|
||||
* 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 "is31flcommon.h"
|
||||
#include "i2c_master.h"
|
||||
#include "wait.h"
|
||||
#include <string.h>
|
||||
|
||||
// Set defaults for Timeout and Persistence
|
||||
#ifndef ISSI_TIMEOUT
|
||||
# define ISSI_TIMEOUT 100
|
||||
#endif
|
||||
#ifndef ISSI_PERSISTENCE
|
||||
# define ISSI_PERSISTENCE 0
|
||||
#endif
|
||||
|
||||
// Transfer buffer for TWITransmitData()
|
||||
uint8_t g_twi_transfer_buffer[20];
|
||||
|
||||
// These buffers match the PWM & scaling registers.
|
||||
// Storing them like this is optimal for I2C transfers to the registers.
|
||||
uint8_t g_pwm_buffer[DRIVER_COUNT][ISSI_MAX_LEDS];
|
||||
bool g_pwm_buffer_update_required[DRIVER_COUNT] = {false};
|
||||
|
||||
uint8_t g_scaling_buffer[DRIVER_COUNT][ISSI_SCALING_SIZE];
|
||||
bool g_scaling_buffer_update_required[DRIVER_COUNT] = {false};
|
||||
|
||||
// For writing of single register entry
|
||||
void IS31FL_write_single_register(uint8_t addr, uint8_t reg, uint8_t data) {
|
||||
// Set register address and register data ready to write
|
||||
g_twi_transfer_buffer[0] = reg;
|
||||
g_twi_transfer_buffer[1] = data;
|
||||
|
||||
#if ISSI_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0) break;
|
||||
}
|
||||
#else
|
||||
i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
// For writing of mulitple register entries to make use of address auto increment
|
||||
// Once the controller has been called and we have written the first bit of data
|
||||
// the controller will move to the next register meaning we can write sequential blocks.
|
||||
bool IS31FL_write_multi_registers(uint8_t addr, uint8_t *source_buffer, uint8_t buffer_size, uint8_t transfer_size, uint8_t start_reg_addr) {
|
||||
// Split the buffer into chunks to transfer
|
||||
for (int i = 0; i < buffer_size; i += transfer_size) {
|
||||
// Set the first entry of transfer buffer to the first register we want to write
|
||||
g_twi_transfer_buffer[0] = i + start_reg_addr;
|
||||
// Copy the section of our source buffer into the transfer buffer after first register address
|
||||
memcpy(g_twi_transfer_buffer + 1, source_buffer + i, transfer_size);
|
||||
|
||||
#if ISSI_PERSISTENCE > 0
|
||||
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, transfer_size + 1, ISSI_TIMEOUT) != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (i2c_transmit(addr << 1, g_twi_transfer_buffer, transfer_size + 1, ISSI_TIMEOUT) != 0) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void IS31FL_unlock_register(uint8_t addr, uint8_t page) {
|
||||
// unlock the command register and select Page to write
|
||||
IS31FL_write_single_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, ISSI_REGISTER_UNLOCK);
|
||||
IS31FL_write_single_register(addr, ISSI_COMMANDREGISTER, page);
|
||||
}
|
||||
|
||||
void IS31FL_common_init(uint8_t addr, uint8_t ssr) {
|
||||
// Setup phase, need to take out of software shutdown and configure
|
||||
// ISSI_SSR_x is passed to allow Master / Slave setting where applicable
|
||||
|
||||
// Unlock the command register & select Function Register
|
||||
IS31FL_unlock_register(addr, ISSI_PAGE_FUNCTION);
|
||||
// Set Configuration Register to remove Software shutdown
|
||||
IS31FL_write_single_register(addr, ISSI_REG_CONFIGURATION, ISSI_CONFIGURATION);
|
||||
// Set Golbal Current Control Register
|
||||
IS31FL_write_single_register(addr, ISSI_REG_GLOBALCURRENT, ISSI_GLOBALCURRENT);
|
||||
// Set Pull up & Down for SWx CSy
|
||||
IS31FL_write_single_register(addr, ISSI_REG_PULLDOWNUP, ISSI_PULLDOWNUP);
|
||||
// Set Tempature Status
|
||||
#ifdef ISSI_REG_TEMP
|
||||
IS31FL_write_single_register(addr, ISSI_REG_TEMP, ISSI_TEMP);
|
||||
#endif
|
||||
// Set Spread Spectrum Register, passed through as sets SYNC function
|
||||
IS31FL_write_single_register(addr, ISSI_REG_SSR, ssr);
|
||||
// Set PWM Frequency Enable Register if applicable
|
||||
#ifdef ISSI_REG_PWM_ENABLE
|
||||
IS31FL_write_single_register(addr, ISSI_REG_PWM_ENABLE, ISSI_PWM_ENABLE);
|
||||
#endif
|
||||
// Set PWM Frequency Register if applicable
|
||||
#ifdef ISSI_REG_PWM_SET
|
||||
IS31FL_write_single_register(addr, ISSI_REG_PWM_SET, ISSI_PWM_SET);
|
||||
#endif
|
||||
|
||||
// Wait 10ms to ensure the device has woken up.
|
||||
wait_ms(10);
|
||||
}
|
||||
|
||||
void IS31FL_common_update_pwm_register(uint8_t addr, uint8_t index) {
|
||||
if (g_pwm_buffer_update_required[index]) {
|
||||
// Queue up the correct page
|
||||
IS31FL_unlock_register(addr, ISSI_PAGE_PWM);
|
||||
// Hand off the update to IS31FL_write_multi_registers
|
||||
IS31FL_write_multi_registers(addr, g_pwm_buffer[index], ISSI_MAX_LEDS, ISSI_PWM_TRF_SIZE, ISSI_PWM_REG_1ST);
|
||||
// Update flags that pwm_buffer has been updated
|
||||
g_pwm_buffer_update_required[index] = false;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ISSI_MANUAL_SCALING
|
||||
void IS31FL_set_manual_scaling_buffer(void) {
|
||||
for (int i = 0; i < ISSI_MANUAL_SCALING; i++) {
|
||||
is31_led scale = g_is31_scaling[i];
|
||||
if (scale.driver >= 0 && scale.driver < DRIVER_LED_TOTAL) {
|
||||
is31_led led = g_is31_leds[scale.driver];
|
||||
|
||||
# ifdef RGB_MATRIX_ENABLE
|
||||
g_scaling_buffer[led.driver][led.r] = scale.r;
|
||||
g_scaling_buffer[led.driver][led.g] = scale.g;
|
||||
g_scaling_buffer[led.driver][led.b] = scale.b;
|
||||
# elif defined(LED_MATRIX_ENABLE)
|
||||
g_scaling_buffer[led.driver][led.v] = scale.v;
|
||||
# endif
|
||||
g_scaling_buffer_update_required[led.driver] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void IS31FL_common_update_scaling_register(uint8_t addr, uint8_t index) {
|
||||
if (g_scaling_buffer_update_required[index]) {
|
||||
// Queue up the correct page
|
||||
IS31FL_unlock_register(addr, ISSI_PAGE_SCALING);
|
||||
// Hand off the update to IS31FL_write_multi_registers
|
||||
IS31FL_write_multi_registers(addr, g_scaling_buffer[index], ISSI_SCALING_SIZE, ISSI_SCALING_TRF_SIZE, ISSI_SCL_REG_1ST);
|
||||
// Update flags that scaling_buffer has been updated
|
||||
g_scaling_buffer_update_required[index] = false;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
// Colour is set by adjusting PWM register
|
||||
void IS31FL_RGB_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
if (index >= 0 && index < DRIVER_LED_TOTAL) {
|
||||
is31_led led = g_is31_leds[index];
|
||||
|
||||
g_pwm_buffer[led.driver][led.r] = red;
|
||||
g_pwm_buffer[led.driver][led.g] = green;
|
||||
g_pwm_buffer[led.driver][led.b] = blue;
|
||||
g_pwm_buffer_update_required[led.driver] = true;
|
||||
}
|
||||
}
|
||||
|
||||
void IS31FL_RGB_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
|
||||
for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
|
||||
IS31FL_RGB_set_color(i, red, green, blue);
|
||||
}
|
||||
}
|
||||
|
||||
// Setup Scaling register that decides the peak current of each LED
|
||||
void IS31FL_RGB_set_scaling_buffer(uint8_t index, bool red, bool green, bool blue) {
|
||||
is31_led led = g_is31_leds[index];
|
||||
if (red) {
|
||||
g_scaling_buffer[led.driver][led.r] = ISSI_SCAL_RED;
|
||||
} else {
|
||||
g_scaling_buffer[led.driver][led.r] = ISSI_SCAL_RED_OFF;
|
||||
}
|
||||
if (green) {
|
||||
g_scaling_buffer[led.driver][led.g] = ISSI_SCAL_GREEN;
|
||||
} else {
|
||||
g_scaling_buffer[led.driver][led.g] = ISSI_SCAL_GREEN_OFF;
|
||||
}
|
||||
if (blue) {
|
||||
g_scaling_buffer[led.driver][led.b] = ISSI_SCAL_BLUE;
|
||||
} else {
|
||||
g_scaling_buffer[led.driver][led.b] = ISSI_SCAL_BLUE_OFF;
|
||||
}
|
||||
g_scaling_buffer_update_required[led.driver] = true;
|
||||
}
|
||||
|
||||
#elif defined(LED_MATRIX_ENABLE)
|
||||
// LED Matrix Specific scripts
|
||||
void IS31FL_simple_set_scaling_buffer(uint8_t index, bool value) {
|
||||
is31_led led = g_is31_leds[index];
|
||||
if (value) {
|
||||
g_scaling_buffer[led.driver][led.v] = ISSI_SCAL_LED;
|
||||
} else {
|
||||
g_scaling_buffer[led.driver][led.v] = ISSI_SCAL_LED_OFF;
|
||||
}
|
||||
g_scaling_buffer_update_required[led.driver] = true;
|
||||
}
|
||||
|
||||
void IS31FL_simple_set_brightness(int index, uint8_t value) {
|
||||
if (index >= 0 && index < DRIVER_LED_TOTAL) {
|
||||
is31_led led = g_is31_leds[index];
|
||||
g_pwm_buffer[led.driver][led.v] = value;
|
||||
g_pwm_buffer_update_required[led.driver] = true;
|
||||
}
|
||||
}
|
||||
|
||||
void IS31FL_simple_set_brigntness_all(uint8_t value) {
|
||||
for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
|
||||
IS31FL_simple_set_brightness(i, value);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
78
drivers/led/issi/is31flcommon.h
Normal file
78
drivers/led/issi/is31flcommon.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/* Copyright 2017 Jason Williams
|
||||
* Copyright 2018 Jack Humbert
|
||||
* Copyright 2018 Yiancar
|
||||
* Copyright 2020 MelGeek
|
||||
* Copyright 2021 MasterSpoon
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "progmem.h"
|
||||
|
||||
// Which variant header file to use
|
||||
#ifdef IS31FL3742A
|
||||
# include "is31fl3742.h"
|
||||
#elif defined(IS31FL3743A)
|
||||
# include "is31fl3743.h"
|
||||
#elif defined(IS31FL3745)
|
||||
# include "is31fl3745.h"
|
||||
#elif defined(IS31FL3746A)
|
||||
# include "is31fl3746.h"
|
||||
#endif
|
||||
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
typedef struct is31_led {
|
||||
uint8_t driver;
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
} __attribute__((packed)) is31_led;
|
||||
|
||||
#elif defined(LED_MATRIX_ENABLE)
|
||||
typedef struct is31_led {
|
||||
uint8_t driver;
|
||||
uint8_t v;
|
||||
} __attribute__((packed)) is31_led;
|
||||
#endif
|
||||
|
||||
#ifdef ISSI_MANUAL_SCALING
|
||||
extern const is31_led __flash g_is31_scaling[];
|
||||
void IS31FL_set_manual_scaling_buffer(void);
|
||||
#endif
|
||||
|
||||
extern const is31_led __flash g_is31_leds[DRIVER_LED_TOTAL];
|
||||
|
||||
void IS31FL_write_single_register(uint8_t addr, uint8_t reg, uint8_t data);
|
||||
bool IS31FL_write_multi_registers(uint8_t addr, uint8_t *source_buffer, uint8_t buffer_size, uint8_t transfer_size, uint8_t start_reg_addr);
|
||||
void IS31FL_unlock_register(uint8_t addr, uint8_t page);
|
||||
void IS31FL_common_init(uint8_t addr, uint8_t ssr);
|
||||
|
||||
void IS31FL_common_update_pwm_register(uint8_t addr, uint8_t index);
|
||||
void IS31FL_common_update_scaling_register(uint8_t addr, uint8_t index);
|
||||
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
// RGB Matrix Specific scripts
|
||||
void IS31FL_RGB_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
|
||||
void IS31FL_RGB_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
|
||||
void IS31FL_RGB_set_scaling_buffer(uint8_t index, bool red, bool green, bool blue);
|
||||
#elif defined(LED_MATRIX_ENABLE)
|
||||
// LED Matrix Specific scripts
|
||||
void IS31FL_simple_set_scaling_buffer(uint8_t index, bool value);
|
||||
void IS31FL_simple_set_brightness(int index, uint8_t value);
|
||||
void IS31FL_simple_set_brigntness_all(uint8_t value);
|
||||
#endif
|
||||
294
drivers/sensors/pmw3389.c
Normal file
294
drivers/sensors/pmw3389.c
Normal file
@@ -0,0 +1,294 @@
|
||||
/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
|
||||
* Copyright 2019 Sunjun Kim
|
||||
* Copyright 2020 Ploopy Corporation
|
||||
*
|
||||
* 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 "spi_master.h"
|
||||
#include "pmw3389.h"
|
||||
#include "wait.h"
|
||||
#include "debug.h"
|
||||
#include "print.h"
|
||||
#include "pmw3389_firmware.h"
|
||||
|
||||
// Registers
|
||||
// clang-format off
|
||||
#define REG_Product_ID 0x00
|
||||
#define REG_Revision_ID 0x01
|
||||
#define REG_Motion 0x02
|
||||
#define REG_Delta_X_L 0x03
|
||||
#define REG_Delta_X_H 0x04
|
||||
#define REG_Delta_Y_L 0x05
|
||||
#define REG_Delta_Y_H 0x06
|
||||
#define REG_SQUAL 0x07
|
||||
#define REG_RawData_Sum 0x08
|
||||
#define REG_Maximum_RawData 0x09
|
||||
#define REG_Minimum_RawData 0x0a
|
||||
#define REG_Shutter_Lower 0x0b
|
||||
#define REG_Shutter_Upper 0x0c
|
||||
#define REG_Ripple_Control 0x0d
|
||||
#define REG_Resolution_L 0x0e
|
||||
#define REG_Resolution_H 0x0f
|
||||
#define REG_Config2 0x10
|
||||
#define REG_Angle_Tune 0x11
|
||||
#define REG_Frame_Capture 0x12
|
||||
#define REG_SROM_Enable 0x13
|
||||
#define REG_Run_Downshift 0x14
|
||||
#define REG_Rest1_Rate_Lower 0x15
|
||||
#define REG_Rest1_Rate_Upper 0x16
|
||||
#define REG_Rest1_Downshift 0x17
|
||||
#define REG_Rest2_Rate_Lower 0x18
|
||||
#define REG_Rest2_Rate_Upper 0x19
|
||||
#define REG_Rest2_Downshift 0x1a
|
||||
#define REG_Rest3_Rate_Lower 0x1b
|
||||
#define REG_Rest3_Rate_Upper 0x1c
|
||||
#define REG_Observation 0x24
|
||||
#define REG_Data_Out_Lower 0x25
|
||||
#define REG_Data_Out_Upper 0x26
|
||||
#define REG_SROM_ID 0x2a
|
||||
#define REG_Min_SQ_Run 0x2b
|
||||
#define REG_RawData_Threshold 0x2c
|
||||
#define REG_Control2 0x2d
|
||||
#define REG_Config5_L 0x2e
|
||||
#define REG_Config5_H 0x2f
|
||||
#define REG_Power_Up_Reset 0X3a
|
||||
#define REG_Shutdown 0x3b
|
||||
#define REG_Inverse_Product_ID 0x3f
|
||||
#define REG_LiftCutoff_Cal3 0x41
|
||||
#define REG_Angle_Snap 0x42
|
||||
#define REG_LiftCutoff_Cal1 0x4a
|
||||
#define REG_Motion_Burst 0x50
|
||||
#define REG_SROM_Load_Burst 0x62
|
||||
#define REG_Lift_Config 0x63
|
||||
#define REG_RawData_Burst 0x64
|
||||
#define REG_LiftCutoff_Cal2 0x65
|
||||
#define REG_LiftCutoff_Cal_Timeout 0x71
|
||||
#define REG_LiftCutoff_Cal_Min_Length 0x72
|
||||
#define REG_PWM_Period_Cnt 0x73
|
||||
#define REG_PWM_Width_Cnt 0x74
|
||||
|
||||
#define CPI_STEP 50
|
||||
// clang-format on
|
||||
|
||||
// limits to 0--319, resulting in a CPI range of 50 -- 16000 (as only steps of 50 are possible).
|
||||
#ifndef MAX_CPI
|
||||
# define MAX_CPI 0x013f
|
||||
#endif
|
||||
|
||||
bool _inBurst = false;
|
||||
|
||||
#ifdef CONSOLE_ENABLE
|
||||
void print_byte(uint8_t byte) {
|
||||
dprintf("%c%c%c%c%c%c%c%c|", (byte & 0x80 ? '1' : '0'), (byte & 0x40 ? '1' : '0'), (byte & 0x20 ? '1' : '0'), (byte & 0x10 ? '1' : '0'), (byte & 0x08 ? '1' : '0'), (byte & 0x04 ? '1' : '0'), (byte & 0x02 ? '1' : '0'), (byte & 0x01 ? '1' : '0'));
|
||||
}
|
||||
#endif
|
||||
#define constrain(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt)))
|
||||
|
||||
bool pmw3389_spi_start(void) {
|
||||
bool status = spi_start(PMW3389_CS_PIN, PMW3389_SPI_LSBFIRST, PMW3389_SPI_MODE, PMW3389_SPI_DIVISOR);
|
||||
// tNCS-SCLK, 120ns
|
||||
wait_us(1);
|
||||
return status;
|
||||
}
|
||||
|
||||
spi_status_t pmw3389_write(uint8_t reg_addr, uint8_t data) {
|
||||
pmw3389_spi_start();
|
||||
|
||||
if (reg_addr != REG_Motion_Burst) {
|
||||
_inBurst = false;
|
||||
}
|
||||
|
||||
// send address of the register, with MSBit = 1 to indicate it's a write
|
||||
spi_status_t status = spi_write(reg_addr | 0x80);
|
||||
status = spi_write(data);
|
||||
|
||||
// tSCLK-NCS for write operation is 35 us
|
||||
wait_us(35);
|
||||
spi_stop();
|
||||
|
||||
// tSWW/tSWR (=180us) minus tSCLK-NCS. Could be shortened, but is looks like a safe lower bound
|
||||
wait_us(145);
|
||||
return status;
|
||||
}
|
||||
|
||||
uint8_t pmw3389_read(uint8_t reg_addr) {
|
||||
pmw3389_spi_start();
|
||||
// send adress of the register, with MSBit = 0 to indicate it's a read
|
||||
spi_write(reg_addr & 0x7f);
|
||||
// tSRAD (=160us)
|
||||
wait_us(160);
|
||||
uint8_t data = spi_read();
|
||||
|
||||
// tSCLK-NCS, 120ns
|
||||
wait_us(1);
|
||||
spi_stop();
|
||||
|
||||
// tSRW/tSRR (=20us) minus tSCLK-NCS
|
||||
wait_us(19);
|
||||
return data;
|
||||
}
|
||||
|
||||
bool pmw3389_init(void) {
|
||||
setPinOutput(PMW3389_CS_PIN);
|
||||
|
||||
spi_init();
|
||||
_inBurst = false;
|
||||
|
||||
spi_stop();
|
||||
pmw3389_spi_start();
|
||||
spi_stop();
|
||||
|
||||
pmw3389_write(REG_Shutdown, 0xb6); // Shutdown first
|
||||
wait_ms(300);
|
||||
|
||||
pmw3389_spi_start();
|
||||
wait_us(40);
|
||||
spi_stop();
|
||||
wait_us(40);
|
||||
|
||||
// power up, need to first drive NCS high then low, see above.
|
||||
pmw3389_write(REG_Power_Up_Reset, 0x5a);
|
||||
wait_ms(50);
|
||||
|
||||
// read registers and discard
|
||||
pmw3389_read(REG_Motion);
|
||||
pmw3389_read(REG_Delta_X_L);
|
||||
pmw3389_read(REG_Delta_X_H);
|
||||
pmw3389_read(REG_Delta_Y_L);
|
||||
pmw3389_read(REG_Delta_Y_H);
|
||||
|
||||
pmw3389_upload_firmware();
|
||||
|
||||
spi_stop();
|
||||
|
||||
wait_ms(10);
|
||||
pmw3389_set_cpi(PMW3389_CPI);
|
||||
|
||||
wait_ms(1);
|
||||
|
||||
pmw3389_write(REG_Config2, 0x00);
|
||||
|
||||
pmw3389_write(REG_Angle_Tune, constrain(ROTATIONAL_TRANSFORM_ANGLE, -127, 127));
|
||||
|
||||
pmw3389_write(REG_Lift_Config, PMW3389_LIFTOFF_DISTANCE);
|
||||
|
||||
bool init_success = pmw3389_check_signature();
|
||||
#ifdef CONSOLE_ENABLE
|
||||
if (init_success) {
|
||||
dprintf("pmw3389 signature verified");
|
||||
} else {
|
||||
dprintf("pmw3389 signature verification failed!");
|
||||
}
|
||||
#endif
|
||||
|
||||
writePinLow(PMW3389_CS_PIN);
|
||||
|
||||
return init_success;
|
||||
}
|
||||
|
||||
void pmw3389_upload_firmware(void) {
|
||||
// Datasheet claims we need to disable REST mode first, but during startup
|
||||
// it's already disabled and we're not turning it on ...
|
||||
// pmw3389_write(REG_Config2, 0x00); // disable REST mode
|
||||
pmw3389_write(REG_SROM_Enable, 0x1d);
|
||||
|
||||
wait_ms(10);
|
||||
|
||||
pmw3389_write(REG_SROM_Enable, 0x18);
|
||||
|
||||
pmw3389_spi_start();
|
||||
spi_write(REG_SROM_Load_Burst | 0x80);
|
||||
wait_us(15);
|
||||
|
||||
for (uint16_t i = 0; i < FIRMWARE_LENGTH; i++) {
|
||||
spi_write(pgm_read_byte(firmware_data + i));
|
||||
#ifndef PMW3389_FIRMWARE_UPLOAD_FAST
|
||||
wait_us(15);
|
||||
#endif
|
||||
}
|
||||
wait_us(200);
|
||||
|
||||
pmw3389_read(REG_SROM_ID);
|
||||
pmw3389_write(REG_Config2, 0x00);
|
||||
}
|
||||
|
||||
bool pmw3389_check_signature(void) {
|
||||
uint8_t pid = pmw3389_read(REG_Product_ID);
|
||||
uint8_t iv_pid = pmw3389_read(REG_Inverse_Product_ID);
|
||||
uint8_t SROM_ver = pmw3389_read(REG_SROM_ID);
|
||||
return (pid == firmware_signature[0] && iv_pid == firmware_signature[1] && SROM_ver == firmware_signature[2]); // signature for SROM 0x04
|
||||
}
|
||||
|
||||
uint16_t pmw3389_get_cpi(void) {
|
||||
uint16_t cpival = (pmw3389_read(REG_Resolution_H) << 8) | pmw3389_read(REG_Resolution_L);
|
||||
return (uint16_t)((cpival + 1) & 0xffff) * CPI_STEP;
|
||||
}
|
||||
|
||||
void pmw3389_set_cpi(uint16_t cpi) {
|
||||
uint16_t cpival = constrain((cpi / CPI_STEP) - 1, 0, MAX_CPI);
|
||||
// Sets upper byte first for more consistent setting of cpi
|
||||
pmw3389_write(REG_Resolution_H, (cpival >> 8) & 0xff);
|
||||
pmw3389_write(REG_Resolution_L, cpival & 0xff);
|
||||
}
|
||||
|
||||
report_pmw3389_t pmw3389_read_burst(void) {
|
||||
report_pmw3389_t report = {0};
|
||||
|
||||
if (!_inBurst) {
|
||||
#ifdef CONSOLE_ENABLE
|
||||
dprintf("burst on");
|
||||
#endif
|
||||
pmw3389_write(REG_Motion_Burst, 0x00);
|
||||
_inBurst = true;
|
||||
}
|
||||
|
||||
pmw3389_spi_start();
|
||||
spi_write(REG_Motion_Burst);
|
||||
wait_us(35); // waits for tSRAD_MOTBR
|
||||
|
||||
report.motion = spi_read();
|
||||
spi_read(); // skip Observation
|
||||
// delta registers
|
||||
report.dx = spi_read();
|
||||
report.mdx = spi_read();
|
||||
report.dy = spi_read();
|
||||
report.mdy = spi_read();
|
||||
|
||||
if (report.motion & 0b111) { // panic recovery, sometimes burst mode works weird.
|
||||
_inBurst = false;
|
||||
}
|
||||
|
||||
spi_stop();
|
||||
|
||||
#ifdef CONSOLE_ENABLE
|
||||
if (debug_mouse) {
|
||||
print_byte(report.motion);
|
||||
print_byte(report.dx);
|
||||
print_byte(report.mdx);
|
||||
print_byte(report.dy);
|
||||
print_byte(report.mdy);
|
||||
dprintf("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
report.isMotion = (report.motion & 0x80) != 0;
|
||||
report.isOnSurface = (report.motion & 0x08) == 0;
|
||||
report.dx |= (report.mdx << 8);
|
||||
report.dx = report.dx * -1;
|
||||
report.dy |= (report.mdy << 8);
|
||||
report.dy = report.dy * -1;
|
||||
|
||||
return report;
|
||||
}
|
||||
76
drivers/sensors/pmw3389.h
Normal file
76
drivers/sensors/pmw3389.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/* Copyright 2021 Alabastard (@Alabastard-64)
|
||||
* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
|
||||
* Copyright 2019 Sunjun Kim
|
||||
* Copyright 2020 Ploopy Corporation
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef PMW3389_CPI
|
||||
# define PMW3389_CPI 2000
|
||||
#endif
|
||||
|
||||
#ifndef PMW3389_CLOCK_SPEED
|
||||
# define PMW3389_CLOCK_SPEED 2000000
|
||||
#endif
|
||||
|
||||
#ifndef PMW3389_SPI_LSBFIRST
|
||||
# define PMW3389_SPI_LSBFIRST false
|
||||
#endif
|
||||
|
||||
#ifndef PMW3389_SPI_MODE
|
||||
# define PMW3389_SPI_MODE 3
|
||||
#endif
|
||||
|
||||
#ifndef PMW3389_SPI_DIVISOR
|
||||
# ifdef __AVR__
|
||||
# define PMW3389_SPI_DIVISOR (F_CPU / PMW3389_CLOCK_SPEED)
|
||||
# else
|
||||
# define PMW3389_SPI_DIVISOR 64
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef PMW3389_LIFTOFF_DISTANCE
|
||||
# define PMW3389_LIFTOFF_DISTANCE 0x02
|
||||
#endif
|
||||
|
||||
#ifndef ROTATIONAL_TRANSFORM_ANGLE
|
||||
# define ROTATIONAL_TRANSFORM_ANGLE 0x00
|
||||
#endif
|
||||
|
||||
#ifndef PMW3389_CS_PIN
|
||||
# error "No chip select pin defined -- missing PMW3389_CS_PIN"
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int8_t motion;
|
||||
bool isMotion; // True if a motion is detected.
|
||||
bool isOnSurface; // True when a chip is on a surface
|
||||
int16_t dx; // displacement on x directions. Unit: Count. (CPI * Count = Inch value)
|
||||
int8_t mdx;
|
||||
int16_t dy; // displacement on y directions.
|
||||
int8_t mdy;
|
||||
} report_pmw3389_t;
|
||||
|
||||
bool pmw3389_init(void);
|
||||
void pmw3389_upload_firmware(void);
|
||||
bool pmw3389_check_signature(void);
|
||||
uint16_t pmw3389_get_cpi(void);
|
||||
void pmw3389_set_cpi(uint16_t cpi);
|
||||
/* Reads and clears the current delta values on the sensor */
|
||||
report_pmw3389_t pmw3389_read_burst(void);
|
||||
@@ -64,5 +64,3 @@
|
||||
//#define NO_ACTION_LAYER
|
||||
//#define NO_ACTION_TAPPING
|
||||
//#define NO_ACTION_ONESHOT
|
||||
//#define NO_ACTION_MACRO
|
||||
//#define NO_ACTION_FUNCTION
|
||||
|
||||
@@ -58,5 +58,3 @@
|
||||
//#define NO_ACTION_LAYER
|
||||
//#define NO_ACTION_TAPPING
|
||||
//#define NO_ACTION_ONESHOT
|
||||
//#define NO_ACTION_MACRO
|
||||
//#define NO_ACTION_FUNCTION
|
||||
|
||||
@@ -19,13 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "config_common.h"
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0xE117
|
||||
#define PRODUCT_ID 0x6161
|
||||
#define DEVICE_VER 0x0001
|
||||
#define MANUFACTURER 0xC7
|
||||
#define PRODUCT 61Key
|
||||
|
||||
/* key matrix size */
|
||||
#define MATRIX_ROWS 5
|
||||
#define MATRIX_COLS 14
|
||||
@@ -143,10 +136,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//#define NO_ACTION_TAPPING
|
||||
//#define NO_ACTION_ONESHOT
|
||||
|
||||
/* disable these deprecated features by default */
|
||||
#define NO_ACTION_MACRO
|
||||
#define NO_ACTION_FUNCTION
|
||||
|
||||
/* Bootmagic Lite key configuration */
|
||||
//#define BOOTMAGIC_LITE_ROW 0
|
||||
//#define BOOTMAGIC_LITE_COLUMN 0
|
||||
//#define BOOTMAGIC_LITE_COLUMN 0
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
{
|
||||
"keyboard_name": "61Key",
|
||||
"manufacturer": "0xC7",
|
||||
"url": "",
|
||||
"maintainer": "RealEmanGaming",
|
||||
"usb": {
|
||||
"vid": "0xE117",
|
||||
"pid": "0x6161",
|
||||
"device_version": "0.0.1"
|
||||
},
|
||||
"layout_aliases": {
|
||||
"LAYOUT": "LAYOUT_60_ansi"
|
||||
},
|
||||
|
||||
@@ -19,13 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include "config_common.h"
|
||||
// clang-format off
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0xCB00
|
||||
#define PRODUCT_ID 0x1337
|
||||
#define DEVICE_VER 0x0001
|
||||
#define MANUFACTURER 0xCB
|
||||
#define PRODUCT 1337
|
||||
|
||||
/* key matrix size */
|
||||
#define MATRIX_ROWS 3
|
||||
#define MATRIX_COLS 3
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
{
|
||||
"keyboard_name": "0xCB 1337",
|
||||
"keyboard_name": "1337",
|
||||
"manufacturer": "0xCB",
|
||||
"url": "https://0xCB.dev",
|
||||
"maintainer": "Conor-Burns",
|
||||
"usb": {
|
||||
"vid": "0xCB00",
|
||||
"pid": "0x1337",
|
||||
"device_version": "0.0.1"
|
||||
},
|
||||
"layouts": {
|
||||
"LAYOUT": {
|
||||
"layout": [
|
||||
|
||||
@@ -18,12 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "config_common.h"
|
||||
// clang-format off
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0xCB00
|
||||
#define PRODUCT_ID 0xA455
|
||||
#define DEVICE_VER 0x0001
|
||||
#define MANUFACTURER 0xCB
|
||||
#define PRODUCT Static
|
||||
|
||||
/* key matrix size */
|
||||
#define MATRIX_ROWS 8
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
{
|
||||
"keyboard_name": "0xCB Static",
|
||||
"keyboard_name": "Static",
|
||||
"manufacturer": "0xCB",
|
||||
"url": "https://0xCB.dev",
|
||||
"maintainer": "Conor-Burns",
|
||||
"usb": {
|
||||
"vid": "0xCB00",
|
||||
"pid": "0xA455",
|
||||
"device_version": "0.0.1"
|
||||
},
|
||||
"layout_aliases": {
|
||||
"LAYOUT": "LAYOUT_all"
|
||||
},
|
||||
|
||||
@@ -17,11 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/
|
||||
#pragma once
|
||||
|
||||
#include "config_common.h"
|
||||
#define VENDOR_ID 0x7C88 // "hw" = haierwangwei2005
|
||||
#define PRODUCT_ID 0x7C99 // "10b" = 10bleoledhub
|
||||
#define DEVICE_VER 0x0001
|
||||
#define MANUFACTURER haierwangwei2005
|
||||
#define PRODUCT 10bleoledhub
|
||||
|
||||
/* key matrix size */
|
||||
#define MATRIX_ROWS 4
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
{
|
||||
"keyboard_name": "10bleoledhub",
|
||||
"manufacturer": "haierwangwei2005",
|
||||
"url": "https://github.com/haierwangwei2005/10BLE-OLED-HUB",
|
||||
"maintainer": "haierwangwei2005",
|
||||
"usb": {
|
||||
"vid": "0x7C88",
|
||||
"pid": "0x7C99",
|
||||
"device_version": "0.0.1"
|
||||
},
|
||||
"layouts": {
|
||||
"LAYOUT": {
|
||||
"layout": [
|
||||
|
||||
@@ -20,7 +20,7 @@ BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
|
||||
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
|
||||
AUDIO_ENABLE = no # Audio output
|
||||
BLUETOOTH_ENABLE = yes
|
||||
BLUETOOTH_DRIVER = AdafruitBLE
|
||||
BLUETOOTH_DRIVER = BluefruitLE
|
||||
OLED_ENABLE = yes
|
||||
OLED_DRIVER = SSD1306
|
||||
ENCODER_ENABLE = yes
|
||||
|
||||
16
keyboards/1k/1k.c
Normal file
16
keyboards/1k/1k.c
Normal file
@@ -0,0 +1,16 @@
|
||||
/* Copyright 2020 zvecr<git@zvecr.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 "1k.h"
|
||||
33
keyboards/1k/1k.h
Normal file
33
keyboards/1k/1k.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/* Copyright 2020 zvecr<git@zvecr.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/>.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "quantum.h"
|
||||
|
||||
/* This a shortcut to help you visually see your layout.
|
||||
*
|
||||
* The first section contains all of the arguments representing the physical
|
||||
* layout of the board and position of the keys.
|
||||
*
|
||||
* The second converts the arguments into a two-dimensional array which
|
||||
* represents the switch matrix.
|
||||
*/
|
||||
#define LAYOUT_ortho_1x1( \
|
||||
K01 \
|
||||
) \
|
||||
{ \
|
||||
{ K01 }, \
|
||||
}
|
||||
60
keyboards/1k/config.h
Normal file
60
keyboards/1k/config.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/* Copyright 2020 zvecr<git@zvecr.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/>.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "config_common.h"
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0x0009
|
||||
#define PRODUCT_ID 0x0001
|
||||
#define DEVICE_VER 0x0001
|
||||
#define MANUFACTURER MakotoKurauchi
|
||||
#define PRODUCT 1K
|
||||
|
||||
/* matrix size */
|
||||
#define MATRIX_ROWS 1
|
||||
#define MATRIX_COLS 1
|
||||
|
||||
/*
|
||||
* Keyboard Matrix Assignments
|
||||
*
|
||||
* On this board we have direct connection: no diodes.
|
||||
*/
|
||||
#define DIRECT_PINS {{ B0 }}
|
||||
|
||||
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
|
||||
#define DEBOUNCE 5
|
||||
|
||||
#define RGBLED_NUM 1
|
||||
#define RGB_DI_PIN B2
|
||||
|
||||
// Save as much space as we can...
|
||||
#define LAYER_STATE_8BIT
|
||||
#define NO_ACTION_LAYER
|
||||
#define NO_ACTION_TAPPING
|
||||
#define NO_ACTION_ONESHOT
|
||||
#define NO_RESET
|
||||
|
||||
// usbconfig.h overrides
|
||||
#define USB_CFG_IOPORTNAME B
|
||||
#define USB_CFG_DMINUS_BIT 3
|
||||
#define USB_CFG_DPLUS_BIT 4
|
||||
#define USB_COUNT_SOF 0
|
||||
#define USB_INTR_CFG PCMSK
|
||||
#define USB_INTR_CFG_SET (1<<USB_CFG_DPLUS_BIT)
|
||||
#define USB_INTR_ENABLE_BIT PCIE
|
||||
#define USB_INTR_PENDING_BIT PCIF
|
||||
#define USB_INTR_VECTOR SIG_PIN_CHANGE
|
||||
12
keyboards/1k/info.json
Normal file
12
keyboards/1k/info.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"keyboard_name": "1k",
|
||||
"url": "",
|
||||
"maintainer": "MakotoKurauchi",
|
||||
"layouts": {
|
||||
"LAYOUT_ortho_1x1": {
|
||||
"layout": [
|
||||
{"x":0, "y":0}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
25
keyboards/1k/keymaps/default/keymap.c
Normal file
25
keyboards/1k/keymaps/default/keymap.c
Normal file
@@ -0,0 +1,25 @@
|
||||
// Copyright 2022 Makoto Kurauchi (@MakotoKurauchi)
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
#include "rgblite.h"
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[0] = LAYOUT_ortho_1x1(
|
||||
RGB_HUI
|
||||
)
|
||||
};
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
if (record->event.pressed) {
|
||||
switch (keycode) {
|
||||
case RGB_HUI:
|
||||
rgblite_increase_hue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void keyboard_post_init_user(void) {
|
||||
rgblite_increase_hue();
|
||||
}
|
||||
23
keyboards/1k/keymaps/default/rgblite.h
Normal file
23
keyboards/1k/keymaps/default/rgblite.h
Normal file
@@ -0,0 +1,23 @@
|
||||
// Copyright 2022 Makoto Kurauchi (@MakotoKurauchi)
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ws2812.h"
|
||||
#include "color.h"
|
||||
|
||||
static inline void rgblite_setrgb(RGB rgb) {
|
||||
LED_TYPE leds[RGBLED_NUM] = {{.r = rgb.r, .g = rgb.g, .b = rgb.b}};
|
||||
ws2812_setleds(leds, RGBLED_NUM);
|
||||
}
|
||||
|
||||
static void rgblite_increase_hue(void) {
|
||||
static uint8_t state = 0;
|
||||
|
||||
HSV hsv = { 255, 255, 255 };
|
||||
hsv.h = state;
|
||||
state = (state + 8) % 256;
|
||||
|
||||
rgblite_setrgb(hsv_to_rgb(hsv));
|
||||
|
||||
}
|
||||
2
keyboards/1k/keymaps/default/rules.mk
Normal file
2
keyboards/1k/keymaps/default/rules.mk
Normal file
@@ -0,0 +1,2 @@
|
||||
SRC += ws2812.c
|
||||
SRC += color.c
|
||||
22
keyboards/1k/keymaps/media/keymap.c
Normal file
22
keyboards/1k/keymaps/media/keymap.c
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright 2022 Makoto Kurauchi (@MakotoKurauchi)
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
#include "rgblite.h"
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[0] = LAYOUT_ortho_1x1(
|
||||
KC_MUTE
|
||||
)
|
||||
};
|
||||
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
if (record->event.pressed) {
|
||||
rgblite_increase_hue();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void keyboard_post_init_user(void) {
|
||||
rgblite_increase_hue();
|
||||
}
|
||||
23
keyboards/1k/keymaps/media/rgblite.h
Normal file
23
keyboards/1k/keymaps/media/rgblite.h
Normal file
@@ -0,0 +1,23 @@
|
||||
// Copyright 2022 Makoto Kurauchi (@MakotoKurauchi)
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ws2812.h"
|
||||
#include "color.h"
|
||||
|
||||
static inline void rgblite_setrgb(RGB rgb) {
|
||||
LED_TYPE leds[RGBLED_NUM] = {{.r = rgb.r, .g = rgb.g, .b = rgb.b}};
|
||||
ws2812_setleds(leds, RGBLED_NUM);
|
||||
}
|
||||
|
||||
static void rgblite_increase_hue(void) {
|
||||
static uint8_t state = 0;
|
||||
|
||||
HSV hsv = { 255, 255, 255 };
|
||||
hsv.h = state;
|
||||
state = (state + 8) % 256;
|
||||
|
||||
rgblite_setrgb(hsv_to_rgb(hsv));
|
||||
|
||||
}
|
||||
3
keyboards/1k/keymaps/media/rules.mk
Normal file
3
keyboards/1k/keymaps/media/rules.mk
Normal file
@@ -0,0 +1,3 @@
|
||||
SRC += ws2812.c
|
||||
SRC += color.c
|
||||
EXTRAKEY_ENABLE = yes
|
||||
6
keyboards/1k/keymaps/tap_dance/config.h
Normal file
6
keyboards/1k/keymaps/tap_dance/config.h
Normal file
@@ -0,0 +1,6 @@
|
||||
// Copyright 2022 Makoto Kurauchi (@MakotoKurauchi)
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#define TAPPING_TERM 500
|
||||
22
keyboards/1k/keymaps/tap_dance/keymap.c
Normal file
22
keyboards/1k/keymaps/tap_dance/keymap.c
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright 2022 Makoto Kurauchi (@MakotoKurauchi)
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
|
||||
enum layers {
|
||||
_BASE = 0,
|
||||
};
|
||||
|
||||
enum {
|
||||
TD_AB = 0
|
||||
};
|
||||
|
||||
qk_tap_dance_action_t tap_dance_actions[] = {
|
||||
[TD_AB] = ACTION_TAP_DANCE_DOUBLE(KC_A, KC_B)
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[_BASE] = LAYOUT_ortho_1x1(
|
||||
TD(TD_AB)
|
||||
)
|
||||
};
|
||||
47
keyboards/1k/readme.md
Normal file
47
keyboards/1k/readme.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# 1k
|
||||
|
||||

|
||||
|
||||
1% Custom mechanical keyboard. ATtiny85 powered, with 1*WS2812 LED, and the micronucleus bootloader.
|
||||
|
||||
**Note**: Due to limited firmware space, a _**lot**_ of features have to be disabled to get a functioning QMK based keyboard.
|
||||
|
||||
* Keyboard Maintainer: [MakotoKurauchi](https://github.com/MakotoKurauchi)
|
||||
* Hardware Supported: 1k
|
||||
* Hardware Availability: [booth](https://ninep.booth.pm/items/3504781)
|
||||
|
||||
Make example for this keyboard (after setting up your build environment):
|
||||
|
||||
make 1k:default
|
||||
|
||||
See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
|
||||
|
||||
## Flashing
|
||||
### Prerequisites
|
||||
|
||||
```bash
|
||||
git clone https://github.com/micronucleus/micronucleus.git
|
||||
cd micronucleus/commandline/
|
||||
sudo make install
|
||||
```
|
||||
|
||||
On Linux, you’ll need proper privileges to access the MCU. You can either use sudo when flashing firmware, or place [these files](https://github.com/micronucleus/micronucleus/blob/master/commandline/49-micronucleus.rules) in /etc/udev/rules.d/. Once added run the following:
|
||||
|
||||
```bash
|
||||
sudo udevadm control --reload-rules
|
||||
sudo udevadm trigger
|
||||
```
|
||||
|
||||
### Instructions
|
||||
|
||||
```bash
|
||||
make 1k:default:flash
|
||||
|
||||
# or directly with...
|
||||
micronucleus --run <firmware.hex>
|
||||
```
|
||||
|
||||
### Recovery
|
||||
|
||||
* [Original Firmware](https://github.com/xiudi/Attiny85_vusb_pad_test)
|
||||
* [Bootloader Repair](https://digistump.com/wiki/digispark/tutorials/proisp)
|
||||
26
keyboards/1k/rules.mk
Normal file
26
keyboards/1k/rules.mk
Normal file
@@ -0,0 +1,26 @@
|
||||
# MCU name
|
||||
MCU = attiny85
|
||||
|
||||
# Bootloader selection
|
||||
BOOTLOADER = custom
|
||||
BOOTLOADER_SIZE = 1862
|
||||
PROGRAM_CMD = micronucleus --run $(BUILD_DIR)/$(TARGET).hex
|
||||
|
||||
# Build Options
|
||||
# change yes to no to disable
|
||||
#
|
||||
BOOTMAGIC_ENABLE = no # Enable Bootmagic Lite
|
||||
MOUSEKEY_ENABLE = no # Mouse keys
|
||||
EXTRAKEY_ENABLE = no # Audio control and System control
|
||||
CONSOLE_ENABLE = no # Console for debug
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
NKRO_ENABLE = no # Enable N-Key Rollover
|
||||
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
|
||||
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
|
||||
AUDIO_ENABLE = no # Audio output
|
||||
|
||||
# Save as much space as we can...
|
||||
LTO_ENABLE = yes
|
||||
GRAVE_ESC_ENABLE = no
|
||||
MAGIC_ENABLE = no
|
||||
SPACE_CADET_ENABLE = no
|
||||
@@ -19,13 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "config_common.h"
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0x6F75 // OU
|
||||
#define PRODUCT_ID 0x6873
|
||||
#define DEVICE_VER 0x0001
|
||||
#define MANUFACTURER 1upkeyboards
|
||||
#define PRODUCT 1up60hse
|
||||
|
||||
/* key matrix size */
|
||||
#define MATRIX_ROWS 5
|
||||
#define MATRIX_COLS 14
|
||||
@@ -115,5 +108,3 @@ 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
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
{
|
||||
"keyboard_name": "1up60hse",
|
||||
"manufacturer": "1upkeyboards",
|
||||
"url": "",
|
||||
"maintainer": "qmk",
|
||||
"usb": {
|
||||
"vid": "0x6F75",
|
||||
"pid": "0x6873",
|
||||
"device_version": "0.0.1"
|
||||
},
|
||||
"layouts": {
|
||||
"LAYOUT_60_ansi": {
|
||||
"layout": [{"label":"~", "x":0, "y":0}, {"label":"!", "x":1, "y":0}, {"label":"@", "x":2, "y":0}, {"label":"#", "x":3, "y":0}, {"label":"$", "x":4, "y":0}, {"label":"%", "x":5, "y":0}, {"label":"^", "x":6, "y":0}, {"label":"&", "x":7, "y":0}, {"label":"*", "x":8, "y":0}, {"label":"(", "x":9, "y":0}, {"label":")", "x":10, "y":0}, {"label":"_", "x":11, "y":0}, {"label":"+", "x":12, "y":0}, {"label":"Backspace", "x":13, "y":0, "w":2}, {"label":"Tab", "x":0, "y":1, "w":1.5}, {"label":"Q", "x":1.5, "y":1}, {"label":"W", "x":2.5, "y":1}, {"label":"E", "x":3.5, "y":1}, {"label":"R", "x":4.5, "y":1}, {"label":"T", "x":5.5, "y":1}, {"label":"Y", "x":6.5, "y":1}, {"label":"U", "x":7.5, "y":1}, {"label":"I", "x":8.5, "y":1}, {"label":"O", "x":9.5, "y":1}, {"label":"P", "x":10.5, "y":1}, {"label":"{", "x":11.5, "y":1}, {"label":"}", "x":12.5, "y":1}, {"label":"|", "x":13.5, "y":1, "w":1.5}, {"label":"Caps Lock", "x":0, "y":2, "w":1.75}, {"label":"A", "x":1.75, "y":2}, {"label":"S", "x":2.75, "y":2}, {"label":"D", "x":3.75, "y":2}, {"label":"F", "x":4.75, "y":2}, {"label":"G", "x":5.75, "y":2}, {"label":"H", "x":6.75, "y":2}, {"label":"J", "x":7.75, "y":2}, {"label":"K", "x":8.75, "y":2}, {"label":"L", "x":9.75, "y":2}, {"label":":", "x":10.75, "y":2}, {"label":"\"", "x":11.75, "y":2}, {"label":"Enter", "x":12.75, "y":2, "w":2.25}, {"label":"Shift", "x":0, "y":3, "w":2.25}, {"label":"Z", "x":2.25, "y":3}, {"label":"X", "x":3.25, "y":3}, {"label":"C", "x":4.25, "y":3}, {"label":"V", "x":5.25, "y":3}, {"label":"B", "x":6.25, "y":3}, {"label":"N", "x":7.25, "y":3}, {"label":"M", "x":8.25, "y":3}, {"label":"<", "x":9.25, "y":3}, {"label":">", "x":10.25, "y":3}, {"label":"?", "x":11.25, "y":3}, {"label":"Shift", "x":12.25, "y":3, "w":2.75}, {"label":"Ctrl", "x":0, "y":4, "w":1.25}, {"label":"Win", "x":1.25, "y":4, "w":1.25}, {"label":"Alt", "x":2.5, "y":4, "w":1.25}, {"x":3.75, "y":4, "w":6.25}, {"label":"Alt", "x":10, "y":4, "w":1.25}, {"label":"Win", "x":11.25, "y":4, "w":1.25}, {"label":"Menu", "x":12.5, "y":4, "w":1.25}, {"label":"Ctrl", "x":13.75, "y":4, "w":1.25}]
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user