denko 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/build_avr.yml +61 -0
- data/.github/workflows/build_esp32.yml +58 -0
- data/.github/workflows/build_esp8266.yml +57 -0
- data/.github/workflows/build_megaavr.yml +61 -0
- data/.github/workflows/build_rp2040.yml +61 -0
- data/.github/workflows/build_sam3x.yml +59 -0
- data/.github/workflows/build_samd.yml +61 -0
- data/.github/workflows/ruby.yml +47 -0
- data/.gitignore +24 -0
- data/.gitmodules +3 -0
- data/.vscode/settings.json +5 -0
- data/.vscode/tasks.json +20 -0
- data/CHANGELOG.md +466 -0
- data/DEPS_CLI.md +80 -0
- data/DEPS_IDE.md +120 -0
- data/Gemfile +4 -0
- data/HARDWARE.md +195 -0
- data/LICENSE +22 -0
- data/README.md +152 -0
- data/Rakefile +11 -0
- data/bin/denko +22 -0
- data/build +27 -0
- data/denko.gemspec +47 -0
- data/examples/advanced/rotary_encoder_mac_volume.rb +48 -0
- data/examples/advanced/ssd1306_time_temp_rh.rb +48 -0
- data/examples/analog_io/ads1118.rb +74 -0
- data/examples/analog_io/dac_loopback.rb +32 -0
- data/examples/analog_io/input.rb +52 -0
- data/examples/connection/tcp.rb +34 -0
- data/examples/digital_io/rotary_encoder.rb +26 -0
- data/examples/display/hd44780.png +0 -0
- data/examples/display/hd44780.rb +39 -0
- data/examples/display/ssd1306.rb +40 -0
- data/examples/display/ssd1306_s2_pico.rb +29 -0
- data/examples/eeprom/built_in.rb +32 -0
- data/examples/i2c/search.rb +53 -0
- data/examples/led/apa102_bounce.rb +33 -0
- data/examples/led/apa102_breathe.rb +45 -0
- data/examples/led/builtin_blink.rb +12 -0
- data/examples/led/seven_segment_char_echo.rb +15 -0
- data/examples/led/ws2812_bounce.rb +32 -0
- data/examples/led/ws2812_builtin_blink.rb +21 -0
- data/examples/motor/l298.rb +43 -0
- data/examples/motor/servo.rb +16 -0
- data/examples/motor/stepper.png +0 -0
- data/examples/motor/stepper.rb +43 -0
- data/examples/pulse_io/buzzer.rb +30 -0
- data/examples/pulse_io/ir_transmitter.rb +55 -0
- data/examples/rtc/ds3231.rb +48 -0
- data/examples/sensor/aht10.rb +15 -0
- data/examples/sensor/aht20.rb +15 -0
- data/examples/sensor/bme280.rb +75 -0
- data/examples/sensor/dht.rb +24 -0
- data/examples/sensor/ds18b20.rb +58 -0
- data/examples/sensor/htu21d.rb +54 -0
- data/examples/sensor/htu31d.rb +31 -0
- data/examples/spi/input_register.rb +50 -0
- data/examples/spi/output_register.rb +49 -0
- data/examples/spi/ssd_through_register.rb +40 -0
- data/examples/spi/two_registers.rb +46 -0
- data/examples/uart/bit_bang_read.rb +16 -0
- data/examples/uart/bit_bang_write.rb +16 -0
- data/examples/uart/board_passthrough.rb +34 -0
- data/examples/uart/hardware_loopback.rb +16 -0
- data/lib/denko/analog_io/ads1118.rb +182 -0
- data/lib/denko/analog_io/input.rb +79 -0
- data/lib/denko/analog_io/output.rb +20 -0
- data/lib/denko/analog_io/potentiometer.rb +15 -0
- data/lib/denko/analog_io/sensor.rb +6 -0
- data/lib/denko/analog_io.rb +9 -0
- data/lib/denko/behaviors/board_proxy.rb +23 -0
- data/lib/denko/behaviors/bus_controller.rb +11 -0
- data/lib/denko/behaviors/bus_controller_addressed.rb +15 -0
- data/lib/denko/behaviors/bus_peripheral.rb +21 -0
- data/lib/denko/behaviors/bus_peripheral_addressed.rb +15 -0
- data/lib/denko/behaviors/callbacks.rb +67 -0
- data/lib/denko/behaviors/component.rb +48 -0
- data/lib/denko/behaviors/input_pin.rb +24 -0
- data/lib/denko/behaviors/listener.rb +22 -0
- data/lib/denko/behaviors/multi_pin.rb +72 -0
- data/lib/denko/behaviors/output_pin.rb +13 -0
- data/lib/denko/behaviors/poller.rb +31 -0
- data/lib/denko/behaviors/reader.rb +49 -0
- data/lib/denko/behaviors/single_pin.rb +26 -0
- data/lib/denko/behaviors/state.rb +24 -0
- data/lib/denko/behaviors/subcomponents.rb +35 -0
- data/lib/denko/behaviors/threaded.rb +54 -0
- data/lib/denko/behaviors.rb +26 -0
- data/lib/denko/board/core.rb +151 -0
- data/lib/denko/board/eeprom.rb +20 -0
- data/lib/denko/board/i2c.rb +68 -0
- data/lib/denko/board/infrared.rb +18 -0
- data/lib/denko/board/led_array.rb +18 -0
- data/lib/denko/board/map.rb +46 -0
- data/lib/denko/board/message_pack.rb +7 -0
- data/lib/denko/board/one_wire.rb +34 -0
- data/lib/denko/board/pulse.rb +26 -0
- data/lib/denko/board/servo.rb +22 -0
- data/lib/denko/board/spi.rb +65 -0
- data/lib/denko/board/spi_bit_bang.rb +41 -0
- data/lib/denko/board/tone.rb +23 -0
- data/lib/denko/board/uart.rb +42 -0
- data/lib/denko/board/uart_bit_bang.rb +33 -0
- data/lib/denko/board.rb +104 -0
- data/lib/denko/connection/base.rb +75 -0
- data/lib/denko/connection/board_uart.rb +36 -0
- data/lib/denko/connection/flow_control.rb +153 -0
- data/lib/denko/connection/handshake.rb +60 -0
- data/lib/denko/connection/serial.rb +90 -0
- data/lib/denko/connection/tcp.rb +44 -0
- data/lib/denko/connection.rb +10 -0
- data/lib/denko/digital_io/button.rb +8 -0
- data/lib/denko/digital_io/input.rb +44 -0
- data/lib/denko/digital_io/output.rb +47 -0
- data/lib/denko/digital_io/relay.rb +6 -0
- data/lib/denko/digital_io/rotary_encoder.rb +107 -0
- data/lib/denko/digital_io.rb +9 -0
- data/lib/denko/display/canvas.rb +282 -0
- data/lib/denko/display/hd44780.rb +266 -0
- data/lib/denko/display/ssd1306.rb +179 -0
- data/lib/denko/display.rb +7 -0
- data/lib/denko/eeprom/built_in.rb +69 -0
- data/lib/denko/eeprom.rb +5 -0
- data/lib/denko/fonts.rb +106 -0
- data/lib/denko/i2c/bus.rb +52 -0
- data/lib/denko/i2c/peripheral.rb +38 -0
- data/lib/denko/i2c.rb +6 -0
- data/lib/denko/led/apa102.rb +87 -0
- data/lib/denko/led/base.rb +12 -0
- data/lib/denko/led/rgb.rb +38 -0
- data/lib/denko/led/seven_segment.rb +111 -0
- data/lib/denko/led/ws2812.rb +48 -0
- data/lib/denko/led.rb +13 -0
- data/lib/denko/message.rb +92 -0
- data/lib/denko/motor/l298.rb +49 -0
- data/lib/denko/motor/servo.rb +51 -0
- data/lib/denko/motor/stepper.rb +71 -0
- data/lib/denko/motor.rb +7 -0
- data/lib/denko/one_wire/bus.rb +61 -0
- data/lib/denko/one_wire/bus_enumeration.rb +88 -0
- data/lib/denko/one_wire/constants.rb +17 -0
- data/lib/denko/one_wire/helper.rb +33 -0
- data/lib/denko/one_wire/peripheral.rb +62 -0
- data/lib/denko/one_wire.rb +9 -0
- data/lib/denko/pulse_io/buzzer.rb +25 -0
- data/lib/denko/pulse_io/ir_transmitter.rb +22 -0
- data/lib/denko/pulse_io/pwm_output.rb +34 -0
- data/lib/denko/pulse_io.rb +7 -0
- data/lib/denko/rtc/ds3231.rb +48 -0
- data/lib/denko/rtc.rb +5 -0
- data/lib/denko/sensor/aht.rb +165 -0
- data/lib/denko/sensor/bme280.rb +366 -0
- data/lib/denko/sensor/dht.rb +43 -0
- data/lib/denko/sensor/ds18b20.rb +74 -0
- data/lib/denko/sensor/htu21d.rb +168 -0
- data/lib/denko/sensor/htu31d.rb +187 -0
- data/lib/denko/sensor/virtual.rb +42 -0
- data/lib/denko/sensor.rb +13 -0
- data/lib/denko/spi/base_register.rb +37 -0
- data/lib/denko/spi/bit_bang.rb +74 -0
- data/lib/denko/spi/bus.rb +44 -0
- data/lib/denko/spi/input_register.rb +130 -0
- data/lib/denko/spi/output_register.rb +67 -0
- data/lib/denko/spi/peripheral.rb +43 -0
- data/lib/denko/spi.rb +10 -0
- data/lib/denko/uart/bit_bang.rb +69 -0
- data/lib/denko/uart/hardware.rb +65 -0
- data/lib/denko/uart.rb +6 -0
- data/lib/denko/version.rb +3 -0
- data/lib/denko.rb +39 -0
- data/lib/denko_cli/generator.rb +171 -0
- data/lib/denko_cli/helper.rb +29 -0
- data/lib/denko_cli/missing_files.txt +20 -0
- data/lib/denko_cli/packages.rb +101 -0
- data/lib/denko_cli/parser.rb +73 -0
- data/lib/denko_cli/targets.rb +30 -0
- data/lib/denko_cli/targets.txt +113 -0
- data/lib/denko_cli/usage.txt +34 -0
- data/lib/denko_cli.rb +18 -0
- data/src/denko_ethernet.ino +78 -0
- data/src/denko_serial.ino +41 -0
- data/src/denko_wifi.ino +157 -0
- data/src/lib/Denko.cpp +330 -0
- data/src/lib/Denko.h +259 -0
- data/src/lib/DenkoCoreIO.cpp +322 -0
- data/src/lib/DenkoDefines.h +116 -0
- data/src/lib/DenkoEEPROM.cpp +64 -0
- data/src/lib/DenkoI2C.cpp +155 -0
- data/src/lib/DenkoIROut.cpp +33 -0
- data/src/lib/DenkoIROutESP.cpp +26 -0
- data/src/lib/DenkoLEDArray.cpp +49 -0
- data/src/lib/DenkoOneWire.cpp +156 -0
- data/src/lib/DenkoPulseInput.cpp +57 -0
- data/src/lib/DenkoSPI.cpp +165 -0
- data/src/lib/DenkoSPIBB.cpp +156 -0
- data/src/lib/DenkoServo.cpp +83 -0
- data/src/lib/DenkoTone.cpp +25 -0
- data/src/lib/DenkoUART.cpp +118 -0
- data/src/lib/DenkoUARTBB.cpp +62 -0
- data/target.yml +3 -0
- data/test/analog_io/input_test.rb +38 -0
- data/test/analog_io/output_test.rb +26 -0
- data/test/analog_io/potentiometer_test.rb +62 -0
- data/test/behaviors/board_proxy_test.rb +24 -0
- data/test/behaviors/bus_controller_addressed_test.rb +40 -0
- data/test/behaviors/bus_controller_test.rb +28 -0
- data/test/behaviors/bus_peripheral_addressed.rb +44 -0
- data/test/behaviors/bus_peripheral_test.rb +39 -0
- data/test/behaviors/callbacks_test.rb +118 -0
- data/test/behaviors/component_test.rb +56 -0
- data/test/behaviors/input_pin_test.rb +42 -0
- data/test/behaviors/listener_test.rb +60 -0
- data/test/behaviors/multi_pin_test.rb +70 -0
- data/test/behaviors/output_pin_test.rb +27 -0
- data/test/behaviors/poller_test.rb +64 -0
- data/test/behaviors/reader_test.rb +68 -0
- data/test/behaviors/single_pin_test.rb +41 -0
- data/test/behaviors/subcomponents_test.rb +75 -0
- data/test/behaviors/threaded_test.rb +98 -0
- data/test/board/board_test.rb +130 -0
- data/test/board/core_test.rb +182 -0
- data/test/board/eeprom_test.rb +34 -0
- data/test/board/helper_test.rb +38 -0
- data/test/board/i2c_test.rb +114 -0
- data/test/board/infrared_test.rb +37 -0
- data/test/board/message_test.rb +54 -0
- data/test/board/one_wire_test.rb +69 -0
- data/test/board/pulse_test.rb +51 -0
- data/test/board/servo_test.rb +47 -0
- data/test/board/spi_test.rb +97 -0
- data/test/board/tone_test.rb +42 -0
- data/test/connection/serial_test.rb +172 -0
- data/test/connection/tcp_test.rb +37 -0
- data/test/digital_io/input_test.rb +65 -0
- data/test/digital_io/output_test.rb +64 -0
- data/test/digital_io/rotary_encoder_test.rb +99 -0
- data/test/display/hd44780_test.rb +23 -0
- data/test/eeprom/built_in_test.rb +61 -0
- data/test/i2c/bus_test.rb +66 -0
- data/test/i2c/peripheral_test.rb +50 -0
- data/test/led/base_test.rb +24 -0
- data/test/led/rgb_test.rb +64 -0
- data/test/led/seven_segment_test.rb +86 -0
- data/test/motor/servo_test.rb +62 -0
- data/test/motor/stepper_test.rb +51 -0
- data/test/one_wire/bus_enumerator_test.rb +134 -0
- data/test/one_wire/bus_test.rb +142 -0
- data/test/one_wire/helper_test.rb +18 -0
- data/test/one_wire/peripheral_test.rb +158 -0
- data/test/pulse_io/buzzer_test.rb +48 -0
- data/test/pulse_io/ir_transmitter_test.rb +38 -0
- data/test/pulse_io/pwm_output_test.rb +72 -0
- data/test/rtc/ds3231_test.rb +55 -0
- data/test/sensor/dht_test.rb +64 -0
- data/test/sensor/ds18b20_test.rb +107 -0
- data/test/spi/base_register_test.rb +34 -0
- data/test/spi/bus_test.rb +76 -0
- data/test/spi/input_register_test.rb +140 -0
- data/test/spi/output_register_test.rb +93 -0
- data/test/test_helper.rb +223 -0
- data/test/uart/bitbang_test.rb +37 -0
- data/tutorial/01-led/led.fzz +0 -0
- data/tutorial/01-led/led.pdf +0 -0
- data/tutorial/01-led/led.rb +73 -0
- data/tutorial/02-button/button.fzz +0 -0
- data/tutorial/02-button/button.pdf +0 -0
- data/tutorial/02-button/button.rb +64 -0
- data/tutorial/03-potentiometer/potentiometer.fzz +0 -0
- data/tutorial/03-potentiometer/potentiometer.pdf +0 -0
- data/tutorial/03-potentiometer/potentiometer.rb +62 -0
- data/tutorial/04-pwm_led/pwm_led.fzz +0 -0
- data/tutorial/04-pwm_led/pwm_led.pdf +0 -0
- data/tutorial/04-pwm_led/pwm_led.rb +66 -0
- data/tutorial/05-rgb_led/rgb_led.fzz +0 -0
- data/tutorial/05-rgb_led/rgb_led.pdf +0 -0
- data/tutorial/05-rgb_led/rgb_led.rb +58 -0
- data/tutorial/05-rgb_led/rgb_mapping.rb +76 -0
- data/vendor/board-maps/.gitignore +56 -0
- data/vendor/board-maps/.gitmodules +21 -0
- data/vendor/board-maps/BoardMap.h +1364 -0
- data/vendor/board-maps/README.md +51 -0
- data/vendor/board-maps/lib/boards_parser.rb +66 -0
- data/vendor/board-maps/lib/header_parser.rb +164 -0
- data/vendor/board-maps/run.rb +47 -0
- data/vendor/board-maps/yaml/0XCB_HELIOS.yml +48 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32S2.yml +25 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32S2_REVTFT.yml +25 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32S2_TFT.yml +27 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32S3.yml +29 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32S3_NOPSRAM.yml +29 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32S3_REVTFT.yml +25 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32S3_TFT.yml +27 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32_V2.yml +30 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_RP2040_CAN.yml +48 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_RP2040_DVI.yml +48 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_RP2040_PROP_MAKER.yml +48 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_RP2040_RFM.yml +48 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_RP2040_SCORPIO.yml +48 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_RP2040_THINKINK.yml +48 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_RP2040_USB_HOST.yml +48 -0
- data/vendor/board-maps/yaml/ADAFRUIT_ITSYBITSY_ESP32.yml +24 -0
- data/vendor/board-maps/yaml/ADAFRUIT_ITSYBITSY_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/ADAFRUIT_KB2040_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/ADAFRUIT_MACROPAD_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/ADAFRUIT_MATRIXPORTAL_ESP32S3.yml +16 -0
- data/vendor/board-maps/yaml/ADAFRUIT_QTPY_ESP32C3.yml +12 -0
- data/vendor/board-maps/yaml/ADAFRUIT_QTPY_ESP32S2.yml +22 -0
- data/vendor/board-maps/yaml/ADAFRUIT_QTPY_ESP32S3_NOPSRAM.yml +20 -0
- data/vendor/board-maps/yaml/ADAFRUIT_QTPY_ESP32_PICO.yml +27 -0
- data/vendor/board-maps/yaml/ADAFRUIT_QTPY_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/ADAFRUIT_STEMMAFRIEND_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/ADAFRUIT_TRINKEYQT_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/ALKS.yml +34 -0
- data/vendor/board-maps/yaml/AMPERKA_WIFI_SLOT.yml +16 -0
- data/vendor/board-maps/yaml/AVR_ADK.yml +24 -0
- data/vendor/board-maps/yaml/AVR_BT.yml +16 -0
- data/vendor/board-maps/yaml/AVR_CIRCUITPLAY.yml +14 -0
- data/vendor/board-maps/yaml/AVR_DUEMILANOVE.yml +16 -0
- data/vendor/board-maps/yaml/AVR_ESPLORA.yml +20 -0
- data/vendor/board-maps/yaml/AVR_ETHERNET.yml +16 -0
- data/vendor/board-maps/yaml/AVR_FIO.yml +16 -0
- data/vendor/board-maps/yaml/AVR_GEMMA.yml +6 -0
- data/vendor/board-maps/yaml/AVR_INDUSTRIAL101.yml +20 -0
- data/vendor/board-maps/yaml/AVR_LEONARDO.yml +20 -0
- data/vendor/board-maps/yaml/AVR_LEONARDO_ETH.yml +20 -0
- data/vendor/board-maps/yaml/AVR_LILYPAD.yml +16 -0
- data/vendor/board-maps/yaml/AVR_LILYPAD_USB.yml +20 -0
- data/vendor/board-maps/yaml/AVR_LININO_ONE.yml +20 -0
- data/vendor/board-maps/yaml/AVR_MEGA.yml +24 -0
- data/vendor/board-maps/yaml/AVR_MEGA2560.yml +24 -0
- data/vendor/board-maps/yaml/AVR_MICRO.yml +20 -0
- data/vendor/board-maps/yaml/AVR_MINI.yml +16 -0
- data/vendor/board-maps/yaml/AVR_NANO.yml +16 -0
- data/vendor/board-maps/yaml/AVR_NANO_EVERY.yml +22 -0
- data/vendor/board-maps/yaml/AVR_NG.yml +16 -0
- data/vendor/board-maps/yaml/AVR_PRO.yml +16 -0
- data/vendor/board-maps/yaml/AVR_ROBOT_CONTROL.yml +22 -0
- data/vendor/board-maps/yaml/AVR_ROBOT_MOTOR.yml +19 -0
- data/vendor/board-maps/yaml/AVR_UNO.yml +16 -0
- data/vendor/board-maps/yaml/AVR_UNO_WIFI_DEV_ED.yml +16 -0
- data/vendor/board-maps/yaml/AVR_UNO_WIFI_REV2.yml +22 -0
- data/vendor/board-maps/yaml/AVR_YUN.yml +20 -0
- data/vendor/board-maps/yaml/AVR_YUNMINI.yml +20 -0
- data/vendor/board-maps/yaml/AirM2M_CORE_ESP32C3.yml +14 -0
- data/vendor/board-maps/yaml/BEE_DATA_LOGGER.yml +39 -0
- data/vendor/board-maps/yaml/BPI_BIT.yml +9 -0
- data/vendor/board-maps/yaml/BPI_LEAF_S3.yml +31 -0
- data/vendor/board-maps/yaml/BRIDGETEK_IDM2040-7A.yml +48 -0
- data/vendor/board-maps/yaml/BeeMotionS3.yml +40 -0
- data/vendor/board-maps/yaml/Bee_Motion.yml +27 -0
- data/vendor/board-maps/yaml/Bee_Motion_Mini.yml +1 -0
- data/vendor/board-maps/yaml/Bee_S3.yml +38 -0
- data/vendor/board-maps/yaml/CHALLENGER_2040_LORA_RP2040.yml +39 -0
- data/vendor/board-maps/yaml/CHALLENGER_2040_LTE_RP2040.yml +38 -0
- data/vendor/board-maps/yaml/CHALLENGER_2040_NFC_RP2040.yml +32 -0
- data/vendor/board-maps/yaml/CHALLENGER_2040_SDRTC_RP2040.yml +36 -0
- data/vendor/board-maps/yaml/CHALLENGER_2040_SUBGHZ_RP2040.yml +39 -0
- data/vendor/board-maps/yaml/CHALLENGER_2040_UWB_RP2040.yml +39 -0
- data/vendor/board-maps/yaml/CHALLENGER_2040_WIFI_BLE_RP2040.yml +42 -0
- data/vendor/board-maps/yaml/CHALLENGER_2040_WIFI_RP2040.yml +38 -0
- data/vendor/board-maps/yaml/CHALLENGER_NB_2040_WIFI_RP2040.yml +38 -0
- data/vendor/board-maps/yaml/CRABIK_SLOT_ESP32_S3.yml +19 -0
- data/vendor/board-maps/yaml/CYTRON_MAKER_FEATHER_AIOT_S3.yml +26 -0
- data/vendor/board-maps/yaml/CYTRON_MAKER_NANO_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/CYTRON_MAKER_PI_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/CoreESP32.yml +49 -0
- data/vendor/board-maps/yaml/D1_MINI32.yml +36 -0
- data/vendor/board-maps/yaml/D1_UNO32.yml +28 -0
- data/vendor/board-maps/yaml/DATANOISETV_PICOADK.yml +48 -0
- data/vendor/board-maps/yaml/DENKY.yml +26 -0
- data/vendor/board-maps/yaml/DENKY_PICOV3.yml +26 -0
- data/vendor/board-maps/yaml/DENKY_WROOM32.yml +26 -0
- data/vendor/board-maps/yaml/DEPARTMENT_OF_ALCHEMY_MINIMAIN_ESP32S2.yml +26 -0
- data/vendor/board-maps/yaml/DFROBOT_BEETLE_ESP32_C3.yml +14 -0
- data/vendor/board-maps/yaml/DFROBOT_BEETLE_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/DFROBOT_FIREBEETLE_2_ESP32E.yml +44 -0
- data/vendor/board-maps/yaml/DFROBOT_FIREBEETLE_2_ESP32S3.yml +38 -0
- data/vendor/board-maps/yaml/DFROBOT_ROMEO_ESP32S3.yml +7 -0
- data/vendor/board-maps/yaml/DPU_ESP32.yml +26 -0
- data/vendor/board-maps/yaml/DYDK.yml +38 -0
- data/vendor/board-maps/yaml/DYDK1A.yml +37 -0
- data/vendor/board-maps/yaml/DYDK1Av2.yml +45 -0
- data/vendor/board-maps/yaml/DYG.yml +20 -0
- data/vendor/board-maps/yaml/DYM.yml +40 -0
- data/vendor/board-maps/yaml/DYMv2.yml +39 -0
- data/vendor/board-maps/yaml/D_Duino_32.yml +29 -0
- data/vendor/board-maps/yaml/ELECTRONICCATS_HUNTERCAT_NFC.yml +44 -0
- data/vendor/board-maps/yaml/ESP320.yml +8 -0
- data/vendor/board-maps/yaml/ESP32C3_DEV.yml +14 -0
- data/vendor/board-maps/yaml/ESP32C3_M1_I_KIT.yml +13 -0
- data/vendor/board-maps/yaml/ESP32S2_DEV.yml +33 -0
- data/vendor/board-maps/yaml/ESP32S2_THING_PLUS.yml +34 -0
- data/vendor/board-maps/yaml/ESP32S2_USB.yml +33 -0
- data/vendor/board-maps/yaml/ESP32S3_CAM_LCD.yml +7 -0
- data/vendor/board-maps/yaml/ESP32S3_DEV.yml +38 -0
- data/vendor/board-maps/yaml/ESP32_DEV.yml +26 -0
- data/vendor/board-maps/yaml/ESP32_DEVKIT_LIPO.yml +26 -0
- data/vendor/board-maps/yaml/ESP32_EVB.yml +7 -0
- data/vendor/board-maps/yaml/ESP32_GATEWAY.yml +13 -0
- data/vendor/board-maps/yaml/ESP32_GATEWAY_C.yml +13 -0
- data/vendor/board-maps/yaml/ESP32_GATEWAY_E.yml +13 -0
- data/vendor/board-maps/yaml/ESP32_GATEWAY_F.yml +13 -0
- data/vendor/board-maps/yaml/ESP32_IOT_REDBOARD.yml +27 -0
- data/vendor/board-maps/yaml/ESP32_MICROMOD.yml +24 -0
- data/vendor/board-maps/yaml/ESP32_PICO.yml +26 -0
- data/vendor/board-maps/yaml/ESP32_POE.yml +7 -0
- data/vendor/board-maps/yaml/ESP32_POE_ISO.yml +7 -0
- data/vendor/board-maps/yaml/ESP32_S3_BOX.yml +16 -0
- data/vendor/board-maps/yaml/ESP32_S3_USB_OTG.yml +11 -0
- data/vendor/board-maps/yaml/ESP32_THING.yml +27 -0
- data/vendor/board-maps/yaml/ESP32_THING_PLUS.yml +30 -0
- data/vendor/board-maps/yaml/ESP32_THING_PLUS_C.yml +30 -0
- data/vendor/board-maps/yaml/ESP32_WROOM_DA.yml +26 -0
- data/vendor/board-maps/yaml/ESP32_WROVER_KIT.yml +26 -0
- data/vendor/board-maps/yaml/ESP8266_ADAFRUIT_HUZZAH.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_AGRUMINO_LEMON_V4.yml +8 -0
- data/vendor/board-maps/yaml/ESP8266_ARDUINO_PRIMO.yml +7 -0
- data/vendor/board-maps/yaml/ESP8266_ARDUINO_STAR_OTTO.yml +7 -0
- data/vendor/board-maps/yaml/ESP8266_ARDUINO_UNOWIFI.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_ESP01.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_ESP07.yml +20 -0
- data/vendor/board-maps/yaml/ESP8266_ESP12.yml +20 -0
- data/vendor/board-maps/yaml/ESP8266_ESP13.yml +17 -0
- data/vendor/board-maps/yaml/ESP8266_ESP210.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_ESPECTRO_CORE.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_ESPINO_ESP12.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_ESPINO_ESP13.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_ESPRESSO_LITE_V1.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_ESPRESSO_LITE_V2.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_GENERIC.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_INVENT_ONE.yml +22 -0
- data/vendor/board-maps/yaml/ESP8266_NODEMCU_ESP12.yml +20 -0
- data/vendor/board-maps/yaml/ESP8266_NODEMCU_ESP12E.yml +20 -0
- data/vendor/board-maps/yaml/ESP8266_OAK.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_PHOENIX_V1.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_PHOENIX_V2.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_SCHIRMILABS_EDUINO_WIFI.yml +25 -0
- data/vendor/board-maps/yaml/ESP8266_SONOFF_BASIC.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_SONOFF_S20.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_SONOFF_SV.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_SONOFF_TH.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_THING.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_THING_DEV.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_WEMOS_D1MINI.yml +18 -0
- data/vendor/board-maps/yaml/ESP8266_WEMOS_D1MINILITE.yml +18 -0
- data/vendor/board-maps/yaml/ESP8266_WEMOS_D1MINIPRO.yml +18 -0
- data/vendor/board-maps/yaml/ESP8266_WEMOS_D1R1.yml +25 -0
- data/vendor/board-maps/yaml/ESP8266_WEMOS_D1WROOM02.yml +18 -0
- data/vendor/board-maps/yaml/ESP8266_WIO_LINK.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_XINABOX_CW01.yml +9 -0
- data/vendor/board-maps/yaml/ESPECTRO32.yml +27 -0
- data/vendor/board-maps/yaml/ESPea32.yml +27 -0
- data/vendor/board-maps/yaml/ESPino32.yml +27 -0
- data/vendor/board-maps/yaml/ET-Board.yml +26 -0
- data/vendor/board-maps/yaml/EXTREMEELEXTRONICS_RC2040.yml +46 -0
- data/vendor/board-maps/yaml/Edgebox-ESP-100.yml +7 -0
- data/vendor/board-maps/yaml/FEATHERS2.yml +33 -0
- data/vendor/board-maps/yaml/FEATHERS2NEO.yml +30 -0
- data/vendor/board-maps/yaml/FEATHERS3.yml +29 -0
- data/vendor/board-maps/yaml/FEATHER_ESP32.yml +28 -0
- data/vendor/board-maps/yaml/FLYBOARD2040_CORE.yml +48 -0
- data/vendor/board-maps/yaml/FRANZININHO_WIFI.yml +33 -0
- data/vendor/board-maps/yaml/FRANZININHO_WIFI_MSC.yml +33 -0
- data/vendor/board-maps/yaml/FROG_ESP32.yml +26 -0
- data/vendor/board-maps/yaml/FUNHOUSE_ESP32S2.yml +22 -0
- data/vendor/board-maps/yaml/GEN4_IOD.yml +9 -0
- data/vendor/board-maps/yaml/GENERIC_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/HEALTHYPI_4.yml +27 -0
- data/vendor/board-maps/yaml/HONEYLEMON.yml +27 -0
- data/vendor/board-maps/yaml/HORNBILL_ESP32_DEV.yml +27 -0
- data/vendor/board-maps/yaml/HORNBILL_ESP32_MINIMA.yml +16 -0
- data/vendor/board-maps/yaml/ILABS_2040_RPICO32_RP2040.yml +47 -0
- data/vendor/board-maps/yaml/IMBRIOS_LOGSENS_V1P1.yml +19 -0
- data/vendor/board-maps/yaml/INTOROBOT_ESP32_DEV.yml +34 -0
- data/vendor/board-maps/yaml/LILYGO_T_DISPLAY_S3.yml +26 -0
- data/vendor/board-maps/yaml/LOLIN32.yml +27 -0
- data/vendor/board-maps/yaml/LOLIN32_LITE.yml +27 -0
- data/vendor/board-maps/yaml/LOLIN_C3_MINI.yml +14 -0
- data/vendor/board-maps/yaml/LOLIN_D32.yml +27 -0
- data/vendor/board-maps/yaml/LOLIN_D32_PRO.yml +27 -0
- data/vendor/board-maps/yaml/LOLIN_S2_MINI.yml +34 -0
- data/vendor/board-maps/yaml/LOLIN_S2_PICO.yml +34 -0
- data/vendor/board-maps/yaml/LOLIN_S3.yml +32 -0
- data/vendor/board-maps/yaml/LOLIN_S3_MINI.yml +32 -0
- data/vendor/board-maps/yaml/LOLIN_S3_PRO.yml +32 -0
- data/vendor/board-maps/yaml/Lion_Bit_Dev_Board.yml +18 -0
- data/vendor/board-maps/yaml/LoPy.yml +27 -0
- data/vendor/board-maps/yaml/LoPy4.yml +27 -0
- data/vendor/board-maps/yaml/M5STACK_CORES3.yml +8 -0
- data/vendor/board-maps/yaml/M5STACK_Core2.yml +9 -0
- data/vendor/board-maps/yaml/M5STACK_FIRE.yml +10 -0
- data/vendor/board-maps/yaml/M5Stack-Timer-CAM.yml +10 -0
- data/vendor/board-maps/yaml/M5Stack_ATOM.yml +10 -0
- data/vendor/board-maps/yaml/M5Stack_ATOMS3.yml +7 -0
- data/vendor/board-maps/yaml/M5Stack_CoreInk.yml +9 -0
- data/vendor/board-maps/yaml/M5Stack_Core_ESP32.yml +10 -0
- data/vendor/board-maps/yaml/M5Stack_Station.yml +10 -0
- data/vendor/board-maps/yaml/M5Stick_C.yml +10 -0
- data/vendor/board-maps/yaml/MAGTAG29_ESP32S2.yml +21 -0
- data/vendor/board-maps/yaml/MELOPERO_COOKIE_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/MELOPERO_SHAKE_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/METRO_ESP32S2.yml +34 -0
- data/vendor/board-maps/yaml/MGBOT_IOTIK32A.yml +27 -0
- data/vendor/board-maps/yaml/MGBOT_IOTIK32B.yml +27 -0
- data/vendor/board-maps/yaml/MH_ET_LIVE_ESP32DEVKIT.yml +27 -0
- data/vendor/board-maps/yaml/MH_ET_LIVE_ESP32MINIKIT.yml +27 -0
- data/vendor/board-maps/yaml/MICROS2.yml +34 -0
- data/vendor/board-maps/yaml/MOD_WIFI_ESP8266.yml +9 -0
- data/vendor/board-maps/yaml/Metro.yml +8 -0
- data/vendor/board-maps/yaml/NANO32.yml +27 -0
- data/vendor/board-maps/yaml/NANO_RP2040_CONNECT.yml +35 -0
- data/vendor/board-maps/yaml/NEBULAS3.yml +33 -0
- data/vendor/board-maps/yaml/NEKOSYSTEMS_BL2040_MINI.yml +48 -0
- data/vendor/board-maps/yaml/NULLBITS_BIT_C_PRO.yml +48 -0
- data/vendor/board-maps/yaml/Node32s.yml +27 -0
- data/vendor/board-maps/yaml/NodeMCU_32S.yml +27 -0
- data/vendor/board-maps/yaml/ODROID_ESP32.yml +10 -0
- data/vendor/board-maps/yaml/ONEHORSE_ESP32_DEV.yml +24 -0
- data/vendor/board-maps/yaml/OROCA_EDUBOT.yml +33 -0
- data/vendor/board-maps/yaml/PIMORONI_PGA2040.yml +48 -0
- data/vendor/board-maps/yaml/PROS3.yml +28 -0
- data/vendor/board-maps/yaml/PYCOM_GPY.yml +27 -0
- data/vendor/board-maps/yaml/Piranha.yml +16 -0
- data/vendor/board-maps/yaml/Pocket32.yml +27 -0
- data/vendor/board-maps/yaml/QUANTUM.yml +26 -0
- data/vendor/board-maps/yaml/RASPBERRY_PI_PICO.yml +48 -0
- data/vendor/board-maps/yaml/RASPBERRY_PI_PICO_W.yml +48 -0
- data/vendor/board-maps/yaml/REDPILL_ESP32S3.yml +32 -0
- data/vendor/board-maps/yaml/RMP.yml +33 -0
- data/vendor/board-maps/yaml/SAMD_CIRCUITPLAYGROUND_EXPRESS.yml +12 -0
- data/vendor/board-maps/yaml/SAMD_MKR1000.yml +20 -0
- data/vendor/board-maps/yaml/SAMD_MKRFox1200.yml +19 -0
- data/vendor/board-maps/yaml/SAMD_MKRGSM1400.yml +15 -0
- data/vendor/board-maps/yaml/SAMD_MKRNB1500.yml +15 -0
- data/vendor/board-maps/yaml/SAMD_MKRVIDOR4000.yml +19 -0
- data/vendor/board-maps/yaml/SAMD_MKRWAN1300.yml +18 -0
- data/vendor/board-maps/yaml/SAMD_MKRWAN1310.yml +18 -0
- data/vendor/board-maps/yaml/SAMD_MKRWIFI1010.yml +19 -0
- data/vendor/board-maps/yaml/SAMD_MKRZERO.yml +19 -0
- data/vendor/board-maps/yaml/SAMD_NANO_33_IOT.yml +13 -0
- data/vendor/board-maps/yaml/SAMD_TIAN.yml +15 -0
- data/vendor/board-maps/yaml/SAMD_ZERO.yml +14 -0
- data/vendor/board-maps/yaml/SAM_DUE.yml +26 -0
- data/vendor/board-maps/yaml/SAM_ZERO.yml +15 -0
- data/vendor/board-maps/yaml/SEEED_INDICATOR_RP2040.yml +47 -0
- data/vendor/board-maps/yaml/SEEED_XIAO_RP2040.yml +29 -0
- data/vendor/board-maps/yaml/SOLDERPARTY_RP2040_STAMP.yml +48 -0
- data/vendor/board-maps/yaml/SONOFF_DUALR3.yml +26 -0
- data/vendor/board-maps/yaml/SPARKFUN_PROMICRO_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/SPARKFUN_THINGPLUS_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/STAMP_S3.yml +4 -0
- data/vendor/board-maps/yaml/TAMC_TERMOD_S3.yml +31 -0
- data/vendor/board-maps/yaml/TBEAM_USE_RADIO_SX1262.yml +23 -0
- data/vendor/board-maps/yaml/TBEAM_USE_RADIO_SX1268.yml +23 -0
- data/vendor/board-maps/yaml/TBEAM_USE_RADIO_SX1276.yml +23 -0
- data/vendor/board-maps/yaml/TBEAM_USE_RADIO_SX1278.yml +23 -0
- data/vendor/board-maps/yaml/TBEAM_USE_RADIO_SX1280.yml +23 -0
- data/vendor/board-maps/yaml/TBeam.yml +23 -0
- data/vendor/board-maps/yaml/TINYPICO.yml +26 -0
- data/vendor/board-maps/yaml/TINYS2.yml +33 -0
- data/vendor/board-maps/yaml/TINYS3.yml +25 -0
- data/vendor/board-maps/yaml/TTGO-T-OI-PLUS_DEV.yml +11 -0
- data/vendor/board-maps/yaml/TTGO_LoRa32_V1.yml +28 -0
- data/vendor/board-maps/yaml/TTGO_LoRa32_V2.yml +28 -0
- data/vendor/board-maps/yaml/TTGO_LoRa32_v21new.yml +28 -0
- data/vendor/board-maps/yaml/TTGO_T1.yml +27 -0
- data/vendor/board-maps/yaml/TTGO_T7_V13_Mini32.yml +27 -0
- data/vendor/board-maps/yaml/TTGO_T7_V14_Mini32.yml +27 -0
- data/vendor/board-maps/yaml/TWATCH_2020_V1.yml +10 -0
- data/vendor/board-maps/yaml/TWATCH_2020_V2.yml +10 -0
- data/vendor/board-maps/yaml/TWATCH_2020_V3.yml +10 -0
- data/vendor/board-maps/yaml/TWATCH_BASE.yml +10 -0
- data/vendor/board-maps/yaml/TWatch.yml +10 -0
- data/vendor/board-maps/yaml/Trueverit_ESP32_Universal_IoT_Driver.yml +18 -0
- data/vendor/board-maps/yaml/Trueverit_ESP32_Universal_IoT_Driver_MK_II.yml +18 -0
- data/vendor/board-maps/yaml/UBLOX_NINA_W10.yml +48 -0
- data/vendor/board-maps/yaml/UBLOX_NORA_W10.yml +43 -0
- data/vendor/board-maps/yaml/UPESY_RP2040_DEVKIT.yml +48 -0
- data/vendor/board-maps/yaml/VALTRACK_V4_MFW_ESP32_C3.yml +23 -0
- data/vendor/board-maps/yaml/VALTRACK_V4_VTS_ESP32_C3.yml +23 -0
- data/vendor/board-maps/yaml/VIYALAB_MIZU_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/WATCHY.yml +7 -0
- data/vendor/board-maps/yaml/WATCHY_V10.yml +7 -0
- data/vendor/board-maps/yaml/WATCHY_V15.yml +7 -0
- data/vendor/board-maps/yaml/WATCHY_V20.yml +7 -0
- data/vendor/board-maps/yaml/WAVESHARE_RP2040_LCD_0_96.yml +47 -0
- data/vendor/board-maps/yaml/WAVESHARE_RP2040_LCD_1_28.yml +47 -0
- data/vendor/board-maps/yaml/WAVESHARE_RP2040_ONE.yml +47 -0
- data/vendor/board-maps/yaml/WAVESHARE_RP2040_PLUS.yml +48 -0
- data/vendor/board-maps/yaml/WAVESHARE_RP2040_ZERO.yml +47 -0
- data/vendor/board-maps/yaml/WESP32.yml +17 -0
- data/vendor/board-maps/yaml/WIDORA_AIR.yml +34 -0
- data/vendor/board-maps/yaml/WIFIDUINO_ESP8266.yml +23 -0
- data/vendor/board-maps/yaml/WIFINFO.yml +20 -0
- data/vendor/board-maps/yaml/WIPY3.yml +27 -0
- data/vendor/board-maps/yaml/WIZNET_5100S_EVB_PICO.yml +48 -0
- data/vendor/board-maps/yaml/WIZNET_5500_EVB_PICO.yml +48 -0
- data/vendor/board-maps/yaml/WIZNET_WIZFI360_EVB_PICO.yml +48 -0
- data/vendor/board-maps/yaml/WT32_ETH01.yml +8 -0
- data/vendor/board-maps/yaml/WiFiduino32S3.yml +27 -0
- data/vendor/board-maps/yaml/WiFiduinoV2.yml +27 -0
- data/vendor/board-maps/yaml/Wifiduino32.yml +40 -0
- data/vendor/board-maps/yaml/XIAO_ESP32C3.yml +22 -0
- data/vendor/board-maps/yaml/XIAO_ESP32S3.yml +36 -0
- data/vendor/board-maps/yaml/YD_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/atmegazero_esp32s2.yml +30 -0
- data/vendor/board-maps/yaml/connaxio_espoir.yml +18 -0
- data/vendor/board-maps/yaml/esp32vn_iot_uno.yml +22 -0
- data/vendor/board-maps/yaml/fm_devkit.yml +15 -0
- data/vendor/board-maps/yaml/heltec_wifi_32_lora_V3.yml +31 -0
- data/vendor/board-maps/yaml/heltec_wifi_kit_32.yml +28 -0
- data/vendor/board-maps/yaml/heltec_wifi_kit_32_V3.yml +32 -0
- data/vendor/board-maps/yaml/heltec_wifi_lora_32.yml +27 -0
- data/vendor/board-maps/yaml/heltec_wifi_lora_32_V2.yml +27 -0
- data/vendor/board-maps/yaml/heltec_wireless_stick.yml +27 -0
- data/vendor/board-maps/yaml/heltec_wireless_stick_LITE.yml +27 -0
- data/vendor/board-maps/yaml/openkb.yml +27 -0
- data/vendor/board-maps/yaml/roboheart_hercules.yml +17 -0
- data/vendor/board-maps/yaml/sensesiot_weizen.yml +26 -0
- data/vendor/board-maps/yaml/uPesy_WROOM.yml +27 -0
- data/vendor/board-maps/yaml/uPesy_WROVER.yml +27 -0
- data/vendor/board-maps/yaml/unphone8.yml +32 -0
- data/vendor/board-maps/yaml/unphone9.yml +32 -0
- data/vendor/board-maps/yaml/wifi_kit_8.yml +15 -0
- metadata +800 -0
@@ -0,0 +1,187 @@
|
|
1
|
+
module Denko
|
2
|
+
module Sensor
|
3
|
+
class HTU31D
|
4
|
+
include I2C::Peripheral
|
5
|
+
include Behaviors::Poller
|
6
|
+
|
7
|
+
# Commands
|
8
|
+
RESET = 0x1E
|
9
|
+
RESET_TIME = 0.015 # Reset time in seconds.
|
10
|
+
HEATER_ON = 0X04
|
11
|
+
HEATER_OFF = 0X02
|
12
|
+
READ_T_AND_H = 0x00 # Returns 6 bytes: [T_MSB, T_LSB, T_CRC, H_MSB, H_LSB, H_CRC]
|
13
|
+
READ_H = 0x10 # Returns 3 bytes: [H_MSB, H_LSB, H_CRC]
|
14
|
+
READ_SERIAL = 0x0A # Returns 6 bytes: [S1, S1_CRC, S2, S2_CRC, S3, S3_CRC]
|
15
|
+
READ_DIAGNOSTIC = 0x08 # Returns 1 byte: [HEATER, T_LOW, T_HIGH, T_RUN, H_LOW, H_HIGH, H_RUN, NVM_ERR]
|
16
|
+
#
|
17
|
+
# HEATER : Bit set if heater is turned on.
|
18
|
+
# T_LOW / T_HIGH : Bit set if temperature is outside range of -50 to 150 C.
|
19
|
+
# H_LOW / H_HIGH : Bit set if humidity is outside range of -10 to 120 % RH.
|
20
|
+
# T_RUN / H_RUN : Bit set if storage register under/overruns, truncated to min or max integer value.
|
21
|
+
# NVM_ERR : Bit set if internal CRC failed.
|
22
|
+
#
|
23
|
+
START_CONVERSION = 0x40 # Must be OR'ed with resolution setting bits.
|
24
|
+
|
25
|
+
# User can give resolutions as integer from 0-3, as shown in the datasheet.
|
26
|
+
T_RESOLUTIONS = {
|
27
|
+
0 => 0x00, # LSBIT = 0.040 C
|
28
|
+
1 => 0x02, # LSBIT = 0.025 C
|
29
|
+
2 => 0x04, # LSBIT = 0.016 C
|
30
|
+
3 => 0x06, # LSBIT = 0.012 C
|
31
|
+
}
|
32
|
+
H_RESOLUTIONS = {
|
33
|
+
0 => 0x00, # LSBIT = 0.020%
|
34
|
+
1 => 0x08, # LSBIT = 0.014%
|
35
|
+
2 => 0x10, # LSBIT = 0.010%
|
36
|
+
3 => 0x18, # LSBIT = 0.007%
|
37
|
+
}
|
38
|
+
|
39
|
+
# Leave some margin for error, since this doesn't lock the bus during conversion like the HTU21D.
|
40
|
+
CONVERSION_SAFETY_FACTOR = 1.2
|
41
|
+
|
42
|
+
# Conversion times in seconds.
|
43
|
+
T_CONVERSION_TIMES = {
|
44
|
+
0 => 0.00111 * CONVERSION_SAFETY_FACTOR,
|
45
|
+
1 => 0.00214 * CONVERSION_SAFETY_FACTOR,
|
46
|
+
2 => 0.00421 * CONVERSION_SAFETY_FACTOR,
|
47
|
+
3 => 0.00834 * CONVERSION_SAFETY_FACTOR,
|
48
|
+
}
|
49
|
+
H_CONVERSION_TIMES = {
|
50
|
+
0 => 0.00157 * CONVERSION_SAFETY_FACTOR,
|
51
|
+
1 => 0.00306 * CONVERSION_SAFETY_FACTOR,
|
52
|
+
2 => 0.00603 * CONVERSION_SAFETY_FACTOR,
|
53
|
+
3 => 0.01198 * CONVERSION_SAFETY_FACTOR,
|
54
|
+
}
|
55
|
+
|
56
|
+
def before_initialize(options={})
|
57
|
+
@i2c_address = 0x40
|
58
|
+
super(options)
|
59
|
+
end
|
60
|
+
|
61
|
+
def after_initialize(options={})
|
62
|
+
super(options)
|
63
|
+
|
64
|
+
# Avoid repeated memory allocation for callback data and state.
|
65
|
+
@reading = { temperature: nil, humidity: nil }
|
66
|
+
self.state = { temperature: nil, humidity: nil }
|
67
|
+
@resolutions = { temperature: 0, humidity: 0 }
|
68
|
+
|
69
|
+
reset
|
70
|
+
end
|
71
|
+
|
72
|
+
def reset
|
73
|
+
i2c_write [RESET]
|
74
|
+
sleep RESET_TIME
|
75
|
+
@heater_on = false
|
76
|
+
end
|
77
|
+
|
78
|
+
def heater_on?
|
79
|
+
@heater_on
|
80
|
+
end
|
81
|
+
|
82
|
+
def heater_off?
|
83
|
+
!@heater_on
|
84
|
+
end
|
85
|
+
|
86
|
+
def heater_on
|
87
|
+
i2c_write [HEATER_ON]
|
88
|
+
@heater_on = true
|
89
|
+
end
|
90
|
+
|
91
|
+
def heater_off
|
92
|
+
i2c_write [HEATER_OFF]
|
93
|
+
@heater_on = false
|
94
|
+
end
|
95
|
+
|
96
|
+
def temperature_resolution
|
97
|
+
@resolutions[:temperature]
|
98
|
+
end
|
99
|
+
|
100
|
+
def temperature_resolution=(setting)
|
101
|
+
raise ArgumentError, "wrong resolution given: #{setting}. Must be in range 0..3" unless (0..3).include?(setting)
|
102
|
+
@resolutions[:temperature] = setting
|
103
|
+
end
|
104
|
+
|
105
|
+
def humidity_resolution
|
106
|
+
@resolutions[:humidity]
|
107
|
+
end
|
108
|
+
|
109
|
+
def humidity_resolution=(setting)
|
110
|
+
raise ArgumentError, "wrong resolution given: #{setting}. Must be in range 0..3" unless (0..3).include?(setting)
|
111
|
+
@resolutions[:humidity] = setting
|
112
|
+
end
|
113
|
+
|
114
|
+
def [](key)
|
115
|
+
@state_mutex.synchronize do
|
116
|
+
return @state[key]
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def _read
|
121
|
+
# Calculate total conversion time.
|
122
|
+
conversion_time = T_CONVERSION_TIMES[temperature_resolution] +
|
123
|
+
H_CONVERSION_TIMES[humidity_resolution]
|
124
|
+
|
125
|
+
# Build the conversion command from the set resolutions.
|
126
|
+
conversion_command = START_CONVERSION | T_RESOLUTIONS[temperature_resolution] | H_RESOLUTIONS[humidity_resolution]
|
127
|
+
|
128
|
+
# Write it and sleep.
|
129
|
+
i2c_write [conversion_command]
|
130
|
+
sleep conversion_time
|
131
|
+
|
132
|
+
# Write the read command and read back 6 bytes.
|
133
|
+
i2c_read(READ_T_AND_H, 6)
|
134
|
+
end
|
135
|
+
|
136
|
+
def pre_callback_filter(bytes)
|
137
|
+
# Bytes given as: [T_MSB, T_LSB, T_CRC, H_MSB, H_LSB, H_CRC]
|
138
|
+
|
139
|
+
# Temperature
|
140
|
+
t_raw = (bytes[0] << 8) | bytes[1]
|
141
|
+
if calculate_crc(t_raw) != bytes[2]
|
142
|
+
@reading[:temperature] = nil
|
143
|
+
else
|
144
|
+
@reading[:temperature] = (165 * t_raw.to_f / 65535) - 40
|
145
|
+
end
|
146
|
+
|
147
|
+
# Humidity
|
148
|
+
h_raw = (bytes[3] << 8) | bytes[4]
|
149
|
+
if calculate_crc(h_raw) != bytes[5]
|
150
|
+
@reading[:humidity] = nil
|
151
|
+
else
|
152
|
+
@reading[:humidity] = h_raw.to_f / 655.35
|
153
|
+
end
|
154
|
+
|
155
|
+
# Ignore entire reading if either CRC failed.
|
156
|
+
return nil unless (@reading[:temperature] && @reading[:humidity])
|
157
|
+
@reading
|
158
|
+
end
|
159
|
+
|
160
|
+
def update_state(reading)
|
161
|
+
@state_mutex.synchronize do
|
162
|
+
@state[:temperature] = reading[:temperature]
|
163
|
+
@state[:humidity] = reading[:humidity]
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
#
|
168
|
+
# CRC calculation adapted from offical driver, found here:
|
169
|
+
# https://github.com/TEConnectivity/HTU21D_Generic_C_Driver/blob/master/htu21d.c#L275
|
170
|
+
#
|
171
|
+
def calculate_crc(value)
|
172
|
+
polynomial = 0x988000 # x^8 + x^5 + x^4 + 1
|
173
|
+
msb = 0x800000
|
174
|
+
mask = 0xFF8000
|
175
|
+
result = value << 8 # Pad right with length of output CRC
|
176
|
+
|
177
|
+
while msb != 0x80
|
178
|
+
result = ((result ^ polynomial) & mask) | (result & ~mask) if (result & msb !=0)
|
179
|
+
msb >>= 1
|
180
|
+
mask >>= 1
|
181
|
+
polynomial >>= 1
|
182
|
+
end
|
183
|
+
result
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Denko
|
2
|
+
module Sensor
|
3
|
+
class Temperature
|
4
|
+
include Behaviors::Poller
|
5
|
+
|
6
|
+
def initialize(sensor)
|
7
|
+
@sensor = sensor
|
8
|
+
super
|
9
|
+
end
|
10
|
+
|
11
|
+
def _read
|
12
|
+
@sensor.read_temperature
|
13
|
+
end
|
14
|
+
|
15
|
+
alias :celsius :state
|
16
|
+
alias :to_i :state
|
17
|
+
|
18
|
+
def fahrenheit
|
19
|
+
(celsius * 9 / 5) + 32
|
20
|
+
end
|
21
|
+
|
22
|
+
def kelvin
|
23
|
+
celsius + 273.15
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class Humidity
|
28
|
+
include Behaviors::Poller
|
29
|
+
|
30
|
+
def initialize(sensor)
|
31
|
+
@sensor = sensor
|
32
|
+
super
|
33
|
+
end
|
34
|
+
|
35
|
+
def _read
|
36
|
+
@sensor.read_humidity
|
37
|
+
end
|
38
|
+
|
39
|
+
alias :to_i :state
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/denko/sensor.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
module Denko
|
2
|
+
module Sensor
|
3
|
+
autoload :Temperature, "#{__dir__}/sensor/virtual"
|
4
|
+
autoload :Humidity, "#{__dir__}/sensor/virtual"
|
5
|
+
autoload :DHT, "#{__dir__}/sensor/dht"
|
6
|
+
autoload :DS18B20, "#{__dir__}/sensor/ds18b20"
|
7
|
+
autoload :BME280, "#{__dir__}/sensor/bme280"
|
8
|
+
autoload :HTU21D, "#{__dir__}/sensor/htu21d"
|
9
|
+
autoload :HTU31D, "#{__dir__}/sensor/htu31d"
|
10
|
+
autoload :AHT10, "#{__dir__}/sensor/aht"
|
11
|
+
autoload :AHT20, "#{__dir__}/sensor/aht"
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Denko
|
2
|
+
module SPI
|
3
|
+
class BaseRegister
|
4
|
+
include Peripheral
|
5
|
+
#
|
6
|
+
# Registers act as a Board for components that need only digital pins in
|
7
|
+
# in their I/O direction. Give the register as a 'board' when initializing a
|
8
|
+
# new component, and pin numbers that map onto the registers parallel output pins.
|
9
|
+
#
|
10
|
+
include Behaviors::BoardProxy
|
11
|
+
|
12
|
+
attr_reader :bytes
|
13
|
+
|
14
|
+
def before_initialize(options={})
|
15
|
+
super(options)
|
16
|
+
#
|
17
|
+
# To use the register as a board proxy, we need to know how many
|
18
|
+
# bytes there are and map each bit to a virtual pin.
|
19
|
+
# Defaults to 1 byte. Ignore if writing to the register directly.
|
20
|
+
#
|
21
|
+
@bytes = options[:bytes] || 1
|
22
|
+
#
|
23
|
+
# When used as a board proxy, store the state of each register
|
24
|
+
# pin as a 0 or 1 in an array that is (@bytes * 8) long. Zero out to start.
|
25
|
+
#
|
26
|
+
@state = Array.new(@bytes*8) { 0 }
|
27
|
+
end
|
28
|
+
|
29
|
+
def after_initialize(options={})
|
30
|
+
super(options)
|
31
|
+
|
32
|
+
# Drive select pin high by default.
|
33
|
+
self.high
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Denko
|
2
|
+
module SPI
|
3
|
+
class BitBang
|
4
|
+
include Behaviors::MultiPin
|
5
|
+
include Behaviors::BusController
|
6
|
+
include Behaviors::Reader
|
7
|
+
|
8
|
+
def initialize_pins(options={})
|
9
|
+
# Allow pin aliases.
|
10
|
+
pins[:input] = pins[:input] || pins[:poci] || pins[:miso]
|
11
|
+
pins[:output] = pins[:output] || pins[:pico] || pins[:mosi]
|
12
|
+
pins[:clock] = pins[:clock] || pins[:sck] || pins[:clk]
|
13
|
+
|
14
|
+
# Clean up the pins hash.
|
15
|
+
[:poci, :miso, :pico, :mosi, :sck, :clk].each { |key| pins.delete(key) }
|
16
|
+
|
17
|
+
# Validate input or output pin.
|
18
|
+
unless pins[:input] || pins[:output]
|
19
|
+
raise ArgumentError, "no input or output pin given. Require either or both"
|
20
|
+
end
|
21
|
+
|
22
|
+
# If only output or input, set the other 255 for a one-directional bus.
|
23
|
+
pins[:input] = 255 if pins[:output] && !pins[:input]
|
24
|
+
pins[:output] = 255 if pins[:input] && !pins[:output]
|
25
|
+
|
26
|
+
require_pins(:clock, :input, :output)
|
27
|
+
end
|
28
|
+
|
29
|
+
def transfer(select_pin, write: [], read: 0, frequency: nil, mode: 0, bit_order: :msbfirst)
|
30
|
+
board.spi_bb_transfer select_pin, clock: pins[:clock], output: pins[:output], input: pins[:input],
|
31
|
+
write: write, read: read, mode: mode, bit_order: bit_order
|
32
|
+
end
|
33
|
+
|
34
|
+
def listen(select_pin, read: 0, frequency: nil, mode: 0, bit_order: :msbfirst)
|
35
|
+
board.spi_bb_listen select_pin, clock: pins[:clock], input: pins[:input],
|
36
|
+
read: read, mode: mode, bit_order: bit_order
|
37
|
+
end
|
38
|
+
|
39
|
+
# Uses regular Board#spi_stop since listeners are shared.
|
40
|
+
def stop(pin)
|
41
|
+
board.spi_stop(pin)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Delegate this to board so peripherals can initialize their select pins.
|
45
|
+
def set_pin_mode(*args)
|
46
|
+
board.set_pin_mode(*args)
|
47
|
+
end
|
48
|
+
|
49
|
+
def convert_pin(pin)
|
50
|
+
board.convert_pin(pin)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Add peripheral to self and the board. It gets callbacks directly from the board.
|
54
|
+
def add_component(component)
|
55
|
+
# Treat pin 255 as the component having no select pin. Mostly for APA102.
|
56
|
+
return if component.pin == 255
|
57
|
+
|
58
|
+
pins = components.map { |c| c.pin }
|
59
|
+
if pins.include? component.pin
|
60
|
+
raise ArgumentError, "duplicate select pin for #{component}"
|
61
|
+
end
|
62
|
+
|
63
|
+
components << component
|
64
|
+
board.add_component(component)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Remove peripheral from self and the board.
|
68
|
+
def remove_component(component)
|
69
|
+
components.delete(component)
|
70
|
+
board.remove_component(component)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Denko
|
2
|
+
module SPI
|
3
|
+
class Bus
|
4
|
+
include Behaviors::Component
|
5
|
+
include Behaviors::BusController
|
6
|
+
include Behaviors::Reader
|
7
|
+
|
8
|
+
# Board expects all components to have #pin.
|
9
|
+
attr_reader :pin
|
10
|
+
|
11
|
+
# Forward some methods directly to the board.
|
12
|
+
extend Forwardable
|
13
|
+
|
14
|
+
# Forward SPI methods with prefixed names.
|
15
|
+
def_delegator :board, :spi_transfer, :transfer
|
16
|
+
def_delegator :board, :spi_listen, :listen
|
17
|
+
def_delegator :board, :spi_stop, :stop
|
18
|
+
|
19
|
+
# Forward pin control methods with same names for board proxying.
|
20
|
+
def_delegator :board, :convert_pin
|
21
|
+
def_delegator :board, :set_pin_mode
|
22
|
+
|
23
|
+
# Add peripheral to self and the board. It gets callbacks directly from the board.
|
24
|
+
def add_component(component)
|
25
|
+
# Treat pin 255 as the component having no select pin. Mostly for APA102.
|
26
|
+
return if component.pin == 255
|
27
|
+
|
28
|
+
pins = components.map { |c| c.pin }
|
29
|
+
if pins.include? component.pin
|
30
|
+
raise ArgumentError, "duplicate select pin for #{component}"
|
31
|
+
end
|
32
|
+
|
33
|
+
components << component
|
34
|
+
board.add_component(component)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Remove peripheral from self and the board.
|
38
|
+
def remove_component(component)
|
39
|
+
components.delete(component)
|
40
|
+
board.remove_component(component)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
module Denko
|
2
|
+
module SPI
|
3
|
+
class InputRegister < BaseRegister
|
4
|
+
|
5
|
+
def before_initialize(options={})
|
6
|
+
super(options)
|
7
|
+
#
|
8
|
+
# Keep track of whether anything is listening or reading a specific pin.
|
9
|
+
# This might be separate from whether a component is attached or not.
|
10
|
+
#
|
11
|
+
@reading_pins = Array.new(@bytes*8) { false }
|
12
|
+
@listening_pins = Array.new(@bytes*8) { false }
|
13
|
+
end
|
14
|
+
|
15
|
+
def after_initialize(options={})
|
16
|
+
super(options)
|
17
|
+
enable_proxy
|
18
|
+
end
|
19
|
+
|
20
|
+
def read
|
21
|
+
spi_read(@bytes)
|
22
|
+
end
|
23
|
+
|
24
|
+
def listen
|
25
|
+
spi_listen(@bytes)
|
26
|
+
end
|
27
|
+
|
28
|
+
def stop
|
29
|
+
spi_stop
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# BoardProxy interface
|
34
|
+
#
|
35
|
+
def digital_read(pin)
|
36
|
+
# Remember what pin was read and force callbacks to run next update.
|
37
|
+
add_callback(:force_update) { Proc.new{} }
|
38
|
+
@reading_pins[pin] = true
|
39
|
+
|
40
|
+
# Don't actually call #read if already listening.
|
41
|
+
read unless any_listening
|
42
|
+
end
|
43
|
+
|
44
|
+
def digital_listen(pin, divider)
|
45
|
+
listen unless any_listening
|
46
|
+
@listening_pins[pin] = true
|
47
|
+
end
|
48
|
+
|
49
|
+
def stop_listener(pin)
|
50
|
+
@listening_pins[pin] = false
|
51
|
+
stop unless any_listening
|
52
|
+
end
|
53
|
+
|
54
|
+
def any_listening
|
55
|
+
@listening_pins.each { |p| return true if p }
|
56
|
+
false
|
57
|
+
end
|
58
|
+
|
59
|
+
#
|
60
|
+
# Mimic Board#update, but in a callback fired through #update.
|
61
|
+
# This doesn't interfere with using the register directly,
|
62
|
+
# and doesn't fire if the board isn't acting as a proxy (no components).
|
63
|
+
#
|
64
|
+
def enable_proxy
|
65
|
+
self.add_callback(:board_proxy) do |bit_array|
|
66
|
+
bit_array.each_with_index do |value, pin|
|
67
|
+
components.each do |part|
|
68
|
+
update_component(part, pin, value) if pin == part.pin
|
69
|
+
end
|
70
|
+
@reading_pins[pin] = false
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
#
|
76
|
+
# Override Callbacks#update to make sure we handle :force_update
|
77
|
+
# within the main mutex lock.
|
78
|
+
#
|
79
|
+
def update(message)
|
80
|
+
bits = byte_array_to_bit_array(message.split(","))
|
81
|
+
|
82
|
+
@callback_mutex.synchronize {
|
83
|
+
#
|
84
|
+
# The Arduino code does not de-duplicate repeated state.
|
85
|
+
# Do it here, but if a :force_update callback exists, run anyway.
|
86
|
+
#
|
87
|
+
if (bits != @state)|| @callbacks[:force_update]
|
88
|
+
@callbacks.each_value do |array|
|
89
|
+
array.each { |callback| callback.call(bits) }
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
# Remove both :read and :force update while inside the lock.
|
94
|
+
@callbacks.delete(:read)
|
95
|
+
@callbacks.delete(:force_update)
|
96
|
+
}
|
97
|
+
@state = bits
|
98
|
+
end
|
99
|
+
|
100
|
+
def update_component(part, pin, value)
|
101
|
+
# Update if component is listening and value has changed.
|
102
|
+
if @listening_pins[pin] && (value != @state[pin])
|
103
|
+
part.update(value)
|
104
|
+
# Also update if the component forced a read.
|
105
|
+
elsif @reading_pins[pin] && @callbacks[:force_update]
|
106
|
+
part.update(value)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
#
|
111
|
+
# Convert array of bytes coming from the register into an array of bits
|
112
|
+
# to update self state and give to component callbacks.
|
113
|
+
#
|
114
|
+
def byte_array_to_bit_array(byte_array)
|
115
|
+
#
|
116
|
+
# For each array element (1 byte):
|
117
|
+
# decimal number as string -> integer -> padded string of binary digits
|
118
|
+
# -> reverse digits from reading order to array indexing order
|
119
|
+
# -> join digits of all bytes into one string
|
120
|
+
#
|
121
|
+
binary_string = byte_array.map do |byte|
|
122
|
+
byte.to_i.to_s(2).rjust(8, "0").reverse
|
123
|
+
end.join
|
124
|
+
|
125
|
+
# Split the digits out of the string into individual integers.
|
126
|
+
binary_string.split("").map { |bit| bit.to_i }
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Denko
|
2
|
+
module SPI
|
3
|
+
class OutputRegister < BaseRegister
|
4
|
+
|
5
|
+
def before_initialize(options={})
|
6
|
+
super(options)
|
7
|
+
#
|
8
|
+
# When used as a board proxy, only write sate if @write_delay seconds
|
9
|
+
# have passed since this object last got input. Better for things like SSDs
|
10
|
+
# where many bits change in sequence, but not at exactly the same time.
|
11
|
+
#
|
12
|
+
@buffer_writes = true
|
13
|
+
@buffer_writes = false if options[:buffer_writes] == false
|
14
|
+
@write_delay = options[:write_delay] || 0.001
|
15
|
+
end
|
16
|
+
|
17
|
+
def after_initialize(options={})
|
18
|
+
write
|
19
|
+
end
|
20
|
+
|
21
|
+
#
|
22
|
+
# Overrides Peripheral#write to always write @state.
|
23
|
+
# Convert bit state to array of 0-255 integers (bytes) first.
|
24
|
+
#
|
25
|
+
def write
|
26
|
+
bytes = []
|
27
|
+
@state.each_slice(8) do |slice|
|
28
|
+
# Convert nils in the slice to zero.
|
29
|
+
zeroed = slice.map { |bit| bit.to_i }
|
30
|
+
|
31
|
+
# Each slice is 8 bits of a byte, with the lowest on the left.
|
32
|
+
# Reverse to reading order (lowest right) then join into string, and convert to integer.
|
33
|
+
byte = zeroed.reverse.join.to_i(2)
|
34
|
+
|
35
|
+
# Pack bytes in reverse order.
|
36
|
+
bytes.unshift byte
|
37
|
+
end
|
38
|
+
spi_write(bytes)
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# BoardProxy interface
|
43
|
+
#
|
44
|
+
def digital_write(pin, value)
|
45
|
+
state[pin] = value # Might not be atomic?
|
46
|
+
@buffer_writes ? write_buffered(state) : write
|
47
|
+
end
|
48
|
+
|
49
|
+
def digital_read(pin)
|
50
|
+
state[pin]
|
51
|
+
end
|
52
|
+
|
53
|
+
#
|
54
|
+
# If acting as board, do writes in a separate thread and with small delay.
|
55
|
+
# Lets us catch multiple changed bits, like when hosting an SSD.
|
56
|
+
#
|
57
|
+
include Behaviors::Threaded
|
58
|
+
def write_buffered(old_state)
|
59
|
+
threaded do
|
60
|
+
sleep @write_delay
|
61
|
+
# Keep delaying if state has changed.
|
62
|
+
write if (old_state == state)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Denko
|
2
|
+
module SPI
|
3
|
+
module Peripheral
|
4
|
+
include Behaviors::OutputPin
|
5
|
+
include Behaviors::Callbacks
|
6
|
+
include Behaviors::BusPeripheral
|
7
|
+
|
8
|
+
attr_reader :spi_frequency, :spi_mode, :spi_bit_order
|
9
|
+
|
10
|
+
def before_initialize(options={})
|
11
|
+
super(options)
|
12
|
+
|
13
|
+
# Save SPI settings.
|
14
|
+
@spi_frequency = options[:spi_frequency]
|
15
|
+
@spi_mode = options[:spi_mode]
|
16
|
+
@spi_bit_order = options[:spi_bit_order]
|
17
|
+
end
|
18
|
+
|
19
|
+
#
|
20
|
+
# Delegate methods to the bus.
|
21
|
+
#
|
22
|
+
def spi_transfer(write: [], read: 0)
|
23
|
+
bus.transfer(pin, write: write, read: read, frequency: spi_frequency, mode: spi_mode, bit_order: spi_bit_order)
|
24
|
+
end
|
25
|
+
|
26
|
+
def spi_write(byte_array)
|
27
|
+
bus.transfer(pin, write: byte_array, frequency: spi_frequency, mode: spi_mode, bit_order: spi_bit_order)
|
28
|
+
end
|
29
|
+
|
30
|
+
def spi_read(num_bytes)
|
31
|
+
bus.transfer(pin, read: num_bytes, frequency: spi_frequency, mode: spi_mode, bit_order: spi_bit_order)
|
32
|
+
end
|
33
|
+
|
34
|
+
def spi_listen(num_bytes)
|
35
|
+
bus.listen(pin, read: num_bytes, frequency: spi_frequency, mode: spi_mode, bit_order: spi_bit_order)
|
36
|
+
end
|
37
|
+
|
38
|
+
def spi_stop
|
39
|
+
bus.stop(pin)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/denko/spi.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
module Denko
|
2
|
+
module SPI
|
3
|
+
autoload :Bus, "#{__dir__}/spi/bus"
|
4
|
+
autoload :BitBang, "#{__dir__}/spi/bit_bang"
|
5
|
+
autoload :Peripheral, "#{__dir__}/spi/peripheral"
|
6
|
+
autoload :BaseRegister, "#{__dir__}/spi/base_register"
|
7
|
+
autoload :InputRegister, "#{__dir__}/spi/input_register"
|
8
|
+
autoload :OutputRegister, "#{__dir__}/spi/output_register"
|
9
|
+
end
|
10
|
+
end
|