aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rwxr-xr-xutil/docker_build.sh2
-rwxr-xr-xutil/freebsd_install.sh3
-rwxr-xr-xutil/linux_install.sh9
-rwxr-xr-xutil/macos_install.sh2
-rwxr-xr-xutil/msys2_install.sh2
-rwxr-xr-xutil/new_keyboard.sh159
-rwxr-xr-xutil/new_project.sh70
-rw-r--r--util/rgblight_breathing_table_calc.c49
8 files changed, 221 insertions, 75 deletions
diff --git a/util/docker_build.sh b/util/docker_build.sh
index e7aeac8f3..c573ebcae 100755
--- a/util/docker_build.sh
+++ b/util/docker_build.sh
@@ -35,7 +35,7 @@ else
fi
if [ -n "$target" ]; then
if [ "$(uname)" = "Linux" ] || docker-machine active >/dev/null 2>&1; then
- usb_args="--privileged -v /dev/bus/usb:/dev/bus/usb"
+ usb_args="--privileged -v /dev:/dev"
else
echo "Error: target requires docker-machine to work on your platform" >&2
echo "See http://gw.tnode.com/docker/docker-machine-with-usb-support-on-windows-macos" >&2
diff --git a/util/freebsd_install.sh b/util/freebsd_install.sh
index 25ea80a7f..c8696e8cc 100755
--- a/util/freebsd_install.sh
+++ b/util/freebsd_install.sh
@@ -15,4 +15,5 @@ pkg install -y \
arm-none-eabi-gcc \
arm-none-eabi-binutils \
arm-none-eabi-newlib \
- diffutils
+ diffutils \
+ python3
diff --git a/util/linux_install.sh b/util/linux_install.sh
index 608975a91..5e2afe999 100755
--- a/util/linux_install.sh
+++ b/util/linux_install.sh
@@ -25,6 +25,7 @@ if grep ID /etc/os-release | grep -qE "fedora"; then
kernel-headers \
make \
perl \
+ python3 \
unzip \
wget \
zip
@@ -47,6 +48,7 @@ elif grep ID /etc/os-release | grep -qE 'debian|ubuntu'; then
gcc-avr \
git \
libnewlib-arm-none-eabi \
+ python3 \
unzip \
wget \
zip
@@ -66,6 +68,7 @@ elif grep ID /etc/os-release | grep -q 'arch\|manjaro'; then
diffutils \
gcc \
git \
+ python \
unzip \
wget \
zip
@@ -87,6 +90,7 @@ elif grep ID /etc/os-release | grep -q gentoo; then
app-arch/zip \
app-mobilephone/dfu-util \
dev-embedded/avrdude \
+ dev-lang/python:3.5 \
net-misc/wget \
sys-devel/gcc \
sys-devel/crossdev
@@ -102,6 +106,7 @@ elif grep ID /etc/os-release | grep -q sabayon; then
app-arch/zip \
app-mobilephone/dfu-util \
dev-embedded/avrdude \
+ dev-lang/python \
net-misc/wget \
sys-devel/gcc \
sys-devel/crossdev
@@ -125,6 +130,7 @@ elif grep ID /etc/os-release | grep -qE "opensuse|tumbleweed"; then
dfu-tool \
dfu-programmer \
gcc \
+ python3 \
unzip \
wget \
zip
@@ -143,7 +149,8 @@ elif grep ID /etc/os-release | grep -q slackware; then
dfu-util \
arm-binutils \
arm-gcc \
- newlib
+ newlib \
+ python3
echo "Done!"
else
echo "Quitting..."
diff --git a/util/macos_install.sh b/util/macos_install.sh
index d2629a8cb..93f3ed0b9 100755
--- a/util/macos_install.sh
+++ b/util/macos_install.sh
@@ -22,5 +22,5 @@ fi
brew tap osx-cross/avr
brew tap PX4/homebrew-px4
brew update
-brew install avr-gcc@7 gcc-arm-none-eabi dfu-programmer avrdude dfu-util
+brew install avr-gcc@7 gcc-arm-none-eabi dfu-programmer avrdude dfu-util python3
brew link --force avr-gcc@7
diff --git a/util/msys2_install.sh b/util/msys2_install.sh
index fcb488249..bcb628ab2 100755
--- a/util/msys2_install.sh
+++ b/util/msys2_install.sh
@@ -7,7 +7,7 @@ armtools=gcc-arm-none-eabi
installflip=false
echo "Installing dependencies needed for the installation (quazip)"
-pacman --needed -S msys/unzip msys/p7zip base-devel msys/git mingw-w64-x86_64-toolchain
+pacman --needed -S base-devel mingw-w64-x86_64-toolchain msys/git msys/p7zip msys/python3 msys/unzip
source "$dir/win_shared_install.sh"
diff --git a/util/new_keyboard.sh b/util/new_keyboard.sh
new file mode 100755
index 000000000..e9ce30978
--- /dev/null
+++ b/util/new_keyboard.sh
@@ -0,0 +1,159 @@
+#!/bin/bash
+
+# This script generates a new keyboard directory under keyboards/,
+# and copies the template files from quantum/template/ into it.
+
+# Print an error message with the word "ERROR" in red.
+echo_error() {
+ echo -e "[\033[0;91mERROR\033[m]: $1"
+}
+
+# Print a message in bold.
+echo_bold() {
+ echo -e "\033[1m$1\033[m"
+}
+
+# Prompt the user for information, showing the default value in brackets.
+prompt() {
+ local message="$1"
+ local default="$2"
+
+ [ -n "$default" ] && message+=" [$default]"
+ message+=": "
+
+ read -rp "$message" prompt_return
+ [ -z "$prompt_return" ] && prompt_return="$default"
+}
+
+# Grab a username from Git config.
+set_git_username() {
+ git_username="$(git config --get user.name)"
+}
+
+# Copy the template files to the new keyboard directory.
+copy_templates() {
+ echo -n "Copying base template files..."
+ cp -r "quantum/template/base" "${keyboard_dir}"
+ echo " done"
+
+ echo -n "Copying $keyboard_type template files..."
+ cp -r "quantum/template/${keyboard_type}/." "${keyboard_dir}"
+ echo " done"
+
+ echo -n "Renaming keyboard files..."
+ mv "${keyboard_dir}/template.c" "${keyboard_dir}/${keyboard_name}.c"
+ mv "${keyboard_dir}/template.h" "${keyboard_dir}/${keyboard_name}.h"
+ echo " done"
+}
+
+# Set the inplace editing parameter for sed.
+# macOS/BSD sed expects a file extension immediately following -i.
+set_sed_i() {
+ sed_i=(-i)
+
+ case $(uname -a) in
+ *Darwin*) sed_i=(-i "")
+ esac
+}
+
+# Replace a token with a value in the given list of files.
+replace_placeholders() {
+ local replace_token="$1"
+ local replace_value="$2"
+ shift 2
+ local replace_filenames=("$@")
+
+ echo -n "Replacing $replace_token with $replace_value..."
+ for replace_filename in "${replace_filenames[@]}"; do
+ sed "${sed_i[@]}" -e "s/${replace_token}/${replace_value}/g" "$replace_filename"
+ done
+ echo " done"
+}
+
+# Replace %KEYBOARD% with the keyboard name.
+replace_keyboard_placeholders() {
+ local replace_keyboard_filenames=(
+ "${keyboard_dir}/config.h"
+ "${keyboard_dir}/readme.md"
+ "${keyboard_dir}/${keyboard_name}.c"
+ "${keyboard_dir}/keymaps/default/readme.md"
+ )
+ replace_placeholders "%KEYBOARD%" "$keyboard_name" "${replace_keyboard_filenames[@]}"
+}
+
+# Replace %YOUR_NAME% with the username.
+replace_name_placeholders() {
+ local replace_name_filenames=(
+ "${keyboard_dir}/config.h"
+ "${keyboard_dir}/readme.md"
+ "${keyboard_dir}/${keyboard_name}.c"
+ "${keyboard_dir}/${keyboard_name}.h"
+ "${keyboard_dir}/keymaps/default/config.h"
+ "${keyboard_dir}/keymaps/default/keymap.c"
+ )
+ replace_placeholders "%YOUR_NAME%" "$username" "${replace_name_filenames[@]}"
+}
+
+# Check if an array contains an element.
+array_contains() {
+ local e match="$1"
+ shift
+ for e; do
+ [[ "$e" == "$match" ]] && return 0;
+ done
+
+ return 1
+}
+
+# If we've been started from util/, we want to be in qmk_firmware/
+[[ "$PWD" == *util ]] && cd ..
+
+# The root qmk_firmware/ directory should have a subdirectory called quantum/
+if [ ! -d "quantum" ]; then
+ echo_error "Could not detect the QMK firmware directory!"
+ echo_error "Are you sure you're in the right place?"
+ exit 1
+fi
+
+echo_bold "Generating a new QMK keyboard directory"
+echo
+
+# Keyboard name is required, so keep prompting until we get one
+while [ -z "$keyboard_name" ]; do
+ prompt "Keyboard Name" ""
+ keyboard_name=$prompt_return
+done
+
+keyboard_dir="keyboards/$keyboard_name"
+
+if [ -d "$keyboard_dir" ]; then
+ echo_error "Keyboard $keyboard_name already exists!"
+ exit 1
+fi
+
+KEYBOARD_TYPES=("avr" "ps2avrgb")
+
+prompt "Keyboard Type" "avr"
+keyboard_type=$prompt_return
+
+if ! array_contains "$keyboard_type" "${KEYBOARD_TYPES[@]}"; then
+ echo_error "Keyboard type must be one of: ${KEYBOARD_TYPES[*]}"
+ exit 1
+fi
+
+set_git_username
+prompt "Your Name" "$git_username"
+username=$prompt_return
+
+echo
+
+copy_templates
+set_sed_i
+replace_keyboard_placeholders
+[ -n "$username" ] && replace_name_placeholders
+
+echo
+echo_bold "Created a new keyboard called $keyboard_name."
+echo
+echo_bold "To start working on things, cd into keyboards/$keyboard_name,"
+echo_bold "or open the directory in your favourite text editor."
diff --git a/util/new_project.sh b/util/new_project.sh
deleted file mode 100755
index 9dec714b0..000000000
--- a/util/new_project.sh
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/bin/sh
-# Script to make a new quantum project
-# Jack Humbert 2015
-
-KEYBOARD=$1
-KEYBOARD_TYPE=$2
-
-if [ -z "$KEYBOARD" ]; then
- echo "Usage: $0 <keyboard_name> <keyboard_type>"
- echo "Example: $0 gh60 avr"
- echo "Example: $0 bfake ps2avrgb"
- exit 1
-elif [ -z "$KEYBOARD_TYPE" ]; then
- KEYBOARD_TYPE=avr
-fi
-
-if [ "$KEYBOARD_TYPE" != "avr" ] && [ "$KEYBOARD_TYPE" != "ps2avrgb" ]; then
- echo "Invalid keyboard type target"
- exit 1
-fi
-
-if [ -e "keyboards/$1" ]; then
- echo "Error! keyboards/$1 already exists!"
- exit 1
-fi
-
-cd "$(dirname "$0")/.." || exit
-
-KEYBOARD_NAME=$(basename "$1")
-KEYBOARD_NAME_UPPERCASE=$(echo "$KEYBOARD_NAME" | awk '{print toupper($0)}')
-NEW_KBD=keyboards/${KEYBOARD}
-
-
-cp -r quantum/template/base "$NEW_KBD"
-cp -r "quantum/template/$KEYBOARD_TYPE/." "$NEW_KBD"
-
-mv "${NEW_KBD}/template.c" "${NEW_KBD}/${KEYBOARD_NAME}.c"
-mv "${NEW_KBD}/template.h" "${NEW_KBD}/${KEYBOARD_NAME}.h"
-find "${NEW_KBD}" -type f -exec sed -i '' -e "s;%KEYBOARD%;${KEYBOARD_NAME};g" {} \;
-find "${NEW_KBD}" -type f -exec sed -i '' -e "s;%KEYBOARD_UPPERCASE%;${KEYBOARD_NAME_UPPERCASE};g" {} \;
-
-GIT=$(whereis git)
-if [ "$GIT" != "" ]; then
- IS_GIT_REPO=$($GIT log >>/dev/null 2>&1; echo $?)
- if [ "$IS_GIT_REPO" -eq 0 ]; then
- ID="$($GIT config --get user.name)"
- read -rp "What is your name? [$ID] " YOUR_NAME
- if [ -n "$YOUR_NAME" ]; then
- ID=$YOUR_NAME
- fi
- echo "Using $ID as user name"
-
- for i in "$NEW_KBD/config.h" \
- "$NEW_KBD/$KEYBOARD_NAME.c" \
- "$NEW_KBD/$KEYBOARD_NAME.h" \
- "$NEW_KBD/keymaps/default/config.h" \
- "$NEW_KBD/keymaps/default/keymap.c"
- do
- awk -v id="$ID" '{sub(/%YOUR_NAME%/,id); print}' < "$i" > "$i.$$"
- mv "$i.$$" "$i"
- done
- fi
-fi
-
-cat <<-EOF
-######################################################
-# $NEW_KBD project created. To start
-# working on things, cd into $NEW_KBD
-######################################################
-EOF
diff --git a/util/rgblight_breathing_table_calc.c b/util/rgblight_breathing_table_calc.c
new file mode 100644
index 000000000..fc4d49ea5
--- /dev/null
+++ b/util/rgblight_breathing_table_calc.c
@@ -0,0 +1,49 @@
+//
+// calculate rgblight_effect_breathe_table[] values
+//
+// this is host program for quantum/rgblight.c:void rgblight_effect_breathing();
+//
+// example:
+// $ edit util/rgblight_breathing_table_calc.c
+// $ cc -o util/rgblight_breathing_table_calc util/rgblight_breathing_table_calc.c
+// $ ./util/rgblight_breathing_table_calc > keyboards/KEYBOARD_NAME/keymaps/KEYMAP_NAME/rgblight_breathe_table.h
+//
+#include <stdio.h>
+#include <math.h>
+#include <stdint.h>
+
+/// customize breeathing effect part ///////////////////////////
+#define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 // 1 to 2.7
+#define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0 to 255
+////////////////////////////////////////////////////////////////
+
+int main(void) {
+ int pos, step;
+ int table[256];
+ for (pos = 0; pos < 256; pos ++ ) {
+ table[pos] = (uint8_t)(
+ (exp(sin((pos/255.0)*M_PI))- RGBLIGHT_EFFECT_BREATHE_CENTER/M_E)
+ * (RGBLIGHT_EFFECT_BREATHE_MAX/(M_E-1/M_E))
+ );
+ }
+ printf("#ifndef RGBLIGHT_EFFECT_BREATHE_TABLE\n");
+ printf("#define RGBLIGHT_EFFECT_BREATHE_TABLE\n\n");
+ printf("const uint8_t rgblight_effect_breathe_table[] PROGMEM = {\n");
+ printf(" /* #define RGBLIGHT_EFFECT_BREATHE_CENTER %.2f */\n", RGBLIGHT_EFFECT_BREATHE_CENTER);
+ printf(" /* #define RGBLIGHT_EFFECT_BREATHE_MAX %d */\n", RGBLIGHT_EFFECT_BREATHE_MAX);
+
+ for (int s = 0, step = (1<<s); s < 3 ; s += 1, step = (1<<s) ) {
+ printf("\n #if RGBLIGHT_BREATHE_TABLE_SIZE == %d\n",
+ s == 0 ? 256:(s== 1 ? 128: 64));
+ for (pos = 0; pos < 256; pos += step ) {
+ printf(" 0x%x%s", table[pos], (pos+step)>=256?"":"," );
+ if ((pos+step) % 8 == 0)
+ printf("\n");
+ }
+ printf(" #endif /* %d bytes table */\n", s == 0 ? 256:(s== 1 ? 128: 64));
+ }
+ printf("};\n");
+ printf("\nstatic const int table_scale = 256/sizeof(rgblight_effect_breathe_table);\n");
+ printf("\n#endif /* RGBLIGHT_EFFECT_BREATHE_TABLE */\n");
+ return 0;
+}