Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Anne Pro 2 keyboard #14385

Merged
merged 131 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
4a549da
[keyboard] Initial support for Anne Pro 2
Codetector1374 Jun 30, 2020
91ae4c7
[keyboard][AnnePro2] Keymap:update to a reasonable keymap with caps+h…
Codetector1374 Jun 30, 2020
c323356
:(
Codetector1374 Jun 30, 2020
bc1c566
changed to use HSI
Codetector1374 Jun 30, 2020
7e44861
support for annepro2 c18
Codetector1374 Jul 1, 2020
00509c8
keyboard/annepro2: Very stupid matrix scan bug fix.
Codetector1374 Jul 1, 2020
f4089ce
typo
Codetector1374 Jul 1, 2020
648c482
swap COL14/13
Codetector1374 Jul 1, 2020
87b1e2c
keyboard/annepro2: startup secondary LED MCU
Codetector1374 Jul 4, 2020
5712e04
keyboard/annepro2: typo fix
Codetector1374 Jul 6, 2020
b2d2f00
Add IO Values
Jul 7, 2020
e240591
Disable Combo feature
Jul 7, 2020
77dbcc0
Update default keymap to Anne Pro 2 Official Keymap
Codetector1374 Jul 8, 2020
cb7e23a
keyboard/annepro2: keymap layer name changes
Codetector1374 Jul 9, 2020
7b3726e
keyboard/annepro2 BLE Support
Codetector1374 Jul 10, 2020
db480da
Fix keymap comment
jgillich Jul 10, 2020
ac810bf
keyboard/annepro2: Bluetooth path
Codetector1374 Jul 13, 2020
46c2221
Keyboard annepro2 bidir led comms (#5)
tech2077 Aug 21, 2020
266edcb
add custom keycodes to switch led profiles
iojcde Aug 21, 2020
39d5a42
Optimize code
iojcde Aug 21, 2020
cab0772
switch to prev profile before turning leds off
iojcde Aug 22, 2020
4bbc680
Add persistent led support with eeprom (#9)
tech2077 Aug 24, 2020
fffa641
Cleanup to fix C15 eeprom/spi build errors (#11)
tech2077 Aug 29, 2020
e60ea29
LED Masking support for Shine
Codetector1374 Aug 30, 2020
c179625
[AnnePro2]: update bluetooth connection
Codetector1374 Nov 4, 2020
cf4ca46
Merge the custom keys enums on annepro2.h (#13)
thomazmoura Nov 12, 2020
758c541
Keyboard annepro2 ble caps lock (#12)
tech2077 Nov 24, 2020
1a7732f
Add support for LED intensity (#15)
kdarkhan Dec 5, 2020
c165136
Improve logic for switching off and on of LEDs (#16)
kdarkhan Dec 5, 2020
ab17a1e
Implement animation speed (#17)
kdarkhan Dec 5, 2020
fb5829f
Include logic to send solid colors as foreground to shine and add sam…
thomazmoura Dec 5, 2020
b63980e
Implement reactive lighting effects (#18)
kdarkhan Dec 7, 2020
218e352
Added multiarrow keymap (#19)
packorf Dec 7, 2020
853388d
Add LED documentation (#26)
jmarmstrong1207 Jan 27, 2021
54de886
Implement QMK's IAP default keybind (#29)
jmarmstrong1207 Jan 31, 2021
83d7f9a
Make default config more like Obins stock default (#30)
jmarmstrong1207 Feb 3, 2021
365eb5c
Add new message type for resetting foreground color (#31)
kdarkhan Feb 3, 2021
1637c81
annepro2(bluetooth): add media keys support (#41)
1Conan Jul 15, 2021
f771cb5
Asynchronous, robust serial protocol. (#39)
blaa Jul 15, 2021
8963c3b
Let the LED chip settle a bit before waking it from the bootloader. (…
blaa Jul 25, 2021
5408f57
annepro2: rename KEYMAP to LAYOUT, as required by new version of QMK
bwisn Aug 29, 2021
64b8086
annepro2: update ChibiOS configuration files
bwisn Aug 29, 2021
22504e6
annepro2: fix undefined reference to dprint and timer_read32
bwisn Aug 29, 2021
48069e3
annepro2: update ChibiOS MCU name
bwisn Aug 29, 2021
3ec41ff
update spi driver, fix bad merging with master
bwisn Aug 29, 2021
bc761b5
annepro2: add readme and info.json
bwisn Aug 29, 2021
b276ac6
annepro2: make code compatible with QMK coding conventions
bwisn Aug 29, 2021
83fd7ba
tmk_core: temporary fix to allow HT32 based keyboards to work without…
bwisn Aug 29, 2021
d3c5709
AnnePro2: removed core changes
bwisn Sep 11, 2021
8ad8264
AnnePro2: Leave only default keymaps
bwisn Sep 12, 2021
807582e
annepro2: add licence information
bwisn Sep 15, 2021
0df099b
annepro2: satisfy qmk lint
bwisn Sep 15, 2021
6e08944
annepro2: fix drashna's suggestions
bwisn Sep 15, 2021
5ebfacb
annepro2: fix matrix
bwisn Sep 15, 2021
e68f6a5
annepro2: apply code review suggestions
bwisn Sep 16, 2021
46d861f
annepro2: apply remaining code review suggestions
bwisn Sep 16, 2021
6a32f0e
annepro2: update info.json
bwisn Sep 16, 2021
b697196
annepro2: remove include
bwisn Sep 17, 2021
1fbaa28
annepro2: rename keymap to layout
bwisn Sep 18, 2021
d5b9080
Merge remote-tracking branch 'qmkremote/develop' into bwisn_ap2
bwisn Oct 18, 2021
b4cac43
annepro2: fix typing
bwisn Oct 18, 2021
77ada6d
annepro2: apply suggestions from tzarc's code review
bwisn Oct 18, 2021
41a8091
annepro2: more fixes
bwisn Oct 18, 2021
af30f79
annepro2: apply suggestions from code review
bwisn Oct 19, 2021
6f89eee
annepro2: rename file
bwisn Oct 19, 2021
0e1449c
more fixes
bwisn Nov 1, 2021
72884e6
Apply suggestions from @tzarc code review
bwisn Nov 2, 2021
ae60484
Update keyboards/annepro2/protocol.h
bwisn Nov 2, 2021
d36ed0c
Update keyboards/annepro2/chconf.h
bwisn Nov 2, 2021
f0d102c
apply CR suggestions
bwisn Nov 13, 2021
ff35e18
upgrade readme
bwisn Nov 13, 2021
c0a39be
IAP
bwisn Nov 13, 2021
78bd57f
update IAP comments, defines
bwisn Nov 13, 2021
a2b7d34
led fix
bwisn Nov 13, 2021
7027360
init fix
bwisn Nov 13, 2021
5f559c2
annepro2: GPIO cleanup
bwisn Nov 14, 2021
36c2242
annepro2: ioline
bwisn Nov 14, 2021
be70725
change waiting time
bwisn Nov 15, 2021
3da34f2
Start develop for 2022q2
zvecr Feb 26, 2022
8a23742
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Feb 26, 2022
5360cb1
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Feb 27, 2022
d995cf3
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Feb 27, 2022
0d953a2
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Feb 27, 2022
0815d89
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Feb 27, 2022
4fae7cd
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Feb 27, 2022
d9a6932
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Feb 27, 2022
cb8528c
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Feb 27, 2022
156f056
[Core] Squeeze AVR some more with `-mrelax` and `-mcall-prologues` (#…
KarlK90 Feb 27, 2022
f6bc058
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Feb 27, 2022
4fd2739
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Feb 27, 2022
8f457ad
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Feb 27, 2022
e4a6afa
Rework generate-api CLI command to use .build directory (#16441)
zvecr Feb 27, 2022
48f06ae
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Feb 27, 2022
3c7c9bd
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Feb 27, 2022
36e47cb
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Feb 28, 2022
73135e7
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Feb 28, 2022
5e57d18
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Feb 28, 2022
c70bb75
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Feb 28, 2022
d77b5ad
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Mar 1, 2022
5467bdf
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Mar 1, 2022
7d842c6
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Mar 1, 2022
7f515ee
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Mar 1, 2022
9d7f6d1
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Mar 1, 2022
d75ce48
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Mar 2, 2022
9f95844
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Mar 3, 2022
8a5ad2a
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Mar 3, 2022
b16af15
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Mar 3, 2022
77ea1bd
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Mar 3, 2022
d1bd5a0
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Mar 3, 2022
c6111aa
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Mar 3, 2022
c45ed89
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Mar 4, 2022
9958f9e
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Mar 4, 2022
bcd4f34
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Mar 4, 2022
24f2eff
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Mar 4, 2022
f634fdd
Remove `send_unicode_hex_string()` (#16518)
fauxpark Mar 4, 2022
ace0603
Change data driven "str" type to represent a quoted string literal (#…
fauxpark Mar 4, 2022
386d19b
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Mar 4, 2022
618aaa8
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Mar 4, 2022
7d41639
Map data driven `DESCRIPTION` as string literal (#16523)
fauxpark Mar 5, 2022
967b9e3
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Mar 5, 2022
ab76e6a
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Mar 5, 2022
e2ab505
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Mar 5, 2022
f7512d6
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Mar 5, 2022
621b4b7
Merge remote-tracking branch 'origin/master' into develop
qmk-bot Mar 6, 2022
0cc83e4
Merge pull request #1 from qmk/master
bwisn Mar 6, 2022
240745d
update bootloader
bwisn Mar 6, 2022
9c76065
Merge pull request #2 from qmk/develop
bwisn Mar 6, 2022
1585912
Revert "Merge pull request #2 from qmk/develop"
bwisn Mar 6, 2022
75967b8
Revert "update bootloader"
bwisn Mar 6, 2022
2057887
fix rules.mk
bwisn Mar 6, 2022
259d799
change PROGRAM_CMD
bwisn Mar 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
202 changes: 202 additions & 0 deletions keyboards/annepro2/annepro2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
/* Copyright 2021 OpenAnnePro community
*
* 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/>.
*/

#include "hal.h"
#include "annepro2.h"
#include "annepro2_ble.h"
#include "spi_master.h"
#include "ap2_led.h"
#include "protocol.h"

#define RAM_MAGIC_LOCATION 0x20001ffc
#define IAP_MAGIC_VALUE 0x0000fab2

static const SerialConfig ledUartInitConfig = {
.speed = 115200,
};

#ifndef LED_UART_BAUD_RATE
# define LED_UART_BAUD_RATE 115200
#endif // LED_UART_BAUD_RATE

static const SerialConfig ledUartRuntimeConfig = {
.speed = LED_UART_BAUD_RATE,
};

static const SerialConfig bleUartConfig = {
.speed = 115200,
};

static uint8_t ledMcuWakeup[11] = {0x7b, 0x10, 0x43, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x02, 0x01, 0x02};

ble_capslock_t BLECapsLock = {._dummy = {0}, .caps_lock = false};

void bootloader_jump(void) {
// Send msg to shine to boot into IAP
annepro2SetIAP();

// wait for shine to boot into IAP
wait_ms(15);

// Load ble into IAP
annepro2_ble_bootload();
wait_ms(15);

// Magic key to set keyboard to IAP
// It’s from reversing original boot loader
// If value is that it stays in boot loader aka IAP
*((uint32_t *)RAM_MAGIC_LOCATION) = IAP_MAGIC_VALUE;

// Load the main MCU into IAP
__disable_irq();
NVIC_SystemReset();
}

void keyboard_pre_init_kb(void) {
// Start LED UART
sdStart(&SD0, &ledUartInitConfig);
/* Let the LED chip settle a bit before switching the mode.
* That helped at least one person. */
wait_ms(15);
sdWrite(&SD0, ledMcuWakeup, sizeof(ledMcuWakeup));

// wait to receive response from wakeup
wait_ms(15);

protoInit(&proto, ledCommandCallback);

// loop to clear out receive buffer from shine wakeup
while (!sdGetWouldBlock(&SD0)) sdGet(&SD0);

sdStart(&SD0, &ledUartRuntimeConfig);
keyboard_pre_init_user();
}
bwisn marked this conversation as resolved.
Show resolved Hide resolved

void keyboard_post_init_kb(void) {
// Start BLE UART
sdStart(&SD1, &bleUartConfig);
annepro2_ble_startup();

// Give the send uart thread some time to
// send out the queue before we read back
wait_ms(100);

// loop to clear out receive buffer from ble wakeup
while (!sdGetWouldBlock(&SD1)) sdGet(&SD1);

annepro2LedGetStatus();

keyboard_post_init_user();
}

void matrix_scan_kb() {
// if there's stuff on the ble serial buffer
// read it into the capslock struct
while (!sdGetWouldBlock(&SD1)) {
sdReadTimeout(&SD1, (uint8_t *)&BLECapsLock, sizeof(ble_capslock_t), 10);
}

/* While there's data from LED keyboard sent - read it. */
while (!sdGetWouldBlock(&SD0)) {
uint8_t byte = sdGet(&SD0);
protoConsume(&proto, byte);
}

matrix_scan_user();
}

bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
if (annepro2LedStatus.matrixEnabled && annepro2LedStatus.isReactive) {
annepro2LedForwardKeypress(record->event.key.row, record->event.key.col);
}

const annepro2Led_t blue = {
.p.blue = 0xff,
.p.red = 0x00,
.p.green = 0x00,
.p.alpha = 0xff,
};

switch (keycode) {
case KC_AP2_BT1:
annepro2_ble_broadcast(0);
/* FIXME: This hardcodes col/row position */
annepro2LedBlink(0, 1, blue, 8, 50);
return false;

case KC_AP2_BT2:
annepro2_ble_broadcast(1);
annepro2LedBlink(0, 2, blue, 8, 50);
return false;

case KC_AP2_BT3:
annepro2_ble_broadcast(2);
annepro2LedBlink(0, 3, blue, 8, 50);
return false;

case KC_AP2_BT4:
annepro2_ble_broadcast(3);
annepro2LedBlink(0, 4, blue, 8, 50);
return false;

case KC_AP2_USB:
annepro2_ble_disconnect();
return false;

case KC_AP2_BT_UNPAIR:
annepro2_ble_unpair();
return false;

case KC_AP_LED_OFF:
annepro2LedDisable();
break;

case KC_AP_LED_ON:
if (annepro2LedStatus.matrixEnabled) {
annepro2LedNextProfile();
} else {
annepro2LedEnable();
}
annepro2LedResetForegroundColor();
break;

case KC_AP_LED_NEXT_PROFILE:
annepro2LedNextProfile();
annepro2LedResetForegroundColor();
break;

case KC_AP_LED_PREV_PROFILE:
annepro2LedPrevProfile();
annepro2LedResetForegroundColor();
break;

case KC_AP_LED_NEXT_INTENSITY:
annepro2LedNextIntensity();
annepro2LedResetForegroundColor();
return false;

case KC_AP_LED_SPEED:
annepro2LedNextAnimationSpeed();
annepro2LedResetForegroundColor();
return false;

default:
break;
}
}
return process_record_user(keycode, record);
}
65 changes: 65 additions & 0 deletions keyboards/annepro2/annepro2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright (c) 2018 Yaotian Feng
*
* 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/>.
*/

#pragma once
#include "quantum.h"
#include <stdint.h>
#include "ap2_led.h"

typedef struct __attribute__((__packed__)) {
uint8_t _dummy[10];
bool caps_lock;
} ble_capslock_t;
extern ble_capslock_t BLECapsLock;

// Matrix keymap
// clang-format off
#define LAYOUT( \
K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \
K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, \
K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, \
K40, K42, K43, K46, K49, K4A, K4B, K4C \
) { \
/* COL1 COL2 COL3 COL4 COL5 COL6 COL7 COL8 COL9 COL10 COL11 COL12 COL13 COL14*/ \
/* ROW1 */ { K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D }, \
/* ROW2 */ { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D }, \
/* ROW3 */ { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, KC_NO}, \
/* ROW4 */ { K30, KC_NO, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, KC_NO}, \
/* ROW5 */ { K40, KC_NO, K42, K43, KC_NO, KC_NO, K46, KC_NO, KC_NO, K49, K4A, K4B, K4C, KC_NO}, \
}
// clang-format on

enum AP2KeyCodes {
KC_AP2_BT1 = SAFE_RANGE,
KC_AP2_BT2,
KC_AP2_BT3,
KC_AP2_BT4,
KC_AP2_BT_UNPAIR,
KC_AP2_USB,
KC_AP_LED_ON,
KC_AP_LED_OFF,
KC_AP_LED_NEXT_PROFILE,
KC_AP_LED_PREV_PROFILE,
KC_AP_LED_NEXT_INTENSITY,
KC_AP_LED_SPEED,
AP2_SAFE_RANGE,
};
bwisn marked this conversation as resolved.
Show resolved Hide resolved

#undef SAFE_RANGE
#define SAFE_RANGE AP2_SAFE_RANGE

Loading