Skip to content

Commit

Permalink
Merge pull request #222 from zsa/staging
Browse files Browse the repository at this point in the history
Firmware 15
  • Loading branch information
fdidron authored Dec 6, 2019
2 parents 1d600f0 + 038cef3 commit 13e1dd3
Show file tree
Hide file tree
Showing 94 changed files with 2,278 additions and 459 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ quantum/version.h
CMakeLists.txt
cmake-build-debug
doxygen/
.DS_STORE
.DS_Store
/util/wsl_downloaded
/util/win_downloaded
/users/
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
url = https://github.com/google/googletest
[submodule "lib/lufa"]
path = lib/lufa
url = https://github.com/qmk/lufa
url = https://github.com/zsa/lufa
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,9 @@ define PARSE_KEYBOARD
# The same if all was specified
else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all),true)
$$(eval $$(call PARSE_ALL_KEYMAPS))
# List all keymaps for the given keyboard
else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,list-keymaps),true)
$$(eval $$(call LIST_ALL_KEYMAPS))
# Try to match the specified keyamp with the list of known keymaps
else ifeq ($$(call TRY_TO_MATCH_RULE_FROM_LIST,$$(KEYMAPS)),true)
$$(eval $$(call PARSE_KEYMAP,$$(MATCHED_ITEM)))
Expand Down Expand Up @@ -407,6 +410,16 @@ endef
# endif
# endef

# Prints a list of all known keymaps for the given keyboard
define LIST_ALL_KEYMAPS
COMMAND_true_LIST_KEYMAPS := \
printf "$$(KEYMAPS)\n";
COMMAND_false_LIST_KEYMAPS := \
printf "$$(MSG_AVAILABLE_KEYMAPS)\n"; \
printf "$$(KEYMAPS)\n";
COMMANDS += LIST_KEYMAPS
endef

# $1 Keymap
# This is the meat of compiling a keyboard, when entering this, everything is known
# keyboard, subproject, and keymap
Expand Down
94 changes: 37 additions & 57 deletions bin/qmk
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,17 @@
import os
import subprocess
import sys
from glob import glob
from time import strftime
from importlib import import_module
from importlib.util import find_spec
from time import strftime

# Add the QMK python libs to our path
script_dir = os.path.dirname(os.path.realpath(__file__))
qmk_dir = os.path.abspath(os.path.join(script_dir, '..'))
python_lib_dir = os.path.abspath(os.path.join(qmk_dir, 'lib', 'python'))
sys.path.append(python_lib_dir)

# Change to the root of our checkout
os.environ['ORIG_CWD'] = os.getcwd()
os.chdir(qmk_dir)

# Make sure our modules have been setup
with open('requirements.txt', 'r') as fd:
with open(os.path.join(qmk_dir, 'requirements.txt'), 'r') as fd:
for line in fd.readlines():
line = line.strip().replace('<', '=').replace('>', '=')

Expand All @@ -32,72 +26,58 @@ with open('requirements.txt', 'r') as fd:

module = line.split('=')[0] if '=' in line else line
if not find_spec(module):
print('Your QMK build environment is not fully setup!\n')
print('Please run `./util/qmk_install.sh` to setup QMK.')
print('Could not find module %s!', module)
print('Please run `pip3 install -r requirements.txt` to install the python dependencies.')
exit(255)

# Figure out our version
# TODO(skullydazed/anyone): Find a method that doesn't involve git. This is slow in docker and on windows.
command = ['git', 'describe', '--abbrev=6', '--dirty', '--always', '--tags']
result = subprocess.run(command, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
result = subprocess.run(command, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

if result.returncode == 0:
os.environ['QMK_VERSION'] = 'QMK ' + result.stdout.strip()
os.environ['QMK_VERSION'] = result.stdout.strip()
else:
os.environ['QMK_VERSION'] = 'QMK ' + strftime('%Y-%m-%d-%H:%M:%S')
os.environ['QMK_VERSION'] = 'nogit-' + strftime('%Y-%m-%d-%H:%M:%S') + '-dirty'

# Setup the CLI
import milc
milc.EMOJI_LOGLEVELS['INFO'] = '{fg_blue}ψ{style_reset_all}'

# If we were invoked as `qmk <cmd>` massage sys.argv into `qmk-<cmd>`.
# This means we can't accept arguments to the qmk script itself.
script_name = os.path.basename(sys.argv[0])
if script_name == 'qmk':
if len(sys.argv) == 1:
milc.cli.log.error('No subcommand specified!\n')

if len(sys.argv) == 1 or sys.argv[1] in ['-h', '--help']:
milc.cli.echo('usage: qmk <subcommand> [...]')
milc.cli.echo('\nsubcommands:')
subcommands = glob(os.path.join(qmk_dir, 'bin', 'qmk-*'))
for subcommand in sorted(subcommands):
subcommand = os.path.basename(subcommand).split('-', 1)[1]
milc.cli.echo('\t%s', subcommand)
milc.cli.echo('\nqmk <subcommand> --help for more information')
exit(1)

if sys.argv[1] in ['-V', '--version']:
milc.cli.echo(os.environ['QMK_VERSION'])
exit(0)
milc.EMOJI_LOGLEVELS['INFO'] = '{fg_blue}Ψ{style_reset_all}'

sys.argv[0] = script_name = '-'.join((script_name, sys.argv[1]))
del sys.argv[1]

# Look for which module to import
if script_name == 'qmk':
milc.cli.print_help()
exit(0)
elif not script_name.startswith('qmk-'):
milc.cli.log.error('Invalid symlink, must start with "qmk-": %s', script_name)
else:
subcommand = script_name.replace('-', '.').replace('_', '.').split('.')
subcommand.insert(1, 'cli')
subcommand = '.'.join(subcommand)
@milc.cli.entrypoint('QMK Helper Script')
def qmk_main(cli):
"""The function that gets run when no subcommand is provided.
"""
cli.print_help()

try:
import_module(subcommand)
except ModuleNotFoundError as e:
if e.__class__.__name__ != subcommand:
raise

milc.cli.log.error('Invalid subcommand! Could not import %s.', subcommand)
exit(1)
def main():
"""Setup our environment and then call the CLI entrypoint.
"""
# Change to the root of our checkout
os.environ['ORIG_CWD'] = os.getcwd()
os.chdir(qmk_dir)

if __name__ == '__main__':
# Import the subcommands
import qmk.cli

# Execute
return_code = milc.cli()

if return_code is False:
exit(1)
elif return_code is not True and isinstance(return_code, int) and return_code < 256:

elif return_code is not True and isinstance(return_code, int):
if return_code < 0 or return_code > 255:
milc.cli.log.error('Invalid return_code: %d', return_code)
exit(255)

exit(return_code)
else:
exit(0)

exit(0)


if __name__ == '__main__':
main()
1 change: 0 additions & 1 deletion bin/qmk-compile-json

This file was deleted.

1 change: 0 additions & 1 deletion bin/qmk-doctor

This file was deleted.

1 change: 0 additions & 1 deletion bin/qmk-hello

This file was deleted.

1 change: 0 additions & 1 deletion bin/qmk-json-keymap

This file was deleted.

2 changes: 1 addition & 1 deletion build_json.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ endif

# Generate the keymap.c
ifneq ("$(KEYMAP_JSON)","")
_ = $(shell test -e $(KEYMAP_C) || bin/qmk-json-keymap $(KEYMAP_JSON) -o $(KEYMAP_C))
_ = $(shell test -e $(KEYMAP_C) || bin/qmk json-keymap $(KEYMAP_JSON) -o $(KEYMAP_C))
endif
36 changes: 33 additions & 3 deletions common_features.mk
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
ifeq ($(strip $(RGBLIGHT_CUSTOM_DRIVER)), yes)
OPT_DEFS += -DRGBLIGHT_CUSTOM_DRIVER
else
SRC += ws2812.c
WS2812_DRIVER_REQUIRED = yes
endif
endif

Expand Down Expand Up @@ -176,7 +176,7 @@ endif

ifeq ($(strip $(RGB_MATRIX_ENABLE)), WS2812)
OPT_DEFS += -DWS2812
SRC += ws2812.c
WS2812_DRIVER_REQUIRED = yes
endif

ifeq ($(strip $(RGB_MATRIX_CUSTOM_KB)), yes)
Expand Down Expand Up @@ -233,11 +233,37 @@ ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
ifeq ($(strip $(VISUALIZER_ENABLE)), yes)
CIE1931_CURVE = yes
endif
ifeq ($(strip $(BACKLIGHT_CUSTOM_DRIVER)), yes)


COMMON_VPATH += $(QUANTUM_DIR)/backlight
SRC += $(QUANTUM_DIR)/backlight/backlight.c
OPT_DEFS += -DBACKLIGHT_ENABLE

ifeq ($(strip $(BACKLIGHT_ENABLE)), custom)
OPT_DEFS += -DBACKLIGHT_CUSTOM_DRIVER
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)),)
$(error WS2812_DRIVER="$(WS2812_DRIVER)" is not a valid WS2812 driver)
endif

ifeq ($(strip $(WS2812_DRIVER)), bitbang)
SRC += ws2812.c
else
SRC += ws2812_$(strip $(WS2812_DRIVER)).c
endif

# add extra deps
ifeq ($(strip $(WS2812_DRIVER)), i2c)
QUANTUM_LIB_SRC += i2c_master.c
endif
endif

ifeq ($(strip $(CIE1931_CURVE)), yes)
OPT_DEFS += -DUSE_CIE1931_CURVE
LED_TABLES = yes
Expand All @@ -262,6 +288,10 @@ ifeq ($(strip $(USB_HID_ENABLE)), yes)
include $(TMK_DIR)/protocol/usb_hid.mk
endif

ifeq ($(strip $(WEBUSB_ENABLE)), yes)
SRC += $(TMK_DIR)/common/webusb.c
endif

ifeq ($(strip $(ENCODER_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/encoder.c
OPT_DEFS += -DENCODER_ENABLE
Expand Down
1 change: 1 addition & 0 deletions drivers/arm/ws2812.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error("NOT SUPPORTED")
1 change: 1 addition & 0 deletions drivers/arm/ws2812_pwm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error("NOT SUPPORTED")
1 change: 1 addition & 0 deletions drivers/arm/ws2812_spi.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error("NOT SUPPORTED")
33 changes: 10 additions & 23 deletions drivers/avr/ws2812.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@
#include <avr/interrupt.h>
#include <avr/io.h>
#include <util/delay.h>
#include "debug.h"

#if !defined(LED_ARRAY) && defined(RGB_MATRIX_ENABLE)
// LED color buffer
LED_TYPE led[DRIVER_LED_TOTAL];
# define LED_ARRAY led
#endif
/*
* Forward declare internal functions
*
* The functions take a byte-array and send to the data output as WS2812 bitstream.
* The length is the number of bytes to send - three per LED.
*/

void ws2812_sendarray(uint8_t *array, uint16_t length);
void ws2812_sendarray_mask(uint8_t *array, uint16_t length, uint8_t pinmask);


#ifdef RGBW_BB_TWI

Expand Down Expand Up @@ -135,23 +139,6 @@ unsigned char I2C_Write(unsigned char c) {

#endif

#ifdef RGB_MATRIX_ENABLE
// Set an led in the buffer to a color
void inline ws2812_setled(int i, uint8_t r, uint8_t g, uint8_t b) {
led[i].r = r;
led[i].g = g;
led[i].b = b;
}

void ws2812_setled_all(uint8_t r, uint8_t g, uint8_t b) {
for (int i = 0; i < sizeof(led) / sizeof(led[0]); i++) {
led[i].r = r;
led[i].g = g;
led[i].b = b;
}
}
#endif

// Setleds for standard RGB
void inline ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) {
// ws2812_setleds_pin(ledarray,leds, _BV(ws2812_pin));
Expand Down
35 changes: 1 addition & 34 deletions drivers/avr/ws2812.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef LIGHT_WS2812_H_
#define LIGHT_WS2812_H_

#include <avr/io.h>
#include <avr/interrupt.h>
//#include "ws2812_config.h"
//#include "i2cmaster.h"
#pragma once

#include "quantum/color.h"

Expand All @@ -42,33 +36,6 @@
* - Send out the LED data
* - Wait 50�s to reset the LEDs
*/
#ifdef RGB_MATRIX_ENABLE
void ws2812_setled(int index, uint8_t r, uint8_t g, uint8_t b);
void ws2812_setled_all(uint8_t r, uint8_t g, uint8_t b);
#endif

void ws2812_setleds(LED_TYPE *ledarray, uint16_t number_of_leds);
void ws2812_setleds_pin(LED_TYPE *ledarray, uint16_t number_of_leds, uint8_t pinmask);
void ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t number_of_leds);

/*
* Old interface / Internal functions
*
* The functions take a byte-array and send to the data output as WS2812 bitstream.
* The length is the number of bytes to send - three per LED.
*/

void ws2812_sendarray(uint8_t *array, uint16_t length);
void ws2812_sendarray_mask(uint8_t *array, uint16_t length, uint8_t pinmask);

/*
* Internal defines
*/
#ifndef CONCAT
# define CONCAT(a, b) a##b
#endif
#ifndef CONCAT_EXP
# define CONCAT_EXP(a, b) CONCAT(a, b)
#endif

#endif /* LIGHT_WS2812_H_ */
Loading

0 comments on commit 13e1dd3

Please sign in to comment.