commit fe85e19e1db9db074c26cfcdbd0ff48f703207c1
parent c705b877642ebde1532eb84014eb05458d3593c5
Author: René Wagner <rwa@clttr.info>
Date: Sat, 20 Jan 2024 10:09:32 +0100
Merge branch 'master' of https://source.mnt.re/reform/reform
Diffstat:
8 files changed, 87 insertions(+), 9 deletions(-)
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
@@ -54,3 +54,8 @@ build:
grep --quiet "# define KBD_FW_VERSION \"$(git describe --always --tags --abbrev=0 | tr -d -)\"" reform2-keyboard-fw/constants.h
grep --quiet "# define FW_STRING3 \"$(git describe --always --tags --abbrev=0 | tr -d -)\"" reform2-lpc-fw/src/boards/reform2/board_reform2.c
fi
+ # assure that the latest git tag is reflected in top CHANGELOG.md
+ if git describe >/dev/null 2>&1; then
+ head -1 reform2-keyboard-fw/CHANGELOG.md | grep --quiet "^### $(git describe --always --tags --abbrev=0)"
+ head -1 reform2-lpc-fw/CHANGELOG.md | grep --quiet "^### $(git describe --always --tags --abbrev=0)"
+ fi
diff --git a/reform2-keyboard-fw/CHANGELOG.md b/reform2-keyboard-fw/CHANGELOG.md
@@ -0,0 +1,11 @@
+### 2023-11-24
+
+ - allow usb hid commands to draw on all 128 display columns
+ - v3: add home/end/pgup/pgdn on hyper layer
+ - fade-in & fade-out animations for keyboard backlight
+ - add a ~30s timeout to the MNT Reform logo on the OLED to prevent burn-in
+ - mention on the OLED that firmware update mode is active
+
+### 2023-07-03
+
+ - first tagged version
diff --git a/reform2-keyboard-fw/README.md b/reform2-keyboard-fw/README.md
@@ -62,5 +62,7 @@ standalone keyboard, define `KBD_MODE_STANDALONE` using
make REFORM_KBD_OPTIONS="-DKBD_VARIANT_3_US -DKBD_MODE_STANDALONE"
make REFORM_KBD_OPTIONS="-DKBD_VARIANT_3 -DKBD_MODE_STANDALONE"
+For keyboard 3 there is also an option to swap Ctrl- and Hyper-Keys: `KBD_SWP_CTRL`.
+
To flash, put your keyboard into [flashing mode](https://mntre.com/reform2/handbook/parts.html#keyboard-firmware) and run:
`sudo ./flash.sh`
diff --git a/reform2-keyboard-fw/flash.sh b/reform2-keyboard-fw/flash.sh
@@ -12,6 +12,17 @@ if [ "$(id -u)" -ne 0 ]; then
exit 1
fi
+get_property() {
+ path="$1"
+ property="$2"
+ if [ "$(udevadm --version)" -lt 250 ]; then
+ # no udevadm --property before version 250
+ udevadm info --query=property "$path" | sed -ne "s/^$property=//p"
+ else
+ udevadm info --query=property --property="$property" --value "$path"
+ fi
+}
+
find_usb_device() {
result=
for p in /sys/bus/usb/devices/*; do
@@ -19,7 +30,7 @@ find_usb_device() {
[ "$(cat "$p/idVendor")" = "$1" ] || continue
[ -e "$p/idProduct" ] || continue
[ "$(cat "$p/idProduct")" = "$2" ] || continue
- [ "$(udevadm info --query=property --property=ID_MODEL --value "$p")" = "$3" ] || continue
+ [ "$(get_property "$p" "ID_MODEL")" = "$3" ] || continue
if [ -n "$result" ]; then
echo "found more than one device matching $1 $2 $3" >&2
exit 1
@@ -46,8 +57,8 @@ path_keyboard=$(find_usb_device 03eb 2042 Reform_Keyboard)
busnum_keyboard=
devnum_keyboard=
if [ -n "$path_keyboard" ] && [ -e "$path_keyboard" ]; then
- busnum_keyboard="$(udevadm info --query=property --property=BUSNUM --value "$path_keyboard")"
- devnum_keyboard="$(udevadm info --query=property --property=DEVNUM --value "$path_keyboard")"
+ busnum_keyboard="$(get_property "$path_keyboard" "BUSNUM")"
+ devnum_keyboard="$(get_property "$path_keyboard" "DEVNUM")"
echo " 1. Find out your keyboard firmware version in the 'System Status' by pressing" >&2
echo " the circle key followed by the S key. The keyboard firmware version is on" >&2
echo " on the last line in a date-based format YYYYMMDD. Then either:"
@@ -86,8 +97,8 @@ if [ -z "$path" ] || [ ! -e "$path" ]; then
exit 1
fi
-busnum="$(udevadm info --query=property --property=BUSNUM --value "$path")"
-devnum="$(udevadm info --query=property --property=DEVNUM --value "$path")"
+busnum="$(get_property "$path" "BUSNUM")"
+devnum="$(get_property "$path" "DEVNUM")"
# do some extra checks if we saw the usb device as a keyboard before
if [ -n "$path_keyboard" ] && [ -e "$path_keyboard" ]; then
diff --git a/reform2-keyboard-fw/keyboard.c b/reform2-keyboard-fw/keyboard.c
@@ -141,6 +141,10 @@ void get_media_keys(uint8_t keycode, USB_MediaReport_Data_t* mcr) {
#define MAX_SCANCODES 6
static uint8_t pressed_scancodes[MAX_SCANCODES] = {0,0,0,0,0,0};
+// number of cycles a key has to remain pressed to register a keypress
+// is at least 1 but at most 8
+#define DEBOUNCE_BITS 1
+
// usb_report_mode: if you pass 0, you can leave KeyboardReport NULL
int process_keyboard(uint8_t* resulting_scancodes) {
// how many keys are pressed this round
@@ -149,6 +153,14 @@ int process_keyboard(uint8_t* resulting_scancodes) {
int old_keymods = active_keymods;
bool left_ctrl_pressed = 1;
bool left_shift_pressed = 1;
+
+ // create a bitmask with the lowest DEBOUNCE_BITS number of bits set to 1
+ // 1 -> 0b00000001
+ // 2 -> 0b00000011
+ // ...
+ // 8 -> 0b11111111
+ uint8_t debounce_bitmask = (1<<DEBOUNCE_BITS)-1;
+
// pull ROWs low one after the other
for (int y = 0; y < KBD_ROWS; y++) {
switch (y) {
@@ -196,7 +208,9 @@ int process_keyboard(uint8_t* resulting_scancodes) {
// if unclear state, we need to keep the last state of the key
if (matrix_debounce[loc] == 0x00) {
matrix_state[loc] = 0;
- } else if (matrix_debounce[loc] == 0x01) {
+ } else if (matrix_debounce[loc] == debounce_bitmask) {
+ // the key has been pressed for the last DEBOUNCE_BITS number of
+ // cycles -> register key press
matrix_state[loc] = 1;
}
debounced_pressed = matrix_state[loc];
diff --git a/reform2-keyboard-fw/matrix_3.h b/reform2-keyboard-fw/matrix_3.h
@@ -6,9 +6,17 @@
#include "keyboard.h"
+#ifdef KBD_SWP_CTRL
+ #define R4_C1 HID_KEYBOARD_SC_EXECUTE
+ #define R6_C1 HID_KEYBOARD_SC_LEFT_CONTROL
+#else
+ #define R4_C1 HID_KEYBOARD_SC_LEFT_CONTROL
+ #define R6_C1 HID_KEYBOARD_SC_EXECUTE
+#endif
+
// Fourth row
#define MATRIX3_DEFAULT_ROW_4 \
- HID_KEYBOARD_SC_LEFT_CONTROL,\
+ R4_C1,\
KEY_A,\
KEY_S,\
KEY_D,\
@@ -25,7 +33,7 @@
// Sixth row
#define MATRIX3_DEFAULT_ROW_6 \
- HID_KEYBOARD_SC_EXECUTE,\
+ R6_C1,\
HID_KEYBOARD_SC_LEFT_GUI,\
HID_KEYBOARD_SC_LEFT_ALT,\
KEY_SPACE,\
@@ -117,7 +125,7 @@ uint8_t matrix_fn[KBD_MATRIX_SZ] = {
HID_KEYBOARD_SC_PAGE_UP,
HID_KEYBOARD_SC_RIGHT_SHIFT,
- HID_KEYBOARD_SC_EXECUTE,
+ R6_C1,
HID_KEYBOARD_SC_LEFT_GUI,
HID_KEYBOARD_SC_LEFT_ALT,
KEY_SPACE,
diff --git a/reform2-lpc-fw/CHANGELOG.md b/reform2-lpc-fw/CHANGELOG.md
@@ -0,0 +1,7 @@
+### 2023-11-24
+
+ - disable brownout reset during sleep to keep battery status
+
+### 2023-07-03
+
+ - first tagged version
diff --git a/reform2-lpc-fw/src/boards/reform2/board_reform2.c b/reform2-lpc-fw/src/boards/reform2/board_reform2.c
@@ -782,6 +782,21 @@ void handle_commands() {
uartSend((uint8_t*)uartBuffer, strlen(uartBuffer));
}
+ else if (remote_cmd == 'f') {
+ // print the firmware string
+ if (cmd_number == 1) {
+ sprintf(uartBuffer,FW_STRING1"\r\n");
+ } else if (cmd_number == 2) {
+ sprintf(uartBuffer,FW_STRING2"\r\n");
+ } else if (cmd_number == 3) {
+ sprintf(uartBuffer,FW_STRING3"\r\n");
+ } else {
+ // if cmd_number is 0, print all of them concatenated as it is
+ // done for "s"
+ sprintf(uartBuffer,FW_REV"\r\n");
+ }
+ uartSend((uint8_t*)uartBuffer, strlen(uartBuffer));
+ }
else if (remote_cmd == 'u') {
// turn reporting to i.MX on or off
if (cmd_number>0) {
@@ -854,6 +869,11 @@ void handle_commands() {
som_is_powered);
uartSend((uint8_t*)uartBuffer, strlen(uartBuffer));
}
+ else if (remote_cmd == 'U') {
+ // get uptime
+ sprintf(uartBuffer, "%d\r\n", cycles_uptime);
+ uartSend((uint8_t*)uartBuffer, strlen(uartBuffer));
+ }
else if (remote_cmd == 'S') {
// get charger system cycles in current state
sprintf(uartBuffer, "%d\r\n", cycles_in_state);