1
0
Fork 0

Migrate hadron away from QWIIC_DRIVERS (#14415)

This commit is contained in:
Joel Challis 2021-09-13 14:59:53 +01:00 committed by GitHub
parent 8a3f97b20f
commit cb4346edb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 153 additions and 731 deletions

View file

@ -1,10 +1,4 @@
#include QMK_KEYBOARD_H
#ifdef USE_I2C
#include "i2c.h"
#endif
#ifdef SSD1306OLED
#include "ssd1306.h"
#endif
//Following line allows macro to read current RGB settings
extern rgblight_config_t rgblight_config;
@ -18,8 +12,8 @@ extern rgblight_config_t rgblight_config;
#define _DVORAK 2
#define _LOWER 3
#define _RAISE 4
#define _MOUSECURSOR 8
#define _ADJUST 16
#define _MOUSECURSOR 5
#define _ADJUST 6
enum preonic_keycodes {
QWERTY = SAFE_RANGE,
@ -307,115 +301,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return true;
}
//Functions for ver2
#ifdef KEYBOARD_hadron_ver2
#include <LUFA/Drivers/Peripheral/TWI.h>
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;
}
}
//assign the right code to your layers for OLED display
#define L_BASE 0
#define L_LOWER 8
#define L_RAISE 16
#define L_FNLAYER 64
#define L_NUMLAY 128
#define L_NLOWER 136
#define L_NFNLAYER 192
#define L_MOUSECURSOR 256
#define L_ADJUST 65560
void iota_gfx_task_user(void) {
#if DEBUG_TO_SCREEN
if (debug_enable) {
return;
}
#ifdef AUDIO_ENABLE
startup_user();
#endif
struct CharacterMatrix matrix;
matrix_clear(&matrix);
matrix_write_P(&matrix, PSTR("USB: "));
#ifdef PROTOCOL_LUFA
switch (USB_DeviceState) {
case DEVICE_STATE_Unattached:
matrix_write_P(&matrix, PSTR("Unattached"));
break;
case DEVICE_STATE_Suspended:
matrix_write_P(&matrix, PSTR("Suspended"));
break;
case DEVICE_STATE_Configured:
matrix_write_P(&matrix, PSTR("Connected"));
break;
case DEVICE_STATE_Powered:
matrix_write_P(&matrix, PSTR("Powered"));
break;
case DEVICE_STATE_Default:
matrix_write_P(&matrix, PSTR("Default"));
break;
case DEVICE_STATE_Addressed:
matrix_write_P(&matrix, PSTR("Addressed"));
break;
default:
matrix_write_P(&matrix, PSTR("Invalid"));
}
#endif
// Define layers here, Have not worked out how to have text displayed for each layer. Copy down the number you see and add a case for it below
char buf[40];
snprintf(buf,sizeof(buf), "Undef-%ld", layer_state);
matrix_write_P(&matrix, PSTR("\n\nLayer: "));
switch (layer_state) {
case L_BASE:
matrix_write_P(&matrix, PSTR("Default"));
break;
case L_RAISE:
matrix_write_P(&matrix, PSTR("Raise"));
break;
case L_LOWER:
matrix_write_P(&matrix, PSTR("Lower"));
break;
case L_ADJUST:
matrix_write_P(&matrix, PSTR("ADJUST"));
break;
default:
matrix_write(&matrix, buf);
}
// Host Keyboard LED Status
char led[40];
snprintf(led, sizeof(led), "\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);
}
#endif