summaryrefslogtreecommitdiffstats
path: root/keyboards
diff options
context:
space:
mode:
authorRyan Caltabiano <rcalt2vt@gmail.com>2019-04-15 22:32:57 -0500
committerskullydazed <skullydazed@users.noreply.github.com>2019-04-20 08:05:10 -0700
commit0a645225b9c863a106921185a6c2e0c340f10694 (patch)
tree2bf8c295650e54fb4548a7ac4d348ccfc8caa307 /keyboards
parentb5cb5ec6ddb15cfe336b835055f546f72d440a66 (diff)
OLED Driver Feature
Diffstat (limited to 'keyboards')
-rw-r--r--keyboards/cannonkeys/satisfaction75/i2c_master.c46
-rw-r--r--keyboards/sol/common/glcdfont.c140
-rw-r--r--keyboards/sol/common/ssd1306.c329
-rw-r--r--keyboards/sol/common/ssd1306.h92
-rw-r--r--keyboards/sol/i2c.c162
-rw-r--r--keyboards/sol/i2c.h49
-rwxr-xr-xkeyboards/sol/keymaps/brianweyer/config.h2
-rwxr-xr-xkeyboards/sol/keymaps/brianweyer/keymap.c146
-rwxr-xr-xkeyboards/sol/keymaps/brianweyer/rules.mk14
-rw-r--r--keyboards/sol/keymaps/danielhklein/keymap.c145
-rw-r--r--keyboards/sol/keymaps/danielhklein/rules.mk8
-rw-r--r--keyboards/sol/keymaps/default/keymap.c145
-rw-r--r--keyboards/sol/keymaps/default/rules.mk8
-rw-r--r--keyboards/sol/keymaps/kageurufu/rules.mk7
-rw-r--r--keyboards/sol/rev1/config.h6
-rw-r--r--keyboards/sol/rev1/rev1.c7
-rw-r--r--keyboards/sol/rev1/split_util.h2
-rw-r--r--keyboards/sol/rules.mk7
18 files changed, 271 insertions, 1044 deletions
diff --git a/keyboards/cannonkeys/satisfaction75/i2c_master.c b/keyboards/cannonkeys/satisfaction75/i2c_master.c
index d81eb92d49..ce0e0a7ba1 100644
--- a/keyboards/cannonkeys/satisfaction75/i2c_master.c
+++ b/keyboards/cannonkeys/satisfaction75/i2c_master.c
@@ -29,8 +29,6 @@
#include "quantum.h"
#include <string.h>
#include <hal.h>
-#include "chtypes.h"
-#include "ch.h"
static uint8_t i2c_address;
@@ -44,6 +42,18 @@ static const I2CConfig i2cconfig = {
0
};
+static i2c_status_t chibios_to_qmk(const msg_t* status) {
+ switch (*status) {
+ case I2C_NO_ERROR:
+ return I2C_STATUS_SUCCESS;
+ case I2C_TIMEOUT:
+ return I2C_STATUS_TIMEOUT;
+ // I2C_BUS_ERROR, I2C_ARBITRATION_LOST, I2C_ACK_FAILURE, I2C_OVERRUN, I2C_PEC_ERROR, I2C_SMB_ALERT
+ default:
+ return I2C_STATUS_ERROR;
+ }
+}
+
__attribute__ ((weak))
void i2c_init(void)
{
@@ -59,34 +69,32 @@ void i2c_init(void)
//i2cInit(); //This is invoked by halInit() so no need to redo it.
}
-// This is usually not needed
-uint8_t i2c_start(uint8_t address)
+i2c_status_t i2c_start(uint8_t address)
{
i2c_address = address;
i2cStart(&I2C_DRIVER, &i2cconfig);
- return 0;
+ return I2C_STATUS_SUCCESS;
}
-uint8_t i2c_transmit(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout)
+i2c_status_t i2c_transmit(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout)
{
- msg_t status = MSG_OK;
-
i2c_address = address;
i2cStart(&I2C_DRIVER, &i2cconfig);
i2cAcquireBus(&I2C_DRIVER);
- status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), data, length, 0, 0, MS2ST(timeout));
+ msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), data, length, 0, 0, MS2ST(timeout));
i2cReleaseBus(&I2C_DRIVER);
- return status;
+ return chibios_to_qmk(&status);
}
-uint8_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout)
+i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout)
{
i2c_address = address;
i2cStart(&I2C_DRIVER, &i2cconfig);
- return i2cMasterReceiveTimeout(&I2C_DRIVER, (i2c_address >> 1), data, length, MS2ST(timeout));
+ msg_t status = i2cMasterReceiveTimeout(&I2C_DRIVER, (i2c_address >> 1), data, length, MS2ST(timeout));
+ return chibios_to_qmk(&status);
}
-uint8_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)
+i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout)
{
i2c_address = devaddr;
i2cStart(&I2C_DRIVER, &i2cconfig);
@@ -98,19 +106,19 @@ uint8_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t l
}
complete_packet[0] = regaddr;
- return i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), complete_packet, length + 1, 0, 0, MS2ST(timeout));
+ msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), complete_packet, length + 1, 0, 0, MS2ST(timeout));
+ return chibios_to_qmk(&status);
}
-uint8_t i2c_readReg(uint8_t devaddr, uint8_t* regaddr, uint8_t* data, uint16_t length, uint16_t timeout)
+i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t* regaddr, uint8_t* data, uint16_t length, uint16_t timeout)
{
i2c_address = devaddr;
i2cStart(&I2C_DRIVER, &i2cconfig);
- return i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), regaddr, 1, data, length, MS2ST(timeout));
+ msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), regaddr, 1, data, length, MS2ST(timeout));
+ return chibios_to_qmk(&status);
}
-// This is usually not needed. It releases the driver to allow pins to become GPIO again.
-uint8_t i2c_stop(void)
+void i2c_stop(void)
{
i2cStop(&I2C_DRIVER);
- return 0;
}
diff --git a/keyboards/sol/common/glcdfont.c b/keyboards/sol/common/glcdfont.c
index 89665ba074..f772e31811 100644
--- a/keyboards/sol/common/glcdfont.c
+++ b/keyboards/sol/common/glcdfont.c
@@ -1,8 +1,4 @@
-// This is the 'classic' fixed-space bitmap font for Adafruit_GFX since 1.0.
-// See gfxfont.h for newer custom bitmap font info.
-
-#ifndef FONT5X7_H
-#define FONT5X7_H
+#pragma once
#ifdef __AVR__
#include <avr/io.h>
@@ -13,7 +9,8 @@
#define PROGMEM
#endif
-// Standard ASCII 5x7 font
+// Helidox 8x6 font with RGBKB SOL Logo
+// Online editor: http://teripom.x0.com/
static const unsigned char font[] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -144,27 +141,27 @@ static const unsigned char font[] PROGMEM = {
0x00, 0x41, 0x36, 0x08, 0x00, 0x00,
0x02, 0x01, 0x02, 0x04, 0x02, 0x00,
0x3C, 0x26, 0x23, 0x26, 0x3C, 0x00,
- 0x03, 0x07, 0x1F, 0x7F, 0xFF, 0xFF,
- 0xFE, 0xF8, 0xF0, 0xC0, 0x20, 0xF8,
- 0xFE, 0xFF, 0xFE, 0x79, 0x27, 0x1F,
- 0x7F, 0xFF, 0xFF, 0xFE, 0xF8, 0xF0,
- 0xC0, 0x20, 0xF8, 0xFE, 0xFF, 0xFF,
- 0x7F, 0x3F, 0x3F, 0x7F, 0xFF, 0xFE,
- 0xF8, 0xF0, 0xC0, 0x00, 0x00, 0x00,
- 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xFF, 0x7F, 0x7F, 0x7F,
- 0xBF, 0xBF, 0xC0, 0xC0, 0xC0, 0xE0,
- 0xE0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF0,
- 0xF8, 0x78, 0x78, 0x7C, 0x3C, 0x3C,
- 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x00,
+ 0x00, 0x00, 0x00, 0x80, 0x80, 0x80,
0x00, 0x00, 0x00, 0x00, 0x80, 0x80,
- 0xBF, 0xBF, 0xDF, 0xDF, 0xEF, 0xEF,
- 0x00, 0x03, 0x07, 0x1F, 0x7F, 0xFF,
- 0xFF, 0xFF, 0xFE, 0xF8, 0xE0, 0xC0,
- 0xE0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF,
- 0x7F, 0x1F, 0x07, 0x03, 0x00, 0x00,
+ 0x80, 0x80, 0x80, 0x80, 0x80, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x0C, 0x90,
+ 0xB0, 0xE0, 0x72, 0x31, 0x9B, 0xDE,
+ 0xCE, 0xEC, 0xEE, 0xE9, 0xE9, 0xEC,
+ 0xCF, 0xDA, 0x99, 0x3E, 0x62, 0xE4,
+ 0xC4, 0x70, 0x10, 0x10, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x60,
+ 0xC0, 0xC0, 0x80, 0x80, 0x02, 0x85,
+ 0x85, 0x87, 0x85, 0x89, 0x89, 0x92,
+ 0xEA, 0xC6, 0xC4, 0x48, 0x50, 0x60,
+ 0x40, 0x40, 0x40, 0x40, 0xC0, 0xE0,
+ 0x50, 0x28, 0x10, 0x10, 0x60, 0xC0,
+ 0x40, 0x40, 0x40, 0x40, 0x80, 0x80,
+ 0x80, 0x80, 0x80, 0xE0, 0xF8, 0xFC,
+ 0xF8, 0xF0, 0x00, 0x00, 0x00, 0x00,
0xE0, 0xF0, 0xF0, 0xF0, 0xE0, 0xEC,
0xEE, 0xF7, 0xF3, 0x70, 0x20, 0x00,
0x7C, 0x7C, 0x7C, 0x7E, 0x00, 0x7E,
@@ -173,30 +170,30 @@ static const unsigned char font[] PROGMEM = {
0x4F, 0x5B, 0xFE, 0xC0, 0x00, 0x00,
0xC0, 0x00, 0xDC, 0xD7, 0xDE, 0xDE,
0xDE, 0xD7, 0xDC, 0x00, 0xC0, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xC1, 0xF3,
- 0xCF, 0xBF, 0x7F, 0xFF, 0xFF, 0xFC,
- 0xFB, 0xE7, 0x81, 0x00, 0x00, 0x00,
- 0x00, 0x80, 0xE3, 0xCF, 0x3F, 0xFF,
- 0xFF, 0xFF, 0xFC, 0xFB, 0xE7, 0x81,
- 0x00, 0x00, 0x00, 0x00, 0x81, 0xE7,
- 0xFF, 0xFF, 0xFF, 0xFF, 0x3C, 0x00,
- 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xF8, 0xF8, 0xFC, 0x7C, 0x7E,
- 0x7E, 0x3E, 0xFE, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xF7, 0xF7, 0xF7, 0xFB,
- 0xFB, 0x7D, 0x7D, 0x7D, 0xBE, 0xBE,
- 0xBE, 0xDF, 0xDF, 0xE0, 0xE0, 0x00,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x00, 0xFC, 0xFC, 0x7C, 0x7E, 0x7E,
- 0x3E, 0x3E, 0x1F, 0x1F, 0x1F, 0x0F,
+ 0x00, 0x00, 0x00, 0xE0, 0xEC, 0xDF,
+ 0xFC, 0xE0, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x7F, 0x80, 0x80,
+ 0x80, 0x70, 0x0F, 0x00, 0x00, 0x80,
+ 0x7F, 0x00, 0x00, 0x7F, 0x80, 0x80,
+ 0x80, 0x80, 0x80, 0x80, 0x80, 0x7F,
+ 0x00, 0x00, 0x80, 0x80, 0x80, 0x80,
+ 0x80, 0x80, 0x80, 0xFF, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x40, 0x21, 0x33, 0x3B, 0x7B,
+ 0xFF, 0x00, 0x7C, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x81,
- 0xE7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xE7, 0x81,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0x7C, 0x01,
+ 0xFF, 0xDE, 0x8C, 0x04, 0x0C, 0x08,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x01, 0x01, 0x01, 0x7F, 0x80,
+ 0x80, 0xBE, 0xBE, 0x80, 0x80, 0x80,
+ 0xC1, 0xFF, 0x80, 0x04, 0x32, 0x5E,
+ 0x1C, 0x3D, 0x26, 0x10, 0xC1, 0xFF,
+ 0x3E, 0x00, 0x00, 0x08, 0x36, 0xC1,
+ 0x08, 0x08, 0x14, 0x77, 0x94, 0x94,
+ 0x94, 0xF7, 0x94, 0xF7, 0x9C, 0x9C,
+ 0xFF, 0xFF, 0x1E, 0x00, 0x00, 0x00,
0x0F, 0x1F, 0x3F, 0x7F, 0x7F, 0x7F,
0x7F, 0x7F, 0x3F, 0x1E, 0x0C, 0x00,
0x1F, 0x1F, 0x1F, 0x3F, 0x00, 0x3F,
@@ -205,30 +202,31 @@ static const unsigned char font[] PROGMEM = {
0x20, 0x30, 0x78, 0x7F, 0x3B, 0x00,
0x03, 0x00, 0x0F, 0x7F, 0x0F, 0x0F,
0x0F, 0x7F, 0x0F, 0x00, 0x03, 0x00,
+ 0x40, 0x7C, 0x3F, 0x3F, 0x23, 0x01,
+ 0x23, 0x3F, 0x37, 0x6C, 0x40, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x06, 0x02, 0x06,
+ 0x4D, 0x4F, 0x8C, 0xF9, 0x73, 0x37,
+ 0x27, 0x2F, 0x2F, 0xAF, 0xEF, 0x6F,
+ 0x77, 0x17, 0x33, 0x79, 0xCC, 0x1F,
+ 0x31, 0x20, 0x21, 0x02, 0x02, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x40, 0xE0,
+ 0xA0, 0xA0, 0xD0, 0x90, 0x48, 0x48,
+ 0x25, 0x2B, 0x11, 0x09, 0x05, 0x03,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x03, 0x02, 0x04, 0x03, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0x03, 0x0F, 0x1F,
+ 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x60, 0x70, 0x7C, 0x7F, 0x7F, 0x7F,
- 0x7F, 0x1F, 0x06, 0x01, 0x03, 0x0F,
- 0x3F, 0x7F, 0x7F, 0x7E, 0x7C, 0x7C,
- 0x7E, 0x7F, 0x7F, 0x7F, 0x1F, 0x06,
- 0x01, 0x07, 0x0F, 0x3F, 0x7F, 0x7F,
- 0x7E, 0x7C, 0x7C, 0x7E, 0x7F, 0x7F,
- 0x3F, 0x0F, 0x03, 0x00, 0x00, 0x00,
- 0x00, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
- 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x7F, 0x7F, 0x7F, 0x7F,
- 0x7F, 0x7F, 0x7D, 0x7D, 0x3D, 0x3E,
- 0x1E, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F,
- 0x07, 0x07, 0x07, 0x03, 0x03, 0x00,
- 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
- 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C,
- 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x00,
- 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
- 0x00, 0x40, 0x70, 0x78, 0x7E, 0x7F,
- 0x7F, 0x7F, 0x3F, 0x0F, 0x03, 0x01,
- 0x03, 0x0F, 0x3F, 0x7F, 0x7F, 0x7F,
- 0x7E, 0x78, 0x70, 0x40, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -239,6 +237,4 @@ static const unsigned char font[] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
-#endif // FONT5X7_H
diff --git a/keyboards/sol/common/ssd1306.c b/keyboards/sol/common/ssd1306.c
deleted file mode 100644
index b3e55a67c2..0000000000
--- a/keyboards/sol/common/ssd1306.c
+++ /dev/null
@@ -1,329 +0,0 @@
-#ifdef SSD1306OLED
-
-#include "ssd1306.h"
-#include "i2c.h"
-#include <string.h>
-#include "print.h"
-#ifndef LOCAL_GLCDFONT
-#include "common/glcdfont.c"
-#else
-#include <helixfont.h>
-#endif
-#ifdef ADAFRUIT_BLE_ENABLE
-#include "adafruit_ble.h"
-#endif
-#ifdef PROTOCOL_LUFA
-#include "lufa.h"
-#endif
-#include "sendchar.h"
-#include "timer.h"
-
-// Set this to 1 to help diagnose early startup problems
-// when testing power-on with ble. Turn it off otherwise,
-// as the latency of printing most of the debug info messes
-// with the matrix scan, causing keys to drop.
-#define DEBUG_TO_SCREEN 0
-
-//static uint16_t last_battery_update;
-//static uint32_t vbat;
-//#define BatteryUpdateInterval 10000 /* milliseconds */
-#define ScreenOffInterval 300000 /* milliseconds */
-#if DEBUG_TO_SCREEN
-static uint8_t displaying;
-#endif
-static uint16_t last_flush;
-
-// Write command sequence.
-// Returns true on success.
-static inline bool _send_cmd1(uint8_t cmd) {
- bool res = false;
-
- if (i2c_start_write(SSD1306_ADDRESS)) {
- xprintf("failed to start write to %d\n", SSD1306_ADDRESS);
- goto done;
- }
-
- if (i2c_master_write(0x0 /* command byte follows */)) {
- print("failed to write control byte\n");
-
- goto done;
- }
-
- if (i2c_master_write(cmd)) {
- xprintf("failed to write command %d\n", cmd);
- goto done;
- }
- res = true;
-done:
- i2c_master_stop();
- return res;
-}
-
-// Write 2-byte command sequence.
-// Returns true on success
-static inline bool _send_cmd2(uint8_t cmd, uint8_t opr) {
- if (!_send_cmd1(cmd)) {
- return false;
- }
- return _send_cmd1(opr);
-}
-
-// Write 3-byte command sequence.
-// Returns true on success
-static inline bool _send_cmd3(uint8_t cmd, uint8_t opr1, uint8_t opr2) {
- if (!_send_cmd1(cmd)) {
- return false;
- }
- if (!_send_cmd1(opr1)) {
- return false;
- }
- return _send_cmd1(opr2);
-}
-
-#define send_cmd1(c) if (!_send_cmd1(c)) {goto done;}
-#define send_cmd2(c,o) if (!_send_cmd2(c,o)) {goto done;}
-#define send_cmd3(c,o1,o2) if (!_send_cmd3(c,o1,o2)) {goto done;}
-
-static void clear_display(void) {
- matrix_clear(&display);
-
- // Clear all of the display bits (there can be random noise
- // in the RAM on startup)
- send_cmd3(PageAddr, 0, (DisplayHeight / 8) - 1);
- send_cmd3(ColumnAddr, 0, DisplayWidth - 1);
-
- if (i2c_start_write(SSD1306_ADDRESS)) {
- goto done;
- }
- if (i2c_master_write(0x40)) {
- // Data mode
- goto done;
- }
- for (uint8_t row = 0; row < MatrixRows; ++row) {
- for (uint8_t col = 0; col < DisplayWidth; ++col) {
- i2c_master_write(0);
- }
- }
-
- display.dirty = false;
-
-done:
- i2c_master_stop();
-}
-
-#if DEBUG_TO_SCREEN
-#undef sendchar
-static int8_t capture_sendchar(uint8_t c) {
- sendchar(c);
- iota_gfx_write_char(c);
-
- if (!displaying) {
- iota_gfx_flush();
- }
- return 0;
-}
-#endif
-
-bool iota_gfx_init(bool rotate) {
- bool success = false;
-
- i2c_master_init();
- send_cmd1(DisplayOff);
- send_cmd2(SetDisplayClockDiv, 0x80);
- send_cmd2(SetMultiPlex, DisplayHeight - 1);
-
- send_cmd2(SetDisplayOffset, 0);
-
-
- send_cmd1(SetStartLine | 0x0);
- send_cmd2(SetChargePump, 0x14 /* Enable */);
- send_cmd2(SetMemoryMode, 0 /* horizontal addressing */);
-
- if(rotate){
- // the following Flip the display orientation 180 degrees
- send_cmd1(SegRemap);
- send_cmd1(ComScanInc);
- }else{
- // Flips the display orientation 0 degrees
- send_cmd1(SegRemap | 0x1);
- send_cmd1(ComScanDec);
- }
-
- send_cmd2(SetComPins, 0x2);
- send_cmd2(SetContrast, 0x8f);
- send_cmd2(SetPreCharge, 0xf1);
- send_cmd2(SetVComDetect, 0x40);
- send_cmd1(DisplayAllOnResume);
- send_cmd1(NormalDisplay);
- send_cmd1(DeActivateScroll);
- send_cmd1(DisplayOn);
-
- send_cmd2(SetContrast, 0); // Dim
-
- clear_display();
-
- success = true;
-
- iota_gfx_flush();
-
-#if DEBUG_TO_SCREEN
- print_set_sendchar(capture_sendchar);
-#endif
-
-done:
- return success;
-}
-
-bool iota_gfx_off(void) {
- bool success = false;
-
- send_cmd1(DisplayOff);
- success = true;
-
-done:
- return success;
-}
-
-bool iota_gfx_on(void) {
- bool success = false;
-
- send_cmd1(DisplayOn);
- success = true;
-
-done:
- return success;
-}
-
-void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c) {
- *matrix->cursor = c;
- ++matrix->cursor;
-
- if (matrix->cursor - &matrix->display[0][0] == sizeof(matrix->display)) {
- // We went off the end; scroll the display upwards by one line
- memmove(&matrix->display[0], &matrix->display[1],
- MatrixCols * (MatrixRows - 1));
- matrix->cursor = &matrix->display[MatrixRows - 1][0];
- memset(matrix->cursor, ' ', MatrixCols);
- }
-}
-
-void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c) {
- matrix->dirty = true;
-
- if (c == '\n') {
- // Clear to end of line from the cursor and then move to the
- // start of the next line
- uint8_t cursor_col = (matrix->cursor - &matrix->display[0][0]) % MatrixCols;
-
- while (cursor_col++ < MatrixCols) {
- matrix_write_char_inner(matrix, ' ');
- }
- return;
- }
-
- matrix_write_char_inner(matrix, c);
-}
-
-void iota_gfx_write_char(uint8_t c) {
- matrix_write_char(&display, c);
-}
-
-void matrix_write(struct CharacterMatrix *matrix, const char *data) {
- const char *end = data + strlen(data);
- while (data < end) {
- matrix_write_char(matrix, *data);
- ++data;
- }
-}
-
-void iota_gfx_write(const char *data) {
- matrix_write(&display, data);
-}
-
-void matrix_write_P(struct CharacterMatrix *matrix, const char *data) {
- while (true) {
- uint8_t c = pgm_read_byte(data);
- if (c == 0) {
- return;
- }
- matrix_write_char(matrix, c);
- ++data;
- }
-}
-
-void iota_gfx_write_P(const char *data) {
- matrix_write_P(&display, data);
-}
-
-void matrix_clear(struct CharacterMatrix *matrix) {
- memset(matrix->display, ' ', sizeof(matrix->display));
- matrix->cursor = &matrix->display[0][0];
- matrix->dirty = true;
-}
-
-void iota_gfx_clear_screen(void) {
- matrix_clear(&display);
-}
-
-void matrix_render(struct CharacterMatrix *matrix) {
- last_flush = timer_read();
- iota_gfx_on();
-#if DEBUG_TO_SCREEN
- ++displaying;
-#endif
-
- // Move to the home position
- send_cmd3(PageAddr, 0, MatrixRows - 1);
- send_cmd3(ColumnAddr, 0, (MatrixCols * FontWidth) - 1);
-
- if (i2c_start_write(SSD1306_ADDRESS)) {
- goto done;
- }
- if (i2c_master_write(0x40)) {
- // Data mode
- goto done;
- }
-
- for (uint8_t row = 0; row < MatrixRows; ++row) {
- for (uint8_t col = 0; col < MatrixCols; ++col) {
- const uint8_t *glyph = font + (matrix->display[row][col] * FontWidth);
-
- for (uint8_t glyphCol = 0; glyphCol < FontWidth; ++glyphCol) {
- uint8_t colBits = pgm_read_byte(glyph + glyphCol);
- i2c_master_write(colBits);
- }
-
- // 1 column of space between chars (it's not included in the glyph)
- //i2c_master_write(0);
- }
- }
-
- matrix->dirty = false;
-
-done:
- i2c_master_stop();
-#if DEBUG_TO_SCREEN
- --displaying;
-#endif
-}
-
-void iota_gfx_flush(void) {
- matrix_render(&display);
-}
-
-__attribute__ ((weak))
-void iota_gfx_task_user(void) {
-}
-
-void iota_gfx_task(void) {
- iota_gfx_task_user();
-
- if (display.dirty) {
- iota_gfx_flush();
- }
-
- if (timer_elapsed(last_flush) > ScreenOffInterval) {
- iota_gfx_off();
- }
-}
-#endif
diff --git a/keyboards/sol/common/ssd1306.h b/keyboards/sol/common/ssd1306.h
deleted file mode 100644
index 77ce7c211a..0000000000
--- a/keyboards/sol/common/ssd1306.h
+++ /dev/null
@@ -1,92 +0,0 @@
-#ifndef SSD1306_H
-#define SSD1306_H
-
-#include <stdbool.h>
-#include <stdio.h>
-#include "pincontrol.h"
-
-enum ssd1306_cmds {
- DisplayOff = 0xAE,
- DisplayOn = 0xAF,
-
- SetContrast = 0x81,
- DisplayAllOnResume = 0xA4,
-
- DisplayAllOn = 0xA5,
- NormalDisplay = 0xA6,
- InvertDisplay = 0xA7,
- SetDisplayOffset = 0xD3,
- SetComPins = 0xda,
- SetVComDetect = 0xdb,
- SetDisplayClockDiv = 0xD5,
- SetPreCharge = 0xd9,
- SetMultiPlex = 0xa8,
- SetLowColumn = 0x00,
- SetHighColumn = 0x10,
- SetStartLine = 0x40,
-
- SetMemoryMode = 0x20,
- ColumnAddr = 0x21,
- PageAddr = 0x22,
-
- ComScanInc = 0xc0,
- ComScanDec = 0xc8,
- SegRemap = 0xa0,
- SetChargePump = 0x8d,
- ExternalVcc = 0x01,
- SwitchCapVcc = 0x02,
-
- ActivateScroll = 0x2f,
- DeActivateScroll = 0x2e,
- SetVerticalScrollArea = 0xa3,
- RightHorizontalScroll = 0x26,
- LeftHorizontalScroll = 0x27,
- VerticalAndRightHorizontalScroll = 0x29,
- VerticalAndLeftHorizontalScroll = 0x2a,
-};
-
-// Controls the SSD1306 128x32 OLED display via i2c
-
-#ifndef SSD1306_ADDRESS
-#define SSD1306_ADDRESS 0x3C
-#endif
-
-#define DisplayHeight 32
-#define DisplayWidth 128
-
-#define FontHeight 8
-#define FontWidth 6
-
-#define MatrixRows (DisplayHeight / FontHeight)
-#define MatrixCols (DisplayWidth / FontWidth)
-
-struct CharacterMatrix {
- uint8_t display[MatrixRows][MatrixCols];
- uint8_t *cursor;
- bool dirty;
-};
-
-struct CharacterMatrix display;
-
-bool iota_gfx_init(bool rotate);
-void iota_gfx_task(void);
-bool iota_gfx_off(void);
-bool iota_gfx_on(void);
-void iota_gfx_flush(void);
-void iota_gfx_write_char(uint8_t c);
-void iota_gfx_write(const char *data);
-void iota_gfx_write_P(const char *data);
-void iota_gfx_clear_screen(void);
-
-void iota_gfx_task_user(void);
-
-void matrix_clear(struct CharacterMatrix *matrix);
-void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c);
-void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c);
-void matrix_write(struct CharacterMatrix *matrix, const char *data);
-void matrix_write_P(struct CharacterMatrix *matrix, const char *data);
-void matrix_render(struct CharacterMatrix *matrix);
-
-
-
-#endif
diff --git a/keyboards/sol/i2c.c b/keyboards/sol/i2c.c
deleted file mode 100644
index 4bee5c6398..0000000000
--- a/keyboards/sol/i2c.c
+++ /dev/null
@@ -1,162 +0,0 @@
-#include <util/twi.h>
-#include <avr/io.h>
-#include <stdlib.h>
-#include <avr/interrupt.h>
-#include <util/twi.h>
-#include <stdbool.h>
-#include "i2c.h"
-
-#ifdef USE_I2C
-
-// Limits the amount of we wait for any one i2c transaction.
-// Since were running SCL line 100kHz (=> 10μs/bit), and each transactions is
-// 9 bits, a single transaction will take around 90μs to complete.
-//
-// (F_CPU/SCL_CLOCK) => # of μC cycles to transfer a bit
-// poll loop takes at least 8 clock cycles to execute
-#define I2C_LOOP_TIMEOUT (9+1)*(F_CPU/SCL_CLOCK)/8
-
-#define BUFFER_POS_INC() (slave_buffer_pos = (slave_buffer_pos+1)%SLAVE_BUFFER_SIZE)
-
-volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE];
-
-static volatile uint8_t slave_buffer_pos;
-static volatile bool slave_has_register_set = false;
-
-// Wait for an i2c operation to finish
-inline static
-void i2c_delay(void) {
- uint16_t lim = 0;
- while(!(TWCR & (1<<TWINT)) && lim < I2C_LOOP_TIMEOUT)
- lim++;
-
- // easier way, but will wait slightly longer
- // _delay_us(100);
-}
-
-// Setup twi to run at 100kHz or 400kHz (see ./i2c.h SCL_CLOCK)
-void i2c_master_init(void) {
- // no prescaler
- TWSR = 0;
- // Set TWI clock frequency to SCL_CLOCK. Need TWBR>10.
- // Check datasheets for more info.
- TWBR = ((F_CPU/SCL_CLOCK)-16)/2;
-}
-
-// Start a transaction with the given i2c slave address. The direction of the
-// transfer is set with I2C_READ and I2C_WRITE.
-// returns: 0 => success
-// 1 => error
-uint8_t i2c_master_start(uint8_t address) {
- TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTA);
-
- i2c_delay();
-
- // check that we started successfully
- if ( (TW_STATUS != TW_START) && (TW_STATUS != TW_REP_START))
- return 1;
-
- TWDR = address;
- TWCR = (1<<TWINT) | (1<<TWEN);
-
- i2c_delay();
-
- if ( (TW_STATUS != TW_MT_SLA_ACK) && (TW_STATUS != TW_MR_SLA_ACK) )
- return 1; // slave did not acknowledge
- else
- return 0; // success
-}
-
-
-// Finish the i2c transaction.
-void i2c_master_stop(void) {
- TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);
-
- uint16_t lim = 0;
- while(!(TWCR & (1<<TWSTO)) && lim < I2C_LOOP_TIMEOUT)
- lim++;
-}
-
-// Write one byte to the i2c slave.
-// returns 0 => slave ACK
-// 1 => slave NACK
-uint8_t i2c_master_write(uint8_t data) {
- TWDR = data;
- TWCR = (1<<TWINT) | (1<<TWEN);
-
- i2c_delay();
-
- // check if the slave acknowledged us
- return (TW_STATUS == TW_MT_DATA_ACK) ? 0 : 1;
-}
-
-// Read one byte from the i2c slave. If ack=1 the slave is acknowledged,
-// if ack=0 the acknowledge bit is not set.
-// returns: byte read from i2c device
-uint8_t i2c_master_read(int ack) {
- TWCR = (1<<TWINT) | (1<<TWEN) | (ack<<TWEA);
-
- i2c_delay();
- return TWDR;
-}
-
-void i2c_reset_state(void) {
- TWCR = 0;
-}
-
-void i2c_slave_init(uint8_t address) {
- TWAR = address << 0; // slave i2c address
- // TWEN - twi enable
- // TWEA - enable address acknowledgement
- // TWINT - twi interrupt flag
- // TWIE - enable the twi interrupt
- TWCR = (1<<TWIE) | (1<<TWEA) | (1<<TWINT) | (1<<TWEN);
-}
-
-ISR(TWI_vect);
-
-ISR(TWI_vect) {
- uint8_t ack = 1;
- switch(TW_STATUS) {
- case TW_SR_SLA_ACK:
- // this device has been addressed as a slave receiver
- slave_has_register_set = false;
- break;
-
- case TW_SR_DATA_ACK:
- // this device has received data as a slave receiver
- // The first byte that we receive in this transaction sets the location
- // of the read/write location of the slaves memory that it exposes over
- // i2c. After that, bytes will be written at slave_buffer_pos, incrementing
- // slave_buffer_pos after each write.
- if(!slave_has_register_set) {
- slave_buffer_pos = TWDR;
- // don't acknowledge the master if this memory loctaion is out of bounds
- if ( slave_buffer_pos >= SLAVE_BUFFER_SIZE ) {
- ack = 0;
- slave_buffer_pos = 0;
- }
- slave_has_register_set = true;
- } else {
- i2c_slave_buffer[slave_buffer_pos] = TWDR;
- BUFFER_POS_INC();
- }
- break;
-
- case TW_ST_SLA_ACK:
- case TW_ST_DATA_ACK:
- // master has addressed this device as a slave transmitter and is
- // requesting data.
- TWDR = i2c_slave_buffer[slave_buffer_pos];
- BUFFER_POS_INC();
- break;
-
- case TW_BUS_ERROR: // something went wrong, reset twi state
- TWCR = 0;
- default:
- break;
- }
- // Reset everything, so we are ready for the next TWI interrupt
- TWCR |= (1<<TWIE) | (1<<TWINT) | (ack<<TWEA) | (1<<TWEN);
-}
-#endif
diff --git a/keyboards/sol/i2c.h b/keyboards/sol/i2c.h
deleted file mode 100644
index 47cf6bd1b2..0000000000
--- a/keyboards/sol/i2c.h
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef I2C_H
-#define I2C_H
-
-#include <stdint.h>
-
-#ifndef F_CPU
-#define F_CPU 16000000UL
-#endif
-
-#define I2C_READ 1
-#define I2C_WRITE 0
-
-#define I2C_ACK 1
-#define I2C_NACK 0
-
-#define SLAVE_BUFFER_SIZE 0x10
-
-// i2c SCL clock frequency 400kHz
-#define SCL_CLOCK 400000L
-
-extern volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE];
-
-void i2c_master_init(void);
-uint8_t i2c_master_start(uint8_t address);
-void i2c_master_stop(void);
-uint8_t i2c_master_write(uint8_t data);
-uint8_t i2c_master_read(int);
-void i2c_reset_state(void);
-void i2c_slave_init(uint8_t address);
-
-
-static inline unsigned char i2c_start_read(unsigned char addr) {
- return i2c_master_start((addr << 1) | I2C_READ);
-}
-
-static inline unsigned char i2c_start_write(unsigned char addr) {
- return i2c_master_start((addr << 1) | I2C_WRITE);
-}
-
-// from SSD1306 scrips
-extern unsigned char i2c_rep_start(unsigned char addr);
-extern void i2c_start_wait(unsigned char addr);
-extern unsigned char i2c_readAck(void);
-extern unsigned char i2c_readNak(void);
-extern unsigned char i2c_read(unsigned char ack);
-
-#define i2c_read(ack) (ack) ? i2c_readAck() : i2c_readNak();
-
-#endif
diff --git a/keyboards/sol/keymaps/brianweyer/config.h b/keyboards/sol/keymaps/brianweyer/config.h
index 87b7dd2ac0..452cdda823 100755
--- a/keyboards/sol/keymaps/brianweyer/config.h
+++ b/keyboards/sol/keymaps/brianweyer/config.h
@@ -20,8 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
-#define SSD1306OLED
-
// place overrides here
diff --git a/keyboards/sol/keymaps/brianweyer/keymap.c b/keyboards/sol/keymaps/brianweyer/keymap.c
index 2259e246d2..9fd6ad6153 100755
--- a/keyboards/sol/keymaps/brianweyer/keymap.c
+++ b/keyboards/sol/keymaps/brianweyer/keymap.c
@@ -3,9 +3,6 @@
#include "lufa.h"
#include "split_util.h"
#endif
-#ifdef SSD1306OLED
- #include "common/ssd1306.h"
-#endif
extern keymap_config_t keymap_config;
@@ -175,38 +172,28 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
}
void matrix_init_user(void) {
- #ifdef RGBLIGHT_ENABLE
- RGB_current_mode = rgblight_config.mode;
- #endif
- //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h
- #ifdef SSD1306OLED
- iota_gfx_init(!has_usb()); // turns on the display
- #endif
+#ifdef RGBLIGHT_ENABLE
+ RGB_current_mode = rgblight_config.mode;
+#endif
}
-void matrix_scan_user(void) {
- #ifdef SSD1306OLED
- // led_test_init();
- iota_gfx_task(); // this is what updates the display continuously
- #endif
-}
+// OLED Driver Logic
+#ifdef OLED_DRIVER_ENABLE
-//SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h
-#ifdef SSD1306OLED
+uint8_t oled_init_user(uint8_t rotation) {
+ if (!has_usb())
+ return OLED_ROTATION_180; // flip 180 for offhand