Releases: denko-rb/denko
v0.15.0
0.15.0
New Platform
Denko now runs on mruby! This means it can run on smaller devices. The first of these is the:
- Milk-V Duo
- Same footprint as Raspberry Pi Pico
- Runs Buildroot Linux on a 1GHz RISC-V CPU
- Prebuilt binaries and instructions available here
- Limitations:
- UART not supported yet. Consequently, the
JSNSR04Tsensor won't be fully supported either. - Duo has no on-board DAC, but
AnalogIO::Outputshould work when support for external DACs is added.
- UART not supported yet. Consequently, the
Updated Platforms
- See denko-piboard release notes for its matching 0.15.0 release. This is Denko for "big" Linux SBCs running CRuby.
New Peripherals
-
AnalogIO::Joystick-- MultiPin. Give
x:andy:in:pinsof initialize. Both must be analog input capable. - Inversion configurable, per axis
- Axes are swappable
- Deadzone and maxzone configurable, NOT per axis
- MultiPin. Give
-
DigitalIO::PCF8574-- 8-bit (channel) bi-directional I/O expander over I2C
- Is a
BoardProxysoDigitalIOcomponents may treat it asBoard. Not recommended for fast inputs. - Common in "backpacks" attached to HD44780 LCDs. See example
-
Display::IL0373:- 212 x 104 pixel E-Paper display over SPI
- Black/White and Black/Red/White versions supported (B/R/W version not tested in hardware)
- Hardware controls: black channel inversion, H/V reflection, rotation
-
Display::PCD8544-- 84 x 48 pixel backlit mono LCD over SPI
- Old design from Nokia phones in late 90's and early 00's
- Hardware controls: inversion, contrast (Vop), bias
- Gotcha: Pixels appear to have an aspect ratio of about 0.8
-
Display::SH1107-- 128 x 128 mono OLED over I2C or SPI
-
Display::SSD1680-- 296 x 128 pixel E-Paper display over SPI
- Black/White and Black/Red/White versions supported
- Hardware controls: black channel inversion, horizontal reflection
-
Display::SSD1681-- 200 x 200 pixel variation of SSD1680
-
Display::ST7302-- 250 x 122 pixel mono reflective LCD over SPI
- Hardware controls: inversion, refresh rate
-
Display::ST7565-- 128 x 64 pixel backlit LCD over SPI
- Hardware controls: inversion, H/V reflection, rotation, brightness
-
EEPROM::AT24C-- 32, 64 128 or 256 kib EEPROM over I2C
- Direct read/write with interface similar to Array.
#[]and#[]=
-
Sensor::AHT3X-- Temperature + Relative Humidity sensor over I2C
-
Sensor::HDC1080-- Temperature + Relative Humidity sensor over I2C
- Can also monitor battery level.
#battery_low?is true when VCC < 2.8V.
-
Sensor::JSNSR04T-- Waterproof ultrasonic distance sensor, similar to HC-SR04
- Mode 1 supported by
Sensor::HCSR04class - This new class only supports mode 2 (UART mode)
- Requires
board:ANDuart:in initialize hash - UART must be set to 9600 baud beforehand
-
Sensor::SHT4X-- Temperature + Relative Humidity sensor over I2C
-
Sensor::VL53L0X-- Laser distance sensor over I2C
- 20 - 2000mm range
- Only continuous mode implemented. No configuration yet.
- Has
#smoothing=and#smoothing_size=for moving averages, likeAnalogIO::Input
Peripheral Changes
-
Display::Canvas-#printchanged to#text#print_charchanged to#draw_char- All drawing methods (
#set_pixel,#line,#circleetc.) changed to only take keyword arguments - Removed all
#filled_*methods. Givefilled: trueto any shape method for the same result instead. - Added
#current_color=to set the default color for drawing whencolor:not given - Fonts can be any size and don't need to align to page boundaries now
- Unset pixels/bits in fonts are now ignored (effectively transparent)
- Added more fonts
- Added integer scaling for fonts
- Added
#rotate(degrees) - Added
#reflect(axis),#reflect_x, and#reflect_y - Optimized
#lineto use only integer math, avoid float - Added support for multicolor e-paper displays
- Handled as array of 1-bit framebuffers, one per ink color
- Not real multi-bit color yet
-
Display::HD44780-#printchanged to#text, and#set_cursorto#text_cursorfor consistency withDisplay::Canvas- Added backlight as a subcomponent
- Give positive pin (anode) as
backlight:inpins:hash when initializing HD44780#backlightis an instance ofDenko::LED::Base- Use like:
lcd.backlight.on/lcd.backlight.off, or (if connected to PWM)lcd.backlight.duty=
- Give positive pin (anode) as
-
Display::MonoOLED-- Removed
rotate:option from#initialize - Added
#reflect_x,#reflect_yand#rotatemethods instead, to match the interface of other displays - Affects
SSD1306,SH1106andSH1107OLEDs
- Removed
-
EEPROM::Board-- Renamed from
EEPROM::BuiltIn - Simplified interface, matching
EEPROM::AT24C - Only provides
[]and[]=, for individual values or ranges - Both block, and read/write hardware immediately, rather than caching state
- Renamed from
-
LED::RBG-- Changed
#write(r,g,b)so it takes percentages (0-100) - Added
#write_8_bitthat takes an 8 bit range (0-255), regardless of the underlying PWM settings
- Changed
-
Sensor::DHTreset pulse changed from 20ms to 10ms. Within spec, and appears more reliable in testing.
Behavior Changes
-
Raw Read Rework
Behavior::State,Behavior::Callbacks,Behavior::Reader,Behavior::Poller, andBehavior::Listenerhave received a combined rework, allowing "raw_reads".- A raw read bypasses the "update pathway":
#pre_callback_filter, and#update, which would run callbacks and update component state. - This simplifies development of drivers for things like sensors, where config and calibration data needs to be passed back and forth, but can't hit the update pathway. The old behavior is still available, for actual sensor data.
#_readis a delegate method. Define it to get a single sensor reading, expected to hit the update pathway.#_readshould never be called directly now, as it might conflict with raw reads.- Use
#read_nbto trigger an async read instead. It delegates to#_readin a way that won't conflict. #readis now the same as#read_nb, except blocking.#read_rawalways blocks. Use it to get raw data (no#pre_callback_filter), and not hit the update pathway.#read_rawcannot be called if the component is currently listening. No way to gaurantee message order. Stop listening first.#read_rawtakes a method object or Proc. It does not delegate to#_read, since it's not meant for sensor data.
-
Mutex Rework
Mutex#lockandMutex#unlocknow preferred overMutex#synchronize, so mruby doesn't have to pass a block around.Mutexinstances are all replaced withMutexStubinstances in mruby, and CRuby.Component#state(reading) is no longer protected by a mutex, unless it's a simple Integer.Component#state=(writing) is still portected by@state_mutex.
-
SPI::Peripheral::SinglePinremoved. It's simpler to useSPI::Peripheral::MultiPin(now renamed toSPI::Peripheral) for everything instead.
Microcontroller Changes
-
Arduino Core Version Updates:
- ESP32 Arduino Core -> 3.2.0
- NOTE: HW CDC (UART) is still broken when sending large amounts of data both directions. If using an ESP32 board that has a USB port with a USB-UART chip (not native USB), that will be more reliable for now.
- All other cores -> latest released version
- ESP32 Arduino Core -> 3.2.0
-
Arduino Library Version Updates:
- Adafruit NeoPixel -> 1.15.1
- ESP32Servo -> 3.0.6
- IRremote -> 4.4.2
-
Arduino Uno R4 (Minima and Wi-Fi):
- WS2812 RGB LEDs are now supported by the NeoPixel library on the RA4M1, so enabled for these
-
ATmega168-based microcontrollers:
- Removed OneWire support from default build config and replaced with bit-bang UART
-
AUX_SIZE:
- AUX_SIZE reduced to 528 bytes for almost all microcontrollers, and still 48 for ATmega168
- Most implemented interfaces (except infrared) work fine sending/receiving data in chunks. This allows 512 byte chunks, even if using 16 bytes for configuration etc.
-
SPI transfer size limits:
- SPI transfer sizes are now sent as 12-bit unsigned integers. This allows for a theoretical limit of 4095 bytes per SPI transaction, but AUX_SIZE is lower by default, so 520 (528 - 8 config bytes) is the practical limit, more than doubling the previous 255.
Board Interface Changes
-
Boardclasses must implement#spi_limit, which returns the maximum size (in bytes) of a SPI transaction. The same value is used for both reading and writing. -
Boardclasses must implement#pin_is_pwm?(pin). This takes a pin number and returns true if that pin number is muxed to a hardware PWM output that cannot be remuxed. This is only relevant on Linux, where calling something like#digital_writeon a hardware PWM output does nothing, so we want to mimic it with PWM values instead. -
Boardclasses must implement#pwm_write(pin, duty)so that the second argument is always the duty cycle in nanoseconds, not a percentage, or based on PWM timer bit-depth.- The only exception is connected microcontrollers on Arduino firmware. PWM period may not always be controllable (or even known), so use values based on PWM timer bit-depth. This is handled conditionally inside
PulseIO::PWMOutput.
- The only exception is connected microcontrollers on Arduino firmware. PWM period may not always be controllable (or even known), so use values based on PWM timer bit-depth. This is handled conditionally inside
-
Board#one_wire_resetarguments changed from(pin, read_presence=0)to(pin, read_presence=false). Any truthy value will update the bus' with the presence result.
Driver convergence with mruby
- Many classes had small changes made to avoid using CRuby features...
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::Inputsince it's a single channel ADC. - Can be read directly with
#reador 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_mutexand@callback_mutexare now instances ofDenko::MutexStub, which just runs the given block when called with#synchronize. - The options hash (now called params), given to
#initializeis always available through the#paramsmethod. #initializeno longer acceptspullup: trueorpulldown: true. Set mode explicitly, likemode: :input_pullup.
- On CRuby,
-
Temperature / Pressure / Humidity Sensors:
DS18B20,DHTandHTU21Dreadings 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@stateremoved removed. Use#temperature,#pressure,#humidityinstead.- Added
#temperature_f#temperature_k#pressure_atm#pressure_barhelper conversion methods. #readmethods standardized to always read ALL sub-sensors. AffectsHTU21DandBMP180.
-
AnalogIO::Input:- Added
#smoothing=and#smoothing_size=accessors toAnalogIO::Inputfor configuration. AnalogIO::Sensorremoved. UseInputinstead.
- Added
-
Behavior::InputPin- Added
#debounce=(time)which just callsBoard#set_pin_debouncefor 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
:inputmode. 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_revolutionchanged tocounts_per_revolution- Every level change is counted now (full-quadrature). Was half-quadrature before.
counts_per_revolutionnow defaults to 60 instead of 30 (generic 30-detent encoders).stateand callback hash store:countinstead 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.
#updateaccepts String of comma delimited ASCII numbers (Board), or Array of bytes (PiBoard).
-
I2C::Peripheral:#i2c_readarg order changed from(register, num_bytes)to(num_bytes, register: nil)
-
LED:Base,RGBandSevenSegmentall inherit fromPulseIO::PWMOutput, so see that below.#writeMUST always be given a PWM value if used, not0or1.- Prefer using
duty=if possible, which is percentage based. - Alternatively, call
#digital_writeonly to stay in faster digital mode.
-
LED::RGB:#writetakes 3 regular args now. Use*arrayinstead to pass an array.#coloronly takes a symbol for one of the predefined colors (or:off) now.
-
Motor::Stepper:#step_ccrenamed to#step_ccw.
-
OneWire::Bus:#updateaccepts String of comma delimited ASCII numbers (Board), or Array of bytes (PiBoard).
-
PulseIO::IRTransmitter:- Renamed to
PulseIO::IROutputto be more consistent with other classes. #emitrenamed to#writefor consistency.
- Renamed to
-
PulseIO::PWMOutput:#writewill never try to call#digital_write, always#pwm_write.- Initial mode is
:outputinstead of:output_pwm, saving MCU PWM channels until needed. - Mode change is lazy. Happens with first call to
#pwm_write. - Call only
#digital_writeto stay in digital:outputmode (faster). - Added
#duty=. Set duty cycle in percentage regardless of PWM resolution. - Set resolution and frequency per
PWMOutputinstance (pin), instead of perBoardinstance:#initializehash acceptsfrequency:andresolution:keys.- Call
#pwm_enablewithfrequency:andresolution:kwargs - Or use
#resolution=and#frequency=methods. - Defaults are 1 kHz frequency and 8-bit resolution.
- ONLY works on ESP32 and
PiBoardright now. Others still control at the Board level. - Limited to 13-bit resolution on
Denko::Boardfor 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::SinglePinandSpi::Peripheral::MultiPinto allow modeling more complex peripherals. #updateaccepts 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
#writeto 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_OUTPUTmode. 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_modenow takes a third hash argument,options={}. Only used keys areresolution:andfrequency:for setting PWM resolution. Only works on ESP32 boards andPiBoardon 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_DRAINandOUTPUT_OPEN_SOURCEpin modes to supportPiBoard.
CLI Changes
- All Atmel targets now prefixed with "at". Eg.
atsamd21now, instead ofsamd21before.
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::Connectioncould have negative bytes in transit, making it overflow the board's rx buffer.Servo,BuzzerandIRTransmitterdidn't start in:output_pwmmode.SSD1306#onand#offwould raise errors, trying to write Integer instead of Array toI2C::Bus.SPI::BitBangdid not correctly set initial clock state for modes 2 and 3.IRTransmitter.emitdidn't work at all ESP8266. Pulse data wasn't aligned properly in memory.Board#ws2812_writewas 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.
#readreturns 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::Inputclass. - 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.
#readreturns 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
BMP280sensor 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
valvariable in Arduino is now 16-bit instead of 8-bit. - Fixed instances where
Minitestwas 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#readwith the 2 config register bytes. #readautomatically waits for conversion before reading result.- Implements
BoardProxyinterface, soAnalogIO::Inputcan use it in place ofBoard. - For each
AnalogIO::Inputsubcomponent:- 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.
ADS1115sets@volts_per_bitin 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
benchmarksfolder 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, :SS0in a loaded board map are automatically copied to the key without the trailing 0, i.e.:SDAand 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
:padoption 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
Boardinstance 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-piboardextension gem:- Ruby needs to be running on the Pi itself.
- Only works with CRuby. No JRuby or TruffleRuby.
- Folllow install instructions from
denko-piboardgem's readme. require "denko/piboard"instead ofrequire "denko"- Substitute
Denko::PiBoardforDenko::Boardas board class. - Not all interfaces and components from
denkoare 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
:indexas the UART's number, according to the Arduino IDE/pinout.Serial1has index1.Serial2has index2, and so on. :baudargument 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, andSerialUSBis the Denko transport. UART::Hardware#writeaccepts either a String or Array of bytes to send binary data.- The
UART::Hardwareinstance 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#stopto disable the UART and return the pins to regular GPIO. - Added
Denko::Connection::BoardUART, allowing a board's UART to be the transport for anotherBoardinstance. 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#readwith the 2 config register bytes. #readautomatically waits for conversion before reading result.- Implements
BoardProxyinterface, soAnalogIO::Inputcan use it in place ofBoard. - For each
AnalogIO::Inputsubcomponent:- 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.
ADS1118sets@volts_per_bitin 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::BME280andDenko::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_temperatureandHTU21D#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#temperatureandHTU21D#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#drawrefreshes 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::Componentsnamespace, make naming clearer.- TODO: Update here with a list of renamed components.
-
SPI peripherals now go through a
Denko::SPI::Busobject:- 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 (
SPIorSPI0), 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::Busvalidates select pin uniquness among peripherals, per bus instance.SPI::Bustreats 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::BitBangwhich is class-compatible withSPI::Bus, except for frequency.- See SPI changes above.
-
SPI::Peripheralhas 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::Busdoes not automatically search when initialized. -
I2C frequency now configurable:
I2C::Peripheraland it's subclasses take:i2c_frequencykeywoard arg when instantiating. It's stored in@i2c_frequencyand used for all reads and writes.Board#i2c_writeandBoard#i2c_readalso accept:i2c_frequencyas a keyword arg.- Valid values are:
100000, 400000, 1000000, 3400000. Defaults to100000at theBoardlevel, 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 #putschanged to#printto better represent functionality.- No longer depends on the
LiquidCrystalArduino library, which has been removed. - Depends only on
Denko::DigitalIO::Outputand#micro_delay. - Old implementation in
Denko::Components::LCDremoved. - This solves compatibility with boards that the library didn't work on.
HD44780#create_charallows 8 custom characters to be defined in memory addresse...
- New class: