diff options
Diffstat (limited to 'util')
| -rwxr-xr-x | util/audio_generate_dac_lut.py | 67 | ||||
| -rwxr-xr-x | util/chibios_conf_updater.sh (renamed from util/chibios-upgrader.sh) | 10 | ||||
| -rw-r--r-- | util/drivers.txt | 1 | ||||
| -rwxr-xr-x | util/install/gentoo.sh | 2 | ||||
| -rwxr-xr-x | util/install/opensuse.sh | 31 | ||||
| -rwxr-xr-x | util/install/sabayon.sh | 15 | ||||
| -rwxr-xr-x | util/qmk_install.sh | 8 | ||||
| -rwxr-xr-x | util/sample_parser.py | 39 | ||||
| -rw-r--r-- | util/udev/50-qmk.rules | 2 | ||||
| -rwxr-xr-x | util/wavetable_parser.py | 40 | 
10 files changed, 161 insertions, 54 deletions
diff --git a/util/audio_generate_dac_lut.py b/util/audio_generate_dac_lut.py new file mode 100755 index 0000000000..c31ba3d7ee --- /dev/null +++ b/util/audio_generate_dac_lut.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python3 +# +# Copyright 2020 JohSchneider +# +# 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/>. +# + +AUDIO_DAC_BUFFER_SIZE=256 +AUDIO_DAC_SAMPLE_MAX=4095 + +def plot(values): +    for v in values: +        print('0'* int(v * 80/AUDIO_DAC_SAMPLE_MAX)) + +def to_lut(values): +    for v in values: +        print(hex(int(v)), end=", ") + + +from math import sin, tau, pi + +samples=[] + +def sampleSine(): +    for s in range(AUDIO_DAC_BUFFER_SIZE): +        samples.append((sin((s/AUDIO_DAC_BUFFER_SIZE)*tau - pi/2) + 1 )/2* AUDIO_DAC_SAMPLE_MAX) + +def sampleTriangle(): +    for s in range(AUDIO_DAC_BUFFER_SIZE): +        if s < AUDIO_DAC_BUFFER_SIZE/2: +            samples.append(s/(AUDIO_DAC_BUFFER_SIZE/2) * AUDIO_DAC_SAMPLE_MAX) +        else: +            samples.append(AUDIO_DAC_SAMPLE_MAX - (s-AUDIO_DAC_BUFFER_SIZE/2)/(AUDIO_DAC_BUFFER_SIZE/2) * AUDIO_DAC_SAMPLE_MAX) + +#compromise between square and triangle wave, +def sampleTrapezoidal(): +    for i in range(AUDIO_DAC_BUFFER_SIZE): +        a=3 #slope/inclination +        if (i < AUDIO_DAC_BUFFER_SIZE/2): +            s = a * (i * AUDIO_DAC_SAMPLE_MAX/(AUDIO_DAC_BUFFER_SIZE/2)) + (1-a)*AUDIO_DAC_SAMPLE_MAX/2 +        else: +            i = i - AUDIO_DAC_BUFFER_SIZE/2 +            s = AUDIO_DAC_SAMPLE_MAX - a * (i * AUDIO_DAC_SAMPLE_MAX/(AUDIO_DAC_BUFFER_SIZE/2)) - (1-a)*AUDIO_DAC_SAMPLE_MAX/2 + +        if s < 0: +            s=0 +        if s> AUDIO_DAC_SAMPLE_MAX: +            s=AUDIO_DAC_SAMPLE_MAX +        samples.append(s) + + +#sampleSine() +sampleTrapezoidal() +#print(samples) +plot(samples) +to_lut(samples) diff --git a/util/chibios-upgrader.sh b/util/chibios_conf_updater.sh index ebc12abe7d..70bd80da1e 100755 --- a/util/chibios-upgrader.sh +++ b/util/chibios_conf_updater.sh @@ -51,7 +51,7 @@ revert_chibi_files() {      for file in $(find_chibi_files "$search_path" -name chconf.h -or -name halconf.h -or -name mcuconf.h -or -name board.c -or -name board.h -or -name board.mk -or -name board.chcfg) ; do          pushd "$search_path" >/dev/null 2>&1          local relpath=$(realpath --relative-to="$search_path" "$file") -        git checkout upstream/master -- "$relpath" || git checkout origin/master -- "$relpath" || true +        git checkout upstream/develop -- "$relpath" || git checkout origin/develop -- "$relpath" || true          popd >/dev/null 2>&1      done  } @@ -132,6 +132,14 @@ upgrade_chconf_files() {  upgrade_halconf_files() {      upgrade_conf_files_generic halconf.h update_halconf.sh + +    OIFS=$IFS +    IFS=$'\n' +    for file in $(find_chibi_files "$qmk_firmware_dir" -name halconf.h) ; do +        echo $file +        sed -i 's@#include "mcuconf.h"@#include <mcuconf.h>@g' "$file" +    done +    IFS=$OIFS  }  upgrade_mcuconf_files() { diff --git a/util/drivers.txt b/util/drivers.txt index c3c5e286b1..a41192571f 100644 --- a/util/drivers.txt +++ b/util/drivers.txt @@ -11,4 +11,5 @@ libusb,ATmega32U2,03EB,2FF0,ddc2c572-cb6e-4f61-a6cc-1a5de941f063  libusb,ATmega16U4,03EB,2FF3,3180d426-bf93-4578-a693-2efbc337da8e  libusb,ATmega32U4,03EB,2FF4,5f9726fd-f9de-487a-9fbd-8b3524a7a56a  libusb,AT90USB64,03EB,2FF9,c6a708ad-e97d-43cd-b04a-3180d737a71b +libusb,AT90USB162,03EB,2FFA,ef8546f0-ef09-4e7c-8fc2-ffbae1dcd84a  libusb,AT90USB128,03EB,2FFB,fd217df3-59d0-440a-a8f3-4c0c8c84daa3 diff --git a/util/install/gentoo.sh b/util/install/gentoo.sh index d4284e9a93..97eb5df07f 100755 --- a/util/install/gentoo.sh +++ b/util/install/gentoo.sh @@ -23,7 +23,7 @@ _qmk_install() {      sudo emerge -auN sys-devel/gcc      sudo emerge -au --noreplace \          app-arch/unzip app-arch/zip net-misc/wget sys-devel/clang sys-devel/crossdev \ -        \>=dev-lang/python-3.6 \ +        \>=dev-lang/python-3.7 \          dev-embedded/avrdude dev-embedded/dfu-programmer app-mobilephone/dfu-util      sudo crossdev -s4 --stable --g \<9 --portage --verbose --target avr diff --git a/util/install/opensuse.sh b/util/install/opensuse.sh deleted file mode 100755 index 47b44ae364..0000000000 --- a/util/install/opensuse.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -_qmk_install_prepare() { -    case $(grep ID /etc/os-release) in -        *15.1*) -            REPO_RELEASE=Leap_15.1;; -        *15.2*) -            REPO_RELEASE=Leap_15.2;; -        *) -            #REPO_RELEASE=Tumbleweed;; -            echo "ERROR: Tumbleweed is currently not supported." -            exit 1 -    esac - -    sudo zypper addrepo https://download.opensuse.org/repositories/devel:gcc/openSUSE_$REPO_RELEASE/devel:gcc.repo -    sudo zypper addrepo https://download.opensuse.org/repositories/hardware/openSUSE_$REPO_RELEASE/hardware.repo -    sudo zypper --gpg-auto-import-keys refresh -} - -_qmk_install() { -    echo "Installing dependencies" - -    sudo zypper install -y \ -        make clang gcc unzip wget zip \ -        python3-pip \ -        cross-avr-binutils cross-avr-gcc8 avr-libc \ -        cross-arm-binutils cross-arm-none-gcc8 cross-arm-none-newlib-devel \ -        avrdude dfu-programmer dfu-util - -    python3 -m pip install --user -r $QMK_FIRMWARE_DIR/requirements.txt -} diff --git a/util/install/sabayon.sh b/util/install/sabayon.sh deleted file mode 100755 index fd4f4d8dfd..0000000000 --- a/util/install/sabayon.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -_qmk_install() { -    echo "Installing dependencies" - -    sudo equo install \ -        app-arch/unzip app-arch/zip net-misc/wget dev-vcs/git sys-devel/clang sys-devel/gcc sys-devel/crossdev \ -        dev-python/pip \ -        dev-embedded/avrdude dev-embedded/dfu-programmer app-mobilephone/dfu-util - -    sudo crossdev -s4 --stable --g \<9 --portage --verbose --target avr -    sudo crossdev -s4 --stable --g \<9 --portage --verbose --target arm-none-eabi - -    python3 -m pip install --user -r $QMK_FIRMWARE_DIR/requirements.txt -} diff --git a/util/qmk_install.sh b/util/qmk_install.sh index 5076e980a2..421a91a999 100755 --- a/util/qmk_install.sh +++ b/util/qmk_install.sh @@ -25,10 +25,6 @@ case $(uname -a) in                  . "$QMK_FIRMWARE_UTIL_DIR/install/fedora.sh";;              *gentoo*)                  . "$QMK_FIRMWARE_UTIL_DIR/install/gentoo.sh";; -            *opensuse*|*tumbleweed*) -                . "$QMK_FIRMWARE_UTIL_DIR/install/opensuse.sh";; -            *sabayon*) -                . "$QMK_FIRMWARE_UTIL_DIR/install/sabayon.sh";;              *slackware*)                  . "$QMK_FIRMWARE_UTIL_DIR/install/slackware.sh";;              *solus*) @@ -36,9 +32,9 @@ case $(uname -a) in              *void*)                  . "$QMK_FIRMWARE_UTIL_DIR/install/void.sh";;              *) -                echo "Sorry, we don't recognize your distribution. Help us by contributing support!" +                echo "Sorry, we don't recognize your distribution. Try using the docker image instead:"                  echo -                echo "https://docs.qmk.fm/#/contributing" +                echo "https://docs.qmk.fm/#/getting_started_docker"                  exit 1;;          esac diff --git a/util/sample_parser.py b/util/sample_parser.py new file mode 100755 index 0000000000..70e193aee7 --- /dev/null +++ b/util/sample_parser.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 Jack Humbert +# +# 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/>. +# + +import wave, struct, sys + +waveFile = wave.open(sys.argv[1], 'r') +# print(str(waveFile.getparams())) +# sys.exit() + +if (waveFile.getsampwidth() != 2): +    raise(Exception("This script currently only works with 16bit audio files")) + +length = waveFile.getnframes() +out = "#define DAC_SAMPLE_CUSTOM_LENGTH " + str(length) + "\n\n" +out += "static const dacsample_t dac_sample_custom[" + str(length) + "] = {" +for i in range(0,length): +    if (i % 8 == 0): +        out += "\n    " +    waveData = waveFile.readframes(1) +    data = struct.unpack("<h", waveData) +    out += str(int((int(data[0]) + 0x8000) / 16)) + ", " +out = out[:-2] +out += "\n};" +print(out) diff --git a/util/udev/50-qmk.rules b/util/udev/50-qmk.rules index 70bd7e6e3e..acaa7dcc58 100644 --- a/util/udev/50-qmk.rules +++ b/util/udev/50-qmk.rules @@ -9,6 +9,8 @@ SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2ff3", TAG+="uacc  SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2ff4", TAG+="uaccess"  ### AT90USB64  SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2ff9", TAG+="uaccess" +### AT90USB162 +SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2ffa", TAG+="uaccess"  ### AT90USB128  SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2ffb", TAG+="uaccess" diff --git a/util/wavetable_parser.py b/util/wavetable_parser.py new file mode 100755 index 0000000000..be0f01f7b4 --- /dev/null +++ b/util/wavetable_parser.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 Jack Humbert +# +# 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/>. +# + +import wave, struct, sys + +waveFile = wave.open(sys.argv[1], 'r') + +length = waveFile.getnframes() +out = "#define DAC_WAVETABLE_CUSTOM_LENGTH " + str(int(length / 256)) + "\n\n" +out += "static const dacsample_t dac_wavetable_custom[" + str(int(length / 256)) + "][256] = {" +for i in range(0,length): +    if (i % 8 == 0): +        out += "\n    " +    if (i % 256 == 0): +        out = out[:-2] +        out += "{\n    " +    waveData = waveFile.readframes(1) +    data = struct.unpack("<h", waveData) +    out += str(int((int(data[0]) + 0x8000) / 16)) + ", " +    if (i % 256 == 255): +        out = out[:-2] +        out += "\n  }," +out = out[:-1] +out += "\n};" +print(out)  | 
