Skip to content

v0.15.0

Latest

Choose a tag to compare

@vickash vickash released this 13 Jun 15:18
· 97 commits to master since this release

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 JSNSR04T sensor won't be fully supported either.
      • Duo has no on-board DAC, but AnalogIO::Output should work when support for external DACs is added.

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: and y: in :pins of initialize. Both must be analog input capable.
    • Inversion configurable, per axis
    • Axes are swappable
    • Deadzone and maxzone configurable, NOT per axis
  • DigitalIO::PCF8574 -

    • 8-bit (channel) bi-directional I/O expander over I2C
    • Is a BoardProxy so DigitalIO components may treat it as Board. 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::HCSR04 class
    • This new class only supports mode 2 (UART mode)
    • Requires board: AND uart: 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, like AnalogIO::Input

Peripheral Changes

  • Display::Canvas -

    • #print changed to #text
    • #print_char changed to #draw_char
    • All drawing methods (#set_pixel, #line, #circle etc.) changed to only take keyword arguments
    • Removed all #filled_* methods. Give filled: true to any shape method for the same result instead.
    • Added #current_color= to set the default color for drawing when color: 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 #line to 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 -

    • #print changed to #text, and #set_cursor to #text_cursor for consistency with Display::Canvas
    • Added backlight as a subcomponent
      • Give positive pin (anode) as backlight: in pins: hash when initializing
      • HD44780#backlight is an instance of Denko::LED::Base
      • Use like: lcd.backlight.on / lcd.backlight.off, or (if connected to PWM) lcd.backlight.duty=
  • Display::MonoOLED -

    • Removed rotate: option from #initialize
    • Added #reflect_x, #reflect_y and #rotate methods instead, to match the interface of other displays
    • Affects SSD1306, SH1106 and SH1107 OLEDs
  • 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
  • LED::RBG -

    • Changed #write(r,g,b) so it takes percentages (0-100)
    • Added #write_8_bit that takes an 8 bit range (0-255), regardless of the underlying PWM settings
  • Sensor::DHT reset 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, and Behavior::Listener have 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.
    • #_read is a delegate method. Define it to get a single sensor reading, expected to hit the update pathway.
    • #_read should never be called directly now, as it might conflict with raw reads.
    • Use #read_nb to trigger an async read instead. It delegates to #_read in a way that won't conflict.
    • #read is now the same as #read_nb, except blocking.
    • #read_raw always blocks. Use it to get raw data (no #pre_callback_filter), and not hit the update pathway.
    • #read_raw cannot be called if the component is currently listening. No way to gaurantee message order. Stop listening first.
    • #read_raw takes a method object or Proc. It does not delegate to #_read, since it's not meant for sensor data.
  • Mutex Rework

    • Mutex#lock and Mutex#unlock now preferred over Mutex#synchronize, so mruby doesn't have to pass a block around.
    • Mutex instances are all replaced with MutexStub instances 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::SinglePin removed. It's simpler to use SPI::Peripheral::MultiPin (now renamed to SPI::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
  • 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

  • Board classes 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.

  • Board classes 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_write on a hardware PWM output does nothing, so we want to mimic it with PWM values instead.

  • Board classes 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.
  • Board#one_wire_reset arguments 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

Bug Fixes

  • Fixed bug where Display::HD44780 would try to call #board_has_write_bit? instead of #board.is_register?.
  • Fixed a bug with multiple enviro sensors where calling #state would reset the values of all keys to nil.
  • Fixed bug where Canvas#polygon and #path were not passing through color to sub-methods.
  • Fixed a bug where Behavior::MultiPin would try to convert pins given as nil to Integer, creating unnecesary subcomponents on pin 0.
  • Shortened Sensor::DHT reset time to 10ms, which works more reliably.
  • Write twice before rading for Sensor::RCWL9620, which works more reliably.