Compare commits
6 commits
develop
...
qwiic_joys
Author | SHA1 | Date | |
---|---|---|---|
|
531387c01c | ||
|
4446a3781c | ||
|
129df28574 | ||
|
a094696548 | ||
|
636c5989de | ||
|
d2856529ce |
20 changed files with 1395 additions and 8 deletions
|
@ -234,6 +234,8 @@ ifeq ($(strip $(LEADER_ENABLE)), yes)
|
||||||
OPT_DEFS += -DLEADER_ENABLE
|
OPT_DEFS += -DLEADER_ENABLE
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
include $(DRIVER_PATH)/qwiic/qwiic.mk
|
||||||
|
|
||||||
QUANTUM_SRC:= \
|
QUANTUM_SRC:= \
|
||||||
$(QUANTUM_DIR)/quantum.c \
|
$(QUANTUM_DIR)/quantum.c \
|
||||||
$(QUANTUM_DIR)/keymap_common.c \
|
$(QUANTUM_DIR)/keymap_common.c \
|
||||||
|
|
|
@ -43,7 +43,12 @@ static const I2CConfig i2cconfig = {
|
||||||
|
|
||||||
void i2c_init(void)
|
void i2c_init(void)
|
||||||
{
|
{
|
||||||
palSetGroupMode(GPIOB, GPIOB_PIN6 | GPIOB_PIN7, 0, PAL_MODE_INPUT); // Try releasing special pins for a short time
|
//palSetGroupMode(GPIOB, GPIOB_PIN6 | GPIOB_PIN7, 0, PAL_MODE_INPUT);
|
||||||
|
|
||||||
|
// Try releasing special pins for a short time
|
||||||
|
palSetPadMode(GPIOB, 6, PAL_MODE_INPUT);
|
||||||
|
palSetPadMode(GPIOB, 7, PAL_MODE_INPUT);
|
||||||
|
|
||||||
chThdSleepMilliseconds(10);
|
chThdSleepMilliseconds(10);
|
||||||
|
|
||||||
palSetPadMode(GPIOB, 6, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN | PAL_STM32_PUPDR_PULLUP);
|
palSetPadMode(GPIOB, 6, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN | PAL_STM32_PUPDR_PULLUP);
|
||||||
|
@ -74,6 +79,10 @@ uint8_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t ti
|
||||||
return i2cMasterReceiveTimeout(&I2C_DRIVER, (i2c_address >> 1), data, length, MS2ST(timeout));
|
return i2cMasterReceiveTimeout(&I2C_DRIVER, (i2c_address >> 1), data, length, MS2ST(timeout));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t i2c_transmit_receive(uint8_t address, uint8_t * tx_body, uint16_t tx_length, uint8_t * rx_body, uint16_t rx_length) {
|
||||||
|
return i2cMasterTransmitTimeout(&I2C_DRIVER, address/2, tx_body, tx_length, rx_body, rx_length, MS2ST(100));
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)
|
uint8_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout)
|
||||||
{
|
{
|
||||||
i2c_address = devaddr;
|
i2c_address = devaddr;
|
||||||
|
|
|
@ -34,6 +34,7 @@ void i2c_init(void);
|
||||||
uint8_t i2c_start(uint8_t address);
|
uint8_t i2c_start(uint8_t address);
|
||||||
uint8_t i2c_transmit(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout);
|
uint8_t i2c_transmit(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout);
|
||||||
uint8_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout);
|
uint8_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout);
|
||||||
|
uint8_t i2c_transmit_receive(uint8_t address, uint8_t * tx_body, uint16_t tx_length, uint8_t * rx_body, uint16_t rx_length);
|
||||||
uint8_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout);
|
uint8_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout);
|
||||||
uint8_t i2c_readReg(uint8_t devaddr, uint8_t* regaddr, uint8_t* data, uint16_t length, uint16_t timeout);
|
uint8_t i2c_readReg(uint8_t devaddr, uint8_t* regaddr, uint8_t* data, uint16_t length, uint16_t timeout);
|
||||||
uint8_t i2c_stop(uint16_t timeout);
|
uint8_t i2c_stop(uint16_t timeout);
|
||||||
|
|
125
drivers/qwiic/joystiic.c
Normal file
125
drivers/qwiic/joystiic.c
Normal file
|
@ -0,0 +1,125 @@
|
||||||
|
/* Copyright 2018 Jack Humbert <jack.humb@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 "joystiic.h"
|
||||||
|
#include "print.h"
|
||||||
|
#include "action.h"
|
||||||
|
|
||||||
|
#define JOYSTIIC_DEFAULT_ADDR 0x20
|
||||||
|
#define JOYSTIIC_COMMAND_HORIZONTAL 0x00
|
||||||
|
#define JOYSTIIC_COMMAND_VERTICAL 0x02
|
||||||
|
#define JOYSTIIC_COMMAND_BUTTON 0x04
|
||||||
|
|
||||||
|
#define JOYSTIIC_CENTER 512
|
||||||
|
#define JOYSTIIC_DEADZONE 200
|
||||||
|
|
||||||
|
uint16_t joystiic_horizontal;
|
||||||
|
uint16_t joystiic_vertical;
|
||||||
|
bool joystiic_button;
|
||||||
|
|
||||||
|
uint8_t joystiic_tx[1];
|
||||||
|
uint8_t joystiic_rx_horizontal[2];
|
||||||
|
uint8_t joystiic_rx_vertical[2];
|
||||||
|
uint8_t joystiic_rx_button[1];
|
||||||
|
|
||||||
|
bool joystiic_triggered[5] = {0};
|
||||||
|
|
||||||
|
void joystiic_init(void) {
|
||||||
|
i2c_init();
|
||||||
|
i2c_start(JOYSTIIC_DEFAULT_ADDR);
|
||||||
|
}
|
||||||
|
|
||||||
|
void joystiic_update(uint16_t horizontal, uint16_t vertical, bool button) {
|
||||||
|
joystiic_update_kb(horizontal, vertical, button);
|
||||||
|
joystiic_update_user(horizontal, vertical, button);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__ ((weak))
|
||||||
|
void joystiic_update_kb(uint16_t horizontal, uint16_t vertical, bool button) { }
|
||||||
|
|
||||||
|
__attribute__ ((weak))
|
||||||
|
void joystiic_update_user(uint16_t horizontal, uint16_t vertical, bool button) { }
|
||||||
|
|
||||||
|
void joystiic_trigger(uint8_t trigger, bool active) {
|
||||||
|
joystiic_trigger_kb(trigger, active);
|
||||||
|
joystiic_trigger_user(trigger, active);
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__ ((weak))
|
||||||
|
void joystiic_trigger_kb(uint8_t trigger, bool active) { }
|
||||||
|
|
||||||
|
__attribute__ ((weak))
|
||||||
|
void joystiic_trigger_user(uint8_t trigger, bool active) { }
|
||||||
|
|
||||||
|
void joystiic_trigger_if_not(uint8_t trigger, bool active) {
|
||||||
|
if (joystiic_triggered[trigger] != active) {
|
||||||
|
joystiic_triggered[trigger] = active;
|
||||||
|
joystiic_trigger(trigger, active);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void joystiic_task(void) {
|
||||||
|
// get horizontal axis
|
||||||
|
joystiic_tx[0] = JOYSTIIC_COMMAND_HORIZONTAL;
|
||||||
|
|
||||||
|
if (MSG_OK != i2c_transmit_receive(JOYSTIIC_DEFAULT_ADDR << 1,
|
||||||
|
joystiic_tx, 1,
|
||||||
|
joystiic_rx_horizontal, 2
|
||||||
|
)) {
|
||||||
|
printf("error hori\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
joystiic_horizontal = ((uint16_t)joystiic_rx_horizontal[0] << 8) | joystiic_rx_horizontal[1];
|
||||||
|
|
||||||
|
joystiic_trigger_if_not(JOYSTIIC_LEFT, joystiic_horizontal > (JOYSTIIC_CENTER + JOYSTIIC_DEADZONE));
|
||||||
|
joystiic_trigger_if_not(JOYSTIIC_RIGHT, joystiic_horizontal < (JOYSTIIC_CENTER - JOYSTIIC_DEADZONE));
|
||||||
|
|
||||||
|
// get vertical axis
|
||||||
|
joystiic_tx[0] = JOYSTIIC_COMMAND_VERTICAL;
|
||||||
|
if (MSG_OK != i2c_transmit_receive(JOYSTIIC_DEFAULT_ADDR << 1,
|
||||||
|
joystiic_tx, 1,
|
||||||
|
joystiic_rx_vertical, 2
|
||||||
|
)) {
|
||||||
|
printf("error vert\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
joystiic_vertical = ((uint16_t)joystiic_rx_vertical[0] << 8) | joystiic_rx_vertical[1];
|
||||||
|
|
||||||
|
joystiic_trigger_if_not(JOYSTIIC_UP, joystiic_vertical > (JOYSTIIC_CENTER + JOYSTIIC_DEADZONE));
|
||||||
|
joystiic_trigger_if_not(JOYSTIIC_DOWN, joystiic_vertical < (JOYSTIIC_CENTER - JOYSTIIC_DEADZONE));
|
||||||
|
|
||||||
|
// get button press
|
||||||
|
joystiic_tx[0] = JOYSTIIC_COMMAND_BUTTON;
|
||||||
|
if (MSG_OK != i2c_transmit_receive(JOYSTIIC_DEFAULT_ADDR << 1,
|
||||||
|
joystiic_tx, 1,
|
||||||
|
joystiic_rx_button, 1
|
||||||
|
)) {
|
||||||
|
printf("error vert\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
joystiic_button = !joystiic_rx_button[0];
|
||||||
|
|
||||||
|
joystiic_trigger_if_not(JOYSTIIC_PRESS, joystiic_button);
|
||||||
|
|
||||||
|
joystiic_update(joystiic_horizontal, joystiic_vertical, joystiic_button);
|
||||||
|
|
||||||
|
//printf("%d\n", joystiic[0]);
|
||||||
|
|
||||||
|
// SEND_STRING("H: ");
|
||||||
|
// send_word(joystiic_rx_horizontal[0]);
|
||||||
|
// tap_code(KC_SPACE);
|
||||||
|
// send_word(joystiic_rx_horizontal[1]);
|
||||||
|
// tap_code(KC_SPACE);
|
||||||
|
}
|
34
drivers/qwiic/joystiic.h
Normal file
34
drivers/qwiic/joystiic.h
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/* Copyright 2018 Jack Humbert <jack.humb@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 "qwiic.h"
|
||||||
|
|
||||||
|
enum {
|
||||||
|
JOYSTIIC_LEFT,
|
||||||
|
JOYSTIIC_RIGHT,
|
||||||
|
JOYSTIIC_UP,
|
||||||
|
JOYSTIIC_DOWN,
|
||||||
|
JOYSTIIC_PRESS
|
||||||
|
};
|
||||||
|
|
||||||
|
void joystiic_update_kb(uint16_t horizontal, uint16_t vertical, bool button);
|
||||||
|
void joystiic_update_user(uint16_t horizontal, uint16_t vertical, bool button);
|
||||||
|
void joystiic_trigger_kb(uint8_t trigger, bool active);
|
||||||
|
void joystiic_trigger_user(uint8_t trigger, bool active);
|
||||||
|
|
||||||
|
void joystiic_init(void);
|
||||||
|
void joystiic_task(void);
|
469
drivers/qwiic/micro_oled.c
Normal file
469
drivers/qwiic/micro_oled.c
Normal file
|
@ -0,0 +1,469 @@
|
||||||
|
/* Jim Lindblom @ SparkFun Electronics
|
||||||
|
* October 26, 2014
|
||||||
|
* https://github.com/sparkfun/Micro_OLED_Breakout/tree/master/Firmware/Arduino/libraries/SFE_MicroOLED
|
||||||
|
*
|
||||||
|
* Modified by:
|
||||||
|
* Emil Varughese @ Edwin Robotics Pvt. Ltd.
|
||||||
|
* July 27, 2015
|
||||||
|
* https://github.com/emil01/SparkFun_Micro_OLED_Arduino_Library/
|
||||||
|
*
|
||||||
|
* This code was heavily based around the MicroView library, written by GeekAmmo
|
||||||
|
* (https://github.com/geekammo/MicroView-Arduino-Library).
|
||||||
|
*
|
||||||
|
* Adapted for QMK by:
|
||||||
|
* Jack Humbert <jack.humb@gmail.com>
|
||||||
|
* October 11, 2018
|
||||||
|
*
|
||||||
|
* 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 3 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 "micro_oled.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "util/font5x7.h"
|
||||||
|
#include "util/font8x16.h"
|
||||||
|
#include "string.h"
|
||||||
|
|
||||||
|
#define TOTALFONTS 2
|
||||||
|
const unsigned char * fonts_pointer[]= { font5x7, font8x16 };
|
||||||
|
|
||||||
|
uint8_t foreColor,drawMode,fontWidth, fontHeight, fontType, fontStartChar, fontTotalChar, cursorX, cursorY;
|
||||||
|
uint16_t fontMapWidth;
|
||||||
|
|
||||||
|
#define _BV(x) (1 << (x))
|
||||||
|
#define swap(a, b) { uint8_t t = a; a = b; b = t; }
|
||||||
|
|
||||||
|
uint8_t micro_oled_transfer_buffer[20];
|
||||||
|
static uint8_t micro_oled_screen_current[384] = { 0 };
|
||||||
|
static uint8_t micro_oled_screen_buffer[] = {
|
||||||
|
/* LCD Memory organised in 64 horizontal pixel and 6 rows of byte
|
||||||
|
B B .............B -----
|
||||||
|
y y .............y \
|
||||||
|
t t .............t \
|
||||||
|
e e .............e \
|
||||||
|
0 1 .............63 \
|
||||||
|
\
|
||||||
|
D0 D0.............D0 \
|
||||||
|
D1 D1.............D1 / ROW 0
|
||||||
|
D2 D2.............D2 /
|
||||||
|
D3 D3.............D3 /
|
||||||
|
D4 D4.............D4 /
|
||||||
|
D5 D5.............D5 /
|
||||||
|
D6 D6.............D6 /
|
||||||
|
D7 D7.............D7 ----
|
||||||
|
*/
|
||||||
|
|
||||||
|
// QMK Logo - generated at http://www.majer.ch/lcd/adf_bitmap.php
|
||||||
|
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0x00, 0x00,
|
||||||
|
0x00, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0x00, 0x00,
|
||||||
|
0x00, 0xF0, 0xF0, 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, 0x60, 0x60, 0x60, 0x60,
|
||||||
|
0xF8, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0x1F, 0x1F, 0xFF, 0xFF,
|
||||||
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x1F, 0xFF, 0xFF, 0xFF,
|
||||||
|
0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x1F, 0xFF, 0xFF, 0xFF, 0xFE,
|
||||||
|
0xFE, 0xF8, 0x60, 0x60, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x8C, 0x8C, 0x8C, 0x8C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||||
|
0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
|
||||||
|
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
|
||||||
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x8C, 0x8C, 0x8C, 0x8C,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x31, 0x31, 0x31, 0x31, 0xFF, 0xFF,
|
||||||
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF8, 0xF1, 0xE3, 0xE7, 0xCF,
|
||||||
|
0xCF, 0xCF, 0xCF, 0x00, 0x00, 0xCF, 0xCF, 0xCF, 0xC7, 0xE7,
|
||||||
|
0xE3, 0xF1, 0xF8, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||||
|
0x31, 0x31, 0x31, 0x31, 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, 0x06,
|
||||||
|
0x06, 0x06, 0x1F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||||
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0xF8, 0xFF,
|
||||||
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||||
|
0xFF, 0x7F, 0x7F, 0x1F, 0x06, 0x06, 0x06, 0x06, 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, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00,
|
||||||
|
0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00,
|
||||||
|
0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00
|
||||||
|
};
|
||||||
|
|
||||||
|
void micro_oled_init(void) {
|
||||||
|
|
||||||
|
i2c_init();
|
||||||
|
i2c_start(I2C_ADDRESS_SA0_1);
|
||||||
|
|
||||||
|
// Display Init sequence for 64x48 OLED module
|
||||||
|
send_command(DISPLAYOFF); // 0xAE
|
||||||
|
|
||||||
|
send_command(SETDISPLAYCLOCKDIV); // 0xD5
|
||||||
|
send_command(0x80); // the suggested ratio 0x80
|
||||||
|
|
||||||
|
send_command(SETMULTIPLEX); // 0xA8
|
||||||
|
send_command(0x2F);
|
||||||
|
|
||||||
|
send_command(SETDISPLAYOFFSET); // 0xD3
|
||||||
|
send_command(0x0); // no offset
|
||||||
|
|
||||||
|
send_command(SETSTARTLINE | 0x0); // line #0
|
||||||
|
|
||||||
|
send_command(CHARGEPUMP); // enable charge pump
|
||||||
|
send_command(0x14);
|
||||||
|
|
||||||
|
send_command(NORMALDISPLAY); // 0xA6
|
||||||
|
send_command(DISPLAYALLONRESUME); // 0xA4
|
||||||
|
|
||||||
|
send_command(SEGREMAP | 0x1);
|
||||||
|
send_command(COMSCANDEC);
|
||||||
|
|
||||||
|
send_command(SETCOMPINS); // 0xDA
|
||||||
|
send_command(0x12);
|
||||||
|
|
||||||
|
send_command(SETCONTRAST); // 0x81
|
||||||
|
send_command(0x8F);
|
||||||
|
|
||||||
|
send_command(SETPRECHARGE); // 0xd9
|
||||||
|
send_command(0xF1);
|
||||||
|
|
||||||
|
send_command(SETVCOMDESELECT); // 0xDB
|
||||||
|
send_command(0x40);
|
||||||
|
|
||||||
|
send_command(DISPLAYON); //--turn on oled panel
|
||||||
|
clear_screen(); // Erase hardware memory inside the OLED controller to avoid random data in memory.
|
||||||
|
send_buffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
void send_command(uint8_t command) {
|
||||||
|
micro_oled_transfer_buffer[0] = I2C_COMMAND;
|
||||||
|
micro_oled_transfer_buffer[1] = command;
|
||||||
|
i2c_transmit(I2C_ADDRESS_SA0_1 << 1, micro_oled_transfer_buffer, 2, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
void send_data(uint8_t data) {
|
||||||
|
micro_oled_transfer_buffer[0] = I2C_DATA;
|
||||||
|
micro_oled_transfer_buffer[1] = data;
|
||||||
|
i2c_transmit(I2C_ADDRESS_SA0_1 << 1, micro_oled_transfer_buffer, 2, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief Set SSD1306 page address.
|
||||||
|
Send page address command and address to the SSD1306 OLED controller.
|
||||||
|
*/
|
||||||
|
void set_page_address(uint8_t address) {
|
||||||
|
address = (0xB0 | address);
|
||||||
|
send_command(address);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief Set SSD1306 column address.
|
||||||
|
Send column address command and address to the SSD1306 OLED controller.
|
||||||
|
*/
|
||||||
|
void set_column_address(uint8_t address) {
|
||||||
|
send_command( ( 0x10 | (address >> 4) ) + 0x02 );
|
||||||
|
send_command( 0x0f & address );
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief Clear SSD1306's memory.
|
||||||
|
To clear GDRAM inside the LCD controller.
|
||||||
|
*/
|
||||||
|
void clear_screen(void) {
|
||||||
|
for (int i=0;i<8; i++) {
|
||||||
|
set_page_address(i);
|
||||||
|
set_column_address(0);
|
||||||
|
for (int j=0; j<0x80; j++) {
|
||||||
|
send_data(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief Clear SSD1306's memory.
|
||||||
|
To clear GDRAM inside the LCD controller.
|
||||||
|
*/
|
||||||
|
void clear_buffer(void) {
|
||||||
|
memset(micro_oled_screen_buffer, 0, 384);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief Invert display.
|
||||||
|
The PIXEL_ON color of the display will turn to PIXEL_OFF and the PIXEL_OFF will turn to PIXEL_ON.
|
||||||
|
*/
|
||||||
|
void invert_screen(bool invert) {
|
||||||
|
if (invert) {
|
||||||
|
send_command(INVERTDISPLAY);
|
||||||
|
} else {
|
||||||
|
send_command(NORMALDISPLAY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief Set contrast.
|
||||||
|
OLED contract value from 0 to 255. Note: Contrast level is not very obvious.
|
||||||
|
*/
|
||||||
|
void set_contrast(uint8_t contrast) {
|
||||||
|
send_command(SETCONTRAST); // 0x81
|
||||||
|
send_command(contrast);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief Transfer display buffer.
|
||||||
|
Sends the updated buffer to the controller - the current status is checked before to save i2c exectution time
|
||||||
|
*/
|
||||||
|
void send_buffer(void) {
|
||||||
|
uint8_t i, j;
|
||||||
|
|
||||||
|
uint8_t page_addr = 0xFF;
|
||||||
|
for (i = 0; i < 6; i++) {
|
||||||
|
uint8_t col_addr = 0xFF;
|
||||||
|
for (j = 0; j < 0x40; j++) {
|
||||||
|
if (micro_oled_screen_buffer[i*0x40+j] != micro_oled_screen_current[i*0x40+j]) {
|
||||||
|
if (page_addr != i) {
|
||||||
|
set_page_address(i);
|
||||||
|
}
|
||||||
|
if (col_addr != j) {
|
||||||
|
set_column_address(j);
|
||||||
|
}
|
||||||
|
send_data(micro_oled_screen_buffer[i*0x40+j]);
|
||||||
|
micro_oled_screen_current[i*0x40+j] = micro_oled_screen_buffer[i*0x40+j];
|
||||||
|
col_addr = j + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief Draw pixel with color and mode.
|
||||||
|
Draw color pixel in the screen buffer's x,y position with NORM or XOR draw mode.
|
||||||
|
*/
|
||||||
|
void draw_pixel(uint8_t x, uint8_t y, uint8_t color, uint8_t mode) {
|
||||||
|
if ((x<0) || (x>=LCDWIDTH) || (y<0) || (y>=LCDHEIGHT))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (mode == XOR) {
|
||||||
|
if (color == PIXEL_ON)
|
||||||
|
micro_oled_screen_buffer[x + (y/8)*LCDWIDTH] ^= _BV((y%8));
|
||||||
|
} else {
|
||||||
|
if (color == PIXEL_ON)
|
||||||
|
micro_oled_screen_buffer[x + (y/8)*LCDWIDTH] |= _BV((y%8));
|
||||||
|
else
|
||||||
|
micro_oled_screen_buffer[x + (y/8)*LCDWIDTH] &= ~_BV((y%8));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief Draw line with color and mode.
|
||||||
|
Draw line using color and mode from x0,y0 to x1,y1 of the screen buffer.
|
||||||
|
*/
|
||||||
|
void draw_line(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t color, uint8_t mode) {
|
||||||
|
uint8_t steep = abs(y1 - y0) > abs(x1 - x0);
|
||||||
|
if (steep) {
|
||||||
|
swap(x0, y0);
|
||||||
|
swap(x1, y1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x0 > x1) {
|
||||||
|
swap(x0, x1);
|
||||||
|
swap(y0, y1);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t dx, dy;
|
||||||
|
dx = x1 - x0;
|
||||||
|
dy = abs(y1 - y0);
|
||||||
|
|
||||||
|
int8_t err = dx / 2;
|
||||||
|
int8_t ystep;
|
||||||
|
|
||||||
|
if (y0 < y1) {
|
||||||
|
ystep = 1;
|
||||||
|
} else {
|
||||||
|
ystep = -1;}
|
||||||
|
|
||||||
|
for (; x0<x1; x0++) {
|
||||||
|
if (steep) {
|
||||||
|
draw_pixel(y0, x0, color, mode);
|
||||||
|
} else {
|
||||||
|
draw_pixel(x0, y0, color, mode);
|
||||||
|
}
|
||||||
|
err -= dy;
|
||||||
|
if (err < 0) {
|
||||||
|
y0 += ystep;
|
||||||
|
err += dx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief Draw horizontal line with color and mode.
|
||||||
|
Draw horizontal line using color and mode from x,y to x+width,y of the screen buffer.
|
||||||
|
*/
|
||||||
|
void draw_line_hori(uint8_t x, uint8_t y, uint8_t width, uint8_t color, uint8_t mode) {
|
||||||
|
draw_line(x,y,x+width,y,color,mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief Draw vertical line.
|
||||||
|
Draw vertical line using current fore color and current draw mode from x,y to x,y+height of the screen buffer.
|
||||||
|
*/
|
||||||
|
void draw_line_vert(uint8_t x, uint8_t y, uint8_t height, bool color, uint8_t mode) {
|
||||||
|
draw_line(x,y,x,y+height,color,mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief Draw rectangle with color and mode.
|
||||||
|
Draw rectangle using color and mode from x,y to x+width,y+height of the screen buffer.
|
||||||
|
*/
|
||||||
|
void draw_rect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode) {
|
||||||
|
uint8_t tempHeight;
|
||||||
|
|
||||||
|
draw_line_hori(x,y, width, color, mode);
|
||||||
|
draw_line_hori(x,y+height-1, width, color, mode);
|
||||||
|
|
||||||
|
tempHeight=height-2;
|
||||||
|
|
||||||
|
// skip drawing vertical lines to avoid overlapping of pixel that will
|
||||||
|
// affect XOR plot if no pixel in between horizontal lines
|
||||||
|
if (tempHeight<1) return;
|
||||||
|
|
||||||
|
draw_line_vert(x,y+1, tempHeight, color, mode);
|
||||||
|
draw_line_vert(x+width-1, y+1, tempHeight, color, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief Draw rectangle with color and mode.
|
||||||
|
Draw rectangle using color and mode from x,y to x+width,y+height of the screen buffer.
|
||||||
|
*/
|
||||||
|
void draw_rect_soft(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode) {
|
||||||
|
uint8_t tempHeight;
|
||||||
|
|
||||||
|
draw_line_hori(x+1,y, width-2, color, mode);
|
||||||
|
draw_line_hori(x+1,y+height-1, width-2, color, mode);
|
||||||
|
|
||||||
|
tempHeight=height-2;
|
||||||
|
|
||||||
|
// skip drawing vertical lines to avoid overlapping of pixel that will
|
||||||
|
// affect XOR plot if no pixel in between horizontal lines
|
||||||
|
if (tempHeight<1) return;
|
||||||
|
|
||||||
|
draw_line_vert(x,y+1, tempHeight, color, mode);
|
||||||
|
draw_line_vert(x+width-1, y+1, tempHeight, color, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief Draw filled rectangle with color and mode.
|
||||||
|
Draw filled rectangle using color and mode from x,y to x+width,y+height of the screen buffer.
|
||||||
|
*/
|
||||||
|
void draw_rect_filled(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode) {
|
||||||
|
// TODO - need to optimise the memory map draw so that this function will not call pixel one by one
|
||||||
|
for (int i=x; i<x+width;i++) {
|
||||||
|
draw_line_vert(i,y, height, color, mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief Draw filled rectangle with color and mode.
|
||||||
|
Draw filled rectangle using color and mode from x,y to x+width,y+height of the screen buffer.
|
||||||
|
*/
|
||||||
|
void draw_rect_filled_soft(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode) {
|
||||||
|
// TODO - need to optimise the memory map draw so that this function will not call pixel one by one
|
||||||
|
for (int i=x; i<x+width;i++) {
|
||||||
|
if (i == x || i == (x + width - 1))
|
||||||
|
draw_line_vert(i, y+1, height-2, color, mode);
|
||||||
|
else
|
||||||
|
draw_line_vert(i, y, height, color, mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief Draw character with color and mode.
|
||||||
|
Draw character c using color and draw mode at x,y.
|
||||||
|
*/
|
||||||
|
void draw_char(uint8_t x, uint8_t y, uint8_t c, uint8_t color, uint8_t mode, uint8_t font) {
|
||||||
|
// TODO - New routine to take font of any height, at the moment limited to font height in multiple of 8 pixels
|
||||||
|
|
||||||
|
uint8_t rowsToDraw,row, tempC;
|
||||||
|
uint8_t i,j,temp;
|
||||||
|
uint16_t charPerBitmapRow,charColPositionOnBitmap,charRowPositionOnBitmap,charBitmapStartPosition;
|
||||||
|
|
||||||
|
if ((font>=TOTALFONTS) || (font<0))
|
||||||
|
return;
|
||||||
|
|
||||||
|
uint8_t fontType = font;
|
||||||
|
uint8_t fontWidth = pgm_read_byte(fonts_pointer[fontType]+0);
|
||||||
|
uint8_t fontHeight = pgm_read_byte(fonts_pointer[fontType]+1);
|
||||||
|
uint8_t fontStartChar = pgm_read_byte(fonts_pointer[fontType]+2);
|
||||||
|
uint8_t fontTotalChar = pgm_read_byte(fonts_pointer[fontType]+3);
|
||||||
|
uint16_t fontMapWidth = (pgm_read_byte(fonts_pointer[fontType]+4)*100)+pgm_read_byte(fonts_pointer[fontType]+5); // two bytes values into integer 16
|
||||||
|
|
||||||
|
if ((c<fontStartChar) || (c>(fontStartChar+fontTotalChar-1))) // no bitmap for the required c
|
||||||
|
return;
|
||||||
|
|
||||||
|
tempC=c-fontStartChar;
|
||||||
|
|
||||||
|
// each row (in datasheet is call page) is 8 bits high, 16 bit high character will have 2 rows to be drawn
|
||||||
|
rowsToDraw=fontHeight/8; // 8 is LCD's page size, see SSD1306 datasheet
|
||||||
|
if (rowsToDraw<=1) rowsToDraw=1;
|
||||||
|
|
||||||
|
// the following draw function can draw anywhere on the screen, but SLOW pixel by pixel draw
|
||||||
|
if (rowsToDraw==1) {
|
||||||
|
for (i=0;i<fontWidth+1;i++) {
|
||||||
|
if (i==fontWidth) // this is done in a weird way because for 5x7 font, there is no margin, this code add a margin after col 5
|
||||||
|
temp=0;
|
||||||
|
else
|
||||||
|
temp=pgm_read_byte(fonts_pointer[fontType]+FONTHEADERSIZE+(tempC*fontWidth)+i);
|
||||||
|
|
||||||
|
for (j=0;j<8;j++) { // 8 is the LCD's page height (see datasheet for explanation)
|
||||||
|
if (temp & 0x1) {
|
||||||
|
draw_pixel(x+i, y+j, color,mode);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
draw_pixel(x+i, y+j, !color,mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
temp >>=1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// font height over 8 bit
|
||||||
|
// take character "0" ASCII 48 as example
|
||||||
|
charPerBitmapRow = fontMapWidth/fontWidth; // 256/8 =32 char per row
|
||||||
|
charColPositionOnBitmap = tempC % charPerBitmapRow; // =16
|
||||||
|
charRowPositionOnBitmap = (int)(tempC/charPerBitmapRow); // =1
|
||||||
|
charBitmapStartPosition = (charRowPositionOnBitmap * fontMapWidth * (fontHeight/8)) + (charColPositionOnBitmap * fontWidth) ;
|
||||||
|
|
||||||
|
// each row on LCD is 8 bit height (see datasheet for explanation)
|
||||||
|
for(row=0;row<rowsToDraw;row++) {
|
||||||
|
for (i=0; i<fontWidth;i++) {
|
||||||
|
temp=pgm_read_byte(fonts_pointer[fontType]+FONTHEADERSIZE+(charBitmapStartPosition+i+(row*fontMapWidth)));
|
||||||
|
for (j=0;j<8;j++) { // 8 is the LCD's page height (see datasheet for explanation)
|
||||||
|
if (temp & 0x1) {
|
||||||
|
draw_pixel(x+i,y+j+(row*8), color, mode);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
draw_pixel(x+i,y+j+(row*8), !color, mode);
|
||||||
|
}
|
||||||
|
temp >>=1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw_string(uint8_t x, uint8_t y, char * string, uint8_t color, uint8_t mode, uint8_t font) {
|
||||||
|
|
||||||
|
if ((font>=TOTALFONTS) || (font<0))
|
||||||
|
return;
|
||||||
|
|
||||||
|
uint8_t fontType = font;
|
||||||
|
uint8_t fontWidth = pgm_read_byte(fonts_pointer[fontType]+0);
|
||||||
|
|
||||||
|
uint8_t cur_x = x;
|
||||||
|
for (int i = 0; i < strlen(string); i++) {
|
||||||
|
draw_char(cur_x, y, string[i], color, mode, font);
|
||||||
|
cur_x += fontWidth + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
129
drivers/qwiic/micro_oled.h
Normal file
129
drivers/qwiic/micro_oled.h
Normal file
|
@ -0,0 +1,129 @@
|
||||||
|
/* Jim Lindblom @ SparkFun Electronics
|
||||||
|
* October 26, 2014
|
||||||
|
* https://github.com/sparkfun/Micro_OLED_Breakout/tree/master/Firmware/Arduino/libraries/SFE_MicroOLED
|
||||||
|
*
|
||||||
|
* Modified by:
|
||||||
|
* Emil Varughese @ Edwin Robotics Pvt. Ltd.
|
||||||
|
* July 27, 2015
|
||||||
|
* https://github.com/emil01/SparkFun_Micro_OLED_Arduino_Library/
|
||||||
|
*
|
||||||
|
* This code was heavily based around the MicroView library, written by GeekAmmo
|
||||||
|
* (https://github.com/geekammo/MicroView-Arduino-Library).
|
||||||
|
*
|
||||||
|
* Adapted for QMK by:
|
||||||
|
* Jack Humbert <jack.humb@gmail.com>
|
||||||
|
* October 11, 2018
|
||||||
|
*
|
||||||
|
* 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 3 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 "qwiic.h"
|
||||||
|
|
||||||
|
void micro_oled_init(void);
|
||||||
|
|
||||||
|
void send_command(uint8_t command);
|
||||||
|
void send_data(uint8_t data);
|
||||||
|
void set_page_address(uint8_t address);
|
||||||
|
void set_column_address(uint8_t address);
|
||||||
|
void clear_screen(void);
|
||||||
|
void clear_buffer(void);
|
||||||
|
void send_buffer(void);
|
||||||
|
void draw_pixel(uint8_t x, uint8_t y, uint8_t color, uint8_t mode);
|
||||||
|
void draw_line(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t color, uint8_t mode);
|
||||||
|
void draw_line_hori(uint8_t x, uint8_t y, uint8_t width, uint8_t color, uint8_t mode);
|
||||||
|
void draw_line_vert(uint8_t x, uint8_t y, uint8_t height, bool color, uint8_t mode);
|
||||||
|
void draw_rect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode);
|
||||||
|
void draw_rect_soft(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode);
|
||||||
|
void draw_rect_filled(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode);
|
||||||
|
void draw_rect_filled_soft(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color, uint8_t mode);
|
||||||
|
void draw_char(uint8_t x, uint8_t y, uint8_t c, uint8_t color, uint8_t mode, uint8_t font);
|
||||||
|
void draw_string(uint8_t x, uint8_t y, char * string, uint8_t color, uint8_t mode, uint8_t font);
|
||||||
|
|
||||||
|
#define I2C_ADDRESS_SA0_0 0b0111100
|
||||||
|
#define I2C_ADDRESS_SA0_1 0b0111101
|
||||||
|
#define I2C_COMMAND 0x00
|
||||||
|
#define I2C_DATA 0x40
|
||||||
|
|
||||||
|
#define PIXEL_OFF 0
|
||||||
|
#define PIXEL_ON 1
|
||||||
|
|
||||||
|
#define LCDWIDTH 64
|
||||||
|
#define LCDHEIGHT 48
|
||||||
|
#define FONTHEADERSIZE 6
|
||||||
|
|
||||||
|
#define NORM 0
|
||||||
|
#define XOR 1
|
||||||
|
|
||||||
|
#define PAGE 0
|
||||||
|
#define ALL 1
|
||||||
|
|
||||||
|
#define WIDGETSTYLE0 0
|
||||||
|
#define WIDGETSTYLE1 1
|
||||||
|
#define WIDGETSTYLE2 2
|
||||||
|
|
||||||
|
#define SETCONTRAST 0x81
|
||||||
|
#define DISPLAYALLONRESUME 0xA4
|
||||||
|
#define DISPLAYALLON 0xA5
|
||||||
|
#define NORMALDISPLAY 0xA6
|
||||||
|
#define INVERTDISPLAY 0xA7
|
||||||
|
#define DISPLAYOFF 0xAE
|
||||||
|
#define DISPLAYON 0xAF
|
||||||
|
#define SETDISPLAYOFFSET 0xD3
|
||||||
|
#define SETCOMPINS 0xDA
|
||||||
|
#define SETVCOMDESELECT 0xDB
|
||||||
|
#define SETDISPLAYCLOCKDIV 0xD5
|
||||||
|
#define SETPRECHARGE 0xD9
|
||||||
|
#define SETMULTIPLEX 0xA8
|
||||||
|
#define SETLOWCOLUMN 0x00
|
||||||
|
#define SETHIGHCOLUMN 0x10
|
||||||
|
#define SETSTARTLINE 0x40
|
||||||
|
#define MEMORYMODE 0x20
|
||||||
|
#define COMSCANINC 0xC0
|
||||||
|
#define COMSCANDEC 0xC8
|
||||||
|
#define SEGREMAP 0xA0
|
||||||
|
#define CHARGEPUMP 0x8D
|
||||||
|
#define EXTERNALVCC 0x01
|
||||||
|
#define SWITCHCAPVCC 0x02
|
||||||
|
|
||||||
|
// Scroll
|
||||||
|
#define ACTIVATESCROLL 0x2F
|
||||||
|
#define DEACTIVATESCROLL 0x2E
|
||||||
|
#define SETVERTICALSCROLLAREA 0xA3
|
||||||
|
#define RIGHTHORIZONTALSCROLL 0x26
|
||||||
|
#define LEFT_HORIZONTALSCROLL 0x27
|
||||||
|
#define VERTICALRIGHTHORIZONTALSCROLL 0x29
|
||||||
|
#define VERTICALLEFTHORIZONTALSCROLL 0x2A
|
||||||
|
|
||||||
|
typedef enum CMD {
|
||||||
|
CMD_CLEAR, //0
|
||||||
|
CMD_INVERT, //1
|
||||||
|
CMD_CONTRAST, //2
|
||||||
|
CMD_DISPLAY, //3
|
||||||
|
CMD_SETCURSOR, //4
|
||||||
|
CMD_PIXEL, //5
|
||||||
|
CMD_LINE, //6
|
||||||
|
CMD_LINEH, //7
|
||||||
|
CMD_LINEV, //8
|
||||||
|
CMD_RECT, //9
|
||||||
|
CMD_RECTFILL, //10
|
||||||
|
CMD_CIRCLE, //11
|
||||||
|
CMD_CIRCLEFILL, //12
|
||||||
|
CMD_DRAWCHAR, //13
|
||||||
|
CMD_DRAWBITMAP, //14
|
||||||
|
CMD_GETLCDWIDTH, //15
|
||||||
|
CMD_GETLCDHEIGHT, //16
|
||||||
|
CMD_SETCOLOR, //17
|
||||||
|
CMD_SETDRAWMODE //18
|
||||||
|
} commCommand_t;
|
31
drivers/qwiic/qwiic.c
Normal file
31
drivers/qwiic/qwiic.c
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
/* Copyright 2018 Jack Humbert <jack.humb@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 "qwiic.h"
|
||||||
|
|
||||||
|
void qwiic_init(void) {
|
||||||
|
#ifdef QWIIC_JOYSTIIC_ENABLE
|
||||||
|
joystiic_init();
|
||||||
|
#endif
|
||||||
|
#ifdef QWIIC_MICRO_OLED_ENABLE
|
||||||
|
micro_oled_init();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void qwiic_task(void) {
|
||||||
|
#ifdef QWIIC_JOYSTIIC_ENABLE
|
||||||
|
joystiic_task();
|
||||||
|
#endif
|
||||||
|
}
|
28
drivers/qwiic/qwiic.h
Normal file
28
drivers/qwiic/qwiic.h
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
/* Copyright 2018 Jack Humbert <jack.humb@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 "i2c_master.h"
|
||||||
|
|
||||||
|
#ifdef QWIIC_JOYSTIIC_ENABLE
|
||||||
|
#include "joystiic.h"
|
||||||
|
#endif
|
||||||
|
#ifdef QWIIC_MICRO_OLED_ENABLE
|
||||||
|
#include "micro_oled.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void qwiic_init(void);
|
||||||
|
void qwiic_task(void);
|
18
drivers/qwiic/qwiic.mk
Normal file
18
drivers/qwiic/qwiic.mk
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
ifneq ($(strip $(QWIIC_ENABLE)),)
|
||||||
|
COMMON_VPATH += $(DRIVER_PATH)/qwiic
|
||||||
|
OPT_DEFS += -DQWIIC_ENABLE
|
||||||
|
SRC += qwiic.c
|
||||||
|
ifeq ($(filter "i2c_master.c", $(SRC)),)
|
||||||
|
SRC += i2c_master.c
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(filter JOYSTIIC, $(QWIIC_ENABLE)),)
|
||||||
|
OPT_DEFS += -DQWIIC_JOYSTIIC_ENABLE
|
||||||
|
SRC += joystiic.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(filter MICRO_OLED, $(QWIIC_ENABLE)),)
|
||||||
|
OPT_DEFS += -DQWIIC_MICRO_OLED_ENABLE
|
||||||
|
SRC += micro_oled.c
|
||||||
|
endif
|
7
drivers/qwiic/readme.md
Normal file
7
drivers/qwiic/readme.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# Qwiic Devices
|
||||||
|
|
||||||
|
[More info on Sparkfun's Qwiic Connect System](https://www.sparkfun.com/qwiic)
|
||||||
|
|
||||||
|
Currently supported devices:
|
||||||
|
|
||||||
|
* [Joystiic](https://www.sparkfun.com/products/14656)
|
288
drivers/qwiic/util/font5x7.h
Normal file
288
drivers/qwiic/util/font5x7.h
Normal file
|
@ -0,0 +1,288 @@
|
||||||
|
/******************************************************************************
|
||||||
|
font5x7.h
|
||||||
|
Definition for small font
|
||||||
|
|
||||||
|
This file was imported from the MicroView library, written by GeekAmmo
|
||||||
|
(https://github.com/geekammo/MicroView-Arduino-Library), and released under
|
||||||
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
Foundation, either version 3 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/>.
|
||||||
|
|
||||||
|
Modified by:
|
||||||
|
Emil Varughese @ Edwin Robotics Pvt. Ltd.
|
||||||
|
July 27, 2015
|
||||||
|
https://github.com/emil01/SparkFun_Micro_OLED_Arduino_Library/
|
||||||
|
|
||||||
|
******************************************************************************/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "progmem.h"
|
||||||
|
|
||||||
|
// Standard ASCII 5x7 font
|
||||||
|
static const unsigned char font5x7[] PROGMEM = {
|
||||||
|
// first row defines - FONTWIDTH, FONTHEIGHT, ASCII START CHAR, TOTAL CHARACTERS, FONT MAP WIDTH HIGH, FONT MAP WIDTH LOW (2,56 meaning 256)
|
||||||
|
5,8,0,255,12,75,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x3E, 0x5B, 0x4F, 0x5B, 0x3E,
|
||||||
|
0x3E, 0x6B, 0x4F, 0x6B, 0x3E,
|
||||||
|
0x1C, 0x3E, 0x7C, 0x3E, 0x1C,
|
||||||
|
0x18, 0x3C, 0x7E, 0x3C, 0x18,
|
||||||
|
0x1C, 0x57, 0x7D, 0x57, 0x1C,
|
||||||
|
0x1C, 0x5E, 0x7F, 0x5E, 0x1C,
|
||||||
|
0x00, 0x18, 0x3C, 0x18, 0x00,
|
||||||
|
0xFF, 0xE7, 0xC3, 0xE7, 0xFF,
|
||||||
|
0x00, 0x18, 0x24, 0x18, 0x00,
|
||||||
|
0xFF, 0xE7, 0xDB, 0xE7, 0xFF,
|
||||||
|
0x30, 0x48, 0x3A, 0x06, 0x0E,
|
||||||
|
0x26, 0x29, 0x79, 0x29, 0x26,
|
||||||
|
0x40, 0x7F, 0x05, 0x05, 0x07,
|
||||||
|
0x40, 0x7F, 0x05, 0x25, 0x3F,
|
||||||
|
0x5A, 0x3C, 0xE7, 0x3C, 0x5A,
|
||||||
|
0x7F, 0x3E, 0x1C, 0x1C, 0x08,
|
||||||
|
0x08, 0x1C, 0x1C, 0x3E, 0x7F,
|
||||||
|
0x14, 0x22, 0x7F, 0x22, 0x14,
|
||||||
|
0x5F, 0x5F, 0x00, 0x5F, 0x5F,
|
||||||
|
0x06, 0x09, 0x7F, 0x01, 0x7F,
|
||||||
|
0x00, 0x66, 0x89, 0x95, 0x6A,
|
||||||
|
0x60, 0x60, 0x60, 0x60, 0x60,
|
||||||
|
0x94, 0xA2, 0xFF, 0xA2, 0x94,
|
||||||
|
0x08, 0x04, 0x7E, 0x04, 0x08,
|
||||||
|
0x10, 0x20, 0x7E, 0x20, 0x10,
|
||||||
|
0x08, 0x08, 0x2A, 0x1C, 0x08,
|
||||||
|
0x08, 0x1C, 0x2A, 0x08, 0x08,
|
||||||
|
0x1E, 0x10, 0x10, 0x10, 0x10,
|
||||||
|
0x0C, 0x1E, 0x0C, 0x1E, 0x0C,
|
||||||
|
0x30, 0x38, 0x3E, 0x38, 0x30,
|
||||||
|
0x06, 0x0E, 0x3E, 0x0E, 0x06,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x5F, 0x00, 0x00,
|
||||||
|
0x00, 0x07, 0x00, 0x07, 0x00,
|
||||||
|
0x14, 0x7F, 0x14, 0x7F, 0x14,
|
||||||
|
0x24, 0x2A, 0x7F, 0x2A, 0x12,
|
||||||
|
0x23, 0x13, 0x08, 0x64, 0x62,
|
||||||
|
0x36, 0x49, 0x56, 0x20, 0x50,
|
||||||
|
0x00, 0x08, 0x07, 0x03, 0x00,
|
||||||
|
0x00, 0x1C, 0x22, 0x41, 0x00,
|
||||||
|
0x00, 0x41, 0x22, 0x1C, 0x00,
|
||||||
|
0x2A, 0x1C, 0x7F, 0x1C, 0x2A,
|
||||||
|
0x08, 0x08, 0x3E, 0x08, 0x08,
|
||||||
|
0x00, 0x80, 0x70, 0x30, 0x00,
|
||||||
|
0x08, 0x08, 0x08, 0x08, 0x08,
|
||||||
|
0x00, 0x00, 0x60, 0x60, 0x00,
|
||||||
|
0x20, 0x10, 0x08, 0x04, 0x02,
|
||||||
|
0x3E, 0x51, 0x49, 0x45, 0x3E,
|
||||||
|
0x00, 0x42, 0x7F, 0x40, 0x00,
|
||||||
|
0x72, 0x49, 0x49, 0x49, 0x46,
|
||||||
|
0x21, 0x41, 0x49, 0x4D, 0x33,
|
||||||
|
0x18, 0x14, 0x12, 0x7F, 0x10,
|
||||||
|
0x27, 0x45, 0x45, 0x45, 0x39,
|
||||||
|
0x3C, 0x4A, 0x49, 0x49, 0x31,
|
||||||
|
0x41, 0x21, 0x11, 0x09, 0x07,
|
||||||
|
0x36, 0x49, 0x49, 0x49, 0x36,
|
||||||
|
0x46, 0x49, 0x49, 0x29, 0x1E,
|
||||||
|
0x00, 0x00, 0x14, 0x00, 0x00,
|
||||||
|
0x00, 0x40, 0x34, 0x00, 0x00,
|
||||||
|
0x00, 0x08, 0x14, 0x22, 0x41,
|
||||||
|
0x14, 0x14, 0x14, 0x14, 0x14,
|
||||||
|
0x00, 0x41, 0x22, 0x14, 0x08,
|
||||||
|
0x02, 0x01, 0x59, 0x09, 0x06,
|
||||||
|
0x3E, 0x41, 0x5D, 0x59, 0x4E,
|
||||||
|
0x7C, 0x12, 0x11, 0x12, 0x7C,
|
||||||
|
0x7F, 0x49, 0x49, 0x49, 0x36,
|
||||||
|
0x3E, 0x41, 0x41, 0x41, 0x22,
|
||||||
|
0x7F, 0x41, 0x41, 0x41, 0x3E,
|
||||||
|
0x7F, 0x49, 0x49, 0x49, 0x41,
|
||||||
|
0x7F, 0x09, 0x09, 0x09, 0x01,
|
||||||
|
0x3E, 0x41, 0x41, 0x51, 0x73,
|
||||||
|
0x7F, 0x08, 0x08, 0x08, 0x7F,
|
||||||
|
0x00, 0x41, 0x7F, 0x41, 0x00,
|
||||||
|
0x20, 0x40, 0x41, 0x3F, 0x01,
|
||||||
|
0x7F, 0x08, 0x14, 0x22, 0x41,
|
||||||
|
0x7F, 0x40, 0x40, 0x40, 0x40,
|
||||||
|
0x7F, 0x02, 0x1C, 0x02, 0x7F,
|
||||||
|
0x7F, 0x04, 0x08, 0x10, 0x7F,
|
||||||
|
0x3E, 0x41, 0x41, 0x41, 0x3E,
|
||||||
|
0x7F, 0x09, 0x09, 0x09, 0x06,
|
||||||
|
0x3E, 0x41, 0x51, 0x21, 0x5E,
|
||||||
|
0x7F, 0x09, 0x19, 0x29, 0x46,
|
||||||
|
0x26, 0x49, 0x49, 0x49, 0x32,
|
||||||
|
0x03, 0x01, 0x7F, 0x01, 0x03,
|
||||||
|
0x3F, 0x40, 0x40, 0x40, 0x3F,
|
||||||
|
0x1F, 0x20, 0x40, 0x20, 0x1F,
|
||||||
|
0x3F, 0x40, 0x38, 0x40, 0x3F,
|
||||||
|
0x63, 0x14, 0x08, 0x14, 0x63,
|
||||||
|
0x03, 0x04, 0x78, 0x04, 0x03,
|
||||||
|
0x61, 0x59, 0x49, 0x4D, 0x43,
|
||||||
|
0x00, 0x7F, 0x41, 0x41, 0x41,
|
||||||
|
0x02, 0x04, 0x08, 0x10, 0x20,
|
||||||
|
0x00, 0x41, 0x41, 0x41, 0x7F,
|
||||||
|
0x04, 0x02, 0x01, 0x02, 0x04,
|
||||||
|
0x40, 0x40, 0x40, 0x40, 0x40,
|
||||||
|
0x00, 0x03, 0x07, 0x08, 0x00,
|
||||||
|
0x20, 0x54, 0x54, 0x78, 0x40,
|
||||||
|
0x7F, 0x28, 0x44, 0x44, 0x38,
|
||||||
|
0x38, 0x44, 0x44, 0x44, 0x28,
|
||||||
|
0x38, 0x44, 0x44, 0x28, 0x7F,
|
||||||
|
0x38, 0x54, 0x54, 0x54, 0x18,
|
||||||
|
0x00, 0x08, 0x7E, 0x09, 0x02,
|
||||||
|
0x18, 0xA4, 0xA4, 0x9C, 0x78,
|
||||||
|
0x7F, 0x08, 0x04, 0x04, 0x78,
|
||||||
|
0x00, 0x44, 0x7D, 0x40, 0x00,
|
||||||
|
0x20, 0x40, 0x40, 0x3D, 0x00,
|
||||||
|
0x7F, 0x10, 0x28, 0x44, 0x00,
|
||||||
|
0x00, 0x41, 0x7F, 0x40, 0x00,
|
||||||
|
0x7C, 0x04, 0x78, 0x04, 0x78,
|
||||||
|
0x7C, 0x08, 0x04, 0x04, 0x78,
|
||||||
|
0x38, 0x44, 0x44, 0x44, 0x38,
|
||||||
|
0xFC, 0x18, 0x24, 0x24, 0x18,
|
||||||
|
0x18, 0x24, 0x24, 0x18, 0xFC,
|
||||||
|
0x7C, 0x08, 0x04, 0x04, 0x08,
|
||||||
|
0x48, 0x54, 0x54, 0x54, 0x24,
|
||||||
|
0x04, 0x04, 0x3F, 0x44, 0x24,
|
||||||
|
0x3C, 0x40, 0x40, 0x20, 0x7C,
|
||||||
|
0x1C, 0x20, 0x40, 0x20, 0x1C,
|
||||||
|
0x3C, 0x40, 0x30, 0x40, 0x3C,
|
||||||
|
0x44, 0x28, 0x10, 0x28, 0x44,
|
||||||
|
0x4C, 0x90, 0x90, 0x90, 0x7C,
|
||||||
|
0x44, 0x64, 0x54, 0x4C, 0x44,
|
||||||
|
0x00, 0x08, 0x36, 0x41, 0x00,
|
||||||
|
0x00, 0x00, 0x77, 0x00, 0x00,
|
||||||
|
0x00, 0x41, 0x36, 0x08, 0x00,
|
||||||
|
0x02, 0x01, 0x02, 0x04, 0x02,
|
||||||
|
0x3C, 0x26, 0x23, 0x26, 0x3C,
|
||||||
|
0x1E, 0xA1, 0xA1, 0x61, 0x12,
|
||||||
|
0x3A, 0x40, 0x40, 0x20, 0x7A,
|
||||||
|
0x38, 0x54, 0x54, 0x55, 0x59,
|
||||||
|
0x21, 0x55, 0x55, 0x79, 0x41,
|
||||||
|
0x21, 0x54, 0x54, 0x78, 0x41,
|
||||||
|
0x21, 0x55, 0x54, 0x78, 0x40,
|
||||||
|
0x20, 0x54, 0x55, 0x79, 0x40,
|
||||||
|
0x0C, 0x1E, 0x52, 0x72, 0x12,
|
||||||
|
0x39, 0x55, 0x55, 0x55, 0x59,
|
||||||
|
0x39, 0x54, 0x54, 0x54, 0x59,
|
||||||
|
0x39, 0x55, 0x54, 0x54, 0x58,
|
||||||
|
0x00, 0x00, 0x45, 0x7C, 0x41,
|
||||||
|
0x00, 0x02, 0x45, 0x7D, 0x42,
|
||||||
|
0x00, 0x01, 0x45, 0x7C, 0x40,
|
||||||
|
0xF0, 0x29, 0x24, 0x29, 0xF0,
|
||||||
|
0xF0, 0x28, 0x25, 0x28, 0xF0,
|
||||||
|
0x7C, 0x54, 0x55, 0x45, 0x00,
|
||||||
|
0x20, 0x54, 0x54, 0x7C, 0x54,
|
||||||
|
0x7C, 0x0A, 0x09, 0x7F, 0x49,
|
||||||
|
0x32, 0x49, 0x49, 0x49, 0x32,
|
||||||
|
0x32, 0x48, 0x48, 0x48, 0x32,
|
||||||
|
0x32, 0x4A, 0x48, 0x48, 0x30,
|
||||||
|
0x3A, 0x41, 0x41, 0x21, 0x7A,
|
||||||
|
0x3A, 0x42, 0x40, 0x20, 0x78,
|
||||||
|
0x00, 0x9D, 0xA0, 0xA0, 0x7D,
|
||||||
|
0x39, 0x44, 0x44, 0x44, 0x39,
|
||||||
|
0x3D, 0x40, 0x40, 0x40, 0x3D,
|
||||||
|
0x3C, 0x24, 0xFF, 0x24, 0x24,
|
||||||
|
0x48, 0x7E, 0x49, 0x43, 0x66,
|
||||||
|
0x2B, 0x2F, 0xFC, 0x2F, 0x2B,
|
||||||
|
0xFF, 0x09, 0x29, 0xF6, 0x20,
|
||||||
|
0xC0, 0x88, 0x7E, 0x09, 0x03,
|
||||||
|
0x20, 0x54, 0x54, 0x79, 0x41,
|
||||||
|
0x00, 0x00, 0x44, 0x7D, 0x41,
|
||||||
|
0x30, 0x48, 0x48, 0x4A, 0x32,
|
||||||
|
0x38, 0x40, 0x40, 0x22, 0x7A,
|
||||||
|
0x00, 0x7A, 0x0A, 0x0A, 0x72,
|
||||||
|
0x7D, 0x0D, 0x19, 0x31, 0x7D,
|
||||||
|
0x26, 0x29, 0x29, 0x2F, 0x28,
|
||||||
|
0x26, 0x29, 0x29, 0x29, 0x26,
|
||||||
|
0x30, 0x48, 0x4D, 0x40, 0x20,
|
||||||
|
0x38, 0x08, 0x08, 0x08, 0x08,
|
||||||
|
0x08, 0x08, 0x08, 0x08, 0x38,
|
||||||
|
0x2F, 0x10, 0xC8, 0xAC, 0xBA,
|
||||||
|
0x2F, 0x10, 0x28, 0x34, 0xFA,
|
||||||
|
0x00, 0x00, 0x7B, 0x00, 0x00,
|
||||||
|
0x08, 0x14, 0x2A, 0x14, 0x22,
|
||||||
|
0x22, 0x14, 0x2A, 0x14, 0x08,
|
||||||
|
0xAA, 0x00, 0x55, 0x00, 0xAA,
|
||||||
|
0xAA, 0x55, 0xAA, 0x55, 0xAA,
|
||||||
|
0x00, 0x00, 0x00, 0xFF, 0x00,
|
||||||
|
0x10, 0x10, 0x10, 0xFF, 0x00,
|
||||||
|
0x14, 0x14, 0x14, 0xFF, 0x00,
|
||||||
|
0x10, 0x10, 0xFF, 0x00, 0xFF,
|
||||||
|
0x10, 0x10, 0xF0, 0x10, 0xF0,
|
||||||
|
0x14, 0x14, 0x14, 0xFC, 0x00,
|
||||||
|
0x14, 0x14, 0xF7, 0x00, 0xFF,
|
||||||
|
0x00, 0x00, 0xFF, 0x00, 0xFF,
|
||||||
|
0x14, 0x14, 0xF4, 0x04, 0xFC,
|
||||||
|
0x14, 0x14, 0x17, 0x10, 0x1F,
|
||||||
|
0x10, 0x10, 0x1F, 0x10, 0x1F,
|
||||||
|
0x14, 0x14, 0x14, 0x1F, 0x00,
|
||||||
|
0x10, 0x10, 0x10, 0xF0, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x1F, 0x10,
|
||||||
|
0x10, 0x10, 0x10, 0x1F, 0x10,
|
||||||
|
0x10, 0x10, 0x10, 0xF0, 0x10,
|
||||||
|
0x00, 0x00, 0x00, 0xFF, 0x10,
|
||||||
|
0x10, 0x10, 0x10, 0x10, 0x10,
|
||||||
|
0x10, 0x10, 0x10, 0xFF, 0x10,
|
||||||
|
0x00, 0x00, 0x00, 0xFF, 0x14,
|
||||||
|
0x00, 0x00, 0xFF, 0x00, 0xFF,
|
||||||
|
0x00, 0x00, 0x1F, 0x10, 0x17,
|
||||||
|
0x00, 0x00, 0xFC, 0x04, 0xF4,
|
||||||
|
0x14, 0x14, 0x17, 0x10, 0x17,
|
||||||
|
0x14, 0x14, 0xF4, 0x04, 0xF4,
|
||||||
|
0x00, 0x00, 0xFF, 0x00, 0xF7,
|
||||||
|
0x14, 0x14, 0x14, 0x14, 0x14,
|
||||||
|
0x14, 0x14, 0xF7, 0x00, 0xF7,
|
||||||
|
0x14, 0x14, 0x14, 0x17, 0x14,
|
||||||
|
0x10, 0x10, 0x1F, 0x10, 0x1F,
|
||||||
|
0x14, 0x14, 0x14, 0xF4, 0x14,
|
||||||
|
0x10, 0x10, 0xF0, 0x10, 0xF0,
|
||||||
|
0x00, 0x00, 0x1F, 0x10, 0x1F,
|
||||||
|
0x00, 0x00, 0x00, 0x1F, 0x14,
|
||||||
|
0x00, 0x00, 0x00, 0xFC, 0x14,
|
||||||
|
0x00, 0x00, 0xF0, 0x10, 0xF0,
|
||||||
|
0x10, 0x10, 0xFF, 0x10, 0xFF,
|
||||||
|
0x14, 0x14, 0x14, 0xFF, 0x14,
|
||||||
|
0x10, 0x10, 0x10, 0x1F, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0xF0, 0x10,
|
||||||
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||||
|
0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
|
||||||
|
0xFF, 0xFF, 0xFF, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0xFF, 0xFF,
|
||||||
|
0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
|
||||||
|
0x38, 0x44, 0x44, 0x38, 0x44,
|
||||||
|
0x7C, 0x2A, 0x2A, 0x3E, 0x14,
|
||||||
|
0x7E, 0x02, 0x02, 0x06, 0x06,
|
||||||
|
0x02, 0x7E, 0x02, 0x7E, 0x02,
|
||||||
|
0x63, 0x55, 0x49, 0x41, 0x63,
|
||||||
|
0x38, 0x44, 0x44, 0x3C, 0x04,
|
||||||
|
0x40, 0x7E, 0x20, 0x1E, 0x20,
|
||||||
|
0x06, 0x02, 0x7E, 0x02, 0x02,
|
||||||
|
0x99, 0xA5, 0xE7, 0xA5, 0x99,
|
||||||
|
0x1C, 0x2A, 0x49, 0x2A, 0x1C,
|
||||||
|
0x4C, 0x72, 0x01, 0x72, 0x4C,
|
||||||
|
0x30, 0x4A, 0x4D, 0x4D, 0x30,
|
||||||
|
0x30, 0x48, 0x78, 0x48, 0x30,
|
||||||
|
0xBC, 0x62, 0x5A, 0x46, 0x3D,
|
||||||
|
0x3E, 0x49, 0x49, 0x49, 0x00,
|
||||||
|
0x7E, 0x01, 0x01, 0x01, 0x7E,
|
||||||
|
0x2A, 0x2A, 0x2A, 0x2A, 0x2A,
|
||||||
|
0x44, 0x44, 0x5F, 0x44, 0x44,
|
||||||
|
0x40, 0x51, 0x4A, 0x44, 0x40,
|
||||||
|
0x40, 0x44, 0x4A, 0x51, 0x40,
|
||||||
|
0x00, 0x00, 0xFF, 0x01, 0x03,
|
||||||
|
0xE0, 0x80, 0xFF, 0x00, 0x00,
|
||||||
|
0x08, 0x08, 0x6B, 0x6B, 0x08,
|
||||||
|
0x36, 0x12, 0x36, 0x24, 0x36,
|
||||||
|
0x06, 0x0F, 0x09, 0x0F, 0x06,
|
||||||
|
0x00, 0x00, 0x18, 0x18, 0x00,
|
||||||
|
0x00, 0x00, 0x10, 0x10, 0x00,
|
||||||
|
0x30, 0x40, 0xFF, 0x01, 0x01,
|
||||||
|
0x00, 0x1F, 0x01, 0x01, 0x1E,
|
||||||
|
0x00, 0x19, 0x1D, 0x17, 0x12,
|
||||||
|
0x00, 0x3C, 0x3C, 0x3C, 0x3C,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00
|
||||||
|
};
|
127
drivers/qwiic/util/font8x16.h
Normal file
127
drivers/qwiic/util/font8x16.h
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
/******************************************************************************
|
||||||
|
font8x16.h
|
||||||
|
Definition for medium font
|
||||||
|
|
||||||
|
This file was imported from the MicroView library, written by GeekAmmo
|
||||||
|
(https://github.com/geekammo/MicroView-Arduino-Library), and released under
|
||||||
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
Foundation, either version 3 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/>.
|
||||||
|
|
||||||
|
Modified by:
|
||||||
|
Emil Varughese @ Edwin Robotics Pvt. Ltd.
|
||||||
|
July 27, 2015
|
||||||
|
https://github.com/emil01/SparkFun_Micro_OLED_Arduino_Library/
|
||||||
|
******************************************************************************/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "progmem.h"
|
||||||
|
|
||||||
|
static const unsigned char font8x16[] PROGMEM = {
|
||||||
|
// first row defines - FONTWIDTH, FONTHEIGHT, ASCII START CHAR, TOTAL CHARACTERS, FONT MAP WIDTH HIGH, FONT MAP WIDTH LOW (2,56 meaning 256)
|
||||||
|
8,16,32,96,2,56,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0xD0, 0xBE, 0x90, 0xD0, 0xBE, 0x90, 0x00,
|
||||||
|
0x00, 0x1C, 0x62, 0xFF, 0xC2, 0x80, 0x00, 0x00, 0x0C, 0x12, 0x92, 0x4C, 0xB0, 0x88, 0x06, 0x00,
|
||||||
|
0x80, 0x7C, 0x62, 0xB2, 0x1C, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x0E, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0xE0, 0x18, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x02, 0x02, 0x04, 0x18, 0xE0, 0x00, 0x00,
|
||||||
|
0x00, 0x24, 0x18, 0x7E, 0x18, 0x24, 0x00, 0x00, 0x80, 0x80, 0x80, 0xF0, 0x80, 0x80, 0x80, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x60, 0x18, 0x06, 0x00, 0x00,
|
||||||
|
0xF8, 0x04, 0xC2, 0x32, 0x0C, 0xF8, 0x00, 0x00, 0x00, 0x04, 0x04, 0xFE, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x02, 0x82, 0x42, 0x22, 0x1C, 0x00, 0x00, 0x00, 0x02, 0x22, 0x22, 0x22, 0xDC, 0x00, 0x00,
|
||||||
|
0xC0, 0xA0, 0x98, 0x84, 0xFE, 0x80, 0x80, 0x00, 0x00, 0x1E, 0x12, 0x12, 0x22, 0xC2, 0x00, 0x00,
|
||||||
|
0xF8, 0x44, 0x22, 0x22, 0x22, 0xC0, 0x00, 0x00, 0x00, 0x02, 0x02, 0xC2, 0x32, 0x0A, 0x06, 0x00,
|
||||||
|
0x00, 0x8C, 0x52, 0x22, 0x52, 0x8C, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x26, 0xF8, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x80, 0x80, 0x40, 0x40, 0x20, 0x20, 0x10, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00,
|
||||||
|
0x10, 0x20, 0x20, 0x40, 0x40, 0x80, 0x80, 0x00, 0x00, 0x02, 0x82, 0x42, 0x22, 0x1C, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x04, 0x04, 0x0F, 0x04, 0x03, 0x00, 0x00, 0x04, 0x02, 0x01, 0x03, 0x04, 0x04, 0x03, 0x00,
|
||||||
|
0x03, 0x04, 0x04, 0x04, 0x05, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x03, 0x06, 0x08, 0x10, 0x10, 0x00, 0x00, 0x00, 0x10, 0x10, 0x08, 0x06, 0x03, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x16, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x01, 0x03, 0x04, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x04, 0x04, 0x07, 0x04, 0x04, 0x00, 0x00,
|
||||||
|
0x00, 0x07, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00,
|
||||||
|
0x01, 0x02, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x03, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x02, 0x01, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x0E, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x04, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,
|
||||||
|
0x04, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0xF8, 0x04, 0x72, 0x8A, 0xFA, 0x84, 0x78, 0x00, 0x00, 0xC0, 0x38, 0x06, 0x38, 0xC0, 0x00, 0x00,
|
||||||
|
0x00, 0xFE, 0x22, 0x22, 0x22, 0xDC, 0x00, 0x00, 0xF8, 0x04, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00,
|
||||||
|
0xFE, 0x02, 0x02, 0x02, 0x04, 0xF8, 0x00, 0x00, 0x00, 0xFE, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00,
|
||||||
|
0x00, 0xFE, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0xF8, 0x04, 0x02, 0x02, 0x22, 0xE2, 0x00, 0x00,
|
||||||
|
0xFE, 0x20, 0x20, 0x20, 0x20, 0xFE, 0x00, 0x00, 0x00, 0x02, 0x02, 0xFE, 0x02, 0x02, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x02, 0x02, 0xFE, 0x00, 0x00, 0xFE, 0x40, 0xB0, 0x08, 0x04, 0x02, 0x00, 0x00,
|
||||||
|
0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x0C, 0x70, 0x80, 0x70, 0x0C, 0xFE, 0x00,
|
||||||
|
0xFE, 0x0C, 0x30, 0xC0, 0x00, 0xFE, 0x00, 0x00, 0xF8, 0x04, 0x02, 0x02, 0x04, 0xF8, 0x00, 0x00,
|
||||||
|
0xFE, 0x42, 0x42, 0x42, 0x22, 0x1C, 0x00, 0x00, 0xF8, 0x04, 0x02, 0x02, 0x04, 0xF8, 0x00, 0x00,
|
||||||
|
0x00, 0xFE, 0x42, 0x42, 0xA2, 0x1C, 0x00, 0x00, 0x00, 0x1C, 0x22, 0x42, 0x42, 0x80, 0x00, 0x00,
|
||||||
|
0x02, 0x02, 0x02, 0xFE, 0x02, 0x02, 0x02, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00,
|
||||||
|
0x06, 0x38, 0xC0, 0x00, 0xC0, 0x38, 0x06, 0x00, 0x3E, 0xC0, 0xF0, 0x0E, 0xF0, 0xC0, 0x3E, 0x00,
|
||||||
|
0x00, 0x06, 0x98, 0x60, 0x98, 0x06, 0x00, 0x00, 0x00, 0x06, 0x18, 0xE0, 0x18, 0x06, 0x00, 0x00,
|
||||||
|
0x02, 0x02, 0xC2, 0x32, 0x0A, 0x06, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x02, 0x02, 0x02, 0x02, 0x00,
|
||||||
|
0x00, 0x06, 0x18, 0x60, 0x80, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0xFE, 0x00, 0x00, 0x00,
|
||||||
|
0x40, 0x30, 0x0C, 0x0C, 0x30, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x01, 0x02, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x06, 0x01, 0x01, 0x01, 0x01, 0x01, 0x06, 0x00,
|
||||||
|
0x00, 0x07, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x01, 0x02, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00,
|
||||||
|
0x07, 0x04, 0x04, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00,
|
||||||
|
0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x04, 0x04, 0x07, 0x00, 0x00,
|
||||||
|
0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x04, 0x07, 0x04, 0x04, 0x00, 0x00,
|
||||||
|
0x00, 0x04, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x07, 0x00, 0x00, 0x01, 0x02, 0x04, 0x00, 0x00,
|
||||||
|
0x00, 0x07, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00, 0x07, 0x00,
|
||||||
|
0x07, 0x00, 0x00, 0x00, 0x03, 0x07, 0x00, 0x00, 0x01, 0x02, 0x04, 0x04, 0x02, 0x01, 0x00, 0x00,
|
||||||
|
0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x0C, 0x12, 0x11, 0x10, 0x00,
|
||||||
|
0x00, 0x07, 0x00, 0x00, 0x01, 0x06, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x01, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00,
|
||||||
|
0x00, 0x06, 0x01, 0x00, 0x01, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x06, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x00, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00,
|
||||||
|
0x00, 0xFE, 0x20, 0x10, 0x10, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00,
|
||||||
|
0x00, 0xE0, 0x10, 0x10, 0x10, 0xFE, 0x00, 0x00, 0x00, 0xE0, 0x90, 0x90, 0x90, 0xE0, 0x00, 0x00,
|
||||||
|
0x00, 0x20, 0xFC, 0x22, 0x22, 0x22, 0x02, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00,
|
||||||
|
0x00, 0xFE, 0x20, 0x10, 0x10, 0xE0, 0x00, 0x00, 0x10, 0x10, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x10, 0x10, 0x10, 0xF2, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x80, 0x40, 0x20, 0x10, 0x00, 0x00,
|
||||||
|
0x00, 0x02, 0x02, 0xFE, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x20, 0x10, 0xF0, 0x20, 0x10, 0xF0, 0x00,
|
||||||
|
0x00, 0xF0, 0x20, 0x10, 0x10, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0xE0, 0x00, 0x00,
|
||||||
|
0x00, 0xF0, 0x20, 0x10, 0x10, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00,
|
||||||
|
0x00, 0xF0, 0x20, 0x10, 0x10, 0x70, 0x00, 0x00, 0x00, 0x60, 0x90, 0x90, 0x90, 0x20, 0x00, 0x00,
|
||||||
|
0x00, 0x20, 0x20, 0xFC, 0x20, 0x20, 0x20, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00,
|
||||||
|
0x00, 0x70, 0x80, 0x00, 0x80, 0x70, 0x00, 0x00, 0xF0, 0x00, 0xC0, 0x30, 0xC0, 0x00, 0xF0, 0x00,
|
||||||
|
0x00, 0x30, 0xC0, 0xC0, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0xC0, 0x00, 0x80, 0x70, 0x00, 0x00,
|
||||||
|
0x00, 0x10, 0x10, 0x90, 0x50, 0x30, 0x00, 0x00, 0x00, 0x80, 0x80, 0x7E, 0x02, 0x02, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x7E, 0x80, 0x80, 0x00, 0x00,
|
||||||
|
0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x02, 0x07, 0x00, 0x00,
|
||||||
|
0x00, 0x07, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00,
|
||||||
|
0x00, 0x03, 0x04, 0x04, 0x02, 0x07, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x24, 0x24, 0x22, 0x1F, 0x00, 0x00,
|
||||||
|
0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x00, 0x00, 0x00,
|
||||||
|
0x20, 0x20, 0x20, 0x20, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x01, 0x02, 0x04, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x00, 0x00, 0x07, 0x00, 0x00, 0x07, 0x00, 0x00, 0x07, 0x00,
|
||||||
|
0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00,
|
||||||
|
0x00, 0x3F, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x02, 0x3F, 0x00, 0x00,
|
||||||
|
0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x00, 0x00, 0x03, 0x04, 0x04, 0x02, 0x07, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x03, 0x04, 0x03, 0x00, 0x00, 0x00, 0x01, 0x06, 0x01, 0x00, 0x01, 0x06, 0x01, 0x00,
|
||||||
|
0x00, 0x06, 0x01, 0x01, 0x06, 0x00, 0x00, 0x00, 0x20, 0x20, 0x31, 0x0E, 0x03, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x06, 0x05, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||||
|
};
|
|
@ -76,7 +76,7 @@
|
||||||
* @brief Enables the I2C subsystem.
|
* @brief Enables the I2C subsystem.
|
||||||
*/
|
*/
|
||||||
#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
|
#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
|
||||||
#define HAL_USE_I2C FALSE
|
#define HAL_USE_I2C TRUE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -90,6 +90,9 @@ void dip_update(uint8_t index, bool active) { }
|
||||||
__attribute__ ((weak))
|
__attribute__ ((weak))
|
||||||
void encoder_update(bool clockwise) { }
|
void encoder_update(bool clockwise) { }
|
||||||
|
|
||||||
|
__attribute__ ((weak))
|
||||||
|
void encoder_update_kb(uint8_t index, bool clockwise) { }
|
||||||
|
|
||||||
bool last_dip_switch[4] = {0};
|
bool last_dip_switch[4] = {0};
|
||||||
|
|
||||||
#ifndef ENCODER_RESOLUTION
|
#ifndef ENCODER_RESOLUTION
|
||||||
|
@ -114,9 +117,11 @@ uint8_t matrix_scan(void) {
|
||||||
encoder_value += encoder_LUT[encoder_state & 0xF];
|
encoder_value += encoder_LUT[encoder_state & 0xF];
|
||||||
if (encoder_value >= ENCODER_RESOLUTION) {
|
if (encoder_value >= ENCODER_RESOLUTION) {
|
||||||
encoder_update(0);
|
encoder_update(0);
|
||||||
|
encoder_update_kb(0, 0);
|
||||||
}
|
}
|
||||||
if (encoder_value <= -ENCODER_RESOLUTION) { // direction is arbitrary here, but this clockwise
|
if (encoder_value <= -ENCODER_RESOLUTION) { // direction is arbitrary here, but this clockwise
|
||||||
encoder_update(1);
|
encoder_update(1);
|
||||||
|
encoder_update_kb(0, 1);
|
||||||
}
|
}
|
||||||
encoder_value %= ENCODER_RESOLUTION;
|
encoder_value %= ENCODER_RESOLUTION;
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@
|
||||||
/*
|
/*
|
||||||
* I2C driver system settings.
|
* I2C driver system settings.
|
||||||
*/
|
*/
|
||||||
#define STM32_I2C_USE_I2C1 FALSE
|
#define STM32_I2C_USE_I2C1 TRUE
|
||||||
#define STM32_I2C_USE_I2C2 FALSE
|
#define STM32_I2C_USE_I2C2 FALSE
|
||||||
#define STM32_I2C_BUSY_TIMEOUT 50
|
#define STM32_I2C_BUSY_TIMEOUT 50
|
||||||
#define STM32_I2C_I2C1_IRQ_PRIORITY 10
|
#define STM32_I2C_I2C1_IRQ_PRIORITY 10
|
||||||
|
|
|
@ -14,11 +14,116 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "rev6.h"
|
#include "rev6.h"
|
||||||
|
#include "qwiic.h"
|
||||||
|
#include "action_layer.h"
|
||||||
|
#include "matrix.h"
|
||||||
|
|
||||||
|
#ifdef QWIIC_MICRO_OLED_ENABLE
|
||||||
|
|
||||||
|
static uint8_t layer;
|
||||||
|
static bool queue_for_send = false;
|
||||||
|
static uint8_t encoder_value = 32;
|
||||||
|
|
||||||
|
void draw_ui(void) {
|
||||||
|
clear_buffer();
|
||||||
|
draw_string(0, 2, "LAYER", PIXEL_ON, NORM, 0);
|
||||||
|
draw_rect_filled_soft(32, 0, 11, 11, PIXEL_ON, NORM);
|
||||||
|
draw_char(35, 2, layer + 0x30, PIXEL_ON, XOR, 0);
|
||||||
|
|
||||||
|
#define MATRIX_DISPLAY_X 46
|
||||||
|
#define MATRIX_DISPLAY_Y 1
|
||||||
|
|
||||||
|
for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
|
||||||
|
for (uint8_t y = 0; y < MATRIX_COLS; y++) {
|
||||||
|
if (x < 4)
|
||||||
|
draw_pixel(MATRIX_DISPLAY_X + 2 + y, MATRIX_DISPLAY_Y + 2 + x, (matrix_get_row(x) & (1 << y)) > 0, NORM);
|
||||||
|
else
|
||||||
|
draw_pixel(MATRIX_DISPLAY_X + 8 + y, MATRIX_DISPLAY_Y - 2 + x, (matrix_get_row(x) & (1 << y)) > 0, NORM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
draw_rect_soft(MATRIX_DISPLAY_X, MATRIX_DISPLAY_Y, 16, 8, PIXEL_ON, NORM);
|
||||||
|
|
||||||
|
|
||||||
|
draw_rect_soft(0, 13, 64, 6, PIXEL_ON, NORM);
|
||||||
|
draw_line_vert(encoder_value, 13, 6, PIXEL_ON, NORM);
|
||||||
|
|
||||||
|
|
||||||
|
#define MOD_DISPLAY_X 0
|
||||||
|
#define MOD_DISPLAY_Y 22
|
||||||
|
|
||||||
|
uint8_t mods = get_mods();
|
||||||
|
if (mods & MOD_LSFT) {
|
||||||
|
draw_rect_filled_soft(MOD_DISPLAY_X + 0, MOD_DISPLAY_Y, 5 + (1 * 6), 11, PIXEL_ON, NORM);
|
||||||
|
draw_string(MOD_DISPLAY_X + 3, MOD_DISPLAY_Y + 2, "S", PIXEL_OFF, NORM, 0);
|
||||||
|
} else {
|
||||||
|
draw_string(MOD_DISPLAY_X + 3, MOD_DISPLAY_Y + 2, "S", PIXEL_ON, NORM, 0);
|
||||||
|
}
|
||||||
|
if (mods & MOD_LCTL) {
|
||||||
|
draw_rect_filled_soft(MOD_DISPLAY_X + 10, MOD_DISPLAY_Y, 5 + (1 * 6), 11, PIXEL_ON, NORM);
|
||||||
|
draw_string(MOD_DISPLAY_X + 13, MOD_DISPLAY_Y + 2, "C", PIXEL_OFF, NORM, 0);
|
||||||
|
} else {
|
||||||
|
draw_string(MOD_DISPLAY_X + 13, MOD_DISPLAY_Y + 2, "C", PIXEL_ON, NORM, 0);
|
||||||
|
}
|
||||||
|
if (mods & MOD_LALT) {
|
||||||
|
draw_rect_filled_soft(MOD_DISPLAY_X + 20, MOD_DISPLAY_Y, 5 + (1 * 6), 11, PIXEL_ON, NORM);
|
||||||
|
draw_string(MOD_DISPLAY_X + 23, MOD_DISPLAY_Y + 2, "A", PIXEL_OFF, NORM, 0);
|
||||||
|
} else {
|
||||||
|
draw_string(MOD_DISPLAY_X + 23, MOD_DISPLAY_Y + 2, "A", PIXEL_ON, NORM, 0);
|
||||||
|
}
|
||||||
|
if (mods & MOD_LGUI) {
|
||||||
|
draw_rect_filled_soft(MOD_DISPLAY_X + 30, MOD_DISPLAY_Y, 5 + (1 * 6), 11, PIXEL_ON, NORM);
|
||||||
|
draw_string(MOD_DISPLAY_X + 33, MOD_DISPLAY_Y + 2, "G", PIXEL_OFF, NORM, 0);
|
||||||
|
} else {
|
||||||
|
draw_string(MOD_DISPLAY_X + 33, MOD_DISPLAY_Y + 2, "G", PIXEL_ON, NORM, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
send_buffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t layer_state_set_kb(uint32_t state) {
|
||||||
|
state = layer_state_set_user(state);
|
||||||
|
layer = biton32(state);
|
||||||
|
queue_for_send = true;
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
||||||
|
queue_for_send = true;
|
||||||
|
return process_record_user(keycode, record);
|
||||||
|
}
|
||||||
|
|
||||||
|
void encoder_update_kb(uint8_t index, bool clockwise) {
|
||||||
|
encoder_value = (encoder_value + (clockwise ? 1 : -1)) % 64;
|
||||||
|
queue_for_send = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void matrix_init_kb(void) {
|
void matrix_init_kb(void) {
|
||||||
|
#ifdef QWIIC_MICRO_OLED_ENABLE
|
||||||
|
queue_for_send = true;
|
||||||
|
#endif
|
||||||
matrix_init_user();
|
matrix_init_user();
|
||||||
}
|
}
|
||||||
|
|
||||||
void matrix_scan_kb(void) {
|
void matrix_scan_kb(void) {
|
||||||
|
#ifdef QWIIC_MICRO_OLED_ENABLE
|
||||||
|
if (queue_for_send) {
|
||||||
|
draw_ui();
|
||||||
|
queue_for_send = false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
matrix_scan_user();
|
matrix_scan_user();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef QWIIC_JOYSTIIC_ENABLE
|
||||||
|
void joystiic_trigger_kb(uint8_t trigger, bool active) {
|
||||||
|
switch (trigger) {
|
||||||
|
case JOYSTIIC_LEFT: active ? register_code(KC_L) : unregister_code(KC_L); break;
|
||||||
|
case JOYSTIIC_RIGHT: active ? register_code(KC_R) : unregister_code(KC_R); break;
|
||||||
|
case JOYSTIIC_UP: active ? register_code(KC_U) : unregister_code(KC_U); break;
|
||||||
|
case JOYSTIIC_DOWN: active ? register_code(KC_D) : unregister_code(KC_D); break;
|
||||||
|
case JOYSTIIC_PRESS: active ? register_code(KC_P) : unregister_code(KC_P); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -53,4 +53,5 @@ NKRO_ENABLE = yes # USB Nkey Rollover
|
||||||
CUSTOM_MATRIX = yes # Custom matrix file
|
CUSTOM_MATRIX = yes # Custom matrix file
|
||||||
AUDIO_ENABLE = yes
|
AUDIO_ENABLE = yes
|
||||||
RGBLIGHT_ENABLE = no
|
RGBLIGHT_ENABLE = no
|
||||||
|
QWIIC_ENABLE += MICRO_OLED
|
||||||
# SERIAL_LINK_ENABLE = yes
|
# SERIAL_LINK_ENABLE = yes
|
||||||
|
|
|
@ -82,13 +82,11 @@ void layer_xor(uint32_t state);
|
||||||
#define layer_or(state)
|
#define layer_or(state)
|
||||||
#define layer_and(state)
|
#define layer_and(state)
|
||||||
#define layer_xor(state)
|
#define layer_xor(state)
|
||||||
|
|
||||||
__attribute__((weak))
|
|
||||||
uint32_t layer_state_set_user(uint32_t state);
|
|
||||||
__attribute__((weak))
|
|
||||||
uint32_t layer_state_set_kb(uint32_t state);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
uint32_t layer_state_set_user(uint32_t state);
|
||||||
|
uint32_t layer_state_set_kb(uint32_t state);
|
||||||
|
|
||||||
/* pressed actions cache */
|
/* pressed actions cache */
|
||||||
#if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
|
#if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
|
||||||
/* The number of bits needed to represent the layer number: log2(32). */
|
/* The number of bits needed to represent the layer number: log2(32). */
|
||||||
|
|
|
@ -72,6 +72,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#ifdef HD44780_ENABLE
|
#ifdef HD44780_ENABLE
|
||||||
# include "hd44780.h"
|
# include "hd44780.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef QWIIC_ENABLE
|
||||||
|
# include "qwiic.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef MATRIX_HAS_GHOST
|
#ifdef MATRIX_HAS_GHOST
|
||||||
extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
|
extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
|
||||||
|
@ -157,6 +160,9 @@ void keyboard_init(void) {
|
||||||
MCUCR |= _BV(JTD);
|
MCUCR |= _BV(JTD);
|
||||||
#endif
|
#endif
|
||||||
matrix_init();
|
matrix_init();
|
||||||
|
#ifdef QWIIC_ENABLE
|
||||||
|
qwiic_init();
|
||||||
|
#endif
|
||||||
#ifdef PS2_MOUSE_ENABLE
|
#ifdef PS2_MOUSE_ENABLE
|
||||||
ps2_mouse_init();
|
ps2_mouse_init();
|
||||||
#endif
|
#endif
|
||||||
|
@ -266,6 +272,10 @@ void keyboard_task(void)
|
||||||
|
|
||||||
MATRIX_LOOP_END:
|
MATRIX_LOOP_END:
|
||||||
|
|
||||||
|
#ifdef QWIIC_ENABLE
|
||||||
|
qwiic_task();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef MOUSEKEY_ENABLE
|
#ifdef MOUSEKEY_ENABLE
|
||||||
// mousekey repeat & acceleration
|
// mousekey repeat & acceleration
|
||||||
mousekey_task();
|
mousekey_task();
|
||||||
|
|
Loading…
Reference in a new issue