mirror of
https://github.com/esphome/esphome.git
synced 2024-12-02 03:34:18 +01:00
added gpio
This commit is contained in:
parent
dad38bb220
commit
7ab2a0cfe5
3 changed files with 270 additions and 123 deletions
|
@ -1,13 +1,23 @@
|
|||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome import pins
|
||||
from esphome.components import i2c
|
||||
from esphome.const import CONF_FREQUENCY, CONF_ID
|
||||
from esphome.const import CONF_ID, CONF_NUMBER, CONF_MODE, CONF_INVERTED
|
||||
|
||||
DEPENDENCIES = ['i2c']
|
||||
MULTI_CONF = True
|
||||
|
||||
sx1509_ns = cg.esphome_ns.namespace('sx1509')
|
||||
SX1509GPIOMode = sx1509_ns.enum('SX1509GPIOMode')
|
||||
SX1509_GPIO_MODES = {
|
||||
'INPUT': SX1509GPIOMode.SX1509_INPUT,
|
||||
'INPUT_PULLUP': SX1509GPIOMode.SX1509_INPUT_PULLUP,
|
||||
'OUTPUT': SX1509GPIOMode.SX1509_OUTPUT,
|
||||
'BREATHE_OUTPUT' : SX1509GPIOMode.SX1509_BREATHE_OUTPUT
|
||||
}
|
||||
|
||||
SX1509Component = sx1509_ns.class_('SX1509Component', cg.Component, i2c.I2CDevice)
|
||||
SX1509GPIOPin = sx1509_ns.class_('SX1509GPIOPin', cg.GPIOPin)
|
||||
|
||||
CONFIG_SCHEMA = cv.Schema({
|
||||
cv.GenerateID(): cv.declare_id(SX1509Component),
|
||||
|
@ -18,3 +28,25 @@ def to_code(config):
|
|||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
yield cg.register_component(var, config)
|
||||
yield i2c.register_i2c_device(var, config)
|
||||
|
||||
|
||||
CONF_SX1509 = 'sx1509'
|
||||
SX1509_OUTPUT_PIN_SCHEMA = cv.Schema({
|
||||
cv.Required(CONF_SX1509): cv.use_id(SX1509Component),
|
||||
cv.Required(CONF_NUMBER): cv.int_,
|
||||
cv.Optional(CONF_MODE, default="OUTPUT"): cv.enum(SX1509_GPIO_MODES, upper=True),
|
||||
cv.Optional(CONF_INVERTED, default=False): cv.boolean,
|
||||
})
|
||||
SX1509_INPUT_PIN_SCHEMA = cv.Schema({
|
||||
cv.Required(CONF_SX1509): cv.use_id(SX1509Component),
|
||||
cv.Required(CONF_NUMBER): cv.int_,
|
||||
cv.Optional(CONF_MODE, default="INPUT"): cv.enum(SX1509_GPIO_MODES, upper=True),
|
||||
cv.Optional(CONF_INVERTED, default=False): cv.boolean,
|
||||
})
|
||||
|
||||
|
||||
@pins.PIN_SCHEMA_REGISTRY.register(CONF_SX1509,
|
||||
(SX1509_OUTPUT_PIN_SCHEMA, SX1509_INPUT_PIN_SCHEMA))
|
||||
def sx1509_pin_to_code(config):
|
||||
parent = yield cg.get_variable(config[CONF_SX1509])
|
||||
yield SX1509GPIOPin.new(parent, config[CONF_NUMBER], config[CONF_MODE], config[CONF_INVERTED])
|
||||
|
|
|
@ -41,99 +41,110 @@ void SX1509Component::dump_config() {
|
|||
|
||||
void SX1509Component::loop() {}
|
||||
|
||||
SX1509FloatOutputChannel *
|
||||
SX1509Component::create_float_output_channel(uint8_t channel) {
|
||||
ESP_LOGD(TAG, "Set pin mode for channel %d", channel);
|
||||
auto *c = new SX1509FloatOutputChannel(this, channel);
|
||||
SX1509FloatOutputChannel *SX1509Component::create_float_output_channel(uint8_t pin) {
|
||||
ESP_LOGD(TAG, "Set pin mode for pin %d", pin);
|
||||
auto *c = new SX1509FloatOutputChannel(this, pin);
|
||||
float_output_channels_.push_back(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
void SX1509Component::digitalWrite(uint8_t channel, uint8_t highLow) {
|
||||
uint16_t tempRegDir = 0;
|
||||
uint8_t SX1509Component::digital_read(uint8_t pin) {
|
||||
uint16_t tempRegDir;
|
||||
this->read_byte_16(REG_DIR_B, &tempRegDir);
|
||||
|
||||
if ((0xFFFF ^ tempRegDir) &
|
||||
(1 << channel)) // If the pin is an output, write high/low
|
||||
{
|
||||
uint16_t tempRegData = 0;
|
||||
if (tempRegDir & (1 << pin)) {
|
||||
uint16_t tempRegData;
|
||||
this->read_byte_16(REG_DATA_B, &tempRegData);
|
||||
if (highLow)
|
||||
tempRegData |= (1 << channel);
|
||||
if (tempRegData & (1 << pin))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SX1509Component::digital_write(uint8_t pin, uint8_t bit_value) {
|
||||
uint16_t temp_reg_dir = 0;
|
||||
this->read_byte_16(REG_DIR_B, &temp_reg_dir);
|
||||
|
||||
if ((0xFFFF ^ temp_reg_dir) & (1 << pin)) // If the pin is an output, write high/low
|
||||
{
|
||||
uint16_t temp_reg_data = 0;
|
||||
this->read_byte_16(REG_DATA_B, &temp_reg_data);
|
||||
if (bit_value)
|
||||
temp_reg_data |= (1 << pin);
|
||||
else
|
||||
tempRegData &= ~(1 << channel);
|
||||
this->write_byte_16(REG_DATA_B, tempRegData);
|
||||
temp_reg_data &= ~(1 << pin);
|
||||
this->write_byte_16(REG_DATA_B, temp_reg_data);
|
||||
} else // Otherwise the pin is an input, pull-up/down
|
||||
{
|
||||
uint16_t tempPullUp;
|
||||
this->read_byte_16(REG_PULL_UP_B, &tempPullUp);
|
||||
uint16_t tempPullDown;
|
||||
this->read_byte_16(REG_PULL_DOWN_B, &tempPullDown);
|
||||
uint16_t temp_pullup;
|
||||
this->read_byte_16(REG_PULL_UP_B, &temp_pullup);
|
||||
uint16_t temp_pull_down;
|
||||
this->read_byte_16(REG_PULL_DOWN_B, &temp_pull_down);
|
||||
|
||||
if (highLow) // if HIGH, do pull-up, disable pull-down
|
||||
if (bit_value) // if HIGH, do pull-up, disable pull-down
|
||||
{
|
||||
tempPullUp |= (1 << channel);
|
||||
tempPullDown &= ~(1 << channel);
|
||||
this->write_byte_16(REG_PULL_UP_B, tempPullUp);
|
||||
this->write_byte_16(REG_PULL_DOWN_B, tempPullDown);
|
||||
temp_pullup |= (1 << pin);
|
||||
temp_pull_down &= ~(1 << pin);
|
||||
this->write_byte_16(REG_PULL_UP_B, temp_pullup);
|
||||
this->write_byte_16(REG_PULL_DOWN_B, temp_pull_down);
|
||||
} else // If LOW do pull-down, disable pull-up
|
||||
{
|
||||
tempPullDown |= (1 << channel);
|
||||
tempPullUp &= ~(1 << channel);
|
||||
this->write_byte_16(REG_PULL_UP_B, tempPullUp);
|
||||
this->write_byte_16(REG_PULL_DOWN_B, tempPullDown);
|
||||
temp_pull_down |= (1 << pin);
|
||||
temp_pullup &= ~(1 << pin);
|
||||
this->write_byte_16(REG_PULL_UP_B, temp_pullup);
|
||||
this->write_byte_16(REG_PULL_DOWN_B, temp_pull_down);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SX1509Component::pinMode(uint8_t channel, uint8_t inOut) {
|
||||
// The SX1509 RegDir registers: REG_DIR_B, REG_DIR_A
|
||||
// 0: IO is configured as an output
|
||||
// 1: IO is configured as an input
|
||||
uint8_t modeBit;
|
||||
if ((inOut == OUTPUT) || (inOut == ANALOG_OUTPUT))
|
||||
modeBit = 0;
|
||||
void SX1509Component::pin_mode(uint8_t pin, uint8_t mode) {
|
||||
uint8_t mode_bit;
|
||||
if ((mode == OUTPUT) || (mode == ANALOG_OUTPUT) || (mode == BREATHE_OUTPUT))
|
||||
mode_bit = 0;
|
||||
else
|
||||
modeBit = 1;
|
||||
mode_bit = 1;
|
||||
|
||||
uint16_t tempRegDir = 0;
|
||||
this->read_byte_16(REG_DIR_B, &tempRegDir);
|
||||
uint16_t temp_reg_dir = 0;
|
||||
this->read_byte_16(REG_DIR_B, &temp_reg_dir);
|
||||
|
||||
if (modeBit)
|
||||
tempRegDir |= (1 << channel);
|
||||
if (mode_bit)
|
||||
temp_reg_dir |= (1 << pin);
|
||||
else
|
||||
tempRegDir &= ~(1 << channel);
|
||||
temp_reg_dir &= ~(1 << pin);
|
||||
|
||||
this->write_byte_16(REG_DIR_B, tempRegDir);
|
||||
this->write_byte_16(REG_DIR_B, temp_reg_dir);
|
||||
|
||||
// If INPUT_PULLUP was called, set up the pullup too:
|
||||
if (inOut == INPUT_PULLUP)
|
||||
digitalWrite(channel, HIGH);
|
||||
if (mode == INPUT_PULLUP)
|
||||
digital_write(pin, HIGH);
|
||||
|
||||
if (inOut == ANALOG_OUTPUT) {
|
||||
ledDriverInit(channel);
|
||||
if (mode == ANALOG_OUTPUT) {
|
||||
led_driver_init(pin);
|
||||
}
|
||||
|
||||
if (mode == BREATHE_OUTPUT) {
|
||||
breathe(pin, 1000, 1000, 1000, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
void SX1509Component::ledDriverInit(uint8_t channel, uint8_t freq, bool log) {
|
||||
void SX1509Component::led_driver_init(uint8_t pin, uint8_t freq, bool log) {
|
||||
uint16_t tempWord;
|
||||
uint8_t tempByte;
|
||||
|
||||
// Disable input buffer
|
||||
// Writing a 1 to the pin bit will disable that pins input buffer
|
||||
this->read_byte_16(REG_INPUT_DISABLE_B, &tempWord);
|
||||
tempWord |= (1 << channel);
|
||||
tempWord |= (1 << pin);
|
||||
this->write_byte_16(REG_INPUT_DISABLE_B, tempWord);
|
||||
|
||||
// Disable pull-up
|
||||
// Writing a 0 to the pin bit will disable that pull-up resistor
|
||||
this->read_byte_16(REG_PULL_UP_B, &tempWord);
|
||||
tempWord &= ~(1 << channel);
|
||||
tempWord &= ~(1 << pin);
|
||||
this->write_byte_16(REG_PULL_UP_B, tempWord);
|
||||
|
||||
// Set direction to output (REG_DIR_B)
|
||||
this->read_byte_16(REG_DIR_B, &tempWord);
|
||||
tempWord &= ~(1 << channel); // 0=output
|
||||
tempWord &= ~(1 << pin); // 0=output
|
||||
this->write_byte_16(REG_DIR_B, tempWord);
|
||||
|
||||
// Enable oscillator (REG_CLOCK)
|
||||
|
@ -157,24 +168,60 @@ void SX1509Component::ledDriverInit(uint8_t channel, uint8_t freq, bool log) {
|
|||
{
|
||||
_clkX = 2000000.0 / (1 << (1 - 1)); // Update private clock variable
|
||||
|
||||
byte freq = (1 & 0x07) << 4; // freq should only be 3 bits from 6:4
|
||||
uint8_t freq = (1 & 0x07) << 4; // freq should only be 3 bits from 6:4
|
||||
tempByte |= freq;
|
||||
}
|
||||
this->write_byte(REG_MISC, tempByte);
|
||||
|
||||
// Enable LED driver operation (REG_LED_DRIVER_ENABLE)
|
||||
this->read_byte_16(REG_LED_DRIVER_ENABLE_B, &tempWord);
|
||||
tempWord |= (1 << channel);
|
||||
tempWord |= (1 << pin);
|
||||
this->write_byte_16(REG_LED_DRIVER_ENABLE_B, tempWord);
|
||||
|
||||
// Set REG_DATA bit low ~ LED driver started
|
||||
this->read_byte_16(REG_DATA_B, &tempWord);
|
||||
tempWord &= ~(1 << channel);
|
||||
tempWord &= ~(1 << pin);
|
||||
this->write_byte_16(REG_DATA_B, tempWord);
|
||||
}
|
||||
|
||||
void SX1509Component::clock(byte oscSource, byte oscPinFunction,
|
||||
byte oscFreqOut, byte oscDivider) {
|
||||
void SX1509Component::breathe(uint8_t pin, unsigned long tOn, unsigned long tOff, unsigned long rise,
|
||||
unsigned long fall, uint8_t onInt, uint8_t offInt, bool log) {
|
||||
offInt = constrain(offInt, 0, 7);
|
||||
|
||||
uint8_t onReg = calculate_led_t_register(tOn);
|
||||
uint8_t offReg = calculate_led_t_register(tOff);
|
||||
|
||||
uint8_t riseTime = calculate_slope_register(rise, onInt, offInt);
|
||||
uint8_t fallTime = calculate_slope_register(fall, onInt, offInt);
|
||||
|
||||
setup_blink(pin, onReg, offReg, onInt, offInt, riseTime, fallTime, log);
|
||||
}
|
||||
|
||||
void SX1509Component::setup_blink(uint8_t pin, uint8_t tOn, uint8_t tOff, uint8_t onIntensity, uint8_t offIntensity,
|
||||
uint8_t tRise, uint8_t tFall, bool log) {
|
||||
led_driver_init(pin, log);
|
||||
|
||||
tOn &= 0x1F; // tOn should be a 5-bit value
|
||||
tOff &= 0x1F; // tOff should be a 5-bit value
|
||||
offIntensity &= 0x07;
|
||||
// Write the time on
|
||||
this->write_byte(REG_T_ON[pin], tOn);
|
||||
|
||||
this->write_byte(REG_OFF[pin], (tOff << 3) | offIntensity);
|
||||
|
||||
this->write_byte(REG_I_ON[pin], onIntensity);
|
||||
|
||||
tRise &= 0x1F;
|
||||
tFall &= 0x1F;
|
||||
|
||||
if (REG_T_RISE[pin] != 0xFF)
|
||||
this->write_byte(REG_T_RISE[pin], tRise);
|
||||
|
||||
if (REG_T_FALL[pin] != 0xFF)
|
||||
this->write_byte(REG_T_FALL[pin], tFall);
|
||||
}
|
||||
|
||||
void SX1509Component::clock(byte oscSource, byte oscPinFunction, byte oscFreqOut, byte oscDivider) {
|
||||
oscSource = (oscSource & 0b11) << 5; // 2-bit value, bits 6:5
|
||||
oscPinFunction = (oscPinFunction & 1) << 4; // 1-bit value bit 4
|
||||
oscFreqOut = (oscFreqOut & 0b1111); // 4-bit value, bits 3:0
|
||||
|
@ -192,9 +239,55 @@ void SX1509Component::clock(byte oscSource, byte oscPinFunction,
|
|||
this->write_byte(REG_MISC, regMisc);
|
||||
}
|
||||
|
||||
void SX1509Component::set_channel_value_(uint8_t channel, uint8_t iOn) {
|
||||
ESP_LOGD(TAG, "set_channel_value_ for channel %d to %d", channel, iOn);
|
||||
this->write_byte(REG_I_ON[channel], iOn);
|
||||
void SX1509Component::set_pin_value_(uint8_t pin, uint8_t iOn) {
|
||||
ESP_LOGD(TAG, "set_pin_value_ for pin %d to %d", pin, iOn);
|
||||
this->write_byte(REG_I_ON[pin], iOn);
|
||||
}
|
||||
|
||||
uint8_t SX1509Component::calculate_led_t_register(uint16_t ms) {
|
||||
uint16_t regOn1, regOn2;
|
||||
float timeOn1, timeOn2;
|
||||
|
||||
if (_clkX == 0)
|
||||
return 0;
|
||||
|
||||
regOn1 = (float) (ms / 1000.0) / (64.0 * 255.0 / (float) _clkX);
|
||||
regOn2 = regOn1 / 8;
|
||||
regOn1 = constrain(regOn1, 1, 15);
|
||||
regOn2 = constrain(regOn2, 16, 31);
|
||||
|
||||
timeOn1 = 64.0 * regOn1 * 255.0 / _clkX * 1000.0;
|
||||
timeOn2 = 512.0 * regOn2 * 255.0 / _clkX * 1000.0;
|
||||
|
||||
if (abs(timeOn1 - ms) < abs(timeOn2 - ms))
|
||||
return regOn1;
|
||||
else
|
||||
return regOn2;
|
||||
}
|
||||
|
||||
uint8_t SX1509Component::calculate_slope_register(uint16_t ms, uint8_t onIntensity, uint8_t offIntensity) {
|
||||
uint16_t regSlope1, regSlope2;
|
||||
float regTime1, regTime2;
|
||||
|
||||
if (_clkX == 0)
|
||||
return 0;
|
||||
|
||||
float tFactor = ((float) onIntensity - (4.0 * (float)offIntensity)) * 255.0 / (float) _clkX;
|
||||
float timeS = float(ms) / 1000.0;
|
||||
|
||||
regSlope1 = timeS / tFactor;
|
||||
regSlope2 = regSlope1 / 16;
|
||||
|
||||
regSlope1 = constrain(regSlope1, 1, 15);
|
||||
regSlope2 = constrain(regSlope2, 16, 31);
|
||||
|
||||
regTime1 = regSlope1 * tFactor * 1000.0;
|
||||
regTime2 = 16 * regTime1;
|
||||
|
||||
if (abs(regTime1 - ms) < abs(regTime2 - ms))
|
||||
return regSlope1;
|
||||
else
|
||||
return regSlope2;
|
||||
}
|
||||
|
||||
void SX1509FloatOutputChannel::write_state(float state) {
|
||||
|
@ -202,12 +295,17 @@ void SX1509FloatOutputChannel::write_state(float state) {
|
|||
const uint16_t max_duty = 255;
|
||||
const float duty_rounded = roundf(state * max_duty);
|
||||
auto duty = static_cast<uint16_t>(duty_rounded);
|
||||
this->parent_->set_channel_value_(this->channel_, duty);
|
||||
this->parent_->set_pin_value_(this->pin_, duty);
|
||||
}
|
||||
|
||||
void SX1509FloatOutputChannel::setup_channel() {
|
||||
this->parent_->pinMode(this->channel_, ANALOG_OUTPUT);
|
||||
}
|
||||
void SX1509FloatOutputChannel::setup_channel() { this->parent_->pin_mode(this->pin_, ANALOG_OUTPUT); }
|
||||
|
||||
SX1509GPIOPin::SX1509GPIOPin(SX1509Component *parent, uint8_t pin, uint8_t mode, bool inverted)
|
||||
: GPIOPin(pin, mode, inverted), parent_(parent) {}
|
||||
void SX1509GPIOPin::setup() { this->pin_mode(this->mode_); }
|
||||
void SX1509GPIOPin::pin_mode(uint8_t mode) { this->parent_->pin_mode(this->pin_, mode); }
|
||||
bool SX1509GPIOPin::digital_read() { return this->parent_->digital_read(this->pin_) != this->inverted_; }
|
||||
void SX1509GPIOPin::digital_write(bool value) { this->parent_->digital_write(this->pin_, value != this->inverted_); }
|
||||
|
||||
} // namespace sx1509
|
||||
} // namespace esphome
|
||||
|
|
|
@ -19,47 +19,74 @@ namespace sx1509 {
|
|||
#define SOFTWARE_RESET 0
|
||||
#define HARDWARE_RESET 1
|
||||
|
||||
#define ANALOG_OUTPUT 0x3 // To set a pin mode for PWM output
|
||||
#define ANALOG_OUTPUT 0x03 // To set a pin mode for PWM output
|
||||
#define BREATHE_OUTPUT 0x04
|
||||
|
||||
/// Modes for MCP23017 pins
|
||||
enum SX1509GPIOMode : uint8_t {
|
||||
SX1509_INPUT = INPUT, // 0x00
|
||||
SX1509_INPUT_PULLUP = INPUT_PULLUP, // 0x02
|
||||
SX1509_OUTPUT = OUTPUT, // 0x01
|
||||
SX1509_BREATHE_OUTPUT = BREATHE_OUTPUT // 0x04
|
||||
};
|
||||
|
||||
class SX1509Component;
|
||||
|
||||
class SX1509FloatOutputChannel : public output::FloatOutput {
|
||||
public:
|
||||
SX1509FloatOutputChannel(SX1509Component *parent, uint8_t channel)
|
||||
: parent_(parent), channel_(channel) {}
|
||||
public:
|
||||
SX1509FloatOutputChannel(SX1509Component *parent, uint8_t pin) : parent_(parent), pin_(pin) {}
|
||||
void setup_channel();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void write_state(float state) override;
|
||||
|
||||
SX1509Component *parent_;
|
||||
uint8_t channel_;
|
||||
uint8_t pin_;
|
||||
};
|
||||
|
||||
class SX1509GPIOPin : public GPIOPin {
|
||||
public:
|
||||
SX1509GPIOPin(SX1509Component *parent, uint8_t pin, uint8_t mode, bool inverted = false);
|
||||
|
||||
void setup() override;
|
||||
void pin_mode(uint8_t mode) override;
|
||||
bool digital_read() override;
|
||||
void digital_write(bool value) override;
|
||||
|
||||
protected:
|
||||
SX1509Component *parent_;
|
||||
};
|
||||
|
||||
/// SX1509 float output component.
|
||||
class SX1509Component : public Component, public i2c::I2CDevice {
|
||||
|
||||
public:
|
||||
public:
|
||||
SX1509Component() {}
|
||||
|
||||
SX1509FloatOutputChannel *create_float_output_channel(uint8_t channel);
|
||||
SX1509FloatOutputChannel *create_float_output_channel(uint8_t pin);
|
||||
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
float get_setup_priority() const override { return setup_priority::HARDWARE; }
|
||||
void loop() override;
|
||||
void pin_mode(uint8_t pin, uint8_t inOut);
|
||||
void led_driver_init(uint8_t pin, uint8_t freq = 1, bool log = false);
|
||||
void clock(uint8_t oscSource = 2, uint8_t oscDivider = 1, uint8_t oscPinFunction = 0, uint8_t oscFreqOut = 0);
|
||||
void digital_write(uint8_t pin, uint8_t highLow);
|
||||
uint8_t digital_read(uint8_t pin);
|
||||
void set_pin_value_(uint8_t pin, uint8_t iOn);
|
||||
|
||||
protected:
|
||||
void setup_blink(uint8_t pin, uint8_t tOn, uint8_t toff, uint8_t onIntensity = 255, uint8_t offIntensity = 0,
|
||||
uint8_t tRise = 0, uint8_t tFall = 0, bool log = false);
|
||||
void blink(uint8_t pin, unsigned long tOn, unsigned long tOff, uint8_t onIntensity = 255, uint8_t offIntensity = 0);
|
||||
void breathe(uint8_t pin, unsigned long tOn, unsigned long tOff, unsigned long rise, unsigned long fall,
|
||||
uint8_t onInt = 255, uint8_t offInt = 0, bool log = LINEAR);
|
||||
uint8_t calculate_led_t_register(uint16_t ms);
|
||||
uint8_t calculate_slope_register(uint16_t ms, uint8_t onIntensity, uint8_t offIntensity);
|
||||
|
||||
protected:
|
||||
friend SX1509FloatOutputChannel;
|
||||
std::vector<SX1509FloatOutputChannel *> float_output_channels_{};
|
||||
|
||||
void pinMode(uint8_t channel, uint8_t inOut);
|
||||
void ledDriverInit(uint8_t channel, uint8_t freq = 1, bool log = false);
|
||||
void clock(uint8_t oscSource = 2, uint8_t oscDivider = 1,
|
||||
uint8_t oscPinFunction = 0, uint8_t oscFreqOut = 0);
|
||||
void digitalWrite(uint8_t channel, uint8_t highLow);
|
||||
void set_channel_value_(uint8_t channel, uint8_t iOn);
|
||||
|
||||
// Pin definitions:
|
||||
uint8_t pinInterrupt_;
|
||||
uint8_t pinOscillator_;
|
||||
|
@ -70,32 +97,22 @@ protected:
|
|||
|
||||
bool update_{true};
|
||||
|
||||
byte REG_I_ON[16] = {REG_I_ON_0, REG_I_ON_1, REG_I_ON_2, REG_I_ON_3,
|
||||
REG_I_ON_4, REG_I_ON_5, REG_I_ON_6, REG_I_ON_7,
|
||||
REG_I_ON_8, REG_I_ON_9, REG_I_ON_10, REG_I_ON_11,
|
||||
uint8_t REG_I_ON[16] = {REG_I_ON_0, REG_I_ON_1, REG_I_ON_2, REG_I_ON_3, REG_I_ON_4, REG_I_ON_5,
|
||||
REG_I_ON_6, REG_I_ON_7, REG_I_ON_8, REG_I_ON_9, REG_I_ON_10, REG_I_ON_11,
|
||||
REG_I_ON_12, REG_I_ON_13, REG_I_ON_14, REG_I_ON_15};
|
||||
|
||||
byte REG_T_ON[16] = {REG_T_ON_0, REG_T_ON_1, REG_T_ON_2, REG_T_ON_3,
|
||||
REG_T_ON_4, REG_T_ON_5, REG_T_ON_6, REG_T_ON_7,
|
||||
REG_T_ON_8, REG_T_ON_9, REG_T_ON_10, REG_T_ON_11,
|
||||
uint8_t REG_T_ON[16] = {REG_T_ON_0, REG_T_ON_1, REG_T_ON_2, REG_T_ON_3, REG_T_ON_4, REG_T_ON_5,
|
||||
REG_T_ON_6, REG_T_ON_7, REG_T_ON_8, REG_T_ON_9, REG_T_ON_10, REG_T_ON_11,
|
||||
REG_T_ON_12, REG_T_ON_13, REG_T_ON_14, REG_T_ON_15};
|
||||
|
||||
byte REG_OFF[16] = {REG_OFF_0, REG_OFF_1, REG_OFF_2, REG_OFF_3,
|
||||
REG_OFF_4, REG_OFF_5, REG_OFF_6, REG_OFF_7,
|
||||
REG_OFF_8, REG_OFF_9, REG_OFF_10, REG_OFF_11,
|
||||
REG_OFF_12, REG_OFF_13, REG_OFF_14, REG_OFF_15};
|
||||
uint8_t REG_OFF[16] = {REG_OFF_0, REG_OFF_1, REG_OFF_2, REG_OFF_3, REG_OFF_4, REG_OFF_5, REG_OFF_6, REG_OFF_7,
|
||||
REG_OFF_8, REG_OFF_9, REG_OFF_10, REG_OFF_11, REG_OFF_12, REG_OFF_13, REG_OFF_14, REG_OFF_15};
|
||||
|
||||
byte REG_T_RISE[16] = {
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
REG_T_RISE_4, REG_T_RISE_5, REG_T_RISE_6, REG_T_RISE_7,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
REG_T_RISE_12, REG_T_RISE_13, REG_T_RISE_14, REG_T_RISE_15};
|
||||
uint8_t REG_T_RISE[16] = {0xFF, 0xFF, 0xFF, 0xFF, REG_T_RISE_4, REG_T_RISE_5, REG_T_RISE_6, REG_T_RISE_7,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, REG_T_RISE_12, REG_T_RISE_13, REG_T_RISE_14, REG_T_RISE_15};
|
||||
|
||||
byte REG_T_FALL[16] = {
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
REG_T_FALL_4, REG_T_FALL_5, REG_T_FALL_6, REG_T_FALL_7,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
REG_T_FALL_12, REG_T_FALL_13, REG_T_FALL_14, REG_T_FALL_15};
|
||||
uint8_t REG_T_FALL[16] = {0xFF, 0xFF, 0xFF, 0xFF, REG_T_FALL_4, REG_T_FALL_5, REG_T_FALL_6, REG_T_FALL_7,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, REG_T_FALL_12, REG_T_FALL_13, REG_T_FALL_14, REG_T_FALL_15};
|
||||
};
|
||||
|
||||
} // namespace sx1509
|
||||
|
|
Loading…
Reference in a new issue