99 changes: 23 additions & 76 deletions keyboards/tkc1800/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@
* 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
#include "LUFA/Drivers/Peripheral/TWI.h"
#include "i2c.h"
#include "ssd1306.h"


//Layers

Expand All @@ -26,13 +23,6 @@ enum {
FUNCTION,
};

bool screenWorks = 0;

//13 characters max without re-writing the "Layer: " format in iota_gfx_task_user()
static char layer_lookup[][14] = {"Base","Function"};



const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Keymap BASE: (Base Layer) Default Layer
* ,-------------------------------------------------------. ,-------------------.
Expand Down Expand Up @@ -88,72 +78,29 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
),
};

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return true;
}

void led_set_user(uint8_t usb_led) {

}

void matrix_init_user(void) {
#ifdef USE_I2C
i2c_master_init();
#ifdef SSD1306OLED
// calls code for the SSD1306 OLED
_delay_ms(400);
TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 800000));
if ( iota_gfx_init() ) { // turns on the display
screenWorks = 1;
}
#endif
#endif
#ifdef AUDIO_ENABLE
startup_user();
#endif
}

void matrix_scan_user(void) {
#ifdef SSD1306OLED
if ( screenWorks ) {
iota_gfx_task(); // this is what updates the display continuously
};
#endif
}

void matrix_update(struct CharacterMatrix *dest,
const struct CharacterMatrix *source) {
if (memcmp(dest->display, source->display, sizeof(dest->display))) {
memcpy(dest->display, source->display, sizeof(dest->display));
dest->dirty = true;
}
}

void iota_gfx_task_user(void) {
#if DEBUG_TO_SCREEN
if (debug_enable) {
return;
#ifdef OLED_DRIVER_ENABLE
void oled_task_user(void) {
oled_write_P(PSTR("TKC1800\n"),false);
// Host Keyboard Layer Status
oled_write_P(PSTR("Layer: "), false);

switch (get_highest_layer(layer_state)) {
case BASE:
oled_write_P(PSTR("Base\n"), false);
break;
case FUNCTION:
oled_write_P(PSTR("Function\n"), false);
break;
default:
// Or use the write_ln shortcut over adding '\n' to the end of your string
oled_write_ln_P(PSTR("Undefined"), false);
}
#endif

struct CharacterMatrix matrix;

matrix_clear(&matrix);
matrix_write_P(&matrix, PSTR("TKC1800"));

uint8_t layer = biton32(layer_state);

char buf[40];
snprintf(buf,sizeof(buf), "Undef-%d", layer);
matrix_write_P(&matrix, PSTR("\nLayer: "));
matrix_write(&matrix, layer_lookup[layer]);

// Host Keyboard LED Status
char led[40];
snprintf(led, sizeof(led), "\n\n%s %s %s",
(host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ",
(host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ",
(host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " ");
matrix_write(&matrix, led);
matrix_update(&display, &matrix);
// Host Keyboard LED Status
led_t led_state = host_keyboard_led_state();
oled_write_P(led_state.num_lock ? PSTR("NUM ") : PSTR(" "), false);
oled_write_P(led_state.caps_lock ? PSTR("CAP ") : PSTR(" "), false);
oled_write_P(led_state.scroll_lock ? PSTR("SCR ") : PSTR(" "), false);
}
#endif
24 changes: 0 additions & 24 deletions keyboards/tkc1800/keymaps/smt/config.h

This file was deleted.

95 changes: 29 additions & 66 deletions keyboards/tkc1800/keymaps/smt/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
* 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
#include "LUFA/Drivers/Peripheral/TWI.h"
#include "i2c.h"
#include "ssd1306.h"

// Custom macros
#define CTL_ESC CTL_T(KC_ESC) // Tap for Esc, hold for Ctrl
Expand All @@ -32,11 +30,6 @@ enum {
FUNCTION,
};

//13 characters max without re-writing the "Layer: " format in iota_gfx_task_user()
static char layer_lookup[][14] = {"Qwerty","Dvorak","Function"};



const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Keymap QWERTY: (Qwerty Layer) Default Layer
* ,-------------------------------------------------------. ,-------------------.
Expand Down Expand Up @@ -151,64 +144,34 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return true;
}

void led_set_user(uint8_t usb_led) {

}

void matrix_init_user(void) {
#ifdef USE_I2C
i2c_master_init();
#ifdef SSD1306OLED
// calls code for the SSD1306 OLED
_delay_ms(400);
TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 800000));
iota_gfx_init(); // turns on the display
#endif
#endif
#ifdef AUDIO_ENABLE
startup_user();
#endif
}

void matrix_scan_user(void) {
#ifdef SSD1306OLED
iota_gfx_task(); // this is what updates the display continuously
#endif
}

void matrix_update(struct CharacterMatrix *dest,
const struct CharacterMatrix *source) {
if (memcmp(dest->display, source->display, sizeof(dest->display))) {
memcpy(dest->display, source->display, sizeof(dest->display));
dest->dirty = true;
}
}

void iota_gfx_task_user(void) {
#if DEBUG_TO_SCREEN
if (debug_enable) {
return;
#ifdef OLED_DRIVER_ENABLE
void oled_task_user(void) {
oled_write_P(PSTR("TKC1800\n"),false);
// Host Keyboard Layer Status
oled_write_P(PSTR("Layer: "), false);

switch (get_highest_layer(layer_state)) {
case QWERTY:
oled_write_P(PSTR("Base\n"), false);
break;
case COLEMAK:
oled_write_P(PSTR("Colemak\n"), false);
break;
case DVORAK:
oled_write_P(PSTR("Dvorak\n"), false);
break;
case FUNCTION:
oled_write_P(PSTR("Function\n"), false);
break;
default:
// Or use the write_ln shortcut over adding '\n' to the end of your string
oled_write_ln_P(PSTR("Undefined"), false);
}
#endif

struct CharacterMatrix matrix;

matrix_clear(&matrix);
matrix_write_P(&matrix, PSTR("TKC1800"));

uint8_t layer = biton32(layer_state);

char buf[40];
snprintf(buf,sizeof(buf), "Undef-%d", layer);
matrix_write_P(&matrix, PSTR("\nLayer: "));
matrix_write(&matrix, layer_lookup[layer]);

// Host Keyboard LED Status
char led[40];
snprintf(led, sizeof(led), "\n\n%s %s %s",
(host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ",
(host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ",
(host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " ");
matrix_write(&matrix, led);
matrix_update(&display, &matrix);
// Host Keyboard LED Status
led_t led_state = host_keyboard_led_state();
oled_write_P(led_state.num_lock ? PSTR("NUM ") : PSTR(" "), false);
oled_write_P(led_state.caps_lock ? PSTR("CAP ") : PSTR(" "), false);
oled_write_P(led_state.scroll_lock ? PSTR("SCR ") : PSTR(" "), false);
}
#endif
99 changes: 22 additions & 77 deletions keyboards/tkc1800/keymaps/via/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include QMK_KEYBOARD_H
#include "LUFA/Drivers/Peripheral/TWI.h"
#include "i2c.h"
#include "ssd1306.h"


//Layers

Expand All @@ -26,13 +22,6 @@ enum {
FUNCTION,
};

bool screenWorks = 0;

//13 characters max without re-writing the "Layer: " format in iota_gfx_task_user()
static char layer_lookup[][14] = {"Base","Function"};



const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Keymap BASE: (Base Layer) Default Layer
* ,-------------------------------------------------------. ,-------------------.
Expand Down Expand Up @@ -88,72 +77,28 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
),
};

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return true;
}

void led_set_user(uint8_t usb_led) {

}

void matrix_init_user(void) {
#ifdef USE_I2C
i2c_master_init();
#ifdef SSD1306OLED
// calls code for the SSD1306 OLED
_delay_ms(400);
TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 800000));
if ( iota_gfx_init() ) { // turns on the display
screenWorks = 1;
}
#endif
#endif
#ifdef AUDIO_ENABLE
startup_user();
#endif
}

void matrix_scan_user(void) {
#ifdef SSD1306OLED
if ( screenWorks ) {
iota_gfx_task(); // this is what updates the display continuously
};
#endif
}

void matrix_update(struct CharacterMatrix *dest,
const struct CharacterMatrix *source) {
if (memcmp(dest->display, source->display, sizeof(dest->display))) {
memcpy(dest->display, source->display, sizeof(dest->display));
dest->dirty = true;
}
}

void iota_gfx_task_user(void) {
#if DEBUG_TO_SCREEN
if (debug_enable) {
return;
#ifdef OLED_DRIVER_ENABLE
void oled_task_user(void) {
oled_write_P(PSTR("TKC1800\n"),false);
// Host Keyboard Layer Status
oled_write_P(PSTR("Layer: "), false);

switch (get_highest_layer(layer_state)) {
case BASE:
oled_write_P(PSTR("Base\n"), false);
break;
case FUNCTION:
oled_write_P(PSTR("Function\n"), false);
break;
default:
// Or use the write_ln shortcut over adding '\n' to the end of your string
oled_write_ln_P(PSTR("Undefined"), false);
}
#endif

struct CharacterMatrix matrix;

matrix_clear(&matrix);
matrix_write_P(&matrix, PSTR("TKC1800"));

uint8_t layer = biton32(layer_state);

char buf[40];
snprintf(buf,sizeof(buf), "Undef-%d", layer);
matrix_write_P(&matrix, PSTR("\nLayer: "));
matrix_write(&matrix, layer_lookup[layer]);

// Host Keyboard LED Status
char led[40];
snprintf(led, sizeof(led), "\n\n%s %s %s",
(host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ",
(host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ",
(host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " ");
matrix_write(&matrix, led);
matrix_update(&display, &matrix);
// Host Keyboard LED Status
led_t led_state = host_keyboard_led_state();
oled_write_P(led_state.num_lock ? PSTR("NUM ") : PSTR(" "), false);
oled_write_P(led_state.caps_lock ? PSTR("CAP ") : PSTR(" "), false);
oled_write_P(led_state.scroll_lock ? PSTR("SCR ") : PSTR(" "), false);
}
#endif
24 changes: 0 additions & 24 deletions keyboards/tkc1800/keymaps/wkl/config.h

This file was deleted.

100 changes: 23 additions & 77 deletions keyboards/tkc1800/keymaps/wkl/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@
* 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
#include "LUFA/Drivers/Peripheral/TWI.h"
#include "i2c.h"
#include "ssd1306.h"


//Layers

Expand All @@ -26,13 +23,6 @@ enum {
FUNCTION,
};

bool screenWorks = 0;

//13 characters max without re-writing the "Layer: " format in iota_gfx_task_user()
static char layer_lookup[][14] = {"Base","Function"};



const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Keymap BASE: (Base Layer) Default Layer
* ,-------------------------------------------------------. ,-------------------.
Expand Down Expand Up @@ -71,72 +61,28 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
),
};

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return true;
}

void led_set_user(uint8_t usb_led) {

}

void matrix_init_user(void) {
#ifdef USE_I2C
i2c_master_init();
#ifdef SSD1306OLED
// calls code for the SSD1306 OLED
_delay_ms(400);
TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 800000));
if ( iota_gfx_init() ) { // turns on the display
screenWorks = 1;
}
#endif
#endif
#ifdef AUDIO_ENABLE
startup_user();
#endif
}

void matrix_scan_user(void) {
#ifdef SSD1306OLED
if ( screenWorks ) {
iota_gfx_task(); // this is what updates the display continuously
};
#endif
}

void matrix_update(struct CharacterMatrix *dest,
const struct CharacterMatrix *source) {
if (memcmp(dest->display, source->display, sizeof(dest->display))) {
memcpy(dest->display, source->display, sizeof(dest->display));
dest->dirty = true;
}
}

void iota_gfx_task_user(void) {
#if DEBUG_TO_SCREEN
if (debug_enable) {
return;
#ifdef OLED_DRIVER_ENABLE
void oled_task_user(void) {
oled_write_P(PSTR("TKC1800\n"),false);
// Host Keyboard Layer Status
oled_write_P(PSTR("Layer: "), false);

switch (get_highest_layer(layer_state)) {
case BASE:
oled_write_P(PSTR("Base\n"), false);
break;
case FUNCTION:
oled_write_P(PSTR("Function\n"), false);
break;
default:
// Or use the write_ln shortcut over adding '\n' to the end of your string
oled_write_ln_P(PSTR("Undefined"), false);
}
#endif

struct CharacterMatrix matrix;

matrix_clear(&matrix);
matrix_write_P(&matrix, PSTR("TKC1800"));

uint8_t layer = biton32(layer_state);

char buf[40];
snprintf(buf,sizeof(buf), "Undef-%d", layer);
matrix_write_P(&matrix, PSTR("\nLayer: "));
matrix_write(&matrix, layer_lookup[layer]);

// Host Keyboard LED Status
char led[40];
snprintf(led, sizeof(led), "\n\n%s %s %s",
(host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ",
(host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ",
(host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " ");
matrix_write(&matrix, led);
matrix_update(&display, &matrix);
// Host Keyboard LED Status
led_t led_state = host_keyboard_led_state();
oled_write_P(led_state.num_lock ? PSTR("NUM ") : PSTR(" "), false);
oled_write_P(led_state.caps_lock ? PSTR("CAP ") : PSTR(" "), false);
oled_write_P(led_state.scroll_lock ? PSTR("SCR ") : PSTR(" "), false);
}
#endif
24 changes: 0 additions & 24 deletions keyboards/tkc1800/keymaps/yanfali/config.h

This file was deleted.

94 changes: 23 additions & 71 deletions keyboards/tkc1800/keymaps/yanfali/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@
* 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
#include "LUFA/Drivers/Peripheral/TWI.h"
#include "i2c.h"
#include "ssd1306.h"


//Layers

Expand All @@ -26,11 +23,6 @@ enum {
FUNCTION,
};

//13 characters max without re-writing the "Layer: " format in iota_gfx_task_user()
static char layer_lookup[][14] = {"Base","Function"};



const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Keymap BASE: (Base Layer) Default Layer
* ,-------------------------------------------------------. ,-------------------.
Expand Down Expand Up @@ -69,68 +61,28 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
),
};

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return true;
}

void led_set_user(uint8_t usb_led) {

}

void matrix_init_user(void) {
#ifdef USE_I2C
i2c_master_init();
#ifdef SSD1306OLED
// calls code for the SSD1306 OLED
_delay_ms(400);
TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 800000));
iota_gfx_init(); // turns on the display
#endif
#endif
#ifdef AUDIO_ENABLE
startup_user();
#endif
}

void matrix_scan_user(void) {
#ifdef SSD1306OLED
iota_gfx_task(); // this is what updates the display continuously
#endif
}

void matrix_update(struct CharacterMatrix *dest,
const struct CharacterMatrix *source) {
if (memcmp(dest->display, source->display, sizeof(dest->display))) {
memcpy(dest->display, source->display, sizeof(dest->display));
dest->dirty = true;
}
}

void iota_gfx_task_user(void) {
#if DEBUG_TO_SCREEN
if (debug_enable) {
return;
#ifdef OLED_DRIVER_ENABLE
void oled_task_user(void) {
oled_write_P(PSTR("TKC1800\n"),false);
// Host Keyboard Layer Status
oled_write_P(PSTR("Layer: "), false);

switch (get_highest_layer(layer_state)) {
case BASE:
oled_write_P(PSTR("Base\n"), false);
break;
case FUNCTION:
oled_write_P(PSTR("Function\n"), false);
break;
default:
// Or use the write_ln shortcut over adding '\n' to the end of your string
oled_write_ln_P(PSTR("Undefined"), false);
}
#endif

struct CharacterMatrix matrix;

matrix_clear(&matrix);
matrix_write_P(&matrix, PSTR("TKC1800"));

uint8_t layer = biton32(layer_state);

char buf[40];
snprintf(buf,sizeof(buf), "Undef-%d", layer);
matrix_write_P(&matrix, PSTR("\nLayer: "));
matrix_write(&matrix, layer_lookup[layer]);

// Host Keyboard LED Status
char led[40];
snprintf(led, sizeof(led), "\n\n%s %s %s",
(host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ",
(host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ",
(host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " ");
matrix_write(&matrix, led);
matrix_update(&display, &matrix);
// Host Keyboard LED Status
led_t led_state = host_keyboard_led_state();
oled_write_P(led_state.num_lock ? PSTR("NUM ") : PSTR(" "), false);
oled_write_P(led_state.caps_lock ? PSTR("CAP ") : PSTR(" "), false);
oled_write_P(led_state.scroll_lock ? PSTR("SCR ") : PSTR(" "), false);
}
#endif
9 changes: 4 additions & 5 deletions keyboards/tkc1800/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ MCU = at90usb1286
# QMK DFU qmk-dfu
# ATmega32A bootloadHID
# ATmega328P USBasp
BOOTLOADER = atmel-dfu
BOOTLOADER = qmk-dfu
Copy link
Contributor

@yanfali yanfali Mar 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with the keymap changes. This looks like a much cleaner way to disable i2c, which is incompatible with console logging if you didn't have the OLED.

My only concern here is that all the older PCBs in existence, are still be running atmel-dfu, which has a slightly different behavior around erasure. Usually how this handled is PCB rev folders. I haven't tested what happens if I try to RESET with the bootloader set to qmk-dfu instead of atmel-dfu.

I can certainly add a rules.mk override so this isn't a blocker, more of a technical question. I can also ISP flash my pcb and add qmk-dfu.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yanfali I've tested it, works without issue. Having the QMK code setup for qmk-dfu works correctly whether the bootloader is qmk-dfu or atmel-dfu.


# Build Options
# change yes to no to disable
#
BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration

BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration
MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = no # Console for debug
Expand All @@ -29,6 +30,4 @@ 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

SRC = i2c.c \
ssd1306.c
OLED_DRIVER_ENABLE = yes
7 changes: 7 additions & 0 deletions keyboards/tkc1800/tkc1800.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
#include "tkc1800.h"
#include "led.h"

void keyboard_pre_init_kb(void) {
setPinInputHigh(D0);
setPinInputHigh(D1);

keyboard_pre_init_user();
}

void matrix_init_kb(void) {
// put your keyboard start-up code here
// runs once when the firmware starts up
Expand Down