From 5777177cec2c76f79b4930dacb390b0f4681bc85 Mon Sep 17 00:00:00 2001
From: Yan-Fa Li <yanfali@gmail.com>
Date: Mon, 28 Oct 2019 09:47:48 -0700
Subject: [PATCH] [keyboard] yanfali fruity60 prototype (#7021)

* initial commit

* README

* Unique id

* info.json

* layotus

* br

* Move to handwired

* cleanup

* Disable command for fruity out of flash space

* Old compiler

turn off command
---
 keyboards/handwired/fruity60/config.h         | 53 +++++++++++++++++++
 keyboards/handwired/fruity60/fruity60.c       | 51 ++++++++++++++++++
 keyboards/handwired/fruity60/fruity60.h       | 42 +++++++++++++++
 keyboards/handwired/fruity60/info.json        | 12 +++++
 .../fruity60/keymaps/default/config.h         | 19 +++++++
 .../fruity60/keymaps/default/keymap.c         | 25 +++++++++
 .../fruity60/keymaps/default/readme.md        |  1 +
 keyboards/handwired/fruity60/readme.md        | 15 ++++++
 keyboards/handwired/fruity60/rules.mk         | 38 +++++++++++++
 users/yanfali/rules.mk                        |  3 ++
 10 files changed, 259 insertions(+)
 create mode 100644 keyboards/handwired/fruity60/config.h
 create mode 100644 keyboards/handwired/fruity60/fruity60.c
 create mode 100644 keyboards/handwired/fruity60/fruity60.h
 create mode 100644 keyboards/handwired/fruity60/info.json
 create mode 100644 keyboards/handwired/fruity60/keymaps/default/config.h
 create mode 100644 keyboards/handwired/fruity60/keymaps/default/keymap.c
 create mode 100644 keyboards/handwired/fruity60/keymaps/default/readme.md
 create mode 100644 keyboards/handwired/fruity60/readme.md
 create mode 100644 keyboards/handwired/fruity60/rules.mk

diff --git a/keyboards/handwired/fruity60/config.h b/keyboards/handwired/fruity60/config.h
new file mode 100644
index 0000000000..5cccba3dc8
--- /dev/null
+++ b/keyboards/handwired/fruity60/config.h
@@ -0,0 +1,53 @@
+/*
+Copyright 2019 Yan-Fa Li
+
+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 "config_common.h"
+
+/* USB Device descriptor parameter */
+#define VENDOR_ID 0xFEED
+#define PRODUCT_ID 0xB170
+#define DEVICE_VER 0x0001
+#define MANUFACTURER yanfali
+#define PRODUCT fruity60
+#define DESCRIPTION An Adafruit BLE 32u4 capable 60
+
+/* key matrix size */
+#define MATRIX_ROWS 6
+#define MATRIX_COLS 11
+
+#define MATRIX_ROW_PINS \
+    { B6, B5, D7, C6, D0, D1 }
+#define MATRIX_COL_PINS \
+    { F7, F6, F5, F4, F1, F0, D2, D3, B7, D6, C7 }
+#define UNUSED_PINS
+
+/* COL2ROW, ROW2COL*/
+#define DIODE_DIRECTION COL2ROW
+
+
+/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
+#define DEBOUNCE 5
+
+/* define if matrix has ghost (lacks anti-ghosting diodes) */
+//#define MATRIX_HAS_GHOST
+
+/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
+#define LOCKING_SUPPORT_ENABLE
+/* Locking resynchronize hack */
+#define LOCKING_RESYNC_ENABLE
diff --git a/keyboards/handwired/fruity60/fruity60.c b/keyboards/handwired/fruity60/fruity60.c
new file mode 100644
index 0000000000..d68b17955e
--- /dev/null
+++ b/keyboards/handwired/fruity60/fruity60.c
@@ -0,0 +1,51 @@
+/* Copyright 2019 Yan-Fa Li
+ *
+ * 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 "fruity60.h"
+
+// Optional override functions below.
+// You can leave any or all of these undefined.
+// These are only required if you want to perform custom actions.
+
+/*
+
+void matrix_init_kb(void) {
+  // put your keyboard start-up code here
+  // runs once when the firmware starts up
+
+  matrix_init_user();
+}
+
+void matrix_scan_kb(void) {
+  // put your looping keyboard code here
+  // runs every cycle (a lot)
+
+  matrix_scan_user();
+}
+
+bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
+  // put your per-action keyboard code here
+  // runs for every action, just before processing by the firmware
+
+  return process_record_user(keycode, record);
+}
+
+void led_set_kb(uint8_t usb_led) {
+  // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
+
+  led_set_user(usb_led);
+}
+
+*/
diff --git a/keyboards/handwired/fruity60/fruity60.h b/keyboards/handwired/fruity60/fruity60.h
new file mode 100644
index 0000000000..7eb2e7e6fd
--- /dev/null
+++ b/keyboards/handwired/fruity60/fruity60.h
@@ -0,0 +1,42 @@
+/* Copyright 2019 Yan-Fa Li
+ *
+ * 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"
+
+/* This a shortcut to help you visually see your layout.
+ *
+ * The first section contains all of the arguments representing the physical
+ * layout of the board and position of the keys.
+ *
+ * The second converts the arguments into a two-dimensional array which
+ * represents the switch matrix.
+ */
+#define LAYOUT_60_tsangan_hhkb( \
+        k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k50, k51, k52, k53, \
+        k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k54, k55, k56, \
+        k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k57, k58, \
+        k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3a, k59, k5a, \
+        k40, k41, k42, k45, k48, k49, k4a \
+        ) \
+    { \
+      {k00, k01, k02, k03,   k04,   k05, k06,   k07,   k08, k09, k0a}, \
+      {k10, k11, k12, k13,   k14,   k15, k16,   k17,   k18, k19, k1a}, \
+      {k20, k21, k22, k23,   k24,   k25, k26,   k27,   k28, k29, k2a}, \
+      {k30, k31, k32, k33,   k34,   k35, k36,   k37,   k38, k39, k3a}, \
+      {k40, k41, k42, KC_NO, KC_NO, k45, KC_NO, KC_NO, k48, k49, k4a}, \
+      {k50, k51, k52, k53,   k54,   k55, k56,   k57,   k58, k59, k5a}, \
+    }
diff --git a/keyboards/handwired/fruity60/info.json b/keyboards/handwired/fruity60/info.json
new file mode 100644
index 0000000000..7cf5e61d18
--- /dev/null
+++ b/keyboards/handwired/fruity60/info.json
@@ -0,0 +1,12 @@
+{
+    "keyboard_name": "fruity60",
+    "url": "https://github.com/yanfali/fruity60",
+    "maintainer": "qmk",
+    "width": 15,
+    "height": 5,
+    "layouts": {
+        "LAYOUT": {
+            "layout": [{"label":"~", "x":0, "y":0}, {"label":"!", "x":1, "y":0}, {"label":"@", "x":2, "y":0}, {"label":"#", "x":3, "y":0}, {"label":"$", "x":4, "y":0}, {"label":"%", "x":5, "y":0}, {"label":"^", "x":6, "y":0}, {"label":"&", "x":7, "y":0}, {"label":"*", "x":8, "y":0}, {"label":"(", "x":9, "y":0}, {"label":")", "x":10, "y":0}, {"label":"_", "x":11, "y":0}, {"label":"+", "x":12, "y":0}, {"x":13, "y":0}, {"label":"Backspace", "x":14, "y":0}, {"label":"Tab", "x":0, "y":1, "w":1.5}, {"label":"Q", "x":1.5, "y":1}, {"label":"W", "x":2.5, "y":1}, {"label":"E", "x":3.5, "y":1}, {"label":"R", "x":4.5, "y":1}, {"label":"T", "x":5.5, "y":1}, {"label":"Y", "x":6.5, "y":1}, {"label":"U", "x":7.5, "y":1}, {"label":"I", "x":8.5, "y":1}, {"label":"O", "x":9.5, "y":1}, {"label":"P", "x":10.5, "y":1}, {"label":"{", "x":11.5, "y":1}, {"label":"}", "x":12.5, "y":1}, {"label":"|", "x":13.5, "y":1, "w":1.5}, {"label":"Caps Lock", "x":0, "y":2, "w":1.75}, {"label":"A", "x":1.75, "y":2}, {"label":"S", "x":2.75, "y":2}, {"label":"D", "x":3.75, "y":2}, {"label":"F", "x":4.75, "y":2}, {"label":"G", "x":5.75, "y":2}, {"label":"H", "x":6.75, "y":2}, {"label":"J", "x":7.75, "y":2}, {"label":"K", "x":8.75, "y":2}, {"label":"L", "x":9.75, "y":2}, {"label":":", "x":10.75, "y":2}, {"label":"\"", "x":11.75, "y":2}, {"label":"Enter", "x":12.75, "y":2, "w":2.25}, {"label":"Shift", "x":0, "y":3, "w":2.25}, {"label":"Z", "x":2.25, "y":3}, {"label":"X", "x":3.25, "y":3}, {"label":"C", "x":4.25, "y":3}, {"label":"V", "x":5.25, "y":3}, {"label":"B", "x":6.25, "y":3}, {"label":"N", "x":7.25, "y":3}, {"label":"M", "x":8.25, "y":3}, {"label":"<", "x":9.25, "y":3}, {"label":">", "x":10.25, "y":3}, {"label":"?", "x":11.25, "y":3}, {"label":"Shift", "x":12.25, "y":3, "w":1.75}, {"x":14, "y":3}, {"label":"Ctrl", "x":0, "y":4, "w":1.5}, {"label":"Win", "x":1.5, "y":4}, {"label":"Alt", "x":2.5, "y":4, "w":1.5}, {"x":4, "y":4, "w":7}, {"label":"Alt", "x":11, "y":4, "w":1.5}, {"label":"Win", "x":12.5, "y":4}, {"label":"Menu", "x":13.5, "y":4, "w":1.5}]
+        }
+    }
+}
diff --git a/keyboards/handwired/fruity60/keymaps/default/config.h b/keyboards/handwired/fruity60/keymaps/default/config.h
new file mode 100644
index 0000000000..7d7844ac61
--- /dev/null
+++ b/keyboards/handwired/fruity60/keymaps/default/config.h
@@ -0,0 +1,19 @@
+/* Copyright 2019 Yan-Fa Li
+ *
+ * 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
+
+// place overrides here
diff --git a/keyboards/handwired/fruity60/keymaps/default/keymap.c b/keyboards/handwired/fruity60/keymaps/default/keymap.c
new file mode 100644
index 0000000000..a6cd15f4e2
--- /dev/null
+++ b/keyboards/handwired/fruity60/keymaps/default/keymap.c
@@ -0,0 +1,25 @@
+#include QMK_KEYBOARD_H
+
+enum layer {
+    BASE,
+    FN,
+};
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    [BASE] = LAYOUT_60_tsangan_hhkb(
+        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_GRV, KC_BSPC,
+        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,
+        LCTL_T(KC_ESC), 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_LSFT,        KC_Z,     KC_X,     KC_C,     KC_V,     KC_B,     KC_N,     KC_M,     KC_COMM,  KC_DOT,   KC_SLSH,  KC_RSFT,  MO(FN),
+        KC_LCTL,        KC_LALT,  KC_LGUI,  KC_SPC,   KC_RGUI,  KC_RALT, KC_RCTL
+    ),
+
+    [FN] = LAYOUT_60_tsangan_hhkb(
+        _______,  KC_F1,    KC_F2,    KC_F3,    KC_F4,    KC_F5,    KC_F6,    KC_F7,    KC_F8,    KC_F9,    KC_F10,   KC_F11,   KC_F12,   KC_INS,   KC_DEL,
+        _______,  _______,  KC_UP,    _______,  _______,  _______,  _______,  _______,  _______,  _______,  _______,  _______,  EEP_RST,  RESET,
+        KC_CAPS,  KC_LEFT,  KC_DOWN,  KC_RGHT,  _______,  _______,  _______,  _______,  _______,  _______,  _______,  _______,  _______,
+        _______,  _______,  _______,  _______,  _______,  _______,  _______,  _______,  _______,  _______,  _______,  _______,  _______,
+        _______,  _______,  _______,  _______,  _______,  _______,  _______
+    ),
+
+};
diff --git a/keyboards/handwired/fruity60/keymaps/default/readme.md b/keyboards/handwired/fruity60/keymaps/default/readme.md
new file mode 100644
index 0000000000..7c01154cd1
--- /dev/null
+++ b/keyboards/handwired/fruity60/keymaps/default/readme.md
@@ -0,0 +1 @@
+# The default keymap for fruity60
diff --git a/keyboards/handwired/fruity60/readme.md b/keyboards/handwired/fruity60/readme.md
new file mode 100644
index 0000000000..ed476d2643
--- /dev/null
+++ b/keyboards/handwired/fruity60/readme.md
@@ -0,0 +1,15 @@
+# fruity60
+
+![fruity60](https://github.com/yanfali/fruity60/blob/master/assets/pcb.png)
+
+A 60% tsangan, split bs/rs keyboard designed to support the bluefruit 32u4 ble controller
+
+Keyboard Maintainer: [Yan-Fa Li](https://github.com/yanfali)<br>
+Hardware Supported: [github](https://github.com/yanfali/fruity60)<br>
+Hardware Availability: You can make them yourself by downloading kicad and generating gerbers.<br>
+
+Make example for this keyboard (after setting up your build environment):
+
+    make fruity60: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).
diff --git a/keyboards/handwired/fruity60/rules.mk b/keyboards/handwired/fruity60/rules.mk
new file mode 100644
index 0000000000..8c9bc95e50
--- /dev/null
+++ b/keyboards/handwired/fruity60/rules.mk
@@ -0,0 +1,38 @@
+# MCU name
+MCU = atmega32u4
+
+# Bootloader selection
+#   Teensy       halfkay
+#   Pro Micro    caterina
+#   Atmel DFU    atmel-dfu
+#   LUFA DFU     lufa-dfu
+#   QMK DFU      qmk-dfu
+#   ATmega32A    bootloadHID
+#   ATmega328P   USBasp
+BOOTLOADER = caterina
+
+# Processor frequency
+F_CPU = 8000000
+
+# Build Options
+#   change yes to no to disable
+#
+BOOTMAGIC_ENABLE = lite      # Virtual DIP switch configuration(+1000)
+MOUSEKEY_ENABLE = yes       # Mouse keys(+4700)
+EXTRAKEY_ENABLE = yes       # Audio control and System control(+450)
+CONSOLE_ENABLE = yes        # Console for debug(+400)
+COMMAND_ENABLE = no         # Commands for debug and configuration
+# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
+SLEEP_LED_ENABLE = no       # Breathing sleep LED during USB suspend
+# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
+NKRO_ENABLE = no            # USB Nkey Rollover
+BACKLIGHT_ENABLE = no       # Enable keyboard backlight functionality
+RGBLIGHT_ENABLE = no        # Enable keyboard RGB underglow
+MIDI_ENABLE = no            # MIDI support (+2400 to 4200, depending on config)
+UNICODE_ENABLE = no         # Unicode
+BLUETOOTH_ENABLE = no       # Enable Bluetooth with the Adafruit EZ-Key HID
+AUDIO_ENABLE = no           # Audio output on port C6
+FAUXCLICKY_ENABLE = no      # Use buzzer to emulate clicky switches
+BLUETOOTH = AdafruitBLE
+
+LAYOUTS = 60_tsangan_hhkb
diff --git a/users/yanfali/rules.mk b/users/yanfali/rules.mk
index b52bd55620..c43f298588 100644
--- a/users/yanfali/rules.mk
+++ b/users/yanfali/rules.mk
@@ -11,3 +11,6 @@ else
     AUDIO_ENABLE = no
 endif
 
+ifeq ($(strip $(KEYBOARD)), fruity60)
+    COMMAND_ENABLE = no
+endif