first commit, skeleton code, not sure if working

This commit is contained in:
Muhammad Rizqi Agung Prabowo 2019-08-24 05:27:56 +07:00
parent 3cb28bbe42
commit 0fdc62b04a
8 changed files with 495 additions and 0 deletions

View File

@ -0,0 +1,33 @@
#ifndef CONFIG_H
#define CONFIG_H
#include "config_common.h"
#define VENDOR_ID 0xFEED
#define PRODUCT_ID 0xDA19
#define MANUFACTURER WorthlessOwl
#define PRODUCT Owlet60
#define DESCRIPTION TGR Alice inspired 65 or 60 percent keyboard
#define MATRIX_ROWS 9
#define MATRIX_COLS 8
#define MATRIX_ROW_PINS {B5, F4, F5, F6, F7, B1, B3, B2, B6}
#define MATRIX_COL_SELECT_PINS {D7, B4, E6}
#define MATRIX_COL_DATA_PIN {C6}
#define BACKLIGHT_PIN D3
#define DIODE_DIRECTION COL2ROW
#define BACKLIGHT_LEVELS 5
#define DEBOUNCE 5
/* disable debug print */
#define NO_DEBUG
/* disable print */
#define NO_PRINT
#endif

View File

@ -0,0 +1,13 @@
#include QMK_KEYBOARD_H
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
// Base Layer
LAYOUT_owlet60_full_bsp( \
k50, KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_PGUP, \
k51, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGDOWN, \
k52, KC_CAPS,KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN,KC_QUOT, KC_ENT, KC_HOME, \
KC_LSFT,KC_Z, KC_X, KC_C, KC_V, KC_B, KC_B, KC_N, KC_N, KC_COMM,KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_END, \
KC_LCTL, KC_LALT, KC_SPC, KC_LGUI,KC_SPC, KC_RALT, KC_LEFT, KC_DOWN, KC_RIGHT),
}

View File

@ -0,0 +1,330 @@
/*
Copyright 2012 Jun Wako <wakojun@gmail.com>
Copyright 2017 Cole Markham <cole@ccmcomputing.net>
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/>.
*/
/*
* scan matrix
*/
#include <stdint.h>
#include <stdbool.h>
#if defined(__AVR__)
#include <avr/io.h>
#endif
#include "owlet60.h"
#include "wait.h"
#include "print.h"
#include "debug.h"
#include "util.h"
#include "matrix.h"
#include "config.h"
#include "timer.h"
#ifndef DEBOUNCE
# define DEBOUNCE 5
#endif
#if (DEBOUNCE > 0)
static uint16_t debouncing_time;
static bool debouncing = false;
#endif
#if (MATRIX_COLS <= 8)
# define print_matrix_header() print("\nr/c 01234567\n")
# define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row))
# define matrix_bitpop(i) bitpop(matrix[i])
# define ROW_SHIFTER ((uint8_t)1)
#elif (MATRIX_COLS <= 16)
# define print_matrix_header() print("\nr/c 0123456789ABCDEF\n")
# define print_matrix_row(row) print_bin_reverse16(matrix_get_row(row))
# define matrix_bitpop(i) bitpop16(matrix[i])
# define ROW_SHIFTER ((uint16_t)1)
#elif (MATRIX_COLS <= 32)
# define print_matrix_header() print("\nr/c 0123456789ABCDEF0123456789ABCDEF\n")
# define print_matrix_row(row) print_bin_reverse32(matrix_get_row(row))
# define matrix_bitpop(i) bitpop32(matrix[i])
# define ROW_SHIFTER ((uint32_t)1)
#endif
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
static const uint8_t col_select_pins[3] = MATRIX_COL_SELECT_PINS;
static const uint8_t dat_pin = MATRIX_COL_DATA_PIN;
/* matrix state(1:on, 0:off) */
static matrix_row_t matrix[MATRIX_ROWS]; //raw values
static matrix_row_t matrix_debouncing[MATRIX_ROWS]; //debounced values
__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) {
}
inline
uint8_t matrix_rows(void)
{
return MATRIX_ROWS;
}
inline
uint8_t matrix_cols(void)
{
return MATRIX_COLS;
}
//Deprecated.
bool matrix_is_modified(void)
{
if (debounce_active()) return false;
return true;
}
inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
return (matrix[row] & ((matrix_row_t)1<<col));
}
inline
matrix_row_t matrix_get_row(uint8_t row)
{
// Matrix mask lets you disable switches in the returned matrix data. For example, if you have a
// switch blocker installed and the switch is always pressed.
#ifdef MATRIX_MASKED
return matrix[row] & matrix_mask[row];
#else
return matrix[row];
#endif
}
void matrix_print(void)
{
print_matrix_header();
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
phex(row); print(": ");
print_matrix_row(row);
print("\n");
}
}
uint8_t matrix_key_count(void)
{
uint8_t count = 0;
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
count += matrix_bitpop(i);
}
return count;
}
// uses standard row code
static void select_row(uint8_t row)
{
setPinOutput(row_pins[row]);
writePinLow(row_pins[row]);
}
static void unselect_row(uint8_t row)
{
setPinInputHigh(row_pins[row]);
}
static void unselect_rows(void)
{
for(uint8_t x = 0; x < MATRIX_ROWS; x++) {
setPinInputHigh(row_pins[x]);
}
}
static void init_pins(void) { // still need some fixing, this might not work
unselect_rows(); // with the loop
/*
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
setPinInputHigh(col_pins[x]);
}
*/
setPinInputHigh(dat_pin);
}
static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
{
// Store last value of row prior to reading
matrix_row_t last_row_value = current_matrix[current_row];
// Clear data in matrix row
current_matrix[current_row] = 0;
// Select row and wait for row selecton to stabilize
select_row(current_row);
wait_us(30);
// For each col...
for(uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
// Select the col pin to read (active low)
uint8_t pin_state = readPin(col_pins[col_index]);
// Populate the matrix row with the state of the col pin
current_matrix[current_row] |= pin_state ? 0 : (ROW_SHIFTER << col_index);
}
// Unselect row
unselect_row(current_row);
return (last_row_value != current_matrix[current_row]);
}
// modified for per col read matrix scan
uint8_t matrix_scan(void)
{
bool changed = false;
for(uint8_t colnum = 0; colnum < MATRIX_COLS; colnum++) {
select_col(colnum);
for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) {
changed |= read_cols_on_row(raw_matrix, current_row);
}
}
debounce(raw_matrix, matrix, MATRIX_ROWS, changed);
matrix_scan_quantum();
return (uint8_t)changed;
}
/*
uint8_t matrix_scan(void)
{
bool changed = false;
#if (DIODE_DIRECTION == COL2ROW)
// Set row, read cols
for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) {
changed |= read_cols_on_row(raw_matrix, current_row);
}
#endif
debounce(raw_matrix, matrix, MATRIX_ROWS, changed);
matrix_scan_quantum();
return (uint8_t)changed;
}
*/
static void select_col(_uint8_t col) {
// emergency code, just a simple switch statement
if(col == 0)
{
setPinOutput(col_select_pins[0]);
writePinLow(col_select_pins[0]);
setPinOutput(col_select_pins[1]);
writePinLow(col_select_pins[1]);
setPinOutput(col_select_pins[2]);
writePinLow(col_select_pins[2]);
}
else if(col == 1)
{
setPinOutput(col_select_pins[0]);
writePinHigh(col_select_pins[0]);
setPinOutput(col_select_pins[1]);
writePinLow(col_select_pins[1]);
setPinOutput(col_select_pins[2]);
writePinLow(col_select_pins[2]);
}
else if(col == 2)
{
setPinOutput(col_select_pins[0]);
writePinLow(col_select_pins[0]);
setPinOutput(col_select_pins[1]);
writePinHigh(col_select_pins[1]);
setPinOutput(col_select_pins[2]);
writePinLow(col_select_pins[2]);
}
else if(col == 3)
{
setPinOutput(col_select_pins[0]);
writePinHigh(col_select_pins[0]);
setPinOutput(col_select_pins[1]);
writePinHigh(col_select_pins[1]);
setPinOutput(col_select_pins[2]);
writePinLow(col_select_pins[2]);
}
else if(col == 4)
{
setPinOutput(col_select_pins[0]);
writePinLow(col_select_pins[0]);
setPinOutput(col_select_pins[1]);
writePinLow(col_select_pins[1]);
setPinOutput(col_select_pins[2]);
writePinHigh(col_select_pins[2]);
}
else if(col == 5)
{
setPinOutput(col_select_pins[0]);
writePinHigh(col_select_pins[0]);
setPinOutput(col_select_pins[1]);
writePinLow(col_select_pins[1]);
setPinOutput(col_select_pins[2]);
writePinHigh(col_select_pins[2]);
}
else if(col == 6)
{
setPinOutput(col_select_pins[0]);
writePinLow(col_select_pins[0]);
setPinOutput(col_select_pins[1]);
writePinHigh(col_select_pins[1]);
setPinOutput(col_select_pins[2]);
writePinHigh(col_select_pins[2]);
}
else
{
setPinOutput(col_select_pins[0]);
writePinHigh(col_select_pins[0]);
setPinOutput(col_select_pins[1]);
writePinHigh(col_select_pins[1]);
setPinOutput(col_select_pins[2]);
writePinHigh(col_select_pins[2]);
}
}
void matrix_init(void) {
// initialize key pins
init_pins();
// initialize matrix state: all keys off
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
raw_matrix[i] = 0;
matrix[i] = 0;
}
debounce_init(MATRIX_ROWS);
matrix_init_quantum();
}

View File

@ -0,0 +1,3 @@
#include "owlet60.h"
// write multiplexer handler here

View File

@ -0,0 +1,40 @@
#ifndef OWLET60_H
#define OWLET60_H
#define LAYOUT_owlet60_all( \
k50, k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, k0c, k0d, k0e, k0f, \
k51, k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, k1c, k1d, k1e, \
k52, k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b, k2c, k2d, \
k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3a, k3b, k3c, k3d, k3e, \
k40, k41, k42, k43, k44, k45, k46, k47, k48, \
) \
{ \
{ k50, k51, k52, k40, k30, k20, k10, k00, k01 }, \
{ k11, k21, k31, k41, k32, k22, k12, k02, k03 }, \
{ k13, k23, k33, k42, k34, k24, k14, k04, k05}, \
{ k15, k25, k35, k43, k44, k36, k26, k16, k06}, \
{ k07, k17, k27, k37, k38, k28, k18, k08, k09}, \
{ k19, k29, k39, k45, k3a, k2a, k1a, k0a, k0b}, \
{ k1b, k2b, k3b, k46, k3c, k2c, k1c, k0c, k0d}, \
{ k0e, k1d, k3d, k47, k48, k3e, k2d, k1e, k0f} \
}
#define LAYOUT_owlet60_full_bsp( \
k50, k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, k0c, k0e, k0f, \
k51, k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, k1c, k1d, k1e, \
k52, k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b, k2c, k2d, \
k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3a, k3b, k3c, k3d, k3e, \
k40, k41, k42, k43, k44, k45, k46, k47, k48, \
) \
{ \
{ k50, k51, k52, k40, k30, k20, k10, k00, k01 }, \
{ k11, k21, k31, k41, k32, k22, k12, k02, k03 }, \
{ k13, k23, k33, k42, k34, k24, k14, k04, k05}, \
{ k15, k25, k35, k43, k44, k36, k26, k16, k06}, \
{ k07, k17, k27, k37, k38, k28, k18, k08, k09}, \
{ k19, k29, k39, k45, k3a, k2a, k1a, k0a, k0b}, \
{ k1b, k2b, k3b, k46, k3c, k2c, k1c, k0c, KC_NO}, \
{ k0e, k1d, k3d, k47, k48, k3e, k2d, k1e, k0f} \
}
#endif

View File

@ -0,0 +1,15 @@
# Owlet60
![Owlet60](imgurlink_todo)
A TGR Alice Inspired 65% layout. Powered with a single Pro Micro. Multiplexed matrix. Supports RGB underglow, an OLED screen and a rotary encoder.
Keyboard Maintainer: [worthlessowl](https://github.com/worthlessowl)
Hardware Supported: Owlet60 PCB rev.0
Hardware Availability: 2019 Local Group Buy
Make example for this keyboard (after setting up your build environment):
make handwired/worthlessowl/owlet60:default
See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).

View File

@ -0,0 +1,61 @@
# MCU name
MCU = atmega32u4
# Processor frequency.
# This will define a symbol, F_CPU, in all source code files equal to the
# processor frequency in Hz. You can then use this symbol in your source code to
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
# automatically to create a 32-bit value in your source code.
#
# This will be an integer division of F_USB below, as it is sourced by
# F_USB after it has run through any CPU prescalers. Note that this value
# does not *change* the processor frequency - it should merely be updated to
# reflect the processor speed set externally so that the code can use accurate
# software delays.
F_CPU = 16000000
#
# LUFA specific
#
# Target architecture (see library "Board Types" documentation).
ARCH = AVR8
# Input clock frequency.
# This will define a symbol, F_USB, in all source code files equal to the
# input clock frequency (before any prescaling is performed) in Hz. This value may
# differ from F_CPU if prescaling is used on the latter, and is required as the
# raw input clock is fed directly to the PLL sections of the AVR for high speed
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
# at the end, this will be done automatically to create a 32-bit value in your
# source code.
#
# If no clock division is performed on the input clock inside the AVR (via the
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
F_USB = $(F_CPU)
# Interrupt driven control endpoint task(+60)
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
# Boot Section Size in *bytes*
OPT_DEFS += -DBOOTLOADER_SIZE=4096
# Build Options
# change yes to no to disable
#
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
CONSOLE_ENABLE = no # Console for debug(+400)
COMMAND_ENABLE = no # Commands for debug and configuration
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
NKRO_ENABLE = yes # USB Nkey Rollover
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality on D3 by default
MIDI_ENABLE = no # MIDI controls
UNICODE_ENABLE = no # Unicode
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
AUDIO_ENABLE = no # Audio output on port C6
LAYOUTS = owlet_std60
LAYOUTS_HAS_RGB = no