From 43f25cb105b90c8f2f708edf61dcf1bc966d06c4 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Wed, 8 May 2019 20:19:51 -0700 Subject: [PATCH] Initial support for a port of Kaleidoscope to a new Atreus variant --- .../Atreus2/.kaleidoscope-builder.conf | 2 + .../Devices/Technomancy/Atreus2/Atreus2.ino | 100 ++++++++++++++++++ examples/Devices/Technomancy/Atreus2/Makefile | 56 ++++++++++ ...aleidoscope-Hardware-Technomancy-Atreus2.h | 23 ++++ .../hardware/technomancy/Atreus2.cpp | 38 +++++++ .../hardware/technomancy/Atreus2.h | 89 ++++++++++++++++ 6 files changed, 308 insertions(+) create mode 100644 examples/Devices/Technomancy/Atreus2/.kaleidoscope-builder.conf create mode 100644 examples/Devices/Technomancy/Atreus2/Atreus2.ino create mode 100644 examples/Devices/Technomancy/Atreus2/Makefile create mode 100644 src/Kaleidoscope-Hardware-Technomancy-Atreus2.h create mode 100644 src/kaleidoscope/hardware/technomancy/Atreus2.cpp create mode 100644 src/kaleidoscope/hardware/technomancy/Atreus2.h diff --git a/examples/Devices/Technomancy/Atreus2/.kaleidoscope-builder.conf b/examples/Devices/Technomancy/Atreus2/.kaleidoscope-builder.conf new file mode 100644 index 00000000..b0bcc80e --- /dev/null +++ b/examples/Devices/Technomancy/Atreus2/.kaleidoscope-builder.conf @@ -0,0 +1,2 @@ +DEFAULT_SKETCH="Atreus2" +BOARD="atreus2" diff --git a/examples/Devices/Technomancy/Atreus2/Atreus2.ino b/examples/Devices/Technomancy/Atreus2/Atreus2.ino new file mode 100644 index 00000000..894b9a4b --- /dev/null +++ b/examples/Devices/Technomancy/Atreus2/Atreus2.ino @@ -0,0 +1,100 @@ +/* -*- mode: c++ -*- + * Atreus -- A very basic Kaleidoscope example for the Atreus + * Copyright (C) 2018 Keyboard.io, Inc + * + * 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, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "Kaleidoscope.h" +#include "Kaleidoscope-Macros.h" + +#define MO(n) ShiftToLayer(n) +#define TG(n) LockLayer(n) + +enum { + RESET +}; + +#define Key_Exclamation LSHIFT(Key_1) +#define Key_At LSHIFT(Key_2) +#define Key_Hash LSHIFT(Key_3) +#define Key_Dollar LSHIFT(Key_4) +#define Key_And LSHIFT(Key_7) +#define Key_Star LSHIFT(Key_8) +#define Key_Plus LSHIFT(Key_Equals) + +/* *INDENT-OFF* */ +KEYMAPS( + [0] = KEYMAP_STACKED + ( + Key_Q ,Key_W ,Key_E ,Key_R ,Key_T + ,Key_A ,Key_S ,Key_D ,Key_F ,Key_G + ,Key_Z ,Key_X ,Key_C ,Key_V ,Key_B ,XXX + ,Key_Esc ,Key_Tab ,Key_LeftGui ,Key_LeftShift ,Key_Backspace ,Key_LeftControl + + ,Key_Y ,Key_U ,Key_I ,Key_O ,Key_P + ,Key_H ,Key_J ,Key_K ,Key_L ,Key_Semicolon + ,XXX ,Key_N ,Key_M ,Key_Comma ,Key_Period ,Key_Slash + ,Key_LeftAlt ,Key_Space ,MO(1) ,Key_Minus ,Key_Quote ,Key_Enter + ), + + [1] = KEYMAP_STACKED + ( + Key_Exclamation ,Key_At ,Key_UpArrow ,Key_LeftCurlyBracket ,Key_RightCurlyBracket + ,Key_Hash ,Key_LeftArrow ,Key_DownArrow ,Key_RightArrow ,Key_Dollar + ,Key_LeftBracket ,Key_RightBracket ,Key_LeftParen ,Key_RightParen ,Key_And ,XXX + ,TG(2) ,Key_Insert ,Key_LeftGui ,Key_LeftShift ,Key_Backspace ,Key_LeftControl + + ,Key_PageUp ,Key_7 ,Key_8 ,Key_9 ,Key_Star + ,Key_PageDown ,Key_4 ,Key_5 ,Key_6 ,Key_Plus + ,XXX ,Key_Backtick ,Key_1 ,Key_2 ,Key_3 ,Key_Backslash + ,Key_LeftAlt ,Key_Space ,MO(1) ,Key_Period ,Key_0 ,Key_Equals + ), + + [2] = KEYMAP_STACKED + ( + Key_Insert ,Key_Home ,Key_UpArrow ,Key_End ,Key_PageUp + ,Key_Delete ,Key_LeftArrow ,Key_DownArrow ,Key_RightArrow ,Key_PageDown + ,XXX ,Consumer_VolumeIncrement ,XXX ,XXX ,M(RESET) ,XXX + ,XXX ,Consumer_VolumeDecrement ,___ ,___ ,___ ,___ + + ,Key_UpArrow ,Key_F7 ,Key_F8 ,Key_F9 ,Key_F10 + ,Key_DownArrow ,Key_F4 ,Key_F5 ,Key_F6 ,Key_F11 + ,XXX ,XXX ,Key_F1 ,Key_F2 ,Key_F3 ,Key_F12 + ,___ ,___ ,___ ,Key_PrintScreen ,Key_ScrollLock ,Consumer_PlaySlashPause + ) +) +/* *INDENT-ON* */ + +KALEIDOSCOPE_INIT_PLUGINS(Macros); + +const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) { + switch (macroIndex) { + case RESET: + break; + default: + break; + } + + return MACRO_NONE; +} + +void setup() { + Kaleidoscope.setup(); +} + +void loop() { + Kaleidoscope.loop(); +} diff --git a/examples/Devices/Technomancy/Atreus2/Makefile b/examples/Devices/Technomancy/Atreus2/Makefile new file mode 100644 index 00000000..79f017a0 --- /dev/null +++ b/examples/Devices/Technomancy/Atreus2/Makefile @@ -0,0 +1,56 @@ +# This stub makefile for a Kaleidoscope example pulls in all the targets +# required to build the example + +UNAME_S := $(shell uname -s) + +ifeq ($(UNAME_S),Darwin) +SKETCHBOOK_DIR ?= $(HOME)/Documents/Arduino +PACKAGE_DIR ?= $(HOME)/Library/Arduino15 +else +SKETCHBOOK_DIR ?= $(HOME)/Arduino +PACKAGE_DIR ?= $(HOME)/.arduino15 +endif + + + +ARDUINO_INSTALLED_ENV=$(shell ls -dt $(PACKAGE_DIR)/packages/keyboardio/hardware/avr 2>/dev/null |head -n 1) +MANUALLY_INSTALLED_ENV=$(shell ls -dt $(SKETCHBOOK_DIR)/hardware/keyboardio/avr 2>/dev/null |head -n 1) + + + +ifneq ("$(wildcard $(ARDUINO_INSTALLED_ENV)/boards.txt)","") + +ifneq ("$(wildcard $(MANUALLY_INSTALLED_ENV)/boards.txt)","") + +$(info ***************************************************************************) +$(info It appears that you have installed two copies of Kaleidoscope. One copy was) +$(info installed using Arduino's "Board Manager", while the other was installed by) +$(info hand, probably using "git".) +$(info ) +$(info This will likely cause some trouble as you try to build keyboard firmware) +$(info using Kaleidoscope. You may want to remove either: ) +$(info ) +$(info $(PACKAGE_DIR)/packages/keyboardio/ which was installed using Arduino) +$(info ) +$(info or) +$(info ) +$(info $(SKETCHBOOK_DIR)/hardware/keyboardio/ which was installed by hand.) +$(info ) +$(info ***************************************************************************) +$(info ) + +endif + +BOARD_HARDWARE_PATH = $(ARDUINO_INSTALLED_ENV) +KALEIDOSCOPE_PLUGIN_MAKEFILE_DIR ?= build-tools/makefiles/ +KALEIDOSCOPE_BUILDER_DIR ?= $(ARDUINO_INSTALLED_ENV)/libraries/Kaleidoscope/bin/ + + + +endif + + +BOARD_HARDWARE_PATH ?= $(SKETCHBOOK_DIR)/hardware +KALEIDOSCOPE_PLUGIN_MAKEFILE_DIR ?= keyboardio/avr/build-tools/makefiles/ + +include $(BOARD_HARDWARE_PATH)/$(KALEIDOSCOPE_PLUGIN_MAKEFILE_DIR)/rules.mk diff --git a/src/Kaleidoscope-Hardware-Technomancy-Atreus2.h b/src/Kaleidoscope-Hardware-Technomancy-Atreus2.h new file mode 100644 index 00000000..a9c29eb1 --- /dev/null +++ b/src/Kaleidoscope-Hardware-Technomancy-Atreus2.h @@ -0,0 +1,23 @@ +/* -*- mode: c++ -*- + * Kaleidoscope-Hardware-Technomancy-Atreus2 -- Atreus2 hardware support for Kaleidoscope + * Copyright (C) 2019 Keyboard.io, Inc + * + * 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 3 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 . + */ + +#pragma once + +#define KALEIDOSCOPE_WITH_ATMEGA_KEYBOARD 1 + +#include "kaleidoscope/hardware/technomancy/Atreus2.h" diff --git a/src/kaleidoscope/hardware/technomancy/Atreus2.cpp b/src/kaleidoscope/hardware/technomancy/Atreus2.cpp new file mode 100644 index 00000000..f7da0cf1 --- /dev/null +++ b/src/kaleidoscope/hardware/technomancy/Atreus2.cpp @@ -0,0 +1,38 @@ +/* -*- mode: c++ -*- + * Technomancy Atreus2 hardware support for Kaleidoscope + * Copyright (C) 2019 Keyboard.io, Inc + * + * 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 3 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 . + */ + +#ifdef ARDUINO_AVR_ATREUS2 + +#include +#include + +namespace kaleidoscope { +namespace hardware { +namespace technomancy { + +ATMEGA_KEYBOARD_DATA(Atreus2); +constexpr int8_t Atreus2::led_count; + +} +} +} + +HARDWARE_IMPLEMENTATION KeyboardHardware; +kaleidoscope::hardware::technomancy::Atreus2 &Atreus2 = KeyboardHardware; + +#endif diff --git a/src/kaleidoscope/hardware/technomancy/Atreus2.h b/src/kaleidoscope/hardware/technomancy/Atreus2.h new file mode 100644 index 00000000..f89b6904 --- /dev/null +++ b/src/kaleidoscope/hardware/technomancy/Atreus2.h @@ -0,0 +1,89 @@ +/* -*- mode: c++ -*- + * Technomancy Atreus2 hardware support for Kaleidoscope + * Copyright (C) 2019 Keyboard.io, Inc + * + * 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 3 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 . + */ + +#pragma once + +#ifdef ARDUINO_AVR_ATREUS2 + +#include +#define HARDWARE_IMPLEMENTATION kaleidoscope::hardware::technomancy::Atreus2 +#include "Kaleidoscope-HIDAdaptor-KeyboardioHID.h" + +#include "kaleidoscope/macro_helpers.h" + +#include "kaleidoscope/hardware/ATMegaKeyboard.h" + +namespace kaleidoscope { +namespace hardware { +namespace technomancy { +class Atreus2: public kaleidoscope::hardware::ATMegaKeyboard { + friend class ATMegaKeyboard; + public: + Atreus2(void) {} + + ATMEGA_KEYBOARD_CONFIG( + ROW_PIN_LIST({PIN_F6, PIN_F5, PIN_F4, PIN_F1}), + COL_PIN_LIST({PIN_F7, PIN_E2, PIN_C7, PIN_C6, PIN_B6, PIN_B5, PIN_D7, PIN_D6, PIN_D4, PIN_D5, PIN_D3, PIN_D2}) + + ) + static constexpr int8_t led_count = 0; + + void resetDevice(); + + protected: +}; + +#define KEYMAP( \ + R0C0, R0C1, R0C2, R0C3, R0C4, R0C7, R0C8, R0C9, R0C10, R0C11, \ + R1C0, R1C1, R1C2, R1C3, R1C4, R1C7, R1C8, R1C9, R1C10, R1C11, \ + R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, R2C7, R2C8, R2C9, R2C10, R2C11, \ + R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11 \ + ) \ + { \ + { R0C0, R0C1, R0C2, R0C3, R0C4, XXX, XXX, R0C7, R0C8, R0C9, R0C10, R0C11 }, \ + { R1C0, R1C1, R1C2, R1C3, R1C4, XXX, XXX, R1C7, R1C8, R1C9, R1C10, R1C11 }, \ + { R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, R2C7, R2C8, R2C9, R2C10, R2C11 }, \ + { R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11 } \ + } + +#define KEYMAP_STACKED( \ + R0C0, R0C1, R0C2, R0C3, R0C4, \ + R1C0, R1C1, R1C2, R1C3, R1C4, \ + R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, \ + R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, \ + \ + R0C7, R0C8, R0C9, R0C10, R0C11, \ + R1C7, R1C8, R1C9, R1C10, R1C11, \ + R2C6, R2C7, R2C8, R2C9, R2C10, R2C11, \ + R3C6, R3C7, R3C8, R3C9, R3C10, R3C11 \ + ) \ + { \ + { R0C0, R0C1, R0C2, R0C3, R0C4, XXX, XXX, R0C7, R0C8, R0C9, R0C10, R0C11 }, \ + { R1C0, R1C1, R1C2, R1C3, R1C4, XXX, XXX, R1C7, R1C8, R1C9, R1C10, R1C11 }, \ + { R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, R2C7, R2C8, R2C9, R2C10, R2C11 }, \ + { R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11 } \ + } +} +} +} + +#include "kaleidoscope/hardware/key_indexes.h" + +extern kaleidoscope::hardware::technomancy::Atreus2 &Atreus2; + +#endif