device/dygma/raise: Rename raise::Hand to raise::RaiseSide

We're going to merge KeyboardioScanner into Kaleidoscope as a driver, but we
can't name that model01::Hand, because then we have a filename conflict due to
our use of static archiving during linking. To avoid that, both will use a
similar, but unique naming pattern, and raise::Hand becomes raise::RaiseSide
instead.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/994/head
Gergely Nagy 4 years ago committed by Jesse Vincent
parent 2646b88e0e
commit dc21d751e2
No known key found for this signature in database
GPG Key ID: 122F5DF7108E4046

@ -43,8 +43,8 @@ namespace dygma {
/********* RaiseHands *********/ /********* RaiseHands *********/
struct RaiseHands { struct RaiseHands {
static raise::Hand leftHand; static raise::RaiseSide leftHand;
static raise::Hand rightHand; static raise::RaiseSide rightHand;
static void setup(); static void setup();
static void initializeSides(); static void initializeSides();
@ -68,8 +68,8 @@ struct RaiseHands {
static constexpr uint8_t iso_only_led_ = 19; static constexpr uint8_t iso_only_led_ = 19;
}; };
raise::Hand RaiseHands::leftHand(0); raise::RaiseSide RaiseHands::leftHand(0);
raise::Hand RaiseHands::rightHand(1); raise::RaiseSide RaiseHands::rightHand(1);
uint8_t RaiseHands::layout; uint8_t RaiseHands::layout;
bool RaiseHands::side_power_; bool RaiseHands::side_power_;
uint16_t RaiseHands::settings_base_; uint16_t RaiseHands::settings_base_;

@ -21,7 +21,7 @@
#ifdef ARDUINO_SAMD_RAISE #ifdef ARDUINO_SAMD_RAISE
#include <Arduino.h> #include <Arduino.h>
#include "kaleidoscope/device/dygma/raise/Hand.h" #include "kaleidoscope/device/dygma/raise/RaiseSide.h"
#define CRGB(r,g,b) (cRGB){b, g, r} #define CRGB(r,g,b) (cRGB){b, g, r}

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* kaleidoscope::device::dygma::Raise -- Kaleidoscope device plugin for Dygma Raise * kaleidoscope::device::dygma::Raise -- Kaleidoscope device plugin for Dygma Raise
* Copyright (C) 2017-2019 Keyboard.io, Inc * Copyright (C) 2017-2020 Keyboard.io, Inc
* Copyright (C) 2017-2020 Dygma Lab S.L. * Copyright (C) 2017-2020 Dygma Lab S.L.
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
@ -19,7 +19,7 @@
#ifdef ARDUINO_SAMD_RAISE #ifdef ARDUINO_SAMD_RAISE
#include <Arduino.h> #include <Arduino.h>
#include "Hand.h" #include "RaiseSide.h"
#include "kaleidoscope/driver/color/GammaCorrection.h" #include "kaleidoscope/driver/color/GammaCorrection.h"
@ -66,7 +66,7 @@ namespace raise {
#define ELEMENTS(arr) (sizeof(arr) / sizeof((arr)[0])) #define ELEMENTS(arr) (sizeof(arr) / sizeof((arr)[0]))
// Returns the relative controller addresss. The expected range is 0-3 // Returns the relative controller addresss. The expected range is 0-3
uint8_t Hand::controllerAddress() { uint8_t RaiseSide::controllerAddress() {
return ad01_; return ad01_;
} }
@ -87,42 +87,42 @@ uint8_t Hand::controllerAddress() {
// //
// returns the Wire.endTransmission code (0 = success) // returns the Wire.endTransmission code (0 = success)
// https://www.arduino.cc/en/Reference/WireEndTransmission // https://www.arduino.cc/en/Reference/WireEndTransmission
byte Hand::setKeyscanInterval(byte delay) { byte RaiseSide::setKeyscanInterval(byte delay) {
uint8_t data[] = {TWI_CMD_KEYSCAN_INTERVAL, delay}; uint8_t data[] = {TWI_CMD_KEYSCAN_INTERVAL, delay};
return twi_.writeTo(data, ELEMENTS(data)); return twi_.writeTo(data, ELEMENTS(data));
} }
// returns -1 on error, otherwise returns the scanner version integer // returns -1 on error, otherwise returns the scanner version integer
int Hand::readVersion() { int RaiseSide::readVersion() {
return readRegister(TWI_CMD_VERSION); return readRegister(TWI_CMD_VERSION);
} }
// returns -1 on error, otherwise returns the sled version integer // returns -1 on error, otherwise returns the sled version integer
int Hand::readSLEDVersion() { int RaiseSide::readSLEDVersion() {
return readRegister(TWI_CMD_SLED_STATUS); return readRegister(TWI_CMD_SLED_STATUS);
} }
// returns -1 on error, otherwise returns the sled current settings // returns -1 on error, otherwise returns the sled current settings
int Hand::readSLEDCurrent() { int RaiseSide::readSLEDCurrent() {
return readRegister(TWI_CMD_SLED_CURRENT); return readRegister(TWI_CMD_SLED_CURRENT);
} }
byte Hand::setSLEDCurrent(byte current) { byte RaiseSide::setSLEDCurrent(byte current) {
uint8_t data[] = {TWI_CMD_SLED_CURRENT, current}; uint8_t data[] = {TWI_CMD_SLED_CURRENT, current};
return twi_.writeTo(data, ELEMENTS(data)); return twi_.writeTo(data, ELEMENTS(data));
} }
// returns -1 on error, otherwise returns the scanner keyscan interval // returns -1 on error, otherwise returns the scanner keyscan interval
int Hand::readKeyscanInterval() { int RaiseSide::readKeyscanInterval() {
return readRegister(TWI_CMD_KEYSCAN_INTERVAL); return readRegister(TWI_CMD_KEYSCAN_INTERVAL);
} }
// returns -1 on error, otherwise returns the layout (ANSI/ISO) setting // returns -1 on error, otherwise returns the layout (ANSI/ISO) setting
int Hand::readLayout() { int RaiseSide::readLayout() {
return readRegister(TWI_CMD_LAYOUT); return readRegister(TWI_CMD_LAYOUT);
} }
// returns -1 on error, otherwise returns the LED SPI Frequncy // returns -1 on error, otherwise returns the LED SPI Frequncy
int Hand::readLEDSPIFrequency() { int RaiseSide::readLEDSPIFrequency() {
return readRegister(TWI_CMD_LED_SPI_FREQUENCY); return readRegister(TWI_CMD_LED_SPI_FREQUENCY);
} }
@ -131,13 +131,13 @@ int Hand::readLEDSPIFrequency() {
// //
// returns the Wire.endTransmission code (0 = success) // returns the Wire.endTransmission code (0 = success)
// https://www.arduino.cc/en/Reference/WireEndTransmission // https://www.arduino.cc/en/Reference/WireEndTransmission
byte Hand::setLEDSPIFrequency(byte frequency) { byte RaiseSide::setLEDSPIFrequency(byte frequency) {
uint8_t data[] = {TWI_CMD_LED_SPI_FREQUENCY, frequency}; uint8_t data[] = {TWI_CMD_LED_SPI_FREQUENCY, frequency};
return twi_.writeTo(data, ELEMENTS(data)); return twi_.writeTo(data, ELEMENTS(data));
} }
// returns -1 on error, otherwise returns the value of the hall sensor integer // returns -1 on error, otherwise returns the value of the hall sensor integer
int Hand::readJoint() { int RaiseSide::readJoint() {
byte return_value = 0; byte return_value = 0;
uint8_t data[] = {TWI_CMD_JOINED}; uint8_t data[] = {TWI_CMD_JOINED};
@ -159,7 +159,7 @@ int Hand::readJoint() {
} }
} }
int Hand::readRegister(uint8_t cmd) { int RaiseSide::readRegister(uint8_t cmd) {
byte return_value = 0; byte return_value = 0;
uint8_t data[] = {cmd}; uint8_t data[] = {cmd};
@ -182,13 +182,13 @@ int Hand::readRegister(uint8_t cmd) {
} }
// gives information on the key that was just pressed or released. // gives information on the key that was just pressed or released.
bool Hand::readKeys() { bool RaiseSide::readKeys() {
uint8_t rxBuffer[6] = {0, 0, 0, 0, 0, 0}; uint8_t rxBuffer[6] = {0, 0, 0, 0, 0, 0};
// perform blocking read into buffer // perform blocking read into buffer
uint8_t result = twi_.readFrom(rxBuffer, ELEMENTS(rxBuffer)); uint8_t result = twi_.readFrom(rxBuffer, ELEMENTS(rxBuffer));
// if result isn't 6? this can happens if slave nacks while trying to read // if result isn't 6? this can happens if slave nacks while trying to read
Hand::online = (result == 6) ? true : false; RaiseSide::online = (result == 6) ? true : false;
if (result != 6) if (result != 6)
// could also try reset pressed keys here // could also try reset pressed keys here
@ -206,11 +206,11 @@ bool Hand::readKeys() {
} }
} }
keydata_t Hand::getKeyData() { keydata_t RaiseSide::getKeyData() {
return key_data_; return key_data_;
} }
void Hand::sendLEDData() { void RaiseSide::sendLEDData() {
sendLEDBank(next_led_bank_++); sendLEDBank(next_led_bank_++);
if (next_led_bank_ == LED_BANKS) { if (next_led_bank_ == LED_BANKS) {
next_led_bank_ = 0; next_led_bank_ = 0;
@ -219,7 +219,7 @@ void Hand::sendLEDData() {
auto constexpr gamma8 = kaleidoscope::driver::color::gamma_correction; auto constexpr gamma8 = kaleidoscope::driver::color::gamma_correction;
void Hand::sendLEDBank(uint8_t bank) { void RaiseSide::sendLEDBank(uint8_t bank) {
uint8_t data[LED_BYTES_PER_BANK + 1]; // + 1 for the update LED command itself uint8_t data[LED_BYTES_PER_BANK + 1]; // + 1 for the update LED command itself
data[0] = TWI_CMD_LED_BASE + bank; data[0] = TWI_CMD_LED_BASE + bank;
for (uint8_t i = 0 ; i < LED_BYTES_PER_BANK; i++) { for (uint8_t i = 0 ; i < LED_BYTES_PER_BANK; i++) {

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* kaleidoscope::device::dygma::Raise -- Kaleidoscope device plugin for Dygma Raise * kaleidoscope::device::dygma::Raise -- Kaleidoscope device plugin for Dygma Raise
* Copyright (C) 2017-2019 Keyboard.io, Inc * Copyright (C) 2017-2020 Keyboard.io, Inc
* Copyright (C) 2017-2019 Dygma Lab S.L. * Copyright (C) 2017-2019 Dygma Lab S.L.
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
@ -54,9 +54,9 @@ typedef union {
uint64_t all; uint64_t all;
} keydata_t; } keydata_t;
class Hand { class RaiseSide {
public: public:
explicit Hand(byte ad01) : ad01_(ad01), twi_(i2c_addr_base_ | ad01) {} explicit RaiseSide(byte ad01) : ad01_(ad01), twi_(i2c_addr_base_ | ad01) {}
int readVersion(); int readVersion();
int readSLEDVersion(); int readSLEDVersion();
Loading…
Cancel
Save