WIP porting to the Model100 / GD32

f/keyboardio-model-100
Jesse Vincent 3 years ago
parent 303d4b7e3f
commit a021528b04
No known key found for this signature in database
GPG Key ID: 122F5DF7108E4046

@ -36,8 +36,12 @@ $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/boards.txt:
git://github.com/keyboardio/Kaleidoscope-Bundle-Keyboardio \ git://github.com/keyboardio/Kaleidoscope-Bundle-Keyboardio \
$(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio
-rm -d $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope -rm -d $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope
-rm -d $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/gd32/libraries/Kaleidoscope
ln -s $(KALEIDOSCOPE_DIR) $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope ln -s $(KALEIDOSCOPE_DIR) $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope
git clone -c core.symlinks=true \
--recurse-submodules=":(exclude)libraries/Kaleidoscope" \
--recurse-submodules=libraries/ \
git://github.com/keyboardio/ArduinoCore-GD32-Keyboardio $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/gd32
-rm -d $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/gd32/libraries/Kaleidoscope
ln -s $(KALEIDOSCOPE_DIR) $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/gd32/libraries/Kaleidoscope ln -s $(KALEIDOSCOPE_DIR) $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/gd32/libraries/Kaleidoscope
simulator-tests: simulator-tests:

@ -164,6 +164,7 @@ arduino-update-cores:
install-arduino-core-kaleidoscope: arduino-update-cores install-arduino-core-kaleidoscope: arduino-update-cores
$(QUIET) $(ARDUINO_CLI) core install "keyboardio:avr" $(QUIET) $(ARDUINO_CLI) core install "keyboardio:avr"
$(QUIET) $(ARDUINO_CLI) core install "keyboardio:gd32"
install-arduino-core-avr: arduino-update-cores install-arduino-core-avr: arduino-update-cores
$(QUIET) $(ARDUINO_CLI) core install "arduino:avr" $(QUIET) $(ARDUINO_CLI) core install "arduino:avr"

@ -25,9 +25,6 @@
#include <Arduino.h> #include <Arduino.h>
#include "Model100Side.h" #include "Model100Side.h"
extern "C" {
#include "kaleidoscope/device/keyboardio/twi.h"
}
#include "kaleidoscope/driver/color/GammaCorrection.h" #include "kaleidoscope/driver/color/GammaCorrection.h"
@ -44,7 +41,7 @@ Model100Side::Model100Side(byte setAd01) {
ad01 = setAd01; ad01 = setAd01;
addr = SCANNER_I2C_ADDR_BASE | ad01; addr = SCANNER_I2C_ADDR_BASE | ad01;
if (twi_uninitialized--) { if (twi_uninitialized--) {
twi_init(); // TODO twi_init();
} }
} }
@ -72,7 +69,7 @@ uint8_t Model100Side::controllerAddress() {
// https://www.arduino.cc/en/Reference/WireEndTransmission // https://www.arduino.cc/en/Reference/WireEndTransmission
byte Model100Side::setKeyscanInterval(byte delay) { byte Model100Side::setKeyscanInterval(byte delay) {
uint8_t data[] = {TWI_CMD_KEYSCAN_INTERVAL, delay}; uint8_t data[] = {TWI_CMD_KEYSCAN_INTERVAL, delay};
uint8_t result = twi_writeTo(addr, data, ELEMENTS(data), 1, 0); uint8_t result ; // TODO = twi_writeTo(addr, data, ELEMENTS(data), 1, 0);
return result; return result;
} }
@ -103,7 +100,7 @@ int Model100Side::readLEDSPIFrequency() {
// https://www.arduino.cc/en/Reference/WireEndTransmission // https://www.arduino.cc/en/Reference/WireEndTransmission
byte Model100Side::setLEDSPIFrequency(byte frequency) { byte Model100Side::setLEDSPIFrequency(byte frequency) {
uint8_t data[] = {TWI_CMD_LED_SPI_FREQUENCY, frequency}; uint8_t data[] = {TWI_CMD_LED_SPI_FREQUENCY, frequency};
uint8_t result = twi_writeTo(addr, data, ELEMENTS(data), 1, 0); uint8_t result ; // TODO = twi_writeTo(addr, data, ELEMENTS(data), 1, 0);
return result; return result;
} }
@ -115,7 +112,7 @@ int Model100Side::readRegister(uint8_t cmd) {
byte return_value = 0; byte return_value = 0;
uint8_t data[] = {cmd}; uint8_t data[] = {cmd};
uint8_t result = twi_writeTo(addr, data, ELEMENTS(data), 1, 0); uint8_t result ; // TODO = twi_writeTo(addr, data, ELEMENTS(data), 1, 0);
@ -127,7 +124,7 @@ int Model100Side::readRegister(uint8_t cmd) {
uint8_t rxBuffer[1]; uint8_t rxBuffer[1];
// perform blocking read into buffer // perform blocking read into buffer
uint8_t read = twi_readFrom(addr, rxBuffer, ELEMENTS(rxBuffer), true); uint8_t read ; // TODO = twi_readFrom(addr, rxBuffer, ELEMENTS(rxBuffer), true);
if (read > 0) { if (read > 0) {
return rxBuffer[0]; return rxBuffer[0];
} else { } else {
@ -143,7 +140,7 @@ bool Model100Side::readKeys() {
uint8_t rxBuffer[5]; uint8_t rxBuffer[5];
// perform blocking read into buffer // perform blocking read into buffer
uint8_t read = twi_readFrom(addr, rxBuffer, ELEMENTS(rxBuffer), true); uint8_t read ; // TODO = twi_readFrom(addr, rxBuffer, ELEMENTS(rxBuffer), true);
if (rxBuffer[0] == TWI_REPLY_KEYDATA) { if (rxBuffer[0] == TWI_REPLY_KEYDATA) {
keyData.rows[0] = rxBuffer[1]; keyData.rows[0] = rxBuffer[1];
keyData.rows[1] = rxBuffer[2]; keyData.rows[1] = rxBuffer[2];
@ -184,7 +181,7 @@ void Model100Side::sendLEDBank(byte bank) {
data[i + 1] = pgm_read_byte(&gamma8[c]); data[i + 1] = pgm_read_byte(&gamma8[c]);
} }
uint8_t result = twi_writeTo(addr, data, ELEMENTS(data), 1, 0); uint8_t result ; // TODO = twi_writeTo(addr, data, ELEMENTS(data), 1, 0);
} }
void Model100Side::setAllLEDsTo(cRGB color) { void Model100Side::setAllLEDsTo(cRGB color) {
@ -193,7 +190,7 @@ void Model100Side::setAllLEDsTo(cRGB color) {
pgm_read_byte(&gamma8[color.g]), pgm_read_byte(&gamma8[color.g]),
pgm_read_byte(&gamma8[color.r]) pgm_read_byte(&gamma8[color.r])
}; };
uint8_t result = twi_writeTo(addr, data, ELEMENTS(data), 1, 0); uint8_t result ; // TODO = twi_writeTo(addr, data, ELEMENTS(data), 1, 0);
} }
void Model100Side::setOneLEDTo(byte led, cRGB color) { void Model100Side::setOneLEDTo(byte led, cRGB color) {
@ -203,7 +200,7 @@ void Model100Side::setOneLEDTo(byte led, cRGB color) {
pgm_read_byte(&gamma8[color.g]), pgm_read_byte(&gamma8[color.g]),
pgm_read_byte(&gamma8[color.r]) pgm_read_byte(&gamma8[color.r])
}; };
uint8_t result = twi_writeTo(addr, data, ELEMENTS(data), 1, 0); uint8_t result ; // TODO = twi_writeTo(addr, data, ELEMENTS(data), 1, 0);
} }

Loading…
Cancel
Save