summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/arm/i2c_master.c121
-rw-r--r--drivers/arm/i2c_master.h91
-rw-r--r--drivers/avr/analog.c53
-rw-r--r--drivers/avr/analog.h26
-rw-r--r--[-rwxr-xr-x]drivers/avr/apa102.c147
-rw-r--r--[-rwxr-xr-x]drivers/avr/apa102.h5
-rw-r--r--drivers/avr/glcdfont.c280
-rw-r--r--drivers/avr/hd44780.c510
-rw-r--r--drivers/avr/hd44780.h303
-rw-r--r--[-rwxr-xr-x]drivers/avr/i2c_master.c254
-rw-r--r--[-rwxr-xr-x]drivers/avr/i2c_master.h12
-rw-r--r--[-rwxr-xr-x]drivers/avr/i2c_slave.c18
-rw-r--r--[-rwxr-xr-x]drivers/avr/i2c_slave.h2
-rw-r--r--drivers/avr/pro_micro.h270
-rw-r--r--drivers/avr/ssd1306.c427
-rw-r--r--drivers/avr/ssd1306.h84
-rw-r--r--drivers/avr/ws2812.c384
-rw-r--r--drivers/avr/ws2812.h17
-rw-r--r--drivers/boards/GENERIC_STM32_F303XC/board.c98
-rw-r--r--drivers/boards/GENERIC_STM32_F303XC/board.h1166
-rw-r--r--drivers/boards/IC_TEENSY_3_1/board.c237
-rw-r--r--drivers/boards/IC_TEENSY_3_1/board.h426
-rw-r--r--drivers/gpio/pca9555.c72
-rw-r--r--drivers/haptic/DRV2605L.c150
-rw-r--r--drivers/haptic/DRV2605L.h574
-rw-r--r--drivers/haptic/haptic.c316
-rw-r--r--drivers/haptic/haptic.h78
-rw-r--r--drivers/haptic/solenoid.c100
-rw-r--r--drivers/haptic/solenoid.h10
-rw-r--r--drivers/issi/is31fl3218.c100
-rw-r--r--drivers/issi/is31fl3218.h4
-rw-r--r--drivers/issi/is31fl3731-simple.c71
-rw-r--r--drivers/issi/is31fl3731-simple.h171
-rw-r--r--drivers/issi/is31fl3731.c174
-rw-r--r--drivers/issi/is31fl3731.h195
-rw-r--r--drivers/issi/is31fl3733.c177
-rw-r--r--drivers/issi/is31fl3733.h437
-rw-r--r--drivers/issi/is31fl3736.c219
-rw-r--r--drivers/issi/is31fl3736.h254
-rw-r--r--drivers/issi/is31fl3737.c177
-rw-r--r--drivers/issi/is31fl3737.h341
-rw-r--r--drivers/oled/glcdfont.c241
-rw-r--r--drivers/oled/oled_driver.c798
-rw-r--r--drivers/oled/oled_driver.h206
-rw-r--r--drivers/qwiic/micro_oled.c748
-rw-r--r--drivers/qwiic/micro_oled.h122
-rw-r--r--drivers/qwiic/qwiic.c12
-rw-r--r--drivers/qwiic/qwiic.h4
-rw-r--r--drivers/qwiic/util/font5x7.h265
-rw-r--r--drivers/qwiic/util/font8x16.h108
-rw-r--r--drivers/ugfx/gdisp/is31fl3731c/board_is31fl3731c_template.h85
-rw-r--r--drivers/ugfx/gdisp/is31fl3731c/gdisp_is31fl3731c.c268
-rw-r--r--drivers/ugfx/gdisp/is31fl3731c/gdisp_lld_config.h14
-rw-r--r--drivers/ugfx/gdisp/st7565/board_st7565_template.h71
-rw-r--r--drivers/ugfx/gdisp/st7565/gdisp_lld_ST7565.c337
-rw-r--r--drivers/ugfx/gdisp/st7565/gdisp_lld_config.h16
-rw-r--r--drivers/ugfx/gdisp/st7565/st7565.h42
57 files changed, 4891 insertions, 6997 deletions
diff --git a/drivers/arm/i2c_master.c b/drivers/arm/i2c_master.c
index cba5a1c679..18068d3a6d 100644
--- a/drivers/arm/i2c_master.c
+++ b/drivers/arm/i2c_master.c
@@ -34,98 +34,83 @@ static uint8_t i2c_address;
static const I2CConfig i2cconfig = {
#ifdef USE_I2CV1
- I2C1_OPMODE,
- I2C1_CLOCK_SPEED,
- I2C1_DUTY_CYCLE,
+ I2C1_OPMODE,
+ I2C1_CLOCK_SPEED,
+ I2C1_DUTY_CYCLE,
#else
- STM32_TIMINGR_PRESC(I2C1_TIMINGR_PRESC) |
- STM32_TIMINGR_SCLDEL(I2C1_TIMINGR_SCLDEL) | STM32_TIMINGR_SDADEL(I2C1_TIMINGR_SDADEL) |
- STM32_TIMINGR_SCLH(I2C1_TIMINGR_SCLH) | STM32_TIMINGR_SCLL(I2C1_TIMINGR_SCLL),
- 0,
- 0
+ STM32_TIMINGR_PRESC(I2C1_TIMINGR_PRESC) | STM32_TIMINGR_SCLDEL(I2C1_TIMINGR_SCLDEL) | STM32_TIMINGR_SDADEL(I2C1_TIMINGR_SDADEL) | STM32_TIMINGR_SCLH(I2C1_TIMINGR_SCLH) | STM32_TIMINGR_SCLL(I2C1_TIMINGR_SCLL), 0, 0
#endif
};
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;
- }
+ 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)
-{
- // Try releasing special pins for a short time
- palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_INPUT);
- palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_INPUT);
+__attribute__((weak)) void i2c_init(void) {
+ // Try releasing special pins for a short time
+ palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_INPUT);
+ palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_INPUT);
- chThdSleepMilliseconds(10);
+ chThdSleepMilliseconds(10);
#ifdef USE_I2CV1
- palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_STM32_ALTERNATE_OPENDRAIN);
- palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_STM32_ALTERNATE_OPENDRAIN);
+ palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_STM32_ALTERNATE_OPENDRAIN);
+ palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_STM32_ALTERNATE_OPENDRAIN);
#else
- palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_ALTERNATE(I2C1_SCL_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN);
- palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_ALTERNATE(I2C1_SDA_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN);
+ palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_ALTERNATE(I2C1_SCL_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN);
+ palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_ALTERNATE(I2C1_SDA_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN);
#endif
- //i2cInit(); //This is invoked by halInit() so no need to redo it.
+ // i2cInit(); //This is invoked by halInit() so no need to redo it.
}
-i2c_status_t i2c_start(uint8_t address)
-{
- i2c_address = address;
- i2cStart(&I2C_DRIVER, &i2cconfig);
- return I2C_STATUS_SUCCESS;
+i2c_status_t i2c_start(uint8_t address) {
+ i2c_address = address;
+ i2cStart(&I2C_DRIVER, &i2cconfig);
+ return I2C_STATUS_SUCCESS;
}
-i2c_status_t i2c_transmit(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout)
-{
- i2c_address = address;
- i2cStart(&I2C_DRIVER, &i2cconfig);
- msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), data, length, 0, 0, MS2ST(timeout));
- return chibios_to_qmk(&status);
+i2c_status_t i2c_transmit(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout) {
+ i2c_address = address;
+ i2cStart(&I2C_DRIVER, &i2cconfig);
+ msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), data, length, 0, 0, MS2ST(timeout));
+ return chibios_to_qmk(&status);
}
-i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout)
-{
- i2c_address = address;
- i2cStart(&I2C_DRIVER, &i2cconfig);
- msg_t status = i2cMasterReceiveTimeout(&I2C_DRIVER, (i2c_address >> 1), data, length, MS2ST(timeout));
- return chibios_to_qmk(&status);
+i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout) {
+ i2c_address = address;
+ i2cStart(&I2C_DRIVER, &i2cconfig);
+ msg_t status = i2cMasterReceiveTimeout(&I2C_DRIVER, (i2c_address >> 1), data, length, MS2ST(timeout));
+ return chibios_to_qmk(&status);
}
-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);
+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);
- uint8_t complete_packet[length + 1];
- for(uint8_t i = 0; i < length; i++)
- {
- complete_packet[i+1] = data[i];
- }
- complete_packet[0] = regaddr;
+ uint8_t complete_packet[length + 1];
+ for (uint8_t i = 0; i < length; i++) {
+ complete_packet[i + 1] = data[i];
+ }
+ complete_packet[0] = regaddr;
- msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), complete_packet, length + 1, 0, 0, MS2ST(timeout));
- return chibios_to_qmk(&status);
+ msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), complete_packet, length + 1, 0, 0, MS2ST(timeout));
+ return chibios_to_qmk(&status);
}
-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);
- msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), &regaddr, 1, data, length, MS2ST(timeout));
- return chibios_to_qmk(&status);
+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);
+ msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), &regaddr, 1, data, length, MS2ST(timeout));
+ return chibios_to_qmk(&status);
}
-void i2c_stop(void)
-{
- i2cStop(&I2C_DRIVER);
-}
+void i2c_stop(void) { i2cStop(&I2C_DRIVER); }
diff --git a/drivers/arm/i2c_master.h b/drivers/arm/i2c_master.h
index c8afa31e28..b40fa0a910 100644
--- a/drivers/arm/i2c_master.h
+++ b/drivers/arm/i2c_master.h
@@ -27,84 +27,83 @@
#include "ch.h"
#include <hal.h>
-
#if defined(STM32F1XX) || defined(STM32F1xx) || defined(STM32F2xx) || defined(STM32F4xx) || defined(STM32L0xx) || defined(STM32L1xx)
- #define USE_I2CV1
+# define USE_I2CV1
#endif
#ifdef I2C1_BANK
- #define I2C1_SCL_BANK I2C1_BANK
- #define I2C1_SDA_BANK I2C1_BANK
+# define I2C1_SCL_BANK I2C1_BANK
+# define I2C1_SDA_BANK I2C1_BANK
#endif
#ifndef I2C1_SCL_BANK
- #define I2C1_SCL_BANK GPIOB
+# define I2C1_SCL_BANK GPIOB
#endif
#ifndef I2C1_SDA_BANK
- #define I2C1_SDA_BANK GPIOB
+# define I2C1_SDA_BANK GPIOB
#endif
#ifndef I2C1_SCL
- #define I2C1_SCL 6
+# define I2C1_SCL 6
#endif
#ifndef I2C1_SDA
- #define I2C1_SDA 7
+# define I2C1_SDA 7
#endif
#ifdef USE_I2CV1
- #ifndef I2C1_OPMODE
- #define I2C1_OPMODE OPMODE_I2C
- #endif
- #ifndef I2C1_CLOCK_SPEED
- #define I2C1_CLOCK_SPEED 100000 /* 400000 */
- #endif
- #ifndef I2C1_DUTY_CYCLE
- #define I2C1_DUTY_CYCLE STD_DUTY_CYCLE /* FAST_DUTY_CYCLE_2 */
- #endif
+# ifndef I2C1_OPMODE
+# define I2C1_OPMODE OPMODE_I2C
+# endif
+# ifndef I2C1_CLOCK_SPEED
+# define I2C1_CLOCK_SPEED 100000 /* 400000 */
+# endif
+# ifndef I2C1_DUTY_CYCLE
+# define I2C1_DUTY_CYCLE STD_DUTY_CYCLE /* FAST_DUTY_CYCLE_2 */
+# endif
#else
- // The default PAL alternate modes are used to signal that the pins are used for I2C
- #ifndef I2C1_SCL_PAL_MODE
- #define I2C1_SCL_PAL_MODE 4
- #endif
- #ifndef I2C1_SDA_PAL_MODE
- #define I2C1_SDA_PAL_MODE 4
- #endif
+// The default PAL alternate modes are used to signal that the pins are used for I2C
+# ifndef I2C1_SCL_PAL_MODE
+# define I2C1_SCL_PAL_MODE 4
+# endif
+# ifndef I2C1_SDA_PAL_MODE
+# define I2C1_SDA_PAL_MODE 4
+# endif
- // The default timing values below configures the I2C clock to 400khz assuming a 72Mhz clock
- // For more info : https://www.st.com/en/embedded-software/stsw-stm32126.html
- #ifndef I2C1_TIMINGR_PRESC
- #define I2C1_TIMINGR_PRESC 15U
- #endif
- #ifndef I2C1_TIMINGR_SCLDEL
- #define I2C1_TIMINGR_SCLDEL 4U
- #endif
- #ifndef I2C1_TIMINGR_SDADEL
- #define I2C1_TIMINGR_SDADEL 2U
- #endif
- #ifndef I2C1_TIMINGR_SCLH
- #define I2C1_TIMINGR_SCLH 15U
- #endif
- #ifndef I2C1_TIMINGR_SCLL
- #define I2C1_TIMINGR_SCLL 21U
- #endif
+// The default timing values below configures the I2C clock to 400khz assuming a 72Mhz clock
+// For more info : https://www.st.com/en/embedded-software/stsw-stm32126.html
+# ifndef I2C1_TIMINGR_PRESC
+# define I2C1_TIMINGR_PRESC 15U
+# endif
+# ifndef I2C1_TIMINGR_SCLDEL
+# define I2C1_TIMINGR_SCLDEL 4U
+# endif
+# ifndef I2C1_TIMINGR_SDADEL
+# define I2C1_TIMINGR_SDADEL 2U
+# endif
+# ifndef I2C1_TIMINGR_SCLH
+# define I2C1_TIMINGR_SCLH 15U
+# endif
+# ifndef I2C1_TIMINGR_SCLL
+# define I2C1_TIMINGR_SCLL 21U
+# endif
#endif
#ifndef I2C_DRIVER
- #define I2C_DRIVER I2CD1
+# define I2C_DRIVER I2CD1
#endif
typedef int16_t i2c_status_t;
#define I2C_STATUS_SUCCESS (0)
-#define I2C_STATUS_ERROR (-1)
+#define I2C_STATUS_ERROR (-1)
#define I2C_STATUS_TIMEOUT (-2)
-void i2c_init(void);
+void i2c_init(void);
i2c_status_t i2c_start(uint8_t address);
i2c_status_t i2c_transmit(uint8_t address, const 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_status_t i2c_transmit_receive(uint8_t address, uint8_t * tx_body, uint16_t tx_length, uint8_t * rx_body, uint16_t rx_length);
+i2c_status_t i2c_transmit_receive(uint8_t address, uint8_t* tx_body, uint16_t tx_length, uint8_t* rx_body, uint16_t rx_length);
i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const 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);
-void i2c_stop(void);
+void i2c_stop(void);
diff --git a/drivers/avr/analog.c b/drivers/avr/analog.c
index 1ec38df75d..1a8da4261d 100644
--- a/drivers/avr/analog.c
+++ b/drivers/avr/analog.c
@@ -21,49 +21,38 @@
#include <stdint.h>
#include "analog.h"
+static uint8_t aref = (1 << REFS0); // default to AREF = Vcc
-static uint8_t aref = (1<<REFS0); // default to AREF = Vcc
-
-
-void analogReference(uint8_t mode)
-{
- aref = mode & 0xC0;
-}
-
+void analogReference(uint8_t mode) { aref = mode & 0xC0; }
// Arduino compatible pin input
-int16_t analogRead(uint8_t pin)
-{
+int16_t analogRead(uint8_t pin) {
#if defined(__AVR_ATmega32U4__)
- static const uint8_t PROGMEM pin_to_mux[] = {
- 0x00, 0x01, 0x04, 0x05, 0x06, 0x07,
- 0x25, 0x24, 0x23, 0x22, 0x21, 0x20};
- if (pin >= 12) return 0;
- return adc_read(pgm_read_byte(pin_to_mux + pin));
+ static const uint8_t PROGMEM pin_to_mux[] = {0x00, 0x01, 0x04, 0x05, 0x06, 0x07, 0x25, 0x24, 0x23, 0x22, 0x21, 0x20};
+ if (pin >= 12) return 0;
+ return adc_read(pgm_read_byte(pin_to_mux + pin));
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
- if (pin >= 8) return 0;
- return adc_read(pin);
+ if (pin >= 8) return 0;
+ return adc_read(pin);
#else
- return 0;
+ return 0;
#endif
}
// Mux input
-int16_t adc_read(uint8_t mux)
-{
+int16_t adc_read(uint8_t mux) {
#if defined(__AVR_AT90USB162__)
- return 0;
+ return 0;
#else
- uint8_t low;
-
- ADCSRA = (1<<ADEN) | ADC_PRESCALER; // enable ADC
- ADCSRB = (1<<ADHSM) | (mux & 0x20); // high speed mode
- ADMUX = aref | (mux & 0x1F); // configure mux input
- ADCSRA = (1<<ADEN) | ADC_PRESCALER | (1<<ADSC); // start the conversion
- while (ADCSRA & (1<<ADSC)) ; // wait for result
- low = ADCL; // must read LSB first
- return (ADCH << 8) | low; // must read MSB only once!
+ uint8_t low;
+
+ ADCSRA = (1 << ADEN) | ADC_PRESCALER; // enable ADC
+ ADCSRB = (1 << ADHSM) | (mux & 0x20); // high speed mode
+ ADMUX = aref | (mux & 0x1F); // configure mux input
+ ADCSRA = (1 << ADEN) | ADC_PRESCALER | (1 << ADSC); // start the conversion
+ while (ADCSRA & (1 << ADSC))
+ ; // wait for result
+ low = ADCL; // must read LSB first
+ return (ADCH << 8) | low; // must read MSB only once!
#endif
}
-
-
diff --git a/drivers/avr/analog.h b/drivers/avr/analog.h
index 8d93de7dc2..32452a1ec2 100644
--- a/drivers/avr/analog.h
+++ b/drivers/avr/analog.h
@@ -19,34 +19,34 @@
#include <stdint.h>
-void analogReference(uint8_t mode);
+void analogReference(uint8_t mode);
int16_t analogRead(uint8_t pin);
int16_t adc_read(uint8_t mux);
-#define ADC_REF_POWER (1<<REFS0)
-#define ADC_REF_INTERNAL ((1<<REFS1) | (1<<REFS0))
-#define ADC_REF_EXTERNAL (0)
+#define ADC_REF_POWER (1 << REFS0)
+#define ADC_REF_INTERNAL ((1 << REFS1) | (1 << REFS0))
+#define ADC_REF_EXTERNAL (0)
// These prescaler values are for high speed mode, ADHSM = 1
#if F_CPU == 16000000L
-#define ADC_PRESCALER ((1<<ADPS2) | (1<<ADPS1))
+# define ADC_PRESCALER ((1 << ADPS2) | (1 << ADPS1))
#elif F_CPU == 8000000L
-#define ADC_PRESCALER ((1<<ADPS2) | (1<<ADPS0))
+# define ADC_PRESCALER ((1 << ADPS2) | (1 << ADPS0))
#elif F_CPU == 4000000L
-#define ADC_PRESCALER ((1<<ADPS2))
+# define ADC_PRESCALER ((1 << ADPS2))
#elif F_CPU == 2000000L
-#define ADC_PRESCALER ((1<<ADPS1) | (1<<ADPS0))
+# define ADC_PRESCALER ((1 << ADPS1) | (1 << ADPS0))
#elif F_CPU == 1000000L
-#define ADC_PRESCALER ((1<<ADPS1))
+# define ADC_PRESCALER ((1 << ADPS1))
#else
-#define ADC_PRESCALER ((1<<ADPS0))
+# define ADC_PRESCALER ((1 << ADPS0))
#endif
// some avr-libc versions do not properly define ADHSM
#if defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
-#if !defined(ADHSM)
-#define ADHSM (7)
-#endif
+# if !defined(ADHSM)
+# define ADHSM (7)
+# endif
#endif
#endif
diff --git a/drivers/avr/apa102.c b/drivers/avr/apa102.c
index 55a0d57778..f4d97a1589 100755..100644
--- a/drivers/avr/apa102.c
+++ b/drivers/avr/apa102.c
@@ -1,24 +1,24 @@
/*
-* APA102 lib V1.0a
-*
-* Controls APA102 RGB-LEDs
-* Author: Mikkel (Duckle29 on github)
-*
-* Dec 22th, 2017 v1.0a Initial Version
-*
-* 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/>.
-*/
+ * APA102 lib V1.0a
+ *
+ * Controls APA102 RGB-LEDs
+ * Author: Mikkel (Duckle29 on github)
+ *
+ * Dec 22th, 2017 v1.0a Initial Version
+ *
+ * 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 "apa102.h"
#include <avr/interrupt.h>
@@ -27,75 +27,70 @@
#include "debug.h"
// Setleds for standard RGB
-void inline apa102_setleds(LED_TYPE *ledarray, uint16_t leds){
- apa102_setleds_pin(ledarray,leds, _BV(RGB_DI_PIN & 0xF), _BV(RGB_CLK_PIN & 0xF));
-}
+void inline apa102_setleds(LED_TYPE *ledarray, uint16_t leds) { apa102_setleds_pin(ledarray, leds, _BV(RGB_DI_PIN & 0xF), _BV(RGB_CLK_PIN & 0xF)); }
-void static inline apa102_setleds_pin(LED_TYPE *ledarray, uint16_t leds, uint8_t pinmask_DI, uint8_t pinmask_CLK){
- pinMode(RGB_DI_PIN, PinDirectionOutput);
- pinMode(RGB_CLK_PIN, PinDirectionOutput);
+void static inline apa102_setleds_pin(LED_TYPE *ledarray, uint16_t leds, uint8_t pinmask_DI, uint8_t pinmask_CLK) {
+ pinMode(RGB_DI_PIN, PinDirectionOutput);
+ pinMode(RGB_CLK_PIN, PinDirectionOutput);
- apa102_send_array((uint8_t*)ledarray,leds)
+ apa102_send_array((uint8_t *)ledarray, leds)
}
-void apa102_send_array(uint8_t *data, uint16_t leds){ // Data is struct of 3 bytes. RGB - leds is number of leds in data
- apa102_start_frame();
- while(leds--){
- apa102_send_frame(0xFF000000 | (data->b << 16) | (data->g << 8) | data->r);
- data++;
- }
- apa102_end_frame(leds);
+void apa102_send_array(uint8_t *data, uint16_t leds) { // Data is struct of 3 bytes. RGB - leds is number of leds in data
+ apa102_start_frame();
+ while (leds--) {
+ apa102_send_frame(0xFF000000 | (data->b << 16) | (data->g << 8) | data->r);
+ data++;
+ }
+ apa102_end_frame(leds);
}
-void apa102_send_frame(uint32_t frame){
- for(uint32_t i=0xFF; i>0;){
- apa102_send_byte(frame & i);
- i = i << 8;
- }
+void apa102_send_frame(uint32_t frame) {
+ for (uint32_t i = 0xFF; i > 0;) {
+ apa102_send_byte(frame & i);
+ i = i << 8;
+ }
}
-void apa102_start_frame(){
- apa102_send_frame(0);
-}
+void apa102_start_frame() { apa102_send_frame(0); }
-void apa102_end_frame(uint16_t leds)
-{
- // This function has been taken from: https://github.com/pololu/apa102-arduino/blob/master/APA102.h
- // and adapted. The code is MIT licensed. I think thats compatible?
+void apa102_end_frame(uint16_t leds) {
+ // This function has been taken from: https://github.com/pololu/apa102-arduino/blob/master/APA102.h
+ // and adapted. The code is MIT licensed. I think thats compatible?
- // We need to send some more bytes to ensure that all the LEDs in the
- // chain see their new color and start displaying it.
- //
- // The data stream seen by the last LED in the chain will be delayed by
- // (count - 1) clock edges, because each LED before it inverts the clock
- // line and delays the data by one clock edge. Therefore, to make sure
- // the last LED actually receives the data we wrote, the number of extra
- // edges we send at the end of the frame must be at least (count - 1).
- // For the APA102C, that is sufficient.
- //
- // The SK9822 only updates after it sees 32 zero bits followed by one more
- // rising edge. To avoid having the update time depend on the color of
- // the last LED, we send a dummy 0xFF byte. (Unfortunately, this means
- // that partial updates of the beginning of an LED strip are not possible;
- // the LED after the last one you are trying to update will be black.)
- // After that, to ensure that the last LED in the chain sees 32 zero bits
- // and a rising edge, we need to send at least 65 + (count - 1) edges. It
- // is sufficent and simpler to just send (5 + count/16) bytes of zeros.
- //
- // We are ignoring the specification for the end frame in the APA102/SK9822
- // datasheets because it does not actually ensure that all the LEDs will
- // start displaying their new colors right away.
+ // We need to send some more bytes to ensure that all the LEDs in the
+ // chain see their new color and start displaying it.
+ //
+ // The data stream seen by the last LED in the chain will be delayed by
+ // (count - 1) clock edges, because each LED before it inverts the clock
+ // line and delays the data by one clock edge. Therefore, to make sure
+ // the last LED actually receives the data we wrote, the number of extra
+ // edges we send at the end of the frame must be at least (count - 1).
+ // For the APA102C, that is sufficient.
+ //
+ // The SK9822 only updates after it sees 32 zero bits followed by one more
+ // rising edge. To avoid having the update time depend on the color of
+ // the last LED, we send a dummy 0xFF byte. (Unfortunately, this means
+ // that partial updates of the beginning of an LED strip are not possible;
+ // the LED after the last one you are trying to update will be black.)
+ // After that, to ensure that the last LED in the chain sees 32 zero bits
+ // and a rising edge, we need to send at least 65 + (count - 1) edges. It
+ // is sufficent and simpler to just send (5 + count/16) bytes of zeros.
+ //
+ // We are ignoring the specification for the end frame in the APA102/SK9822
+ // datasheets because it does not actually ensure that all the LEDs will
+ // start displaying their new colors right away.
- apa102_send_byte(0xFF);
- for (uint16_t i = 0; i < 5 + leds / 16; i++){
- apa102_send_byte(0);
- }
+ apa102_send_byte(0xFF);
+ for (uint16_t i = 0; i < 5 + leds / 16; i++) {
+ apa102_send_byte(0);
+ }
}
-void apa102_send_byte(uint8_t byte){
- uint8_t i;
- for (i = 0; i < 8; i++){
+void apa102_send_byte(uint8_t byte) {
+ uint8_t i;
+ for (i = 0; i < 8; i++) {
digitalWrite(RGB_DI_PIN, !!(byte & (1 << (7-i)));
digitalWrite(RGB_CLK_PIN, PinLevelHigh);
- }
+ }
}
diff --git a/drivers/avr/apa102.h b/drivers/avr/apa102.h
index 5d852e0673..d4c1e18ee1 100755..100644
--- a/drivers/avr/apa102.h
+++ b/drivers/avr/apa102.h
@@ -27,7 +27,6 @@
#include "color.h"
-
/* User Interface
*
* Input:
@@ -41,6 +40,6 @@
* - Wait 50�s to reset the LEDs
*/
-void apa102_setleds (LED_TYPE *ledarray, uint16_t number_of_leds);
-void apa102_setleds_pin (LED_TYPE *ledarray, uint16_t number_of_leds,uint8_t pinmask);
+void apa102_setleds(LED_TYPE *ledarray, uint16_t number_of_leds);
+void apa102_setleds_pin(LED_TYPE *ledarray, uint16_t number_of_leds, uint8_t pinmask);
void apa102_setleds_rgbw(LED_TYPE *ledarray, uint16_t number_of_leds);
diff --git a/drivers/avr/glcdfont.c b/drivers/avr/glcdfont.c
index 6f88bd23a7..2c332ea6db 100644
--- a/drivers/avr/glcdfont.c
+++ b/drivers/avr/glcdfont.c
@@ -5,272 +5,30 @@
#define FONT5X7_H
#ifdef __AVR__
- #include <avr/io.h>
- #include <avr/pgmspace.h>
+# include <avr/io.h>
+# include <avr/pgmspace.h>
#elif defined(ESP8266)
- #include <pgmspace.h>
+# include <pgmspace.h>
#else
- #define PROGMEM
+# define PROGMEM
#endif
// Standard ASCII 5x7 font
static const unsigned char font[] PROGMEM = {
- 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,
- 0x22, 0x54, 0x54, 0x78, 0x42, // a-umlaut
- 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,
- 0x7D, 0x12, 0x11, 0x12, 0x7D, // A-umlaut
- 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,
- 0x3A, 0x44, 0x44, 0x44, 0x3A, // o-umlaut
- 0x32, 0x4A, 0x48, 0x48, 0x30,
- 0x3A, 0x41, 0x41, 0x21, 0x7A,
- 0x3A, 0x42, 0x40, 0x20, 0x78,
- 0x00, 0x9D, 0xA0, 0xA0, 0x7D,
- 0x3D, 0x42, 0x42, 0x42, 0x3D, // O-umlaut
- 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,
- 0x55, 0x00, 0x55, 0x00, 0x55, // #176 (25% block) missing in old code
- 0xAA, 0x55, 0xAA, 0x55, 0xAA, // 50% block
- 0xFF, 0x55, 0xFF, 0x55, 0xFF, // 75% block
- 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,
- 0xFC, 0x4A, 0x4A, 0x4A, 0x34, // sharp-s or beta
- 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 // #255 NBSP
+ 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, 0x22, 0x54, 0x54, 0x78, 0x42, // a-umlaut
+ 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, 0x7D, 0x12, 0x11, 0x12, 0x7D, // A-umlaut
+ 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, 0x3A, 0x44, 0x44, 0x44, 0x3A, // o-umlaut
+ 0x32, 0x4A, 0x48, 0x48, 0x30, 0x3A, 0x41, 0x41, 0x21, 0x7A, 0x3A, 0x42, 0x40, 0x20, 0x78, 0x00, 0x9D, 0xA0, 0xA0, 0x7D, 0x3D, 0x42, 0x42, 0x42, 0x3D, // O-umlaut
+ 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, 0x55, 0x00, 0x55, 0x00, 0x55, // #176 (25% block) missing in old code
+ 0xAA, 0x55, 0xAA, 0x55, 0xAA, // 50% block
+ 0xFF, 0x55, 0xFF, 0x55, 0xFF, // 75% block
+ 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, 0xFC, 0x4A, 0x4A, 0x4A, 0x34, // sharp-s or beta
+ 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 // #255 NBSP
};
-#endif // FONT5X7_H
+#endif // FONT5X7_H
diff --git a/drivers/avr/hd44780.c b/drivers/avr/hd44780.c
index 51414d8f91..f71069dece 100644
--- a/drivers/avr/hd44780.c
+++ b/drivers/avr/hd44780.c
@@ -3,7 +3,7 @@
Author: Peter Fleury <pfleury@gmx.ch> http://tinyurl.com/peterfleury
License: GNU General Public License Version 3
File: $Id: lcd.c,v 1.15.2.2 2015/01/17 12:16:05 peter Exp $
- Software: AVR-GCC 3.3
+ Software: AVR-GCC 3.3
Target: any AVR device, memory mapped mode only for AT90S4414/8515/Mega
DESCRIPTION
@@ -13,15 +13,15 @@
changed lcd_init(), added additional constants for lcd_command(),
added 4-bit I/O mode, improved and optimized code.
- Library can be operated in memory mapped mode (LCD_IO_MODE=0) or in
+ Library can be operated in memory mapped mode (LCD_IO_MODE=0) or in
4-bit IO port mode (LCD_IO_MODE=1). 8-bit IO port mode not supported.
-
+
Memory mapped mode compatible with Kanda STK200, but supports also
generation of R/W signal through A8 address line.
USAGE
See the C include lcd.h file for a description of each function
-
+
*****************************************************************************/
#include <inttypes.h>
#include <avr/io.h>
@@ -29,55 +29,54 @@
#include <util/delay.h>
#include "hd44780.h"
-/*
-** constants/macros
+/*
+** constants/macros
*/
-#define DDR(x) (*(&x - 1)) /* address of data direction register of port x */
+#define DDR(x) (*(&x - 1)) /* address of data direction register of port x */
#if defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__)
- /* on ATmega64/128 PINF is on port 0x00 and not 0x60 */
- #define PIN(x) ( &PORTF==&(x) ? _SFR_IO8(0x00) : (*(&x - 2)) )
+/* on ATmega64/128 PINF is on port 0x00 and not 0x60 */
+# define PIN(x) (&PORTF == &(x) ? _SFR_IO8(0x00) : (*(&x - 2)))
#else
- #define PIN(x) (*(&x - 2)) /* address of input register of port x */
+# define PIN(x) (*(&x - 2)) /* address of input register of port x */
#endif
-
#if LCD_IO_MODE
-#define lcd_e_delay() _delay_us(LCD_DELAY_ENABLE_PULSE)
-#define lcd_e_high() LCD_E_PORT |= _BV(LCD_E_PIN);
-#define lcd_e_low() LCD_E_PORT &= ~_BV(LCD_E_PIN);
-#define lcd_e_toggle() toggle_e()
-#define lcd_rw_high() LCD_RW_PORT |= _BV(LCD_RW_PIN)
-#define lcd_rw_low() LCD_RW_PORT &= ~_BV(LCD_RW_PIN)
-#define lcd_rs_high() LCD_RS_PORT |= _BV(LCD_RS_PIN)
-#define lcd_rs_low() LCD_RS_PORT &= ~_BV(LCD_RS_PIN)
+# define lcd_e_delay() _delay_us(LCD_DELAY_ENABLE_PULSE)
+# define lcd_e_high() LCD_E_PORT |= _BV(LCD_E_PIN);
+# define lcd_e_low() LCD_E_PORT &= ~_BV(LCD_E_PIN);
+# define lcd_e_toggle() toggle_e()
+# define lcd_rw_high() LCD_RW_PORT |= _BV(LCD_RW_PIN)
+# define lcd_rw_low() LCD_RW_PORT &= ~_BV(LCD_RW_PIN)
+# define lcd_rs_high() LCD_RS_PORT |= _BV(LCD_RS_PIN)
+# define lcd_rs_low() LCD_RS_PORT &= ~_BV(LCD_RS_PIN)
#endif
#if LCD_IO_MODE
-#if LCD_LINES==1
-#define LCD_FUNCTION_DEFAULT LCD_FUNCTION_4BIT_1LINE
+# if LCD_LINES == 1
+# define LCD_FUNCTION_DEFAULT LCD_FUNCTION_4BIT_1LINE
+# else
+# define LCD_FUNCTION_DEFAULT LCD_FUNCTION_4BIT_2LINES
+# endif
#else
-#define LCD_FUNCTION_DEFAULT LCD_FUNCTION_4BIT_2LINES
-#endif
-#else
-#if LCD_LINES==1
-#define LCD_FUNCTION_DEFAULT LCD_FUNCTION_8BIT_1LINE
-#else
-#define LCD_FUNCTION_DEFAULT LCD_FUNCTION_8BIT_2LINES
-#endif
+# if LCD_LINES == 1
+# define LCD_FUNCTION_DEFAULT LCD_FUNCTION_8BIT_1LINE
+# else
+# define LCD_FUNCTION_DEFAULT LCD_FUNCTION_8BIT_2LINES
+# endif
#endif
#if LCD_CONTROLLER_KS0073
-#if LCD_LINES==4
+# if LCD_LINES == 4
-#define KS0073_EXTENDED_FUNCTION_REGISTER_ON 0x2C /* |0|010|1100 4-bit mode, extension-bit RE = 1 */
-#define KS0073_EXTENDED_FUNCTION_REGISTER_OFF 0x28 /* |0|010|1000 4-bit mode, extension-bit RE = 0 */
-#define KS0073_4LINES_MODE 0x09 /* |0|000|1001 4 lines mode */
+# define KS0073_EXTENDED_FUNCTION_REGISTER_ON 0x2C /* |0|010|1100 4-bit mode, extension-bit RE = 1 */
+# define KS0073_EXTENDED_FUNCTION_REGISTER_OFF 0x28 /* |0|010|1000 4-bit mode, extension-bit RE = 0 */
+# define KS0073_4LINES_MODE 0x09 /* |0|000|1001 4 lines mode */
-#endif
+# endif
#endif
-/*
-** function prototypes
+/*
+** function prototypes
*/
#if LCD_IO_MODE
static void toggle_e(void);
@@ -87,93 +86,83 @@ static void toggle_e(void);
** local functions
*/
-
-/*************************************************************************
+/*************************************************************************
delay for a minimum of <us> microseconds
the number of loops is calculated at compile-time from MCU clock frequency
*************************************************************************/
-#define delay(us) _delay_us(us)
-
+#define delay(us) _delay_us(us)
#if LCD_IO_MODE
/* toggle Enable Pin to initiate write */
-static void toggle_e(void)
-{
+static void toggle_e(void) {
lcd_e_high();
lcd_e_delay();
lcd_e_low();
}
#endif
-
/*************************************************************************
Low-level function to write byte to LCD controller
Input: data byte to write to LCD
- rs 1: write data
+ rs 1: write data
0: write instruction
Returns: none
*************************************************************************/
#if LCD_IO_MODE
-static void lcd_write(uint8_t data,uint8_t rs)
-{
- unsigned char dataBits ;
-
+static void lcd_write(uint8_t data, uint8_t rs) {
+ unsigned char dataBits;
- if (rs) { /* write data (RS=1, RW=0) */
- lcd_rs_high();
- } else { /* write instruction (RS=0, RW=0) */
- lcd_rs_low();
+ if (rs) { /* write data (RS=1, RW=0) */
+ lcd_rs_high();
+ } else { /* write instruction (RS=0, RW=0) */
+ lcd_rs_low();
}
- lcd_rw_low(); /* RW=0 write mode */
+ lcd_rw_low(); /* RW=0 write mode */
- if ( ( &LCD_DATA0_PORT == &LCD_DATA1_PORT) && ( &LCD_DATA1_PORT == &LCD_DATA2_PORT ) && ( &LCD_DATA2_PORT == &LCD_DATA3_PORT )
- && (LCD_DATA0_PIN == 0) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3) )
- {
+ if ((&LCD_DATA0_PORT == &LCD_DATA1_PORT) && (&LCD_DATA1_PORT == &LCD_DATA2_PORT) && (&LCD_DATA2_PORT == &LCD_DATA3_PORT) && (LCD_DATA0_PIN == 0) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3)) {
/* configure data pins as output */
DDR(LCD_DATA0_PORT) |= 0x0F;
/* output high nibble first */
- dataBits = LCD_DATA0_PORT & 0xF0;
- LCD_DATA0_PORT = dataBits |((data>>4)&0x0F);
+ dataBits = LCD_DATA0_PORT & 0xF0;
+ LCD_DATA0_PORT = dataBits | ((data >> 4) & 0x0F);
lcd_e_toggle();
/* output low nibble */
- LCD_DATA0_PORT = dataBits | (data&0x0F);
+ LCD_DATA0_PORT = dataBits | (data & 0x0F);
lcd_e_toggle();
/* all data pins high (inactive) */
LCD_DATA0_PORT = dataBits | 0x0F;
- }
- else
- {
+ } else {
/* configure data pins as output */
DDR(LCD_DATA0_PORT) |= _BV(LCD_DATA0_PIN);
DDR(LCD_DATA1_PORT) |= _BV(LCD_DATA1_PIN);
DDR(LCD_DATA2_PORT) |= _BV(LCD_DATA2_PIN);
DDR(LCD_DATA3_PORT) |= _BV(LCD_DATA3_PIN);
-
+
/* output high nibble first */
LCD_DATA3_PORT &= ~_BV(LCD_DATA3_PIN);
LCD_DATA2_PORT &= ~_BV(LCD_DATA2_PIN);
LCD_DATA1_PORT &= ~_BV(LCD_DATA1_PIN);
LCD_DATA0_PORT &= ~_BV(LCD_DATA0_PIN);
- if(data & 0x80) LCD_DATA3_PORT |= _BV(LCD_DATA3_PIN);
- if(data & 0x40) LCD_DATA2_PORT |= _BV(LCD_DATA2_PIN);
- if(data & 0x20) LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN);
- if(data & 0x10) LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN);
+ if (data & 0x80) LCD_DATA3_PORT |= _BV(LCD_DATA3_PIN);
+ if (data & 0x40) LCD_DATA2_PORT |= _BV(LCD_DATA2_PIN);
+ if (data & 0x20) LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN);
+ if (data & 0x10) LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN);
lcd_e_toggle();
-
+
/* output low nibble */
LCD_DATA3_PORT &= ~_BV(LCD_DATA3_PIN);
LCD_DATA2_PORT &= ~_BV(LCD_DATA2_PIN);
LCD_DATA1_PORT &= ~_BV(LCD_DATA1_PIN);
LCD_DATA0_PORT &= ~_BV(LCD_DATA0_PIN);
- if(data & 0x08) LCD_DATA3_PORT |= _BV(LCD_DATA3_PIN);
- if(data & 0x04) LCD_DATA2_PORT |= _BV(LCD_DATA2_PIN);
- if(data & 0x02) LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN);
- if(data & 0x01) LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN);
- lcd_e_toggle();
-
+ if (data & 0x08) LCD_DATA3_PORT |= _BV(LCD_DATA3_PIN);
+ if (data & 0x04) LCD_DATA2_PORT |= _BV(LCD_DATA2_PIN);
+ if (data & 0x02) LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN);
+ if (data & 0x01) LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN);
+ lcd_e_toggle();
+
/* all data pins high (inactive) */
LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN);
LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN);
@@ -182,85 +171,81 @@ static void lcd_write(uint8_t data,uint8_t rs)
}
}
#else
-#define lcd_write(d,rs) if (rs) *(volatile uint8_t*)(LCD_IO_DATA) = d; else *(volatile uint8_t*)(LCD_IO_FUNCTION) = d;
+# define lcd_write(d, rs) \
+ if (rs) \
+ *(volatile uint8_t *)(LCD_IO_DATA) = d; \
+ else \
+ *(volatile uint8_t *)(LCD_IO_FUNCTION) = d;
/* rs==0 -> write instruction to LCD_IO_FUNCTION */
/* rs==1 -> write data to LCD_IO_DATA */
#endif
-
/*************************************************************************
Low-level function to read byte from LCD controller
-Input: rs 1: read data
+Input: rs 1: read data
0: read busy flag / address counter
Returns: byte read from LCD controller
*************************************************************************/
#if LCD_IO_MODE
-static uint8_t lcd_read(uint8_t rs)
-{
+static uint8_t lcd_read(uint8_t rs) {
uint8_t data;
-
-
+
if (rs)
- lcd_rs_high(); /* RS=1: read data */
+ lcd_rs_high(); /* RS=1: read data */
else
- lcd_rs_low(); /* RS=0: read busy flag */
- lcd_rw_high(); /* RW=1 read mode */
-
- if ( ( &LCD_DATA0_PORT == &LCD_DATA1_PORT) && ( &LCD_DATA1_PORT == &LCD_DATA2_PORT ) && ( &LCD_DATA2_PORT == &LCD_DATA3_PORT )
- && ( LCD_DATA0_PIN == 0 )&& (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3) )
- {
- DDR(LCD_DATA0_PORT) &= 0xF0; /* configure data pins as input */
-
+ lcd_rs_low(); /* RS=0: read busy flag */
+ lcd_rw_high(); /* RW=1 read mode */
+
+ if ((&LCD_DATA0_PORT == &LCD_DATA1_PORT) && (&LCD_DATA1_PORT == &LCD_DATA2_PORT) && (&LCD_DATA2_PORT == &LCD_DATA3_PORT) && (LCD_DATA0_PIN == 0) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3)) {
+ DDR(LCD_DATA0_PORT) &= 0xF0; /* configure data pins as input */
+
lcd_e_high();
- lcd_e_delay();
- data = PIN(LCD_DATA0_PORT) << 4; /* read high nibble first */
+ lcd_e_delay();
+ data = PIN(LCD_DATA0_PORT) << 4; /* read high nibble first */
lcd_e_low();
-
- lcd_e_delay(); /* Enable 500ns low */
-
+
+ lcd_e_delay(); /* Enable 500ns low */
+
lcd_e_high();
lcd_e_delay();
- data |= PIN(LCD_DATA0_PORT)&0x0F; /* read low nibble */
+ data |= PIN(LCD_DATA0_PORT) & 0x0F; /* read low nibble */
lcd_e_low();
- }
- else
- {
+ } else {
/* configure data pins as input */
DDR(LCD_DATA0_PORT) &= ~_BV(LCD_DATA0_PIN);
DDR(LCD_DATA1_PORT) &= ~_BV(LCD_DATA1_PIN);
DDR(LCD_DATA2_PORT) &= ~_BV(LCD_DATA2_PIN);
DDR(LCD_DATA3_PORT) &= ~_BV(LCD_DATA3_PIN);
-
+
/* read high nibble first */
lcd_e_high();
- lcd_e_delay();
+ lcd_e_delay();
data = 0;
- if ( PIN(LCD_DATA0_PORT) & _BV(LCD_DATA0_PIN) ) data |= 0x10;
- if ( PIN(LCD_DATA1_PORT) & _BV(LCD_DATA1_PIN) ) data |= 0x20;
- if ( PIN(LCD_DATA2_PORT) & _BV(LCD_DATA2_PIN) ) data |= 0x40;
- if ( PIN(LCD_DATA3_PORT) & _BV(LCD_DATA3_PIN) ) data |= 0x80;
+ if (PIN(LCD_DATA0_PORT) & _BV(LCD_DATA0_PIN)) data |= 0x10;
+ if (PIN(LCD_DATA1_PORT) & _BV(LCD_DATA1_PIN)) data |= 0x20;
+ if (PIN(LCD_DATA2_PORT) & _BV(LCD_DATA2_PIN)) data |= 0x40;
+ if (PIN(LCD_DATA3_PORT) & _BV(LCD_DATA3_PIN)) data |= 0x80;
lcd_e_low();
- lcd_e_delay(); /* Enable 500ns low */
-
- /* read low nibble */
+ lcd_e_delay(); /* Enable 500ns low */
+
+ /* read low nibble */
lcd_e_high();
lcd_e_delay();
- if ( PIN(LCD_DATA0_PORT) & _BV(LCD_DATA0_PIN) ) data |= 0x01;
- if ( PIN(LCD_DATA1_PORT) & _BV(LCD_DATA1_PIN) ) data |= 0x02;
- if ( PIN(LCD_DATA2_PORT) & _BV(LCD_DATA2_PIN) ) data |= 0x04;
- if ( PIN(LCD_DATA3_PORT) & _BV(LCD_DATA3_PIN) ) data |= 0x08;
+ if (PIN(LCD_DATA0_PORT) & _BV(LCD_DATA0_PIN)) data |= 0x01;
+ if (PIN(LCD_DATA1_PORT) & _BV(LCD_DATA1_PIN)) data |= 0x02;
+ if (PIN(LCD_DATA2_PORT) & _BV(LCD_DATA2_PIN)) data |= 0x04;
+ if (PIN(LCD_DATA3_PORT) & _BV(LCD_DATA3_PIN)) data |= 0x08;
lcd_e_low();
}
return data;
}
#else
-#define lcd_read(rs) (rs) ? *(volatile uint8_t*)(LCD_IO_DATA+LCD_IO_READ) : *(volatile uint8_t*)(LCD_IO_FUNCTION+LCD_IO_READ)
+# define lcd_read(rs) (rs) ? *(volatile uint8_t *)(LCD_IO_DATA + LCD_IO_READ) : *(volatile uint8_t *)(LCD_IO_FUNCTION + LCD_IO_READ)
/* rs==0 -> read instruction from LCD_IO_FUNCTION */
/* rs==1 -> read data from LCD_IO_DATA */
#endif
-
/*************************************************************************
loops while lcd is busy, returns address counter
*************************************************************************/
@@ -268,65 +253,62 @@ static uint8_t lcd_waitbusy(void)
{
register uint8_t c;
-
+
/* wait until busy flag is cleared */
- while ( (c=lcd_read(0)) & (1<<LCD_BUSY)) {}
-
+ while ((c = lcd_read(0)) & (1 << LCD_BUSY)) {
+ }
+
/* the address counter is updated 4us after the busy flag is cleared */
delay(LCD_DELAY_BUSY_FLAG);
/* now read the address counter */
return (lcd_read(0)); // return address counter
-
-}/* lcd_waitbusy */
+} /* lcd_waitbusy */
/*************************************************************************
-Move cursor to the start of next line or to the first line if the cursor
+Move cursor to the start of next line or to the first line if the cursor
is already on the last line.
*************************************************************************/
-static inline void lcd_newline(uint8_t pos)
-{
+static inline void lcd_newline(uint8_t pos) {
register uint8_t addressCounter;
-
-#if LCD_LINES==1
+#if LCD_LINES == 1
addressCounter = 0;
#endif
-#if LCD_LINES==2
- if ( pos < (LCD_START_LINE2) )
+#if LCD_LINES == 2
+ if (pos < (LCD_START_LINE2))
addressCounter = LCD_START_LINE2;
else
addressCounter = LCD_START_LINE1;
#endif
-#if LCD_LINES==4
-#if KS0073_4LINES_MODE
- if ( pos < LCD_START_LINE2 )
+#if LCD_LINES == 4
+# if KS0073_4LINES_MODE
+ if (pos < LCD_START_LINE2)
addressCounter = LCD_START_LINE2;
- else if ( (pos >= LCD_START_LINE2) && (pos < LCD_START_LINE3) )
+ else if ((pos >= LCD_START_LINE2) && (pos < LCD_START_LINE3))
addressCounter = LCD_START_LINE3;
- else if ( (pos >= LCD_START_LINE3) && (pos < LCD_START_LINE4) )
+ else if ((pos >= LCD_START_LINE3) && (pos < LCD_START_LINE4))
addressCounter = LCD_START_LINE4;
- else
+ else
addressCounter = LCD_START_LINE1;
-#else
- if ( pos < LCD_START_LINE3 )
+# else
+ if (pos < LCD_START_LINE3)
addressCounter = LCD_START_LINE2;
- else if ( (pos >= LCD_START_LINE2) && (pos < LCD_START_LINE4) )
+ else if ((pos >= LCD_START_LINE2) && (pos < LCD_START_LINE4))
addressCounter = LCD_START_LINE3;
- else if ( (pos >= LCD_START_LINE3) && (pos < LCD_START_LINE2) )
+ else if ((pos >= LCD_START_LINE3) && (pos < LCD_START_LINE2))
addressCounter = LCD_START_LINE4;
- else
+ else
addressCounter = LCD_START_LINE1;
+# endif
#endif
-#endif
- lcd_command((1<<LCD_DDRAM)+addressCounter);
-
-}/* lcd_newline */
+ lcd_command((1 << LCD_DDRAM) + addressCounter);
+} /* lcd_newline */
/*
-** PUBLIC FUNCTIONS
+** PUBLIC FUNCTIONS
*/
/*************************************************************************
@@ -334,132 +316,107 @@ Send LCD controller instruction command
Input: instruction to send to LCD controller, see HD44780 data sheet
Returns: none
*************************************************************************/
-void lcd_command(uint8_t cmd)
-{
+void lcd_command(uint8_t cmd) {
lcd_waitbusy();
- lcd_write(cmd,0);
+ lcd_write(cmd, 0);
}
-
/*************************************************************************
-Send data byte to LCD controller
+Send data byte to LCD controller
Input: data to send to LCD controller, see HD44780 data sheet
Returns: none
*************************************************************************/
-void lcd_data(uint8_t data)
-{
+void lcd_data(uint8_t data) {
lcd_waitbusy();
- lcd_write(data,1);
+ lcd_write(data, 1);
}
-
-
/*************************************************************************
Set cursor to specified position
Input: x horizontal position (0: left most position)
y vertical position (0: first line)
Returns: none
*************************************************************************/
-void lcd_gotoxy(uint8_t x, uint8_t y)
-{
-#if LCD_LINES==1
- lcd_command((1<<LCD_DDRAM)+LCD_START_LINE1+x);
+void lcd_gotoxy(uint8_t x, uint8_t y) {
+#if LCD_LINES == 1
+ lcd_command((1 << LCD_DDRAM) + LCD_START_LINE1 + x);
#endif
-#if LCD_LINES==2
- if ( y==0 )
- lcd_command((1<<LCD_DDRAM)+LCD_START_LINE1+x);
+#if LCD_LINES == 2
+ if (y == 0)
+ lcd_command((1 << LCD_DDRAM) + LCD_START_LINE1 + x);
else
- lcd_command((1<<LCD_DDRAM)+LCD_START_LINE2+x);
+ lcd_command((1 << LCD_DDRAM) + LCD_START_LINE2 + x);
#endif
-#if LCD_LINES==4
- if ( y==0 )
- lcd_command((1<<LCD_DDRAM)+LCD_START_LINE1+x);
- else if ( y==1)
- lcd_command((1<<LCD_DDRAM)+LCD_START_LINE2+x);
- else if ( y==2)
- lcd_command((1<<LCD_DDRAM)+LCD_START_LINE3+x);
+#if LCD_LINES == 4
+ if (y == 0)
+ lcd_command((1 << LCD_DDRAM) + LCD_START_LINE1 + x);
+ else if (y == 1)
+ lcd_command((1 << LCD_DDRAM) + LCD_START_LINE2 + x);
+ else if (y == 2)
+ lcd_command((1 << LCD_DDRAM) + LCD_START_LINE3 + x);
else /* y==3 */
- lcd_command((1<<LCD_DDRAM)+LCD_START_LINE4+x);
+ lcd_command((1 << LCD_DDRAM) + LCD_START_LINE4 + x);
#endif
-}/* lcd_gotoxy */
-
+} /* lcd_gotoxy */
/*************************************************************************
*************************************************************************/
-int lcd_getxy(void)
-{
- return lcd_waitbusy();
-}
-
+int lcd_getxy(void) { return lcd_waitbusy(); }
/*************************************************************************
Clear display and set cursor to home position
*************************************************************************/
-void lcd_clrscr(void)
-{
- lcd_command(1<<LCD_CLR);
-}
-
+void lcd_clrscr(void) { lcd_command(1 << LCD_CLR); }
/*************************************************************************
Set cursor to home position
*************************************************************************/
-void lcd_home(void)
-{
- lcd_command(1<<LCD_HOME);
-}
-
+void lcd_home(void) { lcd_command(1 << LCD_HOME); }
/*************************************************************************
-Display character at current cursor position
-Input: character to be displayed
+Display character at current cursor position
+Input: character to be displayed
Returns: none
*************************************************************************/
-void lcd_putc(char c)
-{
+void lcd_putc(char c) {
uint8_t pos;
-
- pos = lcd_waitbusy(); // read busy-flag and address counter
- if (c=='\n')
- {
+ pos = lcd_waitbusy(); // read busy-flag and address counter
+ if (c == '\n') {
lcd_newline(pos);
- }
- else
- {
-#if LCD_WRAP_LINES==1
-#if LCD_LINES==1
- if ( pos == LCD_START_LINE1+LCD_DISP_LENGTH ) {
- lcd_write((1<<LCD_DDRAM)+LCD_START_LINE1,0);
+ } else {
+#if LCD_WRAP_LINES == 1
+# if LCD_LINES == 1
+ if (pos == LCD_START_LINE1 + LCD_DISP_LENGTH) {
+ lcd_write((1 << LCD_DDRAM) + LCD_START_LINE1, 0);
}
-#elif LCD_LINES==2
- if ( pos == LCD_START_LINE1+LCD_DISP_LENGTH ) {
- lcd_write((1<<LCD_DDRAM)+LCD_START_LINE2,0);
- }else if ( pos == LCD_START_LINE2+LCD_DISP_LENGTH ){
- lcd_write((1<<LCD_DDRAM)+LCD_START_LINE1,0);
+# elif LCD_LINES == 2
+ if (pos == LCD_START_LINE1 + LCD_DISP_LENGTH) {
+ lcd_write((1 << LCD_DDRAM) + LCD_START_LINE2, 0);
+ } else if (pos == LCD_START_LINE2 + LCD_DISP_LENGTH) {
+ lcd_write((1 << LCD_DDRAM) + LCD_START_LINE1, 0);
}
-#elif LCD_LINES==4
- if ( pos == LCD_START_LINE1+LCD_DISP_LENGTH ) {
- lcd_write((1<<LCD_DDRAM)+LCD_START_LINE2,0);
- }else if ( pos == LCD_START_LINE2+LCD_DISP_LENGTH ) {
- lcd_write((1<<LCD_DDRAM)+LCD_START_LINE3,0);
- }else if ( pos == LCD_START_LINE3+LCD_DISP_LENGTH ) {
- lcd_write((1<<LCD_DDRAM)+LCD_START_LINE4,0);
- }else if ( pos == LCD_START_LINE4+LCD_DISP_LENGTH ) {
- lcd_write((1<<LCD_DDRAM)+LCD_START_LINE1,0);
+# elif LCD_LINES == 4
+ if (pos == LCD_START_LINE1 + LCD_DISP_LENGTH) {
+ lcd_write((1 << LCD_DDRAM) + LCD_START_LINE2, 0);
+ } else if (pos == LCD_START_LINE2 + LCD_DISP_LENGTH) {
+ lcd_write((1 << LCD_DDRAM) + LCD_START_LINE3, 0);
+ } else if (pos == LCD_START_LINE3 + LCD_DISP_LENGTH) {
+ lcd_write((1 << LCD_DDRAM) + LCD_START_LINE4, 0);
+ } else if (pos == LCD_START_LINE4 + LCD_DISP_LENGTH) {
+ lcd_write((1 << LCD_DDRAM) + LCD_START_LINE1, 0);
}
-#endif
+# endif
lcd_waitbusy();
#endif
lcd_write(c, 1);
}
-}/* lcd_putc */
-
+} /* lcd_putc */
/*************************************************************************
-Display string without auto linefeed
+Display string without auto linefeed
Input: string to be displayed
Returns: none
*************************************************************************/
@@ -468,16 +425,15 @@ void lcd_puts(const char *s)
{
register char c;
- while ( (c = *s++) ) {
+ while ((c = *s++)) {
lcd_putc(c);
}
-}/* lcd_puts */
-
+} /* lcd_puts */
/*************************************************************************
-Display string from program memory without auto linefeed
-Input: string from program memory be be displayed
+Display string from program memory without auto linefeed
+Input: string from program memory be be displayed
Returns: none
*************************************************************************/
void lcd_puts_p(const char *progmem_s)
@@ -485,108 +441,96 @@ void lcd_puts_p(const char *progmem_s)
{
register char c;
- while ( (c = pgm_read_byte(progmem_s++)) ) {
+ while ((c = pgm_read_byte(progmem_s++))) {
lcd_putc(c);
}
-}/* lcd_puts_p */
-
+} /* lcd_puts_p */
/*************************************************************************
-Initialize display and select type of cursor
+Initialize display and select type of cursor
Input: dispAttr LCD_DISP_OFF display off
LCD_DISP_ON display on, cursor off
LCD_DISP_ON_CURSOR display on, cursor on
LCD_DISP_CURSOR_BLINK display on, cursor on flashing
Returns: none
*************************************************************************/
-void lcd_init(uint8_t dispAttr)
-{
+void lcd_init(uint8_t dispAttr) {
#if LCD_IO_MODE
/*
* Initialize LCD to 4 bit I/O mode
*/
-
- if ( ( &LCD_DATA0_PORT == &LCD_DATA1_PORT) && ( &LCD_DATA1_PORT == &LCD_DATA2_PORT ) && ( &LCD_DATA2_PORT == &LCD_DATA3_PORT )
- && ( &LCD_RS_PORT == &LCD_DATA0_PORT) && ( &LCD_RW_PORT == &LCD_DATA0_PORT) && (&LCD_E_PORT == &LCD_DATA0_PORT)
- && (LCD_DATA0_PIN == 0 ) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3)
- && (LCD_RS_PIN == 4 ) && (LCD_RW_PIN == 5) && (LCD_E_PIN == 6 ) )
- {
+
+ if ((&LCD_DATA0_PORT == &LCD_DATA1_PORT) && (&LCD_DATA1_PORT == &LCD_DATA2_PORT) && (&LCD_DATA2_PORT == &LCD_DATA3_PORT) && (&LCD_RS_PORT == &LCD_DATA0_PORT) && (&LCD_RW_PORT == &LCD_DATA0_PORT) && (&LCD_E_PORT == &LCD_DATA0_PORT) && (LCD_DATA0_PIN == 0) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3) && (LCD_RS_PIN == 4) && (LCD_RW_PIN == 5) && (LCD_E_PIN == 6)) {
/* configure all port bits as output (all LCD lines on same port) */
DDR(LCD_DATA0_PORT) |= 0x7F;
- }
- else if ( ( &LCD_DATA0_PORT == &LCD_DATA1_PORT) && ( &LCD_DATA1_PORT == &LCD_DATA2_PORT ) && ( &LCD_DATA2_PORT == &LCD_DATA3_PORT )
- && (LCD_DATA0_PIN == 0 ) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3) )
- {
+ } else if ((&LCD_DATA0_PORT == &LCD_DATA1_PORT) && (&LCD_DATA1_PORT == &LCD_DATA2_PORT) && (&LCD_DATA2_PORT == &LCD_DATA3_PORT) && (LCD_DATA0_PIN == 0) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3)) {
/* configure all port bits as output (all LCD data lines on same port, but control lines on different ports) */
DDR(LCD_DATA0_PORT) |= 0x0F;
- DDR(LCD_RS_PORT) |= _BV(LCD_RS_PIN);
- DDR(LCD_RW_PORT) |= _BV(LCD_RW_PIN);
- DDR(LCD_E_PORT) |= _BV(LCD_E_PIN);
- }
- else
- {
+ DDR(LCD_RS_PORT) |= _BV(LCD_RS_PIN);
+ DDR(LCD_RW_PORT) |= _BV(LCD_RW_PIN);
+ DDR(LCD_E_PORT) |= _BV(LCD_E_PIN);
+ } else {
/* configure all port bits as output (LCD data and control lines on different ports */
- DDR(LCD_RS_PORT) |= _BV(LCD_RS_PIN);
- DDR(LCD_RW_PORT) |= _BV(LCD_RW_PIN);
- DDR(LCD_E_PORT) |= _BV(LCD_E_PIN);
+ DDR(LCD_RS_PORT) |= _BV(LCD_RS_PIN);
+ DDR(LCD_RW_PORT) |= _BV(LCD_RW_PIN);
+ DDR(LCD_E_PORT) |= _BV(LCD_E_PIN);
DDR(LCD_DATA0_PORT) |= _BV(LCD_DATA0_PIN);
DDR(LCD_DATA1_PORT) |= _BV(LCD_DATA1_PIN);
DDR(LCD_DATA2_PORT) |= _BV(LCD_DATA2_PIN);
DDR(LCD_DATA3_PORT) |= _BV(LCD_DATA3_PIN);
}
- delay(LCD_DELAY_BOOTUP); /* wait 16ms or more after power-on */
-
+ delay(LCD_DELAY_BOOTUP); /* wait 16ms or more after power-on */
+
/* initial write to lcd is 8bit */
- LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN); // LCD_FUNCTION>>4;
- LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN); // LCD_FUNCTION_8BIT>>4;
+ LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN); // LCD_FUNCTION>>4;
+ LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN); // LCD_FUNCTION_8BIT>>4;
+ lcd_e_toggle();
+ delay(LCD_DELAY_INIT); /* delay, busy flag can't be checked here */
+
+ /* repeat last command */
lcd_e_toggle();
- delay(LCD_DELAY_INIT); /* delay, busy flag can't be checked here */
-
- /* repeat last command */
- lcd_e_toggle();
- delay(LCD_DELAY_INIT_REP); /* delay, busy flag can't be checked here */
-
+ delay(LCD_DELAY_INIT_REP); /* delay, busy flag can't be checked here */
+
/* repeat last command a third time */
- lcd_e_toggle();
- delay(LCD_DELAY_INIT_REP); /* delay, busy flag can't be checked here */
+ lcd_e_toggle();
+ delay(LCD_DELAY_INIT_REP); /* delay, busy flag can't be checked here */
/* now configure for 4bit mode */
- LCD_DATA0_PORT &= ~_BV(LCD_DATA0_PIN); // LCD_FUNCTION_4BIT_1LINE>>4
+ LCD_DATA0_PORT &= ~_BV(LCD_DATA0_PIN); // LCD_FUNCTION_4BIT_1LINE>>4
lcd_e_toggle();
- delay(LCD_DELAY_INIT_4BIT); /* some displays need this additional delay */
-
- /* from now the LCD only accepts 4 bit I/O, we can use lcd_command() */
+ delay(LCD_DELAY_INIT_4BIT); /* some displays need this additional delay */
+
+ /* from now the LCD only accepts 4 bit I/O, we can use lcd_command() */
#else
/*
* Initialize LCD to 8 bit memory mapped mode
*/
-
- /* enable external SRAM (memory mapped lcd) and one wait state */
+
+ /* enable external SRAM (memory mapped lcd) and one wait state */
MCUCR = _BV(SRE) | _BV(SRW);
/* reset LCD */
- delay(LCD_DELAY_BOOTUP); /* wait 16ms after power-on */
- lcd_write(LCD_FUNCTION_8BIT_1LINE,0); /* function set: 8bit interface */
- delay(LCD_DELAY_INIT); /* wait 5ms */
- lcd_write(LCD_FUNCTION_8BIT_1LINE,0); /* function set: 8bit interface */
- delay(LCD_DELAY_INIT_REP); /* wait 64us */
- lcd_write(LCD_FUNCTION_8BIT_1LINE,0); /* function set: 8bit interface */
- delay(LCD_DELAY_INIT_REP); /* wait 64us */
+ delay(LCD_DELAY_BOOTUP); /* wait 16ms after power-on */
+ lcd_write(LCD_FUNCTION_8BIT_1LINE, 0); /* function set: 8bit interface */
+ delay(LCD_DELAY_INIT); /* wait 5ms */
+ lcd_write(LCD_FUNCTION_8BIT_1LINE, 0); /* function set: 8bit interface */
+ delay(LCD_DELAY_INIT_REP); /* wait 64us */
+ lcd_write(LCD_FUNCTION_8BIT_1LINE, 0); /* function set: 8bit interface */
+ delay(LCD_DELAY_INIT_REP); /* wait 64us */
#endif
#if KS0073_4LINES_MODE
/* Display with KS0073 controller requires special commands for enabling 4 line mode */
- lcd_command(KS0073_EXTENDED_FUNCTION_REGISTER_ON);
- lcd_command(KS0073_4LINES_MODE);
- lcd_command(KS0073_EXTENDED_FUNCTION_REGISTER_OFF);
+ lcd_command(KS0073_EXTENDED_FUNCTION_REGISTER_ON);
+ lcd_command(KS0073_4LINES_MODE);
+ lcd_command(KS0073_EXTENDED_FUNCTION_REGISTER_OFF);
#else
- lcd_command(LCD_FUNCTION_DEFAULT); /* function set: display lines */
+ lcd_command(LCD_FUNCTION_DEFAULT); /* function set: display lines */
#endif
- lcd_command(LCD_DISP_OFF); /* display off */
- lcd_clrscr(); /* display clear */
- lcd_command(LCD_MODE_DEFAULT); /* set entry mode */
- lcd_command(dispAttr); /* display/cursor control */
-
-}/* lcd_init */
+ lcd_command(LCD_DISP_OFF); /* display off */
+ lcd_clrscr(); /* display clear */
+ lcd_command(LCD_MODE_DEFAULT); /* set entry mode */
+ lcd_command(dispAttr); /* display/cursor control */
+} /* lcd_init */
diff --git a/drivers/avr/hd44780.h b/drivers/avr/hd44780.h
index 7421c8131f..e60817e989 100644
--- a/drivers/avr/hd44780.h
+++ b/drivers/avr/hd44780.h
@@ -6,7 +6,7 @@
License: GNU General Public License Version 3
File: $Id: lcd.h,v 1.14.2.4 2015/01/20 17:16:07 peter Exp $
Software: AVR-GCC 4.x
- Hardware: any AVR device, memory mapped mode only for AVR with
+ Hardware: any AVR device, memory mapped mode only for AVR with
memory mapped interface (AT90S8515/ATmega8515/ATmega128)
***************************************************************************/
@@ -15,333 +15,315 @@
Collection of libraries for AVR-GCC
@author Peter Fleury pfleury@gmx.ch http://tinyurl.com/peterfleury
@copyright (C) 2015 Peter Fleury, GNU General Public License Version 3
-
+
@file
@defgroup pfleury_lcd LCD library <lcd.h>
@code #include <lcd.h> @endcode
-
+
@brief Basic routines for interfacing a HD44780U-based character LCD display
- LCD character displays can be found in many devices, like espresso machines, laser printers.
- The Hitachi HD44780 controller and its compatible controllers like Samsung KS0066U have become an industry standard for these types of displays.
-
+ LCD character displays can be found in many devices, like espresso machines, laser printers.
+ The Hitachi HD44780 controller and its compatible controllers like Samsung KS0066U have become an industry standard for these types of displays.
+
This library allows easy interfacing with a HD44780 compatible display and can be
- operated in memory mapped mode (LCD_IO_MODE defined as 0 in the include file lcd.h.) or in
+ operated in memory mapped mode (LCD_IO_MODE defined as 0 in the include file lcd.h.) or in
4-bit IO port mode (LCD_IO_MODE defined as 1). 8-bit IO port mode is not supported.
Memory mapped mode is compatible with old Kanda STK200 starter kit, but also supports
generation of R/W signal through A8 address line.
@see The chapter <a href=" http://homepage.hispeed.ch/peterfleury/avr-lcd44780.html" target="_blank">Interfacing a HD44780 Based LCD to an AVR</a>
- on my home page, which shows example circuits how to connect an LCD to an AVR controller.
+ on my home page, which shows example circuits how to connect an LCD to an AVR controller.
@author Peter Fleury pfleury@gmx.ch http://tinyurl.com/peterfleury
-
+
@version 2.0
-
+
@copyright (C) 2015 Peter Fleury, GNU General Public License Version 3
-
+
*/
#include <inttypes.h>
#include <avr/pgmspace.h>
#if (__GNUC__ * 100 + __GNUC_MINOR__) < 405
-#error "This library requires AVR-GCC 4.5 or later, update to newer AVR-GCC compiler !"
+# error "This library requires AVR-GCC 4.5 or later, update to newer AVR-GCC compiler !"
#endif
-
/**@{*/
/*
- * LCD and target specific definitions below can be defined in a separate include file with name lcd_definitions.h instead modifying this file
+ * LCD and target specific definitions below can be defined in a separate include file with name lcd_definitions.h instead modifying this file
* by adding -D_LCD_DEFINITIONS_FILE to the CDEFS section in the Makefile
* All definitions added to the file lcd_definitions.h will override the default definitions from lcd.h
*/
#ifdef _LCD_DEFINITIONS_FILE
-#include "lcd_definitions.h"
+# include "lcd_definitions.h"
#endif
-
/**
* @name Definition for LCD controller type
* Use 0 for HD44780 controller, change to 1 for displays with KS0073 controller.
*/
-#ifndef LCD_CONTROLLER_KS0073
-#define LCD_CONTROLLER_KS0073 0 /**< Use 0 for HD44780 controller, 1 for KS0073 controller */
+#ifndef LCD_CONTROLLER_KS0073
+# define LCD_CONTROLLER_KS0073 0 /**< Use 0 for HD44780 controller, 1 for KS0073 controller */
#endif
-/**
- * @name Definitions for Display Size
+/**
+ * @name Definitions for Display Size
* Change these definitions to adapt setting to your display
*
- * These definitions can be defined in a separate include file \b lcd_definitions.h instead modifying this file by
+ * These definitions can be defined in a separate include file \b lcd_definitions.h instead modifying this file by
* adding -D_LCD_DEFINITIONS_FILE to the CDEFS section in the Makefile.
* All definitions added to the file lcd_definitions.h will override the default definitions from lcd.h
*
*/
#ifndef LCD_LINES
-#define LCD_LINES 2 /**< number of visible lines of the display */
+# define LCD_LINES 2 /**< number of visible lines of the display */
#endif
#ifndef LCD_DISP_LENGTH
-#define LCD_DISP_LENGTH 16 /**< visibles characters per line of the display */
+# define LCD_DISP_LENGTH 16 /**< visibles characters per line of the display */
#endif
#ifndef LCD_LINE_LENGTH
-#define LCD_LINE_LENGTH 0x40 /**< internal line length of the display */
+# define LCD_LINE_LENGTH 0x40 /**< internal line length of the display */
#endif
#ifndef LCD_START_LINE1
-#define LCD_START_LINE1 0x00 /**< DDRAM address of first char of line 1 */
+# define LCD_START_LINE1 0x00 /**< DDRAM address of first char of line 1 */
#endif
#ifndef LCD_START_LINE2
-#define LCD_START_LINE2 0x40 /**< DDRAM address of first char of line 2 */
+# define LCD_START_LINE2 0x40 /**< DDRAM address of first char of line 2 */
#endif
#ifndef LCD_START_LINE3
-#define LCD_START_LINE3 0x14 /**< DDRAM address of first char of line 3 */
+# define LCD_START_LINE3 0x14 /**< DDRAM address of first char of line 3 */
#endif
#ifndef LCD_START_LINE4
-#define LCD_START_LINE4 0x54 /**< DDRAM address of first char of line 4 */
+# define LCD_START_LINE4 0x54 /**< DDRAM address of first char of line 4 */
#endif
#ifndef LCD_WRAP_LINES
-#define LCD_WRAP_LINES 0 /**< 0: no wrap, 1: wrap at end of visibile line */
+# define LCD_WRAP_LINES 0 /**< 0: no wrap, 1: wrap at end of visibile line */
#endif
-
/**
* @name Definitions for 4-bit IO mode
*
- * The four LCD data lines and the three control lines RS, RW, E can be on the
- * same port or on different ports.
+ * The four LCD data lines and the three control lines RS, RW, E can be on the
+ * same port or on different ports.
* Change LCD_RS_PORT, LCD_RW_PORT, LCD_E_PORT if you want the control lines on
- * different ports.
+ * different ports.
*
* Normally the four data lines should be mapped to bit 0..3 on one port, but it
* is possible to connect these data lines in different order or even on different
* ports by adapting the LCD_DATAx_PORT and LCD_DATAx_PIN definitions.
*
- * Adjust these definitions to your target.\n
- * These definitions can be defined in a separate include file \b lcd_definitions.h instead modifying this file by
+ * Adjust these definitions to your target.\n
+ * These definitions can be defined in a separate include file \b lcd_definitions.h instead modifying this file by
* adding \b -D_LCD_DEFINITIONS_FILE to the \b CDEFS section in the Makefile.
* All definitions added to the file lcd_definitions.h will override the default definitions from lcd.h
- *
+ *
*/
-#define LCD_IO_MODE 1 /**< 0: memory mapped mode, 1: IO port mode */
+#define LCD_IO_MODE 1 /**< 0: memory mapped mode, 1: IO port mode */
#if LCD_IO_MODE
-#ifndef LCD_PORT
-#define LCD_PORT PORTA /**< port for the LCD lines */
-#endif
-#ifndef LCD_DATA0_PORT
-#define LCD_DATA0_PORT LCD_PORT /**< port for 4bit data bit 0 */
-#endif
-#ifndef LCD_DATA1_PORT
-#define LCD_DATA1_PORT LCD_PORT /**< port for 4bit data bit 1 */
-#endif
-#ifndef LCD_DATA2_PORT
-#define LCD_DATA2_PORT LCD_PORT /**< port for 4bit data bit 2 */
-#endif
-#ifndef LCD_DATA3_PORT
-#define LCD_DATA3_PORT LCD_PORT /**< port for 4bit data bit 3 */
-#endif
-#ifndef LCD_DATA0_PIN
-#define LCD_DATA0_PIN 4 /**< pin for 4bit data bit 0 */
-#endif
-#ifndef LCD_DATA1_PIN
-#define LCD_DATA1_PIN 5 /**< pin for 4bit data bit 1 */
-#endif
-#ifndef LCD_DATA2_PIN
-#define LCD_DATA2_PIN 6 /**< pin for 4bit data bit 2 */
-#endif
-#ifndef LCD_DATA3_PIN
-#define LCD_DATA3_PIN 7 /**< pin for 4bit data bit 3 */
-#endif
-#ifndef LCD_RS_PORT
-#define LCD_RS_PORT LCD_PORT /**< port for RS line */
-#endif
-#ifndef LCD_RS_PIN
-#define LCD_RS_PIN 3 /**< pin for RS line */
-#endif
-#ifndef LCD_RW_PORT
-#define LCD_RW_PORT LCD_PORT /**< port for RW line */
-#endif
-#ifndef LCD_RW_PIN
-#define LCD_RW_PIN 2 /**< pin for RW line */
-#endif
-#ifndef LCD_E_PORT
-#define LCD_E_PORT LCD_PORT /**< port for Enable line */
-#endif
-#ifndef LCD_E_PIN
-#define LCD_E_PIN 1 /**< pin for Enable line */
-#endif
-
-#elif defined(__AVR_AT90S4414__) || defined(__AVR_AT90S8515__) || defined(__AVR_ATmega64__) || \
- defined(__AVR_ATmega8515__)|| defined(__AVR_ATmega103__) || defined(__AVR_ATmega128__) || \
- defined(__AVR_ATmega161__) || defined(__AVR_ATmega162__)
+# ifndef LCD_PORT
+# define LCD_PORT PORTA /**< port for the LCD lines */
+# endif
+# ifndef LCD_DATA0_PORT
+# define LCD_DATA0_PORT LCD_PORT /**< port for 4bit data bit 0 */
+# endif
+# ifndef LCD_DATA1_PORT
+# define LCD_DATA1_PORT LCD_PORT /**< port for 4bit data bit 1 */
+# endif
+# ifndef LCD_DATA2_PORT
+# define LCD_DATA2_PORT LCD_PORT /**< port for 4bit data bit 2 */
+# endif
+# ifndef LCD_DATA3_PORT
+# define LCD_DATA3_PORT LCD_PORT /**< port for 4bit data bit 3 */
+# endif
+# ifndef LCD_DATA0_PIN
+# define LCD_DATA0_PIN 4 /**< pin for 4bit data bit 0 */
+# endif
+# ifndef LCD_DATA1_PIN
+# define LCD_DATA1_PIN 5 /**< pin for 4bit data bit 1 */
+# endif
+# ifndef LCD_DATA2_PIN
+# define LCD_DATA2_PIN 6 /**< pin for 4bit data bit 2 */
+# endif
+# ifndef LCD_DATA3_PIN
+# define LCD_DATA3_PIN 7 /**< pin for 4bit data bit 3 */
+# endif
+# ifndef LCD_RS_PORT
+# define LCD_RS_PORT LCD_PORT /**< port for RS line */
+# endif
+# ifndef LCD_RS_PIN
+# define LCD_RS_PIN 3 /**< pin for RS line */
+# endif
+# ifndef LCD_RW_PORT
+# define LCD_RW_PORT LCD_PORT /**< port for RW line */
+# endif
+# ifndef LCD_RW_PIN
+# define LCD_RW_PIN 2 /**< pin for RW line */
+# endif
+# ifndef LCD_E_PORT
+# define LCD_E_PORT LCD_PORT /**< port for Enable line */
+# endif
+# ifndef LCD_E_PIN
+# define LCD_E_PIN 1 /**< pin for Enable line */
+# endif
+
+#elif defined(__AVR_AT90S4414__) || defined(__AVR_AT90S8515__) || defined(__AVR_ATmega64__) || defined(__AVR_ATmega8515__) || defined(__AVR_ATmega103__) || defined(__AVR_ATmega128__) || defined(__AVR_ATmega161__) || defined(__AVR_ATmega162__)
/*
* memory mapped mode is only supported when the device has an external data memory interface
*/
-#define LCD_IO_DATA 0xC000 /* A15=E=1, A14=RS=1 */
-#define LCD_IO_FUNCTION 0x8000 /* A15=E=1, A14=RS=0 */
-#define LCD_IO_READ 0x0100 /* A8 =R/W=1 (R/W: 1=Read, 0=Write */
+# define LCD_IO_DATA 0xC000 /* A15=E=1, A14=RS=1 */
+# define LCD_IO_FUNCTION 0x8000 /* A15=E=1, A14=RS=0 */
+# define LCD_IO_READ 0x0100 /* A8 =R/W=1 (R/W: 1=Read, 0=Write */
#else
-#error "external data memory interface not available for this device, use 4-bit IO port mode"
+# error "external data memory interface not available for this device, use 4-bit IO port mode"
#endif
-
/**
* @name Definitions of delays
* Used to calculate delay timers.
* Adapt the F_CPU define in the Makefile to the clock frequency in Hz of your target
*
- * These delay times can be adjusted, if some displays require different delays.\n
- * These definitions can be defined in a separate include file \b lcd_definitions.h instead modifying this file by
+ * These delay times can be adjusted, if some displays require different delays.\n
+ * These definitions can be defined in a separate include file \b lcd_definitions.h instead modifying this file by
* adding \b -D_LCD_DEFINITIONS_FILE to the \b CDEFS section in the Makefile.
* All definitions added to the file lcd_definitions.h will override the default definitions from lcd.h
*/
#ifndef LCD_DELAY_BOOTUP
-#define LCD_DELAY_BOOTUP 16000 /**< delay in micro seconds after power-on */
+# define LCD_DELAY_BOOTUP 16000 /**< delay in micro seconds after power-on */
#endif
#ifndef LCD_DELAY_INIT
-#define LCD_DELAY_INIT 5000 /**< delay in micro seconds after initialization command sent */
+# define LCD_DELAY_INIT 5000 /**< delay in micro seconds after initialization command sent */
#endif
#ifndef LCD_DELAY_INIT_REP
-#define LCD_DELAY_INIT_REP 64 /**< delay in micro seconds after initialization command repeated */
+# define LCD_DELAY_INIT_REP 64 /**< delay in micro seconds after initialization command repeated */
#endif
#ifndef LCD_DELAY_INIT_4BIT
-#define LCD_DELAY_INIT_4BIT 64 /**< delay in micro seconds after setting 4-bit mode */
+# define LCD_DELAY_INIT_4BIT 64 /**< delay in micro seconds after setting 4-bit mode */
#endif
#ifndef LCD_DELAY_BUSY_FLAG
-#define LCD_DELAY_BUSY_FLAG 4 /**< time in micro seconds the address counter is updated after busy flag is cleared */
+# define LCD_DELAY_BUSY_FLAG 4 /**< time in micro seconds the address counter is updated after busy flag is cleared */
#endif
#ifndef LCD_DELAY_ENABLE_PULSE
-#define LCD_DELAY_ENABLE_PULSE 1 /**< enable signal pulse width in micro seconds */
+# define LCD_DELAY_ENABLE_PULSE 1 /**< enable signal pulse width in micro seconds */
#endif
-
/**
* @name Definitions for LCD command instructions
- * The constants define the various LCD controller instructions which can be passed to the
+ * The constants define the various LCD controller instructions which can be passed to the
* function lcd_command(), see HD44780 data sheet for a complete description.
*/
/* instruction register bit positions, see HD44780U data sheet */
-#define LCD_CLR 0 /* DB0: clear display */
-#define LCD_HOME 1 /* DB1: return to home position */
-#define LCD_ENTRY_MODE 2 /* DB2: set entry mode */
-#define LCD_ENTRY_INC 1 /* DB1: 1=increment, 0=decrement */
-#define LCD_ENTRY_SHIFT 0 /* DB2: 1=display shift on */
-#define LCD_ON 3 /* DB3: turn lcd/cursor on */
-#define LCD_ON_DISPLAY 2 /* DB2: turn display on */
-#define LCD_ON_CURSOR 1 /* DB1: turn cursor on */
-#define LCD_ON_BLINK 0 /* DB0: blinking cursor ? */
-#define LCD_MOVE 4 /* DB4: move cursor/display */
-#define LCD_MOVE_DISP 3 /* DB3: move display (0-> cursor) ? */
-#define LCD_MOVE_RIGHT 2 /* DB2: move right (0-> left) ? */
-#define LCD_FUNCTION 5 /* DB5: function set */
-#define LCD_FUNCTION_8BIT 4 /* DB4: set 8BIT mode (0->4BIT mode) */
-#define LCD_FUNCTION_2LINES 3 /* DB3: two lines (0->one line) */
-#define LCD_FUNCTION_10DOTS 2 /* DB2: 5x10 font (0->5x7 font) */
-#define LCD_CGRAM 6 /* DB6: set CG RAM address */
-#define LCD_DDRAM 7 /* DB7: set DD RAM address */
-#define LCD_BUSY 7 /* DB7: LCD is busy */
+#define LCD_CLR 0 /* DB0: clear display */
+#define LCD_HOME 1 /* DB1: return to home position */
+#define LCD_ENTRY_MODE 2 /* DB2: set entry mode */
+#define LCD_ENTRY_INC 1 /* DB1: 1=increment, 0=decrement */
+#define LCD_ENTRY_SHIFT 0 /* DB2: 1=display shift on */
+#define LCD_ON 3 /* DB3: turn lcd/cursor on */
+#define LCD_ON_DISPLAY 2 /* DB2: turn display on */
+#define LCD_ON_CURSOR 1 /* DB1: turn cursor on */
+#define LCD_ON_BLINK 0 /* DB0: blinking cursor ? */
+#define LCD_MOVE 4 /* DB4: move cursor/display */
+#define LCD_MOVE_DISP 3 /* DB3: move display (0-> cursor) ? */
+#define LCD_MOVE_RIGHT 2 /* DB2: move right (0-> left) ? */
+#define LCD_FUNCTION 5 /* DB5: function set */
+#define LCD_FUNCTION_8BIT 4 /* DB4: set 8BIT mode (0->4BIT mode) */
+#define LCD_FUNCTION_2LINES 3 /* DB3: two lines (0->one line) */
+#define LCD_FUNCTION_10DOTS 2 /* DB2: 5x10 font (0->5x7 font) */
+#define LCD_CGRAM 6 /* DB6: set CG RAM address */
+#define LCD_DDRAM 7 /* DB7: set DD RAM address */
+#define LCD_BUSY 7 /* DB7: LCD is busy */
/* set entry mode: display shift on/off, dec/inc cursor move direction */
-#define LCD_ENTRY_DEC 0x04 /* display shift off, dec cursor move dir */
-#define LCD_ENTRY_DEC_SHIFT 0x05 /* display shift on, dec cursor move dir */
-#define LCD_ENTRY_INC_ 0x06 /* display shift off, inc cursor move dir */
-#define LCD_ENTRY_INC_SHIFT 0x07 /* display shift on, inc cursor move dir */
+#define LCD_ENTRY_DEC 0x04 /* display shift off, dec cursor move dir */
+#define LCD_ENTRY_DEC_SHIFT 0x05 /* display shift on, dec cursor move dir */
+#define LCD_ENTRY_INC_ 0x06 /* display shift off, inc cursor move dir */
+#define LCD_ENTRY_INC_SHIFT 0x07 /* display shift on, inc cursor move dir */
/* display on/off, cursor on/off, blinking char at cursor position */
-#define LCD_DISP_OFF 0x08 /* display off */
-#define LCD_DISP_ON 0x0C /* display on, cursor off */
-#define LCD_DISP_ON_BLINK 0x0D /* display on, cursor off, blink char */
-#define LCD_DISP_ON_CURSOR 0x0E /* display on, cursor on */
-#define LCD_DISP_ON_CURSOR_BLINK 0x0F /* display on, cursor on, blink char */
+#define LCD_DISP_OFF 0x08 /* display off */
+#define LCD_DISP_ON 0x0C /* display on, cursor off */
+#define LCD_DISP_ON_BLINK 0x0D /* display on, cursor off, blink char */
+#define LCD_DISP_ON_CURSOR 0x0E /* display on, cursor on */
+#define LCD_DISP_ON_CURSOR_BLINK 0x0F /* display on, cursor on, blink char */
/* move cursor/shift display */
-#define LCD_MOVE_CURSOR_LEFT 0x10 /* move cursor left (decrement) */
-#define LCD_MOVE_CURSOR_RIGHT 0x14 /* move cursor right (increment) */
-#define LCD_MOVE_DISP_LEFT 0x18 /* shift display left */
-#define LCD_MOVE_DISP_RIGHT 0x1C /* shift display right */
+#define LCD_MOVE_CURSOR_LEFT 0x10 /* move cursor left (decrement) */
+#define LCD_MOVE_CURSOR_RIGHT 0x14 /* move cursor right (increment) */
+#define LCD_MOVE_DISP_LEFT 0x18 /* shift display left */
+#define LCD_MOVE_DISP_RIGHT 0x1C /* shift display right */
/* function set: set interface data length and number of display lines */
-#define LCD_FUNCTION_4BIT_1LINE 0x20 /* 4-bit interface, single line, 5x7 dots */
-#define LCD_FUNCTION_4BIT_2LINES 0x28 /* 4-bit interface, dual line, 5x7 dots */
-#define LCD_FUNCTION_8BIT_1LINE 0x30 /* 8-bit interface, single line, 5x7 dots */
-#define LCD_FUNCTION_8BIT_2LINES 0x38 /* 8-bit interface, dual line, 5x7 dots */
+#define LCD_FUNCTION_4BIT_1LINE 0x20 /* 4-bit interface, single line, 5x7 dots */
+#define LCD_FUNCTION_4BIT_2LINES 0x28 /* 4-bit interface, dual line, 5x7 dots */
+#define LCD_FUNCTION_8BIT_1LINE 0x30 /* 8-bit interface, single line, 5x7 dots */
+#define LCD_FUNCTION_8BIT_2LINES 0x38 /* 8-bit interface, dual line, 5x7 dots */
+#define LCD_MODE_DEFAULT ((1 << LCD_ENTRY_MODE) | (1 << LCD_ENTRY_INC))
-#define LCD_MODE_DEFAULT ((1<<LCD_ENTRY_MODE) | (1<<LCD_ENTRY_INC) )
-
-
-
-/**
+/**
* @name Functions
*/
-
/**
@brief Initialize display and select type of cursor
@param dispAttr \b LCD_DISP_OFF display off\n
\b LCD_DISP_ON display on, cursor off\n
\b LCD_DISP_ON_CURSOR display on, cursor on\n
- \b LCD_DISP_ON_CURSOR_BLINK display on, cursor on flashing
+ \b LCD_DISP_ON_CURSOR_BLINK display on, cursor on flashing
@return none
*/
extern void lcd_init(uint8_t dispAttr);
-
/**
@brief Clear display and set cursor to home position
@return none
*/
extern void lcd_clrscr(void);
-
/**
@brief Set cursor to home position
@return none
*/
extern void lcd_home(void);
-
/**
@brief Set cursor to specified position
-
+
@param x horizontal position\n (0: left most position)
@param y vertical position\n (0: first line)
@return none
*/
extern void lcd_gotoxy(uint8_t x, uint8_t y);
-
/**
@brief Display character at current cursor position
- @param c character to be displayed
+ @param c character to be displayed
@return none
*/
extern void lcd_putc(char c);
-
/**
@brief Display string without auto linefeed
- @param s string to be displayed
+ @param s string to be displayed
@return none
*/
extern void lcd_puts(const char *s);
-
/**
@brief Display string from program memory without auto linefeed
- @param progmem_s string from program memory be be displayed
+ @param progmem_s string from program memory be be displayed
@return none
@see lcd_puts_P
*/
extern void lcd_puts_p(const char *progmem_s);
-
/**
@brief Send LCD controller instruction command
@param cmd instruction to send to LCD controller, see HD44780 data sheet
@@ -349,23 +331,20 @@ extern void lcd_puts_p(const char *progmem_s);
*/
extern void lcd_command(uint8_t cmd);
-
/**
- @brief Send data byte to LCD controller
-
+ @brief Send data byte to LCD controller
+
Similar to lcd_putc(), but without interpreting LF
@param data byte to send to LCD controller, see HD44780 data sheet
@return none
*/
extern void lcd_data(uint8_t data);
-
/**
@brief macros for automatically storing string constant in program memory
*/
-#define lcd_puts_P(__s) lcd_puts_p(PSTR(__s))
+#define lcd_puts_P(__s) lcd_puts_p(PSTR(__s))
/**@}*/
-#endif //LCD_H
-
+#endif // LCD_H
diff --git a/drivers/avr/i2c_master.c b/drivers/avr/i2c_master.c
index f4a7e6bf52..52924437e0 100755..100644
--- a/drivers/avr/i2c_master.c
+++ b/drivers/avr/i2c_master.c
@@ -25,188 +25,200 @@
#include "wait.h"
#ifndef F_SCL
-# define F_SCL 400000UL // SCL frequency
+# define F_SCL 400000UL // SCL frequency
#endif
#define Prescaler 1
#define TWBR_val ((((F_CPU / F_SCL) / Prescaler) - 16) / 2)
void i2c_init(void) {
- TWSR = 0; /* no prescaler */
- TWBR = (uint8_t)TWBR_val;
+ TWSR = 0; /* no prescaler */
+ TWBR = (uint8_t)TWBR_val;
+
+#ifdef __AVR_ATmega32A__
+ // set pull-up resistors on I2C bus pins
+ PORTC |= 0b11;
+
+ // enable TWI (two-wire interface)
+ TWCR |= (1 << TWEN);
+
+ // enable TWI interrupt and slave address ACK
+ TWCR |= (1 << TWIE);
+ TWCR |= (1 << TWEA);
+#endif
}
i2c_status_t i2c_start(uint8_t address, uint16_t timeout) {
- // reset TWI control register
- TWCR = 0;
- // transmit START condition
- TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN);
-
- uint16_t timeout_timer = timer_read();
- while (!(TWCR & (1 << TWINT))) {
- if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) {
- return I2C_STATUS_TIMEOUT;
- }
- }
-
- // check if the start condition was successfully transmitted
- if (((TW_STATUS & 0xF8) != TW_START) && ((TW_STATUS & 0xF8) != TW_REP_START)) {
- return I2C_STATUS_ERROR;
- }
-
- // load slave address into data register
- TWDR = address;
- // start transmission of address
- TWCR = (1 << TWINT) | (1 << TWEN);
-
- timeout_timer = timer_read();
- while (!(TWCR & (1 << TWINT))) {
- if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) {
- return I2C_STATUS_TIMEOUT;
- }
- }
-
- // check if the device has acknowledged the READ / WRITE mode
- uint8_t twst = TW_STATUS & 0xF8;
- if ((twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK)) {
- return I2C_STATUS_ERROR;
- }
-
- return I2C_STATUS_SUCCESS;
+ // reset TWI control register
+ TWCR = 0;
+ // transmit START condition
+ TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN);
+
+ uint16_t timeout_timer = timer_read();
+ while (!(TWCR & (1 << TWINT))) {
+ if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) {
+ return I2C_STATUS_TIMEOUT;
+ }
+ }
+
+ // check if the start condition was successfully transmitted
+ if (((TW_STATUS & 0xF8) != TW_START) && ((TW_STATUS & 0xF8) != TW_REP_START)) {
+ return I2C_STATUS_ERROR;
+ }
+
+ // load slave address into data register
+ TWDR = address;
+ // start transmission of address
+ TWCR = (1 << TWINT) | (1 << TWEN);
+
+ timeout_timer = timer_read();
+ while (!(TWCR & (1 << TWINT))) {
+ if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) {
+ return I2C_STATUS_TIMEOUT;
+ }
+ }
+
+ // check if the device has acknowledged the READ / WRITE mode
+ uint8_t twst = TW_STATUS & 0xF8;
+ if ((twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK)) {
+ return I2C_STATUS_ERROR;
+ }
+
+ return I2C_STATUS_SUCCESS;
}
i2c_status_t i2c_write(uint8_t data, uint16_t timeout) {
- // load data into data register
- TWDR = data;
- // start transmission of data
- TWCR = (1 << TWINT) | (1 << TWEN);
-
- uint16_t timeout_timer = timer_read();
- while (!(TWCR & (1 << TWINT))) {
- if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) {
- return I2C_STATUS_TIMEOUT;
+ // load data into data register
+ TWDR = data;
+ // start transmission of data
+ TWCR = (1 << TWINT) | (1 << TWEN);
+
+ uint16_t timeout_timer = timer_read();
+ while (!(TWCR & (1 << TWINT))) {
+ if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) {
+ return I2C_STATUS_TIMEOUT;
+ }
}
- }
- if ((TW_STATUS & 0xF8) != TW_MT_DATA_ACK) {
- return I2C_STATUS_ERROR;
- }
+ if ((TW_STATUS & 0xF8) != TW_MT_DATA_ACK) {
+ return I2C_STATUS_ERROR;
+ }
- return I2C_STATUS_SUCCESS;
+ return I2C_STATUS_SUCCESS;
}
int16_t i2c_read_ack(uint16_t timeout) {
- // start TWI module and acknowledge data after reception
- TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWEA);
-
- uint16_t timeout_timer = timer_read();
- while (!(TWCR & (1 << TWINT))) {
- if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) {
- return I2C_STATUS_TIMEOUT;
+ // start TWI module and acknowledge data after reception
+ TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWEA);
+
+ uint16_t timeout_timer = timer_read();
+ while (!(TWCR & (1 << TWINT))) {
+ if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) {
+ return I2C_STATUS_TIMEOUT;
+ }
}
- }
- // return received data from TWDR
- return TWDR;
+ // return received data from TWDR
+ return TWDR;
}
int16_t i2c_read_nack(uint16_t timeout) {
- // start receiving without acknowledging reception
- TWCR = (1 << TWINT) | (1 << TWEN);
-
- uint16_t timeout_timer = timer_read();
- while (!(TWCR & (1 << TWINT))) {
- if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) {
- return I2C_STATUS_TIMEOUT;
+ // start receiving without acknowledging reception
+ TWCR = (1 << TWINT) | (1 << TWEN);
+
+ uint16_t timeout_timer = timer_read();
+ while (!(TWCR & (1 << TWINT))) {
+ if ((timeout != I2C_TIMEOUT_INFINITE) && ((timer_read() - timeout_timer) >= timeout)) {
+ return I2C_STATUS_TIMEOUT;
+ }
}
- }
- // return received data from TWDR
- return TWDR;
+ // return received data from TWDR
+ return TWDR;
}
i2c_status_t i2c_transmit(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout) {
- i2c_status_t status = i2c_start(address | I2C_WRITE, timeout);
+ i2c_status_t status = i2c_start(address | I2C_WRITE, timeout);
- for (uint16_t i = 0; i < length && status >= 0; i++) {
- status = i2c_write(data[i], timeout);
- }
+ for (uint16_t i = 0; i < length && status >= 0; i++) {
+ status = i2c_write(data[i], timeout);
+ }
- i2c_stop();
+ i2c_stop();
- return status;
+ return status;
}
i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout) {
- i2c_status_t status = i2c_start(address | I2C_READ, timeout);
+ i2c_status_t status = i2c_start(address | I2C_READ, timeout);
- for (uint16_t i = 0; i < (length - 1) && status >= 0; i++) {
- status = i2c_read_ack(timeout);
- if (status >= 0) {
- data[i] = status;
+ for (uint16_t i = 0; i < (length - 1) && status >= 0; i++) {
+ status = i2c_read_ack(timeout);
+ if (status >= 0) {
+ data[i] = status;
+ }
}
- }
- if (status >= 0) {
- status = i2c_read_nack(timeout);
if (status >= 0) {
- data[(length - 1)] = status;
+ status = i2c_read_nack(timeout);
+ if (status >= 0) {
+ data[(length - 1)] = status;
+ }
}
- }
- i2c_stop();
+ i2c_stop();
- return (status < 0) ? status : I2C_STATUS_SUCCESS;
+ return (status < 0) ? status : I2C_STATUS_SUCCESS;
}
i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout) {
- i2c_status_t status = i2c_start(devaddr | 0x00, timeout);
- if (status >= 0) {
- status = i2c_write(regaddr, timeout);
+ i2c_status_t status = i2c_start(devaddr | 0x00, timeout);
+ if (status >= 0) {
+ status = i2c_write(regaddr, timeout);
- for (uint16_t i = 0; i < length && status >= 0; i++) {
- status = i2c_write(data[i], timeout);
+ for (uint16_t i = 0; i < length && status >= 0; i++) {
+ status = i2c_write(data[i], timeout);
+ }
}
- }
- i2c_stop();
+ i2c_stop();
- return status;
+ return status;
}
i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout) {
- i2c_status_t status = i2c_start(devaddr, timeout);
- if (status < 0) {
- goto error;
- }
+ i2c_status_t status = i2c_start(devaddr, timeout);
+ if (status < 0) {
+ goto error;
+ }
- status = i2c_write(regaddr, timeout);
- if (status < 0) {
- goto error;
- }
+ status = i2c_write(regaddr, timeout);
+ if (status < 0) {
+ goto error;
+ }
- status = i2c_start(devaddr | 0x01, timeout);
+ status = i2c_start(devaddr | 0x01, timeout);
- for (uint16_t i = 0; i < (length - 1) && status >= 0; i++) {
- status = i2c_read_ack(timeout);
- if (status >= 0) {
- data[i] = status;
+ for (uint16_t i = 0; i < (length - 1) && status >= 0; i++) {
+ status = i2c_read_ack(timeout);
+ if (status >= 0) {
+ data[i] = status;
+ }
}
- }
- if (status >= 0) {
- status = i2c_read_nack(timeout);
if (status >= 0) {
- data[(length - 1)] = status;
+ status = i2c_read_nack(timeout);
+ if (status >= 0) {
+ data[(length - 1)] = status;
+ }
}
- }
error:
- i2c_stop();
+ i2c_stop();
- return (status < 0) ? status : I2C_STATUS_SUCCESS;
+ return (status < 0) ? status : I2C_STATUS_SUCCESS;
}
void i2c_stop(void) {
- // transmit STOP condition
- TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWSTO);
+ // transmit STOP condition
+ TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWSTO);
}
diff --git a/drivers/avr/i2c_master.h b/drivers/avr/i2c_master.h
index d68142430a..0a3b6c508c 100755..100644
--- a/drivers/avr/i2c_master.h
+++ b/drivers/avr/i2c_master.h
@@ -26,21 +26,21 @@
typedef int16_t i2c_status_t;
#define I2C_STATUS_SUCCESS (0)
-#define I2C_STATUS_ERROR (-1)
+#define I2C_STATUS_ERROR (-1)
#define I2C_STATUS_TIMEOUT (-2)
#define I2C_TIMEOUT_IMMEDIATE (0)
#define I2C_TIMEOUT_INFINITE (0xFFFF)
-void i2c_init(void);
+void i2c_init(void);
i2c_status_t i2c_start(uint8_t address, uint16_t timeout);
i2c_status_t i2c_write(uint8_t data, uint16_t timeout);
-int16_t i2c_read_ack(uint16_t timeout);
-int16_t i2c_read_nack(uint16_t timeout);
+int16_t i2c_read_ack(uint16_t timeout);
+int16_t i2c_read_nack(uint16_t timeout);
i2c_status_t i2c_transmit(uint8_t address, const 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_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const 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);
-void i2c_stop(void);
+void i2c_stop(void);
-#endif // I2C_MASTER_H
+#endif // I2C_MASTER_H
diff --git a/drivers/avr/i2c_slave.c b/drivers/avr/i2c_slave.c
index 4958a0f8e5..3fb684f70a 100755..100644
--- a/drivers/avr/i2c_slave.c
+++ b/drivers/avr/i2c_slave.c
@@ -27,24 +27,24 @@
volatile uint8_t i2c_slave_reg[I2C_SLAVE_REG_COUNT];
static volatile uint8_t buffer_address;
-static volatile bool slave_has_register_set = false;
+static volatile bool slave_has_register_set = false;
-void i2c_slave_init(uint8_t address){
+void i2c_slave_init(uint8_t address) {
// load address into TWI address register
TWAR = address;
// set the TWCR to enable address matching and enable TWI, clear TWINT, enable TWI interrupt
TWCR = (1 << TWIE) | (1 << TWEA) | (1 << TWINT) | (1 << TWEN);
}
-void i2c_slave_stop(void){
+void i2c_slave_stop(void) {
// clear acknowledge and enable bits
TWCR &= ~((1 << TWEA) | (1 << TWEN));
}
-ISR(TWI_vect){
+ISR(TWI_vect) {
uint8_t ack = 1;
- switch(TW_STATUS){
+ switch (TW_STATUS) {
case TW_SR_SLA_ACK:
// The device is now a slave receiver
slave_has_register_set = false;
@@ -53,14 +53,14 @@ ISR(TWI_vect){
case TW_SR_DATA_ACK:
// This device is a slave receiver and has received data
// First byte is the location then the bytes will be writen in buffer with auto-incriment
- if(!slave_has_register_set){
+ if (!slave_has_register_set) {
buffer_address = TWDR;
if (buffer_address >= I2C_SLAVE_REG_COUNT) { // address out of bounds dont ack
- ack = 0;
- buffer_address = 0;
+ ack = 0;
+ buffer_address = 0;
}
- slave_has_register_set = true; // address has been receaved now fill in buffer
+ slave_has_register_set = true; // address has been receaved now fill in buffer
} else {
i2c_slave_reg[buffer_address] = TWDR;
buffer_address++;
diff --git a/drivers/avr/i2c_slave.h b/drivers/avr/i2c_slave.h
index 2f4589e9c7..5ed0b11a8e 100755..100644
--- a/drivers/avr/i2c_slave.h
+++ b/drivers/avr/i2c_slave.h
@@ -30,4 +30,4 @@ extern volatile uint8_t i2c_slave_reg[I2C_SLAVE_REG_COUNT];
void i2c_slave_init(uint8_t address);
void i2c_slave_stop(void);
-#endif // I2C_SLAVE_H
+#endif // I2C_SLAVE_H
diff --git a/drivers/avr/pro_micro.h b/drivers/avr/pro_micro.h
index f9e7ed75d9..762a99a058 100644
--- a/drivers/avr/pro_micro.h
+++ b/drivers/avr/pro_micro.h
@@ -90,14 +90,14 @@
#undef OCR2_6
#undef OCR2_7
-#define NUM_DIGITAL_PINS 30
+#define NUM_DIGITAL_PINS 30
#define NUM_ANALOG_INPUTS 12
-#define TX_RX_LED_INIT DDRD |= (1<<5), DDRB |= (1<<0)
-#define TXLED0 PORTD |= (1<<5)
-#define TXLED1 PORTD &= ~(1<<5)
-#define RXLED0 PORTB |= (1<<0)
-#define RXLED1 PORTB &= ~(1<<0)
+#define TX_RX_LED_INIT DDRD |= (1 << 5), DDRB |= (1 << 0)
+#define TXLED0 PORTD |= (1 << 5)
+#define TXLED1 PORTD &= ~(1 << 5)
+#define RXLED0 PORTB |= (1 << 0)
+#define RXLED1 PORTB &= ~(1 << 0)
static const uint8_t SDA = 2;
static const uint8_t SCL = 3;
@@ -111,27 +111,27 @@ static const uint8_t SCK = 15;
// Mapping of analog pins as digital I/O
// A6-A11 share with digital pins
-static const uint8_t ADC0 = 18;
-static const uint8_t ADC1 = 19;
-static const uint8_t ADC2 = 20;
-static const uint8_t ADC3 = 21;
-static const uint8_t ADC4 = 22;
-static const uint8_t ADC5 = 23;
-static const uint8_t ADC6 = 24; // D4
-static const uint8_t ADC7 = 25; // D6
-static const uint8_t ADC8 = 26; // D8
-static const uint8_t ADC9 = 27; // D9
+static const uint8_t ADC0 = 18;
+static const uint8_t ADC1 = 19;
+static const uint8_t ADC2 = 20;
+static const uint8_t ADC3 = 21;
+static const uint8_t ADC4 = 22;
+static const uint8_t ADC5 = 23;
+static const uint8_t ADC6 = 24; // D4
+static const uint8_t ADC7 = 25; // D6
+static const uint8_t ADC8 = 26; // D8
+static const uint8_t ADC9 = 27; // D9
static const uint8_t ADC10 = 28; // D10
static const uint8_t ADC11 = 29; // D12
-#define digitalPinToPCICR(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCICR) : ((uint8_t *)0))
+#define digitalPinToPCICR(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCICR) : ((uint8_t *)0))
#define digitalPinToPCICRbit(p) 0
-#define digitalPinToPCMSK(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCMSK0) : ((uint8_t *)0))
-#define digitalPinToPCMSKbit(p) ( ((p) >= 8 && (p) <= 11) ? (p) - 4 : ((p) == 14 ? 3 : ((p) == 15 ? 1 : ((p) == 16 ? 2 : ((p) == 17 ? 0 : (p - A8 + 4))))))
+#define digitalPinToPCMSK(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCMSK0) : ((uint8_t *)0))
+#define digitalPinToPCMSKbit(p) (((p) >= 8 && (p) <= 11) ? (p)-4 : ((p) == 14 ? 3 : ((p) == 15 ? 1 : ((p) == 16 ? 2 : ((p) == 17 ? 0 : (p - A8 + 4))))))
// __AVR_ATmega32U4__ has an unusual mapping of pins to channels
extern const uint8_t PROGMEM analog_pin_to_channel_PGM[];
-#define analogPinToChannel(P) ( pgm_read_byte( analog_pin_to_channel_PGM + (P) ) )
+#define analogPinToChannel(P) (pgm_read_byte(analog_pin_to_channel_PGM + (P)))
#define digitalPinToInterrupt(p) ((p) == 0 ? 2 : ((p) == 1 ? 3 : ((p) == 2 ? 1 : ((p) == 3 ? 0 : ((p) == 7 ? 4 : NOT_AN_INTERRUPT)))))
@@ -182,159 +182,121 @@ extern const uint8_t PROGMEM analog_pin_to_channel_PGM[];
// appropriate addresses for various functions (e.g. reading
// and writing)
const uint16_t PROGMEM port_to_mode_PGM[] = {
- NOT_A_PORT,
- NOT_A_PORT,
- (uint16_t) &DDRB,
- (uint16_t) &DDRC,
- (uint16_t) &DDRD,
- (uint16_t) &DDRE,
- (uint16_t) &DDRF,
+ NOT_A_PORT, NOT_A_PORT, (uint16_t)&DDRB, (uint16_t)&DDRC, (uint16_t)&DDRD, (uint16_t)&DDRE, (uint16_t)&DDRF,
};
const uint16_t PROGMEM port_to_output_PGM[] = {
- NOT_A_PORT,
- NOT_A_PORT,
- (uint16_t) &PORTB,
- (uint16_t) &PORTC,
- (uint16_t) &PORTD,
- (uint16_t) &PORTE,
- (uint16_t) &PORTF,
+ NOT_A_PORT, NOT_A_PORT, (uint16_t)&PORTB, (uint16_t)&PORTC, (uint16_t)&PORTD, (uint16_t)&PORTE, (uint16_t)&PORTF,
};
const uint16_t PROGMEM port_to_input_PGM[] = {
- NOT_A_PORT,
- NOT_A_PORT,
- (uint16_t) &PINB,
- (uint16_t) &PINC,
- (uint16_t) &PIND,
- (uint16_t) &PINE,
- (uint16_t) &PINF,
+ NOT_A_PORT, NOT_A_PORT, (uint16_t)&PINB, (uint16_t)&PINC, (uint16_t)&PIND, (uint16_t)&PINE, (uint16_t)&PINF,
};
const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
- PD, // D0 - PD2
- PD, // D1 - PD3
- PD, // D2 - PD1
- PD, // D3 - PD0
- PD, // D4 - PD4
- PC, // D5 - PC6
- PD, // D6 - PD7
- PE, // D7 - PE6
-
- PB, // D8 - PB4
- PB, // D9 - PB5
- PB, // D10 - PB6
- PB, // D11 - PB7
- PD, // D12 - PD6
- PC, // D13 - PC7
-
- PB, // D14 - MISO - PB3
- PB, // D15 - SCK - PB1
- PB, // D16 - MOSI - PB2
- PB, // D17 - SS - PB0
-
- PF, // D18 - A0 - PF7
- PF, // D19 - A1 - PF6
- PF, // D20 - A2 - PF5
- PF, // D21 - A3 - PF4
- PF, // D22 - A4 - PF1
- PF, // D23 - A5 - PF0
-
- PD, // D24 - PD5
- PD, // D25 / D6 - A7 - PD7
- PB, // D26 / D8 - A8 - PB4
- PB, // D27 / D9 - A9 - PB5
- PB, // D28 / D10 - A10 - PB6
- PD, // D29 / D12 - A11 - PD6
+ PD, // D0 - PD2
+ PD, // D1 - PD3
+ PD, // D2 - PD1
+ PD, // D3 - PD0
+ PD, // D4 - PD4
+ PC, // D5 - PC6
+ PD, // D6 - PD7
+ PE, // D7 - PE6
+
+ PB, // D8 - PB4
+ PB, // D9 - PB5
+ PB, // D10 - PB6
+ PB, // D11 - PB7
+ PD, // D12 - PD6
+ PC, // D13 - PC7
+
+ PB, // D14 - MISO - PB3
+ PB, // D15 - SCK - PB1
+ PB, // D16 - MOSI - PB2
+ PB, // D17 - SS - PB0
+
+ PF, // D18 - A0 - PF7
+ PF, // D19 - A1 - PF6
+ PF, // D20 - A2 - PF5
+ PF, // D21 - A3 - PF4
+ PF, // D22 - A4 - PF1
+ PF, // D23 - A5 - PF0
+
+ PD, // D24 - PD5
+ PD, // D25 / D6 - A7 - PD7
+ PB, // D26 / D8 - A8 - PB4
+ PB, // D27 / D9 - A9 - PB5
+ PB, // D28 / D10 - A10 - PB6
+ PD, // D29 / D12 - A11 - PD6
};
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
- _BV(2), // D0 - PD2
- _BV(3), // D1 - PD3
- _BV(1), // D2 - PD1
- _BV(0), // D3 - PD0
- _BV(4), // D4 - PD4
- _BV(6), // D5 - PC6
- _BV(7), // D6 - PD7
- _BV(6), // D7 - PE6
-
- _BV(4), // D8 - PB4
- _BV(5), // D9 - PB5
- _BV(6), // D10 - PB6
- _BV(7), // D11 - PB7
- _BV(6), // D12 - PD6
- _BV(7), // D13 - PC7
-
- _BV(3), // D14 - MISO - PB3
- _BV(1), // D15 - SCK - PB1
- _BV(2), // D16 - MOSI - PB2
- _BV(0), // D17 - SS - PB0
-
- _BV(7), // D18 - A0 - PF7
- _BV(6), // D19 - A1 - PF6
- _BV(5), // D20 - A2 - PF5
- _BV(4), // D21 - A3 - PF4
- _BV(1), // D22 - A4 - PF1
- _BV(0), // D23 - A5 - PF0
-
- _BV(5), // D24 - PD5
- _BV(7), // D25 / D6 - A7 - PD7
- _BV(4), // D26 / D8 - A8 - PB4
- _BV(5), // D27 / D9 - A9 - PB5
- _BV(6), // D28 / D10 - A10 - PB6
- _BV(6), // D29 / D12 - A11 - PD6
+ _BV(2), // D0 - PD2
+ _BV(3), // D1 - PD3
+ _BV(1), // D2 - PD1
+ _BV(0), // D3 - PD0
+ _BV(4), // D4 - PD4
+ _BV(6), // D5 - PC6
+ _BV(7), // D6 - PD7
+ _BV(6), // D7 - PE6
+
+ _BV(4), // D8 - PB4
+ _BV(5), // D9 - PB5
+ _BV(6), // D10 - PB6
+ _BV(7), // D11 - PB7
+ _BV(6), // D12 - PD6
+ _BV(7), // D13 - PC7
+
+ _BV(3), // D14 - MISO - PB3
+ _BV(1), // D15 - SCK - PB1
+ _BV(2), // D16 - MOSI - PB2
+ _BV(0), // D17 - SS - PB0
+
+ _BV(7), // D18 - A0 - PF7
+ _BV(6), // D19 - A1 - PF6
+ _BV(5), // D20 - A2 - PF5
+ _BV(4), // D21 - A3 - PF4
+ _BV(1), // D22 - A4 - PF1
+ _BV(0), // D23 - A5 - PF0
+
+ _BV(5), // D24 - PD5
+ _BV(7), // D25 / D6 - A7 - PD7
+ _BV(4), // D26 / D8 - A8 - PB4
+ _BV(5), // D27 / D9 - A9 - PB5
+ _BV(6), // D28 / D10 - A10 - PB6
+ _BV(6), // D29 / D12 - A11 - PD6
};
const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
- NOT_ON_TIMER,
- NOT_ON_TIMER,
- NOT_ON_TIMER,
- TIMER0B, /* 3 */
- NOT_ON_TIMER,
- TIMER3A, /* 5 */
- TIMER4D, /* 6 */
+ NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, TIMER0B, /* 3 */
+ NOT_ON_TIMER, TIMER3A, /* 5 */
+ TIMER4D, /* 6 */
NOT_ON_TIMER,
- NOT_ON_TIMER,
- TIMER1A, /* 9 */
- TIMER1B, /* 10 */
- TIMER0A, /* 11 */
+ NOT_ON_TIMER, TIMER1A, /* 9 */
+ TIMER1B, /* 10 */
+ TIMER0A, /* 11 */
- NOT_ON_TIMER,
- TIMER4A, /* 13 */
+ NOT_ON_TIMER, TIMER4A, /* 13 */
- NOT_ON_TIMER,
- NOT_ON_TIMER,
- NOT_ON_TIMER,
- NOT_ON_TIMER,
- NOT_ON_TIMER,
- NOT_ON_TIMER,
+ NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER,
- NOT_ON_TIMER,
- NOT_ON_TIMER,
- NOT_ON_TIMER,
- NOT_ON_TIMER,
- NOT_ON_TIMER,
- NOT_ON_TIMER,
- NOT_ON_TIMER,
- NOT_ON_TIMER,
- NOT_ON_TIMER,
- NOT_ON_TIMER,
+ NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER, NOT_ON_TIMER,
};
const uint8_t PROGMEM analog_pin_to_channel_PGM[] = {
- 7, // A0 PF7 ADC7
- 6, // A1 PF6 ADC6
- 5, // A2 PF5 ADC5
- 4, // A3 PF4 ADC4
- 1, // A4 PF1 ADC1
- 0, // A5 PF0 ADC0
- 8, // A6 D4 PD4 ADC8
- 10, // A7 D6 PD7 ADC10
- 11, // A8 D8 PB4 ADC11
- 12, // A9 D9 PB5 ADC12
- 13, // A10 D10 PB6 ADC13
- 9 // A11 D12 PD6 ADC9
+ 7, // A0 PF7 ADC7
+ 6, // A1 PF6 ADC6
+ 5, // A2 PF5 ADC5
+ 4, // A3 PF4 ADC4
+ 1, // A4 PF1 ADC1
+ 0, // A5 PF0 ADC0
+ 8, // A6 D4 PD4 ADC8
+ 10, // A7 D6 PD7 ADC10
+ 11, // A8 D8 PB4 ADC11
+ 12, // A9 D9 PB5 ADC12
+ 13, // A10 D10 PB6 ADC13
+ 9 // A11 D12 PD6 ADC9
};
#endif /* ARDUINO_MAIN */
@@ -354,9 +316,9 @@ const uint8_t PROGMEM analog_pin_to_channel_PGM[] = {
//
// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
// pins are NOT connected to anything by default.
-#define SERIAL_PORT_MONITOR Serial
-#define SERIAL_PORT_USBVIRTUAL Serial
-#define SERIAL_PORT_HARDWARE Serial1
-#define SERIAL_PORT_HARDWARE_OPEN Serial1
+#define SERIAL_PORT_MONITOR Serial
+#define SERIAL_PORT_USBVIRTUAL Serial
+#define SERIAL_PORT_HARDWARE Serial1
+#define SERIAL_PORT_HARDWARE_OPEN Serial1
#endif /* Pins_Arduino_h */
diff --git a/drivers/avr/ssd1306.c b/drivers/avr/ssd1306.c
index bb8938bba3..61d7a99531 100644
--- a/drivers/avr/ssd1306.c
+++ b/drivers/avr/ssd1306.c
@@ -1,325 +1,320 @@
#ifdef SSD1306OLED
-#include "ssd1306.h"
-#include "i2c.h"
-#include <string.h>
-#include "print.h"
-#include "glcdfont.c"
-#ifdef ADAFRUIT_BLE_ENABLE
-#include "adafruit_ble.h"
-#endif
-#ifdef PROTOCOL_LUFA
-#include "lufa.h"
-#endif
-#include "sendchar.h"
-#include "timer.h"
+# include "ssd1306.h"
+# include "i2c.h"
+# include <string.h>
+# include "print.h"
+# include "glcdfont.c"
+# 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
+# define DEBUG_TO_SCREEN 0
-//static uint16_t last_battery_update;
-//static uint32_t vbat;
+// static uint16_t last_battery_update;
+// static uint32_t vbat;
//#define BatteryUpdateInterval 10000 /* milliseconds */
-#define ScreenOffInterval 300000 /* milliseconds */
-#if DEBUG_TO_SCREEN
+# define ScreenOffInterval 300000 /* milliseconds */
+# if DEBUG_TO_SCREEN
static uint8_t displaying;
-#endif
+# endif
static uint16_t last_flush;
// Write command sequence.
// Returns true on success.
static inline bool _send_cmd1(uint8_t cmd) {
- bool res = false;
+ bool res = false;
- if (i2c_start_write(SSD1306_ADDRESS)) {
- xprintf("failed to start write to %d\n", SSD1306_ADDRESS);
- goto done;
- }
+ 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");
+ if (i2c_master_write(0x0 /* command byte follows */)) {
+ print("failed to write control byte\n");
- goto done;
- }
+ goto done;
+ }
- if (i2c_master_write(cmd)) {
- xprintf("failed to write command %d\n", cmd);
- goto done;
- }
- res = true;
+ if (i2c_master_write(cmd)) {
+ xprintf("failed to write command %d\n", cmd);
+ goto done;
+ }
+ res = true;
done:
- i2c_master_stop();
- return res;
+ 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);
+ 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);
+ 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;}
+# 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);
+ 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;
+ display.dirty = false;
done:
- i2c_master_stop();
+ i2c_master_stop();
}
-#if DEBUG_TO_SCREEN
-#undef sendchar
+# if DEBUG_TO_SCREEN
+# undef sendchar
static int8_t capture_sendchar(uint8_t c) {
- sendchar(c);
- iota_gfx_write_char(c);
+ sendchar(c);
+ iota_gfx_write_char(c);
- if (!displaying) {
- iota_gfx_flush();
- }
- return 0;
+ if (!displaying) {
+ iota_gfx_flush();
+ }
+ return 0;
}
-#endif
+# endif
bool iota_gfx_init(void) {
- bool success = false;
+ bool success = false;
- send_cmd1(DisplayOff);
- send_cmd2(SetDisplayClockDiv, 0x80);
- send_cmd2(SetMultiPlex, DisplayHeight - 1);
+ send_cmd1(DisplayOff);
+ send_cmd2(SetDisplayClockDiv, 0x80);
+ send_cmd2(SetMultiPlex, DisplayHeight - 1);
- send_cmd2(SetDisplayOffset, 0);
+ send_cmd2(SetDisplayOffset, 0);
+ send_cmd1(SetStartLine | 0x0);
+ send_cmd2(SetChargePump, 0x14 /* Enable */);
+ send_cmd2(SetMemoryMode, 0 /* horizontal addressing */);
- send_cmd1(SetStartLine | 0x0);
- send_cmd2(SetChargePump, 0x14 /* Enable */);
- send_cmd2(SetMemoryMode, 0 /* horizontal addressing */);
+# ifdef OLED_ROTATE180
+ // the following Flip the display orientation 180 degrees
+ send_cmd1(SegRemap);
+ send_cmd1(ComScanInc);
+# endif
+# ifndef OLED_ROTATE180
+ // Flips the display orientation 0 degrees
+ send_cmd1(SegRemap | 0x1);
+ send_cmd1(ComScanDec);
+# endif
-#ifdef OLED_ROTATE180
-// the following Flip the display orientation 180 degrees
- send_cmd1(SegRemap);
- send_cmd1(ComScanInc);
-#endif
-#ifndef OLED_ROTATE180
-// Flips the display orientation 0 degrees
- send_cmd1(SegRemap | 0x1);
- send_cmd1(ComScanDec);
-#endif
-
- 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(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
+ send_cmd2(SetContrast, 0); // Dim
- clear_display();
+ clear_display();
- success = true;
+ success = true;
- iota_gfx_flush();
+ iota_gfx_flush();
-#if DEBUG_TO_SCREEN
- print_set_sendchar(capture_sendchar);
-#endif
+# if DEBUG_TO_SCREEN
+ print_set_sendchar(capture_sendchar);
+# endif
done:
- return success;
+ return success;
}
bool iota_gfx_off(void) {
- bool success = false;
+ bool success = false;
- send_cmd1(DisplayOff);
- success = true;
+ send_cmd1(DisplayOff);
+ success = true;
done:
- return success;
-}
+ return success;
+}
bool iota_gfx_on(void) {
- bool success = false;
+ bool success = false;
- send_cmd1(DisplayOn);
- success = true;
+ send_cmd1(DisplayOn);
+ success = true;
done:
- return success;
+ 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);
- }
+ *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;
+ 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;
+ 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, ' ');
+ while (cursor_col++ < MatrixCols) {
+ matrix_write_char_inner(matrix, ' ');
+ }
+ return;
}
- return;
- }
- matrix_write_char_inner(matrix, c);
+ matrix_write_char_inner(matrix, c);
}
-void iota_gfx_write_char(uint8_t c) {
- matrix_write_char(&display, 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;
- }
+ 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 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;
+ while (true) {
+ uint8_t c = pgm_read_byte(data);
+ if (c == 0) {
+ return;
+ }
+ matrix_write_char(matrix, c);
+ ++data;
}
- matrix_write_char(matrix, c);
- ++data;
- }
}
-void iota_gfx_write_P(const char *data) {
- matrix_write_P(&display, 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;
+ 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 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
+ 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 - 1));
+
+ for (uint8_t glyphCol = 0; glyphCol < FontWidth - 1; ++glyphCol) {
+ uint8_t colBits = pgm_read_byte(glyph + glyphCol);
+ i2c_master_write(colBits);
+ }
- // 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 - 1));
-
- for (uint8_t glyphCol = 0; glyphCol < FontWidth - 1; ++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);
+ // 1 column of space between chars (it's not included in the glyph)
+ i2c_master_write(0);
+ }
}
- }
- matrix->dirty = false;
+ matrix->dirty = false;
done:
- i2c_master_stop();
-#if DEBUG_TO_SCREEN
- --displaying;
-#endif
+ i2c_master_stop();
+# if DEBUG_TO_SCREEN
+ --displaying;
+# endif
}
-void iota_gfx_flush(void) {
- matrix_render(&display);
-}
+void iota_gfx_flush(void) { matrix_render(&display); }
-__attribute__ ((weak))
-void iota_gfx_task_user(void) {
-}
+__attribute__((weak)) void iota_gfx_task_user(void) {}
void iota_gfx_task(void) {
- iota_gfx_task_user();
+ iota_gfx_task_user();
- if (display.dirty) {
- iota_gfx_flush();
- }
+ if (display.dirty) {
+ iota_gfx_flush();
+ }
- if (timer_elapsed(last_flush) > ScreenOffInterval) {
- iota_gfx_off();
- }
+ if (timer_elapsed(last_flush) > ScreenOffInterval) {
+ iota_gfx_off();
+ }
}
#endif
diff --git a/drivers/avr/ssd1306.h b/drivers/avr/ssd1306.h
index df6a75359f..825b0d7d5b 100644
--- a/drivers/avr/ssd1306.h
+++ b/drivers/avr/ssd1306.h
@@ -7,49 +7,49 @@
#include "config.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,
+ 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
+# define SSD1306_ADDRESS 0x3C
#endif
#define DisplayHeight 32
@@ -62,9 +62,9 @@ enum ssd1306_cmds {
#define MatrixCols (DisplayWidth / FontWidth)
struct CharacterMatrix {
- uint8_t display[MatrixRows][MatrixCols];
- uint8_t *cursor;
- bool dirty;
+ uint8_t display[MatrixRows][MatrixCols];
+ uint8_t *cursor;
+ bool dirty;
};
struct CharacterMatrix display;
@@ -88,6 +88,4 @@ 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/drivers/avr/ws2812.c b/drivers/avr/ws2812.c
index 7c3cb5174d..0a02c6f7fd 100644
--- a/drivers/avr/ws2812.c
+++ b/drivers/avr/ws2812.c
@@ -1,25 +1,25 @@
/*
-* light weight WS2812 lib V2.0b
-*
-* Controls WS2811/WS2812/WS2812B RGB-LEDs
-* Author: Tim (cpldcpu@gmail.com)
-*
-* Jan 18th, 2014 v2.0b Initial Version
-* Nov 29th, 2015 v2.3 Added SK6812RGBW support
-*
-* 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/>.
-*/
+ * light weight WS2812 lib V2.0b
+ *
+ * Controls WS2811/WS2812/WS2812B RGB-LEDs
+ * Author: Tim (cpldcpu@gmail.com)
+ *
+ * Jan 18th, 2014 v2.0b Initial Version
+ * Nov 29th, 2015 v2.3 Added SK6812RGBW support
+ *
+ * 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 "ws2812.h"
#include <avr/interrupt.h>
@@ -30,44 +30,40 @@
#if !defined(LED_ARRAY) && defined(RGB_MATRIX_ENABLE)
// LED color buffer
LED_TYPE led[DRIVER_LED_TOTAL];
- #define LED_ARRAY led
+# define LED_ARRAY led
#endif
#ifdef RGBW_BB_TWI
// Port for the I2C
-#define I2C_DDR DDRD
-#define I2C_PIN PIND
-#define I2C_PORT PORTD
+# define I2C_DDR DDRD
+# define I2C_PIN PIND
+# define I2C_PORT PORTD
// Pins to be used in the bit banging
-#define I2C_CLK 0
-#define I2C_DAT 1
-
-#define I2C_DATA_HI()\
-I2C_DDR &= ~ (1 << I2C_DAT);\
-I2C_PORT |= (1 << I2C_DAT);
-#define I2C_DATA_LO()\
-I2C_DDR |= (1 << I2C_DAT);\
-I2C_PORT &= ~ (1 << I2C_DAT);
-
-#define I2C_CLOCK_HI()\
-I2C_DDR &= ~ (1 << I2C_CLK);\
-I2C_PORT |= (1 << I2C_CLK);
-#define I2C_CLOCK_LO()\
-I2C_DDR |= (1 << I2C_CLK);\
-I2C_PORT &= ~ (1 << I2C_CLK);
-
-#define I2C_DELAY 1
-
-void I2C_WriteBit(unsigned char c)
-{
- if (c > 0)
- {
+# define I2C_CLK 0
+# define I2C_DAT 1
+
+# define I2C_DATA_HI() \
+ I2C_DDR &= ~(1 << I2C_DAT); \
+ I2C_PORT |= (1 << I2C_DAT);
+# define I2C_DATA_LO() \
+ I2C_DDR |= (1 << I2C_DAT); \
+ I2C_PORT &= ~(1 << I2C_DAT);
+
+# define I2C_CLOCK_HI() \
+ I2C_DDR &= ~(1 << I2C_CLK); \
+ I2C_PORT |= (1 << I2C_CLK);
+# define I2C_CLOCK_LO() \
+ I2C_DDR |= (1 << I2C_CLK); \
+ I2C_PORT &= ~(1 << I2C_CLK);
+
+# define I2C_DELAY 1
+
+void I2C_WriteBit(unsigned char c) {
+ if (c > 0) {
I2C_DATA_HI();
- }
- else
- {
+ } else {
I2C_DATA_LO();
}
@@ -77,8 +73,7 @@ void I2C_WriteBit(unsigned char c)
I2C_CLOCK_LO();
_delay_us(I2C_DELAY);
- if (c > 0)
- {
+ if (c > 0) {
I2C_DATA_LO();
}
@@ -87,9 +82,8 @@ void I2C_WriteBit(unsigned char c)
// Inits bitbanging port, must be called before using the functions below
//
-void I2C_Init(void)
-{
- I2C_PORT &= ~ ((1 << I2C_DAT) | (1 << I2C_CLK));
+void I2C_Init(void) {
+ I2C_PORT &= ~((1 << I2C_DAT) | (1 << I2C_CLK));
I2C_CLOCK_HI();
I2C_DATA_HI();
@@ -99,10 +93,9 @@ void I2C_Init(void)
// Send a START Condition
//
-void I2C_Start(void)
-{
+void I2C_Start(void) {
// set both to high at the same time
- I2C_DDR &= ~ ((1 << I2C_DAT) | (1 << I2C_CLK));
+ I2C_DDR &= ~((1 << I2C_DAT) | (1 << I2C_CLK));
_delay_us(I2C_DELAY);
I2C_DATA_LO();
@@ -114,8 +107,7 @@ void I2C_Start(void)
// Send a STOP Condition
//
-void I2C_Stop(void)
-{
+void I2C_Stop(void) {
I2C_CLOCK_HI();
_delay_us(I2C_DELAY);
@@ -125,106 +117,91 @@ void I2C_Stop(void)
// write a byte to the I2C slave device
//
-unsigned char I2C_Write(unsigned char c)
-{
- for (char i = 0; i < 8; i++)
- {
+unsigned char I2C_Write(unsigned char c) {
+ for (char i = 0; i < 8; i++) {
I2C_WriteBit(c & 128);
c <<= 1;
}
-
I2C_WriteBit(0);
_delay_us(I2C_DELAY);
_delay_us(I2C_DELAY);
// _delay_us(I2C_DELAY);
- //return I2C_ReadBit();
+ // return I2C_ReadBit();
return 0;
}
-
#endif
#ifdef RGB_MATRIX_ENABLE
// Set an led in the buffer to a color
-void inline ws2812_setled(int i, uint8_t r, uint8_t g, uint8_t b)
-{
+void inline ws2812_setled(int i, uint8_t r, uint8_t g, uint8_t b) {
led[i].r = r;
led[i].g = g;
led[i].b = b;
}
-void ws2812_setled_all (uint8_t r, uint8_t g, uint8_t b)
-{
- for (int i = 0; i < sizeof(led)/sizeof(led[0]); i++) {
- led[i].r = r;
- led[i].g = g;
- led[i].b = b;
- }
+void ws2812_setled_all(uint8_t r, uint8_t g, uint8_t b) {
+ for (int i = 0; i < sizeof(led) / sizeof(led[0]); i++) {
+ led[i].r = r;
+ led[i].g = g;
+ led[i].b = b;
+ }
}
#endif
// Setleds for standard RGB
-void inline ws2812_setleds(LED_TYPE *ledarray, uint16_t leds)
-{
- // ws2812_setleds_pin(ledarray,leds, _BV(ws2812_pin));
- ws2812_setleds_pin(ledarray,leds, _BV(RGB_DI_PIN & 0xF));
+void inline ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) {
+ // ws2812_setleds_pin(ledarray,leds, _BV(ws2812_pin));
+ ws2812_setleds_pin(ledarray, leds, _BV(RGB_DI_PIN & 0xF));
}
-void inline ws2812_setleds_pin(LED_TYPE *ledarray, uint16_t leds, uint8_t pinmask)
-{
- // ws2812_DDRREG |= pinmask; // Enable DDR
- // new universal format (DDR)
- _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= pinmask;
+void inline ws2812_setleds_pin(LED_TYPE *ledarray, uint16_t leds, uint8_t pinmask) {
+ // ws2812_DDRREG |= pinmask; // Enable DDR
+ // new universal format (DDR)
+ _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= pinmask;
- ws2812_sendarray_mask((uint8_t*)ledarray,leds+leds+leds,pinmask);
- _delay_us(50);
+ ws2812_sendarray_mask((uint8_t *)ledarray, leds + leds + leds, pinmask);
+ _delay_us(50);
}
// Setleds for SK6812RGBW
-void inline ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t leds)
-{
-
- #ifdef RGBW_BB_TWI
+void inline ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t leds) {
+#ifdef RGBW_BB_TWI
uint8_t sreg_prev, twcr_prev;
- sreg_prev=SREG;
- twcr_prev=TWCR;
+ sreg_prev = SREG;
+ twcr_prev = TWCR;
cli();
- TWCR &= ~(1<<TWEN);
+ TWCR &= ~(1 << TWEN);
I2C_Init();
I2C_Start();
I2C_Write(0x84);
- uint16_t datlen = leds<<2;
- uint8_t curbyte;
- uint8_t * data = (uint8_t*)ledarray;
+ uint16_t datlen = leds << 2;
+ uint8_t curbyte;
+ uint8_t *data = (uint8_t *)ledarray;
while (datlen--) {
- curbyte=*data++;
- I2C_Write(curbyte);
+ curbyte = *data++;
+ I2C_Write(curbyte);
}
I2C_Stop();
- SREG=sreg_prev;
- TWCR=twcr_prev;
- #endif
-
-
- // ws2812_DDRREG |= _BV(ws2812_pin); // Enable DDR
- // new universal format (DDR)
- _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= _BV(RGB_DI_PIN & 0xF);
+ SREG = sreg_prev;
+ TWCR = twcr_prev;
+#endif
- ws2812_sendarray_mask((uint8_t*)ledarray,leds<<2,_BV(RGB_DI_PIN & 0xF));
+ // ws2812_DDRREG |= _BV(ws2812_pin); // Enable DDR
+ // new universal format (DDR)
+ _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= _BV(RGB_DI_PIN & 0xF);
+ ws2812_sendarray_mask((uint8_t *)ledarray, leds << 2, _BV(RGB_DI_PIN & 0xF));
- #ifndef RGBW_BB_TWI
+#ifndef RGBW_BB_TWI
_delay_us(80);
- #endif
+#endif
}
-void ws2812_sendarray(uint8_t *data,uint16_t datlen)
-{
- ws2812_sendarray_mask(data,datlen,_BV(RGB_DI_PIN & 0xF));
-}
+void ws2812_sendarray(uint8_t *data, uint16_t datlen) { ws2812_sendarray_mask(data, datlen, _BV(RGB_DI_PIN & 0xF)); }
/*
This routine writes an array of bytes with RGB values to the Dataout pin
@@ -232,136 +209,133 @@ void ws2812_sendarray(uint8_t *data,uint16_t datlen)
*/
// Timing in ns
-#define w_zeropulse 350
-#define w_onepulse 900
+#define w_zeropulse 350
+#define w_onepulse 900
#define w_totalperiod 1250
// Fixed cycles used by the inner loop
-#define w_fixedlow 2
-#define w_fixedhigh 4
-#define w_fixedtotal 8
+#define w_fixedlow 2
+#define w_fixedhigh 4
+#define w_fixedtotal 8
// Insert NOPs to match the timing, if possible
-#define w_zerocycles (((F_CPU/1000)*w_zeropulse )/1000000)
-#define w_onecycles (((F_CPU/1000)*w_onepulse +500000)/1000000)
-#define w_totalcycles (((F_CPU/1000)*w_totalperiod +500000)/1000000)
+#define w_zerocycles (((F_CPU / 1000) * w_zeropulse) / 1000000)
+#define w_onecycles (((F_CPU / 1000) * w_onepulse + 500000) / 1000000)
+#define w_totalcycles (((F_CPU / 1000) * w_totalperiod + 500000) / 1000000)
// w1 - nops between rising edge and falling edge - low
-#define w1 (w_zerocycles-w_fixedlow)
+#define w1 (w_zerocycles - w_fixedlow)
// w2 nops between fe low and fe high
-#define w2 (w_onecycles-w_fixedhigh-w1)
+#define w2 (w_onecycles - w_fixedhigh - w1)
// w3 nops to complete loop
-#define w3 (w_totalcycles-w_fixedtotal-w1-w2)
+#define w3 (w_totalcycles - w_fixedtotal - w1 - w2)
-#if w1>0
- #define w1_nops w1
+#if w1 > 0
+# define w1_nops w1
#else
- #define w1_nops 0
+# define w1_nops 0
#endif
// The only critical timing parameter is the minimum pulse length of the "0"
// Warn or throw error if this timing can not be met with current F_CPU settings.
-#define w_lowtime ((w1_nops+w_fixedlow)*1000000)/(F_CPU/1000)
-#if w_lowtime>550
- #error "Light_ws2812: Sorry, the clock speed is too low. Did you set F_CPU correctly?"
-#elif w_lowtime>450
- #warning "Light_ws2812: The timing is critical and may only work on WS2812B, not on WS2812(S)."
- #warning "Please consider a higher clockspeed, if possible"
+#define w_lowtime ((w1_nops + w_fixedlow) * 1000000) / (F_CPU / 1000)
+#if w_lowtime > 550
+# error "Light_ws2812: Sorry, the clock speed is too low. Did you set F_CPU correctly?"
+#elif w_lowtime > 450
+# warning "Light_ws2812: The timing is critical and may only work on WS2812B, not on WS2812(S)."
+# warning "Please consider a higher clockspeed, if possible"
#endif
-#if w2>0
-#define w2_nops w2
+#if w2 > 0
+# define w2_nops w2
#else
-#define w2_nops 0
+# define w2_nops 0
#endif
-#if w3>0
-#define w3_nops w3
+#if w3 > 0
+# define w3_nops w3
#else
-#define w3_nops 0
+# define w3_nops 0
#endif
-#define w_nop1 "nop \n\t"
-#define w_nop2 "rjmp .+0 \n\t"
-#define w_nop4 w_nop2 w_nop2
-#define w_nop8 w_nop4 w_nop4
+#define w_nop1 "nop \n\t"
+#define w_nop2 "rjmp .+0 \n\t"
+#define w_nop4 w_nop2 w_nop2
+#define w_nop8 w_nop4 w_nop4
#define w_nop16 w_nop8 w_nop8
-void inline ws2812_sendarray_mask(uint8_t *data,uint16_t datlen,uint8_t maskhi)
-{
- uint8_t curbyte,ctr,masklo;
- uint8_t sreg_prev;
-
- // masklo =~maskhi&ws2812_PORTREG;
- // maskhi |= ws2812_PORTREG;
- masklo =~maskhi&_SFR_IO8((RGB_DI_PIN >> 4) + 2);
- maskhi |= _SFR_IO8((RGB_DI_PIN >> 4) + 2);
- sreg_prev=SREG;
- cli();
-
- while (datlen--) {
- curbyte=(*data++);
-
- asm volatile(
- " ldi %0,8 \n\t"
- "loop%=: \n\t"
- " out %2,%3 \n\t" // '1' [01] '0' [01] - re
-#if (w1_nops&1)
-w_nop1
+void inline ws2812_sendarray_mask(uint8_t *data, uint16_t datlen, uint8_t maskhi) {
+ uint8_t curbyte, ctr, masklo;
+ uint8_t sreg_prev;
+
+ // masklo =~maskhi&ws2812_PORTREG;
+ // maskhi |= ws2812_PORTREG;
+ masklo = ~maskhi & _SFR_IO8((RGB_DI_PIN >> 4) + 2);
+ maskhi |= _SFR_IO8((RGB_DI_PIN >> 4) + 2);
+ sreg_prev = SREG;
+ cli();
+
+ while (datlen--) {
+ curbyte = (*data++);
+
+ asm volatile(" ldi %0,8 \n\t"
+ "loop%=: \n\t"
+ " out %2,%3 \n\t" // '1' [01] '0' [01] - re
+#if (w1_nops & 1)
+ w_nop1
#endif
-#if (w1_nops&2)
-w_nop2
+#if (w1_nops & 2)
+ w_nop2
#endif
-#if (w1_nops&4)
-w_nop4
+#if (w1_nops & 4)
+ w_nop4
#endif
-#if (w1_nops&8)
-w_nop8
+#if (w1_nops & 8)
+ w_nop8
#endif
-#if (w1_nops&16)
-w_nop16
+#if (w1_nops & 16)
+ w_nop16
#endif
- " sbrs %1,7 \n\t" // '1' [03] '0' [02]
- " out %2,%4 \n\t" // '1' [--] '0' [03] - fe-low
- " lsl %1 \n\t" // '1' [04] '0' [04]
-#if (w2_nops&1)
- w_nop1
+ " sbrs %1,7 \n\t" // '1' [03] '0' [02]
+ " out %2,%4 \n\t" // '1' [--] '0' [03] - fe-low
+ " lsl %1 \n\t" // '1' [04] '0' [04]
+#if (w2_nops & 1)
+ w_nop1
#endif
-#if (w2_nops&2)
- w_nop2
+#if (w2_nops & 2)
+ w_nop2
#endif
-#if (w2_nops&4)
- w_nop4
+#if (w2_nops & 4)
+ w_nop4
#endif
-#if (w2_nops&8)
- w_nop8
+#if (w2_nops & 8)
+ w_nop8
#endif
-#if (w2_nops&16)
- w_nop16
+#if (w2_nops & 16)
+ w_nop16
#endif
- " out %2,%4 \n\t" // '1' [+1] '0' [+1] - fe-high
-#if (w3_nops&1)
-w_nop1
+ " out %2,%4 \n\t" // '1' [+1] '0' [+1] - fe-high
+#if (w3_nops & 1)
+ w_nop1
#endif
-#if (w3_nops&2)
-w_nop2
+#if (w3_nops & 2)
+ w_nop2
#endif
-#if (w3_nops&4)
-w_nop4
+#if (w3_nops & 4)
+ w_nop4
#endif
-#if (w3_nops&8)
-w_nop8
+#if (w3_nops & 8)
+ w_nop8
#endif
-#if (w3_nops&16)
-w_nop16
+#if (w3_nops & 16)
+ w_nop16
#endif
- " dec %0 \n\t" // '1' [+2] '0' [+2]
- " brne loop%=\n\t" // '1' [+3] '0' [+4]
- : "=&d" (ctr)
- : "r" (curbyte), "I" (_SFR_IO_ADDR(_SFR_IO8((RGB_DI_PIN >> 4) + 2))), "r" (maskhi), "r" (masklo)
- );
- }
+ " dec %0 \n\t" // '1' [+2] '0' [+2]
+ " brne loop%=\n\t" // '1' [+3] '0' [+4]
+ : "=&d"(ctr)
+ : "r"(curbyte), "I"(_SFR_IO_ADDR(_SFR_IO8((RGB_DI_PIN >> 4) + 2))), "r"(maskhi), "r"(masklo));
+ }
- SREG=sreg_prev;
+ SREG = sreg_prev;
}
diff --git a/drivers/avr/ws2812.h b/drivers/avr/ws2812.h
index 95f540b184..a9dd897185 100644
--- a/drivers/avr/ws2812.h
+++ b/drivers/avr/ws2812.h
@@ -43,12 +43,12 @@
* - Wait 50�s to reset the LEDs
*/
#ifdef RGB_MATRIX_ENABLE
-void ws2812_setled (int index, uint8_t r, uint8_t g, uint8_t b);
-void ws2812_setled_all (uint8_t r, uint8_t g, uint8_t b);
+void ws2812_setled(int index, uint8_t r, uint8_t g, uint8_t b);
+void ws2812_setled_all(uint8_t r, uint8_t g, uint8_t b);
#endif
-void ws2812_setleds (LED_TYPE *ledarray, uint16_t number_of_leds);
-void ws2812_setleds_pin (LED_TYPE *ledarray, uint16_t number_of_leds,uint8_t pinmask);
+void ws2812_setleds(LED_TYPE *ledarray, uint16_t number_of_leds);
+void ws2812_setleds_pin(LED_TYPE *ledarray, uint16_t number_of_leds, uint8_t pinmask);
void ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t number_of_leds);
/*
@@ -58,18 +58,17 @@ void ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t number_of_leds);
* The length is the number of bytes to send - three per LED.
*/
-void ws2812_sendarray (uint8_t *array,uint16_t length);
-void ws2812_sendarray_mask(uint8_t *array,uint16_t length, uint8_t pinmask);
-
+void ws2812_sendarray(uint8_t *array, uint16_t length);
+void ws2812_sendarray_mask(uint8_t *array, uint16_t length, uint8_t pinmask);
/*
* Internal defines
*/
#ifndef CONCAT
-#define CONCAT(a, b) a ## b
+# define CONCAT(a, b) a##b
#endif
#ifndef CONCAT_EXP
-#define CONCAT_EXP(a, b) CONCAT(a, b)
+# define CONCAT_EXP(a, b) CONCAT(a, b)
#endif
#endif /* LIGHT_WS2812_H_ */
diff --git a/drivers/boards/GENERIC_STM32_F303XC/board.c b/drivers/boards/GENERIC_STM32_F303XC/board.c
index 4331155df4..60c191d9b1 100644
--- a/drivers/boards/GENERIC_STM32_F303XC/board.c
+++ b/drivers/boards/GENERIC_STM32_F303XC/board.c
@@ -23,42 +23,33 @@
* This variable is used by the HAL when initializing the PAL driver.
*/
const PALConfig pal_default_config = {
-#if STM32_HAS_GPIOA
- {VAL_GPIOA_MODER, VAL_GPIOA_OTYPER, VAL_GPIOA_OSPEEDR, VAL_GPIOA_PUPDR,
- VAL_GPIOA_ODR, VAL_GPIOA_AFRL, VAL_GPIOA_AFRH},
-#endif
-#if STM32_HAS_GPIOB
- {VAL_GPIOB_MODER, VAL_GPIOB_OTYPER, VAL_GPIOB_OSPEEDR, VAL_GPIOB_PUPDR,
- VAL_GPIOB_ODR, VAL_GPIOB_AFRL, VAL_GPIOB_AFRH},
-#endif
-#if STM32_HAS_GPIOC
- {VAL_GPIOC_MODER, VAL_GPIOC_OTYPER, VAL_GPIOC_OSPEEDR, VAL_GPIOC_PUPDR,
- VAL_GPIOC_ODR, VAL_GPIOC_AFRL, VAL_GPIOC_AFRH},
-#endif
-#if STM32_HAS_GPIOD
- {VAL_GPIOD_MODER, VAL_GPIOD_OTYPER, VAL_GPIOD_OSPEEDR, VAL_GPIOD_PUPDR,
- VAL_GPIOD_ODR, VAL_GPIOD_AFRL, VAL_GPIOD_AFRH},
-#endif
-#if STM32_HAS_GPIOE
- {VAL_GPIOE_MODER, VAL_GPIOE_OTYPER, VAL_GPIOE_OSPEEDR, VAL_GPIOE_PUPDR,
- VAL_GPIOE_ODR, VAL_GPIOE_AFRL, VAL_GPIOE_AFRH},
-#endif
-#if STM32_HAS_GPIOF
- {VAL_GPIOF_MODER, VAL_GPIOF_OTYPER, VAL_GPIOF_OSPEEDR, VAL_GPIOF_PUPDR,
- VAL_GPIOF_ODR, VAL_GPIOF_AFRL, VAL_GPIOF_AFRH},
-#endif
-#if STM32_HAS_GPIOG
- {VAL_GPIOG_MODER, VAL_GPIOG_OTYPER, VAL_GPIOG_OSPEEDR, VAL_GPIOG_PUPDR,
- VAL_GPIOG_ODR, VAL_GPIOG_AFRL, VAL_GPIOG_AFRH},
-#endif
-#if STM32_HAS_GPIOH
- {VAL_GPIOH_MODER, VAL_GPIOH_OTYPER, VAL_GPIOH_OSPEEDR, VAL_GPIOH_PUPDR,
- VAL_GPIOH_ODR, VAL_GPIOH_AFRL, VAL_GPIOH_AFRH},
-#endif
-#if STM32_HAS_GPIOI
- {VAL_GPIOI_MODER, VAL_GPIOI_OTYPER, VAL_GPIOI_OSPEEDR, VAL_GPIOI_PUPDR,
- VAL_GPIOI_ODR, VAL_GPIOI_AFRL, VAL_GPIOI_AFRH}
-#endif
+# if STM32_HAS_GPIOA
+ {VAL_GPIOA_MODER, VAL_GPIOA_OTYPER, VAL_GPIOA_OSPEEDR, VAL_GPIOA_PUPDR, VAL_GPIOA_ODR, VAL_GPIOA_AFRL, VAL_GPIOA_AFRH},
+# endif
+# if STM32_HAS_GPIOB
+ {VAL_GPIOB_MODER, VAL_GPIOB_OTYPER, VAL_GPIOB_OSPEEDR, VAL_GPIOB_PUPDR, VAL_GPIOB_ODR, VAL_GPIOB_AFRL, VAL_GPIOB_AFRH},
+# endif
+# if STM32_HAS_GPIOC
+ {VAL_GPIOC_MODER, VAL_GPIOC_OTYPER, VAL_GPIOC_OSPEEDR, VAL_GPIOC_PUPDR, VAL_GPIOC_ODR, VAL_GPIOC_AFRL, VAL_GPIOC_AFRH},
+# endif
+# if STM32_HAS_GPIOD
+ {VAL_GPIOD_MODER, VAL_GPIOD_OTYPER, VAL_GPIOD_OSPEEDR, VAL_GPIOD_PUPDR, VAL_GPIOD_ODR, VAL_GPIOD_AFRL, VAL_GPIOD_AFRH},
+# endif
+# if STM32_HAS_GPIOE
+ {VAL_GPIOE_MODER, VAL_GPIOE_OTYPER, VAL_GPIOE_OSPEEDR, VAL_GPIOE_PUPDR, VAL_GPIOE_ODR, VAL_GPIOE_AFRL, VAL_GPIOE_AFRH},
+# endif
+# if STM32_HAS_GPIOF
+ {VAL_GPIOF_MODER, VAL_GPIOF_OTYPER, VAL_GPIOF_OSPEEDR, VAL_GPIOF_PUPDR, VAL_GPIOF_ODR, VAL_GPIOF_AFRL, VAL_GPIOF_AFRH},
+# endif
+# if STM32_HAS_GPIOG
+ {VAL_GPIOG_MODER, VAL_GPIOG_OTYPER, VAL_GPIOG_OSPEEDR, VAL_GPIOG_PUPDR, VAL_GPIOG_ODR, VAL_GPIOG_AFRL, VAL_GPIOG_AFRH},
+# endif
+# if STM32_HAS_GPIOH
+ {VAL_GPIOH_MODER, VAL_GPIOH_OTYPER, VAL_GPIOH_OSPEEDR, VAL_GPIOH_PUPDR, VAL_GPIOH_ODR, VAL_GPIOH_AFRL, VAL_GPIOH_AFRH},
+# endif
+# if STM32_HAS_GPIOI
+ {VAL_GPIOI_MODER, VAL_GPIOI_OTYPER, VAL_GPIOI_OSPEEDR, VAL_GPIOI_PUPDR, VAL_GPIOI_ODR, VAL_GPIOI_AFRL, VAL_GPIOI_AFRH}
+# endif
};
#endif
@@ -70,8 +61,8 @@ void enter_bootloader_mode_if_requested(void);
* and before any other initialization.
*/
void __early_init(void) {
- enter_bootloader_mode_if_requested();
- stm32_clock_init();
+ enter_bootloader_mode_if_requested();
+ stm32_clock_init();
}
#if HAL_USE_SDC || defined(__DOXYGEN__)
@@ -79,20 +70,18 @@ void __early_init(void) {
* @brief SDC card detection.
*/
bool sdc_lld_is_card_inserted(SDCDriver *sdcp) {
-
- (void)sdcp;
- /* TODO: Fill the implementation.*/
- return true;
+ (void)sdcp;
+ /* TODO: Fill the implementation.*/
+ return true;
}
/**
* @brief SDC card write protection detection.
*/
bool sdc_lld_is_write_protected(SDCDriver *sdcp) {
-
- (void)sdcp;
- /* TODO: Fill the implementation.*/
- return false;
+ (void)sdcp;
+ /* TODO: Fill the implementation.*/
+ return false;
}
#endif /* HAL_USE_SDC */
@@ -101,20 +90,18 @@ bool sdc_lld_is_write_protected(SDCDriver *sdcp) {
* @brief MMC_SPI card detection.
*/
bool mmc_lld_is_card_inserted(MMCDriver *mmcp) {
-
- (void)mmcp;
- /* TODO: Fill the implementation.*/
- return true;
+ (void)mmcp;
+ /* TODO: Fill the implementation.*/
+ return true;
}
/**
* @brief MMC_SPI card write protection detection.
*/
bool mmc_lld_is_write_protected(MMCDriver *mmcp) {
-
- (void)mmcp;
- /* TODO: Fill the implementation.*/
- return false;
+ (void)mmcp;
+ /* TODO: Fill the implementation.*/
+ return false;
}
#endif
@@ -122,5 +109,4 @@ bool mmc_lld_is_write_protected(MMCDriver *mmcp) {
* @brief Board-specific initialization code.
* @todo Add your board-specific code, if any.
*/
-void boardInit(void) {
-}
+void boardInit(void) {}
diff --git a/drivers/boards/GENERIC_STM32_F303XC/board.h b/drivers/boards/GENERIC_STM32_F303XC/board.h
index 11120dfd74..3579c82770 100644
--- a/drivers/boards/GENERIC_STM32_F303XC/board.h
+++ b/drivers/boards/GENERIC_STM32_F303XC/board.h
@@ -25,20 +25,20 @@
* Board identifier.
*/
#define BOARD_GENERIC_STM32_F303XC
-#define BOARD_NAME "STM32_F303"
+#define BOARD_NAME "STM32_F303"
/*
* Board oscillators-related settings.
* NOTE: LSE not fitted.
*/
#if !defined(STM32_LSECLK)
-#define STM32_LSECLK 0U
+# define STM32_LSECLK 0U
#endif
-#define STM32_LSEDRV (3U << 3U)
+#define STM32_LSEDRV (3U << 3U)
#if !defined(STM32_HSECLK)
-#define STM32_HSECLK 8000000U
+# define STM32_HSECLK 8000000U
#endif
// #define STM32_HSE_BYPASS
@@ -51,178 +51,177 @@
/*
* IO pins assignments.
*/
-#define GPIOA_PIN0 0U
-#define GPIOA_PIN1 1U
-#define GPIOA_PIN2 2U
-#define GPIOA_PIN3 3U
-#define GPIOA_PIN4 4U
-#define GPIOA_PIN5 5U
-#define GPIOA_PIN6 6U
-#define GPIOA_PIN7 7U
-#define GPIOA_PIN8 8U
-#define GPIOA_PIN9 9U
-#define GPIOA_PIN10 10U
-#define GPIOA_USB_DM 11U
-#define GPIOA_USB_DP 12U
-#define GPIOA_SWDIO 13U
-#define GPIOA_SWCLK 14U
-#define GPIOA_PIN15 15U
-
-#define GPIOB_PIN0 0U
-#define GPIOB_PIN1 1U
-#define GPIOB_PIN2 2U
-#define GPIOB_PIN3 3U
-#define GPIOB_PIN4 4U
-#define GPIOB_PIN5 5U
-#define GPIOB_PIN6 6U
-#define GPIOB_PIN7 7U
-#define GPIOB_PIN8 8U
-#define GPIOB_PIN9 9U
-#define GPIOB_PIN10 10U
-#define GPIOB_PIN11 11U
-#define GPIOB_PIN12 12U
-#define GPIOB_PIN13 13U
-#define GPIOB_PIN14 14U
-#define GPIOB_PIN15 15U
-
-#define GPIOC_PIN0 0U
-#define GPIOC_PIN1 1U
-#define GPIOC_PIN2 2U
-#define GPIOC_PIN3 3U
-#define GPIOC_PIN4 4U
-#define GPIOC_PIN5 5U
-#define GPIOC_PIN6 6U
-#define GPIOC_PIN7 7U
-#define GPIOC_PIN8 8U
-#define GPIOC_PIN9 9U
-#define GPIOC_PIN10 10U
-#define GPIOC_PIN11 11U
-#define GPIOC_PIN12 12U
-#define GPIOC_PIN13 13U
-#define GPIOC_PIN14 14U
-#define GPIOC_PIN15 15U
-
-#define GPIOD_PIN0 0U
-#define GPIOD_PIN1 1U
-#define GPIOD_PIN2 2U
-#define GPIOD_PIN3 3U
-#define GPIOD_PIN4 4U
-#define GPIOD_PIN5 5U
-#define GPIOD_PIN6 6U
-#define GPIOD_PIN7 7U
-#define GPIOD_PIN8 8U
-#define GPIOD_PIN9 9U
-#define GPIOD_PIN10 10U
-#define GPIOD_PIN11 11U
-#define GPIOD_PIN12 12U
-#define GPIOD_PIN13 13U
-#define GPIOD_PIN14 14U
-#define GPIOD_PIN15 15U
-
-#define GPIOE_PIN0 0U
-#define GPIOE_PIN1 1U
-#define GPIOE_PIN2 2U
-#define GPIOE_PIN3 3U
-#define GPIOE_PIN4 4U
-#define GPIOE_PIN5 5U
-#define GPIOE_PIN6 6U
-#define GPIOE_PIN7 7U
-#define GPIOE_PIN8 8U
-#define GPIOE_PIN9 9U
-#define GPIOE_PIN10 10U
-#define GPIOE_PIN11 11U
-#define GPIOE_PIN12 12U
-#define GPIOE_PIN13 13U
-#define GPIOE_PIN14 14U
-#define GPIOE_PIN15 15U
-
-#define GPIOF_I2C2_SDA 0U
-#define GPIOF_I2C2_SCL 1U
-#define GPIOF_PIN2 2U
-#define GPIOF_PIN3 3U
-#define GPIOF_PIN4 4U
-#define GPIOF_PIN5 5U
-#define GPIOF_PIN6 6U
-#define GPIOF_PIN7 7U
-#define GPIOF_PIN8 8U
-#define GPIOF_PIN9 9U
-#define GPIOF_PIN10 10U
-#define GPIOF_PIN11 11U
-#define GPIOF_PIN12 12U
-#define GPIOF_PIN13 13U
-#define GPIOF_PIN14 14U
-#define GPIOF_PIN15 15U
-
-#define GPIOG_PIN0 0U
-#define GPIOG_PIN1 1U
-#define GPIOG_PIN2 2U
-#define GPIOG_PIN3 3U
-#define GPIOG_PIN4 4U
-#define GPIOG_PIN5 5U
-#define GPIOG_PIN6 6U
-#define GPIOG_PIN7 7U
-#define GPIOG_PIN8 8U
-#define GPIOG_PIN9 9U
-#define GPIOG_PIN10 10U
-#define GPIOG_PIN11 11U
-#define GPIOG_PIN12 12U
-#define GPIOG_PIN13 13U
-#define GPIOG_PIN14 14U
-#define GPIOG_PIN15 15U
-
-#define GPIOH_PIN0 0U
-#define GPIOH_PIN1 1U
-#define GPIOH_PIN2 2U
-#define GPIOH_PIN3 3U
-#define GPIOH_PIN4 4U
-#define GPIOH_PIN5 5U
-#define GPIOH_PIN6 6U
-#define GPIOH_PIN7 7U
-#define GPIOH_PIN8 8U
-#define GPIOH_PIN9 9U
-#define GPIOH_PIN10 10U
-#define GPIOH_PIN11 11U
-#define GPIOH_PIN12 12U
-#define GPIOH_PIN13 13U
-#define GPIOH_PIN14 14U
-#define GPIOH_PIN15 15U
+#define GPIOA_PIN0 0U
+#define GPIOA_PIN1 1U
+#define GPIOA_PIN2 2U
+#define GPIOA_PIN3 3U
+#define GPIOA_PIN4 4U
+#define GPIOA_PIN5 5U
+#define GPIOA_PIN6 6U
+#define GPIOA_PIN7 7U
+#define GPIOA_PIN8 8U
+#define GPIOA_PIN9 9U
+#define GPIOA_PIN10 10U
+#define GPIOA_USB_DM 11U
+#define GPIOA_USB_DP 12U
+#define GPIOA_SWDIO 13U
+#define GPIOA_SWCLK 14U
+#define GPIOA_PIN15 15U
+
+#define GPIOB_PIN0 0U
+#define GPIOB_PIN1 1U
+#define GPIOB_PIN2 2U
+#define GPIOB_PIN3 3U
+#define GPIOB_PIN4 4U
+#define GPIOB_PIN5 5U
+#define GPIOB_PIN6 6U
+#define GPIOB_PIN7 7U
+#define GPIOB_PIN8 8U
+#define GPIOB_PIN9 9U
+#define GPIOB_PIN10 10U
+#define GPIOB_PIN11 11U
+#define GPIOB_PIN12 12U
+#define GPIOB_PIN13 13U
+#define GPIOB_PIN14 14U
+#define GPIOB_PIN15 15U
+
+#define GPIOC_PIN0 0U
+#define GPIOC_PIN1 1U
+#define GPIOC_PIN2 2U
+#define GPIOC_PIN3 3U
+#define GPIOC_PIN4 4U
+#define GPIOC_PIN5 5U
+#define GPIOC_PIN6 6U
+#define GPIOC_PIN7 7U
+#define GPIOC_PIN8 8U
+#define GPIOC_PIN9 9U
+#define GPIOC_PIN10 10U
+#define GPIOC_PIN11 11U
+#define GPIOC_PIN12 12U
+#define GPIOC_PIN13 13U
+#define GPIOC_PIN14 14U
+#define GPIOC_PIN15 15U
+
+#define GPIOD_PIN0 0U
+#define GPIOD_PIN1 1U
+#define GPIOD_PIN2 2U
+#define GPIOD_PIN3 3U
+#define GPIOD_PIN4 4U
+#define GPIOD_PIN5 5U
+#define GPIOD_PIN6 6U
+#define GPIOD_PIN7 7U
+#define GPIOD_PIN8 8U
+#define GPIOD_PIN9 9U
+#define GPIOD_PIN10 10U
+#define GPIOD_PIN11 11U
+#define GPIOD_PIN12 12U
+#define GPIOD_PIN13 13U
+#define GPIOD_PIN14 14U
+#define GPIOD_PIN15 15U
+
+#define GPIOE_PIN0 0U
+#define GPIOE_PIN1 1U
+#define GPIOE_PIN2 2U
+#define GPIOE_PIN3 3U
+#define GPIOE_PIN4 4U
+#define GPIOE_PIN5 5U
+#define GPIOE_PIN6 6U
+#define GPIOE_PIN7 7U
+#define GPIOE_PIN8 8U
+#define GPIOE_PIN9 9U
+#define GPIOE_PIN10 10U
+#define GPIOE_PIN11 11U
+#define GPIOE_PIN12 12U
+#define GPIOE_PIN13 13U
+#define GPIOE_PIN14 14U
+#define GPIOE_PIN15 15U
+
+#define GPIOF_I2C2_SDA 0U
+#define GPIOF_I2C2_SCL 1U
+#define GPIOF_PIN2 2U
+#define GPIOF_PIN3 3U
+#define GPIOF_PIN4 4U
+#define GPIOF_PIN5 5U
+#define GPIOF_PIN6 6U
+#define GPIOF_PIN7 7U
+#define GPIOF_PIN8 8U
+#define GPIOF_PIN9 9U
+#define GPIOF_PIN10 10U
+#define GPIOF_PIN11 11U
+#define GPIOF_PIN12 12U
+#define GPIOF_PIN13 13U
+#define GPIOF_PIN14 14U
+#define GPIOF_PIN15 15U
+
+#define GPIOG_PIN0 0U
+#define GPIOG_PIN1 1U
+#define GPIOG_PIN2 2U
+#define GPIOG_PIN3 3U
+#define GPIOG_PIN4 4U
+#define GPIOG_PIN5 5U
+#define GPIOG_PIN6 6U
+#define GPIOG_PIN7 7U
+#define GPIOG_PIN8 8U
+#define GPIOG_PIN9 9U
+#define GPIOG_PIN10 10U
+#define GPIOG_PIN11 11U
+#define GPIOG_PIN12 12U
+#define GPIOG_PIN13 13U
+#define GPIOG_PIN14 14U
+#define GPIOG_PIN15 15U
+
+#define GPIOH_PIN0 0U
+#define GPIOH_PIN1 1U
+#define GPIOH_PIN2 2U
+#define GPIOH_PIN3 3U
+#define GPIOH_PIN4 4U
+#define GPIOH_PIN5 5U
+#define GPIOH_PIN6 6U
+#define GPIOH_PIN7 7U
+#define GPIOH_PIN8 8U
+#define GPIOH_PIN9 9U
+#define GPIOH_PIN10 10U
+#define GPIOH_PIN11 11U
+#define GPIOH_PIN12 12U
+#define GPIOH_PIN13 13U
+#define GPIOH_PIN14 14U
+#define GPIOH_PIN15 15U
/*
* IO lines assignments.
*/
-#define LINE_L3GD20_SDI PAL_LINE(GPIOA, 7U)
-#define LINE_USB_DM PAL_LINE(GPIOA, 11U)
-#define LINE_USB_DP PAL_LINE(GPIOA, 12U)
-#define LINE_SWDIO PAL_LINE(GPIOA, 13U)
-#define LINE_SWCLK PAL_LINE(GPIOA, 14U)
-
-#define LINE_PIN6 PAL_LINE(GPIOF, 0U)
-#define LINE_PIN7 PAL_LINE(GPIOF, 1U)
+#define LINE_L3GD20_SDI PAL_LINE(GPIOA, 7U)
+#define LINE_USB_DM PAL_LINE(GPIOA, 11U)
+#define LINE_USB_DP PAL_LINE(GPIOA, 12U)
+#define LINE_SWDIO PAL_LINE(GPIOA, 13U)
+#define LINE_SWCLK PAL_LINE(GPIOA, 14U)
-#define LINE_CAPS_LOCK PAL_LINE(GPIOB, 7U)
+#define LINE_PIN6 PAL_LINE(GPIOF, 0U)
+#define LINE_PIN7 PAL_LINE(GPIOF, 1U)
+#define LINE_CAPS_LOCK PAL_LINE(GPIOB, 7U)
/*
* I/O ports initial setup, this configuration is established soon after reset
* in the initialization code.
* Please refer to the STM32 Reference Manual for details.
*/
-#define PIN_MODE_INPUT(n) (0U << ((n) * 2U))
-#define PIN_MODE_OUTPUT(n) (1U << ((n) * 2U))
-#define PIN_MODE_ALTERNATE(n) (2U << ((n) * 2U))
-#define PIN_MODE_ANALOG(n) (3U << ((n) * 2U))
-#define PIN_ODR_LOW(n) (0U << (n))
-#define PIN_ODR_HIGH(n) (1U << (n))
-#define PIN_OTYPE_PUSHPULL(n) (0U << (n))
-#define PIN_OTYPE_OPENDRAIN(n) (1U << (n))
-#define PIN_OSPEED_VERYLOW(n) (0U << ((n) * 2U))
-#define PIN_OSPEED_LOW(n) (1U << ((n) * 2U))
-#define PIN_OSPEED_MEDIUM(n) (2U << ((n) * 2U))
-#define PIN_OSPEED_HIGH(n) (3U << ((n) * 2U))
-#define PIN_PUPDR_FLOATING(n) (0U << ((n) * 2U))
-#define PIN_PUPDR_PULLUP(n) (1U << ((n) * 2U))
-#define PIN_PUPDR_PULLDOWN(n) (2U << ((n) * 2U))
-#define PIN_AFIO_AF(n, v) ((v) << (((n) % 8U) * 4U))
+#define PIN_MODE_INPUT(n) (0U << ((n)*2U))
+#define PIN_MODE_OUTPUT(n) (1U << ((n)*2U))
+#define PIN_MODE_ALTERNATE(n) (2U << ((n)*2U))
+#define PIN_MODE_ANALOG(n) (3U << ((n)*2U))
+#define PIN_ODR_LOW(n) (0U << (n))
+#define PIN_ODR_HIGH(n) (1U << (n))
+#define PIN_OTYPE_PUSHPULL(n) (0U << (n))
+#define PIN_OTYPE_OPENDRAIN(n) (1U << (n))
+#define PIN_OSPEED_VERYLOW(n) (0U << ((n)*2U))
+#define PIN_OSPEED_LOW(n) (1U << ((n)*2U))
+#define PIN_OSPEED_MEDIUM(n) (2U << ((n)*2U))
+#define PIN_OSPEED_HIGH(n) (3U << ((n)*2U))
+#define PIN_PUPDR_FLOATING(n) (0U << ((n)*2U))
+#define PIN_PUPDR_PULLUP(n) (1U << ((n)*2U))
+#define PIN_PUPDR_PULLDOWN(n) (2U << ((n)*2U))
+#define PIN_AFIO_AF(n, v) ((v) << (((n) % 8U) * 4U))
/*
* GPIOA setup:
@@ -244,102 +243,13 @@
* PA14 - SWCLK (alternate 0).
* PA15 - ROW4
*/
-#define VAL_GPIOA_MODER (PIN_MODE_INPUT(GPIOA_PIN0) | \
- PIN_MODE_ALTERNATE(GPIOA_PIN1) | \
- PIN_MODE_INPUT(GPIOA_PIN2) | \
- PIN_MODE_INPUT(GPIOA_PIN3) | \
- PIN_MODE_INPUT(GPIOA_PIN4) | \
- PIN_MODE_INPUT(GPIOA_PIN5) | \
- PIN_MODE_INPUT(GPIOA_PIN6) | \
- PIN_MODE_INPUT(GPIOA_PIN7) | \
- PIN_MODE_INPUT(GPIOA_PIN8) | \
- PIN_MODE_INPUT(GPIOA_PIN9) | \
- PIN_MODE_INPUT(GPIOA_PIN10) | \
- PIN_MODE_ALTERNATE(GPIOA_USB_DM) | \
- PIN_MODE_ALTERNATE(GPIOA_USB_DP) | \
- PIN_MODE_ALTERNATE(GPIOA_SWDIO) | \
- PIN_MODE_ALTERNATE(GPIOA_SWCLK) | \
- PIN_MODE_INPUT(GPIOA_PIN15))
-#define VAL_GPIOA_OTYPER (PIN_OTYPE_PUSHPULL(GPIOA_PIN0) | \
- PIN_OTYPE_PUSHPULL(GPIOA_PIN1) | \
- PIN_OTYPE_PUSHPULL(GPIOA_PIN2) | \
- PIN_OTYPE_PUSHPULL(GPIOA_PIN3) | \
- PIN_OTYPE_PUSHPULL(GPIOA_PIN4) | \
- PIN_OTYPE_PUSHPULL(GPIOA_PIN5) | \
- PIN_OTYPE_PUSHPULL(GPIOA_PIN6) | \
- PIN_OTYPE_PUSHPULL(GPIOA_PIN7) | \
- PIN_OTYPE_PUSHPULL(GPIOA_PIN8) | \
- PIN_OTYPE_PUSHPULL(GPIOA_PIN9) | \
- PIN_OTYPE_PUSHPULL(GPIOA_PIN10) | \
- PIN_OTYPE_PUSHPULL(GPIOA_USB_DM) | \
- PIN_OTYPE_PUSHPULL(GPIOA_USB_DP) | \
- PIN_OTYPE_PUSHPULL(GPIOA_SWDIO) | \
- PIN_OTYPE_PUSHPULL(GPIOA_SWCLK) | \
- PIN_OTYPE_PUSHPULL(GPIOA_PIN15))
-#define VAL_GPIOA_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOA_PIN0) | \
- PIN_OSPEED_HIGH(GPIOA_PIN1) | \
- PIN_OSPEED_VERYLOW(GPIOA_PIN2) | \
- PIN_OSPEED_VERYLOW(GPIOA_PIN3) | \
- PIN_OSPEED_VERYLOW(GPIOA_PIN4) | \
- PIN_OSPEED_VERYLOW(GPIOA_PIN5) | \
- PIN_OSPEED_VERYLOW(GPIOA_PIN6) | \
- PIN_OSPEED_VERYLOW(GPIOA_PIN7) | \
- PIN_OSPEED_VERYLOW(GPIOA_PIN8) | \
- PIN_OSPEED_VERYLOW(GPIOA_PIN9) | \
- PIN_OSPEED_VERYLOW(GPIOA_PIN10) | \
- PIN_OSPEED_HIGH(GPIOA_USB_DM) | \
- PIN_OSPEED_VERYLOW(GPIOA_USB_DP) | \
- PIN_OSPEED_HIGH(GPIOA_SWDIO) | \
- PIN_OSPEED_HIGH(GPIOA_SWCLK) | \
- PIN_OSPEED_VERYLOW(GPIOA_PIN15))
-#define VAL_GPIOA_PUPDR (PIN_PUPDR_FLOATING(GPIOA_PIN0) | \
- PIN_PUPDR_FLOATING(GPIOA_PIN1) | \
- PIN_PUPDR_PULLUP(GPIOA_PIN2) | \
- PIN_PUPDR_PULLUP(GPIOA_PIN3) | \
- PIN_PUPDR_PULLUP(GPIOA_PIN4) | \
- PIN_PUPDR_PULLUP(GPIOA_PIN5) | \
- PIN_PUPDR_PULLUP(GPIOA_PIN6) | \
- PIN_PUPDR_FLOATING(GPIOA_PIN7) | \
- PIN_PUPDR_PULLUP(GPIOA_PIN8) | \
- PIN_PUPDR_PULLUP(GPIOA_PIN9) | \
- PIN_PUPDR_PULLUP(GPIOA_PIN10) | \
- PIN_PUPDR_FLOATING(GPIOA_USB_DM) | \
- PIN_PUPDR_FLOATING(GPIOA_USB_DP) | \
- PIN_PUPDR_PULLUP(GPIOA_SWDIO) | \
- PIN_PUPDR_PULLDOWN(GPIOA_SWCLK) | \
- PIN_PUPDR_PULLUP(GPIOA_PIN15))
-#define VAL_GPIOA_ODR (PIN_ODR_HIGH(GPIOA_PIN0) | \
- PIN_ODR_HIGH(GPIOA_PIN1) | \
- PIN_ODR_HIGH(GPIOA_PIN2) | \
- PIN_ODR_HIGH(GPIOA_PIN3) | \
- PIN_ODR_HIGH(GPIOA_PIN4) | \
- PIN_ODR_HIGH(GPIOA_PIN5) | \
- PIN_ODR_HIGH(GPIOA_PIN6) | \
- PIN_ODR_HIGH(GPIOA_PIN7) | \
- PIN_ODR_HIGH(GPIOA_PIN8) | \
- PIN_ODR_HIGH(GPIOA_PIN9) | \
- PIN_ODR_HIGH(GPIOA_PIN10) | \
- PIN_ODR_HIGH(GPIOA_USB_DM) | \
- PIN_ODR_HIGH(GPIOA_USB_DP) | \
- PIN_ODR_HIGH(GPIOA_SWDIO) | \
- PIN_ODR_HIGH(GPIOA_SWCLK) | \
- PIN_ODR_HIGH(GPIOA_PIN15))
-#define VAL_GPIOA_AFRL (PIN_AFIO_AF(GPIOA_PIN0, 0) | \
- PIN_AFIO_AF(GPIOA_PIN1, 1) | \
- PIN_AFIO_AF(GPIOA_PIN2, 0) | \
- PIN_AFIO_AF(GPIOA_PIN3, 0) | \
- PIN_AFIO_AF(GPIOA_PIN4, 0) | \
- PIN_AFIO_AF(GPIOA_PIN5, 5) | \
- PIN_AFIO_AF(GPIOA_PIN6, 5) | \
- PIN_AFIO_AF(GPIOA_PIN7, 5))
-#define VAL_GPIOA_AFRH (PIN_AFIO_AF(GPIOA_PIN8, 0) | \
- PIN_AFIO_AF(GPIOA_PIN9, 0) | \
- PIN_AFIO_AF(GPIOA_PIN10, 0) | \
- PIN_AFIO_AF(GPIOA_USB_DM, 14) | \
- PIN_AFIO_AF(GPIOA_USB_DP, 14) | \
- PIN_AFIO_AF(GPIOA_SWDIO, 0) | \
- PIN_AFIO_AF(GPIOA_SWCLK, 0) | \
- PIN_AFIO_AF(GPIOA_PIN15, 0))
+#define VAL_GPIOA_MODER (PIN_MODE_INPUT(GPIOA_PIN0) | PIN_MODE_ALTERNATE(GPIOA_PIN1) | PIN_MODE_INPUT(GPIOA_PIN2) | PIN_MODE_INPUT(GPIOA_PIN3) | PIN_MODE_INPUT(GPIOA_PIN4) | PIN_MODE_INPUT(GPIOA_PIN5) | PIN_MODE_INPUT(GPIOA_PIN6) | PIN_MODE_INPUT(GPIOA_PIN7) | PIN_MODE_INPUT(GPIOA_PIN8) | PIN_MODE_INPUT(GPIOA_PIN9) | PIN_MODE_INPUT(GPIOA_PIN10) | PIN_MODE_ALTERNATE(GPIOA_USB_DM) | PIN_MODE_ALTERNATE(GPIOA_USB_DP) | PIN_MODE_ALTERNATE(GPIOA_SWDIO) | PIN_MODE_ALTERNATE(GPIOA_SWCLK) | PIN_MODE_INPUT(GPIOA_PIN15))
+#define VAL_GPIOA_OTYPER (PIN_OTYPE_PUSHPULL(GPIOA_PIN0) | PIN_OTYPE_PUSHPULL(GPIOA_PIN1) | PIN_OTYPE_PUSHPULL(GPIOA_PIN2) | PIN_OTYPE_PUSHPULL(GPIOA_PIN3) | PIN_OTYPE_PUSHPULL(GPIOA_PIN4) | PIN_OTYPE_PUSHPULL(GPIOA_PIN5) | PIN_OTYPE_PUSHPULL(GPIOA_PIN6) | PIN_OTYPE_PUSHPULL(GPIOA_PIN7) | PIN_OTYPE_PUSHPULL(GPIOA_PIN8) | PIN_OTYPE_PUSHPULL(GPIOA_PIN9) | PIN_OTYPE_PUSHPULL(GPIOA_PIN10) | PIN_OTYPE_PUSHPULL(GPIOA_USB_DM) | PIN_OTYPE_PUSHPULL(GPIOA_USB_DP) | PIN_OTYPE_PUSHPULL(GPIOA_SWDIO) | PIN_OTYPE_PUSHPULL(GPIOA_SWCLK) | PIN_OTYPE_PUSHPULL(GPIOA_PIN15))
+#define VAL_GPIOA_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOA_PIN0) | PIN_OSPEED_HIGH(GPIOA_PIN1) | PIN_OSPEED_VERYLOW(GPIOA_PIN2) | PIN_OSPEED_VERYLOW(GPIOA_PIN3) | PIN_OSPEED_VERYLOW(GPIOA_PIN4) | PIN_OSPEED_VERYLOW(GPIOA_PIN5) | PIN_OSPEED_VERYLOW(GPIOA_PIN6) | PIN_OSPEED_VERYLOW(GPIOA_PIN7) | PIN_OSPEED_VERYLOW(GPIOA_PIN8) | PIN_OSPEED_VERYLOW(GPIOA_PIN9) | PIN_OSPEED_VERYLOW(GPIOA_PIN10) | PIN_OSPEED_HIGH(GPIOA_USB_DM) | PIN_OSPEED_VERYLOW(GPIOA_USB_DP) | PIN_OSPEED_HIGH(GPIOA_SWDIO) | PIN_OSPEED_HIGH(GPIOA_SWCLK) | PIN_OSPEED_VERYLOW(GPIOA_PIN15))
+#define VAL_GPIOA_PUPDR (PIN_PUPDR_FLOATING(GPIOA_PIN0) | PIN_PUPDR_FLOATING(GPIOA_PIN1) | PIN_PUPDR_PULLUP(GPIOA_PIN2) | PIN_PUPDR_PULLUP(GPIOA_PIN3) | PIN_PUPDR_PULLUP(GPIOA_PIN4) | PIN_PUPDR_PULLUP(GPIOA_PIN5) | PIN_PUPDR_PULLUP(GPIOA_PIN6) | PIN_PUPDR_FLOATING(GPIOA_PIN7) | PIN_PUPDR_PULLUP(GPIOA_PIN8) | PIN_PUPDR_PULLUP(GPIOA_PIN9) | PIN_PUPDR_PULLUP(GPIOA_PIN10) | PIN_PUPDR_FLOATING(GPIOA_USB_DM) | PIN_PUPDR_FLOATING(GPIOA_USB_DP) | PIN_PUPDR_PULLUP(GPIOA_SWDIO) | PIN_PUPDR_PULLDOWN(GPIOA_SWCLK) | PIN_PUPDR_PULLUP(GPIOA_PIN15))
+#define VAL_GPIOA_ODR (PIN_ODR_HIGH(GPIOA_PIN0) | PIN_ODR_HIGH(GPIOA_PIN1) | PIN_ODR_HIGH(GPIOA_PIN2) | PIN_ODR_HIGH(GPIOA_PIN3) | PIN_ODR_HIGH(GPIOA_PIN4) | PIN_ODR_HIGH(GPIOA_PIN5) | PIN_ODR_HIGH(GPIOA_PIN6) | PIN_ODR_HIGH(GPIOA_PIN7) | PIN_ODR_HIGH(GPIOA_PIN8) | PIN_ODR_HIGH(GPIOA_PIN9) | PIN_ODR_HIGH(GPIOA_PIN10) | PIN_ODR_HIGH(GPIOA_USB_DM) | PIN_ODR_HIGH(GPIOA_USB_DP) | PIN_ODR_HIGH(GPIOA_SWDIO) | PIN_ODR_HIGH(GPIOA_SWCLK) | PIN_ODR_HIGH(GPIOA_PIN15))
+#define VAL_GPIOA_AFRL (PIN_AFIO_AF(GPIOA_PIN0, 0) | PIN_AFIO_AF(GPIOA_PIN1, 1) | PIN_AFIO_AF(GPIOA_PIN2, 0) | PIN_AFIO_AF(GPIOA_PIN3, 0) | PIN_AFIO_AF(GPIOA_PIN4, 0) | PIN_AFIO_AF(GPIOA_PIN5, 5) | PIN_AFIO_AF(GPIOA_PIN6, 5) | PIN_AFIO_AF(GPIOA_PIN7, 5))
+#define VAL_GPIOA_AFRH (PIN_AFIO_AF(GPIOA_PIN8, 0) | PIN_AFIO_AF(GPIOA_PIN9, 0) | PIN_AFIO_AF(GPIOA_PIN10, 0) | PIN_AFIO_AF(GPIOA_USB_DM, 14) | PIN_AFIO_AF(GPIOA_USB_DP, 14) | PIN_AFIO_AF(GPIOA_SWDIO, 0) | PIN_AFIO_AF(GPIOA_SWCLK, 0) | PIN_AFIO_AF(GPIOA_PIN15, 0))
/*
* GPIOB setup:
@@ -361,102 +271,13 @@
* PB14 - PIN14 (input pullup).
* PB15 - PIN15 (input pullup).
*/
-#define VAL_GPIOB_MODER (PIN_MODE_INPUT(GPIOB_PIN0) | \
- PIN_MODE_INPUT(GPIOB_PIN1) | \
- PIN_MODE_INPUT(GPIOB_PIN2) | \
- PIN_MODE_ALTERNATE(GPIOB_PIN3) | \
- PIN_MODE_INPUT(GPIOB_PIN4) | \
- PIN_MODE_INPUT(GPIOB_PIN5) | \
- PIN_MODE_ALTERNATE(GPIOB_PIN6) | \
- PIN_MODE_OUTPUT(GPIOB_PIN7) | \
- PIN_MODE_INPUT(GPIOB_PIN8) | \
- PIN_MODE_INPUT(GPIOB_PIN9) | \
- PIN_MODE_INPUT(GPIOB_PIN10) | \
- PIN_MODE_INPUT(GPIOB_PIN11) | \
- PIN_MODE_INPUT(GPIOB_PIN12) | \
- PIN_MODE_INPUT(GPIOB_PIN13) | \
- PIN_MODE_INPUT(GPIOB_PIN14) | \
- PIN_MODE_INPUT(GPIOB_PIN15))
-#define VAL_GPIOB_OTYPER (PIN_OTYPE_PUSHPULL(GPIOB_PIN0) | \
- PIN_OTYPE_PUSHPULL(GPIOB_PIN1) | \
- PIN_OTYPE_PUSHPULL(GPIOB_PIN2) | \
- PIN_OTYPE_PUSHPULL(GPIOB_PIN3) | \
- PIN_OTYPE_PUSHPULL(GPIOB_PIN4) | \
- PIN_OTYPE_PUSHPULL(GPIOB_PIN5) | \
- PIN_OTYPE_OPENDRAIN(GPIOB_PIN6) | \
- PIN_OTYPE_PUSHPULL(GPIOB_PIN7) | \
- PIN_OTYPE_PUSHPULL(GPIOB_PIN8) | \
- PIN_OTYPE_PUSHPULL(GPIOB_PIN9) | \
- PIN_OTYPE_PUSHPULL(GPIOB_PIN10) | \
- PIN_OTYPE_PUSHPULL(GPIOB_PIN11) | \
- PIN_OTYPE_PUSHPULL(GPIOB_PIN12) | \
- PIN_OTYPE_PUSHPULL(GPIOB_PIN13) | \
- PIN_OTYPE_PUSHPULL(GPIOB_PIN14) | \
- PIN_OTYPE_PUSHPULL(GPIOB_PIN15))
-#define VAL_GPIOB_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOB_PIN0) | \
- PIN_OSPEED_VERYLOW(GPIOB_PIN1) | \
- PIN_OSPEED_VERYLOW(GPIOB_PIN2) | \
- PIN_OSPEED_HIGH(GPIOB_PIN3) | \
- PIN_OSPEED_VERYLOW(GPIOB_PIN4) | \
- PIN_OSPEED_VERYLOW(GPIOB_PIN5) | \
- PIN_OSPEED_HIGH(GPIOB_PIN6) | \
- PIN_OSPEED_VERYLOW(GPIOB_PIN7) | \
- PIN_OSPEED_VERYLOW(GPIOB_PIN8) | \
- PIN_OSPEED_VERYLOW(GPIOB_PIN9) | \
- PIN_OSPEED_VERYLOW(GPIOB_PIN10) | \
- PIN_OSPEED_VERYLOW(GPIOB_PIN11) | \
- PIN_OSPEED_VERYLOW(GPIOB_PIN12) | \
- PIN_OSPEED_VERYLOW(GPIOB_PIN13) | \
- PIN_OSPEED_VERYLOW(GPIOB_PIN14) | \
- PIN_OSPEED_VERYLOW(GPIOB_PIN15))
-#define VAL_GPIOB_PUPDR (PIN_PUPDR_PULLUP(GPIOB_PIN0) | \
- PIN_PUPDR_PULLUP(GPIOB_PIN1) | \
- PIN_PUPDR_PULLUP(GPIOB_PIN2) | \
- PIN_PUPDR_FLOATING(GPIOB_PIN3) | \
- PIN_PUPDR_PULLUP(GPIOB_PIN4) | \
- PIN_PUPDR_PULLUP(GPIOB_PIN5) | \
- PIN_PUPDR_FLOATING(GPIOB_PIN6) | \
- PIN_PUPDR_PULLDOWN(GPIOB_PIN7) | \
- PIN_PUPDR_PULLUP(GPIOB_PIN8) | \
- PIN_PUPDR_PULLUP(GPIOB_PIN9) | \
- PIN_PUPDR_PULLUP(GPIOB_PIN10) | \
- PIN_PUPDR_PULLUP(GPIOB_PIN11) | \
- PIN_PUPDR_PULLUP(GPIOB_PIN12) | \
- PIN_PUPDR_PULLUP(GPIOB_PIN13) | \
- PIN_PUPDR_PULLUP(GPIOB_PIN14) | \
- PIN_PUPDR_PULLUP(GPIOB_PIN15))
-#define VAL_GPIOB_ODR (PIN_ODR_HIGH(GPIOB_PIN0) | \
- PIN_ODR_HIGH(GPIOB_PIN1) | \
- PIN_ODR_HIGH(GPIOB_PIN2) | \
- PIN_ODR_HIGH(GPIOB_PIN3) | \
- PIN_ODR_HIGH(GPIOB_PIN4) | \
- PIN_ODR_HIGH(GPIOB_PIN5) | \
- PIN_ODR_HIGH(GPIOB_PIN6) | \
- PIN_ODR_LOW(GPIOB_PIN7) | \
- PIN_ODR_HIGH(GPIOB_PIN8) | \
- PIN_ODR_HIGH(GPIOB_PIN9) | \
- PIN_ODR_HIGH(GPIOB_PIN10) | \
- PIN_ODR_HIGH(GPIOB_PIN11) | \
- PIN_ODR_HIGH(GPIOB_PIN12) | \
- PIN_ODR_HIGH(GPIOB_PIN13) | \
- PIN_ODR_HIGH(GPIOB_PIN14) | \
- PIN_ODR_HIGH(GPIOB_PIN15))
-#define VAL_GPIOB_AFRL (PIN_AFIO_AF(GPIOB_PIN0, 0) | \
- PIN_AFIO_AF(GPIOB_PIN1, 0) | \
- PIN_AFIO_AF(GPIOB_PIN2, 0) | \
- PIN_AFIO_AF(GPIOB_PIN3, 0) | \
- PIN_AFIO_AF(GPIOB_PIN4, 0) | \
- PIN_AFIO_AF(GPIOB_PIN5, 0) | \
- PIN_AFIO_AF(GPIOB_PIN6, 4) | \
- PIN_AFIO_AF(GPIOB_PIN7, 0))
-#define VAL_GPIOB_AFRH (PIN_AFIO_AF(GPIOB_PIN8, 0) | \
- PIN_AFIO_AF(GPIOB_PIN9, 0) | \
- PIN_AFIO_AF(GPIOB_PIN10, 0) | \
- PIN_AFIO_AF(GPIOB_PIN11, 0) | \
- PIN_AFIO_AF(GPIOB_PIN12, 0) | \
- PIN_AFIO_AF(GPIOB_PIN13, 0) | \
- PIN_AFIO_AF(GPIOB_PIN14, 0) | \
- PIN_AFIO_AF(GPIOB_PIN15, 0))
+#define VAL_GPIOB_MODER (PIN_MODE_INPUT(GPIOB_PIN0) | PIN_MODE_INPUT(GPIOB_PIN1) | PIN_MODE_INPUT(GPIOB_PIN2) | PIN_MODE_ALTERNATE(GPIOB_PIN3) | PIN_MODE_INPUT(GPIOB_PIN4) | PIN_MODE_INPUT(GPIOB_PIN5) | PIN_MODE_ALTERNATE(GPIOB_PIN6) | PIN_MODE_OUTPUT(GPIOB_PIN7) | PIN_MODE_INPUT(GPIOB_PIN8) | PIN_MODE_INPUT(GPIOB_PIN9) | PIN_MODE_INPUT(GPIOB_PIN10) | PIN_MODE_INPUT(GPIOB_PIN11) | PIN_MODE_INPUT(GPIOB_PIN12) | PIN_MODE_INPUT(GPIOB_PIN13) | PIN_MODE_INPUT(GPIOB_PIN14) | PIN_MODE_INPUT(GPIOB_PIN15))
+#define VAL_GPIOB_OTYPER (PIN_OTYPE_PUSHPULL(GPIOB_PIN0) | PIN_OTYPE_PUSHPULL(GPIOB_PIN1) | PIN_OTYPE_PUSHPULL(GPIOB_PIN2) | PIN_OTYPE_PUSHPULL(GPIOB_PIN3) | PIN_OTYPE_PUSHPULL(GPIOB_PIN4) | PIN_OTYPE_PUSHPULL(GPIOB_PIN5) | PIN_OTYPE_OPENDRAIN(GPIOB_PIN6) | PIN_OTYPE_PUSHPULL(GPIOB_PIN7) | PIN_OTYPE_PUSHPULL(GPIOB_PIN8) | PIN_OTYPE_PUSHPULL(GPIOB_PIN9) | PIN_OTYPE_PUSHPULL(GPIOB_PIN10) | PIN_OTYPE_PUSHPULL(GPIOB_PIN11) | PIN_OTYPE_PUSHPULL(GPIOB_PIN12) | PIN_OTYPE_PUSHPULL(GPIOB_PIN13) | PIN_OTYPE_PUSHPULL(GPIOB_PIN14) | PIN_OTYPE_PUSHPULL(GPIOB_PIN15))
+#define VAL_GPIOB_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOB_PIN0) | PIN_OSPEED_VERYLOW(GPIOB_PIN1) | PIN_OSPEED_VERYLOW(GPIOB_PIN2) | PIN_OSPEED_HIGH(GPIOB_PIN3) | PIN_OSPEED_VERYLOW(GPIOB_PIN4) | PIN_OSPEED_VERYLOW(GPIOB_PIN5) | PIN_OSPEED_HIGH(GPIOB_PIN6) | PIN_OSPEED_VERYLOW(GPIOB_PIN7) | PIN_OSPEED_VERYLOW(GPIOB_PIN8) | PIN_OSPEED_VERYLOW(GPIOB_PIN9) | PIN_OSPEED_VERYLOW(GPIOB_PIN10) | PIN_OSPEED_VERYLOW(GPIOB_PIN11) | PIN_OSPEED_VERYLOW(GPIOB_PIN12) | PIN_OSPEED_VERYLOW(GPIOB_PIN13) | PIN_OSPEED_VERYLOW(GPIOB_PIN14) | PIN_OSPEED_VERYLOW(GPIOB_PIN15))
+#define VAL_GPIOB_PUPDR (PIN_PUPDR_PULLUP(GPIOB_PIN0) | PIN_PUPDR_PULLUP(GPIOB_PIN1) | PIN_PUPDR_PULLUP(GPIOB_PIN2) | PIN_PUPDR_FLOATING(GPIOB_PIN3) | PIN_PUPDR_PULLUP(GPIOB_PIN4) | PIN_PUPDR_PULLUP(GPIOB_PIN5) | PIN_PUPDR_FLOATING(GPIOB_PIN6) | PIN_PUPDR_PULLDOWN(GPIOB_PIN7) | PIN_PUPDR_PULLUP(GPIOB_PIN8) | PIN_PUPDR_PULLUP(GPIOB_PIN9) | PIN_PUPDR_PULLUP(GPIOB_PIN10) | PIN_PUPDR_PULLUP(GPIOB_PIN11) | PIN_PUPDR_PULLUP(GPIOB_PIN12) | PIN_PUPDR_PULLUP(GPIOB_PIN13) | PIN_PUPDR_PULLUP(GPIOB_PIN14) | PIN_PUPDR_PULLUP(GPIOB_PIN15))
+#define VAL_GPIOB_ODR (PIN_ODR_HIGH(GPIOB_PIN0) | PIN_ODR_HIGH(GPIOB_PIN1) | PIN_ODR_HIGH(GPIOB_PIN2) | PIN_ODR_HIGH(GPIOB_PIN3) | PIN_ODR_HIGH(GPIOB_PIN4) | PIN_ODR_HIGH(GPIOB_PIN5) | PIN_ODR_HIGH(GPIOB_PIN6) | PIN_ODR_LOW(GPIOB_PIN7) | PIN_ODR_HIGH(GPIOB_PIN8) | PIN_ODR_HIGH(GPIOB_PIN9) | PIN_ODR_HIGH(GPIOB_PIN10) | PIN_ODR_HIGH(GPIOB_PIN11) | PIN_ODR_HIGH(GPIOB_PIN12) | PIN_ODR_HIGH(GPIOB_PIN13) | PIN_ODR_HIGH(GPIOB_PIN14) | PIN_ODR_HIGH(GPIOB_PIN15))
+#define VAL_GPIOB_AFRL (PIN_AFIO_AF(GPIOB_PIN0, 0) | PIN_AFIO_AF(GPIOB_PIN1, 0) | PIN_AFIO_AF(GPIOB_PIN2, 0) | PIN_AFIO_AF(GPIOB_PIN3, 0) | PIN_AFIO_AF(GPIOB_PIN4, 0) | PIN_AFIO_AF(GPIOB_PIN5, 0) | PIN_AFIO_AF(GPIOB_PIN6, 4) | PIN_AFIO_AF(GPIOB_PIN7, 0))
+#define VAL_GPIOB_AFRH (PIN_AFIO_AF(GPIOB_PIN8, 0) | PIN_AFIO_AF(GPIOB_PIN9, 0) | PIN_AFIO_AF(GPIOB_PIN10, 0) | PIN_AFIO_AF(GPIOB_PIN11, 0) | PIN_AFIO_AF(GPIOB_PIN12, 0) | PIN_AFIO_AF(GPIOB_PIN13, 0) | PIN_AFIO_AF(GPIOB_PIN14, 0) | PIN_AFIO_AF(GPIOB_PIN15, 0))
/*
* GPIOC setup:
@@ -478,102 +299,13 @@
* PC14 - PIN14 (input floating).
* PC15 - PIN15 (input floating).
*/
-#define VAL_GPIOC_MODER (PIN_MODE_INPUT(GPIOC_PIN0) | \
- PIN_MODE_INPUT(GPIOC_PIN1) | \
- PIN_MODE_INPUT(GPIOC_PIN2) | \
- PIN_MODE_INPUT(GPIOC_PIN3) | \
- PIN_MODE_INPUT(GPIOC_PIN4) | \
- PIN_MODE_INPUT(GPIOC_PIN5) | \
- PIN_MODE_INPUT(GPIOC_PIN6) | \
- PIN_MODE_INPUT(GPIOC_PIN7) | \
- PIN_MODE_INPUT(GPIOC_PIN8) | \
- PIN_MODE_INPUT(GPIOC_PIN9) | \
- PIN_MODE_INPUT(GPIOC_PIN10) | \
- PIN_MODE_INPUT(GPIOC_PIN11) | \
- PIN_MODE_INPUT(GPIOC_PIN12) | \
- PIN_MODE_INPUT(GPIOC_PIN13) | \
- PIN_MODE_INPUT(GPIOC_PIN14) | \
- PIN_MODE_INPUT(GPIOC_PIN15))
-#define VAL_GPIOC_OTYPER (PIN_OTYPE_PUSHPULL(GPIOC_PIN0) | \
- PIN_OTYPE_PUSHPULL(GPIOC_PIN1) | \
- PIN_OTYPE_PUSHPULL(GPIOC_PIN2) | \
- PIN_OTYPE_PUSHPULL(GPIOC_PIN3) | \
- PIN_OTYPE_PUSHPULL(GPIOC_PIN4) | \
- PIN_OTYPE_PUSHPULL(GPIOC_PIN5) | \
- PIN_OTYPE_PUSHPULL(GPIOC_PIN6) | \
- PIN_OTYPE_PUSHPULL(GPIOC_PIN7) | \
- PIN_OTYPE_PUSHPULL(GPIOC_PIN8) | \
- PIN_OTYPE_PUSHPULL(GPIOC_PIN9) | \
- PIN_OTYPE_PUSHPULL(GPIOC_PIN10) | \
- PIN_OTYPE_PUSHPULL(GPIOC_PIN11) | \
- PIN_OTYPE_PUSHPULL(GPIOC_PIN12) | \
- PIN_OTYPE_PUSHPULL(GPIOC_PIN13) | \
- PIN_OTYPE_PUSHPULL(GPIOC_PIN14) | \
- PIN_OTYPE_PUSHPULL(GPIOC_PIN15))
-#define VAL_GPIOC_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOC_PIN0) | \
- PIN_OSPEED_VERYLOW(GPIOC_PIN1) | \
- PIN_OSPEED_VERYLOW(GPIOC_PIN2) | \
- PIN_OSPEED_VERYLOW(GPIOC_PIN3) | \
- PIN_OSPEED_VERYLOW(GPIOC_PIN4) | \
- PIN_OSPEED_VERYLOW(GPIOC_PIN5) | \
- PIN_OSPEED_VERYLOW(GPIOC_PIN6) | \
- PIN_OSPEED_VERYLOW(GPIOC_PIN7) | \
- PIN_OSPEED_VERYLOW(GPIOC_PIN8) | \
- PIN_OSPEED_VERYLOW(GPIOC_PIN9) | \
- PIN_OSPEED_VERYLOW(GPIOC_PIN10) | \
- PIN_OSPEED_VERYLOW(GPIOC_PIN11) | \
- PIN_OSPEED_VERYLOW(GPIOC_PIN12) | \
- PIN_OSPEED_VERYLOW(GPIOC_PIN13) | \
- PIN_OSPEED_HIGH(GPIOC_PIN14) | \
- PIN_OSPEED_HIGH(GPIOC_PIN15))
-#define VAL_GPIOC_PUPDR (PIN_PUPDR_PULLUP(GPIOC_PIN0) | \
- PIN_PUPDR_PULLUP(GPIOC_PIN1) | \
- PIN_PUPDR_PULLUP(GPIOC_PIN2) | \
- PIN_PUPDR_PULLUP(GPIOC_PIN3) | \
- PIN_PUPDR_PULLUP(GPIOC_PIN4) | \
- PIN_PUPDR_PULLUP(GPIOC_PIN5) | \
- PIN_PUPDR_PULLUP(GPIOC_PIN6) | \
- PIN_PUPDR_PULLUP(GPIOC_PIN7) | \
- PIN_PUPDR_PULLUP(GPIOC_PIN8) | \
- PIN_PUPDR_PULLUP(GPIOC_PIN9) | \
- PIN_PUPDR_PULLUP(GPIOC_PIN10) | \
- PIN_PUPDR_PULLUP(GPIOC_PIN11) | \
- PIN_PUPDR_PULLUP(GPIOC_PIN12) | \
- PIN_PUPDR_PULLUP(GPIOC_PIN13) | \
- PIN_PUPDR_FLOATING(GPIOC_PIN14) | \
- PIN_PUPDR_FLOATING(GPIOC_PIN15))
-#define VAL_GPIOC_ODR (PIN_ODR_HIGH(GPIOC_PIN0) | \
- PIN_ODR_HIGH(GPIOC_PIN1) | \
- PIN_ODR_HIGH(GPIOC_PIN2) | \
- PIN_ODR_HIGH(GPIOC_PIN3) | \
- PIN_ODR_HIGH(GPIOC_PIN4) | \
- PIN_ODR_HIGH(GPIOC_PIN5) | \
- PIN_ODR_HIGH(GPIOC_PIN6) | \
- PIN_ODR_HIGH(GPIOC_PIN7) | \
- PIN_ODR_HIGH(GPIOC_PIN8) | \
- PIN_ODR_HIGH(GPIOC_PIN9) | \
- PIN_ODR_HIGH(GPIOC_PIN10) | \
- PIN_ODR_HIGH(GPIOC_PIN11) | \
- PIN_ODR_HIGH(GPIOC_PIN12) | \
- PIN_ODR_HIGH(GPIOC_PIN13) | \
- PIN_ODR_HIGH(GPIOC_PIN14) | \
- PIN_ODR_HIGH(GPIOC_PIN15))
-#define VAL_GPIOC_AFRL (PIN_AFIO_AF(GPIOC_PIN0, 0) | \
- PIN_AFIO_AF(GPIOC_PIN1, 0) | \
- PIN_AFIO_AF(GPIOC_PIN2, 0) | \
- PIN_AFIO_AF(GPIOC_PIN3, 0) | \
- PIN_AFIO_AF(GPIOC_PIN4, 0) | \
- PIN_AFIO_AF(GPIOC_PIN5, 0) | \
- PIN_AFIO_AF(GPIOC_PIN6, 0) | \
- PIN_AFIO_AF(GPIOC_PIN7, 0))
-#define VAL_GPIOC_AFRH (PIN_AFIO_AF(GPIOC_PIN8, 0) | \
- PIN_AFIO_AF(GPIOC_PIN9, 0) | \
- PIN_AFIO_AF(GPIOC_PIN10, 0) | \
- PIN_AFIO_AF(GPIOC_PIN11, 0) | \
- PIN_AFIO_AF(GPIOC_PIN12, 0) | \
- PIN_AFIO_AF(GPIOC_PIN13, 0) | \
- PIN_AFIO_AF(GPIOC_PIN14, 0) | \
- PIN_AFIO_AF(GPIOC_PIN15, 0))
+#define VAL_GPIOC_MODER (PIN_MODE_INPUT(GPIOC_PIN0) | PIN_MODE_INPUT(GPIOC_PIN1) | PIN_MODE_INPUT(GPIOC_PIN2) | PIN_MODE_INPUT(GPIOC_PIN3) | PIN_MODE_INPUT(GPIOC_PIN4) | PIN_MODE_INPUT(GPIOC_PIN5) | PIN_MODE_INPUT(GPIOC_PIN6) | PIN_MODE_INPUT(GPIOC_PIN7) | PIN_MODE_INPUT(GPIOC_PIN8) | PIN_MODE_INPUT(GPIOC_PIN9) | PIN_MODE_INPUT(GPIOC_PIN10) | PIN_MODE_INPUT(GPIOC_PIN11) | PIN_MODE_INPUT(GPIOC_PIN12) | PIN_MODE_INPUT(GPIOC_PIN13) | PIN_MODE_INPUT(GPIOC_PIN14) | PIN_MODE_INPUT(GPIOC_PIN15))
+#define VAL_GPIOC_OTYPER (PIN_OTYPE_PUSHPULL(GPIOC_PIN0) | PIN_OTYPE_PUSHPULL(GPIOC_PIN1) | PIN_OTYPE_PUSHPULL(GPIOC_PIN2) | PIN_OTYPE_PUSHPULL(GPIOC_PIN3) | PIN_OTYPE_PUSHPULL(GPIOC_PIN4) | PIN_OTYPE_PUSHPULL(GPIOC_PIN5) | PIN_OTYPE_PUSHPULL(GPIOC_PIN6) | PIN_OTYPE_PUSHPULL(GPIOC_PIN7) | PIN_OTYPE_PUSHPULL(GPIOC_PIN8) | PIN_OTYPE_PUSHPULL(GPIOC_PIN9) | PIN_OTYPE_PUSHPULL(GPIOC_PIN10) | PIN_OTYPE_PUSHPULL(GPIOC_PIN11) | PIN_OTYPE_PUSHPULL(GPIOC_PIN12) | PIN_OTYPE_PUSHPULL(GPIOC_PIN13) | PIN_OTYPE_PUSHPULL(GPIOC_PIN14) | PIN_OTYPE_PUSHPULL(GPIOC_PIN15))
+#define VAL_GPIOC_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOC_PIN0) | PIN_OSPEED_VERYLOW(GPIOC_PIN1) | PIN_OSPEED_VERYLOW(GPIOC_PIN2) | PIN_OSPEED_VERYLOW(GPIOC_PIN3) | PIN_OSPEED_VERYLOW(GPIOC_PIN4) | PIN_OSPEED_VERYLOW(GPIOC_PIN5) | PIN_OSPEED_VERYLOW(GPIOC_PIN6) | PIN_OSPEED_VERYLOW(GPIOC_PIN7) | PIN_OSPEED_VERYLOW(GPIOC_PIN8) | PIN_OSPEED_VERYLOW(GPIOC_PIN9) | PIN_OSPEED_VERYLOW(GPIOC_PIN10) | PIN_OSPEED_VERYLOW(GPIOC_PIN11) | PIN_OSPEED_VERYLOW(GPIOC_PIN12) | PIN_OSPEED_VERYLOW(GPIOC_PIN13) | PIN_OSPEED_HIGH(GPIOC_PIN14) | PIN_OSPEED_HIGH(GPIOC_PIN15))
+#define VAL_GPIOC_PUPDR (PIN_PUPDR_PULLUP(GPIOC_PIN0) | PIN_PUPDR_PULLUP(GPIOC_PIN1) | PIN_PUPDR_PULLUP(GPIOC_PIN2) | PIN_PUPDR_PULLUP(GPIOC_PIN3) | PIN_PUPDR_PULLUP(GPIOC_PIN4) | PIN_PUPDR_PULLUP(GPIOC_PIN5) | PIN_PUPDR_PULLUP(GPIOC_PIN6) | PIN_PUPDR_PULLUP(GPIOC_PIN7) | PIN_PUPDR_PULLUP(GPIOC_PIN8) | PIN_PUPDR_PULLUP(GPIOC_PIN9) | PIN_PUPDR_PULLUP(GPIOC_PIN10) | PIN_PUPDR_PULLUP(GPIOC_PIN11) | PIN_PUPDR_PULLUP(GPIOC_PIN12) | PIN_PUPDR_PULLUP(GPIOC_PIN13) | PIN_PUPDR_FLOATING(GPIOC_PIN14) | PIN_PUPDR_FLOATING(GPIOC_PIN15))
+#define VAL_GPIOC_ODR (PIN_ODR_HIGH(GPIOC_PIN0) | PIN_ODR_HIGH(GPIOC_PIN1) | PIN_ODR_HIGH(GPIOC_PIN2) | PIN_ODR_HIGH(GPIOC_PIN3) | PIN_ODR_HIGH(GPIOC_PIN4) | PIN_ODR_HIGH(GPIOC_PIN5) | PIN_ODR_HIGH(GPIOC_PIN6) | PIN_ODR_HIGH(GPIOC_PIN7) | PIN_ODR_HIGH(GPIOC_PIN8) | PIN_ODR_HIGH(GPIOC_PIN9) | PIN_ODR_HIGH(GPIOC_PIN10) | PIN_ODR_HIGH(GPIOC_PIN11) | PIN_ODR_HIGH(GPIOC_PIN12) | PIN_ODR_HIGH(GPIOC_PIN13) | PIN_ODR_HIGH(GPIOC_PIN14) | PIN_ODR_HIGH(GPIOC_PIN15))
+#define VAL_GPIOC_AFRL (PIN_AFIO_AF(GPIOC_PIN0, 0) | PIN_AFIO_AF(GPIOC_PIN1, 0) | PIN_AFIO_AF(GPIOC_PIN2, 0) | PIN_AFIO_AF(GPIOC_PIN3, 0) | PIN_AFIO_AF(GPIOC_PIN4, 0) | PIN_AFIO_AF(GPIOC_PIN5, 0) | PIN_AFIO_AF(GPIOC_PIN6, 0) | PIN_AFIO_AF(GPIOC_PIN7, 0))
+#define VAL_GPIOC_AFRH (PIN_AFIO_AF(GPIOC_PIN8, 0) | PIN_AFIO_AF(GPIOC_PIN9, 0) | PIN_AFIO_AF(GPIOC_PIN10, 0) | PIN_AFIO_AF(GPIOC_PIN11, 0) | PIN_AFIO_AF(GPIOC_PIN12, 0) | PIN_AFIO_AF(GPIOC_PIN13, 0) | PIN_AFIO_AF(GPIOC_PIN14, 0) | PIN_AFIO_AF(GPIOC_PIN15, 0))
/*
* GPIOD setup:
@@ -595,102 +327,13 @@
* PD14 - PIN14 (input pullup).
* PD15 - PIN15 (input pullup).
*/
-#define VAL_GPIOD_MODER (PIN_MODE_INPUT(GPIOD_PIN0) | \
- PIN_MODE_INPUT(GPIOD_PIN1) | \
- PIN_MODE_INPUT(GPIOD_PIN2) | \
- PIN_MODE_INPUT(GPIOD_PIN3) | \
- PIN_MODE_INPUT(GPIOD_PIN4) | \
- PIN_MODE_INPUT(GPIOD_PIN5) | \
- PIN_MODE_INPUT(GPIOD_PIN6) | \
- PIN_MODE_INPUT(GPIOD_PIN7) | \
- PIN_MODE_INPUT(GPIOD_PIN8) | \
- PIN_MODE_INPUT(GPIOD_PIN9) | \
- PIN_MODE_INPUT(GPIOD_PIN10) | \
- PIN_MODE_INPUT(GPIOD_PIN11) | \
- PIN_MODE_INPUT(GPIOD_PIN12) | \
- PIN_MODE_INPUT(GPIOD_PIN13) | \
- PIN_MODE_INPUT(GPIOD_PIN14) | \
- PIN_MODE_INPUT(GPIOD_PIN15))
-#define VAL_GPIOD_OTYPER (PIN_OTYPE_PUSHPULL(GPIOD_PIN0) | \
- PIN_OTYPE_PUSHPULL(GPIOD_PIN1) | \
- PIN_OTYPE_PUSHPULL(GPIOD_PIN2) | \
- PIN_OTYPE_PUSHPULL(GPIOD_PIN3) | \
- PIN_OTYPE_PUSHPULL(GPIOD_PIN4) | \
- PIN_OTYPE_PUSHPULL(GPIOD_PIN5) | \
- PIN_OTYPE_PUSHPULL(GPIOD_PIN6) | \
- PIN_OTYPE_PUSHPULL(GPIOD_PIN7) | \
- PIN_OTYPE_PUSHPULL(GPIOD_PIN8) | \
- PIN_OTYPE_PUSHPULL(GPIOD_PIN9) | \
- PIN_OTYPE_PUSHPULL(GPIOD_PIN10) | \
- PIN_OTYPE_PUSHPULL(GPIOD_PIN11) | \
- PIN_OTYPE_PUSHPULL(GPIOD_PIN12) | \
- PIN_OTYPE_PUSHPULL(GPIOD_PIN13) | \
- PIN_OTYPE_PUSHPULL(GPIOD_PIN14) | \
- PIN_OTYPE_PUSHPULL(GPIOD_PIN15))
-#define VAL_GPIOD_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOD_PIN0) | \
- PIN_OSPEED_VERYLOW(GPIOD_PIN1) | \
- PIN_OSPEED_VERYLOW(GPIOD_PIN2) | \
- PIN_OSPEED_VERYLOW(GPIOD_PIN3) | \
- PIN_OSPEED_VERYLOW(GPIOD_PIN4) | \
- PIN_OSPEED_VERYLOW(GPIOD_PIN5) | \
- PIN_OSPEED_VERYLOW(GPIOD_PIN6) | \
- PIN_OSPEED_VERYLOW(GPIOD_PIN7) | \
- PIN_OSPEED_VERYLOW(GPIOD_PIN8) | \
- PIN_OSPEED_VERYLOW(GPIOD_PIN9) | \
- PIN_OSPEED_VERYLOW(GPIOD_PIN10) | \
- PIN_OSPEED_VERYLOW(GPIOD_PIN11) | \
- PIN_OSPEED_VERYLOW(GPIOD_PIN12) | \
- PIN_OSPEED_VERYLOW(GPIOD_PIN13) | \
- PIN_OSPEED_VERYLOW(GPIOD_PIN14) | \
- PIN_OSPEED_VERYLOW(GPIOD_PIN15))
-#define VAL_GPIOD_PUPDR (PIN_PUPDR_PULLUP(GPIOD_PIN0) | \
- PIN_PUPDR_PULLUP(GPIOD_PIN1) | \
- PIN_PUPDR_PULLUP(GPIOD_PIN2) | \
- PIN_PUPDR_PULLUP(GPIOD_PIN3) | \
- PIN_PUPDR_PULLUP(GPIOD_PIN4) | \
- PIN_PUPDR_PULLUP(GPIOD_PIN5) | \
- PIN_PUPDR_PULLUP(GPIOD_PIN6) | \
- PIN_PUPDR_PULLUP(GPIOD_PIN7) | \
- PIN_PUPDR_PULLUP(GPIOD_PIN8) | \
- PIN_PUPDR_PULLUP(GPIOD_PIN9) | \
- PIN_PUPDR_PULLUP(GPIOD_PIN10) | \
- PIN_PUPDR_PULLUP(GPIOD_PIN11) | \
- PIN_PUPDR_PULLUP(GPIOD_PIN12) | \
- PIN_PUPDR_PULLUP(GPIOD_PIN13) | \
- PIN_PUPDR_PULLUP(GPIOD_PIN14) | \
- PIN_PUPDR_PULLUP(GPIOD_PIN15))
-#define VAL_GPIOD_ODR (PIN_ODR_HIGH(GPIOD_PIN0) | \
- PIN_ODR_HIGH(GPIOD_PIN1) | \
- PIN_ODR_HIGH(GPIOD_PIN2) | \
- PIN_ODR_HIGH(GPIOD_PIN3) | \
- PIN_ODR_HIGH(GPIOD_PIN4) | \
- PIN_ODR_HIGH(GPIOD_PIN5) | \
- PIN_ODR_HIGH(GPIOD_PIN6) | \
- PIN_ODR_HIGH(GPIOD_PIN7) | \
- PIN_ODR_HIGH(GPIOD_PIN8) | \
- PIN_ODR_HIGH(GPIOD_PIN9) | \
- PIN_ODR_HIGH(GPIOD_PIN10) | \
- PIN_ODR_HIGH(GPIOD_PIN11) | \
- PIN_ODR_HIGH(GPIOD_PIN12) | \
- PIN_ODR_HIGH(GPIOD_PIN13) | \
- PIN_ODR_HIGH(GPIOD_PIN14) | \
- PIN_ODR_HIGH(GPIOD_PIN15))
-#define VAL_GPIOD_AFRL (PIN_AFIO_AF(GPIOD_PIN0, 0) | \
- PIN_AFIO_AF(GPIOD_PIN1, 0) | \
- PIN_AFIO_AF(GPIOD_PIN2, 0) | \
- PIN_AFIO_AF(GPIOD_PIN3, 0) | \
- PIN_AFIO_AF(GPIOD_PIN4, 0) | \
- PIN_AFIO_AF(GPIOD_PIN5, 0) | \
- PIN_AFIO_AF(GPIOD_PIN6, 0) | \
- PIN_AFIO_AF(GPIOD_PIN7, 0))
-#define VAL_GPIOD_AFRH (PIN_AFIO_AF(GPIOD_PIN8, 0) | \
- PIN_AFIO_AF(GPIOD_PIN9, 0) | \
- PIN_AFIO_AF(GPIOD_PIN10, 0) | \
- PIN_AFIO_AF(GPIOD_PIN11, 0) | \
- PIN_AFIO_AF(GPIOD_PIN12, 0) | \
- PIN_AFIO_AF(GPIOD_PIN13, 0) | \
- PIN_AFIO_AF(GPIOD_PIN14, 0) | \
- PIN_AFIO_AF(GPIOD_PIN15, 0))
+#define VAL_GPIOD_MODER (PIN_MODE_INPUT(GPIOD_PIN0) | PIN_MODE_INPUT(GPIOD_PIN1) | PIN_MODE_INPUT(GPIOD_PIN2) | PIN_MODE_INPUT(GPIOD_PIN3) | PIN_MODE_INPUT(GPIOD_PIN4) | PIN_MODE_INPUT(GPIOD_PIN5) | PIN_MODE_INPUT(GPIOD_PIN6) | PIN_MODE_INPUT(GPIOD_PIN7) | PIN_MODE_INPUT(GPIOD_PIN8) | PIN_MODE_INPUT(GPIOD_PIN9) | PIN_MODE_INPUT(GPIOD_PIN10) | PIN_MODE_INPUT(GPIOD_PIN11) | PIN_MODE_INPUT(GPIOD_PIN12) | PIN_MODE_INPUT(GPIOD_PIN13) | PIN_MODE_INPUT(GPIOD_PIN14) | PIN_MODE_INPUT(GPIOD_PIN15))
+#define VAL_GPIOD_OTYPER (PIN_OTYPE_PUSHPULL(GPIOD_PIN0) | PIN_OTYPE_PUSHPULL(GPIOD_PIN1) | PIN_OTYPE_PUSHPULL(GPIOD_PIN2) | PIN_OTYPE_PUSHPULL(GPIOD_PIN3) | PIN_OTYPE_PUSHPULL(GPIOD_PIN4) | PIN_OTYPE_PUSHPULL(GPIOD_PIN5) | PIN_OTYPE_PUSHPULL(GPIOD_PIN6) | PIN_OTYPE_PUSHPULL(GPIOD_PIN7) | PIN_OTYPE_PUSHPULL(GPIOD_PIN8) | PIN_OTYPE_PUSHPULL(GPIOD_PIN9) | PIN_OTYPE_PUSHPULL(GPIOD_PIN10) | PIN_OTYPE_PUSHPULL(GPIOD_PIN11) | PIN_OTYPE_PUSHPULL(GPIOD_PIN12) | PIN_OTYPE_PUSHPULL(GPIOD_PIN13) | PIN_OTYPE_PUSHPULL(GPIOD_PIN14) | PIN_OTYPE_PUSHPULL(GPIOD_PIN15))
+#define VAL_GPIOD_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOD_PIN0) | PIN_OSPEED_VERYLOW(GPIOD_PIN1) | PIN_OSPEED_VERYLOW(GPIOD_PIN2) | PIN_OSPEED_VERYLOW(GPIOD_PIN3) | PIN_OSPEED_VERYLOW(GPIOD_PIN4) | PIN_OSPEED_VERYLOW(GPIOD_PIN5) | PIN_OSPEED_VERYLOW(GPIOD_PIN6) | PIN_OSPEED_VERYLOW(GPIOD_PIN7) | PIN_OSPEED_VERYLOW(GPIOD_PIN8) | PIN_OSPEED_VERYLOW(GPIOD_PIN9) | PIN_OSPEED_VERYLOW(GPIOD_PIN10) | PIN_OSPEED_VERYLOW(GPIOD_PIN11) | PIN_OSPEED_VERYLOW(GPIOD_PIN12) | PIN_OSPEED_VERYLOW(GPIOD_PIN13) | PIN_OSPEED_VERYLOW(GPIOD_PIN14) | PIN_OSPEED_VERYLOW(GPIOD_PIN15))
+#define VAL_GPIOD_PUPDR (PIN_PUPDR_PULLUP(GPIOD_PIN0) | PIN_PUPDR_PULLUP(GPIOD_PIN1) | PIN_PUPDR_PULLUP(GPIOD_PIN2) | PIN_PUPDR_PULLUP(GPIOD_PIN3) | PIN_PUPDR_PULLUP(GPIOD_PIN4) | PIN_PUPDR_PULLUP(GPIOD_PIN5) | PIN_PUPDR_PULLUP(GPIOD_PIN6) | PIN_PUPDR_PULLUP(GPIOD_PIN7) | PIN_PUPDR_PULLUP(GPIOD_PIN8) | PIN_PUPDR_PULLUP(GPIOD_PIN9) | PIN_PUPDR_PULLUP(GPIOD_PIN10) | PIN_PUPDR_PULLUP(GPIOD_PIN11) | PIN_PUPDR_PULLUP(GPIOD_PIN12) | PIN_PUPDR_PULLUP(GPIOD_PIN13) | PIN_PUPDR_PULLUP(GPIOD_PIN14) | PIN_PUPDR_PULLUP(GPIOD_PIN15))
+#define VAL_GPIOD_ODR (PIN_ODR_HIGH(GPIOD_PIN0) | PIN_ODR_HIGH(GPIOD_PIN1) | PIN_ODR_HIGH(GPIOD_PIN2) | PIN_ODR_HIGH(GPIOD_PIN3) | PIN_ODR_HIGH(GPIOD_PIN4) | PIN_ODR_HIGH(GPIOD_PIN5) | PIN_ODR_HIGH(GPIOD_PIN6) | PIN_ODR_HIGH(GPIOD_PIN7) | PIN_ODR_HIGH(GPIOD_PIN8) | PIN_ODR_HIGH(GPIOD_PIN9) | PIN_ODR_HIGH(GPIOD_PIN10) | PIN_ODR_HIGH(GPIOD_PIN11) | PIN_ODR_HIGH(GPIOD_PIN12) | PIN_ODR_HIGH(GPIOD_PIN13) | PIN_ODR_HIGH(GPIOD_PIN14) | PIN_ODR_HIGH(GPIOD_PIN15))
+#define VAL_GPIOD_AFRL (PIN_AFIO_AF(GPIOD_PIN0, 0) | PIN_AFIO_AF(GPIOD_PIN1, 0) | PIN_AFIO_AF(GPIOD_PIN2, 0) | PIN_AFIO_AF(GPIOD_PIN3, 0) | PIN_AFIO_AF(GPIOD_PIN4, 0) | PIN_AFIO_AF(GPIOD_PIN5, 0) | PIN_AFIO_AF(GPIOD_PIN6, 0) | PIN_AFIO_AF(GPIOD_PIN7, 0))
+#define VAL_GPIOD_AFRH (PIN_AFIO_AF(GPIOD_PIN8, 0) | PIN_AFIO_AF(GPIOD_PIN9, 0) | PIN_AFIO_AF(GPIOD_PIN10, 0) | PIN_AFIO_AF(GPIOD_PIN11, 0) | PIN_AFIO_AF(GPIOD_PIN12, 0) | PIN_AFIO_AF(GPIOD_PIN13, 0) | PIN_AFIO_AF(GPIOD_PIN14, 0) | PIN_AFIO_AF(GPIOD_PIN15, 0))
/*
* GPIOE setup:
@@ -712,102 +355,13 @@
* PE14 - PIN14 (output pushpull maximum).
* PE15 - PIN15 (output pushpull maximum).
*/
-#define VAL_GPIOE_MODER (PIN_MODE_INPUT(GPIOE_PIN0) | \
- PIN_MODE_INPUT(GPIOE_PIN1) | \
- PIN_MODE_INPUT(GPIOE_PIN2) |\
- PIN_MODE_OUTPUT(GPIOE_PIN3) | \
- PIN_MODE_INPUT(GPIOE_PIN4) |\
- PIN_MODE_INPUT(GPIOE_PIN5) |\
- PIN_MODE_INPUT(GPIOE_PIN6) | \
- PIN_MODE_INPUT(GPIOE_PIN7) | \
- PIN_MODE_OUTPUT(GPIOE_PIN8) | \
- PIN_MODE_OUTPUT(GPIOE_PIN9) | \
- PIN_MODE_OUTPUT(GPIOE_PIN10) | \
- PIN_MODE_OUTPUT(GPIOE_PIN11) | \
- PIN_MODE_OUTPUT(GPIOE_PIN12) | \
- PIN_MODE_OUTPUT(GPIOE_PIN13) | \
- PIN_MODE_OUTPUT(GPIOE_PIN14) | \
- PIN_MODE_OUTPUT(GPIOE_PIN15))
-#define VAL_GPIOE_OTYPER (PIN_OTYPE_PUSHPULL(GPIOE_PIN0) |\
- PIN_OTYPE_PUSHPULL(GPIOE_PIN1) |\
- PIN_OTYPE_PUSHPULL(GPIOE_PIN2) |\
- PIN_OTYPE_PUSHPULL(GPIOE_PIN3) | \
- PIN_OTYPE_PUSHPULL(GPIOE_PIN4) |\
- PIN_OTYPE_PUSHPULL(GPIOE_PIN5) |\
- PIN_OTYPE_PUSHPULL(GPIOE_PIN6) | \
- PIN_OTYPE_PUSHPULL(GPIOE_PIN7) | \
- PIN_OTYPE_PUSHPULL(GPIOE_PIN8) | \
- PIN_OTYPE_PUSHPULL(GPIOE_PIN9) | \
- PIN_OTYPE_PUSHPULL(GPIOE_PIN10) |\
- PIN_OTYPE_PUSHPULL(GPIOE_PIN11) | \
- PIN_OTYPE_PUSHPULL(GPIOE_PIN12) | \
- PIN_OTYPE_PUSHPULL(GPIOE_PIN13) | \
- PIN_OTYPE_PUSHPULL(GPIOE_PIN14) |\
- PIN_OTYPE_PUSHPULL(GPIOE_PIN15))
-#define VAL_GPIOE_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOE_PIN0) |\
- PIN_OSPEED_VERYLOW(GPIOE_PIN1) |\
- PIN_OSPEED_VERYLOW(GPIOE_PIN2) |\
- PIN_OSPEED_HIGH(GPIOE_PIN3) | \
- PIN_OSPEED_VERYLOW(GPIOE_PIN4) |\
- PIN_OSPEED_VERYLOW(GPIOE_PIN5) |\
- PIN_OSPEED_VERYLOW(GPIOE_PIN6) | \
- PIN_OSPEED_VERYLOW(GPIOE_PIN7) | \
- PIN_OSPEED_HIGH(GPIOE_PIN8) | \
- PIN_OSPEED_HIGH(GPIOE_PIN9) | \
- PIN_OSPEED_HIGH(GPIOE_PIN10) | \
- PIN_OSPEED_HIGH(GPIOE_PIN11) | \
- PIN_OSPEED_HIGH(GPIOE_PIN12) | \
- PIN_OSPEED_HIGH(GPIOE_PIN13) | \
- PIN_OSPEED_HIGH(GPIOE_PIN14) | \
- PIN_OSPEED_HIGH(GPIOE_PIN15))
-#define VAL_GPIOE_PUPDR (PIN_PUPDR_PULLUP(GPIOE_PIN0) | \
- PIN_PUPDR_PULLUP(GPIOE_PIN1) | \
- PIN_PUPDR_PULLUP(GPIOE_PIN2) |\
- PIN_PUPDR_FLOATING(GPIOE_PIN3) | \
- PIN_PUPDR_PULLUP(GPIOE_PIN4) |\
- PIN_PUPDR_PULLUP(GPIOE_PIN5) |\
- PIN_PUPDR_PULLUP(GPIOE_PIN6) | \
- PIN_PUPDR_PULLUP(GPIOE_PIN7) | \
- PIN_PUPDR_PULLUP(GPIOE_PIN8) | \
- PIN_PUPDR_PULLUP(GPIOE_PIN9) | \
- PIN_PUPDR_PULLUP(GPIOE_PIN10) | \
- PIN_PUPDR_FLOATING(GPIOE_PIN11) | \
- PIN_PUPDR_PULLUP(GPIOE_PIN12) | \
- PIN_PUPDR_FLOATING(GPIOE_PIN13) | \
- PIN_PUPDR_FLOATING(GPIOE_PIN14) |\
- PIN_PUPDR_FLOATING(GPIOE_PIN15))
-#define VAL_GPIOE_ODR (PIN_ODR_HIGH(GPIOE_PIN0) | \
- PIN_ODR_HIGH(GPIOE_PIN1) | \
- PIN_ODR_HIGH(GPIOE_PIN2) | \
- PIN_ODR_HIGH(GPIOE_PIN3) | \
- PIN_ODR_HIGH(GPIOE_PIN4) | \
- PIN_ODR_HIGH(GPIOE_PIN5) | \
- PIN_ODR_HIGH(GPIOE_PIN6) | \
- PIN_ODR_HIGH(GPIOE_PIN7) | \
- PIN_ODR_LOW(GPIOE_PIN8) | \
- PIN_ODR_LOW(GPIOE_PIN9) | \
- PIN_ODR_LOW(GPIOE_PIN10) | \
- PIN_ODR_LOW(GPIOE_PIN11) | \
- PIN_ODR_LOW(GPIOE_PIN12) | \
- PIN_ODR_LOW(GPIOE_PIN13) | \
- PIN_ODR_LOW(GPIOE_PIN14) | \
- PIN_ODR_LOW(GPIOE_PIN15))
-#define VAL_GPIOE_AFRL (PIN_AFIO_AF(GPIOE_PIN0, 0) | \
- PIN_AFIO_AF(GPIOE_PIN1, 0) | \
- PIN_AFIO_AF(GPIOE_PIN2, 0) |\
- PIN_AFIO_AF(GPIOE_PIN3, 0) | \
- PIN_AFIO_AF(GPIOE_PIN4, 0) |\
- PIN_AFIO_AF(GPIOE_PIN5, 0) |\
- PIN_AFIO_AF(GPIOE_PIN6, 0) | \
- PIN_AFIO_AF(GPIOE_PIN7, 0))
-#define VAL_GPIOE_AFRH (PIN_AFIO_AF(GPIOE_PIN8, 0) | \
- PIN_AFIO_AF(GPIOE_PIN9, 0) | \
- PIN_AFIO_AF(GPIOE_PIN10, 0) | \
- PIN_AFIO_AF(GPIOE_PIN11, 0) | \
- PIN_AFIO_AF(GPIOE_PIN12, 0) | \
- PIN_AFIO_AF(GPIOE_PIN13, 0) | \
- PIN_AFIO_AF(GPIOE_PIN14, 0) | \
- PIN_AFIO_AF(GPIOE_PIN15, 0))
+#define VAL_GPIOE_MODER (PIN_MODE_INPUT(GPIOE_PIN0) | PIN_MODE_INPUT(GPIOE_PIN1) | PIN_MODE_INPUT(GPIOE_PIN2) | PIN_MODE_OUTPUT(GPIOE_PIN3) | PIN_MODE_INPUT(GPIOE_PIN4) | PIN_MODE_INPUT(GPIOE_PIN5) | PIN_MODE_INPUT(GPIOE_PIN6) | PIN_MODE_INPUT(GPIOE_PIN7) | PIN_MODE_OUTPUT(GPIOE_PIN8) | PIN_MODE_OUTPUT(GPIOE_PIN9) | PIN_MODE_OUTPUT(GPIOE_PIN10) | PIN_MODE_OUTPUT(GPIOE_PIN11) | PIN_MODE_OUTPUT(GPIOE_PIN12) | PIN_MODE_OUTPUT(GPIOE_PIN13) | PIN_MODE_OUTPUT(GPIOE_PIN14) | PIN_MODE_OUTPUT(GPIOE_PIN15))
+#define VAL_GPIOE_OTYPER (PIN_OTYPE_PUSHPULL(GPIOE_PIN0) | PIN_OTYPE_PUSHPULL(GPIOE_PIN1) | PIN_OTYPE_PUSHPULL(GPIOE_PIN2) | PIN_OTYPE_PUSHPULL(GPIOE_PIN3) | PIN_OTYPE_PUSHPULL(GPIOE_PIN4) | PIN_OTYPE_PUSHPULL(GPIOE_PIN5) | PIN_OTYPE_PUSHPULL(GPIOE_PIN6) | PIN_OTYPE_PUSHPULL(GPIOE_PIN7) | PIN_OTYPE_PUSHPULL(GPIOE_PIN8) | PIN_OTYPE_PUSHPULL(GPIOE_PIN9) | PIN_OTYPE_PUSHPULL(GPIOE_PIN10) | PIN_OTYPE_PUSHPULL(GPIOE_PIN11) | PIN_OTYPE_PUSHPULL(GPIOE_PIN12) | PIN_OTYPE_PUSHPULL(GPIOE_PIN13) | PIN_OTYPE_PUSHPULL(GPIOE_PIN14) | PIN_OTYPE_PUSHPULL(GPIOE_PIN15))
+#define VAL_GPIOE_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOE_PIN0) | PIN_OSPEED_VERYLOW(GPIOE_PIN1) | PIN_OSPEED_VERYLOW(GPIOE_PIN2) | PIN_OSPEED_HIGH(GPIOE_PIN3) | PIN_OSPEED_VERYLOW(GPIOE_PIN4) | PIN_OSPEED_VERYLOW(GPIOE_PIN5) | PIN_OSPEED_VERYLOW(GPIOE_PIN6) | PIN_OSPEED_VERYLOW(GPIOE_PIN7) | PIN_OSPEED_HIGH(GPIOE_PIN8) | PIN_OSPEED_HIGH(GPIOE_PIN9) | PIN_OSPEED_HIGH(GPIOE_PIN10) | PIN_OSPEED_HIGH(GPIOE_PIN11) | PIN_OSPEED_HIGH(GPIOE_PIN12) | PIN_OSPEED_HIGH(GPIOE_PIN13) | PIN_OSPEED_HIGH(GPIOE_PIN14) | PIN_OSPEED_HIGH(GPIOE_PIN15))
+#define VAL_GPIOE_PUPDR (PIN_PUPDR_PULLUP(GPIOE_PIN0) | PIN_PUPDR_PULLUP(GPIOE_PIN1) | PIN_PUPDR_PULLUP(GPIOE_PIN2) | PIN_PUPDR_FLOATING(GPIOE_PIN3) | PIN_PUPDR_PULLUP(GPIOE_PIN4) | PIN_PUPDR_PULLUP(GPIOE_PIN5) | PIN_PUPDR_PULLUP(GPIOE_PIN6) | PIN_PUPDR_PULLUP(GPIOE_PIN7) | PIN_PUPDR_PULLUP(GPIOE_PIN8) | PIN_PUPDR_PULLUP(GPIOE_PIN9) | PIN_PUPDR_PULLUP(GPIOE_PIN10) | PIN_PUPDR_FLOATING(GPIOE_PIN11) | PIN_PUPDR_PULLUP(GPIOE_PIN12) | PIN_PUPDR_FLOATING(GPIOE_PIN13) | PIN_PUPDR_FLOATING(GPIOE_PIN14) | PIN_PUPDR_FLOATING(GPIOE_PIN15))
+#define VAL_GPIOE_ODR (PIN_ODR_HIGH(GPIOE_PIN0) | PIN_ODR_HIGH(GPIOE_PIN1) | PIN_ODR_HIGH(GPIOE_PIN2) | PIN_ODR_HIGH(GPIOE_PIN3) | PIN_ODR_HIGH(GPIOE_PIN4) | PIN_ODR_HIGH(GPIOE_PIN5) | PIN_ODR_HIGH(GPIOE_PIN6) | PIN_ODR_HIGH(GPIOE_PIN7) | PIN_ODR_LOW(GPIOE_PIN8) | PIN_ODR_LOW(GPIOE_PIN9) | PIN_ODR_LOW(GPIOE_PIN10) | PIN_ODR_LOW(GPIOE_PIN11) | PIN_ODR_LOW(GPIOE_PIN12) | PIN_ODR_LOW(GPIOE_PIN13) | PIN_ODR_LOW(GPIOE_PIN14) | PIN_ODR_LOW(GPIOE_PIN15))
+#define VAL_GPIOE_AFRL (PIN_AFIO_AF(GPIOE_PIN0, 0) | PIN_AFIO_AF(GPIOE_PIN1, 0) | PIN_AFIO_AF(GPIOE_PIN2, 0) | PIN_AFIO_AF(GPIOE_PIN3, 0) | PIN_AFIO_AF(GPIOE_PIN4, 0) | PIN_AFIO_AF(GPIOE_PIN5, 0) | PIN_AFIO_AF(GPIOE_PIN6, 0) | PIN_AFIO_AF(GPIOE_PIN7, 0))
+#define VAL_GPIOE_AFRH (PIN_AFIO_AF(GPIOE_PIN8, 0) | PIN_AFIO_AF(GPIOE_PIN9, 0) | PIN_AFIO_AF(GPIOE_PIN10, 0) | PIN_AFIO_AF(GPIOE_PIN11, 0) | PIN_AFIO_AF(GPIOE_PIN12, 0) | PIN_AFIO_AF(GPIOE_PIN13, 0) | PIN_AFIO_AF(GPIOE_PIN14, 0) | PIN_AFIO_AF(GPIOE_PIN15, 0))
/*
* GPIOF setup:
@@ -829,102 +383,13 @@
* PF14 - PIN14 (input pullup).
* PF15 - PIN15 (input pullup).
*/
-#define VAL_GPIOF_MODER (PIN_MODE_INPUT(GPIOF_I2C2_SDA) | \
- PIN_MODE_INPUT(GPIOF_I2C2_SCL) | \
- PIN_MODE_INPUT(GPIOF_PIN2) | \
- PIN_MODE_INPUT(GPIOF_PIN3) | \
- PIN_MODE_INPUT(GPIOF_PIN4) | \
- PIN_MODE_INPUT(GPIOF_PIN5) | \
- PIN_MODE_INPUT(GPIOF_PIN6) | \
- PIN_MODE_INPUT(GPIOF_PIN7) | \
- PIN_MODE_INPUT(GPIOF_PIN8) | \
- PIN_MODE_INPUT(GPIOF_PIN9) | \
- PIN_MODE_INPUT(GPIOF_PIN10) | \
- PIN_MODE_INPUT(GPIOF_PIN11) | \
- PIN_MODE_INPUT(GPIOF_PIN12) | \
- PIN_MODE_INPUT(GPIOF_PIN13) | \
- PIN_MODE_INPUT(GPIOF_PIN14) | \
- PIN_MODE_INPUT(GPIOF_PIN15))
-#define VAL_GPIOF_OTYPER (PIN_OTYPE_PUSHPULL(GPIOF_I2C2_SDA) | \
- PIN_OTYPE_PUSHPULL(GPIOF_I2C2_SCL) | \
- PIN_OTYPE_PUSHPULL(GPIOF_PIN2) | \
- PIN_OTYPE_PUSHPULL(GPIOF_PIN3) | \
- PIN_OTYPE_PUSHPULL(GPIOF_PIN4) | \
- PIN_OTYPE_PUSHPULL(GPIOF_PIN5) | \
- PIN_OTYPE_PUSHPULL(GPIOF_PIN6) | \
- PIN_OTYPE_PUSHPULL(GPIOF_PIN7) | \
- PIN_OTYPE_PUSHPULL(GPIOF_PIN8) | \
- PIN_OTYPE_PUSHPULL(GPIOF_PIN9) | \
- PIN_OTYPE_PUSHPULL(GPIOF_PIN10) | \
- PIN_OTYPE_PUSHPULL(GPIOF_PIN11) | \
- PIN_OTYPE_PUSHPULL(GPIOF_PIN12) | \
- PIN_OTYPE_PUSHPULL(GPIOF_PIN13) | \
- PIN_OTYPE_PUSHPULL(GPIOF_PIN14) | \
- PIN_OTYPE_PUSHPULL(GPIOF_PIN15))
-#define VAL_GPIOF_OSPEEDR (PIN_OSPEED_HIGH(GPIOF_I2C2_SDA) | \
- PIN_OSPEED_HIGH(GPIOF_I2C2_SCL) | \
- PIN_OSPEED_VERYLOW(GPIOF_PIN2) | \
- PIN_OSPEED_VERYLOW(GPIOF_PIN3) | \
- PIN_OSPEED_VERYLOW(GPIOF_PIN4) | \
- PIN_OSPEED_VERYLOW(GPIOF_PIN5) | \
- PIN_OSPEED_VERYLOW(GPIOF_PIN6) | \
- PIN_OSPEED_VERYLOW(GPIOF_PIN7) | \
- PIN_OSPEED_VERYLOW(GPIOF_PIN8) | \
- PIN_OSPEED_VERYLOW(GPIOF_PIN9) | \
- PIN_OSPEED_VERYLOW(GPIOF_PIN10) | \
- PIN_OSPEED_VERYLOW(GPIOF_PIN11) | \
- PIN_OSPEED_VERYLOW(GPIOF_PIN12) | \
- PIN_OSPEED_VERYLOW(GPIOF_PIN13) | \
- PIN_OSPEED_VERYLOW(GPIOF_PIN14) | \
- PIN_OSPEED_VERYLOW(GPIOF_PIN15))
-#define VAL_GPIOF_PUPDR (PIN_PUPDR_FLOATING(GPIOF_I2C2_SDA) | \
- PIN_PUPDR_FLOATING(GPIOF_I2C2_SCL) | \
- PIN_PUPDR_PULLUP(GPIOF_PIN2) | \
- PIN_PUPDR_PULLUP(GPIOF_PIN3) | \
- PIN_PUPDR_PULLUP(GPIOF_PIN4) | \
- PIN_PUPDR_PULLUP(GPIOF_PIN5) | \
- PIN_PUPDR_PULLUP(GPIOF_PIN6) | \
- PIN_PUPDR_PULLUP(GPIOF_PIN7) | \
- PIN_PUPDR_PULLUP(GPIOF_PIN8) | \
- PIN_PUPDR_PULLUP(GPIOF_PIN9) | \
- PIN_PUPDR_PULLUP(GPIOF_PIN10) | \
- PIN_PUPDR_PULLUP(GPIOF_PIN11) | \
- PIN_PUPDR_PULLUP(GPIOF_PIN12) | \
- PIN_PUPDR_PULLUP(GPIOF_PIN13) | \
- PIN_PUPDR_PULLUP(GPIOF_PIN14) | \
- PIN_PUPDR_PULLUP(GPIOF_PIN15))
-#define VAL_GPIOF_ODR (PIN_ODR_HIGH(GPIOF_I2C2_SDA) | \
- PIN_ODR_HIGH(GPIOF_I2C2_SCL) | \
- PIN_ODR_HIGH(GPIOF_PIN2) | \
- PIN_ODR_HIGH(GPIOF_PIN3) | \
- PIN_ODR_HIGH(GPIOF_PIN4) | \
- PIN_ODR_HIGH(GPIOF_PIN5) | \
- PIN_ODR_HIGH(GPIOF_PIN6) | \
- PIN_ODR_HIGH(GPIOF_PIN7) | \
- PIN_ODR_HIGH(GPIOF_PIN8) | \
- PIN_ODR_HIGH(GPIOF_PIN9) | \
- PIN_ODR_HIGH(GPIOF_PIN10) | \
- PIN_ODR_HIGH(GPIOF_PIN11) | \
- PIN_ODR_HIGH(GPIOF_PIN12) | \
- PIN_ODR_HIGH(GPIOF_PIN13) | \
- PIN_ODR_HIGH(GPIOF_PIN14) | \
- PIN_ODR_HIGH(GPIOF_PIN15))
-#define VAL_GPIOF_AFRL (PIN_AFIO_AF(GPIOF_I2C2_SDA, 0) | \
- PIN_AFIO_AF(GPIOF_I2C2_SCL, 0) | \
- PIN_AFIO_AF(GPIOF_PIN2, 0) | \
- PIN_AFIO_AF(GPIOF_PIN3, 0) | \
- PIN_AFIO_AF(GPIOF_PIN4, 0) | \
- PIN_AFIO_AF(GPIOF_PIN5, 0) | \
- PIN_AFIO_AF(GPIOF_PIN6, 0) | \
- PIN_AFIO_AF(GPIOF_PIN7, 0))
-#define VAL_GPIOF_AFRH (PIN_AFIO_AF(GPIOF_PIN8, 0) | \
- PIN_AFIO_AF(GPIOF_PIN9, 0) | \
- PIN_AFIO_AF(GPIOF_PIN10, 0) | \
- PIN_AFIO_AF(GPIOF_PIN11, 0) | \
- PIN_AFIO_AF(GPIOF_PIN12, 0) | \
- PIN_AFIO_AF(GPIOF_PIN13, 0) | \
- PIN_AFIO_AF(GPIOF_PIN14, 0) | \
- PIN_AFIO_AF(GPIOF_PIN15, 0))
+#define VAL_GPIOF_MODER (PIN_MODE_INPUT(GPIOF_I2C2_SDA) | PIN_MODE_INPUT(GPIOF_I2C2_SCL) | PIN_MODE_INPUT(GPIOF_PIN2) | PIN_MODE_INPUT(GPIOF_PIN3) | PIN_MODE_INPUT(GPIOF_PIN4) | PIN_MODE_INPUT(GPIOF_PIN5) | PIN_MODE_INPUT(GPIOF_PIN6) | PIN_MODE_INPUT(GPIOF_PIN7) | PIN_MODE_INPUT(GPIOF_PIN8) | PIN_MODE_INPUT(GPIOF_PIN9) | PIN_MODE_INPUT(GPIOF_PIN10) | PIN_MODE_INPUT(GPIOF_PIN11) | PIN_MODE_INPUT(GPIOF_PIN12) | PIN_MODE_INPUT(GPIOF_PIN13) | PIN_MODE_INPUT(GPIOF_PIN14) | PIN_MODE_INPUT(GPIOF_PIN15))
+#define VAL_GPIOF_OTYPER (PIN_OTYPE_PUSHPULL(GPIOF_I2C2_SDA) | PIN_OTYPE_PUSHPULL(GPIOF_I2C2_SCL) | PIN_OTYPE_PUSHPULL(GPIOF_PIN2) | PIN_OTYPE_PUSHPULL(GPIOF_PIN3) | PIN_OTYPE_PUSHPULL(GPIOF_PIN4) | PIN_OTYPE_PUSHPULL(GPIOF_PIN5) | PIN_OTYPE_PUSHPULL(GPIOF_PIN6) | PIN_OTYPE_PUSHPULL(GPIOF_PIN7) | PIN_OTYPE_PUSHPULL(GPIOF_PIN8) | PIN_OTYPE_PUSHPULL(GPIOF_PIN9) | PIN_OTYPE_PUSHPULL(GPIOF_PIN10) | PIN_OTYPE_PUSHPULL(GPIOF_PIN11) | PIN_OTYPE_PUSHPULL(GPIOF_PIN12) | PIN_OTYPE_PUSHPULL(GPIOF_PIN13) | PIN_OTYPE_PUSHPULL(GPIOF_PIN14) | PIN_OTYPE_PUSHPULL(GPIOF_PIN15))
+#define VAL_GPIOF_OSPEEDR (PIN_OSPEED_HIGH(GPIOF_I2C2_SDA) | PIN_OSPEED_HIGH(GPIOF_I2C2_SCL) | PIN_OSPEED_VERYLOW(GPIOF_PIN2) | PIN_OSPEED_VERYLOW(GPIOF_PIN3) | PIN_OSPEED_VERYLOW(GPIOF_PIN4) | PIN_OSPEED_VERYLOW(GPIOF_PIN5) | PIN_OSPEED_VERYLOW(GPIOF_PIN6) | PIN_OSPEED_VERYLOW(GPIOF_PIN7) | PIN_OSPEED_VERYLOW(GPIOF_PIN8) | PIN_OSPEED_VERYLOW(GPIOF_PIN9) | PIN_OSPEED_VERYLOW(GPIOF_PIN10) | PIN_OSPEED_VERYLOW(GPIOF_PIN11) | PIN_OSPEED_VERYLOW(GPIOF_PIN12) | PIN_OSPEED_VERYLOW(GPIOF_PIN13) | PIN_OSPEED_VERYLOW(GPIOF_PIN14) | PIN_OSPEED_VERYLOW(GPIOF_PIN15))
+#define VAL_GPIOF_PUPDR (PIN_PUPDR_FLOATING(GPIOF_I2C2_SDA) | PIN_PUPDR_FLOATING(GPIOF_I2C2_SCL) | PIN_PUPDR_PULLUP(GPIOF_PIN2) | PIN_PUPDR_PULLUP(GPIOF_PIN3) | PIN_PUPDR_PULLUP(GPIOF_PIN4) | PIN_PUPDR_PULLUP(GPIOF_PIN5) | PIN_PUPDR_PULLUP(GPIOF_PIN6) | PIN_PUPDR_PULLUP(GPIOF_PIN7) | PIN_PUPDR_PULLUP(GPIOF_PIN8) | PIN_PUPDR_PULLUP(GPIOF_PIN9) | PIN_PUPDR_PULLUP(GPIOF_PIN10) | PIN_PUPDR_PULLUP(GPIOF_PIN11) | PIN_PUPDR_PULLUP(GPIOF_PIN12) | PIN_PUPDR_PULLUP(GPIOF_PIN13) | PIN_PUPDR_PULLUP(GPIOF_PIN14) | PIN_PUPDR_PULLUP(GPIOF_PIN15))
+#define VAL_GPIOF_ODR (PIN_ODR_HIGH(GPIOF_I2C2_SDA) | PIN_ODR_HIGH(GPIOF_I2C2_SCL) | PIN_ODR_HIGH(GPIOF_PIN2) | PIN_ODR_HIGH(GPIOF_PIN3) | PIN_ODR_HIGH(GPIOF_PIN4) | PIN_ODR_HIGH(GPIOF_PIN5) | PIN_ODR_HIGH(GPIOF_PIN6) | PIN_ODR_HIGH(GPIOF_PIN7) | PIN_ODR_HIGH(GPIOF_PIN8) | PIN_ODR_HIGH(GPIOF_PIN9) | PIN_ODR_HIGH(GPIOF_PIN10) | PIN_ODR_HIGH(GPIOF_PIN11) | PIN_ODR_HIGH(GPIOF_PIN12) | PIN_ODR_HIGH(GPIOF_PIN13) | PIN_ODR_HIGH(GPIOF_PIN14) | PIN_ODR_HIGH(GPIOF_PIN15))
+#define VAL_GPIOF_AFRL (PIN_AFIO_AF(GPIOF_I2C2_SDA, 0) | PIN_AFIO_AF(GPIOF_I2C2_SCL, 0) | PIN_AFIO_AF(GPIOF_PIN2, 0) | PIN_AFIO_AF(GPIOF_PIN3, 0) | PIN_AFIO_AF(GPIOF_PIN4, 0) | PIN_AFIO_AF(GPIOF_PIN5, 0) | PIN_AFIO_AF(GPIOF_PIN6, 0) | PIN_AFIO_AF(GPIOF_PIN7, 0))
+#define VAL_GPIOF_AFRH (PIN_AFIO_AF(GPIOF_PIN8, 0) | PIN_AFIO_AF(GPIOF_PIN9, 0) | PIN_AFIO_AF(GPIOF_PIN10, 0) | PIN_AFIO_AF(GPIOF_PIN11, 0) | PIN_AFIO_AF(GPIOF_PIN12, 0) | PIN_AFIO_AF(GPIOF_PIN13, 0) | PIN_AFIO_AF(GPIOF_PIN14, 0) | PIN_AFIO_AF(GPIOF_PIN15, 0))
/*
* GPIOG setup:
@@ -946,102 +411,13 @@
* PG14 - PIN14 (input pullup).
* PG15 - PIN15 (input pullup).
*/
-#define VAL_GPIOG_MODER (PIN_MODE_INPUT(GPIOG_PIN0) | \
- PIN_MODE_INPUT(GPIOG_PIN1) | \
- PIN_MODE_INPUT(GPIOG_PIN2) | \
- PIN_MODE_INPUT(GPIOG_PIN3) | \
- PIN_MODE_INPUT(GPIOG_PIN4) | \
- PIN_MODE_INPUT(GPIOG_PIN5) | \
- PIN_MODE_INPUT(GPIOG_PIN6) | \
- PIN_MODE_INPUT(GPIOG_PIN7) | \
- PIN_MODE_INPUT(GPIOG_PIN8) | \
- PIN_MODE_INPUT(GPIOG_PIN9) | \
- PIN_MODE_INPUT(GPIOG_PIN10) | \
- PIN_MODE_INPUT(GPIOG_PIN11) | \
- PIN_MODE_INPUT(GPIOG_PIN12) | \
- PIN_MODE_INPUT(GPIOG_PIN13) | \
- PIN_MODE_INPUT(GPIOG_PIN14) | \
- PIN_MODE_INPUT(GPIOG_PIN15))
-#define VAL_GPIOG_OTYPER (PIN_OTYPE_PUSHPULL(GPIOG_PIN0) | \
- PIN_OTYPE_PUSHPULL(GPIOG_PIN1) | \
- PIN_OTYPE_PUSHPULL(GPIOG_PIN2) | \
- PIN_OTYPE_PUSHPULL(GPIOG_PIN3) | \
- PIN_OTYPE_PUSHPULL(GPIOG_PIN4) | \
- PIN_OTYPE_PUSHPULL(GPIOG_PIN5) | \
- PIN_OTYPE_PUSHPULL(GPIOG_PIN6) | \
- PIN_OTYPE_PUSHPULL(GPIOG_PIN7) | \
- PIN_OTYPE_PUSHPULL(GPIOG_PIN8) | \
- PIN_OTYPE_PUSHPULL(GPIOG_PIN9) | \
- PIN_OTYPE_PUSHPULL(GPIOG_PIN10) | \
- PIN_OTYPE_PUSHPULL(GPIOG_PIN11) | \
- PIN_OTYPE_PUSHPULL(GPIOG_PIN12) | \
- PIN_OTYPE_PUSHPULL(GPIOG_PIN13) | \
- PIN_OTYPE_PUSHPULL(GPIOG_PIN14) | \
- PIN_OTYPE_PUSHPULL(GPIOG_PIN15))
-#define VAL_GPIOG_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOG_PIN0) | \
- PIN_OSPEED_VERYLOW(GPIOG_PIN1) | \
- PIN_OSPEED_VERYLOW(GPIOG_PIN2) | \
- PIN_OSPEED_VERYLOW(GPIOG_PIN3) | \
- PIN_OSPEED_VERYLOW(GPIOG_PIN4) | \
- PIN_OSPEED_VERYLOW(GPIOG_PIN5) | \
- PIN_OSPEED_VERYLOW(GPIOG_PIN6) | \
- PIN_OSPEED_VERYLOW(GPIOG_PIN7) | \
- PIN_OSPEED_VERYLOW(GPIOG_PIN8) | \
- PIN_OSPEED_VERYLOW(GPIOG_PIN9) | \
- PIN_OSPEED_VERYLOW(GPIOG_PIN10) | \
- PIN_OSPEED_VERYLOW(GPIOG_PIN11) | \
- PIN_OSPEED_VERYLOW(GPIOG_PIN12) | \
- PIN_OSPEED_VERYLOW(GPIOG_PIN13) | \
- PIN_OSPEED_VERYLOW(GPIOG_PIN14) | \
- PIN_OSPEED_VERYLOW(GPIOG_PIN15))
-#define VAL_GPIOG_PUPDR (PIN_PUPDR_PULLUP(GPIOG_PIN0) | \
- PIN_PUPDR_PULLUP(GPIOG_PIN1) | \
- PIN_PUPDR_PULLUP(GPIOG_PIN2) | \
- PIN_PUPDR_PULLUP(GPIOG_PIN3) | \
- PIN_PUPDR_PULLUP(GPIOG_PIN4) | \
- PIN_PUPDR_PULLUP(GPIOG_PIN5) | \
- PIN_PUPDR_PULLUP(GPIOG_PIN6) | \
- PIN_PUPDR_PULLUP(GPIOG_PIN7) | \
- PIN_PUPDR_PULLUP(GPIOG_PIN8) | \
- PIN_PUPDR_PULLUP(GPIOG_PIN9) | \
- PIN_PUPDR_PULLUP(GPIOG_PIN10) | \
- PIN_PUPDR_PULLUP(GPIOG_PIN11) | \
- PIN_PUPDR_PULLUP(GPIOG_PIN12) | \
- PIN_PUPDR_PULLUP(GPIOG_PIN13) | \
- PIN_PUPDR_PULLUP(GPIOG_PIN14) | \
- PIN_PUPDR_PULLUP(GPIOG_PIN15))
-#define VAL_GPIOG_ODR (PIN_ODR_HIGH(GPIOG_PIN0) | \
- PIN_ODR_HIGH(GPIOG_PIN1) | \
- PIN_ODR_HIGH(GPIOG_PIN2) | \
- PIN_ODR_HIGH(GPIOG_PIN3) | \
- PIN_ODR_HIGH(GPIOG_PIN4) | \
- PIN_ODR_HIGH(GPIOG_PIN5) | \
- PIN_ODR_HIGH(GPIOG_PIN6) | \
- PIN_ODR_HIGH(GPIOG_PIN7) | \
- PIN_ODR_HIGH(GPIOG_PIN8) | \
- PIN_ODR_HIGH(GPIOG_PIN9) | \
- PIN_ODR_HIGH(GPIOG_PIN10) | \
- PIN_ODR_HIGH(GPIOG_PIN11) | \
- PIN_ODR_HIGH(GPIOG_PIN12) | \
- PIN_ODR_HIGH(GPIOG_PIN13) | \
- PIN_ODR_HIGH(GPIOG_PIN14) | \
- PIN_ODR_HIGH(GPIOG_PIN15))
-#define VAL_GPIOG_AFRL (PIN_AFIO_AF(GPIOG_PIN0, 0) | \
- PIN_AFIO_AF(GPIOG_PIN1, 0) | \
- PIN_AFIO_AF(GPIOG_PIN2, 0) | \
- PIN_AFIO_AF(GPIOG_PIN3, 0) | \
- PIN_AFIO_AF(GPIOG_PIN4, 0) | \
- PIN_AFIO_AF(GPIOG_PIN5, 0) | \
- PIN_AFIO_AF(GPIOG_PIN6, 0) | \
- PIN_AFIO_AF(GPIOG_PIN7, 0))
-#define VAL_GPIOG_AFRH (PIN_AFIO_AF(GPIOG_PIN8, 0) | \
- PIN_AFIO_AF(GPIOG_PIN9, 0) | \
- PIN_AFIO_AF(GPIOG_PIN10, 0) | \
- PIN_AFIO_AF(GPIOG_PIN11, 0) | \
- PIN_AFIO_AF(GPIOG_PIN12, 0) | \
- PIN_AFIO_AF(GPIOG_PIN13, 0) | \
- PIN_AFIO_AF(GPIOG_PIN14, 0) | \
- PIN_AFIO_AF(GPIOG_PIN15, 0))
+#define VAL_GPIOG_MODER (PIN_MODE_INPUT(GPIOG_PIN0) | PIN_MODE_INPUT(GPIOG_PIN1) | PIN_MODE_INPUT(GPIOG_PIN2) | PIN_MODE_INPUT(GPIOG_PIN3) | PIN_MODE_INPUT(GPIOG_PIN4) | PIN_MODE_INPUT(GPIOG_PIN5) | PIN_MODE_INPUT(GPIOG_PIN6) | PIN_MODE_INPUT(GPIOG_PIN7) | PIN_MODE_INPUT(GPIOG_PIN8) | PIN_MODE_INPUT(GPIOG_PIN9) | PIN_MODE_INPUT(GPIOG_PIN10) | PIN_MODE_INPUT(GPIOG_PIN11) | PIN_MODE_INPUT(GPIOG_PIN12) | PIN_MODE_INPUT(GPIOG_PIN13) | PIN_MODE_INPUT(GPIOG_PIN14) | PIN_MODE_INPUT(GPIOG_PIN15))
+#define VAL_GPIOG_OTYPER (PIN_OTYPE_PUSHPULL(GPIOG_PIN0) | PIN_OTYPE_PUSHPULL(GPIOG_PIN1) | PIN_OTYPE_PUSHPULL(GPIOG_PIN2) | PIN_OTYPE_PUSHPULL(GPIOG_PIN3) | PIN_OTYPE_PUSHPULL(GPIOG_PIN4) | PIN_OTYPE_PUSHPULL(GPIOG_PIN5) | PIN_OTYPE_PUSHPULL(GPIOG_PIN6) | PIN_OTYPE_PUSHPULL(GPIOG_PIN7) | PIN_OTYPE_PUSHPULL(GPIOG_PIN8) | PIN_OTYPE_PUSHPULL(GPIOG_PIN9) | PIN_OTYPE_PUSHPULL(GPIOG_PIN10) | PIN_OTYPE_PUSHPULL(GPIOG_PIN11) | PIN_OTYPE_PUSHPULL(GPIOG_PIN12) | PIN_OTYPE_PUSHPULL(GPIOG_PIN13) | PIN_OTYPE_PUSHPULL(GPIOG_PIN14) | PIN_OTYPE_PUSHPULL(GPIOG_PIN15))
+#define VAL_GPIOG_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOG_PIN0) | PIN_OSPEED_VERYLOW(GPIOG_PIN1) | PIN_OSPEED_VERYLOW(GPIOG_PIN2) | PIN_OSPEED_VERYLOW(GPIOG_PIN3) | PIN_OSPEED_VERYLOW(GPIOG_PIN4) | PIN_OSPEED_VERYLOW(GPIOG_PIN5) | PIN_OSPEED_VERYLOW(GPIOG_PIN6) | PIN_OSPEED_VERYLOW(GPIOG_PIN7) | PIN_OSPEED_VERYLOW(GPIOG_PIN8) | PIN_OSPEED_VERYLOW(GPIOG_PIN9) | PIN_OSPEED_VERYLOW(GPIOG_PIN10) | PIN_OSPEED_VERYLOW(GPIOG_PIN11) | PIN_OSPEED_VERYLOW(GPIOG_PIN12) | PIN_OSPEED_VERYLOW(GPIOG_PIN13) | PIN_OSPEED_VERYLOW(GPIOG_PIN14) | PIN_OSPEED_VERYLOW(GPIOG_PIN15))
+#define VAL_GPIOG_PUPDR (PIN_PUPDR_PULLUP(GPIOG_PIN0) | PIN_PUPDR_PULLUP(GPIOG_PIN1) | PIN_PUPDR_PULLUP(GPIOG_PIN2) | PIN_PUPDR_PULLUP(GPIOG_PIN3) | PIN_PUPDR_PULLUP(GPIOG_PIN4) | PIN_PUPDR_PULLUP(GPIOG_PIN5) | PIN_PUPDR_PULLUP(GPIOG_PIN6) | PIN_PUPDR_PULLUP(GPIOG_PIN7) | PIN_PUPDR_PULLUP(GPIOG_PIN8) | PIN_PUPDR_PULLUP(GPIOG_PIN9) | PIN_PUPDR_PULLUP(GPIOG_PIN10) | PIN_PUPDR_PULLUP(GPIOG_PIN11) | PIN_PUPDR_PULLUP(GPIOG_PIN12) | PIN_PUPDR_PULLUP(GPIOG_PIN13) | PIN_PUPDR_PULLUP(GPIOG_PIN14) | PIN_PUPDR_PULLUP(GPIOG_PIN15))
+#define VAL_GPIOG_ODR (PIN_ODR_HIGH(GPIOG_PIN0) | PIN_ODR_HIGH(GPIOG_PIN1) | PIN_ODR_HIGH(GPIOG_PIN2) | PIN_ODR_HIGH(GPIOG_PIN3) | PIN_ODR_HIGH(GPIOG_PIN4) | PIN_ODR_HIGH(GPIOG_PIN5) | PIN_ODR_HIGH(GPIOG_PIN6) | PIN_ODR_HIGH(GPIOG_PIN7) | PIN_ODR_HIGH(GPIOG_PIN8) | PIN_ODR_HIGH(GPIOG_PIN9) | PIN_ODR_HIGH(GPIOG_PIN10) | PIN_ODR_HIGH(GPIOG_PIN11) | PIN_ODR_HIGH(GPIOG_PIN12) | PIN_ODR_HIGH(GPIOG_PIN13) | PIN_ODR_HIGH(GPIOG_PIN14) | PIN_ODR_HIGH(GPIOG_PIN15))
+#define VAL_GPIOG_AFRL (PIN_AFIO_AF(GPIOG_PIN0, 0) | PIN_AFIO_AF(GPIOG_PIN1, 0) | PIN_AFIO_AF(GPIOG_PIN2, 0) | PIN_AFIO_AF(GPIOG_PIN3, 0) | PIN_AFIO_AF(GPIOG_PIN4, 0) | PIN_AFIO_AF(GPIOG_PIN5, 0) | PIN_AFIO_AF(GPIOG_PIN6, 0) | PIN_AFIO_AF(GPIOG_PIN7, 0))
+#define VAL_GPIOG_AFRH (PIN_AFIO_AF(GPIOG_PIN8, 0) | PIN_AFIO_AF(GPIOG_PIN9, 0) | PIN_AFIO_AF(GPIOG_PIN10, 0) | PIN_AFIO_AF(GPIOG_PIN11, 0) | PIN_AFIO_AF(GPIOG_PIN12, 0) | PIN_AFIO_AF(GPIOG_PIN13, 0) | PIN_AFIO_AF(GPIOG_PIN14, 0) | PIN_AFIO_AF(GPIOG_PIN15, 0))
/*
* GPIOH setup:
@@ -1063,103 +439,13 @@
* PH14 - PIN14 (input pullup).
* PH15 - PIN15 (input pullup).
*/
-#define VAL_GPIOH_MODER (PIN_MODE_INPUT(GPIOH_PIN0) | \
- PIN_MODE_INPUT(GPIOH_PIN1) | \
- PIN_MODE_INPUT(GPIOH_PIN2) | \
- PIN_MODE_INPUT(GPIOH_PIN3) | \
- PIN_MODE_INPUT(GPIOH_PIN4) | \
- PIN_MODE_INPUT(GPIOH_PIN5) | \
- PIN_MODE_INPUT(GPIOH_PIN6) | \
- PIN_MODE_INPUT(GPIOH_PIN7) | \
- PIN_MODE_INPUT(GPIOH_PIN8) | \
- PIN_MODE_INPUT(GPIOH_PIN9) | \
- PIN_MODE_INPUT(GPIOH_PIN10) | \
- PIN_MODE_INPUT(GPIOH_PIN11) | \
- PIN_MODE_INPUT(GPIOH_PIN12) | \
- PIN_MODE_INPUT(GPIOH_PIN13) | \
- PIN_MODE_INPUT(GPIOH_PIN14) | \
- PIN_MODE_INPUT(GPIOH_PIN15))
-#define VAL_GPIOH_OTYPER (PIN_OTYPE_PUSHPULL(GPIOH_PIN0) | \
- PIN_OTYPE_PUSHPULL(GPIOH_PIN1) | \
- PIN_OTYPE_PUSHPULL(GPIOH_PIN2) | \
- PIN_OTYPE_PUSHPULL(GPIOH_PIN3) | \
- PIN_OTYPE_PUSHPULL(GPIOH_PIN4) | \
- PIN_OTYPE_PUSHPULL(GPIOH_PIN5) | \
- PIN_OTYPE_PUSHPULL(GPIOH_PIN6) | \
- PIN_OTYPE_PUSHPULL(GPIOH_PIN7) | \
- PIN_OTYPE_PUSHPULL(GPIOH_PIN8) | \
- PIN_OTYPE_PUSHPULL(GPIOH_PIN9) | \
- PIN_OTYPE_PUSHPULL(GPIOH_PIN10) | \
- PIN_OTYPE_PUSHPULL(GPIOH_PIN11) | \
- PIN_OTYPE_PUSHPULL(GPIOH_PIN12) | \
- PIN_OTYPE_PUSHPULL(GPIOH_PIN13) | \
- PIN_OTYPE_PUSHPULL(GPIOH_PIN14) | \
- PIN_OTYPE_PUSHPULL(GPIOH_PIN15))
-#define VAL_GPIOH_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOH_PIN0) | \
- PIN_OSPEED_VERYLOW(GPIOH_PIN1) | \
- PIN_OSPEED_VERYLOW(GPIOH_PIN2) | \
- PIN_OSPEED_VERYLOW(GPIOH_PIN3) | \
- PIN_OSPEED_VERYLOW(GPIOH_PIN4) | \
- PIN_OSPEED_VERYLOW(GPIOH_PIN5) | \
- PIN_OSPEED_VERYLOW(GPIOH_PIN6) | \
- PIN_OSPEED_VERYLOW(GPIOH_PIN7) | \
- PIN_OSPEED_VERYLOW(GPIOH_PIN8) | \
- PIN_OSPEED_VERYLOW(GPIOH_PIN9) | \
- PIN_OSPEED_VERYLOW(GPIOH_PIN10) | \
- PIN_OSPEED_VERYLOW(GPIOH_PIN11) | \
- PIN_OSPEED_VERYLOW(GPIOH_PIN12) | \
- PIN_OSPEED_VERYLOW(GPIOH_PIN13) | \
- PIN_OSPEED_VERYLOW(GPIOH_PIN14) | \
- PIN_OSPEED_VERYLOW(GPIOH_PIN15))
-#define VAL_GPIOH_PUPDR (PIN_PUPDR_PULLUP(GPIOH_PIN0) | \
- PIN_PUPDR_PULLUP(GPIOH_PIN1) | \
- PIN_PUPDR_PULLUP(GPIOH_PIN2) | \
- PIN_PUPDR_PULLUP(GPIOH_PIN3) | \
- PIN_PUPDR_PULLUP(GPIOH_PIN4) | \
- PIN_PUPDR_PULLUP(GPIOH_PIN5) | \
- PIN_PUPDR_PULLUP(GPIOH_PIN6) | \
- PIN_PUPDR_PULLUP(GPIOH_PIN7) | \
- PIN_PUPDR_PULLUP(GPIOH_PIN8) | \
- PIN_PUPDR_PULLUP(GPIOH_PIN9) | \
- PIN_PUPDR_PULLUP(GPIOH_PIN10) | \
- PIN_PUPDR_PULLUP(GPIOH_PIN11) | \
- PIN_PUPDR_PULLUP(GPIOH_PIN12) | \
- PIN_PUPDR_PULLUP(GPIOH_PIN13) | \
- PIN_PUPDR_PULLUP(GPIOH_PIN14) | \
- PIN_PUPDR_PULLUP(GPIOH_PIN15))
-#define VAL_GPIOH_ODR (PIN_ODR_HIGH(GPIOH_PIN0) | \
- PIN_ODR_HIGH(GPIOH_PIN1) | \
- PIN_ODR_HIGH(GPIOH_PIN2) | \
- PIN_ODR_HIGH(GPIOH_PIN3) | \
- PIN_ODR_HIGH(GPIOH_PIN4) | \
- PIN_ODR_HIGH(GPIOH_PIN5) | \
- PIN_ODR_HIGH(GPIOH_PIN6) | \
- PIN_ODR_HIGH(GPIOH_PIN7) | \
- PIN_ODR_HIGH(GPIOH_PIN8) | \
- PIN_ODR_HIGH(GPIOH_PIN9) | \
- PIN_ODR_HIGH(GPIOH_PIN10) | \
- PIN_ODR_HIGH(GPIOH_PIN11) | \
- PIN_ODR_HIGH(GPIOH_PIN12) | \
- PIN_ODR_HIGH(GPIOH_PIN13) | \
- PIN_ODR_HIGH(GPIOH_PIN14) | \
- PIN_ODR_HIGH(GPIOH_PIN15))
-#define VAL_GPIOH_AFRL (PIN_AFIO_AF(GPIOH_PIN0, 0) | \
- PIN_AFIO_AF(GPIOH_PIN1, 0) | \
- PIN_AFIO_AF(GPIOH_PIN2, 0) | \
- PIN_AFIO_AF(GPIOH_PIN3, 0) | \
- PIN_AFIO_AF(GPIOH_PIN4, 0) | \
- PIN_AFIO_AF(GPIOH_PIN5, 0) | \
- PIN_AFIO_AF(GPIOH_PIN6, 0) | \
- PIN_AFIO_AF(GPIOH_PIN7, 0))
-#define VAL_GPIOH_AFRH (PIN_AFIO_AF(GPIOH_PIN8, 0) | \
- PIN_AFIO_AF(GPIOH_PIN9, 0) | \
- PIN_AFIO_AF(GPIOH_PIN10, 0) | \
- PIN_AFIO_AF(GPIOH_PIN11, 0) | \
- PIN_AFIO_AF(GPIOH_PIN12, 0) | \
- PIN_AFIO_AF(GPIOH_PIN13, 0) | \
- PIN_AFIO_AF(GPIOH_PIN14, 0) | \
- PIN_AFIO_AF(GPIOH_PIN15, 0))
-
+#define VAL_GPIOH_MODER (PIN_MODE_INPUT(GPIOH_PIN0) | PIN_MODE_INPUT(GPIOH_PIN1) | PIN_MODE_INPUT(GPIOH_PIN2) | PIN_MODE_INPUT(GPIOH_PIN3) | PIN_MODE_INPUT(GPIOH_PIN4) | PIN_MODE_INPUT(GPIOH_PIN5) | PIN_MODE_INPUT(GPIOH_PIN6) | PIN_MODE_INPUT(GPIOH_PIN7) | PIN_MODE_INPUT(GPIOH_PIN8) | PIN_MODE_INPUT(GPIOH_PIN9) | PIN_MODE_INPUT(GPIOH_PIN10) | PIN_MODE_INPUT(GPIOH_PIN11) | PIN_MODE_INPUT(GPIOH_PIN12) | PIN_MODE_INPUT(GPIOH_PIN13) | PIN_MODE_INPUT(GPIOH_PIN14) | PIN_MODE_INPUT(GPIOH_PIN15))
+#define VAL_GPIOH_OTYPER (PIN_OTYPE_PUSHPULL(GPIOH_PIN0) | PIN_OTYPE_PUSHPULL(GPIOH_PIN1) | PIN_OTYPE_PUSHPULL(GPIOH_PIN2) | PIN_OTYPE_PUSHPULL(GPIOH_PIN3) | PIN_OTYPE_PUSHPULL(GPIOH_PIN4) | PIN_OTYPE_PUSHPULL(GPIOH_PIN5) | PIN_OTYPE_PUSHPULL(GPIOH_PIN6) | PIN_OTYPE_PUSHPULL(GPIOH_PIN7) | PIN_OTYPE_PUSHPULL(GPIOH_PIN8) | PIN_OTYPE_PUSHPULL(GPIOH_PIN9) | PIN_OTYPE_PUSHPULL(GPIOH_PIN10) | PIN_OTYPE_PUSHPULL(GPIOH_PIN11) | PIN_OTYPE_PUSHPULL(GPIOH_PIN12) | PIN_OTYPE_PUSHPULL(GPIOH_PIN13) | PIN_OTYPE_PUSHPULL(GPIOH_PIN14) | PIN_OTYPE_PUSHPULL(GPIOH_PIN15))
+#define VAL_GPIOH_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOH_PIN0) | PIN_OSPEED_VERYLOW(GPIOH_PIN1) | PIN_OSPEED_VERYLOW(GPIOH_PIN2) | PIN_OSPEED_VERYLOW(GPIOH_PIN3) | PIN_OSPEED_VERYLOW(GPIOH_PIN4) | PIN_OSPEED_VERYLOW(GPIOH_PIN5) | PIN_OSPEED_VERYLOW(GPIOH_PIN6) | PIN_OSPEED_VERYLOW(GPIOH_PIN7) | PIN_OSPEED_VERYLOW(GPIOH_PIN8) | PIN_OSPEED_VERYLOW(GPIOH_PIN9) | PIN_OSPEED_VERYLOW(GPIOH_PIN10) | PIN_OSPEED_VERYLOW(GPIOH_PIN11) | PIN_OSPEED_VERYLOW(GPIOH_PIN12) | PIN_OSPEED_VERYLOW(GPIOH_PIN13) | PIN_OSPEED_VERYLOW(GPIOH_PIN14) | PIN_OSPEED_VERYLOW(GPIOH_PIN15))
+#define VAL_GPIOH_PUPDR (PIN_PUPDR_PULLUP(GPIOH_PIN0) | PIN_PUPDR_PULLUP(GPIOH_PIN1) | PIN_PUPDR_PULLUP(GPIOH_PIN2) | PIN_PUPDR_PULLUP(GPIOH_PIN3) | PIN_PUPDR_PULLUP(GPIOH_PIN4) | PIN_PUPDR_PULLUP(GPIOH_PIN5) | PIN_PUPDR_PULLUP(GPIOH_PIN6) | PIN_PUPDR_PULLUP(GPIOH_PIN7) | PIN_PUPDR_PULLUP(GPIOH_PIN8) | PIN_PUPDR_PULLUP(GPIOH_PIN9) | PIN_PUPDR_PULLUP(GPIOH_PIN10) | PIN_PUPDR_PULLUP(GPIOH_PIN11) | PIN_PUPDR_PULLUP(GPIOH_PIN12) | PIN_PUPDR_PULLUP(GPIOH_PIN13) | PIN_PUPDR_PULLUP(GPIOH_PIN14) | PIN_PUPDR_PULLUP(GPIOH_PIN15))
+#define VAL_GPIOH_ODR (PIN_ODR_HIGH(GPIOH_PIN0) | PIN_ODR_HIGH(GPIOH_PIN1) | PIN_ODR_HIGH(GPIOH_PIN2) | PIN_ODR_HIGH(GPIOH_PIN3) | PIN_ODR_HIGH(GPIOH_PIN4) | PIN_ODR_HIGH(GPIOH_PIN5) | PIN_ODR_HIGH(GPIOH_PIN6) | PIN_ODR_HIGH(GPIOH_PIN7) | PIN_ODR_HIGH(GPIOH_PIN8) | PIN_ODR_HIGH(GPIOH_PIN9) | PIN_ODR_HIGH(GPIOH_PIN10) | PIN_ODR_HIGH(GPIOH_PIN11) | PIN_ODR_HIGH(GPIOH_PIN12) | PIN_ODR_HIGH(GPIOH_PIN13) | PIN_ODR_HIGH(GPIOH_PIN14) | PIN_ODR_HIGH(GPIOH_PIN15))
+#define VAL_GPIOH_AFRL (PIN_AFIO_AF(GPIOH_PIN0, 0) | PIN_AFIO_AF(GPIOH_PIN1, 0) | PIN_AFIO_AF(GPIOH_PIN2, 0) | PIN_AFIO_AF(GPIOH_PIN3, 0) | PIN_AFIO_AF(GPIOH_PIN4, 0) | PIN_AFIO_AF(GPIOH_PIN5, 0) | PIN_AFIO_AF(GPIOH_PIN6, 0) | PIN_AFIO_AF(GPIOH_PIN7, 0))
+#define VAL_GPIOH_AFRH (PIN_AFIO_AF(GPIOH_PIN8, 0) | PIN_AFIO_AF(GPIOH_PIN9, 0) | PIN_AFIO_AF(GPIOH_PIN10, 0) | PIN_AFIO_AF(GPIOH_PIN11, 0) | PIN_AFIO_AF(GPIOH_PIN12, 0) | PIN_AFIO_AF(GPIOH_PIN13, 0) | PIN_AFIO_AF(GPIOH_PIN14, 0) | PIN_AFIO_AF(GPIOH_PIN15, 0))
/*
* USB bus activation macro, required by the USB driver.
@@ -1171,17 +457,19 @@
* USB bus de-activation macro, required by the USB driver.
*/
// #define usb_lld_disconnect_bus(usbp)
-#define usb_lld_disconnect_bus(usbp) (palSetPadMode(GPIOA, GPIOA_USB_DP, PAL_MODE_OUTPUT_PUSHPULL)); palClearPad(GPIOA, GPIOA_USB_DP)
+#define usb_lld_disconnect_bus(usbp) \
+ (palSetPadMode(GPIOA, GPIOA_USB_DP, PAL_MODE_OUTPUT_PUSHPULL)); \
+ palClearPad(GPIOA, GPIOA_USB_DP)
// #define usb_lld_disconnect_bus(usbp) palSetPadMode(GPIOA, 12, PAL_MODE_OUTPUT_PUSHPULL); palClearPad(GPIOA, 12)
#if !defined(_FROM_ASM_)
-#ifdef __cplusplus
+# ifdef __cplusplus
extern "C" {
-#endif
- void boardInit(void);
-#ifdef __cplusplus
+# endif
+void boardInit(void);
+# ifdef __cplusplus
}
-#endif
+# endif
#endif /* _FROM_ASM_ */
#endif /* _BOARD_H_ */
diff --git a/drivers/boards/IC_TEENSY_3_1/board.c b/drivers/boards/IC_TEENSY_3_1/board.c
index 1e952883d8..63e3f64929 100644
--- a/drivers/boards/IC_TEENSY_3_1/board.c
+++ b/drivers/boards/IC_TEENSY_3_1/board.c
@@ -21,154 +21,109 @@
* @details Digital I/O ports static configuration as defined in @p board.h.
* This variable is used by the HAL when initializing the PAL driver.
*/
-const PALConfig pal_default_config =
-{
- .ports = {
+const PALConfig pal_default_config = {
+ .ports =
{
- /*
- * PORTA setup.
- *
- * PTA4 - PIN33
- * PTA5 - PIN24
- * PTA12 - PIN3
- * PTA13 - PIN4
- *
- * PTA18/19 crystal
- * PTA0/3 SWD
- */
- .port = IOPORT1,
- .pads = {
- PAL_MODE_ALTERNATIVE_7, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_ALTERNATIVE_7, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_INPUT_ANALOG, PAL_MODE_INPUT_ANALOG, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
+ {
+ /*
+ * PORTA setup.
+ *
+ * PTA4 - PIN33
+ * PTA5 - PIN24
+ * PTA12 - PIN3
+ * PTA13 - PIN4
+ *
+ * PTA18/19 crystal
+ * PTA0/3 SWD
+ */
+ .port = IOPORT1,
+ .pads =
+ {
+ PAL_MODE_ALTERNATIVE_7, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_ALTERNATIVE_7, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_INPUT_ANALOG, PAL_MODE_INPUT_ANALOG, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
+ },
},
- },
- {
- /*
- * PORTB setup.
- *
- * PTB0 - PIN16
- * PTB1 - PIN17
- * PTB2 - PIN19
- * PTB3 - PIN18
- * PTB16 - PIN0 - UART0_TX
- * PTB17 - PIN1 - UART0_RX
- * PTB18 - PIN32
- * PTB19 - PIN25
- */
- .port = IOPORT2,
- .pads = {
- PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL,
- PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_ALTERNATIVE_3, PAL_MODE_ALTERNATIVE_3,
- PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
+ {
+ /*
+ * PORTB setup.
+ *
+ * PTB0 - PIN16
+ * PTB1 - PIN17
+ * PTB2 - PIN19
+ * PTB3 - PIN18
+ * PTB16 - PIN0 - UART0_TX
+ * PTB17 - PIN1 - UART0_RX
+ * PTB18 - PIN32
+ * PTB19 - PIN25
+ */
+ .port = IOPORT2,
+ .pads =
+ {
+ PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_ALTERNATIVE_3, PAL_MODE_ALTERNATIVE_3, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
+ },
},
- },
- {
- /*
- * PORTC setup.
- *
- * PTC0 - PIN15
- * PTC1 - PIN22
- * PTC2 - PIN23
- * PTC3 - PIN9
- * PTC4 - PIN10
- * PTC5 - PIN13
- * PTC6 - PIN11
- * PTC7 - PIN12
- * PTC8 - PIN28
- * PTC9 - PIN27
- * PTC10 - PIN29
- * PTC11 - PIN30
- */
- .port = IOPORT3,
- .pads = {
- PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL,
- PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL,
- PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL,
- PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
+ {
+ /*
+ * PORTC setup.
+ *
+ * PTC0 - PIN15
+ * PTC1 - PIN22
+ * PTC2 - PIN23
+ * PTC3 - PIN9
+ * PTC4 - PIN10
+ * PTC5 - PIN13
+ * PTC6 - PIN11
+ * PTC7 - PIN12
+ * PTC8 - PIN28
+ * PTC9 - PIN27
+ * PTC10 - PIN29
+ * PTC11 - PIN30
+ */
+ .port = IOPORT3,
+ .pads =
+ {
+ PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
+ },
},
- },
- {
- /*
- * PORTD setup.
- *
- * PTD0 - PIN2
- * PTD1 - PIN14
- * PTD2 - PIN7
- * PTD3 - PIN8
- * PTD4 - PIN6
- * PTD5 - PIN20
- * PTD6 - PIN21
- * PTD7 - PIN5
- */
- .port = IOPORT4,
- .pads = {
- PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL,
- PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL,
- PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
+ {
+ /*
+ * PORTD setup.
+ *
+ * PTD0 - PIN2
+ * PTD1 - PIN14
+ * PTD2 - PIN7
+ * PTD3 - PIN8
+ * PTD4 - PIN6
+ * PTD5 - PIN20
+ * PTD6 - PIN21
+ * PTD7 - PIN5
+ */
+ .port = IOPORT4,
+ .pads =
+ {
+ PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
+ },
},
- },
- {
- /*
- * PORTE setup.
- *
- * PTE0 - PIN31
- * PTE1 - PIN26
- */
- .port = IOPORT5,
- .pads = {
- PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
- PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
+ {
+ /*
+ * PORTE setup.
+ *
+ * PTE0 - PIN31
+ * PTE1 - PIN26
+ */
+ .port = IOPORT5,
+ .pads =
+ {
+ PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
+ },
},
},
- },
};
#endif
// NOTE: This value comes from kiibohd/controller and is the location of a value
// which needs to be checked before disabling the watchdog (which happens in
// k20x_clock_init)
-#define WDOG_TMROUTL *(volatile uint16_t *)0x40052012
+#define WDOG_TMROUTL *(volatile uint16_t *)0x40052012
/**
* @brief Early initialization code.
@@ -176,16 +131,16 @@ const PALConfig pal_default_config =
* and before any other initialization.
*/
void __early_init(void) {
- // This is a dirty hack and should only be used as a temporary fix until this
- // is upstreamed.
- while (WDOG_TMROUTL < 2); // Must wait for WDOG timer if already running, before jumping
+ // This is a dirty hack and should only be used as a temporary fix until this
+ // is upstreamed.
+ while (WDOG_TMROUTL < 2)
+ ; // Must wait for WDOG timer if already running, before jumping
- k20x_clock_init();
+ k20x_clock_init();
}
/**
* @brief Board-specific initialization code.
* @todo Add your board-specific code, if any.
*/
-void boardInit(void) {
-}
+void boardInit(void) {}
diff --git a/drivers/boards/IC_TEENSY_3_1/board.h b/drivers/boards/IC_TEENSY_3_1/board.h
index 8853395efe..c8259ab0c7 100644
--- a/drivers/boards/IC_TEENSY_3_1/board.h
+++ b/drivers/boards/IC_TEENSY_3_1/board.h
@@ -25,13 +25,13 @@
* Board identifier.
*/
#define BOARD_PJRC_TEENSY_3_1
-#define BOARD_NAME "PJRC Teensy 3.1"
+#define BOARD_NAME "PJRC Teensy 3.1"
/* External 16 MHz crystal */
-#define KINETIS_XTAL_FREQUENCY 16000000UL
+#define KINETIS_XTAL_FREQUENCY 16000000UL
/* Use internal capacitors for the crystal */
-#define KINETIS_BOARD_OSCILLATOR_SETTING OSC_CR_SC8P|OSC_CR_SC2P
+#define KINETIS_BOARD_OSCILLATOR_SETTING OSC_CR_SC8P | OSC_CR_SC2P
/*
* MCU type
@@ -41,79 +41,79 @@
/*
* IO pins assignments.
*/
-#define PORTA_PIN0 0
-#define PORTA_PIN1 1
-#define PORTA_PIN2 2
-#define PORTA_PIN3 3
-#define TEENSY_PIN33 4
-#define TEENSY_PIN24 5
-#define PORTA_PIN6 6
-#define PORTA_PIN7 7
-#define PORTA_PIN8 8
-#define PORTA_PIN9 9
-#define PORTA_PIN10 10
-#define PORTA_PIN11 11
-#define TEENSY_PIN3 12
-#define TEENSY_PIN4 13
-#define PORTA_PIN14 14
-#define PORTA_PIN15 15
-#define PORTA_PIN16 16
-#define PORTA_PIN17 17
-#define PORTA_PIN18 18
-#define PORTA_PIN19 19
-#define PORTA_PIN20 20
-#define PORTA_PIN21 21
-#define PORTA_PIN22 22
-#define PORTA_PIN23 23
-#define PORTA_PIN24 24
-#define PORTA_PIN25 25
-#define PORTA_PIN26 26
-#define PORTA_PIN27 27
-#define PORTA_PIN28 28
-#define PORTA_PIN29 29
-#define PORTA_PIN30 30
-#define PORTA_PIN31 31
+#define PORTA_PIN0 0
+#define PORTA_PIN1 1
+#define PORTA_PIN2 2
+#define PORTA_PIN3 3
+#define TEENSY_PIN33 4
+#define TEENSY_PIN24 5
+#define PORTA_PIN6 6
+#define PORTA_PIN7 7
+#define PORTA_PIN8 8
+#define PORTA_PIN9 9
+#define PORTA_PIN10 10
+#define PORTA_PIN11 11
+#define TEENSY_PIN3 12
+#define TEENSY_PIN4 13
+#define PORTA_PIN14 14
+#define PORTA_PIN15 15
+#define PORTA_PIN16 16
+#define PORTA_PIN17 17
+#define PORTA_PIN18 18
+#define PORTA_PIN19 19
+#define PORTA_PIN20 20
+#define PORTA_PIN21 21
+#define PORTA_PIN22 22
+#define PORTA_PIN23 23
+#define PORTA_PIN24 24
+#define PORTA_PIN25 25
+#define PORTA_PIN26 26
+#define PORTA_PIN27 27
+#define PORTA_PIN28 28
+#define PORTA_PIN29 29
+#define PORTA_PIN30 30
+#define PORTA_PIN31 31
-#define TEENSY_PIN3_IOPORT IOPORT1
-#define TEENSY_PIN4_IOPORT IOPORT1
+#define TEENSY_PIN3_IOPORT IOPORT1
+#define TEENSY_PIN4_IOPORT IOPORT1
#define TEENSY_PIN24_IOPORT IOPORT1
#define TEENSY_PIN33_IOPORT IOPORT1
-#define TEENSY_PIN16 0
-#define TEENSY_PIN17 1
-#define TEENSY_PIN19 2
-#define TEENSY_PIN18 3
-#define PORTB_PIN4 4
-#define PORTB_PIN5 5
-#define PORTB_PIN6 6
-#define PORTB_PIN7 7
-#define PORTB_PIN8 8
-#define PORTB_PIN9 9
-#define PORTB_PIN10 10
-#define PORTB_PIN11 11
-#define PORTB_PIN12 12
-#define PORTB_PIN13 13
-#define PORTB_PIN14 14
-#define PORTB_PIN15 15
-#define TEENSY_PIN0 16
-#define TEENSY_PIN1 17
-#define TEENSY_PIN32 18
-#define TEENSY_PIN25 19
-#define PORTB_PIN20 20
-#define PORTB_PIN21 21
-#define PORTB_PIN22 22
-#define PORTB_PIN23 23
-#define PORTB_PIN24 24
-#define PORTB_PIN25 25
-#define PORTB_PIN26 26
-#define PORTB_PIN27 27
-#define PORTB_PIN28 28
-#define PORTB_PIN29 29
-#define PORTB_PIN30 30
-#define PORTB_PIN31 31
+#define TEENSY_PIN16 0
+#define TEENSY_PIN17 1
+#define TEENSY_PIN19 2
+#define TEENSY_PIN18 3
+#define PORTB_PIN4 4
+#define PORTB_PIN5 5
+#define PORTB_PIN6 6
+#define PORTB_PIN7 7
+#define PORTB_PIN8 8
+#define PORTB_PIN9 9
+#define PORTB_PIN10 10
+#define PORTB_PIN11 11
+#define PORTB_PIN12 12
+#define PORTB_PIN13 13
+#define PORTB_PIN14 14
+#define PORTB_PIN15 15
+#define TEENSY_PIN0 16
+#define TEENSY_PIN1 17
+#define TEENSY_PIN32 18
+#define TEENSY_PIN25 19
+#define PORTB_PIN20 20
+#define PORTB_PIN21 21
+#define PORTB_PIN22 22
+#define PORTB_PIN23 23
+#define PORTB_PIN24 24
+#define PORTB_PIN25 25
+#define PORTB_PIN26 26
+#define PORTB_PIN27 27
+#define PORTB_PIN28 28
+#define PORTB_PIN29 29
+#define PORTB_PIN30 30
+#define PORTB_PIN31 31
-#define TEENSY_PIN0_IOPORT IOPORT2
-#define TEENSY_PIN1_IOPORT IOPORT2
+#define TEENSY_PIN0_IOPORT IOPORT2
+#define TEENSY_PIN1_IOPORT IOPORT2
#define TEENSY_PIN16_IOPORT IOPORT2
#define TEENSY_PIN17_IOPORT IOPORT2
#define TEENSY_PIN18_IOPORT IOPORT2
@@ -121,40 +121,40 @@
#define TEENSY_PIN25_IOPORT IOPORT2
#define TEENSY_PIN32_IOPORT IOPORT2
-#define TEENSY_PIN15 0
-#define TEENSY_PIN22 1
-#define TEENSY_PIN23 2
-#define TEENSY_PIN9 3
-#define TEENSY_PIN10 4
-#define TEENSY_PIN13 5
-#define TEENSY_PIN11 6
-#define TEENSY_PIN12 7
-#define TEENSY_PIN28 8
-#define TEENSY_PIN27 9
-#define TEENSY_PIN29 10
-#define TEENSY_PIN30 11
-#define PORTC_PIN12 12
-#define PORTC_PIN13 13
-#define PORTC_PIN14 14
-#define PORTC_PIN15 15
-#define PORTC_PIN16 16
-#define PORTC_PIN17 17
-#define PORTC_PIN18 18
-#define PORTC_PIN19 19
-#define PORTC_PIN20 20
-#define PORTC_PIN21 21
-#define PORTC_PIN22 22
-#define PORTC_PIN23 23
-#define PORTC_PIN24 24
-#define PORTC_PIN25 25
-#define PORTC_PIN26 26
-#define PORTC_PIN27 27
-#define PORTC_PIN28 28
-#define PORTC_PIN29 29
-#define PORTC_PIN30 30
-#define PORTC_PIN31 31
+#define TEENSY_PIN15 0
+#define TEENSY_PIN22 1
+#define TEENSY_PIN23 2
+#define TEENSY_PIN9 3
+#define TEENSY_PIN10 4
+#define TEENSY_PIN13 5
+#define TEENSY_PIN11 6
+#define TEENSY_PIN12 7
+#define TEENSY_PIN28 8
+#define TEENSY_PIN27 9
+#define TEENSY_PIN29 10
+#define TEENSY_PIN30 11
+#define PORTC_PIN12 12
+#define PORTC_PIN13 13
+#define PORTC_PIN14 14
+#define PORTC_PIN15 15
+#define PORTC_PIN16 16
+#define PORTC_PIN17 17
+#define PORTC_PIN18 18
+#define PORTC_PIN19 19
+#define PORTC_PIN20 20
+#define PORTC_PIN21 21
+#define PORTC_PIN22 22
+#define PORTC_PIN23 23
+#define PORTC_PIN24 24
+#define PORTC_PIN25 25
+#define PORTC_PIN26 26
+#define PORTC_PIN27 27
+#define PORTC_PIN28 28
+#define PORTC_PIN29 29
+#define PORTC_PIN30 30
+#define PORTC_PIN31 31
-#define TEENSY_PIN9_IOPORT IOPORT3
+#define TEENSY_PIN9_IOPORT IOPORT3
#define TEENSY_PIN10_IOPORT IOPORT3
#define TEENSY_PIN11_IOPORT IOPORT3
#define TEENSY_PIN12_IOPORT IOPORT3
@@ -167,129 +167,129 @@
#define TEENSY_PIN29_IOPORT IOPORT3
#define TEENSY_PIN30_IOPORT IOPORT3
-#define TEENSY_PIN2 0
-#define TEENSY_PIN14 1
-#define TEENSY_PIN7 2
-#define TEENSY_PIN8 3
-#define TEENSY_PIN6 4
-#define TEENSY_PIN20 5
-#define TEENSY_PIN21 6
-#define TEENSY_PIN5 7
-#define PORTD_PIN8 8
-#define PORTD_PIN9 9
-#define PORTD_PIN10 10
-#define PORTD_PIN11 11
-#define PORTD_PIN12 12
-#define PORTD_PIN13 13
-#define PORTD_PIN14 14
-#define PORTD_PIN15 15
-#define PORTD_PIN16 16
-#define PORTD_PIN17 17
-#define PORTD_PIN18 18
-#define PORTD_PIN19 19
-#define PORTD_PIN20 20
-#define PORTD_PIN21 21
-#define PORTD_PIN22 22
-#define PORTD_PIN23 23
-#define PORTD_PIN24 24
-#define PORTD_PIN25 25
-#define PORTD_PIN26 26
-#define PORTD_PIN27 27
-#define PORTD_PIN28 28
-#define PORTD_PIN29 29
-#define PORTD_PIN30 30
-#define PORTD_PIN31 31
+#define TEENSY_PIN2 0
+#define TEENSY_PIN14 1
+#define TEENSY_PIN7 2
+#define TEENSY_PIN8 3
+#define TEENSY_PIN6 4
+#define TEENSY_PIN20 5
+#define TEENSY_PIN21 6
+#define TEENSY_PIN5 7
+#define PORTD_PIN8 8
+#define PORTD_PIN9 9
+#define PORTD_PIN10 10
+#define PORTD_PIN11 11
+#define PORTD_PIN12 12
+#define PORTD_PIN13 13
+#define PORTD_PIN14 14
+#define PORTD_PIN15 15
+#define PORTD_PIN16 16
+#define PORTD_PIN17 17
+#define PORTD_PIN18 18
+#define PORTD_PIN19 19
+#define PORTD_PIN20 20
+#define PORTD_PIN21 21
+#define PORTD_PIN22 22
+#define PORTD_PIN23 23
+#define PORTD_PIN24 24
+#define PORTD_PIN25 25
+#define PORTD_PIN26 26
+#define PORTD_PIN27 27
+#define PORTD_PIN28 28
+#define PORTD_PIN29 29
+#define PORTD_PIN30 30
+#define PORTD_PIN31 31
-#define TEENSY_PIN2_IOPORT IOPORT4
-#define TEENSY_PIN5_IOPORT IOPORT4
-#define TEENSY_PIN6_IOPORT IOPORT4
-#define TEENSY_PIN7_IOPORT IOPORT4
-#define TEENSY_PIN8_IOPORT IOPORT4
+#define TEENSY_PIN2_IOPORT IOPORT4
+#define TEENSY_PIN5_IOPORT IOPORT4
+#define TEENSY_PIN6_IOPORT IOPORT4
+#define TEENSY_PIN7_IOPORT IOPORT4
+#define TEENSY_PIN8_IOPORT IOPORT4
#define TEENSY_PIN14_IOPORT IOPORT4
#define TEENSY_PIN20_IOPORT IOPORT4
#define TEENSY_PIN21_IOPORT IOPORT4
-#define TEENSY_PIN31 0
-#define TEENSY_PIN26 1
-#define PORTE_PIN2 2
-#define PORTE_PIN3 3
-#define PORTE_PIN4 4
-#define PORTE_PIN5 5
-#define PORTE_PIN6 6
-#define PORTE_PIN7 7
-#define PORTE_PIN8 8
-#define PORTE_PIN9 9
-#define PORTE_PIN10 10
-#define PORTE_PIN11 11
-#define PORTE_PIN12 12
-#define PORTE_PIN13 13
-#define PORTE_PIN14 14
-#define PORTE_PIN15 15
-#define PORTE_PIN16 16
-#define PORTE_PIN17 17
-#define PORTE_PIN18 18
-#define PORTE_PIN19 19
-#define PORTE_PIN20 20
-#define PORTE_PIN21 21
-#define PORTE_PIN22 22
-#define PORTE_PIN23 23
-#define PORTE_PIN24 24
-#define PORTE_PIN25 25
-#define PORTE_PIN26 26
-#define PORTE_PIN27 27
-#define PORTE_PIN28 28
-#define PORTE_PIN29 29
-#define PORTE_PIN30 30
-#define PORTE_PIN31 31
+#define TEENSY_PIN31 0
+#define TEENSY_PIN26 1
+#define PORTE_PIN2 2
+#define PORTE_PIN3 3
+#define PORTE_PIN4 4
+#define PORTE_PIN5 5
+#define PORTE_PIN6 6
+#define PORTE_PIN7 7
+#define PORTE_PIN8 8
+#define PORTE_PIN9 9
+#define PORTE_PIN10 10
+#define PORTE_PIN11 11
+#define PORTE_PIN12 12
+#define PORTE_PIN13 13
+#define PORTE_PIN14 14
+#define PORTE_PIN15 15
+#define PORTE_PIN16 16
+#define PORTE_PIN17 17
+#define PORTE_PIN18 18
+#define PORTE_PIN19 19
+#define PORTE_PIN20 20
+#define PORTE_PIN21 21
+#define PORTE_PIN22 22
+#define PORTE_PIN23 23
+#define PORTE_PIN24 24
+#define PORTE_PIN25 25
+#define PORTE_PIN26 26
+#define PORTE_PIN27 27
+#define PORTE_PIN28 28
+#define PORTE_PIN29 29
+#define PORTE_PIN30 30
+#define PORTE_PIN31 31
#define TEENSY_PIN26_IOPORT IOPORT5
#define TEENSY_PIN31_IOPORT IOPORT5
-#define LINE_PIN1 PAL_LINE(TEENSY_PIN1_IOPORT, TEENSY_PIN1)
-#define LINE_PIN2 PAL_LINE(TEENSY_PIN2_IOPORT, TEENSY_PIN2)
-#define LINE_PIN3 PAL_LINE(TEENSY_PIN3_IOPORT, TEENSY_PIN3)
-#define LINE_PIN4 PAL_LINE(TEENSY_PIN4_IOPORT, TEENSY_PIN4)
-#define LINE_PIN5 PAL_LINE(TEENSY_PIN5_IOPORT, TEENSY_PIN5)
-#define LINE_PIN6 PAL_LINE(TEENSY_PIN6_IOPORT, TEENSY_PIN6)
-#define LINE_PIN7 PAL_LINE(TEENSY_PIN7_IOPORT, TEENSY_PIN7)
-#define LINE_PIN8 PAL_LINE(TEENSY_PIN8_IOPORT, TEENSY_PIN8)
-#define LINE_PIN9 PAL_LINE(TEENSY_PIN9_IOPORT, TEENSY_PIN9)
-#define LINE_PIN10 PAL_LINE(TEENSY_PIN10_IOPORT, TEENSY_PIN10)
-#define LINE_PIN11 PAL_LINE(TEENSY_PIN11_IOPORT, TEENSY_PIN11)
-#define LINE_PIN12 PAL_LINE(TEENSY_PIN12_IOPORT, TEENSY_PIN12)
-#define LINE_PIN13 PAL_LINE(TEENSY_PIN13_IOPORT, TEENSY_PIN13)
-#define LINE_PIN14 PAL_LINE(TEENSY_PIN14_IOPORT, TEENSY_PIN14)
-#define LINE_PIN15 PAL_LINE(TEENSY_PIN15_IOPORT, TEENSY_PIN15)
-#define LINE_PIN16 PAL_LINE(TEENSY_PIN16_IOPORT, TEENSY_PIN16)
-#define LINE_PIN17 PAL_LINE(TEENSY_PIN17_IOPORT, TEENSY_PIN17)
-#define LINE_PIN18 PAL_LINE(TEENSY_PIN18_IOPORT, TEENSY_PIN18)
-#define LINE_PIN19 PAL_LINE(TEENSY_PIN19_IOPORT, TEENSY_PIN19)
-#define LINE_PIN20 PAL_LINE(TEENSY_PIN20_IOPORT, TEENSY_PIN20)
-#define LINE_PIN21 PAL_LINE(TEENSY_PIN21_IOPORT, TEENSY_PIN21)
-#define LINE_PIN22 PAL_LINE(TEENSY_PIN22_IOPORT, TEENSY_PIN22)
-#define LINE_PIN23 PAL_LINE(TEENSY_PIN23_IOPORT, TEENSY_PIN23)
-#define LINE_PIN24 PAL_LINE(TEENSY_PIN24_IOPORT, TEENSY_PIN24)
-#define LINE_PIN25 PAL_LINE(TEENSY_PIN25_IOPORT, TEENSY_PIN25)
-#define LINE_PIN25 PAL_LINE(TEENSY_PIN25_IOPORT, TEENSY_PIN25)
-#define LINE_PIN26 PAL_LINE(TEENSY_PIN26_IOPORT, TEENSY_PIN26)
-#define LINE_PIN27 PAL_LINE(TEENSY_PIN27_IOPORT, TEENSY_PIN27)
-#define LINE_PIN28 PAL_LINE(TEENSY_PIN28_IOPORT, TEENSY_PIN28)
-#define LINE_PIN29 PAL_LINE(TEENSY_PIN29_IOPORT, TEENSY_PIN29)
-#define LINE_PIN30 PAL_LINE(TEENSY_PIN30_IOPORT, TEENSY_PIN30)
-#define LINE_PIN31 PAL_LINE(TEENSY_PIN31_IOPORT, TEENSY_PIN31)
-#define LINE_PIN32 PAL_LINE(TEENSY_PIN32_IOPORT, TEENSY_PIN32)
-#define LINE_PIN33 PAL_LINE(TEENSY_PIN33_IOPORT, TEENSY_PIN33)
+#define LINE_PIN1 PAL_LINE(TEENSY_PIN1_IOPORT, TEENSY_PIN1)
+#define LINE_PIN2 PAL_LINE(TEENSY_PIN2_IOPORT, TEENSY_PIN2)
+#define LINE_PIN3 PAL_LINE(TEENSY_PIN3_IOPORT, TEENSY_PIN3)
+#define LINE_PIN4 PAL_LINE(TEENSY_PIN4_IOPORT, TEENSY_PIN4)
+#define LINE_PIN5 PAL_LINE(TEENSY_PIN5_IOPORT, TEENSY_PIN5)
+#define LINE_PIN6 PAL_LINE(TEENSY_PIN6_IOPORT, TEENSY_PIN6)
+#define LINE_PIN7 PAL_LINE(TEENSY_PIN7_IOPORT, TEENSY_PIN7)
+#define LINE_PIN8 PAL_LINE(TEENSY_PIN8_IOPORT, TEENSY_PIN8)
+#define LINE_PIN9 PAL_LINE(TEENSY_PIN9_IOPORT, TEENSY_PIN9)
+#define LINE_PIN10 PAL_LINE(TEENSY_PIN10_IOPORT, TEENSY_PIN10)
+#define LINE_PIN11 PAL_LINE(TEENSY_PIN11_IOPORT, TEENSY_PIN11)
+#define LINE_PIN12 PAL_LINE(TEENSY_PIN12_IOPORT, TEENSY_PIN12)
+#define LINE_PIN13 PAL_LINE(TEENSY_PIN13_IOPORT, TEENSY_PIN13)
+#define LINE_PIN14 PAL_LINE(TEENSY_PIN14_IOPORT, TEENSY_PIN14)
+#define LINE_PIN15 PAL_LINE(TEENSY_PIN15_IOPORT, TEENSY_PIN15)
+#define LINE_PIN16 PAL_LINE(TEENSY_PIN16_IOPORT, TEENSY_PIN16)
+#define LINE_PIN17 PAL_LINE(TEENSY_PIN17_IOPORT, TEENSY_PIN17)
+#define LINE_PIN18 PAL_LINE(TEENSY_PIN18_IOPORT, TEENSY_PIN18)
+#define LINE_PIN19 PAL_LINE(TEENSY_PIN19_IOPORT, TEENSY_PIN19)
+#define LINE_PIN20 PAL_LINE(TEENSY_PIN20_IOPORT, TEENSY_PIN20)
+#define LINE_PIN21 PAL_LINE(TEENSY_PIN21_IOPORT, TEENSY_PIN21)
+#define LINE_PIN22 PAL_LINE(TEENSY_PIN22_IOPORT, TEENSY_PIN22)
+#define LINE_PIN23 PAL_LINE(TEENSY_PIN23_IOPORT, TEENSY_PIN23)
+#define LINE_PIN24 PAL_LINE(TEENSY_PIN24_IOPORT, TEENSY_PIN24)
+#define LINE_PIN25 PAL_LINE(TEENSY_PIN25_IOPORT, TEENSY_PIN25)
+#define LINE_PIN25 PAL_LINE(TEENSY_PIN25_IOPORT, TEENSY_PIN25)
+#define LINE_PIN26 PAL_LINE(TEENSY_PIN26_IOPORT, TEENSY_PIN26)
+#define LINE_PIN27 PAL_LINE(TEENSY_PIN27_IOPORT, TEENSY_PIN27)
+#define LINE_PIN28 PAL_LINE(TEENSY_PIN28_IOPORT, TEENSY_PIN28)
+#define LINE_PIN29 PAL_LINE(TEENSY_PIN29_IOPORT, TEENSY_PIN29)
+#define LINE_PIN30 PAL_LINE(TEENSY_PIN30_IOPORT, TEENSY_PIN30)
+#define LINE_PIN31 PAL_LINE(TEENSY_PIN31_IOPORT, TEENSY_PIN31)
+#define LINE_PIN32 PAL_LINE(TEENSY_PIN32_IOPORT, TEENSY_PIN32)
+#define LINE_PIN33 PAL_LINE(TEENSY_PIN33_IOPORT, TEENSY_PIN33)
-#define LINE_LED LINE_PIN13
+#define LINE_LED LINE_PIN13
#if !defined(_FROM_ASM_)
-#ifdef __cplusplus
+# ifdef __cplusplus
extern "C" {
-#endif
- void boardInit(void);
-#ifdef __cplusplus
+# endif
+void boardInit(void);
+# ifdef __cplusplus
}
-#endif
+# endif
#endif /* _FROM_ASM_ */
#endif /* _BOARD_H_ */
diff --git a/drivers/gpio/pca9555.c b/drivers/gpio/pca9555.c
index b0e542d8de..496bbca04e 100644
--- a/drivers/gpio/pca9555.c
+++ b/drivers/gpio/pca9555.c
@@ -22,57 +22,57 @@
#define TIMEOUT 100
enum {
- CMD_INPUT_0 = 0,
- CMD_INPUT_1,
- CMD_OUTPUT_0,
- CMD_OUTPUT_1,
- CMD_INVERSION_0,
- CMD_INVERSION_1,
- CMD_CONFIG_0,
- CMD_CONFIG_1,
+ CMD_INPUT_0 = 0,
+ CMD_INPUT_1,
+ CMD_OUTPUT_0,
+ CMD_OUTPUT_1,
+ CMD_INVERSION_0,
+ CMD_INVERSION_1,
+ CMD_CONFIG_0,
+ CMD_CONFIG_1,
};
void pca9555_init(uint8_t slave_addr) {
- static uint8_t s_init = 0;
- if (!s_init) {
- i2c_init();
+ static uint8_t s_init = 0;
+ if (!s_init) {
+ i2c_init();
- s_init = 1;
- }
+ s_init = 1;
+ }
- // TODO: could check device connected
- // i2c_start(SLAVE_TO_ADDR(slave) | I2C_WRITE);
- // i2c_stop();
+ // TODO: could check device connected
+ // i2c_start(SLAVE_TO_ADDR(slave) | I2C_WRITE);
+ // i2c_stop();
}
void pca9555_set_config(uint8_t slave_addr, uint8_t port, uint8_t conf) {
- uint8_t addr = SLAVE_TO_ADDR(slave_addr);
- uint8_t cmd = port ? CMD_CONFIG_1 : CMD_CONFIG_0;
+ uint8_t addr = SLAVE_TO_ADDR(slave_addr);
+ uint8_t cmd = port ? CMD_CONFIG_1 : CMD_CONFIG_0;
- i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
- if (ret != I2C_STATUS_SUCCESS) {
- print("pca9555_set_config::FAILED\n");
- }
+ i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
+ if (ret != I2C_STATUS_SUCCESS) {
+ print("pca9555_set_config::FAILED\n");
+ }
}
void pca9555_set_output(uint8_t slave_addr, uint8_t port, uint8_t conf) {
- uint8_t addr = SLAVE_TO_ADDR(slave_addr);
- uint8_t cmd = port ? CMD_OUTPUT_1 : CMD_OUTPUT_0;
+ uint8_t addr = SLAVE_TO_ADDR(slave_addr);
+ uint8_t cmd = port ? CMD_OUTPUT_1 : CMD_OUTPUT_0;
- i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
- if (ret != I2C_STATUS_SUCCESS) {
- print("pca9555_set_output::FAILED\n");
- }
+ i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
+ if (ret != I2C_STATUS_SUCCESS) {
+ print("pca9555_set_output::FAILED\n");
+ }
}
uint8_t pca9555_readPins(uint8_t slave_addr, uint8_t port) {
- uint8_t addr = SLAVE_TO_ADDR(slave_addr);
- uint8_t cmd = port ? CMD_INPUT_1 : CMD_INPUT_0;
+ uint8_t addr = SLAVE_TO_ADDR(slave_addr);
+ uint8_t cmd = port ? CMD_INPUT_1 : CMD_INPUT_0;
- uint8_t data = 0;
- i2c_status_t ret = i2c_readReg(addr, cmd, &data, sizeof(data), TIMEOUT);
- if (ret != I2C_STATUS_SUCCESS) {
- print("pca9555_readPins::FAILED\n");
- }
- return data;
+ uint8_t data = 0;
+ i2c_status_t ret = i2c_readReg(addr, cmd, &data, sizeof(data), TIMEOUT);
+ if (ret != I2C_STATUS_SUCCESS) {
+ print("pca9555_readPins::FAILED\n");
+ }
+ return data;
}
diff --git a/drivers/haptic/DRV2605L.c b/drivers/haptic/DRV2605L.c
index 215e6be3e7..f74c965253 100644
--- a/drivers/haptic/DRV2605L.c
+++ b/drivers/haptic/DRV2605L.c
@@ -20,110 +20,102 @@
#include <stdio.h>
#include <math.h>
-
uint8_t DRV2605L_transfer_buffer[2];
uint8_t DRV2605L_tx_register[0];
uint8_t DRV2605L_read_buffer[0];
uint8_t DRV2605L_read_register;
-
void DRV_write(uint8_t drv_register, uint8_t settings) {
- DRV2605L_transfer_buffer[0] = drv_register;
- DRV2605L_transfer_buffer[1] = settings;
- i2c_transmit(DRV2605L_BASE_ADDRESS << 1, DRV2605L_transfer_buffer, 2, 100);
+ DRV2605L_transfer_buffer[0] = drv_register;
+ DRV2605L_transfer_buffer[1] = settings;
+ i2c_transmit(DRV2605L_BASE_ADDRESS << 1, DRV2605L_transfer_buffer, 2, 100);
}
uint8_t DRV_read(uint8_t regaddress) {
#ifdef __AVR__
- i2c_readReg(DRV2605L_BASE_ADDRESS << 1,
- regaddress, DRV2605L_read_buffer, 1, 100);
- DRV2605L_read_register = (uint8_t)DRV2605L_read_buffer[0];
+ i2c_readReg(DRV2605L_BASE_ADDRESS << 1, regaddress, DRV2605L_read_buffer, 1, 100);
+ DRV2605L_read_register = (uint8_t)DRV2605L_read_buffer[0];
#else
- DRV2605L_tx_register[0] = regaddress;
- if (MSG_OK != i2c_transmit_receive(DRV2605L_BASE_ADDRESS << 1,
- DRV2605L_tx_register, 1,
- DRV2605L_read_buffer, 1
-)){
- printf("err reading reg \n");
- }
- DRV2605L_read_register = (uint8_t)DRV2605L_read_buffer[0];
+ DRV2605L_tx_register[0] = regaddress;
+ if (MSG_OK != i2c_transmit_receive(DRV2605L_BASE_ADDRESS << 1, DRV2605L_tx_register, 1, DRV2605L_read_buffer, 1)) {
+ printf("err reading reg \n");
+ }
+ DRV2605L_read_register = (uint8_t)DRV2605L_read_buffer[0];
#endif
-return DRV2605L_read_register;
+ return DRV2605L_read_register;
}
-void DRV_init(void)
-{
- i2c_init();
- /* 0x07 sets DRV2605 into calibration mode */
- DRV_write(DRV_MODE,0x07);
+void DRV_init(void) {
+ i2c_init();
+ /* 0x07 sets DRV2605 into calibration mode */
+ DRV_write(DRV_MODE, 0x07);
+
+ // DRV_write(DRV_FEEDBACK_CTRL,0xB6);
-// DRV_write(DRV_FEEDBACK_CTRL,0xB6);
-
- #if FB_ERM_LRA == 0
+#if FB_ERM_LRA == 0
/* ERM settings */
- DRV_write(DRV_RATED_VOLT, (RATED_VOLTAGE/21.33)*1000);
- #if ERM_OPEN_LOOP == 0
- DRV_write(DRV_OVERDRIVE_CLAMP_VOLT, (((V_PEAK*(DRIVE_TIME+BLANKING_TIME+IDISS_TIME))/0.02133)/(DRIVE_TIME-0.0003)));
- #elif ERM_OPEN_LOOP == 1
- DRV_write(DRV_OVERDRIVE_CLAMP_VOLT, (V_PEAK/0.02196));
- #endif
- #elif FB_ERM_LRA == 1
- DRV_write(DRV_RATED_VOLT, ((V_RMS * sqrt(1 - ((4 * ((150+(SAMPLE_TIME*50))*0.000001)) + 0.0003)* F_LRA)/0.02071)));
- #if LRA_OPEN_LOOP == 0
- DRV_write(DRV_OVERDRIVE_CLAMP_VOLT, ((V_PEAK/sqrt(1-(F_LRA*0.0008))/0.02133)));
- #elif LRA_OPEN_LOOP == 1
- DRV_write(DRV_OVERDRIVE_CLAMP_VOLT, (V_PEAK/0.02196));
- #endif
- #endif
-
- DRVREG_FBR FB_SET;
- FB_SET.Bits.ERM_LRA = FB_ERM_LRA;
+ DRV_write(DRV_RATED_VOLT, (RATED_VOLTAGE / 21.33) * 1000);
+# if ERM_OPEN_LOOP == 0
+ DRV_write(DRV_OVERDRIVE_CLAMP_VOLT, (((V_PEAK * (DRIVE_TIME + BLANKING_TIME + IDISS_TIME)) / 0.02133) / (DRIVE_TIME - 0.0003)));
+# elif ERM_OPEN_LOOP == 1
+ DRV_write(DRV_OVERDRIVE_CLAMP_VOLT, (V_PEAK / 0.02196));
+# endif
+#elif FB_ERM_LRA == 1
+ DRV_write(DRV_RATED_VOLT, ((V_RMS * sqrt(1 - ((4 * ((150 + (SAMPLE_TIME * 50)) * 0.000001)) + 0.0003) * F_LRA) / 0.02071)));
+# if LRA_OPEN_LOOP == 0
+ DRV_write(DRV_OVERDRIVE_CLAMP_VOLT, ((V_PEAK / sqrt(1 - (F_LRA * 0.0008)) / 0.02133)));
+# elif LRA_OPEN_LOOP == 1
+ DRV_write(DRV_OVERDRIVE_CLAMP_VOLT, (V_PEAK / 0.02196));
+# endif
+#endif
+
+ DRVREG_FBR FB_SET;
+ FB_SET.Bits.ERM_LRA = FB_ERM_LRA;
FB_SET.Bits.BRAKE_FACTOR = FB_BRAKEFACTOR;
- FB_SET.Bits.LOOP_GAIN =FB_LOOPGAIN;
- FB_SET.Bits.BEMF_GAIN = 0; /* auto-calibration populates this field*/
- DRV_write(DRV_FEEDBACK_CTRL, (uint8_t) FB_SET.Byte);
- DRVREG_CTRL1 C1_SET;
- C1_SET.Bits.C1_DRIVE_TIME = DRIVE_TIME;
- C1_SET.Bits.C1_AC_COUPLE = AC_COUPLE;
+ FB_SET.Bits.LOOP_GAIN = FB_LOOPGAIN;
+ FB_SET.Bits.BEMF_GAIN = 0; /* auto-calibration populates this field*/
+ DRV_write(DRV_FEEDBACK_CTRL, (uint8_t)FB_SET.Byte);
+ DRVREG_CTRL1 C1_SET;
+ C1_SET.Bits.C1_DRIVE_TIME = DRIVE_TIME;
+ C1_SET.Bits.C1_AC_COUPLE = AC_COUPLE;
C1_SET.Bits.C1_STARTUP_BOOST = STARTUP_BOOST;
- DRV_write(DRV_CTRL_1, (uint8_t) C1_SET.Byte);
- DRVREG_CTRL2 C2_SET;
- C2_SET.Bits.C2_BIDIR_INPUT = BIDIR_INPUT;
- C2_SET.Bits.C2_BRAKE_STAB = BRAKE_STAB;
- C2_SET.Bits.C2_SAMPLE_TIME = SAMPLE_TIME;
+ DRV_write(DRV_CTRL_1, (uint8_t)C1_SET.Byte);
+ DRVREG_CTRL2 C2_SET;
+ C2_SET.Bits.C2_BIDIR_INPUT = BIDIR_INPUT;
+ C2_SET.Bits.C2_BRAKE_STAB = BRAKE_STAB;
+ C2_SET.Bits.C2_SAMPLE_TIME = SAMPLE_TIME;
C2_SET.Bits.C2_BLANKING_TIME = BLANKING_TIME;
- C2_SET.Bits.C2_IDISS_TIME = IDISS_TIME;
- DRV_write(DRV_CTRL_2, (uint8_t) C2_SET.Byte);
- DRVREG_CTRL3 C3_SET;
- C3_SET.Bits.C3_LRA_OPEN_LOOP = LRA_OPEN_LOOP;
- C3_SET.Bits.C3_N_PWM_ANALOG = N_PWM_ANALOG;
- C3_SET.Bits.C3_LRA_DRIVE_MODE = LRA_DRIVE_MODE;
+ C2_SET.Bits.C2_IDISS_TIME = IDISS_TIME;
+ DRV_write(DRV_CTRL_2, (uint8_t)C2_SET.Byte);
+ DRVREG_CTRL3 C3_SET;
+ C3_SET.Bits.C3_LRA_OPEN_LOOP = LRA_OPEN_LOOP;
+ C3_SET.Bits.C3_N_PWM_ANALOG = N_PWM_ANALOG;
+ C3_SET.Bits.C3_LRA_DRIVE_MODE = LRA_DRIVE_MODE;
C3_SET.Bits.C3_DATA_FORMAT_RTO = DATA_FORMAT_RTO;
C3_SET.Bits.C3_SUPPLY_COMP_DIS = SUPPLY_COMP_DIS;
- C3_SET.Bits.C3_ERM_OPEN_LOOP = ERM_OPEN_LOOP;
- C3_SET.Bits.C3_NG_THRESH = NG_THRESH;
- DRV_write(DRV_CTRL_3, (uint8_t) C3_SET.Byte);
- DRVREG_CTRL4 C4_SET;
- C4_SET.Bits.C4_ZC_DET_TIME = ZC_DET_TIME;
+ C3_SET.Bits.C3_ERM_OPEN_LOOP = ERM_OPEN_LOOP;
+ C3_SET.Bits.C3_NG_THRESH = NG_THRESH;
+ DRV_write(DRV_CTRL_3, (uint8_t)C3_SET.Byte);
+ DRVREG_CTRL4 C4_SET;
+ C4_SET.Bits.C4_ZC_DET_TIME = ZC_DET_TIME;
C4_SET.Bits.C4_AUTO_CAL_TIME = AUTO_CAL_TIME;
- DRV_write(DRV_CTRL_4, (uint8_t) C4_SET.Byte);
- DRV_write(DRV_LIB_SELECTION,LIB_SELECTION);
+ DRV_write(DRV_CTRL_4, (uint8_t)C4_SET.Byte);
+ DRV_write(DRV_LIB_SELECTION, LIB_SELECTION);
- DRV_write(DRV_GO, 0x01);
+ DRV_write(DRV_GO, 0x01);
- /* 0x00 sets DRV2605 out of standby and to use internal trigger
- * 0x01 sets DRV2605 out of standby and to use external trigger */
- DRV_write(DRV_MODE,0x00);
+ /* 0x00 sets DRV2605 out of standby and to use internal trigger
+ * 0x01 sets DRV2605 out of standby and to use external trigger */
+ DRV_write(DRV_MODE, 0x00);
-//Play greeting sequence
- DRV_write(DRV_GO, 0x00);
- DRV_write(DRV_WAVEFORM_SEQ_1, DRV_GREETING);
- DRV_write(DRV_GO, 0x01);
+ // Play greeting sequence
+ DRV_write(DRV_GO, 0x00);
+ DRV_write(DRV_WAVEFORM_SEQ_1, DRV_GREETING);
+ DRV_write(DRV_GO, 0x01);
}
-void DRV_pulse(uint8_t sequence)
-{
- DRV_write(DRV_GO, 0x00);
- DRV_write(DRV_WAVEFORM_SEQ_1, sequence);
- DRV_write(DRV_GO, 0x01);
+void DRV_pulse(uint8_t sequence) {
+ DRV_write(DRV_GO, 0x00);
+ DRV_write(DRV_WAVEFORM_SEQ_1, sequence);
+ DRV_write(DRV_GO, 0x01);
} \ No newline at end of file
diff --git a/drivers/haptic/DRV2605L.h b/drivers/haptic/DRV2605L.h
index 836e9cbcd2..f550b859f7 100644
--- a/drivers/haptic/DRV2605L.h
+++ b/drivers/haptic/DRV2605L.h
@@ -22,383 +22,383 @@
* Feedback Control Settings */
#ifndef FB_ERM_LRA
-#define FB_ERM_LRA 1 /* For ERM:0 or LRA:1*/
+# define FB_ERM_LRA 1 /* For ERM:0 or LRA:1*/
#endif
#ifndef FB_BRAKEFACTOR
-#define FB_BRAKEFACTOR 3 /* For 1x:0, 2x:1, 3x:2, 4x:3, 6x:4, 8x:5, 16x:6, Disable Braking:7 */
+# define FB_BRAKEFACTOR 3 /* For 1x:0, 2x:1, 3x:2, 4x:3, 6x:4, 8x:5, 16x:6, Disable Braking:7 */
#endif
#ifndef FB_LOOPGAIN
-#define FB_LOOPGAIN 1 /* For Low:0, Medium:1, High:2, Very High:3 */
+# define FB_LOOPGAIN 1 /* For Low:0, Medium:1, High:2, Very High:3 */
#endif
/* LRA specific settings */
#if FB_ERM_LRA == 1
-#ifndef V_RMS
-#define V_RMS 2.0
-#endif
-#ifndef V_PEAK
-#define V_PEAK 2.1
-#endif
-#ifndef F_LRA
-#define F_LRA 205
-#endif
-#ifndef RATED_VOLTAGE
-#define RATED_VOLTAGE 2 /* 2v as safe range in case device voltage is not set */
-#endif
+# ifndef V_RMS
+# define V_RMS 2.0
+# endif
+# ifndef V_PEAK
+# define V_PEAK 2.1
+# endif
+# ifndef F_LRA
+# define F_LRA 205
+# endif
+# ifndef RATED_VOLTAGE
+# define RATED_VOLTAGE 2 /* 2v as safe range in case device voltage is not set */
+# endif
#endif
#ifndef RATED_VOLTAGE
-#define RATED_VOLTAGE 2 /* 2v as safe range in case device voltage is not set */
+# define RATED_VOLTAGE 2 /* 2v as safe range in case device voltage is not set */
#endif
#ifndef V_PEAK
-#define V_PEAK 2.8
+# define V_PEAK 2.8
#endif
/* Library Selection */
#ifndef LIB_SELECTION
-#if FB_ERM_LRA == 1
-#define LIB_SELECTION 6 /* For Empty:0' TS2200 library A to D:1-5, LRA Library: 6 */
-#else
-#define LIB_SELECTION 1
-#endif
+# if FB_ERM_LRA == 1
+# define LIB_SELECTION 6 /* For Empty:0' TS2200 library A to D:1-5, LRA Library: 6 */
+# else
+# define LIB_SELECTION 1
+# endif
#endif
#ifndef DRV_GREETING
-#define DRV_GREETING alert_750ms
+# define DRV_GREETING alert_750ms
#endif
#ifndef DRV_MODE_DEFAULT
-#define DRV_MODE_DEFAULT strong_click1
+# define DRV_MODE_DEFAULT strong_click1
#endif
/* Control 1 register settings */
#ifndef DRIVE_TIME
-#define DRIVE_TIME 25
+# define DRIVE_TIME 25
#endif
#ifndef AC_COUPLE
-#define AC_COUPLE 0
+# define AC_COUPLE 0
#endif
#ifndef STARTUP_BOOST
-#define STARTUP_BOOST 1
+# define STARTUP_BOOST 1
#endif
/* Control 2 Settings */
#ifndef BIDIR_INPUT
-#define BIDIR_INPUT 1
+# define BIDIR_INPUT 1
#endif
#ifndef BRAKE_STAB
-#define BRAKE_STAB 1 /* Loopgain is reduced when braking is almost complete to improve stability */
+# define BRAKE_STAB 1 /* Loopgain is reduced when braking is almost complete to improve stability */
#endif
-#ifndef SAMPLE_TIME
-#define SAMPLE_TIME 3
+#ifndef SAMPLE_TIME
+# define SAMPLE_TIME 3
#endif
#ifndef BLANKING_TIME
-#define BLANKING_TIME 1
+# define BLANKING_TIME 1
#endif
#ifndef IDISS_TIME
-#define IDISS_TIME 1
+# define IDISS_TIME 1
#endif
/* Control 3 settings */
#ifndef NG_THRESH
-#define NG_THRESH 2
+# define NG_THRESH 2
#endif
#ifndef ERM_OPEN_LOOP
-#define ERM_OPEN_LOOP 1
+# define ERM_OPEN_LOOP 1
#endif
#ifndef SUPPLY_COMP_DIS
-#define SUPPLY_COMP_DIS 0
+# define SUPPLY_COMP_DIS 0
#endif
#ifndef DATA_FORMAT_RTO
-#define DATA_FORMAT_RTO 0
+# define DATA_FORMAT_RTO 0
#endif
#ifndef LRA_DRIVE_MODE
-#define LRA_DRIVE_MODE 0
+# define LRA_DRIVE_MODE 0
#endif
#ifndef N_PWM_ANALOG
-#define N_PWM_ANALOG 0
+# define N_PWM_ANALOG 0
#endif
#ifndef LRA_OPEN_LOOP
-#define LRA_OPEN_LOOP 0
+# define LRA_OPEN_LOOP 0
#endif
/* Control 4 settings */
#ifndef ZC_DET_TIME
-#define ZC_DET_TIME 0
+# define ZC_DET_TIME 0
#endif
#ifndef AUTO_CAL_TIME
-#define AUTO_CAL_TIME 3
+# define AUTO_CAL_TIME 3
#endif
/* register defines -------------------------------------------------------- */
-#define DRV2605L_BASE_ADDRESS 0x5A /* DRV2605L Base address */
-#define DRV_STATUS 0x00
-#define DRV_MODE 0x01
-#define DRV_RTP_INPUT 0x02
-#define DRV_LIB_SELECTION 0x03
-#define DRV_WAVEFORM_SEQ_1 0x04
-#define DRV_WAVEFORM_SEQ_2 0x05
-#define DRV_WAVEFORM_SEQ_3 0x06
-#define DRV_WAVEFORM_SEQ_4 0x07
-#define DRV_WAVEFORM_SEQ_5 0x08
-#define DRV_WAVEFORM_SEQ_6 0x09
-#define DRV_WAVEFORM_SEQ_7 0x0A
-#define DRV_WAVEFORM_SEQ_8 0x0B
-#define DRV_GO 0x0C
-#define DRV_OVERDRIVE_TIME_OFFSET 0x0D
-#define DRV_SUSTAIN_TIME_OFFSET_P 0x0E
-#define DRV_SUSTAIN_TIME_OFFSET_N 0x0F
-#define DRV_BRAKE_TIME_OFFSET 0x10
-#define DRV_AUDIO_2_VIBE_CTRL 0x11
-#define DRV_AUDIO_2_VIBE_MIN_IN 0x12
-#define DRV_AUDIO_2_VIBE_MAX_IN 0x13
-#define DRV_AUDIO_2_VIBE_MIN_OUTDRV 0x14
-#define DRV_AUDIO_2_VIBE_MAX_OUTDRV 0x15
-#define DRV_RATED_VOLT 0x16
-#define DRV_OVERDRIVE_CLAMP_VOLT 0x17
-#define DRV_AUTO_CALIB_COMP_RESULT 0x18
-#define DRV_AUTO_CALIB_BEMF_RESULT 0x19
-#define DRV_FEEDBACK_CTRL 0x1A
-#define DRV_CTRL_1 0x1B
-#define DRV_CTRL_2 0x1C
-#define DRV_CTRL_3 0x1D
-#define DRV_CTRL_4 0x1E
-#define DRV_CTRL_5 0x1F
-#define DRV_OPEN_LOOP_PERIOD 0x20
-#define DRV_VBAT_VOLT_MONITOR 0x21
-#define DRV_LRA_RESONANCE_PERIOD 0x22
+#define DRV2605L_BASE_ADDRESS 0x5A /* DRV2605L Base address */
+#define DRV_STATUS 0x00
+#define DRV_MODE 0x01
+#define DRV_RTP_INPUT 0x02
+#define DRV_LIB_SELECTION 0x03
+#define DRV_WAVEFORM_SEQ_1 0x04
+#define DRV_WAVEFORM_SEQ_2 0x05
+#define DRV_WAVEFORM_SEQ_3 0x06
+#define DRV_WAVEFORM_SEQ_4 0x07
+#define DRV_WAVEFORM_SEQ_5 0x08
+#define DRV_WAVEFORM_SEQ_6 0x09
+#define DRV_WAVEFORM_SEQ_7 0x0A
+#define DRV_WAVEFORM_SEQ_8 0x0B
+#define DRV_GO 0x0C
+#define DRV_OVERDRIVE_TIME_OFFSET 0x0D
+#define DRV_SUSTAIN_TIME_OFFSET_P 0x0E
+#define DRV_SUSTAIN_TIME_OFFSET_N 0x0F
+#define DRV_BRAKE_TIME_OFFSET 0x10
+#define DRV_AUDIO_2_VIBE_CTRL 0x11
+#define DRV_AUDIO_2_VIBE_MIN_IN 0x12
+#define DRV_AUDIO_2_VIBE_MAX_IN 0x13
+#define DRV_AUDIO_2_VIBE_MIN_OUTDRV 0x14
+#define DRV_AUDIO_2_VIBE_MAX_OUTDRV 0x15
+#define DRV_RATED_VOLT 0x16
+#define DRV_OVERDRIVE_CLAMP_VOLT 0x17
+#define DRV_AUTO_CALIB_COMP_RESULT 0x18
+#define DRV_AUTO_CALIB_BEMF_RESULT 0x19
+#define DRV_FEEDBACK_CTRL 0x1A
+#define DRV_CTRL_1 0x1B
+#define DRV_CTRL_2 0x1C
+#define DRV_CTRL_3 0x1D
+#define DRV_CTRL_4 0x1E
+#define DRV_CTRL_5 0x1F
+#define DRV_OPEN_LOOP_PERIOD 0x20
+#define DRV_VBAT_VOLT_MONITOR 0x21
+#define DRV_LRA_RESONANCE_PERIOD 0x22
-void DRV_init(void);
-void DRV_write(const uint8_t drv_register, const uint8_t settings);
+void DRV_init(void);
+void DRV_write(const uint8_t drv_register, const uint8_t settings);
uint8_t DRV_read(const uint8_t regaddress);
-void DRV_pulse(const uint8_t sequence);
+void DRV_pulse(const uint8_t sequence);
-typedef enum DRV_EFFECT{
- clear_sequence = 0,
- strong_click = 1,
- strong_click_60 = 2,
- strong_click_30 = 3,
- sharp_click = 4,
- sharp_click_60 = 5,
- sharp_click_30 = 6,
- soft_bump = 7,
- soft_bump_60 = 8,
- soft_bump_30 = 9,
- dbl_click = 10,
- dbl_click_60 = 11,
- trp_click = 12,
- soft_fuzz = 13,
- strong_buzz = 14,
- alert_750ms = 15,
- alert_1000ms = 16,
- strong_click1 = 17,
- strong_click2_80 = 18,
- strong_click3_60 = 19,
- strong_click4_30 = 20,
- medium_click1 = 21,
- medium_click2_80 = 22,
- medium_click3_60 = 23,
- sharp_tick1 = 24,
- sharp_tick2_80 = 25,
- sharp_tick3_60 = 26,
- sh_dblclick_str = 27,
- sh_dblclick_str_80 = 28,
- sh_dblclick_str_60 = 29,
- sh_dblclick_str_30 = 30,
- sh_dblclick_med = 31,
- sh_dblclick_med_80 = 32,
- sh_dblclick_med_60 = 33,
- sh_dblsharp_tick = 34,
- sh_dblsharp_tick_80 = 35,
- sh_dblsharp_tick_60 = 36,
- lg_dblclick_str = 37,
- lg_dblclick_str_80 = 38,
- lg_dblclick_str_60 = 39,
- lg_dblclick_str_30 = 40,
- lg_dblclick_med = 41,
- lg_dblclick_med_80 = 42,
- lg_dblclick_med_60 = 43,
- lg_dblsharp_tick = 44,
- lg_dblsharp_tick_80 = 45,
- lg_dblsharp_tick_60 = 46,
- buzz = 47,
- buzz_80 = 48,
- buzz_60 = 49,
- buzz_40 = 50,
- buzz_20 = 51,
- pulsing_strong = 52,
- pulsing_strong_80 = 53,
- pulsing_medium = 54,
- pulsing_medium_80 = 55,
- pulsing_sharp = 56,
- pulsing_sharp_80 = 57,
- transition_click = 58,
- transition_click_80 = 59,
- transition_click_60 = 60,
- transition_click_40 = 61,
- transition_click_20 = 62,
- transition_click_10 = 63,
- transition_hum = 64,
- transition_hum_80 = 65,
- transition_hum_60 = 66,
- transition_hum_40 = 67,
- transition_hum_20 = 68,
- transition_hum_10 = 69,
- transition_rampdown_long_smooth1 = 70,
- transition_rampdown_long_smooth2 = 71,
- transition_rampdown_med_smooth1 = 72,
- transition_rampdown_med_smooth2 = 73,
- transition_rampdown_short_smooth1 = 74,
- transition_rampdown_short_smooth2 = 75,
- transition_rampdown_long_sharp1 = 76,
- transition_rampdown_long_sharp2 = 77,
- transition_rampdown_med_sharp1 = 78,
- transition_rampdown_med_sharp2 = 79,
- transition_rampdown_short_sharp1 = 80,
- transition_rampdown_short_sharp2 = 81,
- transition_rampup_long_smooth1 = 82,
- transition_rampup_long_smooth2 = 83,
- transition_rampup_med_smooth1 = 84,
- transition_rampup_med_smooth2 = 85,
- transition_rampup_short_smooth1 = 86,
- transition_rampup_short_smooth2 = 87,
- transition_rampup_long_sharp1 = 88,
- transition_rampup_long_sharp2 = 89,
- transition_rampup_med_sharp1 = 90,
- transition_rampup_med_sharp2 = 91,
- transition_rampup_short_sharp1 = 92,
- transition_rampup_short_sharp2 = 93,
- transition_rampdown_long_smooth1_50 = 94,
- transition_rampdown_long_smooth2_50 = 95,
- transition_rampdown_med_smooth1_50 = 96,
- transition_rampdown_med_smooth2_50 = 97,
- transition_rampdown_short_smooth1_50 = 98,
- transition_rampdown_short_smooth2_50 = 99,
- transition_rampdown_long_sharp1_50 = 100,
- transition_rampdown_long_sharp2_50 = 101,
- transition_rampdown_med_sharp1_50 = 102,
- transition_rampdown_med_sharp2_50 = 103,
- transition_rampdown_short_sharp1_50 = 104,
- transition_rampdown_short_sharp2_50 = 105,
- transition_rampup_long_smooth1_50 = 106,
- transition_rampup_long_smooth2_50 = 107,
- transition_rampup_med_smooth1_50 = 108,
- transition_rampup_med_smooth2_50 = 109,
- transition_rampup_short_smooth1_50 = 110,
- transition_rampup_short_smooth2_50 = 111,
- transition_rampup_long_sharp1_50 = 112,
- transition_rampup_long_sharp2_50 = 113,
- transition_rampup_med_sharp1_50 = 114,
- transition_rampup_med_sharp2_50 = 115,
- transition_rampup_short_sharp1_50 = 116,
- transition_rampup_short_sharp2_50 = 117,
- long_buzz_for_programmatic_stopping = 118,
- smooth_hum1_50 = 119,
- smooth_hum2_40 = 120,
- smooth_hum3_30 = 121,
- smooth_hum4_20 = 122,
- smooth_hum5_10 = 123,
- drv_effect_max = 124,
+typedef enum DRV_EFFECT {
+ clear_sequence = 0,
+ strong_click = 1,
+ strong_click_60 = 2,
+ strong_click_30 = 3,
+ sharp_click = 4,
+ sharp_click_60 = 5,
+ sharp_click_30 = 6,
+ soft_bump = 7,
+ soft_bump_60 = 8,
+ soft_bump_30 = 9,
+ dbl_click = 10,
+ dbl_click_60 = 11,
+ trp_click = 12,
+ soft_fuzz = 13,
+ strong_buzz = 14,
+ alert_750ms = 15,
+ alert_1000ms = 16,
+ strong_click1 = 17,
+ strong_click2_80 = 18,
+ strong_click3_60 = 19,
+ strong_click4_30 = 20,
+ medium_click1 = 21,
+ medium_click2_80 = 22,
+ medium_click3_60 = 23,
+ sharp_tick1 = 24,
+ sharp_tick2_80 = 25,
+ sharp_tick3_60 = 26,
+ sh_dblclick_str = 27,
+ sh_dblclick_str_80 = 28,
+ sh_dblclick_str_60 = 29,
+ sh_dblclick_str_30 = 30,
+ sh_dblclick_med = 31,
+ sh_dblclick_med_80 = 32,
+ sh_dblclick_med_60 = 33,
+ sh_dblsharp_tick = 34,
+ sh_dblsharp_tick_80 = 35,
+ sh_dblsharp_tick_60 = 36,
+ lg_dblclick_str = 37,
+ lg_dblclick_str_80 = 38,
+ lg_dblclick_str_60 = 39,
+ lg_dblclick_str_30 = 40,
+ lg_dblclick_med = 41,
+ lg_dblclick_med_80 = 42,
+ lg_dblclick_med_60 = 43,
+ lg_dblsharp_tick = 44,
+ lg_dblsharp_tick_80 = 45,
+ lg_dblsharp_tick_60 = 46,
+ buzz = 47,
+ buzz_80 = 48,
+ buzz_60 = 49,
+ buzz_40 = 50,
+ buzz_20 = 51,
+ pulsing_strong = 52,
+ pulsing_strong_80 = 53,
+ pulsing_medium = 54,
+ pulsing_medium_80 = 55,
+ pulsing_sharp = 56,
+ pulsing_sharp_80 = 57,
+ transition_click = 58,
+ transition_click_80 = 59,
+ transition_click_60 = 60,
+ transition_click_40 = 61,
+ transition_click_20 = 62,
+ transition_click_10 = 63,
+ transition_hum = 64,
+ transition_hum_80 = 65,
+ transition_hum_60 = 66,
+ transition_hum_40 = 67,
+ transition_hum_20 = 68,
+ transition_hum_10 = 69,
+ transition_rampdown_long_smooth1 = 70,
+ transition_rampdown_long_smooth2 = 71,
+ transition_rampdown_med_smooth1 = 72,
+ transition_rampdown_med_smooth2 = 73,
+ transition_rampdown_short_smooth1 = 74,
+ transition_rampdown_short_smooth2 = 75,
+ transition_rampdown_long_sharp1 = 76,
+ transition_rampdown_long_sharp2 = 77,
+ transition_rampdown_med_sharp1 = 78,
+ transition_rampdown_med_sharp2 = 79,
+ transition_rampdown_short_sharp1 = 80,
+ transition_rampdown_short_sharp2 = 81,
+ transition_rampup_long_smooth1 = 82,
+ transition_rampup_long_smooth2 = 83,
+ transition_rampup_med_smooth1 = 84,
+ transition_rampup_med_smooth2 = 85,
+ transition_rampup_short_smooth1 = 86,
+ transition_rampup_short_smooth2 = 87,
+ transition_rampup_long_sharp1 = 88,
+ transition_rampup_long_sharp2 = 89,
+ transition_rampup_med_sharp1 = 90,
+ transition_rampup_med_sharp2 = 91,
+ transition_rampup_short_sharp1 = 92,
+ transition_rampup_short_sharp2 = 93,
+ transition_rampdown_long_smooth1_50 = 94,
+ transition_rampdown_long_smooth2_50 = 95,
+ transition_rampdown_med_smooth1_50 = 96,
+ transition_rampdown_med_smooth2_50 = 97,
+ transition_rampdown_short_smooth1_50 = 98,
+ transition_rampdown_short_smooth2_50 = 99,
+ transition_rampdown_long_sharp1_50 = 100,
+ transition_rampdown_long_sharp2_50 = 101,
+ transition_rampdown_med_sharp1_50 = 102,
+ transition_rampdown_med_sharp2_50 = 103,
+ transition_rampdown_short_sharp1_50 = 104,
+ transition_rampdown_short_sharp2_50 = 105,
+ transition_rampup_long_smooth1_50 = 106,
+ transition_rampup_long_smooth2_50 = 107,
+ transition_rampup_med_smooth1_50 = 108,
+ transition_rampup_med_smooth2_50 = 109,
+ transition_rampup_short_smooth1_50 = 110,
+ transition_rampup_short_smooth2_50 = 111,
+ transition_rampup_long_sharp1_50 = 112,
+ transition_rampup_long_sharp2_50 = 113,
+ transition_rampup_med_sharp1_50 = 114,
+ transition_rampup_med_sharp2_50 = 115,
+ transition_rampup_short_sharp1_50 = 116,
+ transition_rampup_short_sharp2_50 = 117,
+ long_buzz_for_programmatic_stopping = 118,
+ smooth_hum1_50 = 119,
+ smooth_hum2_40 = 120,
+ smooth_hum3_30 = 121,
+ smooth_hum4_20 = 122,
+ smooth_hum5_10 = 123,
+ drv_effect_max = 124,
} DRV_EFFECT;
/* Register bit array unions */
typedef union DRVREG_STATUS { /* register 0x00 */
- uint8_t Byte;
- struct {
- uint8_t OC_DETECT :1; /* set to 1 when overcurrent event is detected */
- uint8_t OVER_TEMP :1; /* set to 1 when device exceeds temp threshold */
- uint8_t FB_STS :1; /* set to 1 when feedback controller has timed out */
- /* auto-calibration routine and diagnostic result
- * result | auto-calibation | diagnostic |
- * 0 | passed | actuator func normal |
- * 1 | failed | actuator func fault* |
- * * actuator is not present or is shorted, timing out, or giving out–of-range back-EMF */
- uint8_t DIAG_RESULT :1;
- uint8_t :1;
- uint8_t DEVICE_ID :3; /* Device IDs 3: DRV2605 4: DRV2604 5: DRV2604L 6: DRV2605L */
- } Bits;
+ uint8_t Byte;
+ struct {
+ uint8_t OC_DETECT : 1; /* set to 1 when overcurrent event is detected */
+ uint8_t OVER_TEMP : 1; /* set to 1 when device exceeds temp threshold */
+ uint8_t FB_STS : 1; /* set to 1 when feedback controller has timed out */
+ /* auto-calibration routine and diagnostic result
+ * result | auto-calibation | diagnostic |
+ * 0 | passed | actuator func normal |
+ * 1 | failed | actuator func fault* |
+ * * actuator is not present or is shorted, timing out, or giving out–of-range back-EMF */
+ uint8_t DIAG_RESULT : 1;
+ uint8_t : 1;
+ uint8_t DEVICE_ID : 3; /* Device IDs 3: DRV2605 4: DRV2604 5: DRV2604L 6: DRV2605L */
+ } Bits;
} DRVREG_STATUS;
typedef union DRVREG_MODE { /* register 0x01 */
- uint8_t Byte;
- struct {
- uint8_t MODE :3; /* Mode setting */
- uint8_t :3;
- uint8_t STANDBY :1; /* 0:standby 1:ready */
- } Bits;
+ uint8_t Byte;
+ struct {
+ uint8_t MODE : 3; /* Mode setting */
+ uint8_t : 3;
+ uint8_t STANDBY : 1; /* 0:standby 1:ready */
+ } Bits;
} DRVREG_MODE;
typedef union DRVREG_WAIT {
- uint8_t Byte;
- struct {
- uint8_t WAIT_MODE :1; /* Set to 1 to interpret as wait for next 7 bits x10ms */
- uint8_t WAIT_TIME :7;
- } Bits;
+ uint8_t Byte;
+ struct {
+ uint8_t WAIT_MODE : 1; /* Set to 1 to interpret as wait for next 7 bits x10ms */
+ uint8_t WAIT_TIME : 7;
+ } Bits;
} DRVREG_WAIT;
-typedef union DRVREG_FBR{ /* register 0x1A */
- uint8_t Byte;
- struct {
- uint8_t BEMF_GAIN :2;
- uint8_t LOOP_GAIN :2;
- uint8_t BRAKE_FACTOR :3;
- uint8_t ERM_LRA :1;
- } Bits;
+typedef union DRVREG_FBR { /* register 0x1A */
+ uint8_t Byte;
+ struct {
+ uint8_t BEMF_GAIN : 2;
+ uint8_t LOOP_GAIN : 2;
+ uint8_t BRAKE_FACTOR : 3;
+ uint8_t ERM_LRA : 1;
+ } Bits;
} DRVREG_FBR;
-typedef union DRVREG_CTRL1{ /* register 0x1B */
- uint8_t Byte;
- struct {
- uint8_t C1_DRIVE_TIME :5;
- uint8_t C1_AC_COUPLE :1;
- uint8_t :1;
- uint8_t C1_STARTUP_BOOST :1;
- } Bits;
+typedef union DRVREG_CTRL1 { /* register 0x1B */
+ uint8_t Byte;
+ struct {
+ uint8_t C1_DRIVE_TIME : 5;
+ uint8_t C1_AC_COUPLE : 1;
+ uint8_t : 1;
+ uint8_t C1_STARTUP_BOOST : 1;
+ } Bits;
} DRVREG_CTRL1;
-typedef union DRVREG_CTRL2{ /* register 0x1C */
- uint8_t Byte;
- struct {
- uint8_t C2_IDISS_TIME :2;
- uint8_t C2_BLANKING_TIME :2;
- uint8_t C2_SAMPLE_TIME :2;
- uint8_t C2_BRAKE_STAB :1;
- uint8_t C2_BIDIR_INPUT :1;
- } Bits;
+typedef union DRVREG_CTRL2 { /* register 0x1C */
+ uint8_t Byte;
+ struct {
+ uint8_t C2_IDISS_TIME : 2;
+ uint8_t C2_BLANKING_TIME : 2;
+ uint8_t C2_SAMPLE_TIME : 2;
+ uint8_t C2_BRAKE_STAB : 1;
+ uint8_t C2_BIDIR_INPUT : 1;
+ } Bits;
} DRVREG_CTRL2;
-typedef union DRVREG_CTRL3{ /* register 0x1D */
- uint8_t Byte;
- struct {
- uint8_t C3_LRA_OPEN_LOOP :1;
- uint8_t C3_N_PWM_ANALOG :1;
- uint8_t C3_LRA_DRIVE_MODE :1;
- uint8_t C3_DATA_FORMAT_RTO :1;
- uint8_t C3_SUPPLY_COMP_DIS :1;
- uint8_t C3_ERM_OPEN_LOOP :1;
- uint8_t C3_NG_THRESH :2;
- } Bits;
+typedef union DRVREG_CTRL3 { /* register 0x1D */
+ uint8_t Byte;
+ struct {
+ uint8_t C3_LRA_OPEN_LOOP : 1;
+ uint8_t C3_N_PWM_ANALOG : 1;
+ uint8_t C3_LRA_DRIVE_MODE : 1;
+ uint8_t C3_DATA_FORMAT_RTO : 1;
+ uint8_t C3_SUPPLY_COMP_DIS : 1;
+ uint8_t C3_ERM_OPEN_LOOP : 1;
+ uint8_t C3_NG_THRESH : 2;
+ } Bits;
} DRVREG_CTRL3;
-typedef union DRVREG_CTRL4{ /* register 0x1E */
- uint8_t Byte;
- struct {
- uint8_t C4_OTP_PROGRAM :1;
- uint8_t :1;
- uint8_t C4_OTP_STATUS :1;
- uint8_t :1;
- uint8_t C4_AUTO_CAL_TIME :2;
- uint8_t C4_ZC_DET_TIME :2;
- } Bits;
+typedef union DRVREG_CTRL4 { /* register 0x1E */
+ uint8_t Byte;
+ struct {
+ uint8_t C4_OTP_PROGRAM : 1;
+ uint8_t : 1;
+ uint8_t C4_OTP_STATUS : 1;
+ uint8_t : 1;
+ uint8_t C4_AUTO_CAL_TIME : 2;
+ uint8_t C4_ZC_DET_TIME : 2;
+ } Bits;
} DRVREG_CTRL4;
-typedef union DRVREG_CTRL5{ /* register 0x1F */
- uint8_t Byte;
- struct {
- uint8_t C5_IDISS_TIME :2;
- uint8_t C5_BLANKING_TIME :2;
- uint8_t C5_PLAYBACK_INTERVAL :1;
- uint8_t C5_LRA_AUTO_OPEN_LOOP :1;
- uint8_t C5_AUTO_OL_CNT :2;
- } Bits;
+typedef union DRVREG_CTRL5 { /* register 0x1F */
+ uint8_t Byte;
+ struct {
+ uint8_t C5_IDISS_TIME : 2;
+ uint8_t C5_BLANKING_TIME : 2;
+ uint8_t C5_PLAYBACK_INTERVAL : 1;
+ uint8_t C5_LRA_AUTO_OPEN_LOOP : 1;
+ uint8_t C5_AUTO_OL_CNT : 2;
+ } Bits;
} DRVREG_CTRL5; \ No newline at end of file
diff --git a/drivers/haptic/haptic.c b/drivers/haptic/haptic.c
index a94f05565c..ded6d8a44a 100644
--- a/drivers/haptic/haptic.c
+++ b/drivers/haptic/haptic.c
@@ -19,230 +19,248 @@
#include "progmem.h"
#include "debug.h"
#ifdef DRV2605L
-#include "DRV2605L.h"
+# include "DRV2605L.h"
#endif
#ifdef SOLENOID_ENABLE
-#include "solenoid.h"
+# include "solenoid.h"
#endif
haptic_config_t haptic_config;
void haptic_init(void) {
- debug_enable = 1; //Debug is ON!
- if (!eeconfig_is_enabled()) {
- eeconfig_init();
- }
- haptic_config.raw = eeconfig_read_haptic();
- if (haptic_config.mode < 1){
- haptic_config.mode = 1;
- }
- if (!haptic_config.mode){
- dprintf("No haptic config found in eeprom, setting default configs\n");
- haptic_reset();
- }
- #ifdef SOLENOID_ENABLE
+ debug_enable = 1; // Debug is ON!
+ if (!eeconfig_is_enabled()) {
+ eeconfig_init();
+ }
+ haptic_config.raw = eeconfig_read_haptic();
+ if (haptic_config.mode < 1) {
+ haptic_config.mode = 1;
+ }
+ if (!haptic_config.mode) {
+ dprintf("No haptic config found in eeprom, setting default configs\n");
+ haptic_reset();
+ }
+#ifdef SOLENOID_ENABLE
solenoid_setup();
dprintf("Solenoid driver initialized\n");
- #endif
- #ifdef DRV2605L
+#endif
+#ifdef DRV2605L
DRV_init();
dprintf("DRV2605 driver initialized\n");
- #endif
- eeconfig_debug_haptic();
+#endif
+ eeconfig_debug_haptic();
}
void haptic_task(void) {
- #ifdef SOLENOID_ENABLE
- solenoid_check();
- #endif
+#ifdef SOLENOID_ENABLE
+ solenoid_check();
+#endif
}
void eeconfig_debug_haptic(void) {
- dprintf("haptic_config eprom\n");
- dprintf("haptic_config.enable = %d\n", haptic_config.enable);
- dprintf("haptic_config.mode = %d\n", haptic_config.mode);
+ dprintf("haptic_config eprom\n");
+ dprintf("haptic_config.enable = %d\n", haptic_config.enable);
+ dprintf("haptic_config.mode = %d\n", haptic_config.mode);
}
void haptic_enable(void) {
- haptic_config.enable = 1;
- xprintf("haptic_config.enable = %u\n", haptic_config.enable);
- eeconfig_update_haptic(haptic_config.raw);
+ haptic_config.enable = 1;
+ xprintf("haptic_config.enable = %u\n", haptic_config.enable);
+ eeconfig_update_haptic(haptic_config.raw);
}
void haptic_disable(void) {
- haptic_config.enable = 0;
- xprintf("haptic_config.enable = %u\n", haptic_config.enable);
- eeconfig_update_haptic(haptic_config.raw);
+ haptic_config.enable = 0;
+ xprintf("haptic_config.enable = %u\n", haptic_config.enable);
+ eeconfig_update_haptic(haptic_config.raw);
}
void haptic_toggle(void) {
-if (haptic_config.enable) {
- haptic_disable();
- } else {
- haptic_enable();
- }
- eeconfig_update_haptic(haptic_config.raw);
+ if (haptic_config.enable) {
+ haptic_disable();
+ } else {
+ haptic_enable();
+ }
+ eeconfig_update_haptic(haptic_config.raw);
}
-void haptic_feedback_toggle(void){
- haptic_config.feedback++;
- if (haptic_config.feedback >= HAPTIC_FEEDBACK_MAX)
- haptic_config.feedback = KEY_PRESS;
- xprintf("haptic_config.feedback = %u\n", !haptic_config.feedback);
- eeconfig_update_haptic(haptic_config.raw);
+void haptic_feedback_toggle(void) {
+ haptic_config.feedback++;
+ if (haptic_config.feedback >= HAPTIC_FEEDBACK_MAX) haptic_config.feedback = KEY_PRESS;
+ xprintf("haptic_config.feedback = %u\n", !haptic_config.feedback);
+ eeconfig_update_haptic(haptic_config.raw);
}
void haptic_buzz_toggle(void) {
- bool buzz_stat = !haptic_config.buzz;
- haptic_config.buzz = buzz_stat;
- haptic_set_buzz(buzz_stat);
+ bool buzz_stat = !haptic_config.buzz;
+ haptic_config.buzz = buzz_stat;
+ haptic_set_buzz(buzz_stat);
}
void haptic_mode_increase(void) {
- uint8_t mode = haptic_config.mode + 1;
- #ifdef DRV2605L
- if (haptic_config.mode >= drv_effect_max) {
- mode = 1;
- }
- #endif
+ uint8_t mode = haptic_config.mode + 1;
+#ifdef DRV2605L
+ if (haptic_config.mode >= drv_effect_max) {
+ mode = 1;
+ }
+#endif
haptic_set_mode(mode);
}
void haptic_mode_decrease(void) {
- uint8_t mode = haptic_config.mode -1;
- #ifdef DRV2605L
- if (haptic_config.mode < 1) {
- mode = (drv_effect_max - 1);
- }
- #endif
- haptic_set_mode(mode);
+ uint8_t mode = haptic_config.mode - 1;
+#ifdef DRV2605L
+ if (haptic_config.mode < 1) {
+ mode = (drv_effect_max - 1);
+ }
+#endif
+ haptic_set_mode(mode);
}
void haptic_dwell_increase(void) {
- uint8_t dwell = haptic_config.dwell + 1;
- #ifdef SOLENOID_ENABLE
- if (haptic_config.dwell >= SOLENOID_MAX_DWELL) {
- dwell = 1;
- }
- solenoid_set_dwell(dwell);
- #endif
- haptic_set_dwell(dwell);
+ uint8_t dwell = haptic_config.dwell + 1;
+#ifdef SOLENOID_ENABLE
+ if (haptic_config.dwell >= SOLENOID_MAX_DWELL) {
+ dwell = 1;
+ }
+ solenoid_set_dwell(dwell);
+#endif
+ haptic_set_dwell(dwell);
}
void haptic_dwell_decrease(void) {
- uint8_t dwell = haptic_config.dwell -1;
- #ifdef SOLENOID_ENABLE
- if (haptic_config.dwell < SOLENOID_MIN_DWELL) {
- dwell = SOLENOID_MAX_DWELL;
- }
- solenoid_set_dwell(dwell);
- #endif
- haptic_set_dwell(dwell);
-}
-
-void haptic_reset(void){
- haptic_config.enable = true;
- uint8_t feedback = HAPTIC_FEEDBACK_DEFAULT;
- haptic_config.feedback = feedback;
- #ifdef DRV2605L
- uint8_t mode = HAPTIC_MODE_DEFAULT;
+ uint8_t dwell = haptic_config.dwell - 1;
+#ifdef SOLENOID_ENABLE
+ if (haptic_config.dwell < SOLENOID_MIN_DWELL) {
+ dwell = SOLENOID_MAX_DWELL;
+ }
+ solenoid_set_dwell(dwell);
+#endif
+ haptic_set_dwell(dwell);
+}
+
+void haptic_reset(void) {
+ haptic_config.enable = true;
+ uint8_t feedback = HAPTIC_FEEDBACK_DEFAULT;
+ haptic_config.feedback = feedback;
+#ifdef DRV2605L
+ uint8_t mode = HAPTIC_MODE_DEFAULT;
haptic_config.mode = mode;
- #endif
- #ifdef SOLENOID_ENABLE
- uint8_t dwell = SOLENOID_DEFAULT_DWELL;
+#endif
+#ifdef SOLENOID_ENABLE
+ uint8_t dwell = SOLENOID_DEFAULT_DWELL;
haptic_config.dwell = dwell;
- #endif
- eeconfig_update_haptic(haptic_config.raw);
- xprintf("haptic_config.feedback = %u\n", haptic_config.feedback);
- xprintf("haptic_config.mode = %u\n", haptic_config.mode);
+#endif
+ eeconfig_update_haptic(haptic_config.raw);
+ xprintf("haptic_config.feedback = %u\n", haptic_config.feedback);
+ xprintf("haptic_config.mode = %u\n", haptic_config.mode);
}
void haptic_set_feedback(uint8_t feedback) {
- haptic_config.feedback = feedback;
- eeconfig_update_haptic(haptic_config.raw);
- xprintf("haptic_config.feedback = %u\n", haptic_config.feedback);
+ haptic_config.feedback = feedback;
+ eeconfig_update_haptic(haptic_config.raw);
+ xprintf("haptic_config.feedback = %u\n", haptic_config.feedback);
}
void haptic_set_mode(uint8_t mode) {
- haptic_config.mode = mode;
- eeconfig_update_haptic(haptic_config.raw);
- xprintf("haptic_config.mode = %u\n", haptic_config.mode);
+ haptic_config.mode = mode;
+ eeconfig_update_haptic(haptic_config.raw);
+ xprintf("haptic_config.mode = %u\n", haptic_config.mode);
}
void haptic_set_buzz(uint8_t buzz) {
- haptic_config.buzz = buzz;
- eeconfig_update_haptic(haptic_config.raw);
- xprintf("haptic_config.buzz = %u\n", haptic_config.buzz);
+ haptic_config.buzz = buzz;
+ eeconfig_update_haptic(haptic_config.raw);
+ xprintf("haptic_config.buzz = %u\n", haptic_config.buzz);
}
void haptic_set_dwell(uint8_t dwell) {
- haptic_config.dwell = dwell;
- eeconfig_update_haptic(haptic_config.raw);
- xprintf("haptic_config.dwell = %u\n", haptic_config.dwell);
+ haptic_config.dwell = dwell;
+ eeconfig_update_haptic(haptic_config.raw);
+ xprintf("haptic_config.dwell = %u\n", haptic_config.dwell);
}
uint8_t haptic_get_mode(void) {
- if (!haptic_config.enable){
- return false;
- }
- return haptic_config.mode;
+ if (!haptic_config.enable) {
+ return false;
+ }
+ return haptic_config.mode;
}
uint8_t haptic_get_feedback(void) {
- if (!haptic_config.enable){
- return false;
- }
- return haptic_config.feedback;
+ if (!haptic_config.enable) {
+ return false;
+ }
+ return haptic_config.feedback;
}
uint8_t haptic_get_dwell(void) {
- if (!haptic_config.enable){
- return false;
- }
- return haptic_config.dwell;
+ if (!haptic_config.enable) {
+ return false;
+ }
+ return haptic_config.dwell;
}
void haptic_play(void) {
- #ifdef DRV2605L
- uint8_t play_eff = 0;
- play_eff = haptic_config.mode;
- DRV_pulse(play_eff);
- #endif
- #ifdef SOLENOID_ENABLE
- solenoid_fire();
- #endif
+#ifdef DRV2605L
+ uint8_t play_eff = 0;
+ play_eff = haptic_config.mode;
+ DRV_pulse(play_eff);
+#endif
+#ifdef SOLENOID_ENABLE
+ solenoid_fire();
+#endif
}
bool process_haptic(uint16_t keycode, keyrecord_t *record) {
- if (keycode == HPT_ON && record->event.pressed) { haptic_enable(); }
- if (keycode == HPT_OFF && record->event.pressed) { haptic_disable(); }
- if (keycode == HPT_TOG && record->event.pressed) { haptic_toggle(); }
- if (keycode == HPT_RST && record->event.pressed) { haptic_reset(); }
- if (keycode == HPT_FBK && record->event.pressed) { haptic_feedback_toggle(); }
- if (keycode == HPT_BUZ && record->event.pressed) { haptic_buzz_toggle(); }
- if (keycode == HPT_MODI && record->event.pressed) { haptic_mode_increase(); }
- if (keycode == HPT_MODD && record->event.pressed) { haptic_mode_decrease(); }
- if (keycode == HPT_DWLI && record->event.pressed) { haptic_dwell_increase(); }
- if (keycode == HPT_DWLD && record->event.pressed) { haptic_dwell_decrease(); }
- if (haptic_config.enable) {
- if ( record->event.pressed ) {
- // keypress
- if (haptic_config.feedback < 2) {
- haptic_play();
- }
- } else {
- //keyrelease
- if (haptic_config.feedback > 0) {
- haptic_play();
- }
+ if (keycode == HPT_ON && record->event.pressed) {
+ haptic_enable();
}
- }
- return true;
+ if (keycode == HPT_OFF && record->event.pressed) {
+ haptic_disable();
+ }
+ if (keycode == HPT_TOG && record->event.pressed) {
+ haptic_toggle();
+ }
+ if (keycode == HPT_RST && record->event.pressed) {
+ haptic_reset();
+ }
+ if (keycode == HPT_FBK && record->event.pressed) {
+ haptic_feedback_toggle();
+ }
+ if (keycode == HPT_BUZ && record->event.pressed) {
+ haptic_buzz_toggle();
+ }
+ if (keycode == HPT_MODI && record->event.pressed) {
+ haptic_mode_increase();
+ }
+ if (keycode == HPT_MODD && record->event.pressed) {
+ haptic_mode_decrease();
+ }
+ if (keycode == HPT_DWLI && record->event.pressed) {
+ haptic_dwell_increase();
+ }
+ if (keycode == HPT_DWLD && record->event.pressed) {
+ haptic_dwell_decrease();
+ }
+ if (haptic_config.enable) {
+ if (record->event.pressed) {
+ // keypress
+ if (haptic_config.feedback < 2) {
+ haptic_play();
+ }
+ } else {
+ // keyrelease
+ if (haptic_config.feedback > 0) {
+ haptic_play();
+ }
+ }
+ }
+ return true;
}
void haptic_shutdown(void) {
- #ifdef SOLENOID_ENABLE
- solenoid_shutdown();
- #endif
-
+#ifdef SOLENOID_ENABLE
+ solenoid_shutdown();
+#endif
}
diff --git a/drivers/haptic/haptic.h b/drivers/haptic/haptic.h
index d39dc5c3b9..8135d0d439 100644
--- a/drivers/haptic/haptic.h
+++ b/drivers/haptic/haptic.h
@@ -20,63 +20,57 @@
#include <stdbool.h>
#include "quantum.h"
#ifdef DRV2605L
-#include "DRV2605L.h"
+# include "DRV2605L.h"
#endif
-
#ifndef HAPTIC_FEEDBACK_DEFAULT
-#define HAPTIC_FEEDBACK_DEFAULT 0
+# define HAPTIC_FEEDBACK_DEFAULT 0
#endif
#ifndef HAPTIC_MODE_DEFAULT
-#define HAPTIC_MODE_DEFAULT DRV_MODE_DEFAULT
+# define HAPTIC_MODE_DEFAULT DRV_MODE_DEFAULT
#endif
/* EEPROM config settings */
typedef union {
- uint32_t raw;
- struct {
- bool enable :1;
- uint8_t feedback :2;
- uint8_t mode :7;
- bool buzz :1;
- uint8_t dwell :7;
- uint16_t reserved :16;
- };
+ uint32_t raw;
+ struct {
+ bool enable : 1;
+ uint8_t feedback : 2;
+ uint8_t mode : 7;
+ bool buzz : 1;
+ uint8_t dwell : 7;
+ uint16_t reserved : 16;
+ };
} haptic_config_t;
-typedef enum HAPTIC_FEEDBACK{
- KEY_PRESS,
- KEY_PRESS_RELEASE,
- KEY_RELEASE,
- HAPTIC_FEEDBACK_MAX,
+typedef enum HAPTIC_FEEDBACK {
+ KEY_PRESS,
+ KEY_PRESS_RELEASE,
+ KEY_RELEASE,
+ HAPTIC_FEEDBACK_MAX,
} HAPTIC_FEEDBACK;
-bool process_haptic(uint16_t keycode, keyrecord_t *record);
-void haptic_init(void);
-void haptic_task(void);
-void eeconfig_debug_haptic(void);
-void haptic_enable(void);
-void haptic_disable(void);
-void haptic_toggle(void);
-void haptic_feedback_toggle(void);
-void haptic_mode_increase(void);
-void haptic_mode_decrease(void);
-void haptic_mode(uint8_t mode);
-void haptic_reset(void);
-void haptic_set_feedback(uint8_t feedback);
-void haptic_set_mode(uint8_t mode);
-void haptic_set_dwell(uint8_t dwell);
-void haptic_set_buzz(uint8_t buzz);
-void haptic_buzz_toggle(void);
+bool process_haptic(uint16_t keycode, keyrecord_t *record);
+void haptic_init(void);
+void haptic_task(void);
+void eeconfig_debug_haptic(void);
+void haptic_enable(void);
+void haptic_disable(void);
+void haptic_toggle(void);
+void haptic_feedback_toggle(void);
+void haptic_mode_increase(void);
+void haptic_mode_decrease(void);
+void haptic_mode(uint8_t mode);
+void haptic_reset(void);
+void haptic_set_feedback(uint8_t feedback);
+void haptic_set_mode(uint8_t mode);
+void haptic_set_dwell(uint8_t dwell);
+void haptic_set_buzz(uint8_t buzz);
+void haptic_buzz_toggle(void);
uint8_t haptic_get_mode(void);
uint8_t haptic_get_feedback(void);
-void haptic_dwell_increase(void);
-void haptic_dwell_decrease(void);
+void haptic_dwell_increase(void);
+void haptic_dwell_decrease(void);
void haptic_play(void);
void haptic_shutdown(void);
-
-
-
-
-
diff --git a/drivers/haptic/solenoid.c b/drivers/haptic/solenoid.c
index 2d39dbc179..d645c379ae 100644
--- a/drivers/haptic/solenoid.c
+++ b/drivers/haptic/solenoid.c
@@ -19,91 +19,77 @@
#include "solenoid.h"
#include "haptic.h"
-bool solenoid_on = false;
-bool solenoid_buzzing = false;
-uint16_t solenoid_start = 0;
-uint8_t solenoid_dwell = SOLENOID_DEFAULT_DWELL;
+bool solenoid_on = false;
+bool solenoid_buzzing = false;
+uint16_t solenoid_start = 0;
+uint8_t solenoid_dwell = SOLENOID_DEFAULT_DWELL;
extern haptic_config_t haptic_config;
+void solenoid_buzz_on(void) { haptic_set_buzz(1); }
-void solenoid_buzz_on(void) {
- haptic_set_buzz(1);
-}
-
-void solenoid_buzz_off(void) {
- haptic_set_buzz(0);
-}
-
-void solenoid_set_buzz(int buzz) {
- haptic_set_buzz(buzz);
-}
+void solenoid_buzz_off(void) { haptic_set_buzz(0); }
+void solenoid_set_buzz(int buzz) { haptic_set_buzz(buzz); }
void solenoid_dwell_minus(uint8_t solenoid_dwell) {
- if (solenoid_dwell > 0) solenoid_dwell--;
+ if (solenoid_dwell > 0) solenoid_dwell--;
}
void solenoid_dwell_plus(uint8_t solenoid_dwell) {
- if (solenoid_dwell < SOLENOID_MAX_DWELL) solenoid_dwell++;
+ if (solenoid_dwell < SOLENOID_MAX_DWELL) solenoid_dwell++;
}
-void solenoid_set_dwell(uint8_t dwell) {
- solenoid_dwell = dwell;
-}
+void solenoid_set_dwell(uint8_t dwell) { solenoid_dwell = dwell; }
void solenoid_stop(void) {
- writePinLow(SOLENOID_PIN);
- solenoid_on = false;
- solenoid_buzzing = false;
+ writePinLow(SOLENOID_PIN);
+ solenoid_on = false;
+ solenoid_buzzing = false;
}
void solenoid_fire(void) {
- if (!haptic_config.buzz && solenoid_on) return;
- if (haptic_config.buzz && solenoid_buzzing) return;
+ if (!haptic_config.buzz && solenoid_on) return;
+ if (haptic_config.buzz && solenoid_buzzing) return;
- solenoid_on = true;
- solenoid_buzzing = true;
- solenoid_start = timer_read();
- writePinHigh(SOLENOID_PIN);
+ solenoid_on = true;
+ solenoid_buzzing = true;
+ solenoid_start = timer_read();
+ writePinHigh(SOLENOID_PIN);
}
void solenoid_check(void) {
- uint16_t elapsed = 0;
-
- if (!solenoid_on) return;
+ uint16_t elapsed = 0;
- elapsed = timer_elapsed(solenoid_start);
+ if (!solenoid_on) return;
- //Check if it's time to finish this solenoid click cycle
- if (elapsed > solenoid_dwell) {
- solenoid_stop();
- return;
- }
+ elapsed = timer_elapsed(solenoid_start);
- //Check whether to buzz the solenoid on and off
- if (haptic_config.buzz) {
- if (elapsed / SOLENOID_MIN_DWELL % 2 == 0){
- if (!solenoid_buzzing) {
- solenoid_buzzing = true;
- writePinHigh(SOLENOID_PIN);
- }
+ // Check if it's time to finish this solenoid click cycle
+ if (elapsed > solenoid_dwell) {
+ solenoid_stop();
+ return;
}
- else {
- if (solenoid_buzzing) {
- solenoid_buzzing = false;
- writePinLow(SOLENOID_PIN);
- }
+
+ // Check whether to buzz the solenoid on and off
+ if (haptic_config.buzz) {
+ if (elapsed / SOLENOID_MIN_DWELL % 2 == 0) {
+ if (!solenoid_buzzing) {
+ solenoid_buzzing = true;
+ writePinHigh(SOLENOID_PIN);
+ }
+ } else {
+ if (solenoid_buzzing) {
+ solenoid_buzzing = false;
+ writePinLow(SOLENOID_PIN);
+ }
+ }
}
- }
}
void solenoid_setup(void) {
- setPinOutput(SOLENOID_PIN);
- solenoid_fire();
+ setPinOutput(SOLENOID_PIN);
+ solenoid_fire();
}
-void solenoid_shutdown(void) {
- writePinLow(SOLENOID_PIN);
-
-}
+void solenoid_shutdown(void) { writePinLow(SOLENOID_PIN); }
diff --git a/drivers/haptic/solenoid.h b/drivers/haptic/solenoid.h
index a08f62a11e..53dc626e33 100644
--- a/drivers/haptic/solenoid.h
+++ b/drivers/haptic/solenoid.h
@@ -18,23 +18,23 @@
#pragma once
#ifndef SOLENOID_DEFAULT_DWELL
-#define SOLENOID_DEFAULT_DWELL 12
+# define SOLENOID_DEFAULT_DWELL 12
#endif
#ifndef SOLENOID_MAX_DWELL
-#define SOLENOID_MAX_DWELL 100
+# define SOLENOID_MAX_DWELL 100
#endif
#ifndef SOLENOID_MIN_DWELL
-#define SOLENOID_MIN_DWELL 4
+# define SOLENOID_MIN_DWELL 4
#endif
#ifndef SOLENOID_ACTIVE
-#define SOLENOID_ACTIVE false
+# define SOLENOID_ACTIVE false
#endif
#ifndef SOLENOID_PIN
-#define SOLENOID_PIN F6
+# define SOLENOID_PIN F6
#endif
void solenoid_buzz_on(void);
diff --git a/drivers/issi/is31fl3218.c b/drivers/issi/is31fl3218.c
index db44f72564..d43863ac4b 100644
--- a/drivers/issi/is31fl3218.c
+++ b/drivers/issi/is31fl3218.c
@@ -35,68 +35,62 @@ uint8_t g_twi_transfer_buffer[20];
// IS31FL3218 has 18 PWM outputs and a fixed I2C address, so no chaining.
// If used as RGB LED driver, LEDs are assigned RGB,RGB,RGB,RGB,RGB,RGB
uint8_t g_pwm_buffer[18];
-bool g_pwm_buffer_update_required = false;
+bool g_pwm_buffer_update_required = false;
-void IS31FL3218_write_register( uint8_t reg, uint8_t data )
-{
- g_twi_transfer_buffer[0] = reg;
- g_twi_transfer_buffer[1] = data;
- i2c_transmit( ISSI_ADDRESS, g_twi_transfer_buffer, 2, ISSI_TIMEOUT);
+void IS31FL3218_write_register(uint8_t reg, uint8_t data) {
+ g_twi_transfer_buffer[0] = reg;
+ g_twi_transfer_buffer[1] = data;
+ i2c_transmit(ISSI_ADDRESS, g_twi_transfer_buffer, 2, ISSI_TIMEOUT);
}
-void IS31FL3218_write_pwm_buffer( uint8_t *pwm_buffer )
-{
- g_twi_transfer_buffer[0] = ISSI_REG_PWM;
- for ( int i=0; i<18; i++ ) {
- g_twi_transfer_buffer[1+i] = pwm_buffer[i];
- }
-
- i2c_transmit( ISSI_ADDRESS, g_twi_transfer_buffer, 19, ISSI_TIMEOUT);
+void IS31FL3218_write_pwm_buffer(uint8_t *pwm_buffer) {
+ g_twi_transfer_buffer[0] = ISSI_REG_PWM;
+ for (int i = 0; i < 18; i++) {
+ g_twi_transfer_buffer[1 + i] = pwm_buffer[i];
+ }
+
+ i2c_transmit(ISSI_ADDRESS, g_twi_transfer_buffer, 19, ISSI_TIMEOUT);
}
-void IS31FL3218_init(void)
-{
- // In case we ever want to reinitialize (?)
- IS31FL3218_write_register( ISSI_REG_RESET, 0x00 );
-
- // Turn off software shutdown
- IS31FL3218_write_register( ISSI_REG_SHUTDOWN, 0x01 );
-
- // Set all PWM values to zero
- for ( uint8_t i = 0; i < 18; i++ ) {
- IS31FL3218_write_register( ISSI_REG_PWM+i, 0x00 );
- }
-
- // Enable all channels
- for ( uint8_t i = 0; i < 3; i++ ) {
- IS31FL3218_write_register( ISSI_REG_CONTROL+i, 0b00111111 );
- }
-
- // Load PWM registers and LED Control register data
- IS31FL3218_write_register( ISSI_REG_UPDATE, 0x01 );
+void IS31FL3218_init(void) {
+ // In case we ever want to reinitialize (?)
+ IS31FL3218_write_register(ISSI_REG_RESET, 0x00);
+
+ // Turn off software shutdown
+ IS31FL3218_write_register(ISSI_REG_SHUTDOWN, 0x01);
+
+ // Set all PWM values to zero
+ for (uint8_t i = 0; i < 18; i++) {
+ IS31FL3218_write_register(ISSI_REG_PWM + i, 0x00);
+ }
+
+ // Enable all channels
+ for (uint8_t i = 0; i < 3; i++) {
+ IS31FL3218_write_register(ISSI_REG_CONTROL + i, 0b00111111);
+ }
+
+ // Load PWM registers and LED Control register data
+ IS31FL3218_write_register(ISSI_REG_UPDATE, 0x01);
}
-void IS31FL3218_set_color( int index, uint8_t red, uint8_t green, uint8_t blue )
-{
- g_pwm_buffer[index * 3 + 0] = red;
- g_pwm_buffer[index * 3 + 1] = green;
- g_pwm_buffer[index * 3 + 2] = blue;
- g_pwm_buffer_update_required = true;
+void IS31FL3218_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
+ g_pwm_buffer[index * 3 + 0] = red;
+ g_pwm_buffer[index * 3 + 1] = green;
+ g_pwm_buffer[index * 3 + 2] = blue;
+ g_pwm_buffer_update_required = true;
}
-void IS31FL3218_set_color_all( uint8_t red, uint8_t green, uint8_t blue )
-{
- for ( int i = 0; i < 6; i++ ) {
- IS31FL3218_set_color( i, red, green, blue );
- }
+void IS31FL3218_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
+ for (int i = 0; i < 6; i++) {
+ IS31FL3218_set_color(i, red, green, blue);
+ }
}
-void IS31FL3218_update_pwm_buffers(void)
-{
- if ( g_pwm_buffer_update_required ) {
- IS31FL3218_write_pwm_buffer( g_pwm_buffer );
- // Load PWM registers and LED Control register data
- IS31FL3218_write_register( ISSI_REG_UPDATE, 0x01 );
- }
- g_pwm_buffer_update_required = false;
+void IS31FL3218_update_pwm_buffers(void) {
+ if (g_pwm_buffer_update_required) {
+ IS31FL3218_write_pwm_buffer(g_pwm_buffer);
+ // Load PWM registers and LED Control register data
+ IS31FL3218_write_register(ISSI_REG_UPDATE, 0x01);
+ }
+ g_pwm_buffer_update_required = false;
}
diff --git a/drivers/issi/is31fl3218.h b/drivers/issi/is31fl3218.h
index 2d24e51463..a70cc1e793 100644
--- a/drivers/issi/is31fl3218.h
+++ b/drivers/issi/is31fl3218.h
@@ -19,6 +19,6 @@
#include <stdbool.h>
void IS31FL3218_init(void);
-void IS31FL3218_set_color( int index, uint8_t red, uint8_t green, uint8_t blue );
-void IS31FL3218_set_color_all( uint8_t red, uint8_t green, uint8_t blue );
+void IS31FL3218_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
+void IS31FL3218_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
void IS31FL3218_update_pwm_buffers(void);
diff --git a/drivers/issi/is31fl3731-simple.c b/drivers/issi/is31fl3731-simple.c
index a7faa9c38c..fad4676def 100644
--- a/drivers/issi/is31fl3731-simple.c
+++ b/drivers/issi/is31fl3731-simple.c
@@ -17,11 +17,11 @@
*/
#ifdef __AVR__
-#include <avr/interrupt.h>
-#include <avr/io.h>
-#include <util/delay.h>
+# include <avr/interrupt.h>
+# include <avr/io.h>
+# include <util/delay.h>
#else
-#include "wait.h"
+# include "wait.h"
#endif
#include <stdint.h>
@@ -41,7 +41,7 @@
// 0b1110110 AD <-> SDA
#define ISSI_ADDR_DEFAULT 0x74
-#define ISSI_REG_CONFIG 0x00
+#define ISSI_REG_CONFIG 0x00
#define ISSI_REG_CONFIG_PICTUREMODE 0x00
#define ISSI_REG_CONFIG_AUTOPLAYMODE 0x08
#define ISSI_REG_CONFIG_AUDIOPLAYMODE 0x18
@@ -50,20 +50,20 @@
#define ISSI_CONF_AUTOFRAMEMODE 0x04
#define ISSI_CONF_AUDIOMODE 0x08
-#define ISSI_REG_PICTUREFRAME 0x01
+#define ISSI_REG_PICTUREFRAME 0x01
#define ISSI_REG_SHUTDOWN 0x0A
#define ISSI_REG_AUDIOSYNC 0x06
#define ISSI_COMMANDREGISTER 0xFD
-#define ISSI_BANK_FUNCTIONREG 0x0B // helpfully called 'page nine'
+#define ISSI_BANK_FUNCTIONREG 0x0B // helpfully called 'page nine'
#ifndef ISSI_TIMEOUT
- #define ISSI_TIMEOUT 100
+# define ISSI_TIMEOUT 100
#endif
#ifndef ISSI_PERSISTENCE
- #define ISSI_PERSISTENCE 0
+# define ISSI_PERSISTENCE 0
#endif
// Transfer buffer for TWITransmitData()
@@ -75,17 +75,17 @@ uint8_t g_twi_transfer_buffer[20];
// buffers and the transfers in IS31FL3731_write_pwm_buffer() but it's
// probably not worth the extra complexity.
uint8_t g_pwm_buffer[LED_DRIVER_COUNT][144];
-bool g_pwm_buffer_update_required = false;
+bool g_pwm_buffer_update_required = false;
/* There's probably a better way to init this... */
#if LED_DRIVER_COUNT == 1
- uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}};
+uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}};
#elif LED_DRIVER_COUNT == 2
- uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}, {0}};
+uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}, {0}};
#elif LED_DRIVER_COUNT == 3
- uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}, {0}, {0}};
+uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}, {0}, {0}};
#elif LED_DRIVER_COUNT == 4
- uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}, {0}, {0}, {0}};
+uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}, {0}, {0}, {0}};
#endif
bool g_led_control_registers_update_required = false;
@@ -103,20 +103,19 @@ bool g_led_control_registers_update_required = false;
// 0x0E - R17,G15,G14,G13,G12,G11,G10,G09
// 0x10 - R16,R15,R14,R13,R12,R11,R10,R09
-
void IS31FL3731_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
g_twi_transfer_buffer[0] = reg;
g_twi_transfer_buffer[1] = data;
- #if ISSI_PERSISTENCE > 0
- for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
- if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0) {
- break;
- }
+#if ISSI_PERSISTENCE > 0
+ for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
+ if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0) {
+ break;
}
- #else
- i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT);
- #endif
+ }
+#else
+ i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT);
+#endif
}
void IS31FL3731_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
@@ -136,14 +135,13 @@ void IS31FL3731_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
g_twi_transfer_buffer[1 + j] = pwm_buffer[i + j];
}
- #if ISSI_PERSISTENCE > 0
- for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
- if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0)
- break;
- }
- #else
- i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT);
- #endif
+#if ISSI_PERSISTENCE > 0
+ for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
+ if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0) break;
+ }
+#else
+ i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT);
+#endif
}
}
@@ -196,7 +194,6 @@ void IS31FL3731_init(uint8_t addr) {
// most usage after initialization is just writing PWM buffers in bank 0
// as there's not much point in double-buffering
IS31FL3731_write_register(addr, ISSI_COMMANDREGISTER, 0);
-
}
void IS31FL3731_set_value(int index, uint8_t value) {
@@ -205,7 +202,7 @@ void IS31FL3731_set_value(int index, uint8_t value) {
// Subtract 0x24 to get the second index of g_pwm_buffer
g_pwm_buffer[led.driver][led.v - 0x24] = value;
- g_pwm_buffer_update_required = true;
+ g_pwm_buffer_update_required = true;
}
}
@@ -216,10 +213,10 @@ void IS31FL3731_set_value_all(uint8_t value) {
}
void IS31FL3731_set_led_control_register(uint8_t index, bool value) {
- is31_led led = g_is31_leds[index];
+ is31_led led = g_is31_leds[index];
- uint8_t control_register = (led.v - 0x24) / 8;
- uint8_t bit_value = (led.v - 0x24) % 8;
+ uint8_t control_register = (led.v - 0x24) / 8;
+ uint8_t bit_value = (led.v - 0x24) % 8;
if (value) {
g_led_control_registers[led.driver][control_register] |= (1 << bit_value);
@@ -239,7 +236,7 @@ void IS31FL3731_update_pwm_buffers(uint8_t addr, uint8_t index) {
void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index) {
if (g_led_control_registers_update_required) {
- for (int i=0; i<18; i++) {
+ for (int i = 0; i < 18; i++) {
IS31FL3731_write_register(addr, i, g_led_control_registers[index][i]);
}
}
diff --git a/drivers/issi/is31fl3731-simple.h b/drivers/issi/is31fl3731-simple.h
index dbe4982817..a223c351e8 100644
--- a/drivers/issi/is31fl3731-simple.h
+++ b/drivers/issi/is31fl3731-simple.h
@@ -16,14 +16,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
#ifndef IS31FL3731_DRIVER_H
#define IS31FL3731_DRIVER_H
-
typedef struct is31_led {
- uint8_t driver:2;
- uint8_t v;
+ uint8_t driver : 2;
+ uint8_t v;
} __attribute__((packed)) is31_led;
extern const is31_led g_is31_leds[LED_DRIVER_LED_COUNT];
@@ -44,16 +42,16 @@ void IS31FL3731_set_led_control_register(uint8_t index, bool value);
void IS31FL3731_update_pwm_buffers(uint8_t addr, uint8_t index);
void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index);
-#define C1_1 0x24
-#define C1_2 0x25
-#define C1_3 0x26
-#define C1_4 0x27
-#define C1_5 0x28
-#define C1_6 0x29
-#define C1_7 0x2A
-#define C1_8 0x2B
+#define C1_1 0x24
+#define C1_2 0x25
+#define C1_3 0x26
+#define C1_4 0x27
+#define C1_5 0x28
+#define C1_6 0x29
+#define C1_7 0x2A
+#define C1_8 0x2B
-#define C1_9 0x2C
+#define C1_9 0x2C
#define C1_10 0x2D
#define C1_11 0x2E
#define C1_12 0x2F
@@ -62,16 +60,16 @@ void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index);
#define C1_15 0x32
#define C1_16 0x33
-#define C2_1 0x34
-#define C2_2 0x35
-#define C2_3 0x36
-#define C2_4 0x37
-#define C2_5 0x38
-#define C2_6 0x39
-#define C2_7 0x3A
-#define C2_8 0x3B
+#define C2_1 0x34
+#define C2_2 0x35
+#define C2_3 0x36
+#define C2_4 0x37
+#define C2_5 0x38
+#define C2_6 0x39
+#define C2_7 0x3A
+#define C2_8 0x3B
-#define C2_9 0x3C
+#define C2_9 0x3C
#define C2_10 0x3D
#define C2_11 0x3E
#define C2_12 0x3F
@@ -80,16 +78,16 @@ void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index);
#define C2_15 0x42
#define C2_16 0x43
-#define C3_1 0x44
-#define C3_2 0x45
-#define C3_3 0x46
-#define C3_4 0x47
-#define C3_5 0x48
-#define C3_6 0x49
-#define C3_7 0x4A
-#define C3_8 0x4B
+#define C3_1 0x44
+#define C3_2 0x45
+#define C3_3 0x46
+#define C3_4 0x47
+#define C3_5 0x48
+#define C3_6 0x49
+#define C3_7 0x4A
+#define C3_8 0x4B
-#define C3_9 0x4C
+#define C3_9 0x4C
#define C3_10 0x4D
#define C3_11 0x4E
#define C3_12 0x4F
@@ -98,16 +96,16 @@ void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index);
#define C3_15 0x52
#define C3_16 0x53
-#define C4_1 0x54
-#define C4_2 0x55
-#define C4_3 0x56
-#define C4_4 0x57
-#define C4_5 0x58
-#define C4_6 0x59
-#define C4_7 0x5A
-#define C4_8 0x5B
+#define C4_1 0x54
+#define C4_2 0x55
+#define C4_3 0x56
+#define C4_4 0x57
+#define C4_5 0x58
+#define C4_6 0x59
+#define C4_7 0x5A
+#define C4_8 0x5B
-#define C4_9 0x5C
+#define C4_9 0x5C
#define C4_10 0x5D
#define C4_11 0x5E
#define C4_12 0x5F
@@ -116,16 +114,16 @@ void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index);
#define C4_15 0x62
#define C4_16 0x63
-#define C5_1 0x64
-#define C5_2 0x65
-#define C5_3 0x66
-#define C5_4 0x67
-#define C5_5 0x68
-#define C5_6 0x69
-#define C5_7 0x6A
-#define C5_8 0x6B
+#define C5_1 0x64
+#define C5_2 0x65
+#define C5_3 0x66
+#define C5_4 0x67
+#define C5_5 0x68
+#define C5_6 0x69
+#define C5_7 0x6A
+#define C5_8 0x6B
-#define C5_9 0x6C
+#define C5_9 0x6C
#define C5_10 0x6D
#define C5_11 0x6E
#define C5_12 0x6F
@@ -134,16 +132,16 @@ void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index);
#define C5_15 0x72
#define C5_16 0x73
-#define C6_1 0x74
-#define C6_2 0x75
-#define C6_3 0x76
-#define C6_4 0x77
-#define C6_5 0x78
-#define C6_6 0x79
-#define C6_7 0x7A
-#define C6_8 0x7B
+#define C6_1 0x74
+#define C6_2 0x75
+#define C6_3 0x76
+#define C6_4 0x77
+#define C6_5 0x78
+#define C6_6 0x79
+#define C6_7 0x7A
+#define C6_8 0x7B
-#define C6_9 0x7C
+#define C6_9 0x7C
#define C6_10 0x7D
#define C6_11 0x7E
#define C6_12 0x7F
@@ -152,16 +150,16 @@ void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index);
#define C6_15 0x82
#define C6_16 0x83
-#define C7_1 0x84
-#define C7_2 0x85
-#define C7_3 0x86
-#define C7_4 0x87
-#define C7_5 0x88
-#define C7_6 0x89
-#define C7_7 0x8A
-#define C7_8 0x8B
+#define C7_1 0x84
+#define C7_2 0x85
+#define C7_3 0x86
+#define C7_4 0x87
+#define C7_5 0x88
+#define C7_6 0x89
+#define C7_7 0x8A
+#define C7_8 0x8B
-#define C7_9 0x8C
+#define C7_9 0x8C
#define C7_10 0x8D
#define C7_11 0x8E
#define C7_12 0x8F
@@ -170,16 +168,16 @@ void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index);
#define C7_15 0x92
#define C7_16 0x93
-#define C8_1 0x94
-#define C8_2 0x95
-#define C8_3 0x96
-#define C8_4 0x97
-#define C8_5 0x98
-#define C8_6 0x99
-#define C8_7 0x9A
-#define C8_8 0x9B
+#define C8_1 0x94
+#define C8_2 0x95
+#define C8_3 0x96
+#define C8_4 0x97
+#define C8_5 0x98
+#define C8_6 0x99
+#define C8_7 0x9A
+#define C8_8 0x9B
-#define C8_9 0x9C
+#define C8_9 0x9C
#define C8_10 0x9D
#define C8_11 0x9E
#define C8_12 0x9F
@@ -188,16 +186,16 @@ void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index);
#define C8_15 0xA2
#define C8_16 0xA3
-#define C9_1 0xA4
-#define C9_2 0xA5
-#define C9_3 0xA6
-#define C9_4 0xA7
-#define C9_5 0xA8
-#define C9_6 0xA9
-#define C9_7 0xAA
-#define C9_8 0xAB
+#define C9_1 0xA4
+#define C9_2 0xA5
+#define C9_3 0xA6
+#define C9_4 0xA7
+#define C9_5 0xA8
+#define C9_6 0xA9
+#define C9_7 0xAA
+#define C9_8 0xAB
-#define C9_9 0xAC
+#define C9_9 0xAC
#define C9_10 0xAD
#define C9_11 0xAE
#define C9_12 0xAF
@@ -206,5 +204,4 @@ void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index);
#define C9_15 0xB2
#define C9_16 0xB3
-
-#endif // IS31FL3731_DRIVER_H
+#endif // IS31FL3731_DRIVER_H
diff --git a/drivers/issi/is31fl3731.c b/drivers/issi/is31fl3731.c
index c9155f5a37..0b6f3e985d 100644
--- a/drivers/issi/is31fl3731.c
+++ b/drivers/issi/is31fl3731.c
@@ -16,11 +16,11 @@
*/
#ifdef __AVR__
-#include <avr/interrupt.h>
-#include <avr/io.h>
-#include <util/delay.h>
+# include <avr/interrupt.h>
+# include <avr/io.h>
+# include <util/delay.h>
#else
-#include "wait.h"
+# include "wait.h"
#endif
#include "is31fl3731.h"
@@ -37,7 +37,7 @@
// 0b1110110 AD <-> SDA
#define ISSI_ADDR_DEFAULT 0x74
-#define ISSI_REG_CONFIG 0x00
+#define ISSI_REG_CONFIG 0x00
#define ISSI_REG_CONFIG_PICTUREMODE 0x00
#define ISSI_REG_CONFIG_AUTOPLAYMODE 0x08
#define ISSI_REG_CONFIG_AUDIOPLAYMODE 0x18
@@ -46,20 +46,20 @@
#define ISSI_CONF_AUTOFRAMEMODE 0x04
#define ISSI_CONF_AUDIOMODE 0x08
-#define ISSI_REG_PICTUREFRAME 0x01
+#define ISSI_REG_PICTUREFRAME 0x01
#define ISSI_REG_SHUTDOWN 0x0A
#define ISSI_REG_AUDIOSYNC 0x06
#define ISSI_COMMANDREGISTER 0xFD
-#define ISSI_BANK_FUNCTIONREG 0x0B // helpfully called 'page nine'
+#define ISSI_BANK_FUNCTIONREG 0x0B // helpfully called 'page nine'
#ifndef ISSI_TIMEOUT
- #define ISSI_TIMEOUT 100
+# define ISSI_TIMEOUT 100
#endif
#ifndef ISSI_PERSISTENCE
- #define ISSI_PERSISTENCE 0
+# define ISSI_PERSISTENCE 0
#endif
// Transfer buffer for TWITransmitData()
@@ -71,10 +71,10 @@ uint8_t g_twi_transfer_buffer[20];
// buffers and the transfers in IS31FL3731_write_pwm_buffer() but it's
// probably not worth the extra complexity.
uint8_t g_pwm_buffer[DRIVER_COUNT][144];
-bool g_pwm_buffer_update_required = false;
+bool g_pwm_buffer_update_required[DRIVER_COUNT] = {false};
-uint8_t g_led_control_registers[DRIVER_COUNT][18] = { { 0 }, { 0 } };
-bool g_led_control_registers_update_required = false;
+uint8_t g_led_control_registers[DRIVER_COUNT][18] = {{0}, {0}};
+bool g_led_control_registers_update_required[DRIVER_COUNT] = {false};
// This is the bit pattern in the LED control registers
// (for matrix A, add one to register for matrix B)
@@ -90,181 +90,159 @@ bool g_led_control_registers_update_required = false;
// 0x0E - R17,G15,G14,G13,G12,G11,G10,G09
// 0x10 - R16,R15,R14,R13,R12,R11,R10,R09
-
-void IS31FL3731_write_register( uint8_t addr, uint8_t reg, uint8_t data )
-{
+void IS31FL3731_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
g_twi_transfer_buffer[0] = reg;
g_twi_transfer_buffer[1] = data;
- #if ISSI_PERSISTENCE > 0
+#if ISSI_PERSISTENCE > 0
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
- if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0)
- break;
+ if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0) break;
}
- #else
+#else
i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT);
- #endif
+#endif
}
-void IS31FL3731_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer )
-{
+void IS31FL3731_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
// assumes bank is already selected
// transmit PWM registers in 9 transfers of 16 bytes
// g_twi_transfer_buffer[] is 20 bytes
// iterate over the pwm_buffer contents at 16 byte intervals
- for ( int i = 0; i < 144; i += 16 ) {
+ for (int i = 0; i < 144; i += 16) {
// set the first register, e.g. 0x24, 0x34, 0x44, etc.
g_twi_transfer_buffer[0] = 0x24 + i;
// copy the data from i to i+15
// device will auto-increment register for data after the first byte
// thus this sets registers 0x24-0x33, 0x34-0x43, etc. in one transfer
- for ( int j = 0; j < 16; j++ ) {
+ for (int j = 0; j < 16; j++) {
g_twi_transfer_buffer[1 + j] = pwm_buffer[i + j];
}
- #if ISSI_PERSISTENCE > 0
- for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
- if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0)
- break;
- }
- #else
- i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT);
- #endif
+#if ISSI_PERSISTENCE > 0
+ for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
+ if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0) break;
+ }
+#else
+ i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT);
+#endif
}
}
-void IS31FL3731_init( uint8_t addr )
-{
+void IS31FL3731_init(uint8_t addr) {
// In order to avoid the LEDs being driven with garbage data
// in the LED driver's PWM registers, first enable software shutdown,
// then set up the mode and other settings, clear the PWM registers,
// then disable software shutdown.
// select "function register" bank
- IS31FL3731_write_register( addr, ISSI_COMMANDREGISTER, ISSI_BANK_FUNCTIONREG );
+ IS31FL3731_write_register(addr, ISSI_COMMANDREGISTER, ISSI_BANK_FUNCTIONREG);
// enable software shutdown
- IS31FL3731_write_register( addr, ISSI_REG_SHUTDOWN, 0x00 );
- // this delay was copied from other drivers, might not be needed
- #ifdef __AVR__
- _delay_ms( 10 );
- #else
+ IS31FL3731_write_register(addr, ISSI_REG_SHUTDOWN, 0x00);
+// this delay was copied from other drivers, might not be needed
+#ifdef __AVR__
+ _delay_ms(10);
+#else
wait_ms(10);
- #endif
+#endif
// picture mode
- IS31FL3731_write_register( addr, ISSI_REG_CONFIG, ISSI_REG_CONFIG_PICTUREMODE );
+ IS31FL3731_write_register(addr, ISSI_REG_CONFIG, ISSI_REG_CONFIG_PICTUREMODE);
// display frame 0
- IS31FL3731_write_register( addr, ISSI_REG_PICTUREFRAME, 0x00 );
+ IS31FL3731_write_register(addr, ISSI_REG_PICTUREFRAME, 0x00);
// audio sync off
- IS31FL3731_write_register( addr, ISSI_REG_AUDIOSYNC, 0x00 );
+ IS31FL3731_write_register(addr, ISSI_REG_AUDIOSYNC, 0x00);
// select bank 0
- IS31FL3731_write_register( addr, ISSI_COMMANDREGISTER, 0 );
+ IS31FL3731_write_register(addr, ISSI_COMMANDREGISTER, 0);
// turn off all LEDs in the LED control register
- for ( int i = 0x00; i <= 0x11; i++ )
- {
- IS31FL3731_write_register( addr, i, 0x00 );
+ for (int i = 0x00; i <= 0x11; i++) {
+ IS31FL3731_write_register(addr, i, 0x00);
}
// turn off all LEDs in the blink control register (not really needed)
- for ( int i = 0x12; i <= 0x23; i++ )
- {
- IS31FL3731_write_register( addr, i, 0x00 );
+ for (int i = 0x12; i <= 0x23; i++) {
+ IS31FL3731_write_register(addr, i, 0x00);
}
// set PWM on all LEDs to 0
- for ( int i = 0x24; i <= 0xB3; i++ )
- {
- IS31FL3731_write_register( addr, i, 0x00 );
+ for (int i = 0x24; i <= 0xB3; i++) {
+ IS31FL3731_write_register(addr, i, 0x00);
}
// select "function register" bank
- IS31FL3731_write_register( addr, ISSI_COMMANDREGISTER, ISSI_BANK_FUNCTIONREG );
+ IS31FL3731_write_register(addr, ISSI_COMMANDREGISTER, ISSI_BANK_FUNCTIONREG);
// disable software shutdown
- IS31FL3731_write_register( addr, ISSI_REG_SHUTDOWN, 0x01 );
+ IS31FL3731_write_register(addr, ISSI_REG_SHUTDOWN, 0x01);
// select bank 0 and leave it selected.
// most usage after initialization is just writing PWM buffers in bank 0
// as there's not much point in double-buffering
- IS31FL3731_write_register( addr, ISSI_COMMANDREGISTER, 0 );
-
+ IS31FL3731_write_register(addr, ISSI_COMMANDREGISTER, 0);
}
-void IS31FL3731_set_color( int index, uint8_t red, uint8_t green, uint8_t blue )
-{
- if ( index >= 0 && index < DRIVER_LED_TOTAL ) {
+void IS31FL3731_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
+ if (index >= 0 && index < DRIVER_LED_TOTAL) {
is31_led led = g_is31_leds[index];
// Subtract 0x24 to get the second index of g_pwm_buffer
- g_pwm_buffer[led.driver][led.r - 0x24] = red;
- g_pwm_buffer[led.driver][led.g - 0x24] = green;
- g_pwm_buffer[led.driver][led.b - 0x24] = blue;
- g_pwm_buffer_update_required = true;
+ g_pwm_buffer[led.driver][led.r - 0x24] = red;
+ g_pwm_buffer[led.driver][led.g - 0x24] = green;
+ g_pwm_buffer[led.driver][led.b - 0x24] = blue;
+ g_pwm_buffer_update_required[led.driver] = true;
}
}
-void IS31FL3731_set_color_all( uint8_t red, uint8_t green, uint8_t blue )
-{
- for ( int i = 0; i < DRIVER_LED_TOTAL; i++ )
- {
- IS31FL3731_set_color( i, red, green, blue );
+void IS31FL3731_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
+ for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
+ IS31FL3731_set_color(i, red, green, blue);
}
}
-void IS31FL3731_set_led_control_register( uint8_t index, bool red, bool green, bool blue )
-{
+void IS31FL3731_set_led_control_register(uint8_t index, bool red, bool green, bool blue) {
is31_led led = g_is31_leds[index];
- uint8_t control_register_r = (led.r - 0x24) / 8;
- uint8_t control_register_g = (led.g - 0x24) / 8;
- uint8_t control_register_b = (led.b - 0x24) / 8;
- uint8_t bit_r = (led.r - 0x24) % 8;
- uint8_t bit_g = (led.g - 0x24) % 8;
- uint8_t bit_b = (led.b - 0x24) % 8;
+ uint8_t control_register_r = (led.r - 0x24) / 8;
+ uint8_t control_register_g = (led.g - 0x24) / 8;
+ uint8_t control_register_b = (led.b - 0x24) / 8;
+ uint8_t bit_r = (led.r - 0x24) % 8;
+ uint8_t bit_g = (led.g - 0x24) % 8;
+ uint8_t bit_b = (led.b - 0x24) % 8;
- if ( red ) {
+ if (red) {
g_led_control_registers[led.driver][control_register_r] |= (1 << bit_r);
} else {
g_led_control_registers[led.driver][control_register_r] &= ~(1 << bit_r);
}
- if ( green ) {
+ if (green) {
g_led_control_registers[led.driver][control_register_g] |= (1 << bit_g);
} else {
g_led_control_registers[led.driver][control_register_g] &= ~(1 << bit_g);
}
- if ( blue ) {
+ if (blue) {
g_led_control_registers[led.driver][control_register_b] |= (1 << bit_b);
} else {
g_led_control_registers[led.driver][control_register_b] &= ~(1 << bit_b);
}
- g_led_control_registers_update_required = true;
-
+ g_led_control_registers_update_required[led.driver] = true;
}
-void IS31FL3731_update_pwm_buffers( uint8_t addr1, uint8_t addr2 )
-{
- if ( g_pwm_buffer_update_required )
- {
- IS31FL3731_write_pwm_buffer( addr1, g_pwm_buffer[0] );
- IS31FL3731_write_pwm_buffer( addr2, g_pwm_buffer[1] );
+void IS31FL3731_update_pwm_buffers(uint8_t addr, uint8_t index) {
+ if (g_pwm_buffer_update_required[index]) {
+ IS31FL3731_write_pwm_buffer(addr, g_pwm_buffer[index]);
}
- g_pwm_buffer_update_required = false;
+ g_pwm_buffer_update_required[index] = false;
}
-void IS31FL3731_update_led_control_registers( uint8_t addr1, uint8_t addr2 )
-{
- if ( g_led_control_registers_update_required )
- {
- for ( int i=0; i<18; i++ )
- {
- IS31FL3731_write_register(addr1, i, g_led_control_registers[0][i] );
- IS31FL3731_write_register(addr2, i, g_led_control_registers[1][i] );
+void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index) {
+ if (g_led_control_registers_update_required[index]) {
+ for (int i = 0; i < 18; i++) {
+ IS31FL3731_write_register(addr, i, g_led_control_registers[index][i]);
}
}
}
diff --git a/drivers/issi/is31fl3731.h b/drivers/issi/is31fl3731.h
index f354a12db2..6a7a45d8ff 100644
--- a/drivers/issi/is31fl3731.h
+++ b/drivers/issi/is31fl3731.h
@@ -15,7 +15,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
#ifndef IS31FL3731_DRIVER_H
#define IS31FL3731_DRIVER_H
@@ -23,40 +22,40 @@
#include <stdbool.h>
typedef struct is31_led {
- uint8_t driver:2;
- uint8_t r;
- uint8_t g;
- uint8_t b;
+ uint8_t driver : 2;
+ uint8_t r;
+ uint8_t g;
+ uint8_t b;
} __attribute__((packed)) is31_led;
extern const is31_led g_is31_leds[DRIVER_LED_TOTAL];
-void IS31FL3731_init( uint8_t addr );
-void IS31FL3731_write_register( uint8_t addr, uint8_t reg, uint8_t data );
-void IS31FL3731_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer );
+void IS31FL3731_init(uint8_t addr);
+void IS31FL3731_write_register(uint8_t addr, uint8_t reg, uint8_t data);
+void IS31FL3731_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
-void IS31FL3731_set_color( int index, uint8_t red, uint8_t green, uint8_t blue );
-void IS31FL3731_set_color_all( uint8_t red, uint8_t green, uint8_t blue );
+void IS31FL3731_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
+void IS31FL3731_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
-void IS31FL3731_set_led_control_register( uint8_t index, bool red, bool green, bool blue );
+void IS31FL3731_set_led_control_register(uint8_t index, bool red, bool green, bool blue);
// This should not be called from an interrupt
// (eg. from a timer interrupt).
// Call this while idle (in between matrix scans).
// If the buffer is dirty, it will update the driver with the buffer.
-void IS31FL3731_update_pwm_buffers( uint8_t addr1, uint8_t addr2 );
-void IS31FL3731_update_led_control_registers( uint8_t addr1, uint8_t addr2 );
-
-#define C1_1 0x24
-#define C1_2 0x25
-#define C1_3 0x26
-#define C1_4 0x27
-#define C1_5 0x28
-#define C1_6 0x29
-#define C1_7 0x2A
-#define C1_8 0x2B
-
-#define C1_9 0x2C
+void IS31FL3731_update_pwm_buffers(uint8_t addr, uint8_t index);
+void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index);
+
+#define C1_1 0x24
+#define C1_2 0x25
+#define C1_3 0x26
+#define C1_4 0x27
+#define C1_5 0x28
+#define C1_6 0x29
+#define C1_7 0x2A
+#define C1_8 0x2B
+
+#define C1_9 0x2C
#define C1_10 0x2D
#define C1_11 0x2E
#define C1_12 0x2F
@@ -65,16 +64,16 @@ void IS31FL3731_update_led_control_registers( uint8_t addr1, uint8_t addr2 );
#define C1_15 0x32
#define C1_16 0x33
-#define C2_1 0x34
-#define C2_2 0x35
-#define C2_3 0x36
-#define C2_4 0x37
-#define C2_5 0x38
-#define C2_6 0x39
-#define C2_7 0x3A
-#define C2_8 0x3B
+#define C2_1 0x34
+#define C2_2 0x35
+#define C2_3 0x36
+#define C2_4 0x37
+#define C2_5 0x38
+#define C2_6 0x39
+#define C2_7 0x3A
+#define C2_8 0x3B
-#define C2_9 0x3C
+#define C2_9 0x3C
#define C2_10 0x3D
#define C2_11 0x3E
#define C2_12 0x3F
@@ -83,16 +82,16 @@ void IS31FL3731_update_led_control_registers( uint8_t addr1, uint8_t addr2 );
#define C2_15 0x42
#define C2_16 0x43
-#define C3_1 0x44
-#define C3_2 0x45
-#define C3_3 0x46
-#define C3_4 0x47
-#define C3_5 0x48
-#define C3_6 0x49
-#define C3_7 0x4A
-#define C3_8 0x4B
+#define C3_1 0x44
+#define C3_2 0x45
+#define C3_3 0x46
+#define C3_4 0x47
+#define C3_5 0x48
+#define C3_6 0x49
+#define C3_7 0x4A
+#define C3_8 0x4B
-#define C3_9 0x4C
+#define C3_9 0x4C
#define C3_10 0x4D
#define C3_11 0x4E
#define C3_12 0x4F
@@ -101,16 +100,16 @@ void IS31FL3731_update_led_control_registers( uint8_t addr1, uint8_t addr2 );
#define C3_15 0x52
#define C3_16 0x53
-#define C4_1 0x54
-#define C4_2 0x55
-#define C4_3 0x56
-#define C4_4 0x57
-#define C4_5 0x58
-#define C4_6 0x59
-#define C4_7 0x5A
-#define C4_8 0x5B
+#define C4_1 0x54
+#define C4_2 0x55
+#define C4_3 0x56
+#define C4_4 0x57
+#define C4_5 0x58
+#define C4_6 0x59
+#define C4_7 0x5A
+#define C4_8 0x5B
-#define C4_9 0x5C
+#define C4_9 0x5C
#define C4_10 0x5D
#define C4_11 0x5E
#define C4_12 0x5F
@@ -119,16 +118,16 @@ void IS31FL3731_update_led_control_registers( uint8_t addr1, uint8_t addr2 );
#define C4_15 0x62
#define C4_16 0x63
-#define C5_1 0x64
-#define C5_2 0x65
-#define C5_3 0x66
-#define C5_4 0x67
-#define C5_5 0x68
-#define C5_6 0x69
-#define C5_7 0x6A
-#define C5_8 0x6B
+#define C5_1 0x64
+#define C5_2 0x65
+#define C5_3 0x66
+#define C5_4 0x67
+#define C5_5 0x68
+#define C5_6 0x69
+#define C5_7 0x6A
+#define C5_8 0x6B
-#define C5_9 0x6C
+#define C5_9 0x6C
#define C5_10 0x6D
#define C5_11 0x6E
#define C5_12 0x6F
@@ -137,16 +136,16 @@ void IS31FL3731_update_led_control_registers( uint8_t addr1, uint8_t addr2 );
#define C5_15 0x72
#define C5_16 0x73
-#define C6_1 0x74
-#define C6_2 0x75
-#define C6_3 0x76
-#define C6_4 0x77
-#define C6_5 0x78
-#define C6_6 0x79
-#define C6_7 0x7A
-#define C6_8 0x7B
+#define C6_1 0x74
+#define C6_2 0x75
+#define C6_3 0x76
+#define C6_4 0x77
+#define C6_5 0x78
+#define C6_6 0x79
+#define C6_7 0x7A
+#define C6_8 0x7B
-#define C6_9 0x7C
+#define C6_9 0x7C
#define C6_10 0x7D
#define C6_11 0x7E
#define C6_12 0x7F
@@ -155,16 +154,16 @@ void IS31FL3731_update_led_control_registers( uint8_t addr1, uint8_t addr2 );
#define C6_15 0x82
#define C6_16 0x83
-#define C7_1 0x84
-#define C7_2 0x85
-#define C7_3 0x86
-#define C7_4 0x87
-#define C7_5 0x88
-#define C7_6 0x89
-#define C7_7 0x8A
-#define C7_8 0x8B
+#define C7_1 0x84
+#define C7_2 0x85
+#define C7_3 0x86
+#define C7_4 0x87
+#define C7_5 0x88
+#define C7_6 0x89
+#define C7_7 0x8A
+#define C7_8 0x8B
-#define C7_9 0x8C
+#define C7_9 0x8C
#define C7_10 0x8D
#define C7_11 0x8E
#define C7_12 0x8F
@@ -173,16 +172,16 @@ void IS31FL3731_update_led_control_registers( uint8_t addr1, uint8_t addr2 );
#define C7_15 0x92
#define C7_16 0x93
-#define C8_1 0x94
-#define C8_2 0x95
-#define C8_3 0x96
-#define C8_4 0x97
-#define C8_5 0x98
-#define C8_6 0x99
-#define C8_7 0x9A
-#define C8_8 0x9B
+#define C8_1 0x94
+#define C8_2 0x95
+#define C8_3 0x96
+#define C8_4 0x97
+#define C8_5 0x98
+#define C8_6 0x99
+#define C8_7 0x9A
+#define C8_8 0x9B
-#define C8_9 0x9C
+#define C8_9 0x9C
#define C8_10 0x9D
#define C8_11 0x9E
#define C8_12 0x9F
@@ -191,16 +190,16 @@ void IS31FL3731_update_led_control_registers( uint8_t addr1, uint8_t addr2 );
#define C8_15 0xA2
#define C8_16 0xA3
-#define C9_1 0xA4
-#define C9_2 0xA5
-#define C9_3 0xA6
-#define C9_4 0xA7
-#define C9_5 0xA8
-#define C9_6 0xA9
-#define C9_7 0xAA
-#define C9_8 0xAB
+#define C9_1 0xA4
+#define C9_2 0xA5
+#define C9_3 0xA6
+#define C9_4 0xA7
+#define C9_5 0xA8
+#define C9_6 0xA9
+#define C9_7 0xAA
+#define C9_8 0xAB
-#define C9_9 0xAC
+#define C9_9 0xAC
#define C9_10 0xAD
#define C9_11 0xAE
#define C9_12 0xAF
@@ -209,6 +208,4 @@ void IS31FL3731_update_led_control_registers( uint8_t addr1, uint8_t addr2 );
#define C9_15 0xB2
#define C9_16 0xB3
-
-
-#endif // IS31FL3731_DRIVER_H
+#endif // IS31FL3731_DRIVER_H
diff --git a/drivers/issi/is31fl3733.c b/drivers/issi/is31fl3733.c
index aa247f4e8a..968f072de8 100644
--- a/drivers/issi/is31fl3733.c
+++ b/drivers/issi/is31fl3733.c
@@ -17,11 +17,11 @@
*/
#ifdef __AVR__
-#include <avr/interrupt.h>
-#include <avr/io.h>
-#include <util/delay.h>
+# include <avr/interrupt.h>
+# include <avr/io.h>
+# include <util/delay.h>
#else
-#include "wait.h"
+# include "wait.h"
#endif
#include "is31fl3733.h"
@@ -46,23 +46,23 @@
#define ISSI_INTERRUPTMASKREGISTER 0xF0
#define ISSI_INTERRUPTSTATUSREGISTER 0xF1
-#define ISSI_PAGE_LEDCONTROL 0x00 //PG0
-#define ISSI_PAGE_PWM 0x01 //PG1
-#define ISSI_PAGE_AUTOBREATH 0x02 //PG2
-#define ISSI_PAGE_FUNCTION 0x03 //PG3
+#define ISSI_PAGE_LEDCONTROL 0x00 // PG0
+#define ISSI_PAGE_PWM 0x01 // PG1
+#define ISSI_PAGE_AUTOBREATH 0x02 // PG2
+#define ISSI_PAGE_FUNCTION 0x03 // PG3
-#define ISSI_REG_CONFIGURATION 0x00 //PG3
-#define ISSI_REG_GLOBALCURRENT 0x01 //PG3
-#define ISSI_REG_RESET 0x11// PG3
-#define ISSI_REG_SWPULLUP 0x0F //PG3
-#define ISSI_REG_CSPULLUP 0x10 //PG3
+#define ISSI_REG_CONFIGURATION 0x00 // PG3
+#define ISSI_REG_GLOBALCURRENT 0x01 // PG3
+#define ISSI_REG_RESET 0x11 // PG3
+#define ISSI_REG_SWPULLUP 0x0F // PG3
+#define ISSI_REG_CSPULLUP 0x10 // PG3
#ifndef ISSI_TIMEOUT
- #define ISSI_TIMEOUT 100
+# define ISSI_TIMEOUT 100
#endif
#ifndef ISSI_PERSISTENCE
- #define ISSI_PERSISTENCE 0
+# define ISSI_PERSISTENCE 0
#endif
// Transfer buffer for TWITransmitData()
@@ -75,56 +75,51 @@ uint8_t g_twi_transfer_buffer[20];
// buffers and the transfers in IS31FL3733_write_pwm_buffer() but it's
// probably not worth the extra complexity.
uint8_t g_pwm_buffer[DRIVER_COUNT][192];
-bool g_pwm_buffer_update_required[DRIVER_COUNT] = { false };
+bool g_pwm_buffer_update_required[DRIVER_COUNT] = {false};
-uint8_t g_led_control_registers[DRIVER_COUNT][24] = { { 0 }, { 0 } };
-bool g_led_control_registers_update_required[DRIVER_COUNT] = { false };
+uint8_t g_led_control_registers[DRIVER_COUNT][24] = {{0}, {0}};
+bool g_led_control_registers_update_required[DRIVER_COUNT] = {false};
-void IS31FL3733_write_register( uint8_t addr, uint8_t reg, uint8_t data )
-{
+void IS31FL3733_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
g_twi_transfer_buffer[0] = reg;
g_twi_transfer_buffer[1] = data;
- #if ISSI_PERSISTENCE > 0
+#if ISSI_PERSISTENCE > 0
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
- if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0)
- break;
+ if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0) break;
}
- #else
+#else
i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT);
- #endif
+#endif
}
-void IS31FL3733_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer )
-{
+void IS31FL3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
// assumes PG1 is already selected
// transmit PWM registers in 12 transfers of 16 bytes
// g_twi_transfer_buffer[] is 20 bytes
// iterate over the pwm_buffer contents at 16 byte intervals
- for ( int i = 0; i < 192; i += 16 ) {
+ for (int i = 0; i < 192; i += 16) {
g_twi_transfer_buffer[0] = i;
// copy the data from i to i+15
// device will auto-increment register for data after the first byte
// thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer
- for ( int j = 0; j < 16; j++ ) {
+ for (int j = 0; j < 16; j++) {
g_twi_transfer_buffer[1 + j] = pwm_buffer[i + j];
}
- #if ISSI_PERSISTENCE > 0
- for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
- if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0)
- break;
- }
- #else
- i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT);
- #endif
+#if ISSI_PERSISTENCE > 0
+ for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
+ if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0) break;
+ }
+#else
+ i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT);
+#endif
}
}
-void IS31FL3733_init( uint8_t addr, uint8_t sync)
-{
+void IS31FL3733_init(uint8_t addr, uint8_t sync) {
// In order to avoid the LEDs being driven with garbage data
// in the LED driver's PWM registers, shutdown is enabled last.
// Set up the mode and other settings, clear the PWM registers,
@@ -132,120 +127,108 @@ void IS31FL3733_init( uint8_t addr, uint8_t sync)
// Sync is passed so set it according to the datasheet.
// Unlock the command register.
- IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
+ IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
// Select PG0
- IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL );
+ IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL);
// Turn off all LEDs.
- for ( int i = 0x00; i <= 0x17; i++ )
- {
- IS31FL3733_write_register( addr, i, 0x00 );
+ for (int i = 0x00; i <= 0x17; i++) {
+ IS31FL3733_write_register(addr, i, 0x00);
}
// Unlock the command register.
- IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
+ IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
// Select PG1
- IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM );
+ IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM);
// Set PWM on all LEDs to 0
// No need to setup Breath registers to PWM as that is the default.
- for ( int i = 0x00; i <= 0xBF; i++ )
- {
- IS31FL3733_write_register( addr, i, 0x00 );
+ for (int i = 0x00; i <= 0xBF; i++) {
+ IS31FL3733_write_register(addr, i, 0x00);
}
// Unlock the command register.
- IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
+ IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
// Select PG3
- IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_FUNCTION );
+ IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_FUNCTION);
// Set global current to maximum.
- IS31FL3733_write_register( addr, ISSI_REG_GLOBALCURRENT, 0xFF );
+ IS31FL3733_write_register(addr, ISSI_REG_GLOBALCURRENT, 0xFF);
// Disable software shutdown.
- IS31FL3733_write_register( addr, ISSI_REG_CONFIGURATION, (sync << 6) | 0x01 );
+ IS31FL3733_write_register(addr, ISSI_REG_CONFIGURATION, (sync << 6) | 0x01);
- // Wait 10ms to ensure the device has woken up.
- #ifdef __AVR__
- _delay_ms( 10 );
- #else
+// Wait 10ms to ensure the device has woken up.
+#ifdef __AVR__
+ _delay_ms(10);
+#else
wait_ms(10);
- #endif
+#endif
}
-void IS31FL3733_set_color( int index, uint8_t red, uint8_t green, uint8_t blue )
-{
- if ( index >= 0 && index < DRIVER_LED_TOTAL ) {
+void IS31FL3733_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
+ if (index >= 0 && index < DRIVER_LED_TOTAL) {
is31_led led = g_is31_leds[index];
- g_pwm_buffer[led.driver][led.r] = red;
- g_pwm_buffer[led.driver][led.g] = green;
- g_pwm_buffer[led.driver][led.b] = blue;
+ g_pwm_buffer[led.driver][led.r] = red;
+ g_pwm_buffer[led.driver][led.g] = green;
+ g_pwm_buffer[led.driver][led.b] = blue;
g_pwm_buffer_update_required[led.driver] = true;
}
}
-void IS31FL3733_set_color_all( uint8_t red, uint8_t green, uint8_t blue )
-{
- for ( int i = 0; i < DRIVER_LED_TOTAL; i++ )
- {
- IS31FL3733_set_color( i, red, green, blue );
+void IS31FL3733_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
+ for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
+ IS31FL3733_set_color(i, red, green, blue);
}
}
-void IS31FL3733_set_led_control_register( uint8_t index, bool red, bool green, bool blue )
-{
+void IS31FL3733_set_led_control_register(uint8_t index, bool red, bool green, bool blue) {
is31_led led = g_is31_leds[index];
- uint8_t control_register_r = led.r / 8;
- uint8_t control_register_g = led.g / 8;
- uint8_t control_register_b = led.b / 8;
- uint8_t bit_r = led.r % 8;
- uint8_t bit_g = led.g % 8;
- uint8_t bit_b = led.b % 8;
+ uint8_t control_register_r = led.r / 8;
+ uint8_t control_register_g = led.g / 8;
+ uint8_t control_register_b = led.b / 8;
+ uint8_t bit_r = led.r % 8;
+ uint8_t bit_g = led.g % 8;
+ uint8_t bit_b = led.b % 8;
- if ( red ) {
+ if (red) {
g_led_control_registers[led.driver][control_register_r] |= (1 << bit_r);
} else {
g_led_control_registers[led.driver][control_register_r] &= ~(1 << bit_r);
}
- if ( green ) {
+ if (green) {
g_led_control_registers[led.driver][control_register_g] |= (1 << bit_g);
} else {
g_led_control_registers[led.driver][control_register_g] &= ~(1 << bit_g);
}
- if ( blue ) {
+ if (blue) {
g_led_control_registers[led.driver][control_register_b] |= (1 << bit_b);
} else {
g_led_control_registers[led.driver][control_register_b] &= ~(1 << bit_b);
}
g_led_control_registers_update_required[led.driver] = true;
-
}
-void IS31FL3733_update_pwm_buffers( uint8_t addr, uint8_t index )
-{
- if ( g_pwm_buffer_update_required[index] )
- {
+void IS31FL3733_update_pwm_buffers(uint8_t addr, uint8_t index) {
+ if (g_pwm_buffer_update_required[index]) {
// Firstly we need to unlock the command register and select PG1
- IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
- IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM );
+ IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
+ IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM);
- IS31FL3733_write_pwm_buffer( addr, g_pwm_buffer[index] );
+ IS31FL3733_write_pwm_buffer(addr, g_pwm_buffer[index]);
}
g_pwm_buffer_update_required[index] = false;
}
-void IS31FL3733_update_led_control_registers( uint8_t addr, uint8_t index )
-{
- if ( g_led_control_registers_update_required[index] )
- {
+void IS31FL3733_update_led_control_registers(uint8_t addr, uint8_t index) {
+ if (g_led_control_registers_update_required[index]) {
// Firstly we need to unlock the command register and select PG0
- IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
- IS31FL3733_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL );
- for ( int i=0; i<24; i++ )
- {
- IS31FL3733_write_register(addr, i, g_led_control_registers[index][i] );
+ IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
+ IS31FL3733_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL);
+ for (int i = 0; i < 24; i++) {
+ IS31FL3733_write_register(addr, i, g_led_control_registers[index][i]);
}
}
g_led_control_registers_update_required[index] = false;
diff --git a/drivers/issi/is31fl3733.h b/drivers/issi/is31fl3733.h
index e117b25460..5b3283e035 100644
--- a/drivers/issi/is31fl3733.h
+++ b/drivers/issi/is31fl3733.h
@@ -16,7 +16,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
#ifndef IS31FL3733_DRIVER_H
#define IS31FL3733_DRIVER_H
@@ -24,232 +23,232 @@
#include <stdbool.h>
typedef struct is31_led {
- uint8_t driver:2;
- uint8_t r;
- uint8_t g;
- uint8_t b;
+ uint8_t driver : 2;
+ uint8_t r;
+ uint8_t g;
+ uint8_t b;
} __attribute__((packed)) is31_led;
extern const is31_led g_is31_leds[DRIVER_LED_TOTAL];
-void IS31FL3733_init( uint8_t addr, uint8_t sync );
-void IS31FL3733_write_register( uint8_t addr, uint8_t reg, uint8_t data );
-void IS31FL3733_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer );
+void IS31FL3733_init(uint8_t addr, uint8_t sync);
+void IS31FL3733_write_register(uint8_t addr, uint8_t reg, uint8_t data);
+void IS31FL3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
-void IS31FL3733_set_color( int index, uint8_t red, uint8_t green, uint8_t blue );
-void IS31FL3733_set_color_all( uint8_t red, uint8_t green, uint8_t blue );
+void IS31FL3733_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
+void IS31FL3733_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
-void IS31FL3733_set_led_control_register( uint8_t index, bool red, bool green, bool blue );
+void IS31FL3733_set_led_control_register(uint8_t index, bool red, bool green, bool blue);
// This should not be called from an interrupt
// (eg. from a timer interrupt).
// Call this while idle (in between matrix scans).
// If the buffer is dirty, it will update the driver with the buffer.
-void IS31FL3733_update_pwm_buffers( uint8_t addr, uint8_t index );
-void IS31FL3733_update_led_control_registers( uint8_t addr, uint8_t index );
-
-#define A_1 0x00
-#define A_2 0x01
-#define A_3 0x02
-#define A_4 0x03
-#define A_5 0x04
-#define A_6 0x05
-#define A_7 0x06
-#define A_8 0x07
-#define A_9 0x08
-#define A_10 0x09
-#define A_11 0x0A
-#define A_12 0x0B
-#define A_13 0x0C
-#define A_14 0x0D
-#define A_15 0x0E
-#define A_16 0x0F
-
-#define B_1 0x10
-#define B_2 0x11
-#define B_3 0x12
-#define B_4 0x13
-#define B_5 0x14
-#define B_6 0x15
-#define B_7 0x16
-#define B_8 0x17
-#define B_9 0x18
-#define B_10 0x19
-#define B_11 0x1A
-#define B_12 0x1B
-#define B_13 0x1C
-#define B_14 0x1D
-#define B_15 0x1E
-#define B_16 0x1F
-
-#define C_1 0x20
-#define C_2 0x21
-#define C_3 0x22
-#define C_4 0x23
-#define C_5 0x24
-#define C_6 0x25
-#define C_7 0x26
-#define C_8 0x27
-#define C_9 0x28
-#define C_10 0x29
-#define C_11 0x2A
-#define C_12 0x2B
-#define C_13 0x2C
-#define C_14 0x2D
-#define C_15 0x2E
-#define C_16 0x2F
-
-#define D_1 0x30
-#define D_2 0x31
-#define D_3 0x32
-#define D_4 0x33
-#define D_5 0x34
-#define D_6 0x35
-#define D_7 0x36
-#define D_8 0x37
-#define D_9 0x38
-#define D_10 0x39
-#define D_11 0x3A
-#define D_12 0x3B
-#define D_13 0x3C
-#define D_14 0x3D
-#define D_15 0x3E
-#define D_16 0x3F
-
-#define E_1 0x40
-#define E_2 0x41
-#define E_3 0x42
-#define E_4 0x43
-#define E_5 0x44
-#define E_6 0x45
-#define E_7 0x46
-#define E_8 0x47
-#define E_9 0x48
-#define E_10 0x49
-#define E_11 0x4A
-#define E_12 0x4B
-#define E_13 0x4C
-#define E_14 0x4D
-#define E_15 0x4E
-#define E_16 0x4F
-
-#define F_1 0x50
-#define F_2 0x51
-#define F_3 0x52
-#define F_4 0x53
-#define F_5 0x54
-#define F_6 0x55
-#define F_7 0x56
-#define F_8 0x57
-#define F_9 0x58
-#define F_10 0x59
-#define F_11 0x5A
-#define F_12 0x5B
-#define F_13 0x5C
-#define F_14 0x5D
-#define F_15 0x5E
-#define F_16 0x5F
-
-#define G_1 0x60
-#define G_2 0x61
-#define G_3 0x62
-#define G_4 0x63
-#define G_5 0x64
-#define G_6 0x65
-#define G_7 0x66
-#define G_8 0x67
-#define G_9 0x68
-#define G_10 0x69
-#define G_11 0x6A
-#define G_12 0x6B
-#define G_13 0x6C
-#define G_14 0x6D
-#define G_15 0x6E
-#define G_16 0x6F
-
-#define H_1 0x70
-#define H_2 0x71
-#define H_3 0x72
-#define H_4 0x73
-#define H_5 0x74
-#define H_6 0x75
-#define H_7 0x76
-#define H_8 0x77
-#define H_9 0x78
-#define H_10 0x79
-#define H_11 0x7A
-#define H_12 0x7B
-#define H_13 0x7C
-#define H_14 0x7D
-#define H_15 0x7E
-#define H_16 0x7F
-
-#define I_1 0x80
-#define I_2 0x81
-#define I_3 0x82
-#define I_4 0x83
-#define I_5 0x84
-#define I_6 0x85
-#define I_7 0x86
-#define I_8 0x87
-#define I_9 0x88
-#define I_10 0x89
-#define I_11 0x8A
-#define I_12 0x8B
-#define I_13 0x8C
-#define I_14 0x8D
-#define I_15 0x8E
-#define I_16 0x8F
-
-#define J_1 0x90
-#define J_2 0x91
-#define J_3 0x92
-#define J_4 0x93
-#define J_5 0x94
-#define J_6 0x95
-#define J_7 0x96
-#define J_8 0x97
-#define J_9 0x98
-#define J_10 0x99
-#define J_11 0x9A
-#define J_12 0x9B
-#define J_13 0x9C
-#define J_14 0x9D
-#define J_15 0x9E
-#define J_16 0x9F
-
-#define K_1 0xA0
-#define K_2 0xA1
-#define K_3 0xA2
-#define K_4 0xA3
-#define K_5 0xA4
-#define K_6 0xA5
-#define K_7 0xA6
-#define K_8 0xA7
-#define K_9 0xA8
-#define K_10 0xA9
-#define K_11 0xAA
-#define K_12 0xAB
-#define K_13 0xAC
-#define K_14 0xAD
-#define K_15 0xAE
-#define K_16 0xAF
-
-#define L_1 0xB0
-#define L_2 0xB1
-#define L_3 0xB2
-#define L_4 0xB3
-#define L_5 0xB4
-#define L_6 0xB5
-#define L_7 0xB6
-#define L_8 0xB7
-#define L_9 0xB8
-#define L_10 0xB9
-#define L_11 0xBA
-#define L_12 0xBB
-#define L_13 0xBC
-#define L_14 0xBD
-#define L_15 0xBE
-#define L_16 0xBF
-
-#endif // IS31FL3733_DRIVER_H
+void IS31FL3733_update_pwm_buffers(uint8_t addr, uint8_t index);
+void IS31FL3733_update_led_control_registers(uint8_t addr, uint8_t index);
+
+#define A_1 0x00
+#define A_2 0x01
+#define A_3 0x02
+#define A_4 0x03
+#define A_5 0x04
+#define A_6 0x05
+#define A_7 0x06
+#define A_8 0x07
+#define A_9 0x08
+#define A_10 0x09
+#define A_11 0x0A
+#define A_12 0x0B
+#define A_13 0x0C
+#define A_14 0x0D
+#define A_15 0x0E
+#define A_16 0x0F
+
+#define B_1 0x10
+#define B_2 0x11
+#define B_3 0x12
+#define B_4 0x13
+#define B_5 0x14
+#define B_6 0x15
+#define B_7 0x16
+#define B_8 0x17
+#define B_9 0x18
+#define B_10 0x19
+#define B_11 0x1A
+#define B_12 0x1B
+#define B_13 0x1C
+#define B_14 0x1D
+#define B_15 0x1E
+#define B_16 0x1F
+
+#define C_1 0x20
+#define C_2 0x21
+#define C_3 0x22
+#define C_4 0x23
+#define C_5 0x24
+#define C_6 0x25
+#define C_7 0x26
+#define C_8 0x27
+#define C_9 0x28
+#define C_10 0x29
+#define C_11 0x2A
+#define C_12 0x2B
+#define C_13 0x2C
+#define C_14 0x2D
+#define C_15 0x2E
+#define C_16 0x2F
+
+#define D_1 0x30
+#define D_2 0x31
+#define D_3 0x32
+#define D_4 0x33
+#define D_5 0x34
+#define D_6 0x35
+#define D_7 0x36
+#define D_8 0x37
+#define D_9 0x38
+#define D_10 0x39
+#define D_11 0x3A
+#define D_12 0x3B
+#define D_13 0x3C
+#define D_14 0x3D
+#define D_15 0x3E
+#define D_16 0x3F
+
+#define E_1 0x40
+#define E_2 0x41
+#define E_3 0x42
+#define E_4 0x43
+#define E_5 0x44
+#define E_6 0x45
+#define E_7 0x46
+#define E_8 0x47
+#define E_9 0x48
+#define E_10 0x49
+#define E_11 0x4A
+#define E_12 0x4B
+#define E_13 0x4C
+#define E_14 0x4D
+#define E_15 0x4E
+#define E_16 0x4F
+
+#define F_1 0x50
+#define F_2 0x51
+#define F_3 0x52
+#define F_4 0x53
+#define F_5 0x54
+#define F_6 0x55
+#define F_7 0x56
+#define F_8 0x57
+#define F_9 0x58
+#define F_10 0x59
+#define F_11 0x5A
+#define F_12 0x5B
+#define F_13 0x5C
+#define F_14 0x5D
+#define F_15 0x5E
+#define F_16 0x5F
+
+#define G_1 0x60
+#define G_2 0x61
+#define G_3 0x62
+#define G_4 0x63
+#define G_5 0x64
+#define G_6 0x65
+#define G_7 0x66
+#define G_8 0x67
+#define G_9 0x68
+#define G_10 0x69
+#define G_11 0x6A
+#define G_12 0x6B
+#define G_13 0x6C
+#define G_14 0x6D
+#define G_15 0x6E
+#define G_16 0x6F
+
+#define H_1 0x70
+#define H_2 0x71
+#define H_3 0x72
+#define H_4 0x73
+#define H_5 0x74
+#define H_6 0x75
+#define H_7 0x76
+#define H_8 0x77
+#define H_9 0x78
+#define H_10 0x79
+#define H_11 0x7A
+#define H_12 0x7B
+#define H_13 0x7C
+#define H_14 0x7D
+#define H_15 0x7E
+#define H_16 0x7F
+
+#define I_1 0x80
+#define I_2 0x81
+#define I_3 0x82
+#define I_4 0x83
+#define I_5 0x84
+#define I_6 0x85
+#define I_7 0x86
+#define I_8 0x87
+#define I_9 0x88
+#define I_10 0x89
+#define I_11 0x8A
+#define I_12 0x8B
+#define I_13 0x8C
+#define I_14 0x8D
+#define I_15 0x8E
+#define I_16 0x8F
+
+#define J_1 0x90
+#define J_2 0x91
+#define J_3 0x92
+#define J_4 0x93
+#define J_5 0x94
+#define J_6 0x95
+#define J_7 0x96
+#define J_8 0x97
+#define J_9 0x98
+#define J_10 0x99
+#define J_11 0x9A
+#define J_12 0x9B
+#define J_13 0x9C
+#define J_14 0x9D
+#define J_15 0x9E
+#define J_16 0x9F
+
+#define K_1 0xA0
+#define K_2 0xA1
+#define K_3 0xA2
+#define K_4 0xA3
+#define K_5 0xA4
+#define K_6 0xA5
+#define K_7 0xA6
+#define K_8 0xA7
+#define K_9 0xA8
+#define K_10 0xA9
+#define K_11 0xAA
+#define K_12 0xAB
+#define K_13 0xAC
+#define K_14 0xAD
+#define K_15 0xAE
+#define K_16 0xAF
+
+#define L_1 0xB0
+#define L_2 0xB1
+#define L_3 0xB2
+#define L_4 0xB3
+#define L_5 0xB4
+#define L_6 0xB5
+#define L_7 0xB6
+#define L_8 0xB7
+#define L_9 0xB8
+#define L_10 0xB9
+#define L_11 0xBA
+#define L_12 0xBB
+#define L_13 0xBC
+#define L_14 0xBD
+#define L_15 0xBE
+#define L_16 0xBF
+
+#endif // IS31FL3733_DRIVER_H
diff --git a/drivers/issi/is31fl3736.c b/drivers/issi/is31fl3736.c
index c5d4310971..754292425e 100644
--- a/drivers/issi/is31fl3736.c
+++ b/drivers/issi/is31fl3736.c
@@ -14,13 +14,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
#ifdef __AVR__
-#include <avr/interrupt.h>
-#include <avr/io.h>
-#include <util/delay.h>
+# include <avr/interrupt.h>
+# include <avr/io.h>
+# include <util/delay.h>
#else
-#include "wait.h"
+# include "wait.h"
#endif
#include "is31fl3736.h"
@@ -28,8 +27,6 @@
#include "i2c_master.h"
#include "progmem.h"
-
-
// This is a 7-bit address, that gets left-shifted and bit 0
// set to 0 for write, 1 for read (as per I2C protocol)
// The address will vary depending on your wiring:
@@ -47,23 +44,23 @@
#define ISSI_INTERRUPTMASKREGISTER 0xF0
#define ISSI_INTERRUPTSTATUSREGISTER 0xF1
-#define ISSI_PAGE_LEDCONTROL 0x00 //PG0
-#define ISSI_PAGE_PWM 0x01 //PG1
-#define ISSI_PAGE_AUTOBREATH 0x02 //PG2
-#define ISSI_PAGE_FUNCTION 0x03 //PG3
+#define ISSI_PAGE_LEDCONTROL 0x00 // PG0
+#define ISSI_PAGE_PWM 0x01 // PG1
+#define ISSI_PAGE_AUTOBREATH 0x02 // PG2
+#define ISSI_PAGE_FUNCTION 0x03 // PG3
-#define ISSI_REG_CONFIGURATION 0x00 //PG3
-#define ISSI_REG_GLOBALCURRENT 0x01 //PG3
-#define ISSI_REG_RESET 0x11// PG3
-#define ISSI_REG_SWPULLUP 0x0F //PG3
-#define ISSI_REG_CSPULLUP 0x10 //PG3
+#define ISSI_REG_CONFIGURATION 0x00 // PG3
+#define ISSI_REG_GLOBALCURRENT 0x01 // PG3
+#define ISSI_REG_RESET 0x11 // PG3
+#define ISSI_REG_SWPULLUP 0x0F // PG3
+#define ISSI_REG_CSPULLUP 0x10 // PG3
#ifndef ISSI_TIMEOUT
- #define ISSI_TIMEOUT 100
+# define ISSI_TIMEOUT 100
#endif
#ifndef ISSI_PERSISTENCE
- #define ISSI_PERSISTENCE 0
+# define ISSI_PERSISTENCE 0
#endif
// Transfer buffer for TWITransmitData()
@@ -76,124 +73,113 @@ uint8_t g_twi_transfer_buffer[20];
// buffers and the transfers in IS31FL3736_write_pwm_buffer() but it's
// probably not worth the extra complexity.
uint8_t g_pwm_buffer[DRIVER_COUNT][192];
-bool g_pwm_buffer_update_required = false;
+bool g_pwm_buffer_update_required = false;
-uint8_t g_led_control_registers[DRIVER_COUNT][24] = { { 0 }, { 0 } };
-bool g_led_control_registers_update_required = false;
+uint8_t g_led_control_registers[DRIVER_COUNT][24] = {{0}, {0}};
+bool g_led_control_registers_update_required = false;
-void IS31FL3736_write_register( uint8_t addr, uint8_t reg, uint8_t data )
-{
+void IS31FL3736_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
g_twi_transfer_buffer[0] = reg;
g_twi_transfer_buffer[1] = data;
- #if ISSI_PERSISTENCE > 0
+#if ISSI_PERSISTENCE > 0
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
- if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0)
- break;
+ if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0) break;
}
- #else
+#else
i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT);
- #endif
+#endif
}
-void IS31FL3736_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer )
-{
+void IS31FL3736_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
// assumes PG1 is already selected
// transmit PWM registers in 12 transfers of 16 bytes
// g_twi_transfer_buffer[] is 20 bytes
// iterate over the pwm_buffer contents at 16 byte intervals
- for ( int i = 0; i < 192; i += 16 ) {
+ for (int i = 0; i < 192; i += 16) {
g_twi_transfer_buffer[0] = i;
// copy the data from i to i+15
// device will auto-increment register for data after the first byte
// thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer
- for ( int j = 0; j < 16; j++ ) {
+ for (int j = 0; j < 16; j++) {
g_twi_transfer_buffer[1 + j] = pwm_buffer[i + j];
}
- #if ISSI_PERSISTENCE > 0
- for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
- if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0)
- break;
- }
- #else
- i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT);
- #endif
+#if ISSI_PERSISTENCE > 0
+ for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
+ if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0) break;
+ }
+#else
+ i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT);
+#endif
}
}
-void IS31FL3736_init( uint8_t addr )
-{
+void IS31FL3736_init(uint8_t addr) {
// In order to avoid the LEDs being driven with garbage data
// in the LED driver's PWM registers, shutdown is enabled last.
// Set up the mode and other settings, clear the PWM registers,
// then disable software shutdown.
// Unlock the command register.
- IS31FL3736_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
+ IS31FL3736_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
// Select PG0
- IS31FL3736_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL );
+ IS31FL3736_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL);
// Turn off all LEDs.
- for ( int i = 0x00; i <= 0x17; i++ )
- {
- IS31FL3736_write_register( addr, i, 0x00 );
+ for (int i = 0x00; i <= 0x17; i++) {
+ IS31FL3736_write_register(addr, i, 0x00);
}
// Unlock the command register.
- IS31FL3736_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
+ IS31FL3736_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
// Select PG1
- IS31FL3736_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM );
+ IS31FL3736_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM);
// Set PWM on all LEDs to 0
// No need to setup Breath registers to PWM as that is the default.
- for ( int i = 0x00; i <= 0xBF; i++ )
- {
- IS31FL3736_write_register( addr, i, 0x00 );
+ for (int i = 0x00; i <= 0xBF; i++) {
+ IS31FL3736_write_register(addr, i, 0x00);
}
// Unlock the command register.
- IS31FL3736_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
+ IS31FL3736_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
// Select PG3
- IS31FL3736_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_FUNCTION );
+ IS31FL3736_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_FUNCTION);
// Set global current to maximum.
- IS31FL3736_write_register( addr, ISSI_REG_GLOBALCURRENT, 0xFF );
+ IS31FL3736_write_register(addr, ISSI_REG_GLOBALCURRENT, 0xFF);
// Disable software shutdown.
- IS31FL3736_write_register( addr, ISSI_REG_CONFIGURATION, 0x01 );
+ IS31FL3736_write_register(addr, ISSI_REG_CONFIGURATION, 0x01);
- // Wait 10ms to ensure the device has woken up.
- #ifdef __AVR__
- _delay_ms( 10 );
- #else
+// Wait 10ms to ensure the device has woken up.
+#ifdef __AVR__
+ _delay_ms(10);
+#else
wait_ms(10);
- #endif
+#endif
}
-void IS31FL3736_set_color( int index, uint8_t red, uint8_t green, uint8_t blue )
-{
- if ( index >= 0 && index < DRIVER_LED_TOTAL ) {
+void IS31FL3736_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
+ if (index >= 0 && index < DRIVER_LED_TOTAL) {
is31_led led = g_is31_leds[index];
g_pwm_buffer[led.driver][led.r] = red;
g_pwm_buffer[led.driver][led.g] = green;
g_pwm_buffer[led.driver][led.b] = blue;
- g_pwm_buffer_update_required = true;
+ g_pwm_buffer_update_required = true;
}
}
-void IS31FL3736_set_color_all( uint8_t red, uint8_t green, uint8_t blue )
-{
- for ( int i = 0; i < DRIVER_LED_TOTAL; i++ )
- {
- IS31FL3736_set_color( i, red, green, blue );
+void IS31FL3736_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
+ for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
+ IS31FL3736_set_color(i, red, green, blue);
}
}
-void IS31FL3736_set_led_control_register( uint8_t index, bool red, bool green, bool blue )
-{
+void IS31FL3736_set_led_control_register(uint8_t index, bool red, bool green, bool blue) {
is31_led led = g_is31_leds[index];
// IS31FL3733
@@ -209,64 +195,59 @@ void IS31FL3736_set_led_control_register( uint8_t index, bool red, bool green, b
// A1-A4=0x00 A5-A8=0x01
// So, the same math applies.
- uint8_t control_register_r = led.r / 8;
- uint8_t control_register_g = led.g / 8;
- uint8_t control_register_b = led.b / 8;
+ uint8_t control_register_r = led.r / 8;
+ uint8_t control_register_g = led.g / 8;
+ uint8_t control_register_b = led.b / 8;
- uint8_t bit_r = led.r % 8;
- uint8_t bit_g = led.g % 8;
- uint8_t bit_b = led.b % 8;
+ uint8_t bit_r = led.r % 8;
+ uint8_t bit_g = led.g % 8;
+ uint8_t bit_b = led.b % 8;
- if ( red ) {
+ if (red) {
g_led_control_registers[led.driver][control_register_r] |= (1 << bit_r);
} else {
g_led_control_registers[led.driver][control_register_r] &= ~(1 << bit_r);
}
- if ( green ) {
+ if (green) {
g_led_control_registers[led.driver][control_register_g] |= (1 << bit_g);
} else {
g_led_control_registers[led.driver][control_register_g] &= ~(1 << bit_g);
}
- if ( blue ) {
+ if (blue) {
g_led_control_registers[led.driver][control_register_b] |= (1 << bit_b);
} else {
g_led_control_registers[led.driver][control_register_b] &= ~(1 << bit_b);
}
g_led_control_registers_update_required = true;
-
}
-void IS31FL3736_mono_set_brightness( int index, uint8_t value )
-{
- if ( index >= 0 && index < 96 ) {
- // Index in range 0..95 -> A1..A8, B1..B8, etc.
- // Map index 0..95 to registers 0x00..0xBE (interleaved)
- uint8_t pwm_register = index * 2;
+void IS31FL3736_mono_set_brightness(int index, uint8_t value) {
+ if (index >= 0 && index < 96) {
+ // Index in range 0..95 -> A1..A8, B1..B8, etc.
+ // Map index 0..95 to registers 0x00..0xBE (interleaved)
+ uint8_t pwm_register = index * 2;
g_pwm_buffer[0][pwm_register] = value;
- g_pwm_buffer_update_required = true;
+ g_pwm_buffer_update_required = true;
}
}
-void IS31FL3736_mono_set_brightness_all( uint8_t value )
-{
- for ( int i = 0; i < 96; i++ )
- {
- IS31FL3736_mono_set_brightness( i, value );
+void IS31FL3736_mono_set_brightness_all(uint8_t value) {
+ for (int i = 0; i < 96; i++) {
+ IS31FL3736_mono_set_brightness(i, value);
}
}
-void IS31FL3736_mono_set_led_control_register( uint8_t index, bool enabled )
-{
- // Index in range 0..95 -> A1..A8, B1..B8, etc.
+void IS31FL3736_mono_set_led_control_register(uint8_t index, bool enabled) {
+ // Index in range 0..95 -> A1..A8, B1..B8, etc.
- // Map index 0..95 to registers 0x00..0xBE (interleaved)
- uint8_t pwm_register = index * 2;
- // Map register 0x00..0xBE (interleaved) into control register and bit
- uint8_t control_register = pwm_register / 8;
- uint8_t bit = pwm_register % 8;
+ // Map index 0..95 to registers 0x00..0xBE (interleaved)
+ uint8_t pwm_register = index * 2;
+ // Map register 0x00..0xBE (interleaved) into control register and bit
+ uint8_t control_register = pwm_register / 8;
+ uint8_t bit = pwm_register % 8;
- if ( enabled ) {
+ if (enabled) {
g_led_control_registers[0][control_register] |= (1 << bit);
} else {
g_led_control_registers[0][control_register] &= ~(1 << bit);
@@ -275,32 +256,26 @@ void IS31FL3736_mono_set_led_control_register( uint8_t index, bool enabled )
g_led_control_registers_update_required = true;
}
-void IS31FL3736_update_pwm_buffers( uint8_t addr1, uint8_t addr2 )
-{
- if ( g_pwm_buffer_update_required )
- {
+void IS31FL3736_update_pwm_buffers(uint8_t addr1, uint8_t addr2) {
+ if (g_pwm_buffer_update_required) {
// Firstly we need to unlock the command register and select PG1
- IS31FL3736_write_register( addr1, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
- IS31FL3736_write_register( addr1, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM );
+ IS31FL3736_write_register(addr1, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
+ IS31FL3736_write_register(addr1, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM);
- IS31FL3736_write_pwm_buffer( addr1, g_pwm_buffer[0] );
- //IS31FL3736_write_pwm_buffer( addr2, g_pwm_buffer[1] );
+ IS31FL3736_write_pwm_buffer(addr1, g_pwm_buffer[0]);
+ // IS31FL3736_write_pwm_buffer( addr2, g_pwm_buffer[1] );
}
g_pwm_buffer_update_required = false;
}
-void IS31FL3736_update_led_control_registers( uint8_t addr1, uint8_t addr2 )
-{
- if ( g_led_control_registers_update_required )
- {
+void IS31FL3736_update_led_control_registers(uint8_t addr1, uint8_t addr2) {
+ if (g_led_control_registers_update_required) {
// Firstly we need to unlock the command register and select PG0
- IS31FL3736_write_register( addr1, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
- IS31FL3736_write_register( addr1, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL );
- for ( int i=0; i<24; i++ )
- {
- IS31FL3736_write_register(addr1, i, g_led_control_registers[0][i] );
- //IS31FL3736_write_register(addr2, i, g_led_control_registers[1][i] );
+ IS31FL3736_write_register(addr1, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
+ IS31FL3736_write_register(addr1, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL);
+ for (int i = 0; i < 24; i++) {
+ IS31FL3736_write_register(addr1, i, g_led_control_registers[0][i]);
+ // IS31FL3736_write_register(addr2, i, g_led_control_registers[1][i] );
}
}
}
-
diff --git a/drivers/issi/is31fl3736.h b/drivers/issi/is31fl3736.h
index cff50fd0d8..e48e31c279 100644
--- a/drivers/issi/is31fl3736.h
+++ b/drivers/issi/is31fl3736.h
@@ -19,154 +19,150 @@
#include <stdint.h>
#include <stdbool.h>
-
// Simple interface option.
// If these aren't defined, just define them to make it compile
-
#ifndef DRIVER_COUNT
-#define DRIVER_COUNT 2
+# define DRIVER_COUNT 2
#endif
#ifndef DRIVER_LED_TOTAL
-#define DRIVER_LED_TOTAL 96
+# define DRIVER_LED_TOTAL 96
#endif
-
typedef struct is31_led {
- uint8_t driver:2;
- uint8_t r;
- uint8_t g;
- uint8_t b;
+ uint8_t driver : 2;
+ uint8_t r;
+ uint8_t g;
+ uint8_t b;
} __attribute__((packed)) is31_led;
extern const is31_led g_is31_leds[DRIVER_LED_TOTAL];
-void IS31FL3736_init( uint8_t addr );
-void IS31FL3736_write_register( uint8_t addr, uint8_t reg, uint8_t data );
-void IS31FL3736_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer );
+void IS31FL3736_init(uint8_t addr);
+void IS31FL3736_write_register(uint8_t addr, uint8_t reg, uint8_t data);
+void IS31FL3736_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
-void IS31FL3736_set_color( int index, uint8_t red, uint8_t green, uint8_t blue );
-void IS31FL3736_set_color_all( uint8_t red, uint8_t green, uint8_t blue );
+void IS31FL3736_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
+void IS31FL3736_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
-void IS31FL3736_set_led_control_register( uint8_t index, bool red, bool green, bool blue );
+void IS31FL3736_set_led_control_register(uint8_t index, bool red, bool green, bool blue);
-void IS31FL3736_mono_set_brightness( int index, uint8_t value );
-void IS31FL3736_mono_set_brightness_all( uint8_t value );
-void IS31FL3736_mono_set_led_control_register( uint8_t index, bool enabled );
+void IS31FL3736_mono_set_brightness(int index, uint8_t value);
+void IS31FL3736_mono_set_brightness_all(uint8_t value);
+void IS31FL3736_mono_set_led_control_register(uint8_t index, bool enabled);
// This should not be called from an interrupt
// (eg. from a timer interrupt).
// Call this while idle (in between matrix scans).
// If the buffer is dirty, it will update the driver with the buffer.
-void IS31FL3736_update_pwm_buffers( uint8_t addr1, uint8_t addr2 );
-void IS31FL3736_update_led_control_registers( uint8_t addr1, uint8_t addr2 );
-
-#define A_1 0x00
-#define A_2 0x02
-#define A_3 0x04
-#define A_4 0x06
-#define A_5 0x08
-#define A_6 0x0A
-#define A_7 0x0C
-#define A_8 0x0E
-
-#define B_1 0x10
-#define B_2 0x12
-#define B_3 0x14
-#define B_4 0x16
-#define B_5 0x18
-#define B_6 0x1A
-#define B_7 0x1C
-#define B_8 0x1E
-
-#define C_1 0x20
-#define C_2 0x22
-#define C_3 0x24
-#define C_4 0x26
-#define C_5 0x28
-#define C_6 0x2A
-#define C_7 0x2C
-#define C_8 0x2E
-
-#define D_1 0x30
-#define D_2 0x32
-#define D_3 0x34
-#define D_4 0x36
-#define D_5 0x38
-#define D_6 0x3A
-#define D_7 0x3C
-#define D_8 0x3E
-
-#define E_1 0x40
-#define E_2 0x42
-#define E_3 0x44
-#define E_4 0x46
-#define E_5 0x48
-#define E_6 0x4A
-#define E_7 0x4C
-#define E_8 0x4E
-
-#define F_1 0x50
-#define F_2 0x52
-#define F_3 0x54
-#define F_4 0x56
-#define F_5 0x58
-#define F_6 0x5A
-#define F_7 0x5C
-#define F_8 0x5E
-
-#define G_1 0x60
-#define G_2 0x62
-#define G_3 0x64
-#define G_4 0x66
-#define G_5 0x68
-#define G_6 0x6A
-#define G_7 0x6C
-#define G_8 0x6E
-
-#define H_1 0x70
-#define H_2 0x72
-#define H_3 0x74
-#define H_4 0x76
-#define H_5 0x78
-#define H_6 0x7A
-#define H_7 0x7C
-#define H_8 0x7E
-
-#define I_1 0x80
-#define I_2 0x82
-#define I_3 0x84
-#define I_4 0x86
-#define I_5 0x88
-#define I_6 0x8A
-#define I_7 0x8C
-#define I_8 0x8E
-
-#define J_1 0x90
-#define J_2 0x92
-#define J_3 0x94
-#define J_4 0x96
-#define J_5 0x98
-#define J_6 0x9A
-#define J_7 0x9C
-#define J_8 0x9E
-
-#define K_1 0xA0
-#define K_2 0xA2
-#define K_3 0xA4
-#define K_4 0xA6
-#define K_5 0xA8
-#define K_6 0xAA
-#define K_7 0xAC
-#define K_8 0xAE
-
-#define L_1 0xB0
-#define L_2 0xB2
-#define L_3 0xB4
-#define L_4 0xB6
-#define L_5 0xB8
-#define L_6 0xBA
-#define L_7 0xBC
-#define L_8 0xBE
-
+void IS31FL3736_update_pwm_buffers(uint8_t addr1, uint8_t addr2);
+void IS31FL3736_update_led_control_registers(uint8_t addr1, uint8_t addr2);
+
+#define A_1 0x00
+#define A_2 0x02
+#define A_3 0x04
+#define A_4 0x06
+#define A_5 0x08
+#define A_6 0x0A
+#define A_7 0x0C
+#define A_8 0x0E
+
+#define B_1 0x10
+#define B_2 0x12
+#define B_3 0x14
+#define B_4 0x16
+#define B_5 0x18
+#define B_6 0x1A
+#define B_7 0x1C
+#define B_8 0x1E
+
+#define C_1 0x20
+#define C_2 0x22
+#define C_3 0x24
+#define C_4 0x26
+#define C_5 0x28
+#define C_6 0x2A
+#define C_7 0x2C
+#define C_8 0x2E
+
+#define D_1 0x30
+#define D_2 0x32
+#define D_3 0x34
+#define D_4 0x36
+#define D_5 0x38
+#define D_6 0x3A
+#define D_7 0x3C
+#define D_8 0x3E
+
+#define E_1 0x40
+#define E_2 0x42
+#define E_3 0x44
+#define E_4 0x46
+#define E_5 0x48
+#define E_6 0x4A
+#define E_7 0x4C
+#define E_8 0x4E
+
+#define F_1 0x50
+#define F_2 0x52
+#define F_3 0x54
+#define F_4 0x56
+#define F_5 0x58
+#define F_6 0x5A
+#define F_7 0x5C
+#define F_8 0x5E
+
+#define G_1 0x60
+#define G_2 0x62
+#define G_3 0x64
+#define G_4 0x66
+#define G_5 0x68
+#define G_6 0x6A
+#define G_7 0x6C
+#define G_8 0x6E
+
+#define H_1 0x70
+#define H_2 0x72
+#define H_3 0x74
+#define H_4 0x76
+#define H_5 0x78
+#define H_6 0x7A
+#define H_7 0x7C
+#define H_8 0x7E
+
+#define I_1 0x80
+#define I_2 0x82
+#define I_3 0x84
+#define I_4 0x86
+#define I_5 0x88
+#define I_6 0x8A
+#define I_7 0x8C
+#define I_8 0x8E
+
+#define J_1 0x90
+#define J_2 0x92
+#define J_3 0x94
+#define J_4 0x96
+#define J_5 0x98
+#define J_6 0x9A
+#define J_7 0x9C
+#define J_8 0x9E
+
+#define K_1 0xA0
+#define K_2 0xA2
+#define K_3 0xA4
+#define K_4 0xA6
+#define K_5 0xA8
+#define K_6 0xAA
+#define K_7 0xAC
+#define K_8 0xAE
+
+#define L_1 0xB0
+#define L_2 0xB2
+#define L_3 0xB4
+#define L_4 0xB6
+#define L_5 0xB8
+#define L_6 0xBA
+#define L_7 0xBC
+#define L_8 0xBE
diff --git a/drivers/issi/is31fl3737.c b/drivers/issi/is31fl3737.c
index 6491049274..4cc46272e2 100644
--- a/drivers/issi/is31fl3737.c
+++ b/drivers/issi/is31fl3737.c
@@ -17,11 +17,11 @@
*/
#ifdef __AVR__
-#include <avr/interrupt.h>
-#include <avr/io.h>
-#include <util/delay.h>
+# include <avr/interrupt.h>
+# include <avr/io.h>
+# include <util/delay.h>
#else
-#include "wait.h"
+# include "wait.h"
#endif
#include <string.h>
@@ -46,23 +46,23 @@
#define ISSI_INTERRUPTMASKREGISTER 0xF0
#define ISSI_INTERRUPTSTATUSREGISTER 0xF1
-#define ISSI_PAGE_LEDCONTROL 0x00 //PG0
-#define ISSI_PAGE_PWM 0x01 //PG1
-#define ISSI_PAGE_AUTOBREATH 0x02 //PG2
-#define ISSI_PAGE_FUNCTION 0x03 //PG3
+#define ISSI_PAGE_LEDCONTROL 0x00 // PG0
+#define ISSI_PAGE_PWM 0x01 // PG1
+#define ISSI_PAGE_AUTOBREATH 0x02 // PG2
+#define ISSI_PAGE_FUNCTION 0x03 // PG3
-#define ISSI_REG_CONFIGURATION 0x00 //PG3
-#define ISSI_REG_GLOBALCURRENT 0x01 //PG3
-#define ISSI_REG_RESET 0x11// PG3
-#define ISSI_REG_SWPULLUP 0x0F //PG3
-#define ISSI_REG_CSPULLUP 0x10 //PG3
+#define ISSI_REG_CONFIGURATION 0x00 // PG3
+#define ISSI_REG_GLOBALCURRENT 0x01 // PG3
+#define ISSI_REG_RESET 0x11 // PG3
+#define ISSI_REG_SWPULLUP 0x0F // PG3
+#define ISSI_REG_CSPULLUP 0x10 // PG3
#ifndef ISSI_TIMEOUT
- #define ISSI_TIMEOUT 100
+# define ISSI_TIMEOUT 100
#endif
#ifndef ISSI_PERSISTENCE
- #define ISSI_PERSISTENCE 0
+# define ISSI_PERSISTENCE 0
#endif
// Transfer buffer for TWITransmitData()
@@ -75,178 +75,161 @@ uint8_t g_twi_transfer_buffer[20];
// buffers and the transfers in IS31FL3737_write_pwm_buffer() but it's
// probably not worth the extra complexity.
uint8_t g_pwm_buffer[DRIVER_COUNT][192];
-bool g_pwm_buffer_update_required = false;
+bool g_pwm_buffer_update_required = false;
-uint8_t g_led_control_registers[DRIVER_COUNT][24] = { { 0 } };
-bool g_led_control_registers_update_required = false;
+uint8_t g_led_control_registers[DRIVER_COUNT][24] = {{0}};
+bool g_led_control_registers_update_required = false;
-void IS31FL3737_write_register( uint8_t addr, uint8_t reg, uint8_t data )
-{
+void IS31FL3737_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
g_twi_transfer_buffer[0] = reg;
g_twi_transfer_buffer[1] = data;
- #if ISSI_PERSISTENCE > 0
+#if ISSI_PERSISTENCE > 0
for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
- if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0)
- break;
+ if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT) == 0) break;
}
- #else
+#else
i2c_transmit(addr << 1, g_twi_transfer_buffer, 2, ISSI_TIMEOUT);
- #endif
+#endif
}
-void IS31FL3737_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer )
-{
+void IS31FL3737_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
// assumes PG1 is already selected
// transmit PWM registers in 12 transfers of 16 bytes
// g_twi_transfer_buffer[] is 20 bytes
// iterate over the pwm_buffer contents at 16 byte intervals
- for ( int i = 0; i < 192; i += 16 ) {
+ for (int i = 0; i < 192; i += 16) {
g_twi_transfer_buffer[0] = i;
// copy the data from i to i+15
// device will auto-increment register for data after the first byte
// thus this sets registers 0x00-0x0F, 0x10-0x1F, etc. in one transfer
- for ( int j = 0; j < 16; j++ ) {
+ for (int j = 0; j < 16; j++) {
g_twi_transfer_buffer[1 + j] = pwm_buffer[i + j];
}
- #if ISSI_PERSISTENCE > 0
- for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
- if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0)
- break;
- }
- #else
- i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT);
- #endif
+#if ISSI_PERSISTENCE > 0
+ for (uint8_t i = 0; i < ISSI_PERSISTENCE; i++) {
+ if (i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT) == 0) break;
+ }
+#else
+ i2c_transmit(addr << 1, g_twi_transfer_buffer, 17, ISSI_TIMEOUT);
+#endif
}
}
-void IS31FL3737_init( uint8_t addr )
-{
+void IS31FL3737_init(uint8_t addr) {
// In order to avoid the LEDs being driven with garbage data
// in the LED driver's PWM registers, shutdown is enabled last.
// Set up the mode and other settings, clear the PWM registers,
// then disable software shutdown.
// Unlock the command register.
- IS31FL3737_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
+ IS31FL3737_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
// Select PG0
- IS31FL3737_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL );
+ IS31FL3737_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL);
// Turn off all LEDs.
- for ( int i = 0x00; i <= 0x17; i++ )
- {
- IS31FL3737_write_register( addr, i, 0x00 );
+ for (int i = 0x00; i <= 0x17; i++) {
+ IS31FL3737_write_register(addr, i, 0x00);
}
// Unlock the command register.
- IS31FL3737_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
+ IS31FL3737_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
// Select PG1
- IS31FL3737_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM );
+ IS31FL3737_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM);
// Set PWM on all LEDs to 0
// No need to setup Breath registers to PWM as that is the default.
- for ( int i = 0x00; i <= 0xBF; i++ )
- {
- IS31FL3737_write_register( addr, i, 0x00 );
+ for (int i = 0x00; i <= 0xBF; i++) {
+ IS31FL3737_write_register(addr, i, 0x00);
}
// Unlock the command register.
- IS31FL3737_write_register( addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
+ IS31FL3737_write_register(addr, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
// Select PG3
- IS31FL3737_write_register( addr, ISSI_COMMANDREGISTER, ISSI_PAGE_FUNCTION );
+ IS31FL3737_write_register(addr, ISSI_COMMANDREGISTER, ISSI_PAGE_FUNCTION);
// Set global current to maximum.
- IS31FL3737_write_register( addr, ISSI_REG_GLOBALCURRENT, 0xFF );
+ IS31FL3737_write_register(addr, ISSI_REG_GLOBALCURRENT, 0xFF);
// Disable software shutdown.
- IS31FL3737_write_register( addr, ISSI_REG_CONFIGURATION, 0x01 );
+ IS31FL3737_write_register(addr, ISSI_REG_CONFIGURATION, 0x01);
- // Wait 10ms to ensure the device has woken up.
- #ifdef __AVR__
- _delay_ms( 10 );
- #else
+// Wait 10ms to ensure the device has woken up.
+#ifdef __AVR__
+ _delay_ms(10);
+#else
wait_ms(10);
- #endif
+#endif
}
-void IS31FL3737_set_color( int index, uint8_t red, uint8_t green, uint8_t blue )
-{
- if ( index >= 0 && index < DRIVER_LED_TOTAL ) {
+void IS31FL3737_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
+ if (index >= 0 && index < DRIVER_LED_TOTAL) {
is31_led led = g_is31_leds[index];
g_pwm_buffer[led.driver][led.r] = red;
g_pwm_buffer[led.driver][led.g] = green;
g_pwm_buffer[led.driver][led.b] = blue;
- g_pwm_buffer_update_required = true;
+ g_pwm_buffer_update_required = true;
}
}
-void IS31FL3737_set_color_all( uint8_t red, uint8_t green, uint8_t blue )
-{
- for ( int i = 0; i < DRIVER_LED_TOTAL; i++ )
- {
- IS31FL3737_set_color( i, red, green, blue );
+void IS31FL3737_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
+ for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
+ IS31FL3737_set_color(i, red, green, blue);
}
}
-void IS31FL3737_set_led_control_register( uint8_t index, bool red, bool green, bool blue )
-{
+void IS31FL3737_set_led_control_register(uint8_t index, bool red, bool green, bool blue) {
is31_led led = g_is31_leds[index];
- uint8_t control_register_r = led.r / 8;
- uint8_t control_register_g = led.g / 8;
- uint8_t control_register_b = led.b / 8;
- uint8_t bit_r = led.r % 8;
- uint8_t bit_g = led.g % 8;
- uint8_t bit_b = led.b % 8;
+ uint8_t control_register_r = led.r / 8;
+ uint8_t control_register_g = led.g / 8;
+ uint8_t control_register_b = led.b / 8;
+ uint8_t bit_r = led.r % 8;
+ uint8_t bit_g = led.g % 8;
+ uint8_t bit_b = led.b % 8;
- if ( red ) {
+ if (red) {
g_led_control_registers[led.driver][control_register_r] |= (1 << bit_r);
} else {
g_led_control_registers[led.driver][control_register_r] &= ~(1 << bit_r);
}
- if ( green ) {
+ if (green) {
g_led_control_registers[led.driver][control_register_g] |= (1 << bit_g);
} else {
g_led_control_registers[led.driver][control_register_g] &= ~(1 << bit_g);
}
- if ( blue ) {
+ if (blue) {
g_led_control_registers[led.driver][control_register_b] |= (1 << bit_b);
} else {
g_led_control_registers[led.driver][control_register_b] &= ~(1 << bit_b);
}
g_led_control_registers_update_required = true;
-
}
-void IS31FL3737_update_pwm_buffers( uint8_t addr1, uint8_t addr2 )
-{
- if ( g_pwm_buffer_update_required )
- {
+void IS31FL3737_update_pwm_buffers(uint8_t addr1, uint8_t addr2) {
+ if (g_pwm_buffer_update_required) {
// Firstly we need to unlock the command register and select PG1
- IS31FL3737_write_register( addr1, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
- IS31FL3737_write_register( addr1, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM );
+ IS31FL3737_write_register(addr1, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
+ IS31FL3737_write_register(addr1, ISSI_COMMANDREGISTER, ISSI_PAGE_PWM);
- IS31FL3737_write_pwm_buffer( addr1, g_pwm_buffer[0] );
- //IS31FL3737_write_pwm_buffer( addr2, g_pwm_buffer[1] );
+ IS31FL3737_write_pwm_buffer(addr1, g_pwm_buffer[0]);
+ // IS31FL3737_write_pwm_buffer( addr2, g_pwm_buffer[1] );
}
g_pwm_buffer_update_required = false;
}
-void IS31FL3737_update_led_control_registers( uint8_t addr1, uint8_t addr2 )
-{
- if ( g_led_control_registers_update_required )
- {
+void IS31FL3737_update_led_control_registers(uint8_t addr1, uint8_t addr2) {
+ if (g_led_control_registers_update_required) {
// Firstly we need to unlock the command register and select PG0
- IS31FL3737_write_register( addr1, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5 );
- IS31FL3737_write_register( addr1, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL );
- for ( int i=0; i<24; i++ )
- {
- IS31FL3737_write_register(addr1, i, g_led_control_registers[0][i] );
- //IS31FL3737_write_register(addr2, i, g_led_control_registers[1][i] );
+ IS31FL3737_write_register(addr1, ISSI_COMMANDREGISTER_WRITELOCK, 0xC5);
+ IS31FL3737_write_register(addr1, ISSI_COMMANDREGISTER, ISSI_PAGE_LEDCONTROL);
+ for (int i = 0; i < 24; i++) {
+ IS31FL3737_write_register(addr1, i, g_led_control_registers[0][i]);
+ // IS31FL3737_write_register(addr2, i, g_led_control_registers[1][i] );
}
}
}
diff --git a/drivers/issi/is31fl3737.h b/drivers/issi/is31fl3737.h
index 69c4b9b538..2c2fb19641 100644
--- a/drivers/issi/is31fl3737.h
+++ b/drivers/issi/is31fl3737.h
@@ -16,7 +16,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
#ifndef IS31FL3737_DRIVER_H
#define IS31FL3737_DRIVER_H
@@ -24,184 +23,184 @@
#include <stdbool.h>
typedef struct is31_led {
- uint8_t driver:2;
- uint8_t r;
- uint8_t g;
- uint8_t b;
+ uint8_t driver : 2;
+ uint8_t r;
+ uint8_t g;
+ uint8_t b;
} __attribute__((packed)) is31_led;
extern const is31_led g_is31_leds[DRIVER_LED_TOTAL];
-void IS31FL3737_init( uint8_t addr );
-void IS31FL3737_write_register( uint8_t addr, uint8_t reg, uint8_t data );
-void IS31FL3737_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer );
+void IS31FL3737_init(uint8_t addr);
+void IS31FL3737_write_register(uint8_t addr, uint8_t reg, uint8_t data);
+void IS31FL3737_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
-void IS31FL3737_set_color( int index, uint8_t red, uint8_t green, uint8_t blue );
-void IS31FL3737_set_color_all( uint8_t red, uint8_t green, uint8_t blue );
+void IS31FL3737_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
+void IS31FL3737_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
-void IS31FL3737_set_led_control_register( uint8_t index, bool red, bool green, bool blue );
+void IS31FL3737_set_led_control_register(uint8_t index, bool red, bool green, bool blue);
// This should not be called from an interrupt
// (eg. from a timer interrupt).
// Call this while idle (in between matrix scans).
// If the buffer is dirty, it will update the driver with the buffer.
-void IS31FL3737_update_pwm_buffers( uint8_t addr1, uint8_t addr2 );
-void IS31FL3737_update_led_control_registers( uint8_t addr1, uint8_t addr2 );
-
-#define A_1 0x00
-#define A_2 0x01
-#define A_3 0x02
-#define A_4 0x03
-#define A_5 0x04
-#define A_6 0x05
-#define A_7 0x08
-#define A_8 0x09
-#define A_9 0x0A
-#define A_10 0x0B
-#define A_11 0x0C
-#define A_12 0x0D
-
-#define B_1 0x10
-#define B_2 0x11
-#define B_3 0x12
-#define B_4 0x13
-#define B_5 0x14
-#define B_6 0x15
-#define B_7 0x18
-#define B_8 0x19
-#define B_9 0x1A
-#define B_10 0x1B
-#define B_11 0x1C
-#define B_12 0x1D
-
-#define C_1 0x20
-#define C_2 0x21
-#define C_3 0x22
-#define C_4 0x23
-#define C_5 0x24
-#define C_6 0x25
-#define C_7 0x28
-#define C_8 0x29
-#define C_9 0x2A
-#define C_10 0x2B
-#define C_11 0x2C
-#define C_12 0x2D
-
-#define D_1 0x30
-#define D_2 0x31
-#define D_3 0x32
-#define D_4 0x33
-#define D_5 0x34
-#define D_6 0x35
-#define D_7 0x38
-#define D_8 0x39
-#define D_9 0x3A
-#define D_10 0x3B
-#define D_11 0x3C
-#define D_12 0x3D
-
-#define E_1 0x40
-#define E_2 0x41
-#define E_3 0x42
-#define E_4 0x43
-#define E_5 0x44
-#define E_6 0x45
-#define E_7 0x48
-#define E_8 0x49
-#define E_9 0x4A
-#define E_10 0x4B
-#define E_11 0x4C
-#define E_12 0x4D
-
-#define F_1 0x50
-#define F_2 0x51
-#define F_3 0x52
-#define F_4 0x53
-#define F_5 0x54
-#define F_6 0x55
-#define F_7 0x58
-#define F_8 0x59
-#define F_9 0x5A
-#define F_10 0x5B
-#define F_11 0x5C
-#define F_12 0x5D
-
-#define G_1 0x60
-#define G_2 0x61
-#define G_3 0x62
-#define G_4 0x63
-#define G_5 0x64
-#define G_6 0x65
-#define G_7 0x68
-#define G_8 0x69
-#define G_9 0x6A
-#define G_10 0x6B
-#define G_11 0x6C
-#define G_12 0x6D
-
-#define H_1 0x70
-#define H_2 0x71
-#define H_3 0x72
-#define H_4 0x73
-#define H_5 0x74
-#define H_6 0x75
-#define H_7 0x78
-#define H_8 0x79
-#define H_9 0x7A
-#define H_10 0x7B
-#define H_11 0x7C
-#define H_12 0x7D
-
-#define I_1 0x80
-#define I_2 0x81
-#define I_3 0x82
-#define I_4 0x83
-#define I_5 0x84
-#define I_6 0x85
-#define I_7 0x88
-#define I_8 0x89
-#define I_9 0x8A
-#define I_10 0x8B
-#define I_11 0x8C
-#define I_12 0x8D
-
-#define J_1 0x90
-#define J_2 0x91
-#define J_3 0x92
-#define J_4 0x93
-#define J_5 0x94
-#define J_6 0x95
-#define J_7 0x98
-#define J_8 0x99
-#define J_9 0x9A
-#define J_10 0x9B
-#define J_11 0x9C
-#define J_12 0x9D
-
-#define K_1 0xA0
-#define K_2 0xA1
-#define K_3 0xA2
-#define K_4 0xA3
-#define K_5 0xA4
-#define K_6 0xA5
-#define K_7 0xA8
-#define K_8 0xA9
-#define K_9 0xAA
-#define K_10 0xAB
-#define K_11 0xAC
-#define K_12 0xAD
-
-#define L_1 0xB0
-#define L_2 0xB1
-#define L_3 0xB2
-#define L_4 0xB3
-#define L_5 0xB4
-#define L_6 0xB5
-#define L_7 0xB8
-#define L_8 0xB9
-#define L_9 0xBA
-#define L_10 0xBB
-#define L_11 0xBC
-#define L_12 0xBD
-
-#endif // IS31FL3737_DRIVER_H
+void IS31FL3737_update_pwm_buffers(uint8_t addr1, uint8_t addr2);
+void IS31FL3737_update_led_control_registers(uint8_t addr1, uint8_t addr2);
+
+#define A_1 0x00
+#define A_2 0x01
+#define A_3 0x02
+#define A_4 0x03
+#define A_5 0x04
+#define A_6 0x05
+#define A_7 0x08
+#define A_8 0x09
+#define A_9 0x0A
+#define A_10 0x0B
+#define A_11 0x0C
+#define A_12 0x0D
+
+#define B_1 0x10
+#define B_2 0x11
+#define B_3 0x12
+#define B_4 0x13
+#define B_5 0x14
+#define B_6 0x15
+#define B_7 0x18
+#define B_8 0x19
+#define B_9 0x1A
+#define B_10 0x1B
+#define B_11 0x1C
+#define B_12 0x1D
+
+#define C_1 0x20
+#define C_2 0x21
+#define C_3 0x22
+#define C_4 0x23
+#define C_5 0x24
+#define C_6 0x25
+#define C_7 0x28
+#define C_8 0x29
+#define C_9 0x2A
+#define C_10 0x2B
+#define C_11 0x2C
+#define C_12 0x2D
+
+#define D_1 0x30
+#define D_2 0x31
+#define D_3 0x32
+#define D_4 0x33
+#define D_5 0x34
+#define D_6 0x35
+#define D_7 0x38
+#define D_8 0x39
+#define D_9 0x3A
+#define D_10 0x3B
+#define D_11 0x3C
+#define D_12 0x3D
+
+#define E_1 0x40
+#define E_2 0x41
+#define E_3 0x42
+#define E_4 0x43
+#define E_5 0x44
+#define E_6 0x45
+#define E_7 0x48
+#define E_8 0x49
+#define E_9 0x4A
+#define E_10 0x4B
+#define E_11 0x4C
+#define E_12 0x4D
+
+#define F_1 0x50
+#define F_2 0x51
+#define F_3 0x52
+#define F_4 0x53
+#define F_5 0x54
+#define F_6 0x55
+#define F_7 0x58
+#define F_8 0x59
+#define F_9 0x5A
+#define F_10 0x5B
+#define F_11 0x5C
+#define F_12 0x5D
+
+#define G_1 0x60
+#define G_2 0x61
+#define G_3 0x62
+#define G_4 0x63
+#define G_5 0x64
+#define G_6 0x65
+#define G_7 0x68
+#define G_8 0x69
+#define G_9 0x6A
+#define G_10 0x6B
+#define G_11 0x6C
+#define G_12 0x6D
+
+#define H_1 0x70
+#define H_2 0x71
+#define H_3 0x72
+#define H_4 0x73
+#define H_5 0x74
+#define H_6 0x75
+#define H_7 0x78
+#define H_8 0x79
+#define H_9 0x7A
+#define H_10 0x7B
+#define H_11 0x7C
+#define H_12 0x7D
+
+#define I_1 0x80
+#define I_2 0x81
+#define I_3 0x82
+#define I_4 0x83
+#define I_5 0x84
+#define I_6 0x85
+#define I_7 0x88
+#define I_8 0x89
+#define I_9 0x8A
+#define I_10 0x8B
+#define I_11 0x8C
+#define I_12 0x8D
+
+#define J_1 0x90
+#define J_2 0x91
+#define J_3 0x92
+#define J_4 0x93
+#define J_5 0x94
+#define J_6 0x95
+#define J_7 0x98
+#define J_8 0x99
+#define J_9 0x9A
+#define J_10 0x9B
+#define J_11 0x9C
+#define J_12 0x9D
+
+#define K_1 0xA0
+#define K_2 0xA1
+#define K_3 0xA2
+#define K_4 0xA3
+#define K_5 0xA4
+#define K_6 0xA5
+#define K_7 0xA8
+#define K_8 0xA9
+#define K_9 0xAA
+#define K_10 0xAB
+#define K_11 0xAC
+#define K_12 0xAD
+
+#define L_1 0xB0
+#define L_2 0xB1
+#define L_3 0xB2
+#define L_4 0xB3
+#define L_5 0xB4
+#define L_6 0xB5
+#define L_7 0xB8
+#define L_8 0xB9
+#define L_9 0xBA
+#define L_10 0xBB
+#define L_11 0xBC
+#define L_12 0xBD
+
+#endif // IS31FL3737_DRIVER_H
diff --git a/drivers/oled/glcdfont.c b/drivers/oled/glcdfont.c
index 150be9e944..95c5d2ebf4 100644
--- a/drivers/oled/glcdfont.c
+++ b/drivers/oled/glcdfont.c
@@ -1,240 +1,25 @@
#pragma once
#ifdef __AVR__
- #include <avr/io.h>
- #include <avr/pgmspace.h>
+# include <avr/io.h>
+# include <avr/pgmspace.h>
#elif defined(ESP8266)
- #include <pgmspace.h>
+# include <pgmspace.h>
#else
- #define PROGMEM
+# define PROGMEM
#endif
// Helidox 8x6 font with QMK Firmware Logo
// Online editor: http://teripom.x0.com/
static const unsigned char font[] PROGMEM = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x00,
- 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x00,
- 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x00,
- 0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x00,
- 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x00,
- 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00,
- 0x00, 0x18, 0x3C, 0x18, 0x00, 0x00,
- 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00,
- 0x00, 0x18, 0x24, 0x18, 0x00, 0x00,
- 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x00,
- 0x30, 0x48, 0x3A, 0x06, 0x0E, 0x00,
- 0x26, 0x29, 0x79, 0x29, 0x26, 0x00,
- 0x40, 0x7F, 0x05, 0x05, 0x07, 0x00,
- 0x40, 0x7F, 0x05, 0x25, 0x3F, 0x00,
- 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x00,
- 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x00,
- 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x00,
- 0x14, 0x22, 0x7F, 0x22, 0x14, 0x00,
- 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x00,
- 0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00,
- 0x00, 0x66, 0x89, 0x95, 0x6A, 0x00,
- 0x60, 0x60, 0x60, 0x60, 0x60, 0x00,
- 0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x00,
- 0x08, 0x04, 0x7E, 0x04, 0x08, 0x00,
- 0x10, 0x20, 0x7E, 0x20, 0x10, 0x00,
- 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x00,
- 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x00,
- 0x1E, 0x10, 0x10, 0x10, 0x10, 0x00,
- 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x00,
- 0x30, 0x38, 0x3E, 0x38, 0x30, 0x00,
- 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00,
- 0x00, 0x07, 0x00, 0x07, 0x00, 0x00,
- 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00,
- 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x00,
- 0x23, 0x13, 0x08, 0x64, 0x62, 0x00,
- 0x36, 0x49, 0x56, 0x20, 0x50, 0x00,
- 0x00, 0x08, 0x07, 0x03, 0x00, 0x00,
- 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00,
- 0x00, 0x41, 0x22, 0x1C, 0x00, 0x00,
- 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x00,
- 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00,
- 0x00, 0x80, 0x70, 0x30, 0x00, 0x00,
- 0x08, 0x08, 0x08, 0x08, 0x08, 0x00,
- 0x00, 0x00, 0x60, 0x60, 0x00, 0x00,
- 0x20, 0x10, 0x08, 0x04, 0x02, 0x00,
- 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00,
- 0x00, 0x42, 0x7F, 0x40, 0x00, 0x00,
- 0x72, 0x49, 0x49, 0x49, 0x46, 0x00,
- 0x21, 0x41, 0x49, 0x4D, 0x33, 0x00,
- 0x18, 0x14, 0x12, 0x7F, 0x10, 0x00,
- 0x27, 0x45, 0x45, 0x45, 0x39, 0x00,
- 0x3C, 0x4A, 0x49, 0x49, 0x31, 0x00,
- 0x41, 0x21, 0x11, 0x09, 0x07, 0x00,
- 0x36, 0x49, 0x49, 0x49, 0x36, 0x00,
- 0x46, 0x49, 0x49, 0x29, 0x1E, 0x00,
- 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
- 0x00, 0x40, 0x34, 0x00, 0x00, 0x00,
- 0x00, 0x08, 0x14, 0x22, 0x41, 0x00,
- 0x14, 0x14, 0x14, 0x14, 0x14, 0x00,
- 0x00, 0x41, 0x22, 0x14, 0x08, 0x00,
- 0x02, 0x01, 0x59, 0x09, 0x06, 0x00,
- 0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x00,
- 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x00,
- 0x7F, 0x49, 0x49, 0x49, 0x36, 0x00,
- 0x3E, 0x41, 0x41, 0x41, 0x22, 0x00,
- 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x00,
- 0x7F, 0x49, 0x49, 0x49, 0x41, 0x00,
- 0x7F, 0x09, 0x09, 0x09, 0x01, 0x00,
- 0x3E, 0x41, 0x41, 0x51, 0x73, 0x00,
- 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00,
- 0x00, 0x41, 0x7F, 0x41, 0x00, 0x00,
- 0x20, 0x40, 0x41, 0x3F, 0x01, 0x00,
- 0x7F, 0x08, 0x14, 0x22, 0x41, 0x00,
- 0x7F, 0x40, 0x40, 0x40, 0x40, 0x00,
- 0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x00,
- 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00,
- 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00,
- 0x7F, 0x09, 0x09, 0x09, 0x06, 0x00,
- 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00,
- 0x7F, 0x09, 0x19, 0x29, 0x46, 0x00,
- 0x26, 0x49, 0x49, 0x49, 0x32, 0x00,
- 0x03, 0x01, 0x7F, 0x01, 0x03, 0x00,
- 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00,
- 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00,
- 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x00,
- 0x63, 0x14, 0x08, 0x14, 0x63, 0x00,
- 0x03, 0x04, 0x78, 0x04, 0x03, 0x00,
- 0x61, 0x59, 0x49, 0x4D, 0x43, 0x00,
- 0x00, 0x7F, 0x41, 0x41, 0x41, 0x00,
- 0x02, 0x04, 0x08, 0x10, 0x20, 0x00,
- 0x00, 0x41, 0x41, 0x41, 0x7F, 0x00,
- 0x04, 0x02, 0x01, 0x02, 0x04, 0x00,
- 0x40, 0x40, 0x40, 0x40, 0x40, 0x00,
- 0x00, 0x03, 0x07, 0x08, 0x00, 0x00,
- 0x20, 0x54, 0x54, 0x78, 0x40, 0x00,
- 0x7F, 0x28, 0x44, 0x44, 0x38, 0x00,
- 0x38, 0x44, 0x44, 0x44, 0x28, 0x00,
- 0x38, 0x44, 0x44, 0x28, 0x7F, 0x00,
- 0x38, 0x54, 0x54, 0x54, 0x18, 0x00,
- 0x00, 0x08, 0x7E, 0x09, 0x02, 0x00,
- 0x18, 0xA4, 0xA4, 0x9C, 0x78, 0x00,
- 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00,
- 0x00, 0x44, 0x7D, 0x40, 0x00, 0x00,
- 0x20, 0x40, 0x40, 0x3D, 0x00, 0x00,
- 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00,
- 0x00, 0x41, 0x7F, 0x40, 0x00, 0x00,
- 0x7C, 0x04, 0x78, 0x04, 0x78, 0x00,
- 0x7C, 0x08, 0x04, 0x04, 0x78, 0x00,
- 0x38, 0x44, 0x44, 0x44, 0x38, 0x00,
- 0xFC, 0x18, 0x24, 0x24, 0x18, 0x00,
- 0x18, 0x24, 0x24, 0x18, 0xFC, 0x00,
- 0x7C, 0x08, 0x04, 0x04, 0x08, 0x00,
- 0x48, 0x54, 0x54, 0x54, 0x24, 0x00,
- 0x04, 0x04, 0x3F, 0x44, 0x24, 0x00,
- 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x00,
- 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x00,
- 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00,
- 0x44, 0x28, 0x10, 0x28, 0x44, 0x00,
- 0x4C, 0x90, 0x90, 0x90, 0x7C, 0x00,
- 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00,
- 0x00, 0x08, 0x36, 0x41, 0x00, 0x00,
- 0x00, 0x00, 0x77, 0x00, 0x00, 0x00,
- 0x00, 0x41, 0x36, 0x08, 0x00, 0x00,
- 0x02, 0x01, 0x02, 0x04, 0x02, 0x00,
- 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x40, 0x40, 0x40, 0xF0, 0xF8, 0xF8,
- 0xFF, 0x38, 0xFF, 0xF8, 0xF8, 0x3F,
- 0xF8, 0xF8, 0xFF, 0x38, 0xFF, 0xF8,
- 0xF8, 0xF0, 0x40, 0x40, 0x40, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
- 0xC0, 0xC0, 0xC0, 0x80, 0x00, 0x00,
- 0xC0, 0xC0, 0x80, 0x00, 0x00, 0x00,
- 0x80, 0xC0, 0xC0, 0x00, 0xC0, 0xC0,
- 0x00, 0x00, 0x80, 0xC0, 0xC0, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0,
- 0xC0, 0xC0, 0xC0, 0x00, 0xC0, 0xC0,
- 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, 0x00, 0x00,
- 0xE0, 0xF0, 0xF0, 0xF0, 0xE0, 0xEC,
- 0xEE, 0xF7, 0xF3, 0x70, 0x20, 0x00,
- 0x7C, 0x7C, 0x7C, 0x7E, 0x00, 0x7E,
- 0x7E, 0x7E, 0x7F, 0x7F, 0x7F, 0x00,
- 0x00, 0x80, 0xC0, 0xE0, 0x7E, 0x5B,
- 0x4F, 0x5B, 0xFE, 0xC0, 0x00, 0x00,
- 0xC0, 0x00, 0xDC, 0xD7, 0xDE, 0xDE,
- 0xDE, 0xD7, 0xDC, 0x00, 0xC0, 0x00,
- 0x00, 0x00, 0x00, 0xE0, 0xEC, 0xDF,
- 0xFC, 0xE0, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x49, 0x49, 0x49, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xE0, 0xDF, 0xBF, 0xBF, 0x00,
- 0xBF, 0xBF, 0xDF, 0xE0, 0xFF, 0xFF,
- 0xFF, 0xFF, 0x49, 0x49, 0x49, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x1F, 0x3F,
- 0x60, 0x60, 0xE0, 0xBF, 0x1F, 0x00,
- 0x7F, 0x7F, 0x07, 0x1E, 0x38, 0x1E,
- 0x07, 0x7F, 0x7F, 0x00, 0x7F, 0x7F,
- 0x0E, 0x1F, 0x3B, 0x71, 0x60, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F,
- 0x0C, 0x0C, 0x0C, 0x00, 0x7E, 0x7E,
- 0x00, 0x7F, 0x7E, 0x03, 0x03, 0x00,
- 0x7F, 0x7E, 0x03, 0x03, 0x7E, 0x7E,
- 0x03, 0x03, 0x7F, 0x7E, 0x00, 0x0F,
- 0x3E, 0x70, 0x3C, 0x06, 0x3C, 0x70,
- 0x3E, 0x0F, 0x00, 0x32, 0x7B, 0x49,
- 0x49, 0x3F, 0x7E, 0x00, 0x7F, 0x7E,
- 0x03, 0x03, 0x00, 0x1E, 0x3F, 0x69,
- 0x69, 0x6F, 0x26, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x0F, 0x1F, 0x3F, 0x7F, 0x7F, 0x7F,
- 0x7F, 0x7F, 0x3F, 0x1E, 0x0C, 0x00,
- 0x1F, 0x1F, 0x1F, 0x3F, 0x00, 0x3F,
- 0x3F, 0x3F, 0x7F, 0x7F, 0x7F, 0x00,
- 0x30, 0x7B, 0x7F, 0x78, 0x30, 0x20,
- 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,
- 0x01, 0x01, 0x01, 0x07, 0x0F, 0x0F,
- 0x7F, 0x0F, 0x7F, 0x0F, 0x0F, 0x7E,
- 0x0F, 0x0F, 0x7F, 0x0F, 0x7F, 0x0F,
- 0x0F, 0x07, 0x01, 0x01, 0x01, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01, 0x01, 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, 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, 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, 0x00, 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x00, 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x00, 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x00, 0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x00, 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x00, 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00, 0x00, 0x18, 0x3C, 0x18, 0x00, 0x00, 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00, 0x00, 0x18, 0x24, 0x18, 0x00, 0x00, 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x00, 0x30, 0x48, 0x3A, 0x06, 0x0E, 0x00, 0x26, 0x29, 0x79, 0x29, 0x26, 0x00, 0x40, 0x7F, 0x05, 0x05, 0x07, 0x00, 0x40, 0x7F, 0x05, 0x25, 0x3F, 0x00, 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x00, 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x00, 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x00, 0x14, 0x22, 0x7F, 0x22, 0x14, 0x00, 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x00, 0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00, 0x00, 0x66, 0x89, 0x95, 0x6A, 0x00, 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, 0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x00, 0x08, 0x04, 0x7E, 0x04, 0x08, 0x00,
+ 0x10, 0x20, 0x7E, 0x20, 0x10, 0x00, 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x00, 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x00, 0x1E, 0x10, 0x10, 0x10, 0x10, 0x00, 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x00, 0x30, 0x38, 0x3E, 0x38, 0x30, 0x00, 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00, 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x00, 0x23, 0x13, 0x08, 0x64, 0x62, 0x00, 0x36, 0x49, 0x56, 0x20, 0x50, 0x00, 0x00, 0x08, 0x07, 0x03, 0x00, 0x00, 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, 0x00, 0x41, 0x22, 0x1C, 0x00, 0x00, 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, 0x00, 0x80, 0x70, 0x30, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00, 0x00,
+ 0x72, 0x49, 0x49, 0x49, 0x46, 0x00, 0x21, 0x41, 0x49, 0x4D, 0x33, 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10, 0x00, 0x27, 0x45, 0x45, 0x45, 0x39, 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x31, 0x00, 0x41, 0x21, 0x11, 0x09, 0x07, 0x00, 0x36, 0x49, 0x49, 0x49, 0x36, 0x00, 0x46, 0x49, 0x49, 0x29, 0x1E, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x40, 0x34, 0x00, 0x00, 0x00, 0x00, 0x08, 0x14, 0x22, 0x41, 0x00, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, 0x00, 0x41, 0x22, 0x14, 0x08, 0x00, 0x02, 0x01, 0x59, 0x09, 0x06, 0x00, 0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36, 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41, 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01, 0x00, 0x3E, 0x41, 0x41, 0x51, 0x73, 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00, 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01, 0x00,
+ 0x7F, 0x08, 0x14, 0x22, 0x41, 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40, 0x00, 0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06, 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46, 0x00, 0x26, 0x49, 0x49, 0x49, 0x32, 0x00, 0x03, 0x01, 0x7F, 0x01, 0x03, 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x00, 0x63, 0x14, 0x08, 0x14, 0x63, 0x00, 0x03, 0x04, 0x78, 0x04, 0x03, 0x00, 0x61, 0x59, 0x49, 0x4D, 0x43, 0x00, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x04, 0x02, 0x01, 0x02, 0x04, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, 0x03, 0x07, 0x08, 0x00, 0x00, 0x20, 0x54, 0x54, 0x78, 0x40, 0x00, 0x7F, 0x28, 0x44, 0x44, 0x38, 0x00, 0x38, 0x44, 0x44, 0x44, 0x28, 0x00,
+ 0x38, 0x44, 0x44, 0x28, 0x7F, 0x00, 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, 0x00, 0x08, 0x7E, 0x09, 0x02, 0x00, 0x18, 0xA4, 0xA4, 0x9C, 0x78, 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00, 0x00, 0x20, 0x40, 0x40, 0x3D, 0x00, 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00, 0x00, 0x7C, 0x04, 0x78, 0x04, 0x78, 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78, 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, 0xFC, 0x18, 0x24, 0x24, 0x18, 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC, 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08, 0x00, 0x48, 0x54, 0x54, 0x54, 0x24, 0x00, 0x04, 0x04, 0x3F, 0x44, 0x24, 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, 0x4C, 0x90, 0x90, 0x90, 0x7C, 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00,
+ 0x00, 0x41, 0x36, 0x08, 0x00, 0x00, 0x02, 0x01, 0x02, 0x04, 0x02, 0x00, 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0xF0, 0xF8, 0xF8, 0xFF, 0x38, 0xFF, 0xF8, 0xF8, 0x3F, 0xF8, 0xF8, 0xFF, 0x38, 0xFF, 0xF8, 0xF8, 0xF0, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0xC0, 0x80, 0x00, 0x00, 0xC0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0xC0, 0xC0, 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, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xF8, 0xFC, 0x3E,
+ 0x1E, 0x06, 0x01, 0x00, 0x00, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0x7E, 0x5B, 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, 0x00, 0x00, 0x49, 0x49, 0x49, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0xDF, 0xBF, 0xBF, 0x00, 0xBF, 0xBF, 0xDF, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0x49, 0x49, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x3F, 0x60, 0x60, 0xE0, 0xBF, 0x1F, 0x00, 0x7F, 0x7F, 0x07, 0x1E, 0x38, 0x1E, 0x07, 0x7F, 0x7F, 0x00, 0x7F, 0x7F, 0x0E, 0x1F, 0x3B, 0x71, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x0C, 0x0C, 0x0C, 0x00, 0x7E, 0x7E, 0x00, 0x7F, 0x7E, 0x03, 0x03, 0x00, 0x7F, 0x7E, 0x03, 0x03, 0x7E, 0x7E, 0x03, 0x03, 0x7F, 0x7E, 0x00, 0x0F,
+ 0x3E, 0x70, 0x3C, 0x06, 0x3C, 0x70, 0x3E, 0x0F, 0x00, 0x32, 0x7B, 0x49, 0x49, 0x3F, 0x7E, 0x00, 0x7F, 0x7E, 0x03, 0x03, 0x00, 0x1E, 0x3F, 0x69, 0x69, 0x6F, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x1F, 0x3F, 0x3C, 0x78, 0x70, 0x60, 0x00, 0x00, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x7F, 0x41, 0x41, 0x41, 0x7F, 0x00, 0x30, 0x7B, 0x7F, 0x78, 0x30, 0x20, 0x20, 0x30, 0x78, 0x7F, 0x3B, 0x00, 0x03, 0x00, 0x0F, 0x7F, 0x0F, 0x0F, 0x0F, 0x7F, 0x0F, 0x00, 0x03, 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, 0x01, 0x01, 0x01, 0x07, 0x0F, 0x0F, 0x7F, 0x0F, 0x7F, 0x0F, 0x0F, 0x7E, 0x0F, 0x0F, 0x7F, 0x0F, 0x7F, 0x0F, 0x0F, 0x07, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 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, 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, 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,
};
diff --git a/drivers/oled/oled_driver.c b/drivers/oled/oled_driver.c
index d274a9d120..1a1b7299bb 100644
--- a/drivers/oled/oled_driver.c
+++ b/drivers/oled/oled_driver.c
@@ -23,64 +23,64 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <string.h>
#if defined(__AVR__)
- #include <avr/io.h>
- #include <avr/pgmspace.h>
+# include <avr/io.h>
+# include <avr/pgmspace.h>
#elif defined(ESP8266)
- #include <pgmspace.h>
-#else // defined(ESP8266)
- #define PROGMEM
- #define memcpy_P(des, src, len) memcpy(des, src, len)
-#endif // defined(__AVR__)
+# include <pgmspace.h>
+#else // defined(ESP8266)
+# define PROGMEM
+# define memcpy_P(des, src, len) memcpy(des, src, len)
+#endif // defined(__AVR__)
// Used commands from spec sheet: https://cdn-shop.adafruit.com/datasheets/SSD1306.pdf
// for SH1106: https://www.velleman.eu/downloads/29/infosheets/sh1106_datasheet.pdf
// Fundamental Commands
-#define CONTRAST 0x81
-#define DISPLAY_ALL_ON 0xA5
-#define DISPLAY_ALL_ON_RESUME 0xA4
-#define NORMAL_DISPLAY 0xA6
-#define DISPLAY_ON 0xAF
-#define DISPLAY_OFF 0xAE
-#define NOP 0xE3
+#define CONTRAST 0x81
+#define DISPLAY_ALL_ON 0xA5
+#define DISPLAY_ALL_ON_RESUME 0xA4
+#define NORMAL_DISPLAY 0xA6
+#define DISPLAY_ON 0xAF
+#define DISPLAY_OFF 0xAE
+#define NOP 0xE3
// Scrolling Commands
-#define ACTIVATE_SCROLL 0x2F
-#define DEACTIVATE_SCROLL 0x2E
-#define SCROLL_RIGHT 0x26
-#define SCROLL_LEFT 0x27
-#define SCROLL_RIGHT_UP 0x29
-#define SCROLL_LEFT_UP 0x2A
+#define ACTIVATE_SCROLL 0x2F
+#define DEACTIVATE_SCROLL 0x2E
+#define SCROLL_RIGHT 0x26
+#define SCROLL_LEFT 0x27
+#define SCROLL_RIGHT_UP 0x29
+#define SCROLL_LEFT_UP 0x2A
// Addressing Setting Commands
-#define MEMORY_MODE 0x20
-#define COLUMN_ADDR 0x21
-#define PAGE_ADDR 0x22
-#define PAM_SETCOLUMN_LSB 0x00
-#define PAM_SETCOLUMN_MSB 0x10
-#define PAM_PAGE_ADDR 0xB0 // 0xb0 -- 0xb7
+#define MEMORY_MODE 0x20
+#define COLUMN_ADDR 0x21
+#define PAGE_ADDR 0x22
+#define PAM_SETCOLUMN_LSB 0x00
+#define PAM_SETCOLUMN_MSB 0x10
+#define PAM_PAGE_ADDR 0xB0 // 0xb0 -- 0xb7
// Hardware Configuration Commands
-#define DISPLAY_START_LINE 0x40
-#define SEGMENT_REMAP 0xA0
-#define SEGMENT_REMAP_INV 0xA1
-#define MULTIPLEX_RATIO 0xA8
-#define COM_SCAN_INC 0xC0
-#define COM_SCAN_DEC 0xC8
-#define DISPLAY_OFFSET 0xD3
-#define COM_PINS 0xDA
-#define COM_PINS_SEQ 0x02
-#define COM_PINS_ALT 0x12
-#define COM_PINS_SEQ_LR 0x22
-#define COM_PINS_ALT_LR 0x32
+#define DISPLAY_START_LINE 0x40
+#define SEGMENT_REMAP 0xA0
+#define SEGMENT_REMAP_INV 0xA1
+#define MULTIPLEX_RATIO 0xA8
+#define COM_SCAN_INC 0xC0
+#define COM_SCAN_DEC 0xC8
+#define DISPLAY_OFFSET 0xD3
+#define COM_PINS 0xDA
+#define COM_PINS_SEQ 0x02
+#define COM_PINS_ALT 0x12
+#define COM_PINS_SEQ_LR 0x22
+#define COM_PINS_ALT_LR 0x32
// Timing & Driving Commands
-#define DISPLAY_CLOCK 0xD5
-#define PRE_CHARGE_PERIOD 0xD9
-#define VCOM_DETECT 0xDB
+#define DISPLAY_CLOCK 0xD5
+#define PRE_CHARGE_PERIOD 0xD9
+#define VCOM_DETECT 0xDB
// Charge Pump Commands
-#define CHARGE_PUMP 0x8D
+#define CHARGE_PUMP 0x8D
// Misc defines
#define OLED_TIMEOUT 60000
@@ -91,12 +91,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define I2C_CMD 0x00
#define I2C_DATA 0x40
#if defined(__AVR__)
- // already defined on ARM
- #define I2C_TIMEOUT 100
- #define I2C_TRANSMIT_P(data) i2c_transmit_P((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), I2C_TIMEOUT)
-#else // defined(__AVR__)
- #define I2C_TRANSMIT_P(data) i2c_transmit((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), I2C_TIMEOUT)
-#endif // defined(__AVR__)
+// already defined on ARM
+# define I2C_TIMEOUT 100
+# define I2C_TRANSMIT_P(data) i2c_transmit_P((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), I2C_TIMEOUT)
+#else // defined(__AVR__)
+# define I2C_TRANSMIT_P(data) i2c_transmit((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), I2C_TIMEOUT)
+#endif // defined(__AVR__)
#define I2C_TRANSMIT(data) i2c_transmit((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), I2C_TIMEOUT)
#define I2C_WRITE_REG(mode, data, size) i2c_writeReg((OLED_DISPLAY_ADDRESS << 1), mode, data, size, I2C_TIMEOUT)
@@ -106,19 +106,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// this is so we don't end up with rounding errors with
// parts of the display unusable or don't get cleared correctly
// and also allows for drawing & inverting
-uint8_t oled_buffer[OLED_MATRIX_SIZE];
-uint8_t* oled_cursor;
-OLED_BLOCK_TYPE oled_dirty = 0;
-bool oled_initialized = false;
-bool oled_active = false;
-bool oled_scrolling = false;
-uint8_t oled_rotation = 0;
-uint8_t oled_rotation_width = 0;
+uint8_t oled_buffer[OLED_MATRIX_SIZE];
+uint8_t * oled_cursor;
+OLED_BLOCK_TYPE oled_dirty = 0;
+bool oled_initialized = false;
+bool oled_active = false;
+bool oled_scrolling = false;
+uint8_t oled_rotation = 0;
+uint8_t oled_rotation_width = 0;
#if OLED_TIMEOUT > 0
- uint32_t oled_timeout;
+uint32_t oled_timeout;
#endif
#if OLED_SCROLL_TIMEOUT > 0
- uint32_t oled_scroll_timeout;
+uint32_t oled_scroll_timeout;
#endif
// Internal variables to reduce math instructions
@@ -126,465 +126,445 @@ uint8_t oled_rotation_width = 0;
#if defined(__AVR__)
// identical to i2c_transmit, but for PROGMEM since all initialization is in PROGMEM arrays currently
// probably should move this into i2c_master...
-static i2c_status_t i2c_transmit_P(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout) {
- i2c_status_t status = i2c_start(address | I2C_WRITE, timeout);
+static i2c_status_t i2c_transmit_P(uint8_t address, const uint8_t *data, uint16_t length, uint16_t timeout) {
+ i2c_status_t status = i2c_start(address | I2C_WRITE, timeout);
- for (uint16_t i = 0; i < length && status >= 0; i++) {
- status = i2c_write(pgm_read_byte((const char*)data++), timeout);
- if (status) break;
- }
+ for (uint16_t i = 0; i < length && status >= 0; i++) {
+ status = i2c_write(pgm_read_byte((const char *)data++), timeout);
+ if (status) break;
+ }
- i2c_stop();
+ i2c_stop();
- return status;
+ return status;
}
#endif
// Flips the rendering bits for a character at the current cursor position
-static void InvertCharacter(uint8_t *cursor)
-{
- const uint8_t *end = cursor + OLED_FONT_WIDTH;
- while (cursor < end) {
- *cursor = ~(*cursor);
- cursor++;
- }
+static void InvertCharacter(uint8_t *cursor) {
+ const uint8_t *end = cursor + OLED_FONT_WIDTH;
+ while (cursor < end) {
+ *cursor = ~(*cursor);
+ cursor++;
+ }
}
bool oled_init(uint8_t rotation) {
- oled_rotation = oled_init_user(rotation);
- if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) {
- oled_rotation_width = OLED_DISPLAY_WIDTH;
- } else {
- oled_rotation_width = OLED_DISPLAY_HEIGHT;
- }
- i2c_init();
-
- static const uint8_t PROGMEM display_setup1[] = {
- I2C_CMD,
- DISPLAY_OFF,
- DISPLAY_CLOCK, 0x80,
- MULTIPLEX_RATIO, OLED_DISPLAY_HEIGHT - 1,
- DISPLAY_OFFSET, 0x00,
- DISPLAY_START_LINE | 0x00,
- CHARGE_PUMP, 0x14,
+ oled_rotation = oled_init_user(rotation);
+ if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) {
+ oled_rotation_width = OLED_DISPLAY_WIDTH;
+ } else {
+ oled_rotation_width = OLED_DISPLAY_HEIGHT;
+ }
+ i2c_init();
+
+ static const uint8_t PROGMEM display_setup1[] = {
+ I2C_CMD,
+ DISPLAY_OFF,
+ DISPLAY_CLOCK,
+ 0x80,
+ MULTIPLEX_RATIO,
+ OLED_DISPLAY_HEIGHT - 1,
+ DISPLAY_OFFSET,
+ 0x00,
+ DISPLAY_START_LINE | 0x00,
+ CHARGE_PUMP,
+ 0x14,
#if (OLED_IC != OLED_IC_SH1106)
- // MEMORY_MODE is unsupported on SH1106 (Page Addressing only)
- MEMORY_MODE, 0x00, // Horizontal addressing mode
+ // MEMORY_MODE is unsupported on SH1106 (Page Addressing only)
+ MEMORY_MODE,
+ 0x00, // Horizontal addressing mode
#endif
- };
- if (I2C_TRANSMIT_P(display_setup1) != I2C_STATUS_SUCCESS) {
- print("oled_init cmd set 1 failed\n");
- return false;
- }
-
- if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_180)) {
- static const uint8_t PROGMEM display_normal[] = {
- I2C_CMD,
- SEGMENT_REMAP_INV,
- COM_SCAN_DEC };
- if (I2C_TRANSMIT_P(display_normal) != I2C_STATUS_SUCCESS) {
- print("oled_init cmd normal rotation failed\n");
- return false;
- }
- } else {
- static const uint8_t PROGMEM display_flipped[] = {
- I2C_CMD,
- SEGMENT_REMAP,
- COM_SCAN_INC };
- if (I2C_TRANSMIT_P(display_flipped) != I2C_STATUS_SUCCESS) {
- print("display_flipped failed\n");
- return false;
- }
- }
-
- static const uint8_t PROGMEM display_setup2[] = {
- I2C_CMD,
- COM_PINS, OLED_COM_PINS,
- CONTRAST, 0x8F,
- PRE_CHARGE_PERIOD, 0xF1,
- VCOM_DETECT, 0x40,
- DISPLAY_ALL_ON_RESUME,
- NORMAL_DISPLAY,
- DEACTIVATE_SCROLL,
- DISPLAY_ON };
- if (I2C_TRANSMIT_P(display_setup2) != I2C_STATUS_SUCCESS) {
- print("display_setup2 failed\n");
- return false;
- }
+ };
+ if (I2C_TRANSMIT_P(display_setup1) != I2C_STATUS_SUCCESS) {
+ print("oled_init cmd set 1 failed\n");
+ return false;
+ }
+
+ if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_180)) {
+ static const uint8_t PROGMEM display_normal[] = {I2C_CMD, SEGMENT_REMAP_INV, COM_SCAN_DEC};
+ if (I2C_TRANSMIT_P(display_normal) != I2C_STATUS_SUCCESS) {
+ print("oled_init cmd normal rotation failed\n");
+ return false;
+ }
+ } else {
+ static const uint8_t PROGMEM display_flipped[] = {I2C_CMD, SEGMENT_REMAP, COM_SCAN_INC};
+ if (I2C_TRANSMIT_P(display_flipped) != I2C_STATUS_SUCCESS) {
+ print("display_flipped failed\n");
+ return false;
+ }
+ }
+
+ static const uint8_t PROGMEM display_setup2[] = {I2C_CMD, COM_PINS, OLED_COM_PINS, CONTRAST, 0x8F, PRE_CHARGE_PERIOD, 0xF1, VCOM_DETECT, 0x40, DISPLAY_ALL_ON_RESUME, NORMAL_DISPLAY, DEACTIVATE_SCROLL, DISPLAY_ON};
+ if (I2C_TRANSMIT_P(display_setup2) != I2C_STATUS_SUCCESS) {
+ print("display_setup2 failed\n");
+ return false;
+ }
#if OLED_TIMEOUT > 0
- oled_timeout = timer_read32() + OLED_TIMEOUT;
+ oled_timeout = timer_read32() + OLED_TIMEOUT;
#endif
#if OLED_SCROLL_TIMEOUT > 0
- oled_scroll_timeout = timer_read32() + OLED_SCROLL_TIMEOUT;
+ oled_scroll_timeout = timer_read32() + OLED_SCROLL_TIMEOUT;
#endif
- oled_clear();
- oled_initialized = true;
- oled_active = true;
- oled_scrolling = false;
- return true;
+ oled_clear();
+ oled_initialized = true;
+ oled_active = true;
+ oled_scrolling = false;
+ return true;
}
-__attribute__((weak))
-uint8_t oled_init_user(uint8_t rotation) {
- return rotation;
-}
+__attribute__((weak)) oled_rotation_t oled_init_user(oled_rotation_t rotation) { return rotation; }
void oled_clear(void) {
- memset(oled_buffer, 0, sizeof(oled_buffer));
- oled_cursor = &oled_buffer[0];
- oled_dirty = -1; // -1 will be max value as long as display_dirty is unsigned type
+ memset(oled_buffer, 0, sizeof(oled_buffer));
+ oled_cursor = &oled_buffer[0];
+ oled_dirty = -1; // -1 will be max value as long as display_dirty is unsigned type
}
-static void calc_bounds(uint8_t update_start, uint8_t* cmd_array)
-{
- // Calculate commands to set memory addressing bounds.
- uint8_t start_page = OLED_BLOCK_SIZE * update_start / OLED_DISPLAY_WIDTH;
- uint8_t start_column = OLED_BLOCK_SIZE * update_start % OLED_DISPLAY_WIDTH;
+static void calc_bounds(uint8_t update_start, uint8_t *cmd_array) {
+ // Calculate commands to set memory addressing bounds.
+ uint8_t start_page = OLED_BLOCK_SIZE * update_start / OLED_DISPLAY_WIDTH;
+ uint8_t start_column = OLED_BLOCK_SIZE * update_start % OLED_DISPLAY_WIDTH;
#if (OLED_IC == OLED_IC_SH1106)
- // Commands for Page Addressing Mode. Sets starting page and column; has no end bound.
- // Column value must be split into high and low nybble and sent as two commands.
- cmd_array[0] = PAM_PAGE_ADDR | start_page;
- cmd_array[1] = PAM_SETCOLUMN_LSB | ((OLED_COLUMN_OFFSET + start_column) & 0x0f);
- cmd_array[2] = PAM_SETCOLUMN_MSB | ((OLED_COLUMN_OFFSET + start_column) >> 4 & 0x0f);
- cmd_array[3] = NOP;
- cmd_array[4] = NOP;
- cmd_array[5] = NOP;
+ // Commands for Page Addressing Mode. Sets starting page and column; has no end bound.
+ // Column value must be split into high and low nybble and sent as two commands.
+ cmd_array[0] = PAM_PAGE_ADDR | start_page;
+ cmd_array[1] = PAM_SETCOLUMN_LSB | ((OLED_COLUMN_OFFSET + start_column) & 0x0f);
+ cmd_array[2] = PAM_SETCOLUMN_MSB | ((OLED_COLUMN_OFFSET + start_column) >> 4 & 0x0f);
+ cmd_array[3] = NOP;
+ cmd_array[4] = NOP;
+ cmd_array[5] = NOP;
#else
- // Commands for use in Horizontal Addressing mode.
- cmd_array[1] = start_column;
- cmd_array[4] = start_page;
- cmd_array[2] = (OLED_BLOCK_SIZE + OLED_DISPLAY_WIDTH - 1) % OLED_DISPLAY_WIDTH + cmd_array[1];
- cmd_array[5] = (OLED_BLOCK_SIZE + OLED_DISPLAY_WIDTH - 1) / OLED_DISPLAY_WIDTH - 1;
+ // Commands for use in Horizontal Addressing mode.
+ cmd_array[1] = start_column;
+ cmd_array[4] = start_page;
+ cmd_array[2] = (OLED_BLOCK_SIZE + OLED_DISPLAY_WIDTH - 1) % OLED_DISPLAY_WIDTH + cmd_array[1];
+ cmd_array[5] = (OLED_BLOCK_SIZE + OLED_DISPLAY_WIDTH - 1) / OLED_DISPLAY_WIDTH - 1;
#endif
}
-static void calc_bounds_90(uint8_t update_start, uint8_t* cmd_array)
-{
- cmd_array[1] = OLED_BLOCK_SIZE * update_start / OLED_DISPLAY_HEIGHT * 8;
- cmd_array[4] = OLED_BLOCK_SIZE * update_start % OLED_DISPLAY_HEIGHT;
- cmd_array[2] = (OLED_BLOCK_SIZE + OLED_DISPLAY_HEIGHT - 1) / OLED_DISPLAY_HEIGHT * 8 - 1 + cmd_array[1];;
- cmd_array[5] = (OLED_BLOCK_SIZE + OLED_DISPLAY_HEIGHT - 1) % OLED_DISPLAY_HEIGHT / 8;
+static void calc_bounds_90(uint8_t update_start, uint8_t *cmd_array) {
+ cmd_array[1] = OLED_BLOCK_SIZE * update_start / OLED_DISPLAY_HEIGHT * 8;
+ cmd_array[4] = OLED_BLOCK_SIZE * update_start % OLED_DISPLAY_HEIGHT;
+ cmd_array[2] = (OLED_BLOCK_SIZE + OLED_DISPLAY_HEIGHT - 1) / OLED_DISPLAY_HEIGHT * 8 - 1 + cmd_array[1];
+ ;
+ cmd_array[5] = (OLED_BLOCK_SIZE + OLED_DISPLAY_HEIGHT - 1) % OLED_DISPLAY_HEIGHT / 8;
}
-uint8_t crot(uint8_t a, int8_t n)
-{
- const uint8_t mask = 0x7;
- n &= mask;
- return a << n | a >> (-n & mask);
+uint8_t crot(uint8_t a, int8_t n) {
+ const uint8_t mask = 0x7;
+ n &= mask;
+ return a << n | a >> (-n & mask);
}
-static void rotate_90(const uint8_t* src, uint8_t* dest)
-{
- for (uint8_t i = 0, shift = 7; i < 8; ++i, --shift) {
- uint8_t selector = (1 << i);
- for (uint8_t j = 0; j < 8; ++j) {
- dest[i] |= crot(src[j] & selector, shift - (int8_t)j);
+static void rotate_90(const uint8_t *src, uint8_t *dest) {
+ for (uint8_t i = 0, shift = 7; i < 8; ++i, --shift) {
+ uint8_t selector = (1 << i);
+ for (uint8_t j = 0; j < 8; ++j) {
+ dest[i] |= crot(src[j] & selector, shift - (int8_t)j);
+ }
}
- }
}
void oled_render(void) {
- // Do we have work to do?
- if (!oled_dirty || oled_scrolling) {
- return;
- }
-
- // Find first dirty block
- uint8_t update_start = 0;
- while (!(oled_dirty & (1 << update_start))) { ++update_start; }
-
- // Set column & page position
- static uint8_t display_start[] = {
- I2C_CMD,
- COLUMN_ADDR, 0, OLED_DISPLAY_WIDTH - 1,
- PAGE_ADDR, 0, OLED_DISPLAY_HEIGHT / 8 - 1 };
- if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) {
- calc_bounds(update_start, &display_start[1]); // Offset from I2C_CMD byte at the start
- } else {
- calc_bounds_90(update_start, &display_start[1]); // Offset from I2C_CMD byte at the start
- }
-
- // Send column & page position
- if (I2C_TRANSMIT(display_start) != I2C_STATUS_SUCCESS) {
- print("oled_render offset command failed\n");
- return;
- }
-
- if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) {
- // Send render data chunk as is
- if (I2C_WRITE_REG(I2C_DATA, &oled_buffer[OLED_BLOCK_SIZE * update_start], OLED_BLOCK_SIZE) != I2C_STATUS_SUCCESS) {
- print("oled_render data failed\n");
- return;
- }
- } else {
- // Rotate the render chunks
- const static uint8_t source_map[] = OLED_SOURCE_MAP;
- const static uint8_t target_map[] = OLED_TARGET_MAP;
-
- static uint8_t temp_buffer[OLED_BLOCK_SIZE];
- memset(temp_buffer, 0, sizeof(temp_buffer));
- for(uint8_t i = 0; i < sizeof(source_map); ++i) {
- rotate_90(&oled_buffer[OLED_BLOCK_SIZE * update_start + source_map[i]], &temp_buffer[target_map[i]]);
- }
-
- // Send render data chunk after rotating
- if (I2C_WRITE_REG(I2C_DATA, &temp_buffer[0], OLED_BLOCK_SIZE) != I2C_STATUS_SUCCESS) {
- print("oled_render90 data failed\n");
- return;
- }
- }
-
- // Turn on display if it is off
- oled_on();
-
- // Clear dirty flag
- oled_dirty &= ~(1 << update_start);
+ // Do we have work to do?
+ if (!oled_dirty || oled_scrolling) {
+ return;
+ }
+
+ // Find first dirty block
+ uint8_t update_start = 0;
+ while (!(oled_dirty & (1 << update_start))) {
+ ++update_start;
+ }
+
+ // Set column & page position
+ static uint8_t display_start[] = {I2C_CMD, COLUMN_ADDR, 0, OLED_DISPLAY_WIDTH - 1, PAGE_ADDR, 0, OLED_DISPLAY_HEIGHT / 8 - 1};
+ if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) {
+ calc_bounds(update_start, &display_start[1]); // Offset from I2C_CMD byte at the start
+ } else {
+ calc_bounds_90(update_start, &display_start[1]); // Offset from I2C_CMD byte at the start
+ }
+
+ // Send column & page position
+ if (I2C_TRANSMIT(display_start) != I2C_STATUS_SUCCESS) {
+ print("oled_render offset command failed\n");
+ return;
+ }
+
+ if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) {
+ // Send render data chunk as is
+ if (I2C_WRITE_REG(I2C_DATA, &oled_buffer[OLED_BLOCK_SIZE * update_start], OLED_BLOCK_SIZE) != I2C_STATUS_SUCCESS) {
+ print("oled_render data failed\n");
+ return;
+ }
+ } else {
+ // Rotate the render chunks
+ const static uint8_t source_map[] = OLED_SOURCE_MAP;
+ const static uint8_t target_map[] = OLED_TARGET_MAP;
+
+ static uint8_t temp_buffer[OLED_BLOCK_SIZE];
+ memset(temp_buffer, 0, sizeof(temp_buffer));
+ for (uint8_t i = 0; i < sizeof(source_map); ++i) {
+ rotate_90(&oled_buffer[OLED_BLOCK_SIZE * update_start + source_map[i]], &temp_buffer[target_map[i]]);
+ }
+
+ // Send render data chunk after rotating
+ if (I2C_WRITE_REG(I2C_DATA, &temp_buffer[0], OLED_BLOCK_SIZE) != I2C_STATUS_SUCCESS) {
+ print("oled_render90 data failed\n");
+ return;
+ }
+ }
+
+ // Turn on display if it is off
+ oled_on();
+
+ // Clear dirty flag
+ oled_dirty &= ~(1 << update_start);
}
void oled_set_cursor(uint8_t col, uint8_t line) {
- uint16_t index = line * oled_rotation_width + col * OLED_FONT_WIDTH;
+ uint16_t index = line * oled_rotation_width + col * OLED_FONT_WIDTH;
- // Out of bounds?
- if (index >= OLED_MATRIX_SIZE) {
- index = 0;
- }
+ // Out of bounds?
+ if (index >= OLED_MATRIX_SIZE) {
+ index = 0;
+ }
- oled_cursor = &oled_buffer[index];
+ oled_cursor = &oled_buffer[index];
}
void oled_advance_page(bool clearPageRemainder) {
- uint16_t index = oled_cursor - &oled_buffer[0];
- uint8_t remaining = oled_rotation_width - (index % oled_rotation_width);
-
- if (clearPageRemainder) {
- // Remaining Char count
- remaining = remaining / OLED_FONT_WIDTH;
-
- // Write empty character until next line
- while (remaining--)
- oled_write_char(' ', false);
- } else {
- // Next page index out of bounds?
- if (index + remaining >= OLED_MATRIX_SIZE) {
- index = 0;
- remaining = 0;
+ uint16_t index = oled_cursor - &oled_buffer[0];
+ uint8_t remaining = oled_rotation_width - (index % oled_rotation_width);
+
+ if (clearPageRemainder) {
+ // Remaining Char count
+ remaining = remaining / OLED_FONT_WIDTH;
+
+ // Write empty character until next line
+ while (remaining--) oled_write_char(' ', false);
+ } else {
+ // Next page index out of bounds?
+ if (index + remaining >= OLED_MATRIX_SIZE) {
+ index = 0;
+ remaining = 0;
+ }
+
+ oled_cursor = &oled_buffer[index + remaining];
}
-
- oled_cursor = &oled_buffer[index + remaining];
- }
}
void oled_advance_char(void) {
- uint16_t nextIndex = oled_cursor - &oled_buffer[0] + OLED_FONT_WIDTH;
- uint8_t remainingSpace = oled_rotation_width - (nextIndex % oled_rotation_width);
+ uint16_t nextIndex = oled_cursor - &oled_buffer[0] + OLED_FONT_WIDTH;
+ uint8_t remainingSpace = oled_rotation_width - (nextIndex % oled_rotation_width);
- // Do we have enough space on the current line for the next character
- if (remainingSpace < OLED_FONT_WIDTH) {
- nextIndex += remainingSpace;
- }
+ // Do we have enough space on the current line for the next character
+ if (remainingSpace < OLED_FONT_WIDTH) {
+ nextIndex += remainingSpace;
+ }
- // Did we go out of bounds
- if (nextIndex >= OLED_MATRIX_SIZE) {
- nextIndex = 0;
- }
+ // Did we go out of bounds
+ if (nextIndex >= OLED_MATRIX_SIZE) {
+ nextIndex = 0;
+ }
- // Update cursor position
- oled_cursor = &oled_buffer[nextIndex];
+ // Update cursor position
+ oled_cursor = &oled_buffer[nextIndex];
}
// Main handler that writes character data to the display buffer
void oled_write_char(const char data, bool invert) {
- // Advance to the next line if newline
- if (data == '\n') {
- // Old source wrote ' ' until end of line...
- oled_advance_page(true);
- return;
- }
-
- if (data == '\r') {
- oled_advance_page(false);
- return;
- }
-
- // copy the current render buffer to check for dirty after
- static uint8_t oled_temp_buffer[OLED_FONT_WIDTH];
- memcpy(&oled_temp_buffer, oled_cursor, OLED_FONT_WIDTH);
-
- // set the reder buffer data
- uint8_t cast_data = (uint8_t)data; // font based on unsigned type for index
- if (cast_data < OLED_FONT_START || cast_data > OLED_FONT_END) {
- memset(oled_cursor, 0x00, OLED_FONT_WIDTH);
- } else {
- const uint8_t *glyph = &font[(cast_data - OLED_FONT_START) * OLED_FONT_WIDTH];
- memcpy_P(oled_cursor, glyph, OLED_FONT_WIDTH);
- }
-
- // Invert if needed
- if (invert) {
- InvertCharacter(oled_cursor);
- }
-
- // Dirty check
- if (memcmp(&oled_temp_buffer, oled_cursor, OLED_FONT_WIDTH)) {
- oled_dirty |= (1 << ((oled_cursor - &oled_buffer[0]) / OLED_BLOCK_SIZE));
- }
-
- // Finally move to the next char
- oled_advance_char();
+ // Advance to the next line if newline
+ if (data == '\n') {
+ // Old source wrote ' ' until end of line...
+ oled_advance_page(true);
+ return;
+ }
+
+ if (data == '\r') {
+ oled_advance_page(false);
+ return;
+ }
+
+ // copy the current render buffer to check for dirty after
+ static uint8_t oled_temp_buffer[OLED_FONT_WIDTH];
+ memcpy(&oled_temp_buffer, oled_cursor, OLED_FONT_WIDTH);
+
+ // set the reder buffer data
+ uint8_t cast_data = (uint8_t)data; // font based on unsigned type for index
+ if (cast_data < OLED_FONT_START || cast_data > OLED_FONT_END) {
+ memset(oled_cursor, 0x00, OLED_FONT_WIDTH);
+ } else {
+ const uint8_t *glyph = &font[(cast_data - OLED_FONT_START) * OLED_FONT_WIDTH];
+ memcpy_P(oled_cursor, glyph, OLED_FONT_WIDTH);
+ }
+
+ // Invert if needed
+ if (invert) {
+ InvertCharacter(oled_cursor);
+ }
+
+ // Dirty check
+ if (memcmp(&oled_temp_buffer, oled_cursor, OLED_FONT_WIDTH)) {
+ uint16_t index = oled_cursor - &oled_buffer[0];
+ oled_dirty |= (1 << (index / OLED_BLOCK_SIZE));
+ // Edgecase check if the written data spans the 2 chunks
+ oled_dirty |= (1 << ((index + OLED_FONT_WIDTH) / OLED_BLOCK_SIZE));
+ }
+
+ // Finally move to the next char
+ oled_advance_char();
}
void oled_write(const char *data, bool invert) {
- const char *end = data + strlen(data);
- while (data < end) {
- oled_write_char(*data, invert);
- data++;
- }
+ const char *end = data + strlen(data);
+ while (data < end) {
+ oled_write_char(*data, invert);
+ data++;
+ }
}
void oled_write_ln(const char *data, bool invert) {
- oled_write(data, invert);
- oled_advance_page(true);
+ oled_write(data, invert);
+ oled_advance_page(true);
}
#if defined(__AVR__)
void oled_write_P(const char *data, bool invert) {
- uint8_t c = pgm_read_byte(data);
- while (c != 0) {
- oled_write_char(c, invert);
- c = pgm_read_byte(++data);
- }
+ uint8_t c = pgm_read_byte(data);
+ while (c != 0) {
+ oled_write_char(c, invert);
+ c = pgm_read_byte(++data);
+ }
}
void oled_write_ln_P(const char *data, bool invert) {
- oled_write_P(data, invert);
- oled_advance_page(true);
+ oled_write_P(data, invert);
+ oled_advance_page(true);
}
-#endif // defined(__AVR__)
+#endif // defined(__AVR__)
bool oled_on(void) {
#if OLED_TIMEOUT > 0
- oled_timeout = timer_read32() + OLED_TIMEOUT;
+ oled_timeout = timer_read32() + OLED_TIMEOUT;
#endif
- static const uint8_t PROGMEM display_on[] = { I2C_CMD, DISPLAY_ON };
- if (!oled_active) {
- if (I2C_TRANSMIT_P(display_on) != I2C_STATUS_SUCCESS) {
- print("oled_on cmd failed\n");
- return oled_active;
+ static const uint8_t PROGMEM display_on[] = {I2C_CMD, DISPLAY_ON};
+ if (!oled_active) {
+ if (I2C_TRANSMIT_P(display_on) != I2C_STATUS_SUCCESS) {
+ print("oled_on cmd failed\n");
+ return oled_active;
+ }
+ oled_active = true;
}
- oled_active = true;
- }
- return oled_active;
+ return oled_active;
}
bool oled_off(void) {
- static const uint8_t PROGMEM display_off[] = { I2C_CMD, DISPLAY_OFF };
- if (oled_active) {
- if (I2C_TRANSMIT_P(display_off) != I2C_STATUS_SUCCESS) {
- print("oled_off cmd failed\n");
- return oled_active;
- }
- oled_active = false;
- }
- return !oled_active;
+ static const uint8_t PROGMEM display_off[] = {I2C_CMD, DISPLAY_OFF};
+ if (oled_active) {
+ if (I2C_TRANSMIT_P(display_off) != I2C_STATUS_SUCCESS) {
+ print("oled_off cmd failed\n");
+ return oled_active;
+ }
+ oled_active = false;
+ }
+ return !oled_active;
}
bool oled_scroll_right(void) {
- // Dont enable scrolling if we need to update the display
- // This prevents scrolling of bad data from starting the scroll too early after init
- if (!oled_dirty && !oled_scrolling) {
- static const uint8_t PROGMEM display_scroll_right[] = {
- I2C_CMD, SCROLL_RIGHT, 0x00, 0x00, 0x00, 0x0F, 0x00, 0xFF, ACTIVATE_SCROLL };
- if (I2C_TRANSMIT_P(display_scroll_right) != I2C_STATUS_SUCCESS) {
- print("oled_scroll_right cmd failed\n");
- return oled_scrolling;
- }
- oled_scrolling = true;
- }
- return oled_scrolling;
+ // Dont enable scrolling if we need to update the display
+ // This prevents scrolling of bad data from starting the scroll too early after init
+ if (!oled_dirty && !oled_scrolling) {
+ static const uint8_t PROGMEM display_scroll_right[] = {I2C_CMD, SCROLL_RIGHT, 0x00, 0x00, 0x00, 0x0F, 0x00, 0xFF, ACTIVATE_SCROLL};
+ if (I2C_TRANSMIT_P(display_scroll_right) != I2C_STATUS_SUCCESS) {
+ print("oled_scroll_right cmd failed\n");
+ return oled_scrolling;
+ }
+ oled_scrolling = true;
+ }
+ return oled_scrolling;
}
bool oled_scroll_left(void) {
- // Dont enable scrolling if we need to update the display
- // This prevents scrolling of bad data from starting the scroll too early after init
- if (!oled_dirty && !oled_scrolling) {
- static const uint8_t PROGMEM display_scroll_left[] = {
- I2C_CMD, SCROLL_LEFT, 0x00, 0x00, 0x00, 0x0F, 0x00, 0xFF, ACTIVATE_SCROLL };
- if (I2C_TRANSMIT_P(display_scroll_left) != I2C_STATUS_SUCCESS) {
- print("oled_scroll_left cmd failed\n");
- return oled_scrolling;
- }
- oled_scrolling = true;
- }
- return oled_scrolling;
+ // Dont enable scrolling if we need to update the display
+ // This prevents scrolling of bad data from starting the scroll too early after init
+ if (!oled_dirty && !oled_scrolling) {
+ static const uint8_t PROGMEM display_scroll_left[] = {I2C_CMD, SCROLL_LEFT, 0x00, 0x00, 0x00, 0x0F, 0x00, 0xFF, ACTIVATE_SCROLL};
+ if (I2C_TRANSMIT_P(display_scroll_left) != I2C_STATUS_SUCCESS) {
+ print("oled_scroll_left cmd failed\n");
+ return oled_scrolling;
+ }
+ oled_scrolling = true;
+ }
+ return oled_scrolling;
}
bool oled_scroll_off(void) {
- if (oled_scrolling) {
- static const uint8_t PROGMEM display_scroll_off[] = { I2C_CMD, DEACTIVATE_SCROLL };
- if (I2C_TRANSMIT_P(display_scroll_off) != I2C_STATUS_SUCCESS) {
- print("oled_scroll_off cmd failed\n");
- return oled_scrolling;
- }
- oled_scrolling = false;
- oled_dirty = -1;
- }
- return !oled_scrolling;
+ if (oled_scrolling) {
+ static const uint8_t PROGMEM display_scroll_off[] = {I2C_CMD, DEACTIVATE_SCROLL};
+ if (I2C_TRANSMIT_P(display_scroll_off) != I2C_STATUS_SUCCESS) {
+ print("oled_scroll_off cmd failed\n");
+ return oled_scrolling;
+ }
+ oled_scrolling = false;
+ oled_dirty = -1;
+ }
+ return !oled_scrolling;
}
uint8_t oled_max_chars(void) {
- if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) {
- return OLED_DISPLAY_WIDTH / OLED_FONT_WIDTH;
- }
- return OLED_DISPLAY_HEIGHT / OLED_FONT_WIDTH;
+ if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) {
+ return OLED_DISPLAY_WIDTH / OLED_FONT_WIDTH;
+ }
+ return OLED_DISPLAY_HEIGHT / OLED_FONT_WIDTH;
}
uint8_t oled_max_lines(void) {
- if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) {
- return OLED_DISPLAY_HEIGHT / OLED_FONT_HEIGHT;
- }
- return OLED_DISPLAY_WIDTH / OLED_FONT_HEIGHT;
+ if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) {
+ return OLED_DISPLAY_HEIGHT / OLED_FONT_HEIGHT;
+ }
+ return OLED_DISPLAY_WIDTH / OLED_FONT_HEIGHT;
}
void oled_task(void) {
- if (!oled_initialized) {
- return;
- }
+ if (!oled_initialized) {
+ return;
+ }
- oled_set_cursor(0, 0);
+ oled_set_cursor(0, 0);
- oled_task_user();
+ oled_task_user();
#if OLED_SCROLL_TIMEOUT > 0
- if (oled_dirty && oled_scrolling) {
- oled_scroll_timeout = timer_read32() + OLED_SCROLL_TIMEOUT;
- oled_scroll_off();
- }
+ if (oled_dirty && oled_scrolling) {
+ oled_scroll_timeout = timer_read32() + OLED_SCROLL_TIMEOUT;
+ oled_scroll_off();
+ }
#endif
- // Smart render system, no need to check for dirty
- oled_render();
+ // Smart render system, no need to check for dirty
+ oled_render();
- // Display timeout check
+ // Display timeout check
#if OLED_TIMEOUT > 0
- if (oled_active && timer_expired32(timer_read32(), oled_timeout)) {
- oled_off();
- }
+ if (oled_active && timer_expired32(timer_read32(), oled_timeout)) {
+ oled_off();
+ }
#endif
#if OLED_SCROLL_TIMEOUT > 0
- if (!oled_scrolling && timer_expired32(timer_read32(), oled_scroll_timeout)) {
-#ifdef OLED_SCROLL_TIMEOUT_RIGHT
- oled_scroll_right();
-#else
- oled_scroll_left();
-#endif
- }
+ if (!oled_scrolling && timer_expired32(timer_read32(), oled_scroll_timeout)) {
+# ifdef OLED_SCROLL_TIMEOUT_RIGHT
+ oled_scroll_right();
+# else
+ oled_scroll_left();
+# endif
+ }
#endif
}
-__attribute__((weak))
-void oled_task_user(void) {
-}
+__attribute__((weak)) void oled_task_user(void) {}
diff --git a/drivers/oled/oled_driver.h b/drivers/oled/oled_driver.h
index 9c6384edce..218af0b988 100644
--- a/drivers/oled/oled_driver.h
+++ b/drivers/oled/oled_driver.h
@@ -21,129 +21,133 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// an enumeration of the chips this driver supports
#define OLED_IC_SSD1306 0
-#define OLED_IC_SH1106 1
+#define OLED_IC_SH1106 1
#if defined(OLED_DISPLAY_CUSTOM)
- // Expected user to implement the necessary defines
+// Expected user to implement the necessary defines
#elif defined(OLED_DISPLAY_128X64)
- // Double height 128x64
-#ifndef OLED_DISPLAY_WIDTH
- #define OLED_DISPLAY_WIDTH 128
-#endif
-#ifndef OLED_DISPLAY_HEIGHT
- #define OLED_DISPLAY_HEIGHT 64
-#endif
-#ifndef OLED_MATRIX_SIZE
- #define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 1024 (compile time mathed)
-#endif
-#ifndef OLED_BLOCK_TYPE
- #define OLED_BLOCK_TYPE uint16_t
-#endif
-#ifndef OLED_BLOCK_COUNT
- #define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 32 (compile time mathed)
-#endif
-#ifndef OLED_BLOCK_SIZE
- #define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed)
-#endif
-#ifndef OLED_COM_PINS
- #define OLED_COM_PINS COM_PINS_ALT
-#endif
-
- // For 90 degree rotation, we map our internal matrix to oled matrix using fixed arrays
- // The OLED writes to it's memory horizontally, starting top left, but our memory starts bottom left in this mode
-#ifndef OLED_SOURCE_MAP
- #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 }
-#endif
-#ifndef OLED_TARGET_MAP
- #define OLED_TARGET_MAP { 56, 48, 40, 32, 24, 16, 8, 0 }
-#endif
- // If OLED_BLOCK_TYPE is uint32_t, these tables would look like:
- // #define OLED_SOURCE_MAP { 32, 40, 48, 56 }
- // #define OLED_TARGET_MAP { 24, 16, 8, 0 }
- // If OLED_BLOCK_TYPE is uint16_t, these tables would look like:
- // #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 }
- // #define OLED_TARGET_MAP { 56, 48, 40, 32, 24, 16, 8, 0 }
- // If OLED_BLOCK_TYPE is uint8_t, these tables would look like:
- // #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120 }
- // #define OLED_TARGET_MAP { 56, 120, 48, 112, 40, 104, 32, 96, 24, 88, 16, 80, 8, 72, 0, 64 }
-#else // defined(OLED_DISPLAY_128X64)
- // Default 128x32
-#ifndef OLED_DISPLAY_WIDTH
- #define OLED_DISPLAY_WIDTH 128
-#endif
-#ifndef OLED_DISPLAY_HEIGHT
- #define OLED_DISPLAY_HEIGHT 32
-#endif
-#ifndef OLED_MATRIX_SIZE
- #define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 512 (compile time mathed)
-#endif
-#ifndef OLED_BLOCK_TYPE
- #define OLED_BLOCK_TYPE uint16_t // Type to use for segmenting the oled display for smart rendering, use unsigned types only
-#endif
-#ifndef OLED_BLOCK_COUNT
- #define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 16 (compile time mathed)
-#endif
-#ifndef OLED_BLOCK_SIZE
- #define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed)
-#endif
-#ifndef OLED_COM_PINS
- #define OLED_COM_PINS COM_PINS_SEQ
-#endif
-
- // For 90 degree rotation, we map our internal matrix to oled matrix using fixed arrays
- // The OLED writes to it's memory horizontally, starting top left, but our memory starts bottom left in this mode
-#ifndef OLED_SOURCE_MAP
- #define OLED_SOURCE_MAP { 0, 8, 16, 24 }
-#endif
-#ifndef OLED_TARGET_MAP
- #define OLED_TARGET_MAP { 24, 16, 8, 0 }
-#endif
- // If OLED_BLOCK_TYPE is uint8_t, these tables would look like:
- // #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 }
- // #define OLED_TARGET_MAP { 48, 32, 16, 0, 56, 40, 24, 8 }
-#endif // defined(OLED_DISPLAY_CUSTOM)
+// Double height 128x64
+# ifndef OLED_DISPLAY_WIDTH
+# define OLED_DISPLAY_WIDTH 128
+# endif
+# ifndef OLED_DISPLAY_HEIGHT
+# define OLED_DISPLAY_HEIGHT 64
+# endif
+# ifndef OLED_MATRIX_SIZE
+# define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 1024 (compile time mathed)
+# endif
+# ifndef OLED_BLOCK_TYPE
+# define OLED_BLOCK_TYPE uint16_t
+# endif
+# ifndef OLED_BLOCK_COUNT
+# define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 32 (compile time mathed)
+# endif
+# ifndef OLED_BLOCK_SIZE
+# define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed)
+# endif
+# ifndef OLED_COM_PINS
+# define OLED_COM_PINS COM_PINS_ALT
+# endif
+
+// For 90 degree rotation, we map our internal matrix to oled matrix using fixed arrays
+// The OLED writes to it's memory horizontally, starting top left, but our memory starts bottom left in this mode
+# ifndef OLED_SOURCE_MAP
+# define OLED_SOURCE_MAP \
+ { 0, 8, 16, 24, 32, 40, 48, 56 }
+# endif
+# ifndef OLED_TARGET_MAP
+# define OLED_TARGET_MAP \
+ { 56, 48, 40, 32, 24, 16, 8, 0 }
+# endif
+// If OLED_BLOCK_TYPE is uint32_t, these tables would look like:
+// #define OLED_SOURCE_MAP { 32, 40, 48, 56 }
+// #define OLED_TARGET_MAP { 24, 16, 8, 0 }
+// If OLED_BLOCK_TYPE is uint16_t, these tables would look like:
+// #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 }
+// #define OLED_TARGET_MAP { 56, 48, 40, 32, 24, 16, 8, 0 }
+// If OLED_BLOCK_TYPE is uint8_t, these tables would look like:
+// #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120 }
+// #define OLED_TARGET_MAP { 56, 120, 48, 112, 40, 104, 32, 96, 24, 88, 16, 80, 8, 72, 0, 64 }
+#else // defined(OLED_DISPLAY_128X64)
+// Default 128x32
+# ifndef OLED_DISPLAY_WIDTH
+# define OLED_DISPLAY_WIDTH 128
+# endif
+# ifndef OLED_DISPLAY_HEIGHT
+# define OLED_DISPLAY_HEIGHT 32
+# endif
+# ifndef OLED_MATRIX_SIZE
+# define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 512 (compile time mathed)
+# endif
+# ifndef OLED_BLOCK_TYPE
+# define OLED_BLOCK_TYPE uint16_t // Type to use for segmenting the oled display for smart rendering, use unsigned types only
+# endif
+# ifndef OLED_BLOCK_COUNT
+# define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 16 (compile time mathed)
+# endif
+# ifndef OLED_BLOCK_SIZE
+# define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed)
+# endif
+# ifndef OLED_COM_PINS
+# define OLED_COM_PINS COM_PINS_SEQ
+# endif
+
+// For 90 degree rotation, we map our internal matrix to oled matrix using fixed arrays
+// The OLED writes to it's memory horizontally, starting top left, but our memory starts bottom left in this mode
+# ifndef OLED_SOURCE_MAP
+# define OLED_SOURCE_MAP \
+ { 0, 8, 16, 24 }
+# endif
+# ifndef OLED_TARGET_MAP
+# define OLED_TARGET_MAP \
+ { 24, 16, 8, 0 }
+# endif
+// If OLED_BLOCK_TYPE is uint8_t, these tables would look like:
+// #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 }
+// #define OLED_TARGET_MAP { 48, 32, 16, 0, 56, 40, 24, 8 }
+#endif // defined(OLED_DISPLAY_CUSTOM)
#if !defined(OLED_IC)
- #define OLED_IC OLED_IC_SSD1306
+# define OLED_IC OLED_IC_SSD1306
#endif
// the column address corresponding to the first column in the display hardware
#if !defined(OLED_COLUMN_OFFSET)
- #define OLED_COLUMN_OFFSET 0
+# define OLED_COLUMN_OFFSET 0
#endif
// Address to use for the i2c oled communication
#if !defined(OLED_DISPLAY_ADDRESS)
- #define OLED_DISPLAY_ADDRESS 0x3C
+# define OLED_DISPLAY_ADDRESS 0x3C
#endif
// Custom font file to use
#if !defined(OLED_FONT_H)
- #define OLED_FONT_H "glcdfont.c"
+# define OLED_FONT_H "glcdfont.c"
#endif
// unsigned char value of the first character in the font file
#if !defined(OLED_FONT_START)
- #define OLED_FONT_START 0
+# define OLED_FONT_START 0
#endif
// unsigned char value of the last character in the font file
#if !defined(OLED_FONT_END)
- #define OLED_FONT_END 224
+# define OLED_FONT_END 224
#endif
// Font render width
#if !defined(OLED_FONT_WIDTH)
- #define OLED_FONT_WIDTH 6
+# define OLED_FONT_WIDTH 6
#endif
// Font render height
#if !defined(OLED_FONT_HEIGHT)
- #define OLED_FONT_HEIGHT 8
+# define OLED_FONT_HEIGHT 8
#endif
#if !defined(OLED_TIMEOUT)
- #if defined(OLED_DISABLE_TIMEOUT)
- #define OLED_TIMEOUT 0
- #else
- #define OLED_TIMEOUT 60000
- #endif
+# if defined(OLED_DISABLE_TIMEOUT)
+# define OLED_TIMEOUT 0
+# else
+# define OLED_TIMEOUT 60000
+# endif
#endif
// OLED Rotation enum values are flags
@@ -151,7 +155,7 @@ typedef enum {
OLED_ROTATION_0 = 0,
OLED_ROTATION_90 = 1,
OLED_ROTATION_180 = 2,
- OLED_ROTATION_270 = 3, // OLED_ROTATION_90 | OLED_ROTATION_180
+ OLED_ROTATION_270 = 3, // OLED_ROTATION_90 | OLED_ROTATION_180
} oled_rotation_t;
// Initialize the oled display, rotating the rendered output based on the define passed in.
@@ -208,15 +212,15 @@ void oled_write_P(const char *data, bool invert);
// Remapped to call 'void oled_write_ln(const char *data, bool invert);' on ARM
void oled_write_ln_P(const char *data, bool invert);
#else
- // Writes a string to the buffer at current cursor position
- // Advances the cursor while writing, inverts the pixels if true
- #define oled_write_P(data, invert) oled_write(data, invert)
-
- // Writes a string to the buffer at current cursor position
- // Advances the cursor while writing, inverts the pixels if true
- // Advances the cursor to the next page, wiring ' ' to the remainder of the current page
- #define oled_write_ln_P(data, invert) oled_write(data, invert)
-#endif // defined(__AVR__)
+// Writes a string to the buffer at current cursor position
+// Advances the cursor while writing, inverts the pixels if true
+# define oled_write_P(data, invert) oled_write(data, invert)
+
+// Writes a string to the buffer at current cursor position
+// Advances the cursor while writing, inverts the pixels if true
+// Advances the cursor to the next page, wiring ' ' to the remainder of the current page
+# define oled_write_ln_P(data, invert) oled_write(data, invert)
+#endif // defined(__AVR__)
// Can be used to manually turn on the screen if it is off
// Returns true if the screen was on or turns on
diff --git a/drivers/qwiic/micro_oled.c b/drivers/qwiic/micro_oled.c
index 092dd551e3..597810f339 100644
--- a/drivers/qwiic/micro_oled.c
+++ b/drivers/qwiic/micro_oled.c
@@ -35,16 +35,21 @@
#include "string.h"
#define TOTALFONTS 2
-const unsigned char * fonts_pointer[]= { font5x7, font8x16 };
+const unsigned char* fonts_pointer[] = {font5x7, font8x16};
-uint8_t foreColor,drawMode,fontWidth, fontHeight, fontType, fontStartChar, fontTotalChar, cursorX, cursorY;
+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; }
+#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[LCDWIDTH*LCDWIDTH/8] = { 0 };
+uint8_t micro_oled_transfer_buffer[20];
+static uint8_t micro_oled_screen_current[LCDWIDTH * LCDWIDTH / 8] = {0};
/* LCD Memory organised in 64 horizontal pixel and 6 rows of byte
B B .............B -----
@@ -64,628 +69,399 @@ static uint8_t micro_oled_screen_current[LCDWIDTH*LCDWIDTH/8] = { 0 };
*/
#if LCDWIDTH == 64
- #if LCDWIDTH == 48
+# if LCDWIDTH == 48
static uint8_t micro_oled_screen_buffer[] = {
-// QMK Logo - generated at http://www.majer.ch/lcd/adf_bitmap.php
-//64x48 image
-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
-};
- #endif
+ // QMK Logo - generated at http://www.majer.ch/lcd/adf_bitmap.php
+ // 64x48 image
+ 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};
+# endif
#elif LCDWIDTH == 128
- #if LCDHEIGHT == 32
- static uint8_t micro_oled_screen_buffer[LCDWIDTH*LCDWIDTH/8] = {
-//128x32 qmk image
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x80, 0xC0, 0xE0, 0xE0, 0xFC, 0xFC, 0xE0, 0xFC, 0xFC,
-0xE0, 0xF0, 0xFC, 0xE0, 0xE0, 0xFC, 0xE0, 0xE0, 0xFC, 0xFC,
-0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0xF0, 0x10, 0x10, 0x30, 0xE0, 0x00, 0x00,
-0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x00, 0x00,
-0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, 0x80,
-0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00,
-0x80, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80,
-0x80, 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, 0x00, 0x12, 0xB2, 0xB2, 0xFF,
-0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x03, 0xFF, 0xFF, 0xFF, 0x03,
-0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x03, 0xFF, 0xFF, 0xFF,
-0xFF, 0xB7, 0xB2, 0xB2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x1F, 0x02, 0x02, 0x03, 0x01, 0x00, 0x06, 0x1F, 0x10,
-0x10, 0x10, 0x1F, 0x06, 0x00, 0x03, 0x1E, 0x18, 0x0F, 0x01,
-0x0F, 0x18, 0x1E, 0x01, 0x00, 0x0F, 0x1F, 0x12, 0x02, 0x12,
-0x13, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x0E, 0x1F, 0x12,
-0x02, 0x12, 0x13, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x1F,
-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, 0x48, 0x4D, 0x4D, 0xFF, 0xFF, 0xFF,
-0xFF, 0xFF, 0xFE, 0xF8, 0xF9, 0xF3, 0xF3, 0xC0, 0x80, 0xF3,
-0xF3, 0xF3, 0xF9, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xED,
-0x4D, 0x4D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0xFE, 0x20, 0x10, 0x10, 0xE0, 0xC0, 0x00, 0x70, 0xC0,
-0x00, 0x80, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x0C,
-0x04, 0x04, 0x04, 0x04, 0x1C, 0xF0, 0x00, 0x00, 0xFC, 0x0C,
-0x38, 0xE0, 0x00, 0x00, 0xC0, 0x38, 0x0C, 0xFC, 0x00, 0x00,
-0xFC, 0xFC, 0x60, 0x90, 0x0C, 0x04, 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, 0x01, 0x03, 0x07, 0x07, 0x3F,
-0x3F, 0x07, 0x3F, 0x3F, 0x07, 0x0F, 0x3F, 0x07, 0x07, 0x3F,
-0x07, 0x07, 0x3F, 0x3F, 0x07, 0x07, 0x03, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
-0x06, 0x04, 0x04, 0x07, 0x01, 0x00, 0x00, 0x13, 0x1E, 0x03,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x04, 0x04,
-0x04, 0x04, 0x07, 0x0D, 0x08, 0x00, 0x07, 0x00, 0x00, 0x01,
-0x07, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x07, 0x07,
-0x00, 0x01, 0x03, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00
- };
- #elif LCDHEIGHT == 64
- static uint8_t micro_oled_screen_buffer[LCDWIDTH*LCDWIDTH/8] = {
-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, 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, 0xC0, 0xC0,
-0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00,
-0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 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, 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,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0xC0, 0xC0, 0xC0, 0xC0, 0xF8, 0xFC, 0xFC, 0xFE, 0xFE, 0xFF,
-0x7F, 0x7E, 0xFE, 0xFF, 0xFF, 0xFE, 0xFE, 0x7F, 0x7F, 0xFE,
-0xFE, 0xFF, 0xFF, 0xFE, 0x7E, 0x7F, 0xFF, 0xFE, 0xFE, 0xFC,
-0xFC, 0xF8, 0xC0, 0xC0, 0xC0, 0xC0, 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, 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,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x88, 0x88, 0x88, 0xDD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
-0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF,
-0xFF, 0xFF, 0xFF, 0xDD, 0x88, 0x88, 0x88, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x99, 0x99, 0x99, 0x99, 0xFF, 0xFF, 0xFF, 0xFF,
-0xFF, 0xFF, 0xFE, 0xF8, 0xF0, 0xF3, 0xF3, 0xE7, 0xE7, 0x00,
-0x00, 0xE7, 0xE7, 0xF3, 0xF3, 0xF0, 0xF8, 0xFE, 0xFF, 0xFF,
-0xFF, 0xFF, 0xFF, 0xFF, 0x99, 0x99, 0x99, 0x99, 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,
-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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x0F, 0x1F, 0x3F,
-0x3F, 0x3F, 0xFF, 0xFF, 0x3F, 0x3F, 0xFF, 0xFF, 0x3F, 0x3F,
-0xFF, 0xFF, 0x3F, 0x3F, 0xFF, 0xFF, 0x3F, 0x3F, 0xFF, 0xFF,
-0x3F, 0x3F, 0x3F, 0x1F, 0x0F, 0x01, 0x01, 0x01, 0x01, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x03, 0x01, 0x00, 0x00, 0x03, 0x01, 0x00,
-0x80, 0x03, 0x03, 0x00, 0x00, 0x01, 0x03, 0x00, 0x80, 0x01,
-0x03, 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, 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, 0xFF, 0x11, 0x11, 0x11, 0x0E, 0x00, 0x70,
-0x88, 0x04, 0x04, 0x04, 0xF8, 0x00, 0x00, 0x3C, 0xE0, 0xC0,
-0x38, 0x1C, 0xE0, 0x80, 0x70, 0x0C, 0x00, 0xF8, 0xAC, 0x24,
-0x24, 0x3C, 0x30, 0x00, 0x00, 0xFC, 0x0C, 0x04, 0x00, 0xF8,
-0xAC, 0x24, 0x24, 0x2C, 0x30, 0x00, 0x70, 0xDC, 0x04, 0x04,
-0x88, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
-0x8C, 0x04, 0x04, 0xF8, 0x00, 0x04, 0x3C, 0xE0, 0x80, 0xF0,
-0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x83, 0x01, 0x01,
-0x01, 0x81, 0xFE, 0x3C, 0x00, 0x00, 0xFF, 0x03, 0x0E, 0x70,
-0xC0, 0xE0, 0x38, 0x06, 0x03, 0xFF, 0x00, 0x00, 0xFF, 0x18,
-0x38, 0x66, 0xC3, 0x01, 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, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01,
-0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01,
-0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01,
-0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0x03,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x03, 0x02, 0x00, 0x01, 0x00, 0x00,
-0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01,
-0x00, 0x00, 0x00, 0x00, 0x01, 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, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
- };
-//TODO: generate bitmap of QMK logo here
- #endif
+# if LCDHEIGHT == 32
+static uint8_t micro_oled_screen_buffer[LCDWIDTH * LCDWIDTH / 8] = {
+ // 128x32 qmk image
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xE0, 0xFC, 0xFC, 0xE0, 0xFC, 0xFC, 0xE0, 0xF0, 0xFC, 0xE0, 0xE0, 0xFC, 0xE0, 0xE0, 0xFC, 0xFC, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x10, 0x10, 0x30, 0xE0, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 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, 0x00, 0x12, 0xB2, 0xB2, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x03, 0xFF, 0xFF, 0xFF, 0x03, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xB7, 0xB2, 0xB2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x02, 0x02, 0x03, 0x01, 0x00, 0x06, 0x1F, 0x10, 0x10, 0x10, 0x1F, 0x06, 0x00, 0x03, 0x1E, 0x18, 0x0F, 0x01, 0x0F, 0x18, 0x1E, 0x01, 0x00, 0x0F, 0x1F, 0x12, 0x02, 0x12, 0x13, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x0E, 0x1F, 0x12, 0x02, 0x12, 0x13, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x1F, 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, 0x48, 0x4D, 0x4D, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF8, 0xF9, 0xF3, 0xF3, 0xC0, 0x80, 0xF3, 0xF3, 0xF3, 0xF9, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xED, 0x4D, 0x4D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x20, 0x10, 0x10, 0xE0, 0xC0, 0x00, 0x70, 0xC0, 0x00, 0x80, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x0C, 0x04, 0x04, 0x04, 0x04, 0x1C, 0xF0, 0x00, 0x00, 0xFC, 0x0C, 0x38, 0xE0, 0x00, 0x00, 0xC0, 0x38, 0x0C, 0xFC, 0x00, 0x00, 0xFC, 0xFC, 0x60, 0x90, 0x0C, 0x04, 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, 0x01, 0x03, 0x07, 0x07, 0x3F, 0x3F, 0x07, 0x3F, 0x3F, 0x07, 0x0F, 0x3F, 0x07, 0x07, 0x3F, 0x07, 0x07, 0x3F, 0x3F, 0x07, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x06, 0x04, 0x04, 0x07, 0x01, 0x00, 0x00, 0x13, 0x1E, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x04, 0x04, 0x04, 0x04, 0x07, 0x0D, 0x08, 0x00, 0x07, 0x00, 0x00, 0x01, 0x07, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x07, 0x07, 0x00, 0x01, 0x03, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+# elif LCDHEIGHT == 64
+static uint8_t micro_oled_screen_buffer[LCDWIDTH * LCDWIDTH / 8] = {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, 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, 0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xF8, 0xFC, 0xFC, 0xFE, 0xFE, 0xFF, 0x7F, 0x7E, 0xFE, 0xFF, 0xFF, 0xFE, 0xFE, 0x7F, 0x7F, 0xFE, 0xFE, 0xFF, 0xFF, 0xFE, 0x7E, 0x7F, 0xFF, 0xFE, 0xFE, 0xFC, 0xFC, 0xF8, 0xC0, 0xC0, 0xC0, 0xC0, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0x88, 0xDD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDD, 0x88, 0x88, 0x88, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x99, 0x99, 0x99, 0x99, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF8, 0xF0, 0xF3, 0xF3, 0xE7, 0xE7, 0x00, 0x00, 0xE7, 0xE7, 0xF3, 0xF3, 0xF0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x99, 0x99, 0x99, 0x99, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x0F, 0x1F, 0x3F, 0x3F, 0x3F, 0xFF, 0xFF, 0x3F, 0x3F, 0xFF, 0xFF, 0x3F, 0x3F, 0xFF, 0xFF, 0x3F, 0x3F, 0xFF, 0xFF, 0x3F, 0x3F, 0xFF, 0xFF, 0x3F, 0x3F, 0x3F, 0x1F, 0x0F, 0x01, 0x01, 0x01, 0x01, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x00, 0x00, 0x03, 0x01, 0x00, 0x80, 0x03, 0x03, 0x00, 0x00, 0x01, 0x03, 0x00, 0x80, 0x01, 0x03, 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, 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, 0xFF, 0x11, 0x11, 0x11, 0x0E, 0x00, 0x70, 0x88, 0x04, 0x04, 0x04, 0xF8, 0x00, 0x00, 0x3C, 0xE0, 0xC0, 0x38, 0x1C, 0xE0, 0x80, 0x70, 0x0C, 0x00, 0xF8, 0xAC, 0x24, 0x24, 0x3C, 0x30, 0x00, 0x00, 0xFC, 0x0C, 0x04, 0x00, 0xF8, 0xAC, 0x24, 0x24, 0x2C, 0x30, 0x00, 0x70, 0xDC, 0x04, 0x04, 0x88, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x8C, 0x04, 0x04, 0xF8, 0x00, 0x04, 0x3C, 0xE0, 0x80, 0xF0, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x83, 0x01, 0x01, 0x01, 0x81, 0xFE, 0x3C, 0x00, 0x00, 0xFF, 0x03, 0x0E, 0x70, 0xC0, 0xE0, 0x38, 0x06, 0x03, 0xFF, 0x00, 0x00, 0xFF, 0x18, 0x38, 0x66, 0xC3, 0x01, 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, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 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, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+// TODO: generate bitmap of QMK logo here
+# endif
#else
-//catchall for custom screen szies
- static uint8_t micro_oled_screen_buffer[LCDWIDTH*LCDWIDTH/8] = {0};
+// catchall for custom screen szies
+static uint8_t micro_oled_screen_buffer[LCDWIDTH * LCDWIDTH / 8] = {0};
#endif
-
-
void micro_oled_init(void) {
- i2c_init();
- i2c_start(I2C_ADDRESS_SA0_1);
+ i2c_init();
+ i2c_start(I2C_ADDRESS_SA0_1);
- // Display Init sequence for 64x48 OLED module
- send_command(DISPLAYOFF); // 0xAE
+ // Display Init sequence for 64x48 OLED module
+ send_command(DISPLAYOFF); // 0xAE
- send_command(SETDISPLAYCLOCKDIV); // 0xD5
- send_command(0x80); // the suggested ratio 0x80
+ send_command(SETDISPLAYCLOCKDIV); // 0xD5
+ send_command(0x80); // the suggested ratio 0x80
- send_command(SETMULTIPLEX); // 0xA8
- send_command(LCDHEIGHT - 1);
+ send_command(SETMULTIPLEX); // 0xA8
+ send_command(LCDHEIGHT - 1);
- send_command(SETDISPLAYOFFSET); // 0xD3
- send_command(0x00); // no offset
+ send_command(SETDISPLAYOFFSET); // 0xD3
+ send_command(0x00); // no offset
- send_command(SETSTARTLINE | 0x00); // line #0
+ send_command(SETSTARTLINE | 0x00); // line #0
- send_command(CHARGEPUMP); // enable charge pump
- send_command(0x14);
+ send_command(CHARGEPUMP); // enable charge pump
+ send_command(0x14);
- send_command(NORMALDISPLAY); // 0xA6
- send_command(DISPLAYALLONRESUME); // 0xA4
+ send_command(NORMALDISPLAY); // 0xA6
+ send_command(DISPLAYALLONRESUME); // 0xA4
-//display at regular orientation
- send_command(SEGREMAP | 0x1);
- send_command(COMSCANDEC);
+ // display at regular orientation
+ send_command(SEGREMAP | 0x1);
+ send_command(COMSCANDEC);
-//rotate display 180
+// rotate display 180
#ifdef micro_oled_rotate_180
- send_command(SEGREMAP);
- send_command(COMSCANINC);
+ send_command(SEGREMAP);
+ send_command(COMSCANINC);
#endif
- send_command(MEMORYMODE);
- send_command(0x10);
+ send_command(MEMORYMODE);
+ send_command(0x10);
- send_command(SETCOMPINS); // 0xDA
-if (LCDHEIGHT > 32) {
- send_command(0x12);
-} else {
- send_command(0x02);
-}
- send_command(SETCONTRAST); // 0x81
- send_command(0x8F);
+ send_command(SETCOMPINS); // 0xDA
+ if (LCDHEIGHT > 32) {
+ send_command(0x12);
+ } else {
+ send_command(0x02);
+ }
+ send_command(SETCONTRAST); // 0x81
+ send_command(0x8F);
- send_command(SETPRECHARGE); // 0xd9
- send_command(0xF1);
+ send_command(SETPRECHARGE); // 0xd9
+ send_command(0xF1);
- send_command(SETVCOMDESELECT); // 0xDB
- send_command(0x40);
+ 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();
+ 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);
+ 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);
+ 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);
+ 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) ) + ((128 - LCDWIDTH) >> 8) );
- send_command( 0x0F & address );
+ send_command((0x10 | (address >> 4)) + ((128 - LCDWIDTH) >> 8));
+ 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);
+ 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) {
-//384
- memset(micro_oled_screen_buffer, 0, LCDWIDTH*LCDWIDTH/8);
+ // 384
+ memset(micro_oled_screen_buffer, 0, LCDWIDTH * LCDWIDTH / 8);
}
/** \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);
- }
+ 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);
+ 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 < LCDHEIGHT/8; i++) {
- uint8_t col_addr = 0xFF;
- for (j = 0; j < LCDWIDTH; j++) {
- if (micro_oled_screen_buffer[i*LCDWIDTH+j] != micro_oled_screen_current[i*LCDWIDTH+j]) {
- if (page_addr != i) {
- set_page_address(i);
+ uint8_t i, j;
+
+ uint8_t page_addr = 0xFF;
+ for (i = 0; i < LCDHEIGHT / 8; i++) {
+ uint8_t col_addr = 0xFF;
+ for (j = 0; j < LCDWIDTH; j++) {
+ if (micro_oled_screen_buffer[i * LCDWIDTH + j] != micro_oled_screen_current[i * LCDWIDTH + j]) {
+ if (page_addr != i) {
+ set_page_address(i);
+ }
+ if (col_addr != j) {
+ set_column_address(j);
+ }
+ send_data(micro_oled_screen_buffer[i * LCDWIDTH + j]);
+ micro_oled_screen_current[i * LCDWIDTH + j] = micro_oled_screen_buffer[i * LCDWIDTH + j];
+ col_addr = j + 1;
+ }
}
- if (col_addr != j) {
- set_column_address(j);
- }
- send_data(micro_oled_screen_buffer[i*LCDWIDTH+j]);
- micro_oled_screen_current[i*LCDWIDTH+j] = micro_oled_screen_buffer[i*LCDWIDTH+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));
- }
+ 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++) {
+ uint8_t steep = abs(y1 - y0) > abs(x1 - x0);
if (steep) {
- draw_pixel(y0, x0, color, mode);
+ 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 {
- draw_pixel(x0, y0, color, mode);
+ ystep = -1;
}
- err -= dy;
- if (err < 0) {
- y0 += ystep;
- err += dx;
+
+ 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);
-}
+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);
-}
+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;
+ uint8_t tempHeight;
- draw_line_hori(x,y, width, color, mode);
- draw_line_hori(x,y+height-1, width, color, mode);
+ draw_line_hori(x, y, width, color, mode);
+ draw_line_hori(x, y + height - 1, width, color, mode);
- tempHeight=height-2;
+ 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;
+ // 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);
+ 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;
+ 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);
+ 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;
+ 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;
+ // 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);
+ 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);
- }
+ // 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);
- }
+ // 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);
+ // 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;
+ }
}
- else {
- draw_pixel(x+i, y+j, !color,mode);
- }
-
- temp >>=1;
- }
+ return;
}
- 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);
+
+ // 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;
+ }
}
- 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;
+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;
- }
+ 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;
+ }
}
diff --git a/drivers/qwiic/micro_oled.h b/drivers/qwiic/micro_oled.h
index 5d6a1029ed..814143df11 100644
--- a/drivers/qwiic/micro_oled.h
+++ b/drivers/qwiic/micro_oled.h
@@ -49,86 +49,86 @@ void draw_rect_soft(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t
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);
+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
#ifndef I2C_ADDRESS_SA0_1
-#define I2C_ADDRESS_SA0_1 0b0111101
+# define I2C_ADDRESS_SA0_1 0b0111101
#endif
#define I2C_COMMAND 0x00
#define I2C_DATA 0x40
#define PIXEL_OFF 0
-#define PIXEL_ON 1
+#define PIXEL_ON 1
#ifndef LCDWIDTH
-#define LCDWIDTH 64
+# define LCDWIDTH 64
#endif
#ifndef LCDWIDTH
-#define LCDHEIGHT 48
+# define LCDHEIGHT 48
#endif
-#define FONTHEADERSIZE 6
+#define FONTHEADERSIZE 6
-#define NORM 0
-#define XOR 1
+#define NORM 0
+#define XOR 1
-#define PAGE 0
-#define ALL 1
+#define PAGE 0
+#define ALL 1
-#define WIDGETSTYLE0 0
-#define WIDGETSTYLE1 1
-#define WIDGETSTYLE2 2
+#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
+#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 ACTIVATESCROLL 0x2F
+#define DEACTIVATESCROLL 0x2E
+#define SETVERTICALSCROLLAREA 0xA3
+#define RIGHTHORIZONTALSCROLL 0x26
+#define LEFT_HORIZONTALSCROLL 0x27
#define VERTICALRIGHTHORIZONTALSCROLL 0x29
-#define VERTICALLEFTHORIZONTALSCROLL 0x2A
+#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
+ 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; \ No newline at end of file
diff --git a/drivers/qwiic/qwiic.c b/drivers/qwiic/qwiic.c
index 9047919927..316d6539cb 100644
--- a/drivers/qwiic/qwiic.c
+++ b/drivers/qwiic/qwiic.c
@@ -16,16 +16,16 @@
#include "qwiic.h"
void qwiic_init(void) {
- #ifdef QWIIC_JOYSTIIC_ENABLE
+#ifdef QWIIC_JOYSTIIC_ENABLE
joystiic_init();
- #endif
- #ifdef QWIIC_MICRO_OLED_ENABLE
+#endif
+#ifdef QWIIC_MICRO_OLED_ENABLE
micro_oled_init();
- #endif
+#endif
}
void qwiic_task(void) {
- #ifdef QWIIC_JOYSTIIC_ENABLE
+#ifdef QWIIC_JOYSTIIC_ENABLE
joystiic_task();
- #endif
+#endif
}
diff --git a/drivers/qwiic/qwiic.h b/drivers/qwiic/qwiic.h
index 160fb28dfd..8c3d1c8d63 100644
--- a/drivers/qwiic/qwiic.h
+++ b/drivers/qwiic/qwiic.h
@@ -18,10 +18,10 @@
#include "i2c_master.h"
#ifdef QWIIC_JOYSTIIC_ENABLE
- #include "joystiic.h"
+# include "joystiic.h"
#endif
#ifdef QWIIC_MICRO_OLED_ENABLE
- #include "micro_oled.h"
+# include "micro_oled.h"
#endif
void qwiic_init(void);
diff --git a/drivers/qwiic/util/font5x7.h b/drivers/qwiic/util/font5x7.h
index 0bad206b7c..a641945aae 100644
--- a/drivers/qwiic/util/font5x7.h
+++ b/drivers/qwiic/util/font5x7.h
@@ -29,260 +29,11 @@ https://github.com/emil01/SparkFun_Micro_OLED_Arduino_Library/
// 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
-};
+ 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};
diff --git a/drivers/qwiic/util/font8x16.h b/drivers/qwiic/util/font8x16.h
index c070e4ec8c..4d3c237866 100644
--- a/drivers/qwiic/util/font8x16.h
+++ b/drivers/qwiic/util/font8x16.h
@@ -27,101 +27,13 @@ https://github.com/emil01/SparkFun_Micro_OLED_Arduino_Library/
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
-};
+ 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};
diff --git a/drivers/ugfx/gdisp/is31fl3731c/board_is31fl3731c_template.h b/drivers/ugfx/gdisp/is31fl3731c/board_is31fl3731c_template.h
index f248cc25ba..0755ddf6c4 100644
--- a/drivers/ugfx/gdisp/is31fl3731c/board_is31fl3731c_template.h
+++ b/drivers/ugfx/gdisp/is31fl3731c/board_is31fl3731c_template.h
@@ -19,54 +19,53 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define _GDISP_LLD_BOARD_H
static const I2CConfig i2ccfg = {
- 400000 // clock speed (Hz); 400kHz max for IS31
+ 400000 // clock speed (Hz); 400kHz max for IS31
};
static const uint8_t led_mask[] = {
- 0xFF, 0x00, /* C1-1 -> C1-16 */
- 0xFF, 0x00, /* C2-1 -> C2-16 */
- 0xFF, 0x00, /* C3-1 -> C3-16 */
- 0xFF, 0x00, /* C4-1 -> C4-16 */
- 0x3F, 0x00, /* C5-1 -> C5-16 */
- 0x00, 0x00, /* C6-1 -> C6-16 */
- 0x00, 0x00, /* C7-1 -> C7-16 */
- 0x00, 0x00, /* C8-1 -> C8-16 */
- 0x00, 0x00, /* C9-1 -> C9-16 */
+ 0xFF, 0x00, /* C1-1 -> C1-16 */
+ 0xFF, 0x00, /* C2-1 -> C2-16 */
+ 0xFF, 0x00, /* C3-1 -> C3-16 */
+ 0xFF, 0x00, /* C4-1 -> C4-16 */
+ 0x3F, 0x00, /* C5-1 -> C5-16 */
+ 0x00, 0x00, /* C6-1 -> C6-16 */
+ 0x00, 0x00, /* C7-1 -> C7-16 */
+ 0x00, 0x00, /* C8-1 -> C8-16 */
+ 0x00, 0x00, /* C9-1 -> C9-16 */
};
// The address of the LED
-#define LA(c, r) (c + r * 16 )
+#define LA(c, r) (c + r * 16)
// Need to be an address that is not mapped, but inside the range of the controller matrix
#define NA LA(8, 8)
// The numbers in the comments are the led numbers DXX on the PCB
// The mapping is taken from the schematic of left hand side
static const uint8_t led_mapping[GDISP_SCREEN_HEIGHT][GDISP_SCREEN_WIDTH] = {
-// 45 44 43 42 41 40 39
- { LA(1, 1), LA(1, 0), LA(0, 4), LA(0, 3), LA(0, 2), LA(0, 1), LA(0, 0)},
-// 52 51 50 49 48 47 46
- { LA(2, 3), LA(2, 2), LA(2, 1), LA(2, 0), LA(1, 4), LA(1, 3), LA(1, 2) },
-// 58 57 56 55 54 53 N/A
- { LA(3, 4), LA(3, 3), LA(3, 2), LA(3, 1), LA(3, 0), LA(2, 4), NA },
-// 67 66 65 64 63 62 61
- { LA(5, 3), LA(5, 2), LA(5, 1), LA(5, 0), LA(4, 4), LA(4, 3), LA(4, 2) },
-// 76 75 74 73 72 60 59
- { LA(7, 3), LA(7, 2), LA(7, 1), LA(7, 0), LA(6, 3), LA(4, 1), LA(4, 0) },
-// N/A N/A N/A N/A N/A N/A 68
- { NA, NA, NA, NA, NA, NA, LA(5, 4) },
-// N/A N/A N/A N/A 71 70 69
- { NA, NA, NA, NA, LA(6, 2), LA(6, 1), LA(6, 0) },
+ // 45 44 43 42 41 40 39
+ {LA(1, 1), LA(1, 0), LA(0, 4), LA(0, 3), LA(0, 2), LA(0, 1), LA(0, 0)},
+ // 52 51 50 49 48 47 46
+ {LA(2, 3), LA(2, 2), LA(2, 1), LA(2, 0), LA(1, 4), LA(1, 3), LA(1, 2)},
+ // 58 57 56 55 54 53 N/A
+ {LA(3, 4), LA(3, 3), LA(3, 2), LA(3, 1), LA(3, 0), LA(2, 4), NA},
+ // 67 66 65 64 63 62 61
+ {LA(5, 3), LA(5, 2), LA(5, 1), LA(5, 0), LA(4, 4), LA(4, 3), LA(4, 2)},
+ // 76 75 74 73 72 60 59
+ {LA(7, 3), LA(7, 2), LA(7, 1), LA(7, 0), LA(6, 3), LA(4, 1), LA(4, 0)},
+ // N/A N/A N/A N/A N/A N/A 68
+ {NA, NA, NA, NA, NA, NA, LA(5, 4)},
+ // N/A N/A N/A N/A 71 70 69
+ {NA, NA, NA, NA, LA(6, 2), LA(6, 1), LA(6, 0)},
};
-
-#define IS31_ADDR_DEFAULT 0x74 // AD connected to GND
+#define IS31_ADDR_DEFAULT 0x74 // AD connected to GND
#define IS31_TIMEOUT 5000
-static GFXINLINE void init_board(GDisplay *g) {
- (void) g;
+static GFXINLINE void init_board(GDisplay* g) {
+ (void)g;
/* I2C pins */
- palSetPadMode(GPIOB, 0, PAL_MODE_ALTERNATIVE_2); // PTB0/I2C0/SCL
- palSetPadMode(GPIOB, 1, PAL_MODE_ALTERNATIVE_2); // PTB1/I2C0/SDA
+ palSetPadMode(GPIOB, 0, PAL_MODE_ALTERNATIVE_2); // PTB0/I2C0/SCL
+ palSetPadMode(GPIOB, 1, PAL_MODE_ALTERNATIVE_2); // PTB1/I2C0/SDA
palSetPadMode(GPIOB, 16, PAL_MODE_OUTPUT_PUSHPULL);
palClearPad(GPIOB, 16);
/* start I2C */
@@ -77,34 +76,30 @@ static GFXINLINE void init_board(GDisplay *g) {
I2CD1.i2c->FLT = 4;
}
-static GFXINLINE void post_init_board(GDisplay *g) {
- (void) g;
-}
+static GFXINLINE void post_init_board(GDisplay* g) { (void)g; }
static GFXINLINE const uint8_t* get_led_mask(GDisplay* g) {
- (void) g;
+ (void)g;
return led_mask;
}
-static GFXINLINE uint8_t get_led_address(GDisplay* g, uint16_t x, uint16_t y)
-{
- (void) g;
+static GFXINLINE uint8_t get_led_address(GDisplay* g, uint16_t x, uint16_t y) {
+ (void)g;
return led_mapping[y][x];
}
static GFXINLINE void set_hardware_shutdown(GDisplay* g, bool shutdown) {
- (void) g;
- if(!shutdown) {
+ (void)g;
+ if (!shutdown) {
palSetPad(GPIOB, 16);
- }
- else {
+ } else {
palClearPad(GPIOB, 16);
}
}
-static GFXINLINE void write_data(GDisplay *g, uint8_t* data, uint16_t length) {
- (void) g;
- i2cMasterTransmitTimeout(&I2CD1, IS31_ADDR_DEFAULT, data, length, 0, 0, US2ST(IS31_TIMEOUT));
+static GFXINLINE void write_data(GDisplay* g, uint8_t* data, uint16_t length) {
+ (void)g;
+ i2cMasterTransmitTimeout(&I2CD1, IS31_ADDR_DEFAULT, data, length, 0, 0, US2ST(IS31_TIMEOUT));
}
#endif /* _GDISP_LLD_BOARD_H */
diff --git a/drivers/ugfx/gdisp/is31fl3731c/gdisp_is31fl3731c.c b/drivers/ugfx/gdisp/is31fl3731c/gdisp_is31fl3731c.c
index 917adadb84..7188244022 100644
--- a/drivers/ugfx/gdisp/is31fl3731c/gdisp_is31fl3731c.c
+++ b/drivers/ugfx/gdisp/is31fl3731c/gdisp_is31fl3731c.c
@@ -19,15 +19,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#if GFX_USE_GDISP
-#define GDISP_DRIVER_VMT GDISPVMT_IS31FL3731C_QMK
-#define GDISP_SCREEN_HEIGHT LED_HEIGHT
-#define GDISP_SCREEN_WIDTH LED_WIDTH
+# define GDISP_DRIVER_VMT GDISPVMT_IS31FL3731C_QMK
+# define GDISP_SCREEN_HEIGHT LED_HEIGHT
+# define GDISP_SCREEN_WIDTH LED_WIDTH
-#include "gdisp_lld_config.h"
-#include "src/gdisp/gdisp_driver.h"
-
-#include "board_is31fl3731c.h"
+# include "gdisp_lld_config.h"
+# include "src/gdisp/gdisp_driver.h"
+# include "board_is31fl3731c.h"
// Can't include led_tables from here
extern const uint8_t CIE1931_CURVE[];
@@ -36,96 +35,96 @@ extern const uint8_t CIE1931_CURVE[];
/* Driver local definitions. */
/*===========================================================================*/
-#ifndef GDISP_INITIAL_CONTRAST
- #define GDISP_INITIAL_CONTRAST 0
-#endif
-#ifndef GDISP_INITIAL_BACKLIGHT
- #define GDISP_INITIAL_BACKLIGHT 0
-#endif
+# ifndef GDISP_INITIAL_CONTRAST
+# define GDISP_INITIAL_CONTRAST 0
+# endif
+# ifndef GDISP_INITIAL_BACKLIGHT
+# define GDISP_INITIAL_BACKLIGHT 0
+# endif
-#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER<<0)
+# define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER << 0)
-#define IS31_ADDR_DEFAULT 0x74
+# define IS31_ADDR_DEFAULT 0x74
-#define IS31_REG_CONFIG 0x00
+# define IS31_REG_CONFIG 0x00
// bits in reg
-#define IS31_REG_CONFIG_PICTUREMODE 0x00
-#define IS31_REG_CONFIG_AUTOPLAYMODE 0x08
-#define IS31_REG_CONFIG_AUDIOPLAYMODE 0x18
+# define IS31_REG_CONFIG_PICTUREMODE 0x00
+# define IS31_REG_CONFIG_AUTOPLAYMODE 0x08
+# define IS31_REG_CONFIG_AUDIOPLAYMODE 0x18
// D2:D0 bits are starting frame for autoplay mode
-#define IS31_REG_PICTDISP 0x01 // D2:D0 frame select for picture mode
+# define IS31_REG_PICTDISP 0x01 // D2:D0 frame select for picture mode
-#define IS31_REG_AUTOPLAYCTRL1 0x02
+# define IS31_REG_AUTOPLAYCTRL1 0x02
// D6:D4 number of loops (000=infty)
// D2:D0 number of frames to be used
-#define IS31_REG_AUTOPLAYCTRL2 0x03 // D5:D0 delay time (*11ms)
+# define IS31_REG_AUTOPLAYCTRL2 0x03 // D5:D0 delay time (*11ms)
-#define IS31_REG_DISPLAYOPT 0x05
-#define IS31_REG_DISPLAYOPT_INTENSITY_SAME 0x20 // same intensity for all frames
-#define IS31_REG_DISPLAYOPT_BLINK_ENABLE 0x8
+# define IS31_REG_DISPLAYOPT 0x05
+# define IS31_REG_DISPLAYOPT_INTENSITY_SAME 0x20 // same intensity for all frames
+# define IS31_REG_DISPLAYOPT_BLINK_ENABLE 0x8
// D2:D0 bits blink period time (*0.27s)
-#define IS31_REG_AUDIOSYNC 0x06
-#define IS31_REG_AUDIOSYNC_ENABLE 0x1
+# define IS31_REG_AUDIOSYNC 0x06
+# define IS31_REG_AUDIOSYNC_ENABLE 0x1
-#define IS31_REG_FRAMESTATE 0x07
+# define IS31_REG_FRAMESTATE 0x07
-#define IS31_REG_BREATHCTRL1 0x08
+# define IS31_REG_BREATHCTRL1 0x08
// D6:D4 fade out time (26ms*2^i)
// D2:D0 fade in time (26ms*2^i)
-#define IS31_REG_BREATHCTRL2 0x09
-#define IS31_REG_BREATHCTRL2_ENABLE 0x10
+# define IS31_REG_BREATHCTRL2 0x09
+# define IS31_REG_BREATHCTRL2_ENABLE 0x10
// D2:D0 extinguish time (3.5ms*2^i)
-#define IS31_REG_SHUTDOWN 0x0A
-#define IS31_REG_SHUTDOWN_OFF 0x0
-#define IS31_REG_SHUTDOWN_ON 0x1
+# define IS31_REG_SHUTDOWN 0x0A
+# define IS31_REG_SHUTDOWN_OFF 0x0
+# define IS31_REG_SHUTDOWN_ON 0x1
-#define IS31_REG_AGCCTRL 0x0B
-#define IS31_REG_ADCRATE 0x0C
+# define IS31_REG_AGCCTRL 0x0B
+# define IS31_REG_ADCRATE 0x0C
-#define IS31_COMMANDREGISTER 0xFD
-#define IS31_FUNCTIONREG 0x0B // helpfully called 'page nine'
-#define IS31_FUNCTIONREG_SIZE 0xD
+# define IS31_COMMANDREGISTER 0xFD
+# define IS31_FUNCTIONREG 0x0B // helpfully called 'page nine'
+# define IS31_FUNCTIONREG_SIZE 0xD
-#define IS31_FRAME_SIZE 0xB4
+# define IS31_FRAME_SIZE 0xB4
-#define IS31_PWM_REG 0x24
-#define IS31_PWM_SIZE 0x90
+# define IS31_PWM_REG 0x24
+# define IS31_PWM_SIZE 0x90
-#define IS31_LED_MASK_SIZE 0x12
+# define IS31_LED_MASK_SIZE 0x12
-#define IS31
+# define IS31
/*===========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
-typedef struct{
+typedef struct {
uint8_t write_buffer_offset;
uint8_t write_buffer[IS31_FRAME_SIZE];
uint8_t frame_buffer[GDISP_SCREEN_HEIGHT * GDISP_SCREEN_WIDTH];
uint8_t page;
-}__attribute__((__packed__)) PrivData;
+} __attribute__((__packed__)) PrivData;
// Some common routines and macros
-#define PRIV(g) ((PrivData*)g->priv)
+# define PRIV(g) ((PrivData *)g->priv)
/*===========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
-static GFXINLINE void write_page(GDisplay* g, uint8_t page) {
+static GFXINLINE void write_page(GDisplay *g, uint8_t page) {
uint8_t tx[2] __attribute__((aligned(2)));
tx[0] = IS31_COMMANDREGISTER;
tx[1] = page;
write_data(g, tx, 2);
}
-static GFXINLINE void write_register(GDisplay* g, uint8_t page, uint8_t reg, uint8_t data) {
+static GFXINLINE void write_register(GDisplay *g, uint8_t page, uint8_t reg, uint8_t data) {
uint8_t tx[2] __attribute__((aligned(2)));
tx[0] = reg;
tx[1] = data;
@@ -136,7 +135,7 @@ static GFXINLINE void write_register(GDisplay* g, uint8_t page, uint8_t reg, uin
static GFXINLINE void write_ram(GDisplay *g, uint8_t page, uint16_t offset, uint16_t length) {
PRIV(g)->write_buffer_offset = offset;
write_page(g, page);
- write_data(g, (uint8_t*)PRIV(g), length + 1);
+ write_data(g, (uint8_t *)PRIV(g), length + 1);
}
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
@@ -160,10 +159,9 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
write_ram(g, IS31_FUNCTIONREG, 0, IS31_FUNCTIONREG_SIZE);
gfxSleepMilliseconds(10);
-
// zero all LED registers on all 8 pages, and enable the mask
__builtin_memcpy(PRIV(g)->write_buffer, get_led_mask(g), IS31_LED_MASK_SIZE);
- for(uint8_t i=0; i<8; i++) {
+ for (uint8_t i = 0; i < 8; i++) {
write_ram(g, i, 0, IS31_FRAME_SIZE);
gfxSleepMilliseconds(1);
}
@@ -176,133 +174,129 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
post_init_board(g);
/* Initialise the GDISP structure */
- g->g.Width = GDISP_SCREEN_WIDTH;
- g->g.Height = GDISP_SCREEN_HEIGHT;
+ g->g.Width = GDISP_SCREEN_WIDTH;
+ g->g.Height = GDISP_SCREEN_HEIGHT;
g->g.Orientation = GDISP_ROTATE_0;
- g->g.Powermode = powerOff;
- g->g.Backlight = GDISP_INITIAL_BACKLIGHT;
- g->g.Contrast = GDISP_INITIAL_CONTRAST;
+ g->g.Powermode = powerOff;
+ g->g.Backlight = GDISP_INITIAL_BACKLIGHT;
+ g->g.Contrast = GDISP_INITIAL_CONTRAST;
return TRUE;
}
-#if GDISP_HARDWARE_FLUSH
- LLDSPEC void gdisp_lld_flush(GDisplay *g) {
- // Don't flush if we don't need it.
- if (!(g->flags & GDISP_FLG_NEEDFLUSH))
- return;
-
- PRIV(g)->page++;
- PRIV(g)->page %= 2;
- // TODO: some smarter algorithm for this
- // We should run only one physical page at a time
- // This way we don't need to send so much data, and
- // we could use slightly less memory
- uint8_t* src = PRIV(g)->frame_buffer;
- for (int y=0;y<GDISP_SCREEN_HEIGHT;y++) {
- for (int x=0;x<GDISP_SCREEN_WIDTH;x++) {
- uint8_t val = (uint16_t)*src * g->g.Backlight / 100;
- PRIV(g)->write_buffer[get_led_address(g, x, y)]=CIE1931_CURVE[val];
- ++src;
- }
+# if GDISP_HARDWARE_FLUSH
+LLDSPEC void gdisp_lld_flush(GDisplay *g) {
+ // Don't flush if we don't need it.
+ if (!(g->flags & GDISP_FLG_NEEDFLUSH)) return;
+
+ PRIV(g)->page++;
+ PRIV(g)->page %= 2;
+ // TODO: some smarter algorithm for this
+ // We should run only one physical page at a time
+ // This way we don't need to send so much data, and
+ // we could use slightly less memory
+ uint8_t *src = PRIV(g)->frame_buffer;
+ for (int y = 0; y < GDISP_SCREEN_HEIGHT; y++) {
+ for (int x = 0; x < GDISP_SCREEN_WIDTH; x++) {
+ uint8_t val = (uint16_t)*src * g->g.Backlight / 100;
+ PRIV(g)->write_buffer[get_led_address(g, x, y)] = CIE1931_CURVE[val];
+ ++src;
}
- write_ram(g, PRIV(g)->page, IS31_PWM_REG, IS31_PWM_SIZE);
- gfxSleepMilliseconds(1);
- write_register(g, IS31_FUNCTIONREG, IS31_REG_PICTDISP, PRIV(g)->page);
-
- g->flags &= ~GDISP_FLG_NEEDFLUSH;
}
-#endif
+ write_ram(g, PRIV(g)->page, IS31_PWM_REG, IS31_PWM_SIZE);
+ gfxSleepMilliseconds(1);
+ write_register(g, IS31_FUNCTIONREG, IS31_REG_PICTDISP, PRIV(g)->page);
-#if GDISP_HARDWARE_DRAWPIXEL
- LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) {
- coord_t x, y;
+ g->flags &= ~GDISP_FLG_NEEDFLUSH;
+}
+# endif
- switch(g->g.Orientation) {
+# if GDISP_HARDWARE_DRAWPIXEL
+LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) {
+ coord_t x, y;
+
+ switch (g->g.Orientation) {
default:
case GDISP_ROTATE_0:
x = g->p.x;
y = g->p.y;
break;
case GDISP_ROTATE_180:
- x = GDISP_SCREEN_WIDTH-1 - g->p.x;
+ x = GDISP_SCREEN_WIDTH - 1 - g->p.x;
y = g->p.y;
break;
- }
- PRIV(g)->frame_buffer[y * GDISP_SCREEN_WIDTH + x] = gdispColor2Native(g->p.color);
- g->flags |= GDISP_FLG_NEEDFLUSH;
}
-#endif
+ PRIV(g)->frame_buffer[y * GDISP_SCREEN_WIDTH + x] = gdispColor2Native(g->p.color);
+ g->flags |= GDISP_FLG_NEEDFLUSH;
+}
+# endif
-#if GDISP_HARDWARE_PIXELREAD
- LLDSPEC color_t gdisp_lld_get_pixel_color(GDisplay *g) {
- coord_t x, y;
+# if GDISP_HARDWARE_PIXELREAD
+LLDSPEC color_t gdisp_lld_get_pixel_color(GDisplay *g) {
+ coord_t x, y;
- switch(g->g.Orientation) {
+ switch (g->g.Orientation) {
default:
case GDISP_ROTATE_0:
x = g->p.x;
y = g->p.y;
break;
case GDISP_ROTATE_180:
- x = GDISP_SCREEN_WIDTH-1 - g->p.x;
+ x = GDISP_SCREEN_WIDTH - 1 - g->p.x;
y = g->p.y;
break;
- }
- return gdispNative2Color(PRIV(g)->frame_buffer[y * GDISP_SCREEN_WIDTH + x]);
}
-#endif
+ return gdispNative2Color(PRIV(g)->frame_buffer[y * GDISP_SCREEN_WIDTH + x]);
+}
+# endif
-#if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL
- LLDSPEC void gdisp_lld_control(GDisplay *g) {
- switch(g->p.x) {
+# if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL
+LLDSPEC void gdisp_lld_control(GDisplay *g) {
+ switch (g->p.x) {
case GDISP_CONTROL_POWER:
- if (g->g.Powermode == (powermode_t)g->p.ptr)
- return;
- switch((powermode_t)g->p.ptr) {
- case powerOff:
- case powerSleep:
- case powerDeepSleep:
- write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_OFF);
- break;
- case powerOn:
- write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_ON);
- break;
- default:
- return;
+ if (g->g.Powermode == (powermode_t)g->p.ptr) return;
+ switch ((powermode_t)g->p.ptr) {
+ case powerOff:
+ case powerSleep:
+ case powerDeepSleep:
+ write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_OFF);
+ break;
+ case powerOn:
+ write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_ON);
+ break;
+ default:
+ return;
}
g->g.Powermode = (powermode_t)g->p.ptr;
return;
case GDISP_CONTROL_ORIENTATION:
- if (g->g.Orientation == (orientation_t)g->p.ptr)
- return;
- switch((orientation_t)g->p.ptr) {
- /* Rotation is handled by the drawing routines */
- case GDISP_ROTATE_0:
- case GDISP_ROTATE_180:
- g->g.Height = GDISP_SCREEN_HEIGHT;
- g->g.Width = GDISP_SCREEN_WIDTH;
- break;
- case GDISP_ROTATE_90:
- case GDISP_ROTATE_270:
- g->g.Height = GDISP_SCREEN_WIDTH;
- g->g.Width = GDISP_SCREEN_HEIGHT;
- break;
- default:
- return;
+ if (g->g.Orientation == (orientation_t)g->p.ptr) return;
+ switch ((orientation_t)g->p.ptr) {
+ /* Rotation is handled by the drawing routines */
+ case GDISP_ROTATE_0:
+ case GDISP_ROTATE_180:
+ g->g.Height = GDISP_SCREEN_HEIGHT;
+ g->g.Width = GDISP_SCREEN_WIDTH;
+ break;
+ case GDISP_ROTATE_90:
+ case GDISP_ROTATE_270:
+ g->g.Height = GDISP_SCREEN_WIDTH;
+ g->g.Width = GDISP_SCREEN_HEIGHT;
+ break;
+ default:
+ return;
}
g->g.Orientation = (orientation_t)g->p.ptr;
return;
case GDISP_CONTROL_BACKLIGHT:
- if (g->g.Backlight == (unsigned)g->p.ptr)
- return;
- unsigned val = (unsigned)g->p.ptr;
+ if (g->g.Backlight == (unsigned)g->p.ptr) return;
+ unsigned val = (unsigned)g->p.ptr;
g->g.Backlight = val > 100 ? 100 : val;
g->flags |= GDISP_FLG_NEEDFLUSH;
return;
- }
}
-#endif // GDISP_NEED_CONTROL
+}
+# endif // GDISP_NEED_CONTROL
-#endif // GFX_USE_GDISP
+#endif // GFX_USE_GDISP
diff --git a/drivers/ugfx/gdisp/is31fl3731c/gdisp_lld_config.h b/drivers/ugfx/gdisp/is31fl3731c/gdisp_lld_config.h
index 588d688cf6..1b9fadba16 100644
--- a/drivers/ugfx/gdisp/is31fl3731c/gdisp_lld_config.h
+++ b/drivers/ugfx/gdisp/is31fl3731c/gdisp_lld_config.h
@@ -24,13 +24,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Driver hardware support. */
/*===========================================================================*/
-#define GDISP_HARDWARE_FLUSH TRUE // This controller requires flushing
-#define GDISP_HARDWARE_DRAWPIXEL TRUE
-#define GDISP_HARDWARE_PIXELREAD TRUE
-#define GDISP_HARDWARE_CONTROL TRUE
+# define GDISP_HARDWARE_FLUSH TRUE // This controller requires flushing
+# define GDISP_HARDWARE_DRAWPIXEL TRUE
+# define GDISP_HARDWARE_PIXELREAD TRUE
+# define GDISP_HARDWARE_CONTROL TRUE
-#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_GRAY256
+# define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_GRAY256
-#endif /* GFX_USE_GDISP */
+#endif /* GFX_USE_GDISP */
-#endif /* _GDISP_LLD_CONFIG_H */
+#endif /* _GDISP_LLD_CONFIG_H */
diff --git a/drivers/ugfx/gdisp/st7565/board_st7565_template.h b/drivers/ugfx/gdisp/st7565/board_st7565_template.h
index 9ab636c95d..194f8ea24d 100644
--- a/drivers/ugfx/gdisp/st7565/board_st7565_template.h
+++ b/drivers/ugfx/gdisp/st7565/board_st7565_template.h
@@ -8,10 +8,10 @@
#ifndef _GDISP_LLD_BOARD_H
#define _GDISP_LLD_BOARD_H
-#define ST7565_LCD_BIAS ST7565_LCD_BIAS_9 // actually 6
-#define ST7565_ADC ST7565_ADC_NORMAL
-#define ST7565_COM_SCAN ST7565_COM_SCAN_DEC
-#define ST7565_PAGE_ORDER 0,1,2,3
+#define ST7565_LCD_BIAS ST7565_LCD_BIAS_9 // actually 6
+#define ST7565_ADC ST7565_ADC_NORMAL
+#define ST7565_COM_SCAN ST7565_COM_SCAN_DEC
+#define ST7565_PAGE_ORDER 0, 1, 2, 3
/*
* Custom page order for several LCD boards, e.g. HEM12864-99
* #define ST7565_PAGE_ORDER 4,5,6,7,0,1,2,3
@@ -25,11 +25,9 @@
#define ST7565_SLCK_PIN 5
#define ST7565_SS_PIN 4
-#define palSetPadModeRaw(portname, bits) \
- ST7565_PORT->PCR[ST7565_##portname##_PIN] = bits
+#define palSetPadModeRaw(portname, bits) ST7565_PORT->PCR[ST7565_##portname##_PIN] = bits
-#define palSetPadModeNamed(portname, portmode) \
- palSetPadMode(ST7565_GPIOPORT, ST7565_##portname##_PIN, portmode)
+#define palSetPadModeNamed(portname, portmode) palSetPadMode(ST7565_GPIOPORT, ST7565_##portname##_PIN, portmode)
#define ST7565_SPI_MODE PORTx_PCRn_DSE | PORTx_PCRn_MUX(2)
// DSPI Clock and Transfer Attributes
@@ -37,38 +35,37 @@
// MSB First
// CLK Low by default
static const SPIConfig spi1config = {
- // Operation complete callback or @p NULL.
- .end_cb = NULL,
- //The chip select line port - when not using pcs.
- .ssport = ST7565_GPIOPORT,
- // brief The chip select line pad number - when not using pcs.
- .sspad=ST7565_SS_PIN,
- // SPI initialization data.
- .tar0 =
- SPIx_CTARn_FMSZ(7) // Frame size = 8 bytes
- | SPIx_CTARn_ASC(1) // After SCK Delay Scaler (min 50 ns) = 55.56ns
- | SPIx_CTARn_DT(0) // Delay After Transfer Scaler (no minimum)= 27.78ns
- | SPIx_CTARn_CSSCK(0) // PCS to SCK Delay Scaler (min 20 ns) = 27.78ns
- | SPIx_CTARn_PBR(0) // Baud Rate Prescaler = 2
- | SPIx_CTARn_BR(0) // Baud rate (min 50ns) = 55.56ns
+ // Operation complete callback or @p NULL.
+ .end_cb = NULL,
+ // The chip select line port - when not using pcs.
+ .ssport = ST7565_GPIOPORT,
+ // brief The chip select line pad number - when not using pcs.
+ .sspad = ST7565_SS_PIN,
+ // SPI initialization data.
+ .tar0 = SPIx_CTARn_FMSZ(7) // Frame size = 8 bytes
+ | SPIx_CTARn_ASC(1) // After SCK Delay Scaler (min 50 ns) = 55.56ns
+ | SPIx_CTARn_DT(0) // Delay After Transfer Scaler (no minimum)= 27.78ns
+ | SPIx_CTARn_CSSCK(0) // PCS to SCK Delay Scaler (min 20 ns) = 27.78ns
+ | SPIx_CTARn_PBR(0) // Baud Rate Prescaler = 2
+ | SPIx_CTARn_BR(0) // Baud rate (min 50ns) = 55.56ns
};
static GFXINLINE void acquire_bus(GDisplay *g) {
- (void) g;
+ (void)g;
// Only the LCD is using the SPI bus, so no need to acquire
// spiAcquireBus(&SPID1);
spiSelect(&SPID1);
}
static GFXINLINE void release_bus(GDisplay *g) {
- (void) g;
+ (void)g;
// Only the LCD is using the SPI bus, so no need to release
- //spiReleaseBus(&SPID1);
+ // spiReleaseBus(&SPID1);
spiUnselect(&SPID1);
}
static GFXINLINE void init_board(GDisplay *g) {
- (void) g;
+ (void)g;
palSetPadModeNamed(A0, PAL_MODE_OUTPUT_PUSHPULL);
palSetPad(ST7565_GPIOPORT, ST7565_A0_PIN);
palSetPadModeNamed(RST, PAL_MODE_OUTPUT_PUSHPULL);
@@ -82,31 +79,23 @@ static GFXINLINE void init_board(GDisplay *g) {
release_bus(g);
}
-static GFXINLINE void post_init_board(GDisplay *g) {
- (void) g;
-}
+static GFXINLINE void post_init_board(GDisplay *g) { (void)g; }
static GFXINLINE void setpin_reset(GDisplay *g, bool_t state) {
- (void) g;
+ (void)g;
if (state) {
palClearPad(ST7565_GPIOPORT, ST7565_RST_PIN);
- }
- else {
+ } else {
palSetPad(ST7565_GPIOPORT, ST7565_RST_PIN);
}
}
-static GFXINLINE void enter_data_mode(GDisplay *g) {
- palSetPad(ST7565_GPIOPORT, ST7565_A0_PIN);
-}
-
-static GFXINLINE void enter_cmd_mode(GDisplay *g) {
- palClearPad(ST7565_GPIOPORT, ST7565_A0_PIN);
-}
+static GFXINLINE void enter_data_mode(GDisplay *g) { palSetPad(ST7565_GPIOPORT, ST7565_A0_PIN); }
+static GFXINLINE void enter_cmd_mode(GDisplay *g) { palClearPad(ST7565_GPIOPORT, ST7565_A0_PIN); }
-static GFXINLINE void write_data(GDisplay *g, uint8_t* data, uint16_t length) {
- (void) g;
+static GFXINLINE void write_data(GDisplay *g, uint8_t *data, uint16_t length) {
+ (void)g;
spiSend(&SPID1, length, data);
}
diff --git a/drivers/ugfx/gdisp/st7565/gdisp_lld_ST7565.c b/drivers/ugfx/gdisp/st7565/gdisp_lld_ST7565.c
index c38194b069..fde320981b 100644
--- a/drivers/ugfx/gdisp/st7565/gdisp_lld_ST7565.c
+++ b/drivers/ugfx/gdisp/st7565/gdisp_lld_ST7565.c
@@ -9,82 +9,89 @@
#if GFX_USE_GDISP
-#define GDISP_DRIVER_VMT GDISPVMT_ST7565_QMK
-#include "gdisp_lld_config.h"
-#include "src/gdisp/gdisp_driver.h"
+# define GDISP_DRIVER_VMT GDISPVMT_ST7565_QMK
+# include "gdisp_lld_config.h"
+# include "src/gdisp/gdisp_driver.h"
-#include "board_st7565.h"
+# include "board_st7565.h"
/*===========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/
-#ifndef GDISP_SCREEN_HEIGHT
-#define GDISP_SCREEN_HEIGHT LCD_HEIGHT
-#endif
-#ifndef GDISP_SCREEN_WIDTH
-#define GDISP_SCREEN_WIDTH LCD_WIDTH
-#endif
-#ifndef GDISP_INITIAL_CONTRAST
-#define GDISP_INITIAL_CONTRAST 35
-#endif
-#ifndef GDISP_INITIAL_BACKLIGHT
-#define GDISP_INITIAL_BACKLIGHT 100
-#endif
+# ifndef GDISP_SCREEN_HEIGHT
+# define GDISP_SCREEN_HEIGHT LCD_HEIGHT
+# endif
+# ifndef GDISP_SCREEN_WIDTH
+# define GDISP_SCREEN_WIDTH LCD_WIDTH
+# endif
+# ifndef GDISP_INITIAL_CONTRAST
+# define GDISP_INITIAL_CONTRAST 35
+# endif
+# ifndef GDISP_INITIAL_BACKLIGHT
+# define GDISP_INITIAL_BACKLIGHT 100
+# endif
-#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER<<0)
+# define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER << 0)
-#include "st7565.h"
+# include "st7565.h"
/*===========================================================================*/
/* Driver config defaults for backward compatibility. */
/*===========================================================================*/
-#ifndef ST7565_LCD_BIAS
-#define ST7565_LCD_BIAS ST7565_LCD_BIAS_7
-#endif
-#ifndef ST7565_ADC
-#define ST7565_ADC ST7565_ADC_NORMAL
-#endif
-#ifndef ST7565_COM_SCAN
-#define ST7565_COM_SCAN ST7565_COM_SCAN_INC
-#endif
-#ifndef ST7565_PAGE_ORDER
-#define ST7565_PAGE_ORDER 0,1,2,3
-#endif
+# ifndef ST7565_LCD_BIAS
+# define ST7565_LCD_BIAS ST7565_LCD_BIAS_7
+# endif
+# ifndef ST7565_ADC
+# define ST7565_ADC ST7565_ADC_NORMAL
+# endif
+# ifndef ST7565_COM_SCAN
+# define ST7565_COM_SCAN ST7565_COM_SCAN_INC
+# endif
+# ifndef ST7565_PAGE_ORDER
+# define ST7565_PAGE_ORDER 0, 1, 2, 3
+# endif
/*===========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
-typedef struct{
- bool_t buffer2;
+typedef struct {
+ bool_t buffer2;
uint8_t data_pos;
uint8_t data[16];
uint8_t ram[GDISP_SCREEN_HEIGHT * GDISP_SCREEN_WIDTH / 8];
-}PrivData;
+} PrivData;
// Some common routines and macros
-#define PRIV(g) ((PrivData*)g->priv)
-#define RAM(g) (PRIV(g)->ram)
+# define PRIV(g) ((PrivData *)g->priv)
+# define RAM(g) (PRIV(g)->ram)
-static GFXINLINE void write_cmd(GDisplay* g, uint8_t cmd) {
- PRIV(g)->data[PRIV(g)->data_pos++] = cmd;
-}
+static GFXINLINE void write_cmd(GDisplay *g, uint8_t cmd) { PRIV(g)->data[PRIV(g)->data_pos++] = cmd; }
-static GFXINLINE void flush_cmd(GDisplay* g) {
+static GFXINLINE void flush_cmd(GDisplay *g) {
write_data(g, PRIV(g)->data, PRIV(g)->data_pos);
PRIV(g)->data_pos = 0;
}
-#define write_cmd2(g, cmd1, cmd2) { write_cmd(g, cmd1); write_cmd(g, cmd2); }
-#define write_cmd3(g, cmd1, cmd2, cmd3) { write_cmd(g, cmd1); write_cmd(g, cmd2); write_cmd(g, cmd3); }
+# define write_cmd2(g, cmd1, cmd2) \
+ { \
+ write_cmd(g, cmd1); \
+ write_cmd(g, cmd2); \
+ }
+# define write_cmd3(g, cmd1, cmd2, cmd3) \
+ { \
+ write_cmd(g, cmd1); \
+ write_cmd(g, cmd2); \
+ write_cmd(g, cmd3); \
+ }
// Some common routines and macros
-#define delay(us) gfxSleepMicroseconds(us)
-#define delay_ms(ms) gfxSleepMilliseconds(ms)
+# define delay(us) gfxSleepMicroseconds(us)
+# define delay_ms(ms) gfxSleepMilliseconds(ms)
-#define xyaddr(x, y) ((x) + ((y)>>3)*GDISP_SCREEN_WIDTH)
-#define xybit(y) (1<<((y)&7))
+# define xyaddr(x, y) ((x) + ((y) >> 3) * GDISP_SCREEN_WIDTH)
+# define xybit(y) (1 << ((y)&7))
/*===========================================================================*/
/* Driver exported functions. */
@@ -99,8 +106,8 @@ static GFXINLINE void flush_cmd(GDisplay* g) {
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
// The private area is the display surface.
- g->priv = gfxAlloc(sizeof(PrivData));
- PRIV(g)->buffer2 = false;
+ g->priv = gfxAlloc(sizeof(PrivData));
+ PRIV(g)->buffer2 = false;
PRIV(g)->data_pos = 0;
// Initialise the board interface
@@ -139,22 +146,21 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
release_bus(g);
/* Initialise the GDISP structure */
- g->g.Width = GDISP_SCREEN_WIDTH;
- g->g.Height = GDISP_SCREEN_HEIGHT;
+ g->g.Width = GDISP_SCREEN_WIDTH;
+ g->g.Height = GDISP_SCREEN_HEIGHT;
g->g.Orientation = GDISP_ROTATE_0;
- g->g.Powermode = powerOff;
- g->g.Backlight = GDISP_INITIAL_BACKLIGHT;
- g->g.Contrast = GDISP_INITIAL_CONTRAST;
+ g->g.Powermode = powerOff;
+ g->g.Backlight = GDISP_INITIAL_BACKLIGHT;
+ g->g.Contrast = GDISP_INITIAL_CONTRAST;
return TRUE;
}
-#if GDISP_HARDWARE_FLUSH
+# if GDISP_HARDWARE_FLUSH
LLDSPEC void gdisp_lld_flush(GDisplay *g) {
- unsigned p;
+ unsigned p;
// Don't flush if we don't need it.
- if (!(g->flags & GDISP_FLG_NEEDFLUSH))
- return;
+ if (!(g->flags & GDISP_FLG_NEEDFLUSH)) return;
acquire_bus(g);
enter_cmd_mode(g);
@@ -166,7 +172,7 @@ LLDSPEC void gdisp_lld_flush(GDisplay *g) {
write_cmd(g, ST7565_RMW);
flush_cmd(g);
enter_data_mode(g);
- write_data(g, RAM(g) + (p*GDISP_SCREEN_WIDTH), GDISP_SCREEN_WIDTH);
+ write_data(g, RAM(g) + (p * GDISP_SCREEN_WIDTH), GDISP_SCREEN_WIDTH);
enter_cmd_mode(g);
}
unsigned line = (PRIV(g)->buffer2 ? 32 : 0);
@@ -177,30 +183,30 @@ LLDSPEC void gdisp_lld_flush(GDisplay *g) {
g->flags &= ~GDISP_FLG_NEEDFLUSH;
}
-#endif
+# endif
-#if GDISP_HARDWARE_DRAWPIXEL
+# if GDISP_HARDWARE_DRAWPIXEL
LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) {
- coord_t x, y;
-
- switch(g->g.Orientation) {
- default:
- case GDISP_ROTATE_0:
- x = g->p.x;
- y = g->p.y;
- break;
- case GDISP_ROTATE_90:
- x = g->p.y;
- y = GDISP_SCREEN_HEIGHT-1 - g->p.x;
- break;
- case GDISP_ROTATE_180:
- x = GDISP_SCREEN_WIDTH-1 - g->p.x;
- y = GDISP_SCREEN_HEIGHT-1 - g->p.y;
- break;
- case GDISP_ROTATE_270:
- x = GDISP_SCREEN_HEIGHT-1 - g->p.y;
- y = g->p.x;
- break;
+ coord_t x, y;
+
+ switch (g->g.Orientation) {
+ default:
+ case GDISP_ROTATE_0:
+ x = g->p.x;
+ y = g->p.y;
+ break;
+ case GDISP_ROTATE_90:
+ x = g->p.y;
+ y = GDISP_SCREEN_HEIGHT - 1 - g->p.x;
+ break;
+ case GDISP_ROTATE_180:
+ x = GDISP_SCREEN_WIDTH - 1 - g->p.x;
+ y = GDISP_SCREEN_HEIGHT - 1 - g->p.y;
+ break;
+ case GDISP_ROTATE_270:
+ x = GDISP_SCREEN_HEIGHT - 1 - g->p.y;
+ y = g->p.x;
+ break;
}
if (gdispColor2Native(g->p.color) != Black)
RAM(g)[xyaddr(x, y)] |= xybit(y);
@@ -208,53 +214,52 @@ LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) {
RAM(g)[xyaddr(x, y)] &= ~xybit(y);
g->flags |= GDISP_FLG_NEEDFLUSH;
}
-#endif
+# endif
-#if GDISP_HARDWARE_PIXELREAD
+# if GDISP_HARDWARE_PIXELREAD
LLDSPEC color_t gdisp_lld_get_pixel_color(GDisplay *g) {
- coord_t x, y;
-
- switch(g->g.Orientation) {
- default:
- case GDISP_ROTATE_0:
- x = g->p.x;
- y = g->p.y;
- break;
- case GDISP_ROTATE_90:
- x = g->p.y;
- y = GDISP_SCREEN_HEIGHT-1 - g->p.x;
- break;
- case GDISP_ROTATE_180:
- x = GDISP_SCREEN_WIDTH-1 - g->p.x;
- y = GDISP_SCREEN_HEIGHT-1 - g->p.y;
- break;
- case GDISP_ROTATE_270:
- x = GDISP_SCREEN_HEIGHT-1 - g->p.y;
- y = g->p.x;
- break;
+ coord_t x, y;
+
+ switch (g->g.Orientation) {
+ default:
+ case GDISP_ROTATE_0:
+ x = g->p.x;
+ y = g->p.y;
+ break;
+ case GDISP_ROTATE_90:
+ x = g->p.y;
+ y = GDISP_SCREEN_HEIGHT - 1 - g->p.x;
+ break;
+ case GDISP_ROTATE_180:
+ x = GDISP_SCREEN_WIDTH - 1 - g->p.x;
+ y = GDISP_SCREEN_HEIGHT - 1 - g->p.y;
+ break;
+ case GDISP_ROTATE_270:
+ x = GDISP_SCREEN_HEIGHT - 1 - g->p.y;
+ y = g->p.x;
+ break;
}
return (RAM(g)[xyaddr(x, y)] & xybit(y)) ? White : Black;
}
-#endif
+# endif
LLDSPEC void gdisp_lld_blit_area(GDisplay *g) {
- uint8_t* buffer = (uint8_t*)g->p.ptr;
- int linelength = g->p.cx;
+ uint8_t *buffer = (uint8_t *)g->p.ptr;
+ int linelength = g->p.cx;
for (int i = 0; i < g->p.cy; i++) {
- unsigned dstx = g->p.x;
- unsigned dsty = g->p.y + i;
- unsigned srcx = g->p.x1;
- unsigned srcy = g->p.y1 + i;
+ unsigned dstx = g->p.x;
+ unsigned dsty = g->p.y + i;
+ unsigned srcx = g->p.x1;
+ unsigned srcy = g->p.y1 + i;
unsigned srcbit = srcy * g->p.x2 + srcx;
- for(int j=0; j < linelength; j++) {
- uint8_t src = buffer[srcbit / 8];
- uint8_t bit = 7-(srcbit % 8);
- uint8_t bitset = (src >> bit) & 1;
- uint8_t* dst = &(RAM(g)[xyaddr(dstx, dsty)]);
+ for (int j = 0; j < linelength; j++) {
+ uint8_t src = buffer[srcbit / 8];
+ uint8_t bit = 7 - (srcbit % 8);
+ uint8_t bitset = (src >> bit) & 1;
+ uint8_t *dst = &(RAM(g)[xyaddr(dstx, dsty)]);
if (bitset) {
*dst |= xybit(dsty);
- }
- else {
+ } else {
*dst &= ~xybit(dsty);
}
dstx++;
@@ -264,66 +269,64 @@ LLDSPEC void gdisp_lld_blit_area(GDisplay *g) {
g->flags |= GDISP_FLG_NEEDFLUSH;
}
-#if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL
+# if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL
LLDSPEC void gdisp_lld_control(GDisplay *g) {
- switch(g->p.x) {
- case GDISP_CONTROL_POWER:
- if (g->g.Powermode == (powermode_t)g->p.ptr)
- return;
- switch((powermode_t)g->p.ptr) {
- case powerOff:
- case powerSleep:
- case powerDeepSleep:
- acquire_bus(g);
- enter_cmd_mode(g);
- write_cmd(g, ST7565_DISPLAY_OFF);
- flush_cmd(g);
- release_bus(g);
- break;
- case powerOn:
- acquire_bus(g);
- enter_cmd_mode(g);
- write_cmd(g, ST7565_DISPLAY_ON);
- flush_cmd(g);
- release_bus(g);
- break;
- default:
+ switch (g->p.x) {
+ case GDISP_CONTROL_POWER:
+ if (g->g.Powermode == (powermode_t)g->p.ptr) return;
+ switch ((powermode_t)g->p.ptr) {
+ case powerOff:
+ case powerSleep:
+ case powerDeepSleep:
+ acquire_bus(g);
+ enter_cmd_mode(g);
+ write_cmd(g, ST7565_DISPLAY_OFF);
+ flush_cmd(g);
+ release_bus(g);
+ break;
+ case powerOn:
+ acquire_bus(g);
+ enter_cmd_mode(g);
+ write_cmd(g, ST7565_DISPLAY_ON);
+ flush_cmd(g);
+ release_bus(g);
+ break;
+ default:
+ return;
+ }
+ g->g.Powermode = (powermode_t)g->p.ptr;
return;
- }
- g->g.Powermode = (powermode_t)g->p.ptr;
- return;
case GDISP_CONTROL_ORIENTATION:
- if (g->g.Orientation == (orientation_t)g->p.ptr)
- return;
- switch((orientation_t)g->p.ptr) {
- /* Rotation is handled by the drawing routines */
- case GDISP_ROTATE_0:
- case GDISP_ROTATE_180:
- g->g.Height = GDISP_SCREEN_HEIGHT;
- g->g.Width = GDISP_SCREEN_WIDTH;
- break;
- case GDISP_ROTATE_90:
- case GDISP_ROTATE_270:
- g->g.Height = GDISP_SCREEN_WIDTH;
- g->g.Width = GDISP_SCREEN_HEIGHT;
- break;
- default:
- return;
+ if (g->g.Orientation == (orientation_t)g->p.ptr) return;
+ switch ((orientation_t)g->p.ptr) {
+ /* Rotation is handled by the drawing routines */
+ case GDISP_ROTATE_0:
+ case GDISP_ROTATE_180:
+ g->g.Height = GDISP_SCREEN_HEIGHT;
+ g->g.Width = GDISP_SCREEN_WIDTH;
+ break;
+ case GDISP_ROTATE_90:
+ case GDISP_ROTATE_270:
+ g->g.Height = GDISP_SCREEN_WIDTH;
+ g->g.Width = GDISP_SCREEN_HEIGHT;
+ break;
+ default:
+ return;
}
g->g.Orientation = (orientation_t)g->p.ptr;
return;
- case GDISP_CONTROL_CONTRAST:
- g->g.Contrast = (unsigned)g->p.ptr & 63;
- acquire_bus(g);
- enter_cmd_mode(g);
- write_cmd2(g, ST7565_CONTRAST, g->g.Contrast);
- flush_cmd(g);
- release_bus(g);
- return;
+ case GDISP_CONTROL_CONTRAST:
+ g->g.Contrast = (unsigned)g->p.ptr & 63;
+ acquire_bus(g);
+ enter_cmd_mode(g);
+ write_cmd2(g, ST7565_CONTRAST, g->g.Contrast);
+ flush_cmd(g);
+ release_bus(g);
+ return;
}
}
-#endif // GDISP_NEED_CONTROL
+# endif // GDISP_NEED_CONTROL
-#endif // GFX_USE_GDISP
+#endif // GFX_USE_GDISP
diff --git a/drivers/ugfx/gdisp/st7565/gdisp_lld_config.h b/drivers/ugfx/gdisp/st7565/gdisp_lld_config.h
index 4446bd38bc..9ab5daac1c 100644
--- a/drivers/ugfx/gdisp/st7565/gdisp_lld_config.h
+++ b/drivers/ugfx/gdisp/st7565/gdisp_lld_config.h
@@ -14,14 +14,14 @@
/* Driver hardware support. */
/*===========================================================================*/
-#define GDISP_HARDWARE_FLUSH TRUE // This controller requires flushing
-#define GDISP_HARDWARE_DRAWPIXEL TRUE
-#define GDISP_HARDWARE_PIXELREAD TRUE
-#define GDISP_HARDWARE_CONTROL TRUE
-#define GDISP_HARDWARE_BITFILLS TRUE
+# define GDISP_HARDWARE_FLUSH TRUE // This controller requires flushing
+# define GDISP_HARDWARE_DRAWPIXEL TRUE
+# define GDISP_HARDWARE_PIXELREAD TRUE
+# define GDISP_HARDWARE_CONTROL TRUE
+# define GDISP_HARDWARE_BITFILLS TRUE
-#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_MONO
+# define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_MONO
-#endif /* GFX_USE_GDISP */
+#endif /* GFX_USE_GDISP */
-#endif /* _GDISP_LLD_CONFIG_H */
+#endif /* _GDISP_LLD_CONFIG_H */
diff --git a/drivers/ugfx/gdisp/st7565/st7565.h b/drivers/ugfx/gdisp/st7565/st7565.h
index 24924ff050..3c77a88569 100644
--- a/drivers/ugfx/gdisp/st7565/st7565.h
+++ b/drivers/ugfx/gdisp/st7565/st7565.h
@@ -8,32 +8,32 @@
#ifndef _ST7565_H
#define _ST7565_H
-#define ST7565_CONTRAST 0x81
-#define ST7565_ALLON_NORMAL 0xA4
-#define ST7565_ALLON 0xA5
-#define ST7565_POSITIVE_DISPLAY 0xA6
-#define ST7565_INVERT_DISPLAY 0xA7
-#define ST7565_DISPLAY_OFF 0xAE
-#define ST7565_DISPLAY_ON 0xAF
+#define ST7565_CONTRAST 0x81
+#define ST7565_ALLON_NORMAL 0xA4
+#define ST7565_ALLON 0xA5
+#define ST7565_POSITIVE_DISPLAY 0xA6
+#define ST7565_INVERT_DISPLAY 0xA7
+#define ST7565_DISPLAY_OFF 0xAE
+#define ST7565_DISPLAY_ON 0xAF
-#define ST7565_LCD_BIAS_7 0xA3
-#define ST7565_LCD_BIAS_9 0xA2
+#define ST7565_LCD_BIAS_7 0xA3
+#define ST7565_LCD_BIAS_9 0xA2
-#define ST7565_ADC_NORMAL 0xA0
-#define ST7565_ADC_REVERSE 0xA1
+#define ST7565_ADC_NORMAL 0xA0
+#define ST7565_ADC_REVERSE 0xA1
-#define ST7565_COM_SCAN_INC 0xC0
-#define ST7565_COM_SCAN_DEC 0xC8
+#define ST7565_COM_SCAN_INC 0xC0
+#define ST7565_COM_SCAN_DEC 0xC8
-#define ST7565_START_LINE 0x40
-#define ST7565_PAGE 0xB0
-#define ST7565_COLUMN_MSB 0x10
-#define ST7565_COLUMN_LSB 0x00
-#define ST7565_RMW 0xE0
+#define ST7565_START_LINE 0x40
+#define ST7565_PAGE 0xB0
+#define ST7565_COLUMN_MSB 0x10
+#define ST7565_COLUMN_LSB 0x00
+#define ST7565_RMW 0xE0
-#define ST7565_RESISTOR_RATIO 0x20
-#define ST7565_POWER_CONTROL 0x28
+#define ST7565_RESISTOR_RATIO 0x20
+#define ST7565_POWER_CONTROL 0x28
-#define ST7565_RESET 0xE2
+#define ST7565_RESET 0xE2
#endif /* _ST7565_H */