~ruther/qmk_firmware

2dd7242e999c10341f42bb75bcad7ec12b8ed9ce — nopunin10did 3 years ago 0e11f8e
[Keyboard] Kastenwagen 1840 and Kastenwagen 48 (#13565)

* cleaning up

* deleting to undelete

* Stub out defaults

* Jabberwocky firmware WIP

* Stubbing out keymap spacing

* Default keymap and layout updates

* start stubbing out JSON for configurator

* more WIP

* Update jabberwocky.h

* Add Readme

* Apply suggestions from code review

* Fix layout capitalization

* Updates to personal and default keymaps

* Add instructions for jumping the bootloader

* Update keyboards/nopunin10did/jabberwocky/rules.mk

* Add easier ctrl-alt-del to my keymap

* Start stubbing out KW firmware

* More firmware and keymap stuff

* Fix compile error

* Filling out other layers in default keymap

* Update layout JSON and finish default layouts

* Add rotary and LED code

* Add VIA support (first draft)

* Move VIA compatibility to VIA-specific branch

* Fix readme formatting

* Fix state count issue in LED code

* Fix an erroneous change to a Jabberwocky file

* Default LEDs to on.

* Apply suggestions from code review

* Delete kastenwagen.json

* Update keyboards/nopunin10did/kastenwagen/config.h

* Apply suggestions from code review

* Apply suggestions from noroadsleft code review

* Update image in the readme

* Split 1840 & 48 into two boards (part 1)

* Splitting into two keyboards (part 2)
A keyboards/nopunin10did/kastenwagen1840/config.h => keyboards/nopunin10did/kastenwagen1840/config.h +51 -0
@@ 0,0 1,51 @@
/* Copyright 2022 W. Alex Ronke, a.k.a. NoPunIn10Did (w.alex.ronke@gmail.com)
 *
 * 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           0x4E50  // "NP"
#define PRODUCT_ID          0x4B57  // "KW"
#define DEVICE_VER          0x0001
#define MANUFACTURER        NoPunIn10Did
#define PRODUCT             Kastenwagen 1840

/* key matrix size */
#define MATRIX_ROWS         8
#define MATRIX_COLS         9

/* key matrix pins */
#define MATRIX_ROW_PINS     { B4, B5, B7, D5, C7, F1, F0, B6 }
#define MATRIX_COL_PINS     { F4, F5, F6, F7, B1, B3, B2, E6, D7 }
#define UNUSED_PINS

/* Indicator LEDs */
#define LED_INDICATOR_TOP   B0
#define LED_INDICATOR_MID   D4
#define LED_INDICATOR_BOT   C6

/* Rotary encoder rotation pins */
#define ENCODERS_PAD_A      { D0, D3 }
#define ENCODERS_PAD_B      { D1, D2 }


/* COL2ROW or ROW2COL */
#define DIODE_DIRECTION     COL2ROW

/* Set 0 if debouncing isn't needed */
#define DEBOUNCE            5

A keyboards/nopunin10did/kastenwagen1840/info.json => keyboards/nopunin10did/kastenwagen1840/info.json +77 -0
@@ 0,0 1,77 @@
{
    "keyboard_name": "Kastenwagen 1840",
    "url": "https://github.com/qmk/qmk_firmware/tree/master/keyboards/nopunin10did/kastenwagen1840",
    "maintainer": "NoPunIn10Did",
    "manufacturer": "NoPunIn10Did",
    "layouts": {
        "LAYOUT_1840": {
            "layout": [
                {"x":0   ,  "y":0,    "label":"Esc"},
                {"x":1   ,  "y":0,    "label":"Q"},
                {"x":2   ,  "y":0,    "label":"W"},
                {"x":3   ,  "y":0,    "label":"E"},
                {"x":4   ,  "y":0,    "label":"R"},
                {"x":5   ,  "y":0,    "label":"T"},
                {"x":6   ,  "y":0,    "label":"Y"},
                {"x":7   ,  "y":0,    "label":"U"},
                {"x":8   ,  "y":0,    "label":"I"},
                {"x":9   ,  "y":0,    "label":"O"},
                {"x":10  ,  "y":0,    "label":"P"},
                {"x":11  ,  "y":0,    "label":"L Bracket"},
                {"x":12  ,  "y":0,    "label":"Backspace", "w":1.75},
                {"x":14.25, "y":0,    "label":"P-7"},
                {"x":15.25, "y":0,    "label":"P-8"},
                {"x":16.25, "y":0,    "label":"P-9"},
                {"x":17.25, "y":0,    "label":"P-Minus"},
                {"x":0   ,  "y":1,    "label":"Tab", "w":1.25},
                {"x":1.25,  "y":1,    "label":"A"},
                {"x":2.25,  "y":1,    "label":"S"},
                {"x":3.25,  "y":1,    "label":"D"},
                {"x":4.25,  "y":1,    "label":"F"},
                {"x":5.25,  "y":1,    "label":"G"},
                {"x":6.25,  "y":1,    "label":"H"},
                {"x":7.25,  "y":1,    "label":"J"},
                {"x":8.25,  "y":1,    "label":"K"},
                {"x":9.25,  "y":1,    "label":"L"},
                {"x":10.25, "y":1,    "label":"Semicolon"},
                {"x":11.25, "y":1,    "label":"Quote"},
                {"x":12.25, "y":1,    "label":"Enter", "w":1.5},
                {"x":14.25, "y":1,    "label":"P-4"},
                {"x":15.25, "y":1,    "label":"P-5"},
                {"x":16.25, "y":1,    "label":"P-6"},
                {"x":17.25, "y":1,    "label":"P-Plus"},
                {"x":0   ,  "y":2,    "label":"Left Shift", "w":1.75},
                {"x":1.75,  "y":2,    "label":"Z"},
                {"x":2.75,  "y":2,    "label":"X"},
                {"x":3.75,  "y":2,    "label":"C"},
                {"x":4.75,  "y":2,    "label":"V"},
                {"x":5.75,  "y":2,    "label":"B"},
                {"x":6.75,  "y":2,    "label":"N"},
                {"x":7.75,  "y":2,    "label":"M"},
                {"x":8.75,  "y":2,    "label":"Comma"},
                {"x":9.75,  "y":2,    "label":"Period"},
                {"x":10.75, "y":2,    "label":"Slash"},
                {"x":11.75, "y":2,    "label":"Right Shift", "w":1.25},
                {"x":13.125,"y":2.125,"label":"Up"},
                {"x":14.25, "y":2,    "label":"P-1"},
                {"x":15.25, "y":2,    "label":"P-2"},
                {"x":16.25, "y":2,    "label":"P-3"},
                {"x":17.25, "y":2,    "label":"P-Mult"},
                {"x":0    , "y":3,    "label":"Left Ctrl", "w":1.25},
                {"x":1.25 , "y":3,    "label":"Left Alt", "w":1.25},
                {"x":2.5  , "y":3,    "label":"MO(2)"},
                {"x":3.5  , "y":3,    "label":"Space", "w":2.75},
                {"x":6.25 , "y":3,    "label":"Space", "w":2.25},
                {"x":8.5  , "y":3,    "label":"MO(3)"},
                {"x":9.5  , "y":3,    "label":"R Win / Alt Gr", "w":1.25},
                {"x":10.75, "y":3,    "label":"MO(1)", "w":1.25},
                {"x":12.125,"y":3.125,"label":"Left"},
                {"x":13.125,"y":3.125,"label":"Down"},
                {"x":14.125,"y":3.125,"label":"Right"},
                {"x":15.25 ,"y":3,    "label":"P-0"},
                {"x":16.25 ,"y":3,    "label":"P-Dot"},
                {"x":17.25 ,"y":3,    "label":"P-Enter"}
            ]
        }
    }
}

A keyboards/nopunin10did/kastenwagen1840/kastenwagen1840.c => keyboards/nopunin10did/kastenwagen1840/kastenwagen1840.c +60 -0
@@ 0,0 1,60 @@
/* Copyright 2022 W. Alex Ronke, a.k.a. NoPunIn10Did (w.alex.ronke@gmail.com)
 *
 * 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 "kastenwagen1840.h"

#ifndef LAYER_LED_DISABLE

void keyboard_pre_init_kb(void) {
    setPinOutput(LED_INDICATOR_TOP);
    setPinOutput(LED_INDICATOR_MID);
    setPinOutput(LED_INDICATOR_BOT);
    keyboard_pre_init_user();
}

__attribute__((weak)) layer_state_t layer_state_set_user(layer_state_t state) {
    writePinHigh(LED_INDICATOR_TOP);
    writePinHigh(LED_INDICATOR_MID);
    writePinHigh(LED_INDICATOR_BOT);

    switch(get_highest_layer(state) % 4) {
    case 1:
        writePinLow(LED_INDICATOR_TOP);
        writePinLow(LED_INDICATOR_MID);
        break;
    case 2:
        writePinLow(LED_INDICATOR_TOP);
        writePinLow(LED_INDICATOR_BOT);
        break;
    case 3:
        writePinLow(LED_INDICATOR_MID);
        writePinLow(LED_INDICATOR_BOT);
        break;
    }
    return state;
}

#endif

bool encoder_update_kb(uint8_t index, bool clockwise) {
   if (!encoder_update_user(index, clockwise)) { return false; }
   if (clockwise) {
       tap_code(KC_PGUP);
   } else {
       tap_code(KC_PGUP);
   }
   return true;
};

A keyboards/nopunin10did/kastenwagen1840/kastenwagen1840.h => keyboards/nopunin10did/kastenwagen1840/kastenwagen1840.h +54 -0
@@ 0,0 1,54 @@
/* Copyright 2022 W. Alex Ronke, a.k.a. NoPunIn10Did (w.alex.ronke@gmail.com)
 *
 * 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"


#define LAYOUT_1840( \
K100  , K101  , K110  , K111  , K120  , K121  , K130  , K131  , K140  , K141  , K150  , K151  , K160        ,   K170  , K171  , K180  , K181  , \
K202    , K203  , K212  , K213  , K222  , K223  , K232  , K233  , K242  , K243  , K252  , K253  , K262      ,   K272  , K273  , K282  , K283  , \
K304        , K305  , K314  , K315  , K324  , K325  , K334  , K335  , K344  , K345  , K354  , K355    , K364  , K374  , K375  , K384  , K385  , \
K406    , K407    , K416  , K417                , K437            , K446  , K447    , K456    ,  K457 , K467 , K476  ,  K477  , K486  , K487    \
) \
{ \
	{ K100 , K110 , K120 , K130 , K140 , K150 , K160 , K170 , K180 }, \
	{ K101 , K111 , K121 , K131 , K141 , K151 , KC_NO, K171 , K181 }, \
	{ K202 , K212 , K222 , K232 , K242 , K252 , K262 , K272 , K282 }, \
	{ K203 , K213 , K223 , K233 , K243 , K253 , KC_NO, K273 , K283 }, \
	{ K304 , K314 , K324 , K334 , K344 , K354 , K364 , K374 , K384 }, \
	{ K305 , K315 , K325 , K335 , K345 , K355 , KC_NO, K375 , K385 }, \
	{ K406 , K416 , KC_NO, KC_NO, K446 , K456 , KC_NO, K476 , K486 }, \
	{ K407 , K417 , KC_NO, K437 , K447 , K457 , K467 , K477 , K487 } \
}

#define LAYOUT_48( \
K100  , K101  , K110  , K111  , K120  , K121  , K130  , K131  , K140  , K141  , K150  , K151  , K160        ,   K170  , \
K202    , K203  , K212  , K213  , K222  , K223  , K232  , K233  , K242  , K243  , K252  , K253  , K262      ,   K272  , \
K304        , K305  , K314  , K315  , K324  , K325  , K334  , K335  , K344  , K345  , K354  , K355    , K364  , K374  , \
K406    , K407    , K416  , K417                , K437            , K446  , K447    , K456    ,  K457 , K467 , K476     \
) \
{ \
	{ K100 , K110 , K120 , K130 , K140 , K150 , K160 , K170  }, \
	{ K101 , K111 , K121 , K131 , K141 , K151 , KC_NO, KC_NO }, \
	{ K202 , K212 , K222 , K232 , K242 , K252 , K262 , K272  }, \
	{ K203 , K213 , K223 , K233 , K243 , K253 , KC_NO, KC_NO }, \
	{ K304 , K314 , K324 , K334 , K344 , K354 , K364 , K374  }, \
	{ K305 , K315 , K325 , K335 , K345 , K355 , KC_NO, KC_NO }, \
	{ K406 , K416 , KC_NO, KC_NO, K446 , K456 , KC_NO, K476  }, \
	{ K407 , K417 , KC_NO, K437 , K447 , K457 , K467 , KC_NO } \
}
\ No newline at end of file

A keyboards/nopunin10did/kastenwagen1840/keymaps/default/keymap.c => keyboards/nopunin10did/kastenwagen1840/keymaps/default/keymap.c +94 -0
@@ 0,0 1,94 @@
/* Copyright 2021 W. Alex Ronke, a.k.a. NoPunIn10Did (w.alex.ronke@gmail.com)
 *
 * 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 QMK_KEYBOARD_H

#define L2_SPC      LT(2,KC_SPC)
#define L3_SPC      LT(3,KC_SPC)
#define L3_PENT     LT(3,KC_PENT)
#define RWINALT     RALT_T(KC_RGUI)
#define ISO_LT      KC_NUBS
#define ISO_GT      LSFT(KC_NUBS)

bool is_alt_tab_active = false;
uint16_t alt_tab_timer = 0;

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

[0] = LAYOUT_1840(

    KC_ESC ,KC_Q   ,KC_W   ,KC_E   ,KC_R   ,KC_T   ,KC_Y   ,KC_U   ,KC_I   ,KC_O   ,KC_P   ,KC_LBRC,KC_BSPC      , KC_P7  ,KC_P8  ,KC_P9  ,KC_PMNS,
    KC_TAB   ,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_P4  ,KC_P5  ,KC_P6  ,KC_PPLS,
    KC_LSPO      ,KC_Z   ,KC_X   ,KC_C   ,KC_V   ,KC_B   ,KC_N   ,KC_M   ,KC_COMM,KC_DOT ,KC_SLSH,KC_RSPC ,KC_UP , KC_P1  ,KC_P2  ,KC_P3  ,KC_PAST,
    KC_LCTL  ,KC_LALT  ,MO(2)  ,L2_SPC               ,L3_SPC           ,MO(3)  ,RWINALT  ,MO(1)   ,KC_LEFT,KC_DOWN,KC_RGHT,KC_P0  ,KC_PDOT,L3_PENT  
    ),
[1] = LAYOUT_1840(
    RESET  ,KC_F1  ,KC_F2  ,KC_F3  ,KC_F4  ,KC_F5  ,KC_F6  ,KC_F7  ,KC_F8  ,KC_F9  ,KC_F10 ,KC_RBRC,KC_DEL       , KC_HOME,XXXXXXX,KC_PGUP,XXXXXXX,
    KC_CAPS  ,KC_F11 ,KC_F12 ,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX    , XXXXXXX,XXXXXXX,XXXXXXX,KC_PAST,
    _______      ,XXXXXXX,XXXXXXX,KC_PSCR,KC_SLCK,KC_PAUS,KC_INS ,KC_APP ,KC_LGUI,KC_RGUI,XXXXXXX,_______ ,KC_PGUP,KC_END ,XXXXXXX,KC_PGDN,KC_PSLS,
    KC_RCTL  ,_______  ,_______,XXXXXXX              ,XXXXXXX          ,_______,_______  ,_______ ,KC_HOME,KC_PGDN,KC_END ,KC_INS ,KC_DEL ,KC_EQL   
    ),
[2] = LAYOUT_1840(
    KC_GRV ,KC_1   ,KC_2   ,KC_3   ,KC_4   ,KC_5   ,KC_6   ,KC_7   ,KC_8   ,KC_9   ,KC_0   ,KC_MINS,KC_EQL       , XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,
    KC_TILD  ,KC_EXLM,KC_AT  ,KC_HASH,KC_DLR ,KC_PERC,KC_CIRC,KC_AMPR,KC_ASTR,KC_UNDS,KC_LBRC,KC_RBRC,KC_BSLS    , XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,
    _______      ,ISO_LT ,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,_______ ,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,
    _______  ,_______  ,_______,XXXXXXX              ,XXXXXXX          ,_______,_______  ,_______ ,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX  
    ),
[3] = LAYOUT_1840(
    KC_TILD,KC_EXLM,KC_AT  ,KC_HASH,KC_DLR ,KC_PERC,KC_CIRC,KC_AMPR,KC_ASTR,KC_LPRN,KC_RPRN,KC_UNDS,KC_PLUS      , KC_NLCK,KC_PSLS,KC_PAST,XXXXXXX,
    _______  ,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,KC_LCBR,KC_RCBR,KC_PIPE    , KC_PSCR,KC_SLCK,KC_PAUS,XXXXXXX,
    _______      ,ISO_GT ,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,_______ ,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,
    _______  ,_______  ,_______,XXXXXXX              ,XXXXXXX          ,_______,_______  ,_______ ,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,_______  
    )
};

bool encoder_update_user(uint8_t index, bool clockwise) {
    
    if (index == 0) {
        if (clockwise) {
            tap_code(KC_VOLU);
        }
        else {
            tap_code(KC_VOLD);
        }
    }
    else if (index == 1) {
        if (clockwise) {
            if (!is_alt_tab_active) {
                is_alt_tab_active = true;
                register_code(KC_LALT);
            }
            alt_tab_timer = timer_read();
            tap_code16(KC_TAB);
        }
        else {
            alt_tab_timer = timer_read();
            tap_code16(S(KC_TAB));
        }
    }
    
    return false;
}

void matrix_scan_user(void) {
    
    if (is_alt_tab_active) {
        if (timer_elapsed(alt_tab_timer) > 1250) {
            unregister_code(KC_LALT);
            is_alt_tab_active = false;
        }
    }
}

A keyboards/nopunin10did/kastenwagen1840/keymaps/default48/keymap.c => keyboards/nopunin10did/kastenwagen1840/keymaps/default48/keymap.c +93 -0
@@ 0,0 1,93 @@
/* Copyright 2022 W. Alex Ronke, a.k.a. NoPunIn10Did (w.alex.ronke@gmail.com)
 *
 * 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 QMK_KEYBOARD_H

#define L2_SPC      LT(2,KC_SPC)
#define L3_SPC      LT(3,KC_SPC)
#define RWINALT     RALT_T(KC_RGUI)
#define ISO_LT      KC_NUBS
#define ISO_GT      LSFT(KC_NUBS)

bool is_alt_tab_active = false;
uint16_t alt_tab_timer = 0;

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

[0] = LAYOUT_48(

    KC_ESC ,KC_Q   ,KC_W   ,KC_E   ,KC_R   ,KC_T   ,KC_Y   ,KC_U   ,KC_I   ,KC_O   ,KC_P   ,KC_LBRC,KC_BSPC      , KC_DEL ,
    KC_TAB   ,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_PGUP,
    KC_LSPO      ,KC_Z   ,KC_X   ,KC_C   ,KC_V   ,KC_B   ,KC_N   ,KC_M   ,KC_COMM,KC_DOT ,KC_SLSH,KC_RSPC ,KC_UP , KC_PGDN,
    KC_LCTL  ,KC_LALT  ,MO(2)  ,L2_SPC               ,L3_SPC           ,MO(3)  ,RWINALT  ,MO(1)   ,KC_LEFT,KC_DOWN,KC_RGHT 
    ),
[1] = LAYOUT_48(
    RESET  ,KC_F1  ,KC_F2  ,KC_F3  ,KC_F4  ,KC_F5  ,KC_F6  ,KC_F7  ,KC_F8  ,KC_F9  ,KC_F10 ,KC_RBRC,KC_DEL       , KC_INS ,
    KC_CAPS  ,KC_F11 ,KC_F12 ,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX    , KC_HOME,
    _______      ,XXXXXXX,XXXXXXX,KC_PSCR,KC_SLCK,KC_PAUS,KC_INS ,KC_APP ,KC_LGUI,KC_RGUI,XXXXXXX,_______ ,KC_PGUP,KC_END ,
    KC_RCTL  ,_______  ,_______,XXXXXXX              ,XXXXXXX          ,_______,_______  ,_______ ,KC_HOME,KC_PGDN,KC_END  
    ),
[2] = LAYOUT_48(
    KC_GRV ,KC_1   ,KC_2   ,KC_3   ,KC_4   ,KC_5   ,KC_6   ,KC_7   ,KC_8   ,KC_9   ,KC_0   ,KC_MINS,KC_EQL       , XXXXXXX,
    KC_TILD  ,KC_EXLM,KC_AT  ,KC_HASH,KC_DLR ,KC_PERC,KC_CIRC,KC_AMPR,KC_ASTR,KC_UNDS,KC_LBRC,KC_RBRC,KC_BSLS    , XXXXXXX,
    _______      ,ISO_LT ,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,_______ ,XXXXXXX,XXXXXXX,
    _______  ,_______  ,_______,XXXXXXX              ,XXXXXXX          ,_______,_______  ,_______ ,XXXXXXX,XXXXXXX,XXXXXXX 
    ),
[3] = LAYOUT_48(
    KC_TILD,KC_EXLM,KC_AT  ,KC_HASH,KC_DLR ,KC_PERC,KC_CIRC,KC_AMPR,KC_ASTR,KC_LPRN,KC_RPRN,KC_UNDS,KC_PLUS      , XXXXXXX,
    _______  ,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,KC_LCBR,KC_RCBR,KC_PIPE    , XXXXXXX,
    _______      ,ISO_GT ,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,_______ ,XXXXXXX,XXXXXXX,
    _______  ,_______  ,_______,XXXXXXX              ,XXXXXXX          ,_______,_______  ,_______ ,XXXXXXX,XXXXXXX,XXXXXXX 
    )
};

bool encoder_update_user(uint8_t index, bool clockwise) {
    
    if (index == 0) {
        if (clockwise) {
            tap_code(KC_VOLU);
        }
        else {
            tap_code(KC_VOLD);
        }
    }
    else if (index == 1) {
        if (clockwise) {
            if (!is_alt_tab_active) {
                is_alt_tab_active = true;
                register_code(KC_LALT);
            }
            alt_tab_timer = timer_read();
            tap_code16(KC_TAB);
        }
        else {
            alt_tab_timer = timer_read();
            tap_code16(S(KC_TAB));
        }
    }
    
    return false;
}

void matrix_scan_user(void) {
    
    if (is_alt_tab_active) {
        if (timer_elapsed(alt_tab_timer) > 1250) {
            unregister_code(KC_LALT);
            is_alt_tab_active = false;
        }
    }
}

A keyboards/nopunin10did/kastenwagen1840/keymaps/via/keymap.c => keyboards/nopunin10did/kastenwagen1840/keymaps/via/keymap.c +94 -0
@@ 0,0 1,94 @@
/* Copyright 2021 W. Alex Ronke, a.k.a. NoPunIn10Did (w.alex.ronke@gmail.com)
 *
 * 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 QMK_KEYBOARD_H

#define L2_SPC      LT(2,KC_SPC)
#define L3_SPC      LT(3,KC_SPC)
#define L3_PENT     LT(3,KC_PENT)
#define RWINALT     RALT_T(KC_RGUI)
#define ISO_LT      KC_NUBS
#define ISO_GT      LSFT(KC_NUBS)

bool is_alt_tab_active = false;
uint16_t alt_tab_timer = 0;

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

[0] = LAYOUT_1840(

    KC_ESC ,KC_Q   ,KC_W   ,KC_E   ,KC_R   ,KC_T   ,KC_Y   ,KC_U   ,KC_I   ,KC_O   ,KC_P   ,KC_LBRC,KC_BSPC      , KC_P7  ,KC_P8  ,KC_P9  ,KC_PMNS,
    KC_TAB   ,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_P4  ,KC_P5  ,KC_P6  ,KC_PPLS,
    KC_LSPO      ,KC_Z   ,KC_X   ,KC_C   ,KC_V   ,KC_B   ,KC_N   ,KC_M   ,KC_COMM,KC_DOT ,KC_SLSH,KC_RSPC ,KC_UP , KC_P1  ,KC_P2  ,KC_P3  ,KC_PAST,
    KC_LCTL  ,KC_LALT  ,MO(2)  ,L2_SPC               ,L3_SPC           ,MO(3)  ,RWINALT  ,MO(1)   ,KC_LEFT,KC_DOWN,KC_RGHT,KC_P0  ,KC_PDOT,L3_PENT  
    ),
[1] = LAYOUT_1840(
    RESET  ,KC_F1  ,KC_F2  ,KC_F3  ,KC_F4  ,KC_F5  ,KC_F6  ,KC_F7  ,KC_F8  ,KC_F9  ,KC_F10 ,KC_RBRC,KC_DEL       , KC_HOME,XXXXXXX,KC_PGUP,XXXXXXX,
    KC_CAPS  ,KC_F11 ,KC_F12 ,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX    , XXXXXXX,XXXXXXX,XXXXXXX,KC_PAST,
    _______      ,XXXXXXX,XXXXXXX,KC_PSCR,KC_SLCK,KC_PAUS,KC_INS ,KC_APP ,KC_LGUI,KC_RGUI,XXXXXXX,_______ ,KC_PGUP,KC_END ,XXXXXXX,KC_PGDN,KC_PSLS,
    KC_RCTL  ,_______  ,_______,XXXXXXX              ,XXXXXXX          ,_______,_______  ,_______ ,KC_HOME,KC_PGDN,KC_END ,KC_INS ,KC_DEL ,KC_EQL   
    ),
[2] = LAYOUT_1840(
    KC_GRV ,KC_1   ,KC_2   ,KC_3   ,KC_4   ,KC_5   ,KC_6   ,KC_7   ,KC_8   ,KC_9   ,KC_0   ,KC_MINS,KC_EQL       , XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,
    KC_TILD  ,KC_EXLM,KC_AT  ,KC_HASH,KC_DLR ,KC_PERC,KC_CIRC,KC_AMPR,KC_ASTR,KC_UNDS,KC_LBRC,KC_RBRC,KC_BSLS    , XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,
    _______      ,ISO_LT ,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,_______ ,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,
    _______  ,_______  ,_______,XXXXXXX              ,XXXXXXX          ,_______,_______  ,_______ ,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX  
    ),
[3] = LAYOUT_1840(
    KC_TILD,KC_EXLM,KC_AT  ,KC_HASH,KC_DLR ,KC_PERC,KC_CIRC,KC_AMPR,KC_ASTR,KC_LPRN,KC_RPRN,KC_UNDS,KC_PLUS      , KC_NLCK,KC_PSLS,KC_PAST,XXXXXXX,
    _______  ,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,KC_LCBR,KC_RCBR,KC_PIPE    , KC_PSCR,KC_SLCK,KC_PAUS,XXXXXXX,
    _______      ,ISO_GT ,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,_______ ,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,
    _______  ,_______  ,_______,XXXXXXX              ,XXXXXXX          ,_______,_______  ,_______ ,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,_______  
    )
};

bool encoder_update_user(uint8_t index, bool clockwise) {
    
    if (index == 0) {
        if (clockwise) {
            tap_code(KC_VOLU);
        }
        else {
            tap_code(KC_VOLD);
        }
    }
    else if (index == 1) {
        if (clockwise) {
            if (!is_alt_tab_active) {
                is_alt_tab_active = true;
                register_code(KC_LALT);
            }
            alt_tab_timer = timer_read();
            tap_code16(KC_TAB);
        }
        else {
            alt_tab_timer = timer_read();
            tap_code16(S(KC_TAB));
        }
    }
    
    return false;
}

void matrix_scan_user(void) {
    
    if (is_alt_tab_active) {
        if (timer_elapsed(alt_tab_timer) > 1250) {
            unregister_code(KC_LALT);
            is_alt_tab_active = false;
        }
    }
}

A keyboards/nopunin10did/kastenwagen1840/keymaps/via/rules.mk => keyboards/nopunin10did/kastenwagen1840/keymaps/via/rules.mk +2 -0
@@ 0,0 1,2 @@
VIA_ENABLE = yes
LTO_ENABLE = yes
\ No newline at end of file

A keyboards/nopunin10did/kastenwagen1840/readme.md => keyboards/nopunin10did/kastenwagen1840/readme.md +32 -0
@@ 0,0 1,32 @@
# Kastenwagen 1840

![Kastenwagen 1840](https://diplomacyvariants.files.wordpress.com/2022/01/late-harvest-on-kastenwagen.png)

Kastenwagen 1840 is a 40% keyboard with a mini-numpad and dedicated arrows.  The main alpha block is 13.75u long, allowing for more dedicated punctuation keys to be paired with common Minivan-like mod keys.

A second model of Kastenwagen, the [Kastenwagen 48](https://github.com/qmk/qmk_firmware/tree/master/keyboards/nopunin10did/kastenwagen48), is similar but replaces the numpad with a three-key macro column.

Please note that the Kastenwagen 1840 via-compatible keymap firmware is also compatible with the Kastenwagen 48.  The Kastenwagen 48 does not have a dedicated via-compatible firmware.

For more information, join the [NoPunIn10Key Discord](https://discord.gg/sku2Y6w).

* Keyboard Maintainer: [Alex Ronke](diplomacyvariants.wordpress.com), also known as NoPunIn10Did. 
* Hardware Supported: Kastenwagen 1840 & 48 (2021 June)
* Hardware Availability: Currently by request only

To jump the bootloader, either:
* If loaded with the default layout, use Function-Escape *(the function button is the farthest righthand 1.25u on the bottom row)* **OR**
* Use the physical reset switch on the Elite C **OR**
* Briefly jump the Reset and Ground pins of the Elite C

Make example for the 1840 model (after setting up your build environment):

    make nopunin10did/kastenwagen1840:default
    
Make example for the 48 model:

    make nopunin10did/kastenwagen48: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).

![Kastenwagen Default Layouts](https://diplomacyvariants.files.wordpress.com/2022/01/kastenwagen-default-layouts.png)
\ No newline at end of file

A keyboards/nopunin10did/kastenwagen1840/rules.mk => keyboards/nopunin10did/kastenwagen1840/rules.mk +20 -0
@@ 0,0 1,20 @@
# MCU name
MCU = atmega32u4

# Bootloader selection
BOOTLOADER = atmel-dfu

# Build Options
#   change yes to no to disable
#
BOOTMAGIC_ENABLE = yes      # Enable Bootmagic Lite
MOUSEKEY_ENABLE = yes       # Mouse keys
EXTRAKEY_ENABLE = yes       # Audio control and System control
CONSOLE_ENABLE = no         # Console for debug
COMMAND_ENABLE = no         # Commands for debug and configuration
NKRO_ENABLE = yes           # Enable N-Key Rollover
BACKLIGHT_ENABLE = no       # Enable keyboard backlight functionality
RGBLIGHT_ENABLE = no        # Enable keyboard RGB underglow
AUDIO_ENABLE = no           # Audio output

ENCODER_ENABLE = yes        # Enable rotary encoder input

A keyboards/nopunin10did/kastenwagen48/config.h => keyboards/nopunin10did/kastenwagen48/config.h +51 -0
@@ 0,0 1,51 @@
/* Copyright 2022 W. Alex Ronke, a.k.a. NoPunIn10Did (w.alex.ronke@gmail.com)
 *
 * 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           0x4E50  // "NP"
#define PRODUCT_ID          0x4B30  // Hex for "K" and 48
#define DEVICE_VER          0x0001
#define MANUFACTURER        NoPunIn10Did
#define PRODUCT             Kastenwagen 48

/* key matrix size */
#define MATRIX_ROWS         8
#define MATRIX_COLS         8

/* key matrix pins */
#define MATRIX_ROW_PINS     { B4, B5, B7, D5, C7, F1, F0, B6 }
#define MATRIX_COL_PINS     { F4, F5, F6, F7, B1, B3, B2, E6 }
#define UNUSED_PINS

/* Indicator LEDs */
#define LED_INDICATOR_TOP   B0
#define LED_INDICATOR_MID   D4
#define LED_INDICATOR_BOT   C6

/* Rotary encoder rotation pins */
#define ENCODERS_PAD_A      { D0, D3 }
#define ENCODERS_PAD_B      { D1, D2 }


/* COL2ROW or ROW2COL */
#define DIODE_DIRECTION     COL2ROW

/* Set 0 if debouncing isn't needed */
#define DEBOUNCE            5

A keyboards/nopunin10did/kastenwagen48/info.json => keyboards/nopunin10did/kastenwagen48/info.json +65 -0
@@ 0,0 1,65 @@
{
    "keyboard_name": "Kastenwagen 48",
    "url": "https://github.com/qmk/qmk_firmware/tree/master/keyboards/nopunin10did/kastenwagen48",
    "maintainer": "NoPunIn10Did",
    "manufacturer": "NoPunIn10Did",
    "layouts": {
        "LAYOUT_48": {
            "layout": [
                {"x":0   ,  "y":0,    "label":"Esc"},
                {"x":1   ,  "y":0,    "label":"Q"},
                {"x":2   ,  "y":0,    "label":"W"},
                {"x":3   ,  "y":0,    "label":"E"},
                {"x":4   ,  "y":0,    "label":"R"},
                {"x":5   ,  "y":0,    "label":"T"},
                {"x":6   ,  "y":0,    "label":"Y"},
                {"x":7   ,  "y":0,    "label":"U"},
                {"x":8   ,  "y":0,    "label":"I"},
                {"x":9   ,  "y":0,    "label":"O"},
                {"x":10  ,  "y":0,    "label":"P"},
                {"x":11  ,  "y":0,    "label":"L Bracket"},
                {"x":12  ,  "y":0,    "label":"Backspace", "w":1.75},
                {"x":14.25, "y":0,    "label":"Delete"},
                {"x":0   ,  "y":1,    "label":"Tab", "w":1.25},
                {"x":1.25,  "y":1,    "label":"A"},
                {"x":2.25,  "y":1,    "label":"S"},
                {"x":3.25,  "y":1,    "label":"D"},
                {"x":4.25,  "y":1,    "label":"F"},
                {"x":5.25,  "y":1,    "label":"G"},
                {"x":6.25,  "y":1,    "label":"H"},
                {"x":7.25,  "y":1,    "label":"J"},
                {"x":8.25,  "y":1,    "label":"K"},
                {"x":9.25,  "y":1,    "label":"L"},
                {"x":10.25, "y":1,    "label":"Semicolon"},
                {"x":11.25, "y":1,    "label":"Quote"},
                {"x":12.25, "y":1,    "label":"Enter", "w":1.5},
                {"x":14.25, "y":1,    "label":"Pg Up"},
                {"x":0   ,  "y":2,    "label":"Left Shift", "w":1.75},
                {"x":1.75,  "y":2,    "label":"Z"},
                {"x":2.75,  "y":2,    "label":"X"},
                {"x":3.75,  "y":2,    "label":"C"},
                {"x":4.75,  "y":2,    "label":"V"},
                {"x":5.75,  "y":2,    "label":"B"},
                {"x":6.75,  "y":2,    "label":"N"},
                {"x":7.75,  "y":2,    "label":"M"},
                {"x":8.75,  "y":2,    "label":"Comma"},
                {"x":9.75,  "y":2,    "label":"Period"},
                {"x":10.75, "y":2,    "label":"Slash"},
                {"x":11.75, "y":2,    "label":"Right Shift", "w":1.25},
                {"x":13.125,"y":2.125,"label":"Up"},
                {"x":14.25, "y":2,    "label":"Pg Dn"},
                {"x":0    , "y":3,    "label":"Left Ctrl", "w":1.25},
                {"x":1.25 , "y":3,    "label":"Left Alt", "w":1.25},
                {"x":2.5  , "y":3,    "label":"MO(2)"},
                {"x":3.5  , "y":3,    "label":"Space", "w":2.75},
                {"x":6.25 , "y":3,    "label":"Space", "w":2.25},
                {"x":8.5  , "y":3,    "label":"MO(3)"},
                {"x":9.5  , "y":3,    "label":"R Win / Alt Gr", "w":1.25},
                {"x":10.75, "y":3,    "label":"MO(1)", "w":1.25},
                {"x":12.125,"y":3.125,"label":"Left"},
                {"x":13.125,"y":3.125,"label":"Down"},
                {"x":14.125,"y":3.125,"label":"Right"}
            ]
        }
    }
}

A keyboards/nopunin10did/kastenwagen48/kastenwagen48.c => keyboards/nopunin10did/kastenwagen48/kastenwagen48.c +60 -0
@@ 0,0 1,60 @@
/* Copyright 2022 W. Alex Ronke, a.k.a. NoPunIn10Did (w.alex.ronke@gmail.com)
 *
 * 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 "kastenwagen48.h"

#ifndef LAYER_LED_DISABLE

void keyboard_pre_init_kb(void) {
    setPinOutput(LED_INDICATOR_TOP);
    setPinOutput(LED_INDICATOR_MID);
    setPinOutput(LED_INDICATOR_BOT);
    keyboard_pre_init_user();
}

__attribute__((weak)) layer_state_t layer_state_set_user(layer_state_t state) {
    writePinHigh(LED_INDICATOR_TOP);
    writePinHigh(LED_INDICATOR_MID);
    writePinHigh(LED_INDICATOR_BOT);

    switch(get_highest_layer(state) % 4) {
    case 1:
        writePinLow(LED_INDICATOR_TOP);
        writePinLow(LED_INDICATOR_MID);
        break;
    case 2:
        writePinLow(LED_INDICATOR_TOP);
        writePinLow(LED_INDICATOR_BOT);
        break;
    case 3:
        writePinLow(LED_INDICATOR_MID);
        writePinLow(LED_INDICATOR_BOT);
        break;
    }
    return state;
}

#endif

bool encoder_update_kb(uint8_t index, bool clockwise) {
   if (!encoder_update_user(index, clockwise)) { return false; }
   if (clockwise) {
       tap_code(KC_PGUP);
   } else {
       tap_code(KC_PGUP);
   }
   return true;
};

A keyboards/nopunin10did/kastenwagen48/kastenwagen48.h => keyboards/nopunin10did/kastenwagen48/kastenwagen48.h +36 -0
@@ 0,0 1,36 @@
/* Copyright 2022 W. Alex Ronke, a.k.a. NoPunIn10Did (w.alex.ronke@gmail.com)
 *
 * 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"

#define LAYOUT_48( \
K100  , K101  , K110  , K111  , K120  , K121  , K130  , K131  , K140  , K141  , K150  , K151  , K160        ,   K170  , \
K202    , K203  , K212  , K213  , K222  , K223  , K232  , K233  , K242  , K243  , K252  , K253  , K262      ,   K272  , \
K304        , K305  , K314  , K315  , K324  , K325  , K334  , K335  , K344  , K345  , K354  , K355    , K364  , K374  , \
K406    , K407    , K416  , K417                , K437            , K446  , K447    , K456    ,  K457 , K467 , K476     \
) \
{ \
	{ K100 , K110 , K120 , K130 , K140 , K150 , K160 , K170  }, \
	{ K101 , K111 , K121 , K131 , K141 , K151 , KC_NO, KC_NO }, \
	{ K202 , K212 , K222 , K232 , K242 , K252 , K262 , K272  }, \
	{ K203 , K213 , K223 , K233 , K243 , K253 , KC_NO, KC_NO }, \
	{ K304 , K314 , K324 , K334 , K344 , K354 , K364 , K374  }, \
	{ K305 , K315 , K325 , K335 , K345 , K355 , KC_NO, KC_NO }, \
	{ K406 , K416 , KC_NO, KC_NO, K446 , K456 , KC_NO, K476  }, \
	{ K407 , K417 , KC_NO, K437 , K447 , K457 , K467 , KC_NO } \
}

A keyboards/nopunin10did/kastenwagen48/keymaps/default/keymap.c => keyboards/nopunin10did/kastenwagen48/keymaps/default/keymap.c +93 -0
@@ 0,0 1,93 @@
/* Copyright 2022 W. Alex Ronke, a.k.a. NoPunIn10Did (w.alex.ronke@gmail.com)
 *
 * 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 QMK_KEYBOARD_H

#define L2_SPC      LT(2,KC_SPC)
#define L3_SPC      LT(3,KC_SPC)
#define RWINALT     RALT_T(KC_RGUI)
#define ISO_LT      KC_NUBS
#define ISO_GT      LSFT(KC_NUBS)

bool is_alt_tab_active = false;
uint16_t alt_tab_timer = 0;

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

[0] = LAYOUT_48(

    KC_ESC ,KC_Q   ,KC_W   ,KC_E   ,KC_R   ,KC_T   ,KC_Y   ,KC_U   ,KC_I   ,KC_O   ,KC_P   ,KC_LBRC,KC_BSPC      , KC_DEL ,
    KC_TAB   ,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_PGUP,
    KC_LSPO      ,KC_Z   ,KC_X   ,KC_C   ,KC_V   ,KC_B   ,KC_N   ,KC_M   ,KC_COMM,KC_DOT ,KC_SLSH,KC_RSPC ,KC_UP , KC_PGDN,
    KC_LCTL  ,KC_LALT  ,MO(2)  ,L2_SPC               ,L3_SPC           ,MO(3)  ,RWINALT  ,MO(1)   ,KC_LEFT,KC_DOWN,KC_RGHT 
    ),
[1] = LAYOUT_48(
    RESET  ,KC_F1  ,KC_F2  ,KC_F3  ,KC_F4  ,KC_F5  ,KC_F6  ,KC_F7  ,KC_F8  ,KC_F9  ,KC_F10 ,KC_RBRC,KC_DEL       , KC_INS ,
    KC_CAPS  ,KC_F11 ,KC_F12 ,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX    , KC_HOME,
    _______      ,XXXXXXX,XXXXXXX,KC_PSCR,KC_SLCK,KC_PAUS,KC_INS ,KC_APP ,KC_LGUI,KC_RGUI,XXXXXXX,_______ ,KC_PGUP,KC_END ,
    KC_RCTL  ,_______  ,_______,XXXXXXX              ,XXXXXXX          ,_______,_______  ,_______ ,KC_HOME,KC_PGDN,KC_END  
    ),
[2] = LAYOUT_48(
    KC_GRV ,KC_1   ,KC_2   ,KC_3   ,KC_4   ,KC_5   ,KC_6   ,KC_7   ,KC_8   ,KC_9   ,KC_0   ,KC_MINS,KC_EQL       , XXXXXXX,
    KC_TILD  ,KC_EXLM,KC_AT  ,KC_HASH,KC_DLR ,KC_PERC,KC_CIRC,KC_AMPR,KC_ASTR,KC_UNDS,KC_LBRC,KC_RBRC,KC_BSLS    , XXXXXXX,
    _______      ,ISO_LT ,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,_______ ,XXXXXXX,XXXXXXX,
    _______  ,_______  ,_______,XXXXXXX              ,XXXXXXX          ,_______,_______  ,_______ ,XXXXXXX,XXXXXXX,XXXXXXX 
    ),
[3] = LAYOUT_48(
    KC_TILD,KC_EXLM,KC_AT  ,KC_HASH,KC_DLR ,KC_PERC,KC_CIRC,KC_AMPR,KC_ASTR,KC_LPRN,KC_RPRN,KC_UNDS,KC_PLUS      , XXXXXXX,
    _______  ,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,KC_LCBR,KC_RCBR,KC_PIPE    , XXXXXXX,
    _______      ,ISO_GT ,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,_______ ,XXXXXXX,XXXXXXX,
    _______  ,_______  ,_______,XXXXXXX              ,XXXXXXX          ,_______,_______  ,_______ ,XXXXXXX,XXXXXXX,XXXXXXX 
    )
};

bool encoder_update_user(uint8_t index, bool clockwise) {
    
    if (index == 0) {
        if (clockwise) {
            tap_code(KC_VOLU);
        }
        else {
            tap_code(KC_VOLD);
        }
    }
    else if (index == 1) {
        if (clockwise) {
            if (!is_alt_tab_active) {
                is_alt_tab_active = true;
                register_code(KC_LALT);
            }
            alt_tab_timer = timer_read();
            tap_code16(KC_TAB);
        }
        else {
            alt_tab_timer = timer_read();
            tap_code16(S(KC_TAB));
        }
    }
    
    return false;
}

void matrix_scan_user(void) {
    
    if (is_alt_tab_active) {
        if (timer_elapsed(alt_tab_timer) > 1250) {
            unregister_code(KC_LALT);
            is_alt_tab_active = false;
        }
    }
}

A keyboards/nopunin10did/kastenwagen48/readme.md => keyboards/nopunin10did/kastenwagen48/readme.md +28 -0
@@ 0,0 1,28 @@
# Kastenwagen 48

![Kastenwagen 48](https://diplomacyvariants.files.wordpress.com/2022/01/kastenwagen-48-concept-art.png)

Kastenwagen 48 is a 40% keyboard with a macro column and dedicated arrows.  The main alpha block is 13.75u long, allowing for more dedicated punctuation keys to be paired with common Minivan-like mod keys.

A second model of Kastenwagen, the [Kastenwagen 1840](https://github.com/qmk/qmk_firmware/tree/master/keyboards/nopunin10did/kastenwagen1840), is similar but replaces the macro column with a mini-numpad.

Please note that the Kastenwagen 1840 via-compatible keymap firmware is also compatible with the Kastenwagen 48.  The Kastenwagen 48 does not have a dedicated via-compatible firmware.

For more information, join the [NoPunIn10Key Discord](https://discord.gg/sku2Y6w).

* Keyboard Maintainer: [Alex Ronke](diplomacyvariants.wordpress.com), also known as NoPunIn10Did. 
* Hardware Supported: Kastenwagen 48 (2021 June)
* Hardware Availability: Currently by request only

To jump the bootloader, either:
* If loaded with the default layout, use Function-Escape *(the function button is the farthest righthand 1.25u on the bottom row)* **OR**
* Use the physical reset switch on the Elite C **OR**
* Briefly jump the Reset and Ground pins of the Elite C
    
Make example for the 48 model:

    make nopunin10did/kastenwagen48:default48

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).

![Kastenwagen Default Layouts](https://diplomacyvariants.files.wordpress.com/2022/01/kastenwagen-default-layouts.png)
\ No newline at end of file

A keyboards/nopunin10did/kastenwagen48/rules.mk => keyboards/nopunin10did/kastenwagen48/rules.mk +20 -0
@@ 0,0 1,20 @@
# MCU name
MCU = atmega32u4

# Bootloader selection
BOOTLOADER = atmel-dfu

# Build Options
#   change yes to no to disable
#
BOOTMAGIC_ENABLE = yes      # Enable Bootmagic Lite
MOUSEKEY_ENABLE = yes       # Mouse keys
EXTRAKEY_ENABLE = yes       # Audio control and System control
CONSOLE_ENABLE = no         # Console for debug
COMMAND_ENABLE = no         # Commands for debug and configuration
NKRO_ENABLE = yes           # Enable N-Key Rollover
BACKLIGHT_ENABLE = no       # Enable keyboard backlight functionality
RGBLIGHT_ENABLE = no        # Enable keyboard RGB underglow
AUDIO_ENABLE = no           # Audio output

ENCODER_ENABLE = yes        # Enable rotary encoder input