Releases: denko-rb/denko
v0.14.0
Known Issues
- ESP32 Boards
- USB-CDC (aka native USB) appears to be broken in the 3.0 core. Will eventually hang if sending a lot of data both directions at the same time. Use one of the standard UART interfaces until this is fixed.
New Boards
- ESP32-H2 and ESP32-C6 variants (
--target esp32
):- Depends on ESP32 Arduino Core 3.0+
- No WiFi on H2
Board Changes
-
ESP32 Boards
- 3.0+ version of the ESP32 Arduino Core now required.
-
Raspberry Pi Pico (RP2040)
- WS2812 LED strips work now.
New Peripherals
-
Bit-Bang I2C:
- Class:
Denko::I2C::BitBang
- Start a software bit-banged I2C bus on any 2 pins.
- Interchangeable with hardware bus (
Denko::I2C::Bus
), as far as I2C peripherals are concerned.
- Class:
-
ADS1100 Analog-to-Digital Converter:
- Class:
Denko::AnalogIO::ADS1100
- Connects via I2C bus. Driver written in Ruby.
- Modeled after
AnalogIO::Input
since it's a single channel ADC. - Can be read directly with
#read
or polled with#poll
. - Full scale voltage must be given in the initailize hash,
full_scale_voltage:
. - Gain and sample rate configurable. See example for more.
- Class:
-
SSD1306 1-Color OLED
- Added SPI version.
- Both use
Denko::Display::SSD1306
. Instances mutate to I2C or SPI behavior, based on bus given.
-
SH1106 1-Color OLED
- Class:
Denko::Display::SH1106
- Almost the same as SSD1306. Most driver code is shared between them.
- I2C and SPI versions both supported, as SSD1306 above.
- Class:
Peripheral Changes
-
All Peripherals:
- On CRuby,
@state_mutex
and@callback_mutex
are now instances ofDenko::MutexStub
, which just runs the given block when called with#synchronize
. - The options hash (now called params), given to
#initialize
is always available through the#params
method. #initialize
no longer acceptspullup: true
orpulldown: true
. Set mode explicitly, likemode: :input_pullup
.
- On CRuby,
-
Temperature / Pressure / Humidity Sensors:
DS18B20
,DHT
andHTU21D
readings now match all the others (Hash with same keys).- Readings standardized to be in ºC, %RH and Pascals. Callbacks always receive hash with these.
[]
access for@state
removed removed. Use#temperature
,#pressure
,#humidity
instead.- Added
#temperature_f
#temperature_k
#pressure_atm
#pressure_bar
helper conversion methods. #read
methods standardized to always read ALL sub-sensors. AffectsHTU21D
andBMP180
.
-
AnalogIO::Input
:- Added
#smoothing=
and#smoothing_size=
accessors toAnalogIO::Input
for configuration. AnalogIO::Sensor
removed. UseInput
instead.
- Added
-
Behavior::InputPin
- Added
#debounce=(time)
which just callsBoard#set_pin_debounce
for the pin. Only onPiBoard
.
- Added
-
DigitalIO::CBitBang
:- New helper class. Forces initialize validation for bit-bang pins. Essential for
PiBoard
. - As a side-effect, makes sure 2 low-level bit-bang Components (eg. buses) can't use the same pin.
- Always starts pins in
:input
mode. The bit-bang routine is expected to change them.
- New helper class. Forces initialize validation for bit-bang pins. Essential for
-
DigitalIO::RotaryEncoder
:- Pin names standardized to
a:
andb:
, but still accept:clock
,:data
,:clk
,:dt
. steps_per_revolution
changed tocounts_per_revolution
- Every level change is counted now (full-quadrature). Was half-quadrature before.
counts_per_revolution
now defaults to 60 instead of 30 (generic 30-detent encoders).state
and callback hash store:count
instead of:steps
.
- Pin names standardized to
-
I2C::Bus
:- No longer requires SDA pin to initialize.
- Accepts
index:
param (default 0) on initialize, specifying which I2C interface to use.- Only works for PiBoard on Linux right now.
#update
accepts String of comma delimited ASCII numbers (Board), or Array of bytes (PiBoard).
-
I2C::Peripheral
:#i2c_read
arg order changed from(register, num_bytes)
to(num_bytes, register: nil)
-
LED
:Base
,RGB
andSevenSegment
all inherit fromPulseIO::PWMOutput
, so see that below.#write
MUST always be given a PWM value if used, not0
or1
.- Prefer using
duty=
if possible, which is percentage based. - Alternatively, call
#digital_write
only to stay in faster digital mode.
-
LED::RGB
:#write
takes 3 regular args now. Use*array
instead to pass an array.#color
only takes a symbol for one of the predefined colors (or:off
) now.
-
Motor::Stepper
:#step_cc
renamed to#step_ccw
.
-
OneWire::Bus
:#update
accepts String of comma delimited ASCII numbers (Board), or Array of bytes (PiBoard).
-
PulseIO::IRTransmitter
:- Renamed to
PulseIO::IROutput
to be more consistent with other classes. #emit
renamed to#write
for consistency.
- Renamed to
-
PulseIO::PWMOutput
:#write
will never try to call#digital_write
, always#pwm_write
.- Initial mode is
:output
instead of:output_pwm
, saving MCU PWM channels until needed. - Mode change is lazy. Happens with first call to
#pwm_write
. - Call only
#digital_write
to stay in digital:output
mode (faster). - Added
#duty=
. Set duty cycle in percentage regardless of PWM resolution. - Set resolution and frequency per
PWMOutput
instance (pin), instead of perBoard
instance:#initialize
hash acceptsfrequency:
andresolution:
keys.- Call
#pwm_enable
withfrequency:
andresolution:
kwargs - Or use
#resolution=
and#frequency=
methods. - Defaults are 1 kHz frequency and 8-bit resolution.
- ONLY works on ESP32 and
PiBoard
right now. Others still control at the Board level. - Limited to 13-bit resolution on
Denko::Board
for now.
-
SPI::Bus
:- Accepts
index:
param (default 0) on initialize, specifying which SPI interface to use.- Only works for PiBoard on Linux right now.
- Accepts
-
SPI::Peripheral
:- Split into
SPI:Peripheral::SinglePin
andSpi::Peripheral::MultiPin
to allow modeling more complex peripherals. #update
accepts String of comma delimited ASCII numbers (Board), or Array of bytes (PiBoard).
- Split into
-
SPI::OutputRegister
:- Removed automatic buffering of writes.
- Call
#set_bit(value)
instead to modify state in memory, without writing to the physical register. - Call
#write
to send state to the register after modifying.
Fiwmare Changes
-
General:
- Boards now report their serial buffer as 8 bytes less than the actual buffer size.
- Removed local callback hooks (meant for customization in C) from the Arduino sketches.
- Improved serial interface selection for ATSAMD21 boards. Some boards have the native interface as
Serial
, some asSerialUSB
. The native interface is always selected now, regardless of its name. - More accurate pin counts when initializing digital listener storage for different boards.
-
Core I/O:
- Removed
INPUT_OUTPUT
mode. Only ESP32 used it and it's the same asOUTPUT
. - Added an optimized single-byte binary message type for
#digital_write
. Improves write throughput 6-7x. Only works for pins 0..63. Fallback automatic for higher pins.
- Removed
-
Hardware I2C:
- Message format changed so "value" isn't used. Will be used for differentiating multiple I2C interfaces in future.
- Responses now prefixed with
I2C{index}:
(index = I2C device integer, always 0 for now), instead of SDA pin number.
-
Hardware SPI:
- Transfers don't need a chip select pin now. This is for LED strips like APA102.
-
Bit-Bang I2C:
- Newly added. Works similar to Bit-Bang SPI.
Board Interface Changes
-
Board#set_pin_mode
now takes a third hash argument,options={}
. Only used keys areresolution:
andfrequency:
for setting PWM resolution. Only works on ESP32 boards andPiBoard
on Linux. -
Added
Board#set_pin_debounce
- Implemented for Linux GPIO alerts in
Denko::PiBoard
(denko-piboard gem). - Sets a time (in microseconds) that level changes on a pin must be stable for, before an update happens.
- Does nothing for
Denko::Board
.
- Implemented for Linux GPIO alerts in
-
Added
OUTPUT_OPEN_DRAIN
andOUTPUT_OPEN_SOURCE
pin modes to supportPiBoard
.
CLI Changes
- All Atmel targets now prefixed with "at". Eg.
atsamd21
now, instead ofsamd21
before.
Bugs Fixed
- ADS111X sensors were incorrectly validating sample rate when set.
- Handshake could fail if board was left in a state where it kept transmitting data.
- An ESP32 with no DACs might not release a LEDC channel after use.
Denko::Connection
could have negative bytes in transit, making it overflow the board's rx buffer.Servo
,Buzzer
andIRTransmitter
didn't start in:output_pwm
mode.SSD1306#on
and#off
would raise errors, trying to write Integer instead of Array toI2C::Bus
.SPI::BitBang
did not correctly set initial clock state for modes 2 and 3.IRTransmitter.emit
didn't work at all ESP8266. Pulse data wasn't aligned properly in memory.Board#ws2812_write
was validating max length to 256 instead of 255.- WS2812 write on ESP32 would crash it, only with some low 8-bit pixel values. Still unsure why, but four extra 0 bytes (preceding the pixel data in auxMsg) seems to work around this.
v0.13.6
v0.13.5
New Components
- HC-SR04 Ultrasonic Distance Sensor:
- Class:
Denko::Sensor::HCSR04
- Custom function on the board to handle ping and response.
- Simple interface.
#read
returns a distance in mm.
- Class:
Bug Fixes
- OTA updating now works on ESP32.
- Adjust ESP32 expected serial buffer sizes and acknowledge intervals to to be more reliable.
- Fixed a bug on Windows where submodules weren't being included in load path.
- Fixed a bug where the board could incorrectly report EEPROM_LENGTH as 0.
v0.13.4
0.13.4
New Components
-
Generic PIR sensors:
- Class:
Denko::Sensor::GenericPIR
- Based on
Denko::DigitalIO::Input
class. - Tested with AS312 and HC-SR501 sensors. Should work with AM312 and others.
- Class:
-
Bosch BMP 180 Temperature + Pressure Sensor:
- Class:
Denko::Sensor::BMP180
- Connects via I2C bus. Ruby driver.
- Similar to BMP280, but fewer features (older version).
- Should work for BMP085 sensor as well.
- Class:
-
SHT30/31/35 Temperature + Humidity Sensor:
- Class:
Denko::Sensor::SHTX
- Connects via I2C bus. Ruby driver.
- One-shot reading mode only.
- Class:
-
RCWL-9620 Ultrasonic Distance Sensor:
- Class:
Denko::Sensor::RCWL9620
- Connects via I2C bus. Ruby driver.
- Very simple interface.
#read
returns a distance in mm.
- Class:
Component Changes
- HTU21D:
- Humidity values outside the 0-100% range will be clipped to those values automatically.
Example Changes
- Added a simple button example, separate from tutorial.
- Standardize temp/pressure/humidity sensor examples (except DHT, DS18B20, HTU21D) so readings display the same.
Bug Fixes
- Fixed bug where
BMP280
sensor class would not autoload.
v0.13.3
Board Updates / Fixes
-
Arduino UNO R4 Minima & Wi-Fi (
--target ra4m1
):- RA4M1 fully tested
- Only IR-remote and WS2812 libraries not working. Disabled temporarily.
-
Arduino Nano Every
- ATmega4809 fully tested and issues fixed
- Works similarly to the regular AVR chips
-
SAMD21
- Changed serial acknowledgement threshold to 128 instead of 64. More stable, but might be slightly slower performing.
Network Chip Updates / Fixes
-
WINC1500
- Added support for WiFi101 library
- Tested on Arduino MKR 1000
-
NINA-W102
- Added conditions to select the WiFiNINA library on appropriate hardware.
- Untested in hardware
API Changes
- Default aux message size is now 784 bytes (768 + 16) instead of (512 + 16)
Component Changes
- WS2812
- Larger aux message size now allows up to 256 pixels (3 bytes per pixel) on a strip
Bug Fixes
- Fixed a bug with WS2812 strips where it would try to memcpy 3x the number of necessary bytes. Fixed this by just sending the total number of bytes to write to the strip, rather than number of pixels * bytes per pxiel.
- The
val
variable in Arduino is now 16-bit instead of 8-bit. - Fixed instances where
Minitest
was referred to asMiniTest
, causing tests to fail.
v0.13.2
0.13.2
New Boards
- Arduino UNO R4 Minima & Wi-Fi (
--target ra4m1
):- Mostly working
- IR-remote and WS2812 libraries do not support this chip. Disabled temporarily.
- Hardware serial disabled until further testing.
- Wi-Fi still untested.
New Components
- ADS1115 Analog-to-Digital Converter:
- Class:
Denko::AnalogIO::ADS1115
. - Connects via I2C bus. Driver written in Ruby.
- Can be used directly by calling
ADS1115#read
with the 2 config register bytes. #read
automatically waits for conversion before reading result.- Implements
BoardProxy
interface, soAnalogIO::Input
can use it in place ofBoard
. - For each
AnalogIO::Input
subcomponent:- Negative pin (1 or 3) of differential pair can be set with the keyword argument
negative_pin:
- Gain can be set with the keyword argument
gain:
- Sample rate can be set with the keyword argument
sample_rate:
- Sample rate doesn't affect update rate. Higher sample rates oversample for a single reading, increasing resolution.
ADS1115
sets@volts_per_bit
in the subcomponent, so exact voltages can be calculated.- There is no listening interface for subcomponents.
- Negative pin (1 or 3) of differential pair can be set with the keyword argument
- Built in comparator not implemented.
- Basically an I2C version of ADS1118 with the temperature sensor swapped for comparator.
- Class:
Optimizations
- Boards now declare their serial RX buffer size and maximum I2C transaction size in handshake. This makes it possible to send data as fast as possible without data loss.
- Added
benchmarks
folder and a simple SSD1306 screen redrawing benchmark, with results for many chips. - Changed many instance methods to use keyword args instead of options hash pattern. Better performance everywhere, but will matter most in mruby.
- Many small performance improvemnts taken from mruby implementation to keep code as similar as possible across both.
Minor Changes
- Improved detection of default serial interface and EEPROM availability at the sketch level.
- Pins defined as any of
:SDA0, :SCL0, :MISO0, :MOSI0, :SCK0, :SS0
in a loaded board map are automatically copied to the key without the trailing 0, i.e.:SDA
and so forth. This is convenient for chips like the RP2040 which don't define the "non-zero" pins at all. - Simplified handling of Wi-Fi reconnection in that sketch.
- Wi-Fi sketch now prints its connection details to serial on each reconnect, as well as startup.
- Updated both IR libraries to latest version.
Bug Fixes
- Display::HD44780 was trying to write 1 and 0 as String instead of Integer to digital output pins.
- Wi-Fi and Ethernet sketches could get stuck in an endless loop when switching between a TCP client and the Serial interface fallback.
- SAMD21 could hang on I2C when writing lots of data. This has to do with its serial buffer not being saturated somehow? Fixed though.
- Board#set_register_divider wouldn't raise the correct ArgumentError if the divider given was out of range.
- Updated the arduino-yaml-board-maps project to prevent ESP32 chips from wrongly map many of their ADC pins.
- ESP32 variants, other than the original V1, could try to assign more LEDC (PWM) channels than they actually have.
Removed
- Removed the
:pad
option from Message::pack. Nothing was using it and padding bytes should be handled in the component class anyway.
0.13.1
0.13.0
New Features
Board#map
- Returns a hash mapping named pins (taken from the Arduino framework) to their integer GPIO values, once the board is supported. Examples:
:A0
,:DAC0
,:MOSI
,:LED_BUILTIN
. - Pins can be given as symbols when creating peripherals. The
Board
instance converts them to integer usingBoard#convert_pin
. - This works by having the board send an identifier string (again taken from the Arduino framework) during handshake. The identifier is cross-referenced against a directory of YAML files, loading the right map for each board.
- This uses
arduino-yaml-board-maps
. See that repo for which Arduino cores / boards are supported.
- Returns a hash mapping named pins (taken from the Arduino framework) to their integer GPIO values, once the board is supported. Examples:
New Boards
-
ESP32-S2, ESP32-S3 and ESP32-C3 variants (
--target esp32
):- Newer versions of the ESP32 chip with native USB support.
- No DACs on the S3.
- No DACs or capacitive touch on the C3.
-
SAMD21 Boards, Arduino Zero (
--target samd
): -
RP2040 Based Boards, Raspberry Pi Pico (W) (
--target rp2040
):- WS2812 LED arrays don't work.
-
Raspberry Pi SBC (not Pico) built-in GPIO support, using
denko-piboard
extension gem:- Ruby needs to be running on the Pi itself.
- Only works with CRuby. No JRuby or TruffleRuby.
- Folllow install instructions from
denko-piboard
gem's readme. require "denko/piboard"
instead ofrequire "denko"
- Substitute
Denko::PiBoard
forDenko::Board
as board class. - Not all interfaces and components from
denko
are supported yet.
New Components
-
Hardware UART support:
- Class:
Denko::UART::Hardware
. - Read/write support for a board's open (not tied to a USB port) hardware UARTs. Allows interfacing with serial peripherals.
- Initialize giving
:index
as the UART's number, according to the Arduino IDE/pinout.Serial1
has index1
.Serial2
has index2
, and so on. :baud
argument can be given when initializing, or callUART::Hardware#start(YOUR_BAUD_RATE)
. Default is 9600.- No pin arguments are needed to start the UART, but peripherals must be connected properly. Refer to your board's pinout.
- UARTs 1..3 are supported, and map to "virtual pins" 251..253, for purposes of identifying bytes read from the board.
- The 0th UART (
Serial
) is never used, even on boards where it is not in use, andSerialUSB
is the Denko transport. UART::Hardware#write
accepts either a String or Array of bytes to send binary data.- The
UART::Hardware
instance itself buffers read bytes. Complete lines can be read withUART::Hardware#gets
. - Callbacks can be attached, like other input classes, to handle each batch of raw bytes as they arrive.
- Call
UART::Hardware#stop
to disable the UART and return the pins to regular GPIO. - Added
Denko::Connection::BoardUART
, allowing a board's UART to be the transport for anotherBoard
instance. See this example.
- Class:
-
ADS1118 Analog-to-Digital Converter:
- Class:
Denko::AnalogIO::ADS1118
. - Connects via SPI bus. Driver written in Ruby.
- Can be used directly by calling
ADS1118#read
with the 2 config register bytes. #read
automatically waits for conversion before reading result.- Implements
BoardProxy
interface, soAnalogIO::Input
can use it in place ofBoard
. - For each
AnalogIO::Input
subcomponent:- Negative pin (1 or 3) of differential pair can be set with the keyword argument
negative_pin:
- Gain can be set with the keyword argument
gain:
- Sample rate can be set with the keyword argument
sample_rate:
- Sample rate doesn't affect update rate. Higher sample rates oversample for a single reading, increasing resolution.
ADS1118
sets@volts_per_bit
in the subcomponent, so exact voltages can be calculated.- There is no listening interface for subcomponents.
- Negative pin (1 or 3) of differential pair can be set with the keyword argument
- Built in temperature sensor can be read with
ADS1118#temperature_read
. Only 128 SPS. No polling.
- Class:
-
Bosch BME/BMP 280 Temperature + Pressure + Humidity Sensor:
- Classes:
Denko::Sensor::BME280
andDenko::Sensor::BMP280
- Connects via I2C bus. Driver written in Ruby.
- All features in the datasheet are implemented, except status checking.
- Both are mostly identical, except for BMP280 lacking humidity.
- Classes:
-
HTU21D Temperature + Humidity Sensor:
- Class:
Denko::Sensor::HTU21D
- Connects via I2C bus. Driver written in Ruby.
- Most features implemented, except reading back the configuration register, and releasing the I2C bus during measurement. Since conversion times can vary, it's simpler to let the sensor hold the line until its data is ready to be read.
- Always uses CRC. Readings are silently ignored if CRC fails.
- Can be read with direct methods
HTU21D#read_temperature
andHTU21D#read_humidity
, but these do not accept block callbacks, and there is no polling. - For callbacks and polling, use the sub-objects accessible through
HTU21D#temperature
andHTU21D#humidity
. See examples for more info.
- Class:
-
HTU31D Temperature + Humidity Sensor:
- Class:
Denko::Sensor::HTU31D
- Connects via I2C bus. Driver written in Ruby.
- Similar to HTU21D, but temperature and humidity can be, and always are, read together.
- Always uses CRC. Readings are silently ignored if CRC fails.
- Diagnostic register reading not implemented yet.
- Class:
-
AHT10 / AHT15 Temperature + Humidity Sensors:
- Both share a compatible interface, and use the same class:
Denko::Sensor::AHT10
- Connects via I2C bus. Driver written in Ruby.
- Always uses calibrated mode.
- Both share a compatible interface, and use the same class:
-
AHT20 / AHT21 / AHT25 / AM2301B Temperature + Humidity Sensors:
- All share a compatible interface, and use the same class:
Denko::Sensor::AHT20
- Connects via I2C bus. Driver written in Ruby.
- Always uses calibrated mode.
- Always uses CRC. Readings are silently ignored if CRC fails.
- All share a compatible interface, and use the same class:
-
SSD1306 OLED Display:
- Class:
Denko::Display::SSD1306
- Connects via I2C bus. Driver written in Ruby.
- By default,
SSD1306#draw
refreshes the entire frame, using horizontal addressing mode. - Can do partial refreshes with
SSD1306#draw(x_min, x_max, y_min, y_max)
, defining a bounding box to redraw. - One 6x8 font and graphic primitves, included through
Denko::Display::Canvas
.
- Class:
-
L298 H-Bridge Motor Driver:
- Class:
Denko::Motor::L298
- Forward, reverse, idle, and brake modes implemented.
- Speed controlled by PWM output on enable pin.
- Class:
-
WS2812 / WS2812B / NeoPixel RGB LED Array:
- Class:
Denko::LED::WS2812
- No fancy functions yet. Just clear, set pixels, and show.
- Class:
-
APA102 / Dotstar RGB LED Array:
- Class:
Denko::LED::APA102
- No fancy functions yet. Just clear, set pixels, show, global and per-pixel brightness control.
- Needs its own dedicated SPI bus. Select pin is automatically set to 255 (no pin).
- Class:
See new examples in the examples folder to learn more.
Changed Components
-
Virtually every component has been renamed to bring them out of the
Denko::Components
namespace, make naming clearer.- TODO: Update here with a list of renamed components.
-
SPI peripherals now go through a
Denko::SPI::Bus
object:- Instead of giving a board directly when creating a new SPI peripheral, a bus must be created first:
board = Denko::Board.new(connection) bus = Denko::SPI::Bus.new(board: board) # board's default SPI interface output_register = Denko::SPI::OutputRegister.new(bus: bus, pin: 9) # 9 is register select pin input_register = Denko::SPI::InputRegister.new(bus: bus, pin: 10) # 10 is register select pin
- For now, this always uses the default SPI device set by the Arduino framework (
SPI
orSPI0
), but this change will allow access to multiple SPI interfaces on a single board in the future. - It also allows a peripheral to mutex lock the bus for atomic operations if needed.
- When a peripheral is added to the SPI bus, callbacks are hooked (using its select pin as identifier) directly to the board.
SPI::Bus
validates select pin uniquness among peripherals, per bus instance.SPI::Bus
treats a select (enable) pin of 255 as no select pin at all (won't toggle before and after transferring).- See the updated SPI examples to learn more.
- Instead of giving a board directly when creating a new SPI peripheral, a bus must be created first:
-
Shift In/Out features refactored into
SPI::BitBang
which is class-compatible withSPI::Bus
, except for frequency.- See SPI changes above.
-
SPI::Peripheral
has been extracted from the various SPI Register classes.- This should be used for most peripherals, and the register classes used only for simple I/O expansion registers.
-
I2C::Bus
does not automatically search when initialized. -
I2C frequency now configurable:
I2C::Peripheral
and it's subclasses take:i2c_frequency
keywoard arg when instantiating. It's stored in@i2c_frequency
and used for all reads and writes.Board#i2c_write
andBoard#i2c_read
also accept:i2c_frequency
as a keyword arg.- Valid values are:
100000, 400000, 1000000, 3400000
. Defaults to100000
at theBoard
level, when not given. - Note: This DOES NOT work if using
denko-piboard
. See the README on that gem for more info.
-
Hitachi HD44780 LCD driver rewritten in Ruby:
- New class:
Denko::Display::HD44780
#puts
changed to#print
to better represent functionality.- No longer depends on the
LiquidCrystal
Arduino library, which has been removed. - Depends only on
Denko::DigitalIO::Output
and#micro_delay
. - Old implementation in
Denko::Components::LCD
removed. - This solves compatibility with boards that the library didn't work on.
HD44780#create_char
allows 8 custom characters to be defined in memory addresse...
- New class: