Compare commits

...

20 Commits

Author SHA1 Message Date
Ryan
53ac4d214f Update Hungarian keymap and add sendstring LUT (#8220) 2020-03-03 11:55:42 +11:00
Ryan
bff56aa46c Remove "ugly hack in usb_main.c" comments (#8296) 2020-03-02 23:56:46 +00:00
Danny
ce30cd2a01 Update encoder functions for Iris VIA keymap (#8295) 2020-03-02 23:55:57 +00:00
Ted M Lin
552f8d81b9 Reduce PROGMEM usage for sendstring LUT (#8109)
* Reduce PROGMEM usage for keycode map

Bit-pack the keycode bool array to gain back a small amount of flash space.
The trade-off is an increase in runtime instructions when running macros.

It does make the code a bit harder to read, as well as maintain.

For configs that use send_string() et al, it saves ~100 bytes.

* Switch to macro and common definition

Rewrite the array declarations so both the unpacked (original) and
packed LUT arrays can use the same value definitions. This is done by
defining a macro that "knows what to do".

This makes the code much easier to read and maintain.

* Fix macro typos and improve perf

Pack the bits in a more efficient order for extraction.
And also fix the copy/paste error in the macro...

* Switch fully to packed LUT

Some minor reformatting.
Compile tested all sendstring_xyz.h to make sure they were converted
properly. Also checked that an unconverted version would generate a
compile error.

* Apply whitespace suggestions from code review

Co-Authored-By: Ryan <fauxpark@gmail.com>

Co-authored-by: Ryan <fauxpark@gmail.com>
2020-03-03 10:43:18 +11:00
Drashna Jaelre
abd36de5ad [Docs] Update ISP Flashing guide (#8149)
* [Docs] Update ISP Flashing guide

* Apply suggestions from code review

AKA why you shouldn't write docs at 2am

Co-Authored-By: fauxpark <fauxpark@gmail.com>
Co-Authored-By: James Young <18669334+noroadsleft@users.noreply.github.com>

* Update workding for planck-qmk-dfu

Co-authored-by: Ryan <fauxpark@gmail.com>
Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com>
2020-03-01 22:29:26 -08:00
Dustin L. Howett
b72a1aa3fe Rewrite the Bathroom Epiphanies Frosty Flake matrix and LED handling (#8243)
* Keyboard: revamp frosty-flake leds

This commit transitions bpiphany/frosty_flake to led_update_{kb,user}
and rewrites the AVR bit twiddling logic to use the standard QMK GPIO
API.

* Keyboard: rewrite frosty_flake's matrix reader to be a lite custom matrix

This commit replaces frosty_flake's custom matrix and debounce logic
with a "lite" custom matrix. In addition to being somewhat clearer, this
allows a consumer of the flake board to choose their own debouncing
algorithm. The one closest to the implementation originally in use is
sym_g, but this opens us up to supporting eager_pk and eager_pr.

The original matrix code was 18 columns for 8 rows, but using a single
row read and unpacking the bits into individual columns. To simplify,
I've changed the key layout to be 8C 18R instead of 18C 8R: this lets us
use a single read directly into the matrix _and_ drop down to a uint8_t
instead of a uint32_t for matrix_row_t.

Since we're no longer implementing our own debouncing and row unpacking,
we save ~400 bytes on the final firmware image.

Fully tested against a CM Storm QFR hosting the flake -- this commit
message was written using the new matrix code.

Firmware Sizes (assuming stock configuration as of 42d6270f2)

Matrix+Debounce     Size (bytes)
---------------     ------------
original            17740
new + sym_g         17284
new + eager_pr      18106
new + eager_pk      18204

I expect that there are some scanning speed benefits as well.

* Keyboard: update frosty_flake's UNUSED_PINS

* Keyboard: Remove meaningless weak redefinitions from frosty

These are not necessary (and all of them already live somewhere in
Quantum).
2020-03-02 05:17:09 +00:00
Nick Brassel
78069d4826 Add onekey keymap for testing reset to bootloader. (#8288) 2020-03-01 22:36:17 +00:00
Andrew Kannan
c543ccf07c Get the direction right on the S75 encoder (#8287) 2020-03-01 21:30:01 +00:00
Joel Challis
88356c85c4 Prune out pure software pwm && custom driver && remove wrapping BACKLIGHT_PIN (#8041) 2020-03-01 20:22:13 +00:00
Andrew Kannan
3dc061ac78 Make a fix to savage65 and tmov2 for via (#8286) 2020-03-02 07:16:43 +11:00
QMK Bot
95124bf933 format code according to conventions [skip ci] 2020-03-01 19:20:09 +00:00
Joel Challis
e7fb873ee2 Short term fix for conflicting types for 'tfp_printf' (#8157) 2020-03-02 05:46:40 +11:00
Joel Challis
629950e51b Fix recent clang-format breaking quantum.c (#8282) 2020-03-01 17:55:43 +00:00
QMK Bot
1ec8a7205f format code according to conventions [skip ci] 2020-03-01 13:54:25 +00:00
Ryan
ce604e1629 Remove duplicate BRTG case (#8277) 2020-03-01 13:22:21 +00:00
Ryan
c9e3fa6f70 Clean up includes for glcdfont headers (#7745)
* Clean up includes for glcdfont headers

* Remove pragma once, most of these are not headers

* Missed these
2020-03-01 17:56:50 +11:00
James Young
f513a9193c Fix the Breaking Changes doc again
WHAT YEAR IS IT?!
2020-02-29 20:46:48 -08:00
s-show
21715210e2 [Docs] translated 'feature_tap_dance.md' to japanese. (#8137)
* complete translation.

* Update docs/ja/feature_tap_dance.md

Update the file based on the suggestions.

* Update docs/ja/feature_tap_dance.md

Update the file based on the suggestions.

* Apply suggestions from code review

Update the file based on the suggestions.

* Apply suggestions from code review

Update the file based on the suggestions (Part 2).

* Apply suggestions from code review

Update the file based on the suggestions (Part 3).

* Apply suggestions from code review

Update the file based on the suggestions (Part 3).

* Apply suggestions from code review

Update the file based on the suggestions (Part 4).

* Apply suggestions from code review

Update the file based on the suggestions (Part 5).
ご提案いただいた修正案は全て確認できました。
続いて、コメント行の調整、「打つ・叩く」の変更、その他の修正を行います。

* fixed typo.

* Update the file based on the suggestions (Part 6).

* Update the file based on the suggestions (Part 7).

* Fixed sentence.

* Update docs/ja/feature_tap_dance.md

Update the file based on the suggestions (Part 8).

* Update the file based on the suggestions (Part 9).

Co-Authored-By: Takeshi ISHII <2170248+mtei@users.noreply.github.com>
Co-Authored-By: shela <shelaf@users.noreply.github.com>
2020-02-29 20:22:15 -08:00
Joel Challis
f74c769a19 PWM DMA based RGB Underglow for STM32 (#7928)
* Add pwm ws2812 driver

* Add docs for pwm ws2812 driver

* Update ws2812_pwm for ChibiOS 19

Co-Authored-By: Nick Brassel <nick@tzarc.org>

Co-authored-by: Nick Brassel <nick@tzarc.org>
2020-03-01 13:05:56 +11:00
holtenc
bb47236490 Add VIA support to Prime_M. Clean up all files (#8247)
* Add VIA support for Prime_L

* Update keyboards/primekb/prime_l/v1/config.h

* Add prime_exl_plus keyboard

* Temporary removal of prime_exl_plus

* Add Prime_EXL Plus, including VIA support

* Update keyboards/handwired/prime_exl_plus/readme.md

* Update keyboards/handwired/prime_exl_plus/readme.md

* Update keyboards/handwired/prime_exl_plus/readme.md

* Update keyboards/handwired/prime_exl_plus/rules.mk

* Update keyboards/handwired/prime_exl_plus/info.json

* Update keyboards/handwired/prime_exl_plus/info.json

* Update keyboards/handwired/prime_exl_plus/info.json

* Update keymap.c

* correct spacing of keymaps and layout macro. move indicator logic from user space to keyboard space

* further corrections to keymaps and layout macro.

* Update keyboards/handwired/prime_exl_plus/prime_exl_plus.c

* Update keyboards/handwired/prime_exl_plus/prime_exl_plus.c

* Update keyboards/handwired/prime_exl_plus/prime_exl_plus.c

* Update keyboards/handwired/prime_exl_plus/prime_exl_plus.c

* Update prime_exl_plus.c

* small edit to prime_exl_plus.c

* Add via support to Prime_M and clean things up

* Update rules.mk

* Update keyboards/primekb/prime_m/readme.md

* Update keyboards/primekb/prime_m/readme.md

* Update keyboards/primekb/prime_m/config.h
2020-02-29 17:42:50 -08:00
93 changed files with 2062 additions and 1415 deletions

View File

@ -15,7 +15,7 @@ The next Breaking Change is scheduled for May 30, 2020.
### Important Dates
* [x] 2019 Feb 29 - `future` is created. It will be rebased weekly.
* [x] 2020 Feb 29 - `future` is created. It will be rebased weekly.
* [ ] 2020 May 2 - `future` closed to new PR's.
* [ ] 2020 May 2 - Call for testers.
* [ ] 2020 May 28 - `master` is locked, no PR's merged.

View File

@ -1,6 +1,14 @@
# ISP Flashing Guide
If you're having trouble flashing/erasing your board, and running into cryptic error messages like any of the following:
ISP flashing (also known as ICSP flashing) is the process of programming a microcontroller directly. This allows you to replace the bootloader, or change the "fuses" on the controller, which control a number of hardware- and software-related functions, such as the speed of the controller, how it boots, and other options.
The main use of ISP flashing for QMK is flashing or replacing the bootloader on your AVR-based controller (Pro Micros, or V-USB chips).
?> This is only for programming AVR based boards, such as the Pro Micro or other ATmega controllers. It is not for Arm controllers, such as the Proton C.
## Dealing with Corrupted Bootloaders
If you're having trouble flashing/erasing your board, and running into cryptic error messages like any of the following for a DFU based controller:
libusb: warning [darwin_transfer_status] transfer error: timed out
dfu.c:844: -ETIMEDOUT: Transfer timed out, NAK 0xffffffc4 (-60)
@ -19,16 +27,60 @@ If you're having trouble flashing/erasing your board, and running into cryptic e
Memory write error, use debug for more info.
commands.c:360: Error writing memory data. (err -4)
You're likely going to need to ISP flash your board/device to get it working again. Luckily, this process is pretty straight-forward, provided you have any extra programmable keyboard, Pro Micro, or Teensy 2.0/Teensy 2.0++. There are also dedicated ISP flashers available for this, but most cost >$15, and it's assumed that if you are googling this error, this is the first you've heard about ISP flashing, and don't have one readily available (whereas you might have some other AVR board). __We'll be using a Teensy 2.0 or Pro Micro with Windows 10 in this guide__ - if you are comfortable doing this on another system, please consider editing this guide and contributing those instructions!
Or, if you see this sort of message for a Pro Micro based controller:
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
avrdude: verification error, first mismatch at byte 0x002a
0x2b != 0x75
avrdude: verification error; content mismatch
avrdude: verification error; content mismatch
You're likely going to need to ISP flash your board/device to get it working again.
## Hardware Needed
You'll need one of the following to actually perform the ISP flashing (followed by the protocol they use):
* [SparkFun PocketAVR](https://www.sparkfun.com/products/9825) - (USB Tiny)
* [USBtinyISP AVR Programmer Kit](https://www.adafruit.com/product/46) - (USB Tiny)
* [Teensy 2.0](https://www.pjrc.com/store/teensy.html) - (avrisp)
* [Pro Micro](https://www.sparkfun.com/products/12640) - (avrisp)
* [Bus Pirate](https://www.adafruit.com/product/237) - (buspirate)
There are other devices that can be used to ISP flash, but these are the main ones. Also, all product links are to the official versions. You can source them elsewhere.
You'll also need something to wire your "ISP Programmer" to the device that you're programming. Some PCBs may have ISP headers that you can use directly, but this often isn't the case, so you'll likely need to solder to the controller itself or to different switches or other components.
### The ISP Firmware
The Teensy and Pro Micro controllers will need you to flash the ISP firmware to the controllers before you can use them as an ISP programmer. The rest of the hardware should come preprogrammed. So, for these controllers, download the correct hex file, and flash it first.
* Teensy 2.0: [`util/teensy_2.0_ISP_B0.hex`](https://github.com/qmk/qmk_firmware/blob/master/util/teensy_2.0_ISP_B0.hex) (`B0`)
* Pro Micro: [`util/pro_micro_ISP_B6_10.hex`](https://github.com/qmk/qmk_firmware/blob/master/util/pro_micro_ISP_B6_10.hex) (`10/B6`)
Once you've flashed your controller, you won't need this hex file anymore.
## Software Needed
* [Teensy Loader](https://www.pjrc.com/teensy/loader.html) (if using a Teensy)
* QMK Toolbox (flash as usual - be sure to select the correct MCU) or `avrdude` via [WinAVR](http://www.ladyada.net/learn/avr/setup-win.html) (for Teensy & Pro Micro)
The QMK Toolbox can be used for most (all) of this.
However, you can grab the [Teensy Loader](https://www.pjrc.com/teensy/loader.html) to flash your Teensy 2.0 board, if you are using that. Or you can use `avrdude` (installed as part of `qmk_install.sh`), or [AVRDUDESS](https://blog.zakkemble.net/avrdudess-a-gui-for-avrdude/) (for Windows) to flash the Pro Micro, and the ISP flashing.
## Wiring
This is pretty straight-forward - we'll be connecting like-things to like-things in the following manner:
This is pretty straight-forward - we'll be connecting like-things to like-things in the following manner.
### SparkFun Pocket AVR
PocketAVR RST <-> Keyboard RESET
PocketAVR SCLK <-> Keyboard B1 (SCLK)
PocketAVR MOSI <-> Keyboard B2 (MOSI)
PocketAVR MISO <-> Keyboard B3 (MISO)
PocketAVR VCC <-> Keyboard VCC
PocketAVR GND <-> Keyboard GND
### Teensy 2.0
@ -39,6 +91,8 @@ This is pretty straight-forward - we'll be connecting like-things to like-things
Teensy VCC <-> Keyboard VCC
Teensy GND <-> Keyboard GND
!> Note that the B0 pin on the Teensy is wired to the RESET/RST pin on the keyboard's controller. ***DO NOT*** wire the RESET pin on the Teensy to the RESET on the keyboard.
### Pro Micro
Pro Micro 10 (B6) <-> Keyboard RESET
@ -48,45 +102,61 @@ This is pretty straight-forward - we'll be connecting like-things to like-things
Pro Micro VCC <-> Keyboard VCC
Pro Micro GND <-> Keyboard GND
## The ISP Firmware (now pre-compiled)
!> Note that the 10/B6 pin on the Pro Micro is wired to the RESET/RST pin on the keyboard's controller. ***DO NOT*** wire the RESET pin on the Pro Micro to the RESET on the keyboard.
The only difference between the .hex files below is which pin is connected to RESET. You can use them on other boards as well, as long as you're aware of the pins being used. If for some reason neither of these pins are available, [create an issue](https://github.com/qmk/qmk_firmware/issues/new), and we can generate one for you!
* Teensy 2.0: [`util/teensy_2.0_ISP_B0.hex`](https://github.com/qmk/qmk_firmware/blob/master/util/teensy_2.0_ISP_B0.hex) (`B0`)
* Pro Micro: [`util/pro_micro_ISP_B6_10.hex`](https://github.com/qmk/qmk_firmware/blob/master/util/pro_micro_ISP_B6_10.hex) (`B6/10`)
## Flashing Your Keyboard
**Flash your Teenys/Pro Micro with one of these and continue - you won't need the file after flashing your ISP device.**
After you have your ISP programmer set up, and wired to your keyboard, it's time to flash your keyboard.
## Just the Bootloader File
### The Bootloader File
If you just want to get things back to normal, you can flash only a bootloader from [`util/` folder](https://github.com/qmk/qmk_firmware/tree/master/util), and use your normal process to flash the firmware afterwards. Be sure to flash the correct bootloader for your chip:
The simplest and quickest way to get things back to normal is to flash only a bootloader to the keyboard. Once this is done, you can connect the keyboard normally and flash the keyboard like you normally would.
You can find the stock bootloaders in the [`util/` folder](https://github.com/qmk/qmk_firmware/tree/master/util). Be sure to flash the correct bootloader for your chip:
* [`atmega32u4`](https://github.com/qmk/qmk_firmware/blob/master/util/bootloader_atmega32u4_1_0_0.hex) - Most keyboards, Planck Rev 1-5, Preonic Rev 1-2
* [`Pro Micro`](https://github.com/sparkfun/Arduino_Boards/blob/master/sparkfun/avr/bootloaders/caterina/Caterina-promicro16.hex) - The default bootloader for Pro Micro controllers
* [`at90usb1286`](https://github.com/qmk/qmk_firmware/blob/master/util/bootloader_at90usb128x_1_0_1.hex) - Planck Light Rev 1
* [`atmega32a`](https://github.com/qmk/qmk_firmware/blob/master/util/bootloader_atmega32a_1_0_0.hex) - jj40
* [`atmega32a`](https://github.com/qmk/qmk_firmware/blob/master/util/bootloader_atmega32a_1_0_0.hex) - jj40, and other V-USB/ps2avrGB keyboards
If you're not sure what your board uses, look in the `rules.mk` file for the keyboard in QMK. The `MCU =` line will have the value you need. It may differ between different versions of the board.
### Advanced/Production Techniques
### Production Techniques
If you'd like to flash both the bootloader **and** the regular firmware at the same time, you need to combine the files.
If you'd like to flash both the bootloader **and** the regular firmware at the same time, there are two options to do so. Manually, or with the `:production` target when compiling.
To do this manually:
1. Open the original firmware .hex file in a text editor
2. Remove the last line (which should be `:00000001FF` - this is an EOF message)
3. Copy the entire bootloader's contents onto a new line (with no empty lines between) and paste it at the end of the original file
4. Save it as a new file by naming it `<keyboard>_<keymap>_production.hex`
It's possible to use other bootloaders here in the same way, but __you need a bootloader__, otherwise you'll have to use ISP again to write new firmware to your keyboard.
?> It's possible to use other bootloaders here in the same way, but __you need a bootloader__, otherwise you'll have to use ISP again to write new firmware to your keyboard.
To do this the easy way, you can flash the board using the `:production` target when compiling. This compiles the firmware, then compiles the QMK DFU bootloader, and then creates a combined image. Once this is done, you'll see three files:
* `<keyboard>_<keymap>.hex`
* `<keyboard>_<keymap>_bootloader.hex`
* `<keyboard>_<keymap>_production.hex`
The QMK DFU bootloader has only really been tested on `atmega32u4` controllers (such as the AVR based Planck boards, and the Pro Micro), and hasn't been tested on other controllers. However, it will definitely not work on V-USB controllers, such as the `atmega32a` or `atmega328p`.
You can flash either the bootloader or the production firmware file. The production firmware file will take a lot longer to flash, since it's flashing a lot more data.
?> Note: You should stay with the same bootloader. If you're using DFU already, switching to QMK DFU is fine. But flashing QMK DFU onto a Pro Micro, for instance, has additional steps needed.
## Flashing Your Bootloader/Production File
Make sure your keyboard is unplugged from any device, and plug in your Teensy.
Make sure your keyboard is unplugged from any device, and plug in your ISP Programmer.
If you want to change bootloader types, You'll need to use the command line.
### QMK Toolbox
1. `AVRISP device connected` will show up in yellow
1. `AVRISP device connected` or `USB Tiny device connected` will show up in yellow
2. Select the correct bootloader/production .hex file with the `Open` dialog (spaces can't be in the path)
3. Be sure the correct `Microcontroller` option is selected
3. Be sure the correct `Microcontroller` option for the keyboard you're flashing (not the ISP programmer) is selected
4. Hit `Flash`
5. Wait, as nothing will output for a while, especially with production files
@ -94,7 +164,7 @@ If the verification and fuse checks are ok, you're done! Your board may restart
### Command Line
Open `cmd` and navigate to your where your modified .hex file is. We'll pretend this file is called `main.hex`, and that your Teensy 2.0 is on the `COM3` port - if you're unsure, you can open your Device Manager, and look for `Ports > USB Serial Device`. Use that COM port here. You can confirm it's the right port with:
Open a terminal (`cmd` on Windows, for instance) and navigate to your where your modified .hex file is. We'll pretend this file is called `main.hex`, and that your Teensy 2.0 is on the `COM3` port - if you're unsure, you can open your Device Manager, and look for `Ports > USB Serial Device`. Use that COM port here. You can confirm it's the right port with:
avrdude -c avrisp -P COM3 -p atmega32u4
@ -129,4 +199,47 @@ You should see a couple of progress bars, then you should see:
Which means everything should be ok! Your board may restart automatically, otherwise, unplug your Teensy and plug in your keyboard - you can leave your Teensy wired to your keyboard while testing things, but it's recommended that you desolder it/remove the wiring once you're sure everything works.
If you're using a SparkFun PocketAVR Programmer, or another USB Tiny based ISP programmer, you will want to use something like this:
avrdude -c usbtiny -P usb -p atmega32u4
#### Advanced: Changing Fuses
If you're switching bootloaders, such as flashing QMK DFU on a Pro Micro, you will need to change the fuses, in additional to flashing the bootloader hex file. This is because `caterina` (the Pro Micro bootloader) and `dfu` handle the startup routines differently, and that behavior is controlled by the fuses.
!> This is one area that it is very important to be careful, as changing fuses is one of the ways that you can permanently brick your controller.
For this, we are assuming the 5V 16MHz versions of the `atmega32u4` (such as the 5V Pro Micro).
For DFU on the `atmega32u4`, these are the fuse settings that you want:
| Fuse | Setting |
|----------|------------------|
| Low | `0x5E` |
| High | `0xD9` or `0x99` |
| Extended | `0xC3` |
The High fuse can be 0xD9 or 0x99. The difference is that 0xD9 disables JTAG, which QMK Firmware disables via software as well, while 0x99 doesn't disable JTAG.
To set this add `-U lfuse:w:0x5E:m -U hfuse:w:0xD9:m -U efuse:w:0xC3:m` to your command. So the final command should look something like:
avrdude -c avrisp -P COM3 -p atmega32u4 -U flash:w:main.hex:i -U lfuse:w:0x5E:m -U hfuse:w:0xD9:m -U efuse:w:0xC3:m
For Caterina on the `atmega32u4`, these are the fuse settings that you want:
| Fuse | Setting|
|----------|--------|
| Low | `0xFF` |
| High | `0xD9` |
| Extended | `0xC3` |
To set this add `-U lfuse:w:0xFF:m -U hfuse:w:0xD8:m -U efuse:w:0xC3:m` to your command. So the final command should look something like:
avrdude -c avrisp -P COM3 -p atmega32u4 -U flash:w:main.hex:i -U lfuse:w:0xFF:m -U hfuse:w:0xD8:m -U efuse:w:0xC3:m
If you are using a different controller or want different configuration, you can use [this AVR Fuse Calculator](http://www.engbedded.com/fusecalc/) to find a better value for you.
## Help
If you have any questions/problems, feel free to [open an issue](https://github.com/qmk/qmk_firmware/issues/new)!

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@ These LEDs are called "addressable" because instead of using a wire per color, e
| bit bang | :heavy_check_mark: | :heavy_check_mark: |
| I2C | :heavy_check_mark: | |
| SPI | | :heavy_check_mark: |
| PWM | | Soon™ |
| PWM | | :heavy_check_mark: |
## Driver configuration
@ -66,4 +66,36 @@ While not an exhaustive list, the following table provides the scenarios that ha
| f103 | A7 :heavy_check_mark: | B15 :heavy_check_mark: | N/A |
| f303 | A7 :heavy_check_mark: B5 :heavy_check_mark: | B15 :heavy_check_mark: | B5 :heavy_check_mark: |
*Other supported ChibiOS boards and/or pins may function, it will be highly chip and configuration dependent.*
*Other supported ChibiOS boards and/or pins may function, it will be highly chip and configuration dependent.*
### PWM
Targeting STM32 boards where WS2812 support is offloaded to an PWM timer and DMA stream. The advantage is that the use of DMA offloads processing of the WS2812 protocol from the MCU. To configure it, add this to your rules.mk:
```make
WS2812_DRIVER = pwm
```
Configure the hardware via your config.h:
```c
#define WS2812_PWM_DRIVER PWMD2 // default: PWMD2
#define WS2812_PWM_CHANNEL 2 // default: 2
#define WS2812_PWM_PAL_MODE 2 // Pin "alternate function", see the respective datasheet for the appropriate values for your MCU. default: 2
#define WS2812_DMA_STREAM STM32_DMA1_STREAM2 // DMA Stream for TIMx_UP, see the respective reference manual for the appropriate values for your MCU.
#define WS2812_DMA_CHANNEL 2 // DMA Channel for TIMx_UP, see the respective reference manual for the appropriate values for your MCU.
```
You must also turn on the PWM feature in your halconf.h and mcuconf.h
#### Testing Notes
While not an exhaustive list, the following table provides the scenarios that have been partially validated:
| | Status |
|-|-|
| f072 | ? |
| f103 | :heavy_check_mark: |
| f303 | :heavy_check_mark: |
| f401/f411 | :heavy_check_mark: |
*Other supported ChibiOS boards and/or pins may function, it will be highly chip and configuration dependent.*

View File

@ -1 +1,207 @@
#error("NOT SUPPORTED")
#include "ws2812.h"
#include "quantum.h"
#include "hal.h"
/* Adapted from https://github.com/joewa/WS2812-LED-Driver_ChibiOS/ */
#ifdef RGBW
# error "RGBW not supported"
#endif
#ifndef WS2812_PWM_DRIVER
# define WS2812_PWM_DRIVER PWMD2 // TIMx
#endif
#ifndef WS2812_PWM_CHANNEL
# define WS2812_PWM_CHANNEL 2 // Channel
#endif
#ifndef WS2812_PWM_PAL_MODE
# define WS2812_PWM_PAL_MODE 2 // DI Pin's alternate function value
#endif
#ifndef WS2812_DMA_STREAM
# define WS2812_DMA_STREAM STM32_DMA1_STREAM2 // DMA Stream for TIMx_UP
#endif
#ifndef WS2812_DMA_CHANNEL
# define WS2812_DMA_CHANNEL 2 // DMA Channel for TIMx_UP
#endif
#ifndef WS2812_PWM_TARGET_PERIOD
//# define WS2812_PWM_TARGET_PERIOD 800000 // Original code is 800k...?
# define WS2812_PWM_TARGET_PERIOD 80000 // TODO: work out why 10x less on f303/f4x1
#endif
/* --- PRIVATE CONSTANTS ---------------------------------------------------- */
#define WS2812_PWM_FREQUENCY (STM32_SYSCLK / 2) /**< Clock frequency of PWM, must be valid with respect to system clock! */
#define WS2812_PWM_PERIOD (WS2812_PWM_FREQUENCY / WS2812_PWM_TARGET_PERIOD) /**< Clock period in ticks. 1 / 800kHz = 1.25 uS (as per datasheet) */
/**
* @brief Number of bit-periods to hold the data line low at the end of a frame
*
* The reset period for each frame must be at least 50 uS; so we add in 50 bit-times
* of zeroes at the end. (50 bits)*(1.25 uS/bit) = 62.5 uS, which gives us some
* slack in the timing requirements
*/
#define WS2812_RESET_BIT_N (50)
#define WS2812_COLOR_BIT_N (RGBLED_NUM * 24) /**< Number of data bits */
#define WS2812_BIT_N (WS2812_COLOR_BIT_N + WS2812_RESET_BIT_N) /**< Total number of bits in a frame */
/**
* @brief High period for a zero, in ticks
*
* Per the datasheet:
* WS2812:
* - T0H: 200 nS to 500 nS, inclusive
* - T0L: 650 nS to 950 nS, inclusive
* WS2812B:
* - T0H: 200 nS to 500 nS, inclusive
* - T0L: 750 nS to 1050 nS, inclusive
*
* The duty cycle is calculated for a high period of 350 nS.
*/
#define WS2812_DUTYCYCLE_0 (WS2812_PWM_FREQUENCY / (1000000000 / 350))
/**
* @brief High period for a one, in ticks
*
* Per the datasheet:
* WS2812:
* - T1H: 550 nS to 850 nS, inclusive
* - T1L: 450 nS to 750 nS, inclusive
* WS2812B:
* - T1H: 750 nS to 1050 nS, inclusive
* - T1L: 200 nS to 500 nS, inclusive
*
* The duty cycle is calculated for a high period of 800 nS.
* This is in the middle of the specifications of the WS2812 and WS2812B.
*/
#define WS2812_DUTYCYCLE_1 (WS2812_PWM_FREQUENCY / (1000000000 / 800))
/* --- PRIVATE MACROS ------------------------------------------------------- */
/**
* @brief Determine the index in @ref ws2812_frame_buffer "the frame buffer" of a given bit
*
* @param[in] led: The led index [0, @ref RGBLED_NUM)
* @param[in] byte: The byte number [0, 2]
* @param[in] bit: The bit number [0, 7]
*
* @return The bit index
*/
#define WS2812_BIT(led, byte, bit) (24 * (led) + 8 * (byte) + (7 - (bit)))
/**
* @brief Determine the index in @ref ws2812_frame_buffer "the frame buffer" of a given red bit
*
* @note The red byte is the middle byte in the color packet
*
* @param[in] led: The led index [0, @ref RGBLED_NUM)
* @param[in] bit: The bit number [0, 7]
*
* @return The bit index
*/
#define WS2812_RED_BIT(led, bit) WS2812_BIT((led), 1, (bit))
/**
* @brief Determine the index in @ref ws2812_frame_buffer "the frame buffer" of a given green bit
*
* @note The red byte is the first byte in the color packet
*
* @param[in] led: The led index [0, @ref RGBLED_NUM)
* @param[in] bit: The bit number [0, 7]
*
* @return The bit index
*/
#define WS2812_GREEN_BIT(led, bit) WS2812_BIT((led), 0, (bit))
/**
* @brief Determine the index in @ref ws2812_frame_buffer "the frame buffer" of a given blue bit
*
* @note The red byte is the last byte in the color packet
*
* @param[in] led: The led index [0, @ref RGBLED_NUM)
* @param[in] bit: The bit index [0, 7]
*
* @return The bit index
*/
#define WS2812_BLUE_BIT(led, bit) WS2812_BIT((led), 2, (bit))
/* --- PRIVATE VARIABLES ---------------------------------------------------- */
static uint32_t ws2812_frame_buffer[WS2812_BIT_N + 1]; /**< Buffer for a frame */
/* --- PUBLIC FUNCTIONS ----------------------------------------------------- */
/*
* Gedanke: Double-buffer type transactions: double buffer transfers using two memory pointers for
the memory (while the DMA is reading/writing from/to a buffer, the application can
write/read to/from the other buffer).
*/
void ws2812_init(void) {
// Initialize led frame buffer
uint32_t i;
for (i = 0; i < WS2812_COLOR_BIT_N; i++) ws2812_frame_buffer[i] = WS2812_DUTYCYCLE_0; // All color bits are zero duty cycle
for (i = 0; i < WS2812_RESET_BIT_N; i++) ws2812_frame_buffer[i + WS2812_COLOR_BIT_N] = 0; // All reset bits are zero
#if defined(USE_GPIOV1)
palSetLineMode(RGB_DI_PIN, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
#else
palSetLineMode(RGB_DI_PIN, PAL_MODE_ALTERNATE(WS2812_PWM_PAL_MODE) | PAL_STM32_OSPEED_HIGHEST | PAL_STM32_PUPDR_FLOATING);
#endif
// PWM Configuration
//#pragma GCC diagnostic ignored "-Woverride-init" // Turn off override-init warning for this struct. We use the overriding ability to set a "default" channel config
static const PWMConfig ws2812_pwm_config = {
.frequency = WS2812_PWM_FREQUENCY,
.period = WS2812_PWM_PERIOD, // Mit dieser Periode wird UDE-Event erzeugt und ein neuer Wert (Länge WS2812_BIT_N) vom DMA ins CCR geschrieben
.callback = NULL,
.channels =
{
[0 ... 3] = {.mode = PWM_OUTPUT_DISABLED, .callback = NULL}, // Channels default to disabled
[WS2812_PWM_CHANNEL - 1] = {.mode = PWM_OUTPUT_ACTIVE_HIGH, .callback = NULL}, // Turn on the channel we care about
},
.cr2 = 0,
.dier = TIM_DIER_UDE, // DMA on update event for next period
};
//#pragma GCC diagnostic pop // Restore command-line warning options
// Configure DMA
// dmaInit(); // Joe added this
dmaStreamAlloc(WS2812_DMA_STREAM - STM32_DMA1_STREAM1, 10, NULL, NULL);
dmaStreamSetPeripheral(WS2812_DMA_STREAM, &(WS2812_PWM_DRIVER.tim->CCR[WS2812_PWM_CHANNEL - 1])); // Ziel ist der An-Zeit im Cap-Comp-Register
dmaStreamSetMemory0(WS2812_DMA_STREAM, ws2812_frame_buffer);
dmaStreamSetTransactionSize(WS2812_DMA_STREAM, WS2812_BIT_N);
dmaStreamSetMode(WS2812_DMA_STREAM, STM32_DMA_CR_CHSEL(WS2812_DMA_CHANNEL) | STM32_DMA_CR_DIR_M2P | STM32_DMA_CR_PSIZE_WORD | STM32_DMA_CR_MSIZE_WORD | STM32_DMA_CR_MINC | STM32_DMA_CR_CIRC | STM32_DMA_CR_PL(3));
// M2P: Memory 2 Periph; PL: Priority Level
// Start DMA
dmaStreamEnable(WS2812_DMA_STREAM);
// Configure PWM
// NOTE: It's required that preload be enabled on the timer channel CCR register. This is currently enabled in the
// ChibiOS driver code, so we don't have to do anything special to the timer. If we did, we'd have to start the timer,
// disable counting, enable the channel, and then make whatever configuration changes we need.
pwmStart(&WS2812_PWM_DRIVER, &ws2812_pwm_config);
pwmEnableChannel(&WS2812_PWM_DRIVER, WS2812_PWM_CHANNEL - 1, 0); // Initial period is 0; output will be low until first duty cycle is DMA'd in
}
void ws2812_write_led(uint16_t led_number, uint8_t r, uint8_t g, uint8_t b) {
// Write color to frame buffer
for (uint8_t bit = 0; bit < 8; bit++) {
ws2812_frame_buffer[WS2812_RED_BIT(led_number, bit)] = ((r >> bit) & 0x01) ? WS2812_DUTYCYCLE_1 : WS2812_DUTYCYCLE_0;
ws2812_frame_buffer[WS2812_GREEN_BIT(led_number, bit)] = ((g >> bit) & 0x01) ? WS2812_DUTYCYCLE_1 : WS2812_DUTYCYCLE_0;
ws2812_frame_buffer[WS2812_BLUE_BIT(led_number, bit)] = ((b >> bit) & 0x01) ? WS2812_DUTYCYCLE_1 : WS2812_DUTYCYCLE_0;
}
}
// Setleds for standard RGB
void ws2812_setleds(LED_TYPE* ledarray, uint16_t leds) {
static bool s_init = false;
if (!s_init) {
ws2812_init();
s_init = true;
}
for (uint16_t i = 0; i < leds; i++) {
ws2812_write_led(i, ledarray[i].r, ledarray[i].g, ledarray[i].b);
}
}

View File

@ -1,17 +1,7 @@
// This is the 'classic' fixed-space bitmap font for Adafruit_GFX since 1.0.
// See gfxfont.h for newer custom bitmap font info.
#ifndef FONT5X7_H
#define FONT5X7_H
#ifdef __AVR__
# include <avr/io.h>
# include <avr/pgmspace.h>
#elif defined(ESP8266)
# include <pgmspace.h>
#else
# define PROGMEM
#endif
#include "progmem.h"
// Standard ASCII 5x7 font
@ -31,4 +21,3 @@ static const unsigned char font[] PROGMEM = {
0x14, 0x14, 0x14, 0xF4, 0x14, 0x10, 0x10, 0xF0, 0x10, 0xF0, 0x00, 0x00, 0x1F, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x1F, 0x14, 0x00, 0x00, 0x00, 0xFC, 0x14, 0x00, 0x00, 0xF0, 0x10, 0xF0, 0x10, 0x10, 0xFF, 0x10, 0xFF, 0x14, 0x14, 0x14, 0xFF, 0x14, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x38, 0x44, 0x44, 0x38, 0x44, 0xFC, 0x4A, 0x4A, 0x4A, 0x34, // sharp-s or beta
0x7E, 0x02, 0x02, 0x06, 0x06, 0x02, 0x7E, 0x02, 0x7E, 0x02, 0x63, 0x55, 0x49, 0x41, 0x63, 0x38, 0x44, 0x44, 0x3C, 0x04, 0x40, 0x7E, 0x20, 0x1E, 0x20, 0x06, 0x02, 0x7E, 0x02, 0x02, 0x99, 0xA5, 0xE7, 0xA5, 0x99, 0x1C, 0x2A, 0x49, 0x2A, 0x1C, 0x4C, 0x72, 0x01, 0x72, 0x4C, 0x30, 0x4A, 0x4D, 0x4D, 0x30, 0x30, 0x48, 0x78, 0x48, 0x30, 0xBC, 0x62, 0x5A, 0x46, 0x3D, 0x3E, 0x49, 0x49, 0x49, 0x00, 0x7E, 0x01, 0x01, 0x01, 0x7E, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x44, 0x44, 0x5F, 0x44, 0x44, 0x40, 0x51, 0x4A, 0x44, 0x40, 0x40, 0x44, 0x4A, 0x51, 0x40, 0x00, 0x00, 0xFF, 0x01, 0x03, 0xE0, 0x80, 0xFF, 0x00, 0x00, 0x08, 0x08, 0x6B, 0x6B, 0x08, 0x36, 0x12, 0x36, 0x24, 0x36, 0x06, 0x0F, 0x09, 0x0F, 0x06, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x30, 0x40, 0xFF, 0x01, 0x01, 0x00, 0x1F, 0x01, 0x01, 0x1E, 0x00, 0x19, 0x1D, 0x17, 0x12, 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00 // #255 NBSP
};
#endif // FONT5X7_H

View File

@ -1,13 +1,4 @@
#pragma once
#ifdef __AVR__
# include <avr/io.h>
# include <avr/pgmspace.h>
#elif defined(ESP8266)
# include <pgmspace.h>
#else
# define PROGMEM
#endif
#include "progmem.h"
// Helidox 8x6 font with QMK Firmware Logo
// Online editor: http://teripom.x0.com/

View File

@ -22,15 +22,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <string.h>
#if defined(__AVR__)
# include <avr/io.h>
# include <avr/pgmspace.h>
#elif defined(ESP8266)
# include <pgmspace.h>
#else // defined(ESP8266)
# define PROGMEM
#include "progmem.h"
#ifndef __AVR__
# define memcpy_P(des, src, len) memcpy(des, src, len)
#endif // defined(__AVR__)
#endif
// Used commands from spec sheet: https://cdn-shop.adafruit.com/datasheets/SSD1306.pdf
// for SH1106: https://www.velleman.eu/downloads/29/infosheets/sh1106_datasheet.pdf

View File

@ -21,8 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define VENDOR_ID 0xA22A
#define PRODUCT_ID 0x6600
#define DEVICE_VER 0x0001
/* in python2: list(u"whatever".encode('utf-16-le')) */
/* at most 32 characters or the ugly hack in usb_main.c borks */
#define MANUFACTURER AT-AT
#define PRODUCT 660M
#define DESCRIPTION 660M Keyboard

View File

@ -36,13 +36,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* key matrix size */
#define MATRIX_ROWS 8 // Row0 - Row7 in the schematic
#define MATRIX_COLS 18 // ColA - ColR in the schematic
#define MATRIX_ROWS 18 // ColA - ColR in the schematic
#define MATRIX_COLS 8 // Row0 - Row7 in the schematic
/*
* Keyboard Matrix Assignments
*/
#define UNUSED_PINS { B0, C4, D3 }
#define UNUSED_PINS { C0, C1, C2, C3, C4, D2, D7 }
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
#define DEBOUNCE 5

View File

@ -1,63 +1,24 @@
#include "frosty_flake.h"
void matrix_init_kb(void) {
// put your keyboard start-up code here
// runs once when the firmware starts up
void keyboard_pre_init_kb() {
setPinOutput(B7); // num lock
writePinHigh(B7);
setPinOutput(C5); // caps lock
writePinHigh(C7);
setPinOutput(C6); // scroll lock
writePinHigh(C6);
matrix_init_user();
keyboard_pre_init_user();
}
void matrix_scan_kb(void) {
// put your looping keyboard code here
// runs every cycle (a lot)
bool led_update_kb(led_t usb_led) {
// user requests no further processing
if (!led_update_user(usb_led))
return true;
matrix_scan_user();
writePin(C5, !usb_led.caps_lock);
writePin(B7, !usb_led.num_lock);
writePin(C6, !usb_led.scroll_lock);
return true;
}
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
// put your per-action keyboard code here
// runs for every action, just before processing by the firmware
return process_record_user(keycode, record);
}
void led_set_kb(uint8_t usb_led) {
DDRB |= (1<<7);
DDRC |= (1<<5) | (1<<6);
print_dec(usb_led);
if (usb_led & (1<<USB_LED_CAPS_LOCK))
PORTC &= ~(1<<5);
else
PORTC |= (1<<5);
if (usb_led & (1<<USB_LED_NUM_LOCK))
PORTB &= ~(1<<7);
else
PORTB |= (1<<7);
if (usb_led & (1<<USB_LED_SCROLL_LOCK))
PORTC &= ~(1<<6);
else
PORTC |= (1<<6);
led_set_user(usb_led);
}
__attribute__ ((weak))
void matrix_init_user(void) {
}
__attribute__ ((weak))
void matrix_scan_user(void) {
}
__attribute__ ((weak))
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return true;
}
__attribute__ ((weak))
void led_set_user(uint8_t usb_led) {
}

View File

@ -34,16 +34,25 @@
KA4, KP2, KC6, KK6, KC0, KM3, KD0, KA1, KO0, KK0, KL0, KL6, KQ6 \
) \
{ \
/* Columns and rows need to be swapped in the below definition */ \
/* A B C D E F G H I J K L M N O P Q R */ \
/* 0 */ { KC_NO, KB0, KC0, KD0, KC_NO, KF0, KG0, KC_NO, KC_NO, KC_NO, KK0, KL0, KC_NO, KC_NO, KO0, KC_NO, KQ0, KR0 }, \
/* 1 */ { KA1, KB1, KC_NO, KD1, KE1, KF1, KG1, KH1, KI1, KJ1, KK1, KL1, KC_NO, KC_NO, KC_NO, KC_NO, KQ1, KC_NO }, \
/* 2 */ { KC_NO, KB2, KC_NO, KD2, KE2, KF2, KG2, KH2, KI2, KJ2, KK2, KL2, KC_NO, KN2, KC_NO, KP2, KQ2, KR2 }, \
/* 3 */ { KC_NO, KB3, KC_NO, KD3, KE3, KF3, KG3, KH3, KI3, KJ3, KK3, KL3, KM3, KN3, KO3, KC_NO, KQ3, KR3 }, \
/* 4 */ { KA4, KB4, KC_NO, KD4, KE4, KF4, KG4, KH4, KI4, KJ4, KK4, KL4, KC_NO, KC_NO, KO4, KC_NO, KQ4, KR4 }, \
/* 5 */ { KA5, KC_NO, KC5, KD5, KE5, KF5, KG5, KH5, KI5, KJ5, KK5, KL5, KC_NO, KC_NO, KO5, KC_NO, KQ5, KR5 }, \
/* 6 */ { KC_NO, KB6, KC6, KC_NO, KE6, KF6, KG6, KH6, KI6, KJ6, KK6, KL6, KC_NO, KC_NO, KO6, KC_NO, KQ6, KR6 }, \
/* 7 */ { KA7, KB7, KC7, KD7, KE7, KF7, KG7, KH7, KI7, KJ7, KC_NO, KC_NO, KC_NO, KC_NO, KO7, KC_NO, KQ7, KR7 } \
/* 0 1 2 3 4 5 6 7 */ \
/* A */ { KC_NO, KA1, KC_NO, KC_NO, KA4, KA5, KC_NO, KA7, }, \
/* B */ { KB0, KB1, KB2, KB3, KB4, KC_NO, KB6, KB7, }, \
/* C */ { KC0, KC_NO, KC_NO, KC_NO, KC_NO, KC5, KC6, KC7, }, \
/* D */ { KD0, KD1, KD2, KD3, KD4, KD5, KC_NO, KD7, }, \
/* E */ { KC_NO, KE1, KE2, KE3, KE4, KE5, KE6, KE7, }, \
/* F */ { KF0, KF1, KF2, KF3, KF4, KF5, KF6, KF7, }, \
/* G */ { KG0, KG1, KG2, KG3, KG4, KG5, KG6, KG7, }, \
/* H */ { KC_NO, KH1, KH2, KH3, KH4, KH5, KH6, KH7, }, \
/* I */ { KC_NO, KI1, KI2, KI3, KI4, KI5, KI6, KI7, }, \
/* J */ { KC_NO, KJ1, KJ2, KJ3, KJ4, KJ5, KJ6, KJ7, }, \
/* K */ { KK0, KK1, KK2, KK3, KK4, KK5, KK6, KC_NO, }, \
/* L */ { KL0, KL1, KL2, KL3, KL4, KL5, KL6, KC_NO, }, \
/* M */ { KC_NO, KC_NO, KC_NO, KM3, KC_NO, KC_NO, KC_NO, KC_NO, }, \
/* N */ { KC_NO, KC_NO, KN2, KN3, KC_NO, KC_NO, KC_NO, KC_NO, }, \
/* O */ { KO0, KC_NO, KC_NO, KO3, KO4, KO5, KO6, KO7, }, \
/* P */ { KC_NO, KC_NO, KP2, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, }, \
/* Q */ { KQ0, KQ1, KQ2, KQ3, KQ4, KQ5, KQ6, KQ7, }, \
/* R */ { KR0, KC_NO, KR2, KR3, KR4, KR5, KR6, KR7, }, \
}
/*
@ -74,16 +83,25 @@
KA4, KP2, KC6, KK6, KC0, KM3, KD0, KA1, KO0, KK0, KL0 \
) \
{ \
/* Columns and rows need to be swapped in the below definition */ \
/* A B C D E F G H I J K L M N O P Q R */ \
/* 0 */ { KC_NO, KB0, KC0, KD0, KC_NO, KF0, KG0, KC_NO, KC_NO, KC_NO, KK0, KL0, KC_NO, KC_NO, KO0, KC_NO, KC_NO, KR0 }, \
/* 1 */ { KA1, KB1, KC_NO, KD1, KE1, KF1, KG1, KH1, KI1, KJ1, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
/* 2 */ { KC_NO, KB2, KC_NO, KD2, KE2, KF2, KG2, KH2, KI2, KJ2, KC_NO, KC_NO, KC_NO, KN2, KC_NO, KP2, KC_NO, KR2 }, \
/* 3 */ { KC_NO, KB3, KC_NO, KD3, KE3, KF3, KG3, KH3, KI3, KJ3, KC_NO, KC_NO, KM3, KN3, KC_NO, KC_NO, KC_NO, KR3 }, \
/* 4 */ { KA4, KB4, KC_NO, KD4, KE4, KF4, KG4, KH4, KI4, KJ4, KK4, KL4, KC_NO, KC_NO, KO4, KC_NO, KQ4, KR4 }, \
/* 5 */ { KA5, KC_NO, KC5, KD5, KE5, KF5, KG5, KH5, KI5, KJ5, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KR5 }, \
/* 6 */ { KC_NO, KB6, KC6, KC_NO, KE6, KF6, KG6, KH6, KI6, KJ6, KK6, KC_NO, KC_NO, KC_NO, KO6, KC_NO, KC_NO, KR6 }, \
/* 7 */ { KA7, KB7, KC7, KD7, KE7, KF7, KG7, KH7, KI7, KJ7, KC_NO, KC_NO, KC_NO, KC_NO, KO7, KC_NO, KQ7, KR7 } \
/* 0 1 2 3 4 5 6 7 */ \
/* A */ { KC_NO, KA1, KC_NO, KC_NO, KA4, KA5, KC_NO, KA7, }, \
/* B */ { KB0, KB1, KB2, KB3, KB4, KC_NO, KB6, KB7, }, \
/* C */ { KC0, KC_NO, KC_NO, KC_NO, KC_NO, KC5, KC6, KC7, }, \
/* D */ { KD0, KD1, KD2, KD3, KD4, KD5, KC_NO, KD7, }, \
/* E */ { KC_NO, KE1, KE2, KE3, KE4, KE5, KE6, KE7, }, \
/* F */ { KF0, KF1, KF2, KF3, KF4, KF5, KF6, KF7, }, \
/* G */ { KG0, KG1, KG2, KG3, KG4, KG5, KG6, KG7, }, \
/* H */ { KC_NO, KH1, KH2, KH3, KH4, KH5, KH6, KH7, }, \
/* I */ { KC_NO, KI1, KI2, KI3, KI4, KI5, KI6, KI7, }, \
/* J */ { KC_NO, KJ1, KJ2, KJ3, KJ4, KJ5, KJ6, KJ7, }, \
/* K */ { KK0, KC_NO, KC_NO, KC_NO, KK4, KC_NO, KK6, KC_NO, }, \
/* L */ { KL0, KC_NO, KC_NO, KC_NO, KL4, KC_NO, KC_NO, KC_NO, }, \
/* M */ { KC_NO, KC_NO, KC_NO, KM3, KC_NO, KC_NO, KC_NO, KC_NO, }, \
/* N */ { KC_NO, KC_NO, KN2, KN3, KC_NO, KC_NO, KC_NO, KC_NO, }, \
/* O */ { KO0, KC_NO, KC_NO, KC_NO, KO4, KC_NO, KO6, KO7, }, \
/* P */ { KC_NO, KC_NO, KP2, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, }, \
/* Q */ { KC_NO, KC_NO, KC_NO, KC_NO, KQ4, KC_NO, KC_NO, KQ7, }, \
/* R */ { KR0, KC_NO, KR2, KR3, KR4, KR5, KR6, KR7, }, \
}
#define LAYOUT_tkl_ansi( \

View File

@ -15,42 +15,15 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include <util/delay.h>
#include "print.h"
#include "debug.h"
#include "util.h"
#include "matrix.h"
#ifndef DEBOUNCE
# define DEBOUNCE 5
#endif
static uint8_t debouncing = DEBOUNCE;
static matrix_row_t matrix[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
__attribute__ ((weak))
void matrix_init_kb(void) {
matrix_init_user();
}
__attribute__ ((weak))
void matrix_scan_kb(void) {
matrix_scan_user();
}
__attribute__ ((weak))
void matrix_init_user(void) {
}
__attribute__ ((weak))
void matrix_scan_user(void) {
}
static matrix_row_t scan_col(void) {
// Each of the 8 columns is read off pins as below
// 7 6 5 4 3 2 1 0
// ,--,--,--,--,--,--,--,--,
// |B0|B3|B2|B1|B6|B4|B5|C7|
// `--`--`--`--`--`--`--`--`
return (
(PINC&(1<<7) ? 0 : ((matrix_row_t)1<<0)) |
(PINB&(1<<5) ? 0 : ((matrix_row_t)1<<1)) |
@ -63,8 +36,8 @@ static matrix_row_t scan_col(void) {
);
}
static void select_col(uint8_t col) {
switch (col) {
static void select_row(uint8_t row) {
switch (row) {
case 0: PORTD = (PORTD & ~0b01111011) | 0b00011011; break;
case 1: PORTD = (PORTD & ~0b01111011) | 0b01000011; break;
case 2: PORTD = (PORTD & ~0b01111011) | 0b01101010; break;
@ -86,7 +59,7 @@ static void select_col(uint8_t col) {
}
}
void matrix_init(void) {
void matrix_init_custom(void) {
/* Row output pins */
DDRD |= 0b01111011;
/* Column input pins */
@ -94,62 +67,19 @@ void matrix_init(void) {
DDRB &= ~0b01111111;
PORTC |= 0b10000000;
PORTB |= 0b01111111;
for (uint8_t i=0; i < MATRIX_ROWS; i++)
matrix[i] = matrix_debouncing[i] = 0;
matrix_init_quantum();
}
uint8_t matrix_scan(void) {
for (uint8_t col = 0; col < MATRIX_COLS; col++) {
select_col(col);
_delay_us(3);
matrix_row_t col_scan = scan_col();
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col);
bool curr_bit = col_scan & (1<<row);
if (prev_bit != curr_bit) {
matrix_debouncing[row] ^= ((matrix_row_t)1<<col);
debouncing = DEBOUNCE;
}
}
}
if (debouncing) {
if (--debouncing)
_delay_ms(1);
else
for (uint8_t i = 0; i < MATRIX_ROWS; i++)
matrix[i] = matrix_debouncing[i];
}
matrix_scan_quantum();
return 1;
}
inline matrix_row_t matrix_get_row(uint8_t row) {
return matrix[row];
}
void matrix_print(void) {
#ifndef NO_PRINT
print("\nr\\c ABCDEFGHIJKLMNOPQR\n");
// matrix is 18 uint8_t.
// we select the row (one of 18), then read the column
bool matrix_scan_custom(matrix_row_t current_matrix[]) {
bool has_changed = false;
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
matrix_row_t matrix_row = matrix_get_row(row);
xprintf("%02X: ", row);
for (uint8_t col = 0; col < MATRIX_COLS; col++) {
bool curr_bit = matrix_row & (1<<col);
xprintf("%c", curr_bit ? '*' : '.');
}
print("\n");
matrix_row_t orig = current_matrix[row];
select_row(row);
_delay_us(3);
current_matrix[row] = scan_col();
has_changed |= (orig != current_matrix[row]);
}
#endif
}
uint8_t matrix_key_count(void) {
uint8_t count = 0;
for (uint8_t row = 0; row < MATRIX_ROWS; row++)
count += bitpop32(matrix[row]);
return count;
return has_changed;
}

View File

@ -30,7 +30,7 @@ BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
AUDIO_ENABLE = no # Audio output on port C6
FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches
CUSTOM_MATRIX = yes
CUSTOM_MATRIX = lite
SRC += matrix.c
LAYOUTS = tkl_ansi

View File

@ -21,8 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define VENDOR_ID 0xCA04
#define PRODUCT_ID 0xA00C
#define DEVICE_VER 0x0001
/* in python2: list(u"whatever".encode('utf-16-le')) */
/* at most 32 characters or the ugly hack in usb_main.c borks */
#define MANUFACTURER CannonKeys
#define PRODUCT AN-C
#define DESCRIPTION AN-C Keyboard

View File

@ -21,8 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define VENDOR_ID 0xCA04
#define PRODUCT_ID 0xC024
#define DEVICE_VER 0x0001
/* in python2: list(u"whatever".encode('utf-16-le')) */
/* at most 32 characters or the ugly hack in usb_main.c borks */
#define MANUFACTURER CannonKeys
#define PRODUCT Chimera65
#define DESCRIPTION Chimera65 Keyboard

View File

@ -21,8 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define VENDOR_ID 0xCA04
#define PRODUCT_ID 0x1600
#define DEVICE_VER 0x0001
/* in python2: list(u"whatever".encode('utf-16-le')) */
/* at most 32 characters or the ugly hack in usb_main.c borks */
#define MANUFACTURER CannonKeys
#define PRODUCT Instant60
#define DESCRIPTION Instant 60 Keyboard

View File

@ -21,8 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define VENDOR_ID 0x5A12
#define PRODUCT_ID 0x5165
#define DEVICE_VER 0x0001
/* in python2: list(u"whatever".encode('utf-16-le')) */
/* at most 32 characters or the ugly hack in usb_main.c borks */
#define MANUFACTURER SmithAndRune
#define PRODUCT Iron165
#define DESCRIPTION Iron165 Keyboard

View File

@ -21,8 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define VENDOR_ID 0xCA04
#define PRODUCT_ID 0x0248
#define DEVICE_VER 0x0001
/* in python2: list(u"whatever".encode('utf-16-le')) */
/* at most 32 characters or the ugly hack in usb_main.c borks */
#define MANUFACTURER QMK
#define PRODUCT Ortho48
#define DESCRIPTION Ortho48

View File

@ -21,8 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define VENDOR_ID 0xFEED
#define PRODUCT_ID 0x6464
#define DEVICE_VER 0x0001
/* in python2: list(u"whatever".encode('utf-16-le')) */
/* at most 32 characters or the ugly hack in usb_main.c borks */
#define MANUFACTURER QMK
#define PRODUCT Ortho60
#define DESCRIPTION Ortho60

View File

@ -21,8 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define VENDOR_ID 0xFEED
#define PRODUCT_ID 0x6464
#define DEVICE_VER 0x0001
/* in python2: list(u"whatever".encode('utf-16-le')) */
/* at most 32 characters or the ugly hack in usb_main.c borks */
#define MANUFACTURER CannonKeys
#define PRODUCT Ortho75
#define DESCRIPTION Ortho75

View File

@ -21,8 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define VENDOR_ID 0xFEED
#define PRODUCT_ID 0x6464
#define DEVICE_VER 0x0001
/* in python2: list(u"whatever".encode('utf-16-le')) */
/* at most 32 characters or the ugly hack in usb_main.c borks */
#define MANUFACTURER QMK
#define PRODUCT Practice 60
#define DESCRIPTION Practice 60

View File

@ -21,8 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define VENDOR_ID 0xCA04
#define PRODUCT_ID 0x6565
#define DEVICE_VER 0x0001
/* in python2: list(u"whatever".encode('utf-16-le')) */
/* at most 32 characters or the ugly hack in usb_main.c borks */
#define MANUFACTURER CannonKeys
#define PRODUCT Practice 65
#define DESCRIPTION Practice 65

View File

@ -21,8 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define VENDOR_ID 0xCA04
#define PRODUCT_ID 0x57F5
#define DEVICE_VER 0x0001
/* in python2: list(u"whatever".encode('utf-16-le')) */
/* at most 32 characters or the ugly hack in usb_main.c borks */
#define MANUFACTURER CannonKeys
#define PRODUCT Satisfaction75
#define DESCRIPTION Satisfaction 75 Keyboard
@ -35,8 +33,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MATRIX_ROW_PINS { B3, B4, A0, A2, A4, A3 }
#define DIODE_DIRECTION COL2ROW
#define ENCODERS_PAD_A { B8 }
#define ENCODERS_PAD_B { B9 }
#define ENCODERS_PAD_A { B9 }
#define ENCODERS_PAD_B { B8 }
#define ENCODER_RESOLUTION 2

View File

@ -21,8 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define VENDOR_ID 0xCA04
#define PRODUCT_ID 0x5A65
#define DEVICE_VER 0x0001
/* in python2: list(u"whatever".encode('utf-16-le')) */
/* at most 32 characters or the ugly hack in usb_main.c borks */
#define MANUFACTURER CannonKeys
#define PRODUCT Savage65
#define DESCRIPTION Savage65 Keyboard

View File

@ -1,5 +1,4 @@
# rules.mk overrides to enable VIA
RAW_ENABLE = yes
DYNAMIC_KEYMAP_ENABLE = yes
VIA_ENABLE = yes

View File

@ -21,8 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define VENDOR_ID 0xCA04
#define PRODUCT_ID 0x70F2
#define DEVICE_VER 0x0001
/* in python2: list(u"whatever".encode('utf-16-le')) */
/* at most 32 characters or the ugly hack in usb_main.c borks */
#define MANUFACTURER CannonKeys
#define PRODUCT TMOv2
#define DESCRIPTION TMOv2 Keyboard

View File

@ -1,5 +1,4 @@
# rules.mk overrides to enable VIA
RAW_ENABLE = yes
DYNAMIC_KEYMAP_ENABLE = yes
VIA_ENABLE = yes

View File

@ -1,17 +1,7 @@
// This is the 'classic' fixed-space bitmap font for Adafruit_GFX since 1.0.
// See gfxfont.h for newer custom bitmap font info.
#ifndef FONT5X7_H
#define FONT5X7_H
#ifdef __AVR__
#include <avr/io.h>
#include <avr/pgmspace.h>
#elif defined(ESP8266)
#include <pgmspace.h>
#else
#define PROGMEM
#endif
#include "progmem.h"
// Standard ASCII 5x7 font
const unsigned char font[] PROGMEM = {
@ -240,4 +230,3 @@ const unsigned char font[] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
#endif // FONT5X7_H

View File

@ -1,17 +1,7 @@
// This is the 'classic' fixed-space bitmap font for Adafruit_GFX since 1.0.
// See gfxfont.h for newer custom bitmap font info.
#ifndef FONT5X7_H
#define FONT5X7_H
#ifdef __AVR__
#include <avr/io.h>
#include <avr/pgmspace.h>
#elif defined(ESP8266)
#include <pgmspace.h>
#else
#define PROGMEM
#endif
#include "progmem.h"
// Standard ASCII 5x7 font
@ -145,4 +135,3 @@ const unsigned char font[] PROGMEM = {
0x02, 0x01, 0x02, 0x04, 0x02, 0x00,
0x3C, 0x26, 0x23, 0x26, 0x3C, 0x00
};
#endif // FONT5X7_H

Some files were not shown because too many files have changed in this diff Show More