diff options
| author | MechMerlin <30334081+mechmerlin@users.noreply.github.com> | 2019-04-08 10:55:36 -0700 |
|---|---|---|
| committer | Drashna Jaelre <drashna@live.com> | 2019-04-08 10:55:36 -0700 |
| commit | 3e26886700a42fa6f66e934d4981b3e285784cd9 (patch) | |
| tree | 1c084bb10f45a29106233fc7105363980178fecb /keyboards/singa | |
| parent | 0456bd668de37f118e717aabf00a132756ea619c (diff) | |
| download | qmk_firmware-3e26886700a42fa6f66e934d4981b3e285784cd9.tar.gz qmk_firmware-3e26886700a42fa6f66e934d4981b3e285784cd9.zip | |
[Keyboard] Refactor Singa (#5579)
* pragma once it all
* put amnesia's name everywhere
* fixup readme
* remove custom matrix
* remove unneccessary configs
* disable bootmagic
* remove custom i2c in favor of i2c_master
* fix rgb led num
* add in rgb underglow support
Diffstat (limited to 'keyboards/singa')
| -rw-r--r-- | keyboards/singa/config.h | 9 | ||||
| -rw-r--r-- | keyboards/singa/i2c.c | 106 | ||||
| -rw-r--r-- | keyboards/singa/i2c.h | 27 | ||||
| -rw-r--r-- | keyboards/singa/keymaps/amnesia0287/config.h | 2 | ||||
| -rw-r--r-- | keyboards/singa/keymaps/amnesia0287/keymap.c | 2 | ||||
| -rw-r--r-- | keyboards/singa/keymaps/default/config.h | 2 | ||||
| -rw-r--r-- | keyboards/singa/keymaps/default/keymap.c | 2 | ||||
| -rw-r--r-- | keyboards/singa/keymaps/test/config.h | 2 | ||||
| -rw-r--r-- | keyboards/singa/keymaps/test/keymap.c | 2 | ||||
| -rw-r--r-- | keyboards/singa/matrix.c | 112 | ||||
| -rw-r--r-- | keyboards/singa/readme.md | 8 | ||||
| -rw-r--r-- | keyboards/singa/rules.mk | 10 | ||||
| -rw-r--r-- | keyboards/singa/singa.c | 63 | ||||
| -rw-r--r-- | keyboards/singa/singa.h | 7 | ||||
| -rw-r--r-- | keyboards/singa/usbconfig.h | 5 |
15 files changed, 63 insertions, 296 deletions
diff --git a/keyboards/singa/config.h b/keyboards/singa/config.h index 54cacee2e..aca1153d7 100644 --- a/keyboards/singa/config.h +++ b/keyboards/singa/config.h | |||
| @@ -15,8 +15,7 @@ You should have received a copy of the GNU General Public License | |||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ | 16 | */ |
| 17 | 17 | ||
| 18 | #ifndef CONFIG_H | 18 | #pragma once |
| 19 | #define CONFIG_H | ||
| 20 | 19 | ||
| 21 | #include "config_common.h" | 20 | #include "config_common.h" |
| 22 | 21 | ||
| @@ -25,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 25 | #define MANUFACTURER Singa Keyboards | 24 | #define MANUFACTURER Singa Keyboards |
| 26 | #define PRODUCT Singa | 25 | #define PRODUCT Singa |
| 27 | 26 | ||
| 28 | #define RGBLED_NUM 16 | 27 | #define RGBLED_NUM 18 |
| 29 | 28 | ||
| 30 | #define MATRIX_ROWS 7 | 29 | #define MATRIX_ROWS 7 |
| 31 | #define MATRIX_COLS 15 | 30 | #define MATRIX_COLS 15 |
| @@ -40,7 +39,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 40 | #define NO_BACKLIGHT_CLOCK | 39 | #define NO_BACKLIGHT_CLOCK |
| 41 | #define BACKLIGHT_LEVELS 1 | 40 | #define BACKLIGHT_LEVELS 1 |
| 42 | #define RGBLIGHT_ANIMATIONS | 41 | #define RGBLIGHT_ANIMATIONS |
| 43 | |||
| 44 | #define NO_UART 1 | ||
| 45 | |||
| 46 | #endif | ||
diff --git a/keyboards/singa/i2c.c b/keyboards/singa/i2c.c deleted file mode 100644 index e8c4455ad..000000000 --- a/keyboards/singa/i2c.c +++ /dev/null | |||
| @@ -1,106 +0,0 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | // Please do not modify this file | ||
| 19 | |||
| 20 | #include <avr/io.h> | ||
| 21 | #include <util/twi.h> | ||
| 22 | |||
| 23 | #include "i2c.h" | ||
| 24 | |||
| 25 | void i2c_set_bitrate(uint16_t bitrate_khz) { | ||
| 26 | uint8_t bitrate_div = ((F_CPU / 1000l) / bitrate_khz); | ||
| 27 | if (bitrate_div >= 16) { | ||
| 28 | bitrate_div = (bitrate_div - 16) / 2; | ||
| 29 | } | ||
| 30 | TWBR = bitrate_div; | ||
| 31 | } | ||
| 32 | |||
| 33 | void i2c_init(void) { | ||
| 34 | // set pull-up resistors on I2C bus pins | ||
| 35 | PORTC |= 0b11; | ||
| 36 | |||
| 37 | i2c_set_bitrate(400); | ||
| 38 | |||
| 39 | // enable TWI (two-wire interface) | ||
| 40 | TWCR |= (1 << TWEN); | ||
| 41 | |||
| 42 | // enable TWI interrupt and slave address ACK | ||
| 43 | TWCR |= (1 << TWIE); | ||
| 44 | TWCR |= (1 << TWEA); | ||
| 45 | } | ||
| 46 | |||
| 47 | uint8_t i2c_start(uint8_t address) { | ||
| 48 | // reset TWI control register | ||
| 49 | TWCR = 0; | ||
| 50 | |||
| 51 | // begin transmission and wait for it to end | ||
| 52 | TWCR = (1<<TWINT) | (1<<TWSTA) | (1<<TWEN); | ||
| 53 | while (!(TWCR & (1<<TWINT))); | ||
| 54 | |||
| 55 | // check if the start condition was successfully transmitted | ||
| 56 | if ((TWSR & 0xF8) != TW_START) { | ||
| 57 | return 1; | ||
| 58 | } | ||
| 59 | |||
| 60 | // transmit address and wait | ||
| 61 | TWDR = address; | ||
| 62 | TWCR = (1<<TWINT) | (1<<TWEN); | ||
| 63 | while (!(TWCR & (1<<TWINT))); | ||
| 64 | |||
| 65 | // check if the device has acknowledged the READ / WRITE mode | ||
| 66 | uint8_t twst = TW_STATUS & 0xF8; | ||
| 67 | if ((twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK)) { | ||
| 68 | return 1; | ||
| 69 | } | ||
| 70 | |||
| 71 | return 0; | ||
| 72 | } | ||
| 73 | |||
| 74 | void i2c_stop(void) { | ||
| 75 | TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO); | ||
| 76 | } | ||
| 77 | |||
| 78 | uint8_t i2c_write(uint8_t data) { | ||
| 79 | TWDR = data; | ||
| 80 | |||
| 81 | // transmit data and wait | ||
| 82 | TWCR = (1<<TWINT) | (1<<TWEN); | ||
| 83 | while (!(TWCR & (1<<TWINT))); | ||
| 84 | |||
| 85 | if ((TWSR & 0xF8) != TW_MT_DATA_ACK) { | ||
| 86 | return 1; | ||
| 87 | } | ||
| 88 | |||
| 89 | return 0; | ||
| 90 | } | ||
| 91 | |||
| 92 | uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length) { | ||
| 93 | if (i2c_start(address)) { | ||
| 94 | return 1; | ||
| 95 | } | ||
| 96 | |||
| 97 | for (uint16_t i = 0; i < length; i++) { | ||
| 98 | if (i2c_write(data[i])) { | ||
| 99 | return 1; | ||
| 100 | } | ||
| 101 | } | ||
| 102 | |||
| 103 | i2c_stop(); | ||
| 104 | |||
| 105 | return 0; | ||
| 106 | } | ||
diff --git a/keyboards/singa/i2c.h b/keyboards/singa/i2c.h deleted file mode 100644 index 7ce50cdb5..000000000 --- a/keyboards/singa/i2c.h +++ /dev/null | |||
| @@ -1,27 +0,0 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2016 Luiz Ribeiro <luizribeiro@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | // Please do not modify this file | ||
| 19 | |||
| 20 | #ifndef __I2C_H__ | ||
| 21 | #define __I2C_H__ | ||
| 22 | |||
| 23 | void i2c_init(void); | ||
| 24 | void i2c_set_bitrate(uint16_t bitrate_khz); | ||
| 25 | uint8_t i2c_send(uint8_t address, uint8_t *data, uint16_t length); | ||
| 26 | |||
| 27 | #endif | ||
diff --git a/keyboards/singa/keymaps/amnesia0287/config.h b/keyboards/singa/keymaps/amnesia0287/config.h index 0f7563505..e176ed347 100644 --- a/keyboards/singa/keymaps/amnesia0287/config.h +++ b/keyboards/singa/keymaps/amnesia0287/config.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* Copyright 2018 REPLACE_WITH_YOUR_NAME | 1 | /* Copyright 2018 amnesia0287 |
| 2 | * | 2 | * |
| 3 | * This program is free software: you can redistribute it and/or modify | 3 | * This program is free software: you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by | 4 | * it under the terms of the GNU General Public License as published by |
diff --git a/keyboards/singa/keymaps/amnesia0287/keymap.c b/keyboards/singa/keymaps/amnesia0287/keymap.c index cb0ceac1a..dc52122db 100644 --- a/keyboards/singa/keymaps/amnesia0287/keymap.c +++ b/keyboards/singa/keymaps/amnesia0287/keymap.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* Copyright 2018 REPLACE_WITH_YOUR_NAME | 1 | /* Copyright 2018 amnesia0287 |
| 2 | * | 2 | * |
| 3 | * This program is free software: you can redistribute it and/or modify | 3 | * This program is free software: you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by | 4 | * it under the terms of the GNU General Public License as published by |
diff --git a/keyboards/singa/keymaps/default/config.h b/keyboards/singa/keymaps/default/config.h index 4496c5910..93b81b57b 100644 --- a/keyboards/singa/keymaps/default/config.h +++ b/keyboards/singa/keymaps/default/config.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* Copyright 2018 REPLACE_WITH_YOUR_NAME | 1 | /* Copyright 2018 amnesia0287 |
| 2 | * | 2 | * |
| 3 | * This program is free software: you can redistribute it and/or modify | 3 | * This program is free software: you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by | 4 | * it under the terms of the GNU General Public License as published by |
diff --git a/keyboards/singa/keymaps/default/keymap.c b/keyboards/singa/keymaps/default/keymap.c index d201f413b..7beef8a64 100644 --- a/keyboards/singa/keymaps/default/keymap.c +++ b/keyboards/singa/keymaps/default/keymap.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* Copyright 2018 REPLACE_WITH_YOUR_NAME | 1 | /* Copyright 2018 amnesia0287 |
| 2 | * | 2 | * |
| 3 | * This program is free software: you can redistribute it and/or modify | 3 | * This program is free software: you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by | 4 | * it under the terms of the GNU General Public License as published by |
diff --git a/keyboards/singa/keymaps/test/config.h b/keyboards/singa/keymaps/test/config.h index 0f7563505..e176ed347 100644 --- a/keyboards/singa/keymaps/test/config.h +++ b/keyboards/singa/keymaps/test/config.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* Copyright 2018 REPLACE_WITH_YOUR_NAME | 1 | /* Copyright 2018 amnesia0287 |
| 2 | * | 2 | * |
| 3 | * This program is free software: you can redistribute it and/or modify | 3 | * This program is free software: you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by | 4 | * it under the terms of the GNU General Public License as published by |
diff --git a/keyboards/singa/keymaps/test/keymap.c b/keyboards/singa/keymaps/test/keymap.c index 30f8de3b3..a8f31b49c 100644 --- a/keyboards/singa/keymaps/test/keymap.c +++ b/keyboards/singa/keymaps/test/keymap.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* Copyright 2018 REPLACE_WITH_YOUR_NAME | 1 | /* Copyright 2018 amnesia0287 |
| 2 | * | 2 | * |
| 3 | * This program is free software: you can redistribute it and/or modify | 3 | * This program is free software: you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by | 4 | * it under the terms of the GNU General Public License as published by |
diff --git a/keyboards/singa/matrix.c b/keyboards/singa/matrix.c deleted file mode 100644 index 245813dfd..000000000 --- a/keyboards/singa/matrix.c +++ /dev/null | |||
| @@ -1,112 +0,0 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include <avr/io.h> | ||
| 19 | #include <util/delay.h> | ||
| 20 | |||
| 21 | #include "matrix.h" | ||
| 22 | |||
| 23 | #ifndef DEBOUNCE | ||
| 24 | # define DEBOUNCE 5 | ||
| 25 | #endif | ||
| 26 | |||
| 27 | static uint8_t debouncing = DEBOUNCE; | ||
| 28 | |||
| 29 | static matrix_row_t matrix[MATRIX_ROWS]; | ||
| 30 | static matrix_row_t matrix_debouncing[MATRIX_ROWS]; | ||
| 31 | |||
| 32 | void matrix_set_row_status(uint8_t row); | ||
| 33 | uint8_t bit_reverse(uint8_t x); | ||
| 34 | |||
| 35 | void matrix_init(void) { | ||
| 36 | // all outputs for rows high | ||
| 37 | DDRB = 0xFF; | ||
| 38 | PORTB = 0xFF; | ||
| 39 | // all inputs for columns | ||
| 40 | DDRA = 0x00; | ||
| 41 | DDRC &= ~(0x111111<<2); | ||
| 42 | DDRD &= ~(1<<PIND7); | ||
| 43 | // all columns are pulled-up | ||
| 44 | PORTA = 0xFF; | ||
| 45 | PORTC |= (0b111111<<2); | ||
| 46 | PORTD |= (1<<PIND7); | ||
| 47 | |||
| 48 | // initialize matrix state: all keys off | ||
| 49 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
| 50 | matrix[row] = 0x00; | ||
| 51 | matrix_debouncing[row] = 0x00; | ||
| 52 | } | ||
| 53 | |||
| 54 | matrix_init_quantum(); | ||
| 55 | } | ||
| 56 | |||
| 57 | uint8_t matrix_scan(void) { | ||
| 58 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
| 59 | matrix_set_row_status(row); | ||
| 60 | _delay_us(5); | ||
| 61 | |||
| 62 | matrix_row_t cols = ( | ||
| 63 | // cols 0..7, PORTA 0 -> 7 | ||
| 64 | (~PINA) & 0xFF | ||
| 65 | ) | ( | ||
| 66 | // cols 8..13, PORTC 7 -> 0 | ||
| 67 | bit_reverse((~PINC) & 0xFF) << 8 | ||
| 68 | ) | ( | ||
| 69 | // col 14, PORTD 7 | ||
| 70 | ((~PIND) & (1 << PIND7)) << 7 | ||
| 71 | ); | ||
| 72 | |||
| 73 | if (matrix_debouncing[row] != cols) { | ||
| 74 | matrix_debouncing[row] = cols; | ||
| 75 | debouncing = DEBOUNCE; | ||
| 76 | } | ||
| 77 | } | ||
| 78 | |||
| 79 | if (debouncing) { | ||
| 80 | if (--debouncing) { | ||
| 81 | _delay_ms(1); | ||
| 82 | } else { | ||
| 83 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 84 | matrix[i] = matrix_debouncing[i]; | ||
| 85 | } | ||
| 86 | } | ||
| 87 | } | ||
| 88 | |||
| 89 | matrix_scan_quantum(); | ||
| 90 | |||
| 91 | return 1; | ||
| 92 | } | ||
| 93 | |||
| 94 | // declarations | ||
| 95 | void matrix_set_row_status(uint8_t row) { | ||
| 96 | DDRB = (1 << row); | ||
| 97 | PORTB = ~(1 << row); | ||
| 98 | } | ||
| 99 | |||
| 100 | uint8_t bit_reverse(uint8_t x) { | ||
| 101 | x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); | ||
| 102 | x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc); | ||
| 103 | x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0); | ||
| 104 | return x; | ||
| 105 | } | ||
| 106 | |||
| 107 | inline matrix_row_t matrix_get_row(uint8_t row) { | ||
| 108 | return matrix[row]; | ||
| 109 | } | ||
| 110 | |||
| 111 | void matrix_print(void) { | ||
| 112 | } | ||
diff --git a/keyboards/singa/readme.md b/keyboards/singa/readme.md index bdde361a8..4400717c8 100644 --- a/keyboards/singa/readme.md +++ b/keyboards/singa/readme.md | |||
| @@ -4,7 +4,7 @@ | |||
| 4 |  | 4 |  |
| 5 | 5 | ||
| 6 | 6 | ||
| 7 | A short description of the keyboard/project | 7 | 75% Custom Keyboard. |
| 8 | 8 | ||
| 9 | 9 | ||
| 10 | Keyboard Maintainer: [amnesia0287](https://github.com/amnesia0287) | 10 | Keyboard Maintainer: [amnesia0287](https://github.com/amnesia0287) |
| @@ -38,9 +38,9 @@ macOS: | |||
| 38 | ``` | 38 | ``` |
| 39 | 3. Install the following packages: | 39 | 3. Install the following packages: |
| 40 | ``` | 40 | ``` |
| 41 | brew install python | 41 | brew install python3 |
| 42 | brew install pyusb | 42 | pip3 install pyusb |
| 43 | brew install --HEAD`https://raw.githubusercontent.com/robertgzr/homebrew-tap/master/bootloadhid.rb | 43 | brew install --HEAD https://raw.githubusercontent.com/robertgzr/homebrew-tap/master/bootloadhid.rb |
| 44 | 44 | ||
| 45 | 4. Place your keyboard into reset. | 45 | 4. Place your keyboard into reset. |
| 46 | 5. Flash the board by typing `bootloadHID -r` followed by the path to your `.hex` file. | 46 | 5. Flash the board by typing `bootloadHID -r` followed by the path to your `.hex` file. |
diff --git a/keyboards/singa/rules.mk b/keyboards/singa/rules.mk index 68d50aec6..7e4669689 100644 --- a/keyboards/singa/rules.mk +++ b/keyboards/singa/rules.mk | |||
| @@ -31,20 +31,18 @@ F_CPU = 12000000 | |||
| 31 | BOOTLOADER = bootloadHID | 31 | BOOTLOADER = bootloadHID |
| 32 | 32 | ||
| 33 | # build options | 33 | # build options |
| 34 | BOOTMAGIC_ENABLE = yes | 34 | BOOTMAGIC_ENABLE = no |
| 35 | MOUSEKEY_ENABLE = yes | 35 | MOUSEKEY_ENABLE = yes |
| 36 | EXTRAKEY_ENABLE = yes | 36 | EXTRAKEY_ENABLE = yes |
| 37 | CONSOLE_ENABLE = yes | 37 | CONSOLE_ENABLE = yes |
| 38 | COMMAND_ENABLE = yes | 38 | COMMAND_ENABLE = yes |
| 39 | BACKLIGHT_ENABLE = no | 39 | BACKLIGHT_ENABLE = yes |
| 40 | RGBLIGHT_ENABLE = no | 40 | RGBLIGHT_ENABLE = yes |
| 41 | RGBLIGHT_CUSTOM_DRIVER = yes | 41 | RGBLIGHT_CUSTOM_DRIVER = yes |
| 42 | 42 | ||
| 43 | OPT_DEFS = -DDEBUG_LEVEL=0 | 43 | OPT_DEFS = -DDEBUG_LEVEL=0 |
| 44 | 44 | ||
| 45 | # custom matrix setup | 45 | SRC = i2c_master.c |
| 46 | CUSTOM_MATRIX = yes | ||
| 47 | SRC = matrix.c i2c.c | ||
| 48 | 46 | ||
| 49 | # programming options | 47 | # programming options |
| 50 | PROGRAM_CMD = ./util/atmega32a_program.py $(TARGET).hex | 48 | PROGRAM_CMD = ./util/atmega32a_program.py $(TARGET).hex |
diff --git a/keyboards/singa/singa.c b/keyboards/singa/singa.c index 0f5ec471a..26a7e4637 100644 --- a/keyboards/singa/singa.c +++ b/keyboards/singa/singa.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* Copyright 2018 REPLACE_WITH_YOUR_NAME | 1 | /* Copyright 2018 amnesia0287 |
| 2 | * | 2 | * |
| 3 | * This program is free software: you can redistribute it and/or modify | 3 | * This program is free software: you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by | 4 | * it under the terms of the GNU General Public License as published by |
| @@ -13,32 +13,57 @@ | |||
| 13 | * You should have received a copy of the GNU General Public License | 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | #include QMK_KEYBOARD_H | 16 | #include "rgblight.h" |
| 17 | 17 | #include "i2c_master.h" | |
| 18 | #include <avr/pgmspace.h> | ||
| 19 | #include "action_layer.h" | ||
| 20 | #include "i2c.h" | ||
| 21 | #include "quantum.h" | 18 | #include "quantum.h" |
| 22 | 19 | ||
| 20 | #ifdef RGBLIGHT_ENABLE | ||
| 21 | extern rgblight_config_t rgblight_config; | ||
| 22 | |||
| 23 | void rgblight_set(void) { | ||
| 24 | if (!rgblight_config.enable) { | ||
| 25 | for (uint8_t i = 0; i < RGBLED_NUM; i++) { | ||
| 26 | led[i].r = 0; | ||
| 27 | led[i].g = 0; | ||
| 28 | led[i].b = 0; | ||
| 29 | } | ||
| 30 | } | ||
| 23 | 31 | ||
| 24 | // for keyboard subdirectory level init functions | 32 | i2c_init(); |
| 25 | // @Override | 33 | i2c_transmit(0xb0, (uint8_t*)led, 3 * RGBLED_NUM, 100); |
| 26 | void matrix_init_kb(void) { | ||
| 27 | // call user level keymaps, if any | ||
| 28 | matrix_init_user(); | ||
| 29 | } | 34 | } |
| 35 | #endif | ||
| 30 | 36 | ||
| 31 | void matrix_scan_kb(void) { | 37 | __attribute__ ((weak)) |
| 32 | matrix_scan_user(); | 38 | void matrix_scan_user(void) { |
| 33 | /* Nothing else for now. */ | ||
| 34 | } | 39 | } |
| 35 | 40 | ||
| 36 | __attribute__((weak)) // overridable | 41 | void backlight_init_ports(void) { |
| 37 | void matrix_init_user(void) { | 42 | // initialize pins D0, D1, D4 and D6 as output |
| 43 | setPinOutput(D0); | ||
| 44 | setPinOutput(D1); | ||
| 45 | setPinOutput(D4); | ||
| 46 | setPinOutput(D6); | ||
| 38 | 47 | ||
| 48 | // turn RGB LEDs on | ||
| 49 | writePinHigh(D0); | ||
| 50 | writePinHigh(D1); | ||
| 51 | writePinHigh(D4); | ||
| 52 | writePinHigh(D6); | ||
| 39 | } | 53 | } |
| 40 | 54 | ||
| 41 | __attribute__((weak)) // overridable | 55 | void backlight_set(uint8_t level) { |
| 42 | void matrix_scan_user(void) { | 56 | if (level == 0) { |
| 43 | 57 | // turn RGB LEDs off | |
| 58 | writePinLow(D0); | ||
| 59 | writePinLow(D1); | ||
| 60 | writePinLow(D4); | ||
| 61 | writePinLow(D6); | ||
| 62 | } else { | ||
| 63 | // turn RGB LEDs on | ||
| 64 | writePinHigh(D0); | ||
| 65 | writePinHigh(D1); | ||
| 66 | writePinHigh(D4); | ||
| 67 | writePinHigh(D6); | ||
| 68 | } | ||
| 44 | } | 69 | } |
diff --git a/keyboards/singa/singa.h b/keyboards/singa/singa.h index 8221176c1..03b684888 100644 --- a/keyboards/singa/singa.h +++ b/keyboards/singa/singa.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* Copyright 2018 REPLACE_WITH_YOUR_NAME | 1 | /* Copyright 2018 amnesia0287 |
| 2 | * | 2 | * |
| 3 | * This program is free software: you can redistribute it and/or modify | 3 | * This program is free software: you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by | 4 | * it under the terms of the GNU General Public License as published by |
| @@ -13,8 +13,7 @@ | |||
| 13 | * You should have received a copy of the GNU General Public License | 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | #ifndef SINGA_H | 16 | #pragma once |
| 17 | #define SINGA_H | ||
| 18 | 17 | ||
| 19 | #include "quantum.h" | 18 | #include "quantum.h" |
| 20 | 19 | ||
| @@ -139,5 +138,3 @@ | |||
| 139 | { k74, k81, k75, KC_NO, KC_NO, k76, KC_NO, KC_NO, k77, KC_NO, k82, KC_NO, k78, k79, k80 }, \ | 138 | { k74, k81, k75, KC_NO, KC_NO, k76, KC_NO, KC_NO, k77, KC_NO, k82, KC_NO, k78, k79, k80 }, \ |
| 140 | { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, k15, k30 } \ | 139 | { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, k15, k30 } \ |
| 141 | } | 140 | } |
| 142 | |||
| 143 | #endif | ||
diff --git a/keyboards/singa/usbconfig.h b/keyboards/singa/usbconfig.h index d2d848fcd..54a7d20f1 100644 --- a/keyboards/singa/usbconfig.h +++ b/keyboards/singa/usbconfig.h | |||
| @@ -8,8 +8,7 @@ | |||
| 8 | * This Revision: $Id: usbconfig-prototype.h 785 2010-05-30 17:57:07Z cs $ | 8 | * This Revision: $Id: usbconfig-prototype.h 785 2010-05-30 17:57:07Z cs $ |
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | #ifndef __usbconfig_h_included__ | 11 | #pragma once |
| 12 | #define __usbconfig_h_included__ | ||
| 13 | 12 | ||
| 14 | #include "config.h" | 13 | #include "config.h" |
| 15 | 14 | ||
| @@ -392,5 +391,3 @@ section at the end of this file). | |||
| 392 | /* #define USB_INTR_PENDING EIFR */ | 391 | /* #define USB_INTR_PENDING EIFR */ |
| 393 | #define USB_INTR_PENDING_BIT INTF1 | 392 | #define USB_INTR_PENDING_BIT INTF1 |
| 394 | #define USB_INTR_VECTOR INT1_vect | 393 | #define USB_INTR_VECTOR INT1_vect |
| 395 | |||
| 396 | #endif /* __usbconfig_h_included__ */ | ||
