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 not available in mruby. These include:
- Avoid using
Integer#[]to get specific bits - Avoid using
Array#pack - Avoid using regexes entirely
- Avoid
super if defined?(super)- Use
begin; super; rescue NoMethodError; end
- Use
- Avoid using
Bug Fixes
- Fixed bug where
Display::HD44780would try to call#board_has_write_bit?instead of#board.is_register?. - Fixed a bug with multiple enviro sensors where calling
#statewould reset the values of all keys tonil. - Fixed bug where
Canvas#polygonand#pathwere not passing through color to sub-methods. - Fixed a bug where
Behavior::MultiPinwould try to convert pins given asnilto Integer, creating unnecesary subcomponents on pin0. - Shortened
Sensor::DHTreset time to 10ms, which works more reliably. - Write twice before rading for
Sensor::RCWL9620, which works more reliably.