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,158 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
class OneWirePeripheralTest < MiniTest::Test
|
4
|
+
def board
|
5
|
+
@board ||= BoardMock.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def bus
|
9
|
+
return @bus if @bus
|
10
|
+
# Respond with disabled parasite power.
|
11
|
+
board.inject_read_for_pin(1, "1")
|
12
|
+
@bus ||= Denko::OneWire::Bus.new(board: board, pin: 1)
|
13
|
+
end
|
14
|
+
|
15
|
+
def part
|
16
|
+
@part ||= Denko::OneWire::Peripheral.new(bus: bus, address: 0xFFFFFFFFFFFFFFFF)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_requires_address
|
20
|
+
assert_raises(ArgumentError) { Denko::OneWire::Peripheral.new(bus: bus) }
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_atomically_locks_the_bus_mutex
|
24
|
+
mock = MiniTest::Mock.new.expect(:synchronize, nil)
|
25
|
+
bus.stub(:mutex, mock) do
|
26
|
+
part.atomically {}
|
27
|
+
end
|
28
|
+
mock.verify
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_atomically_calls_the_block_once
|
32
|
+
mock = MiniTest::Mock.new.expect(:call, nil)
|
33
|
+
part.atomically { mock.call }
|
34
|
+
mock.verify
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_match_calls_reset
|
38
|
+
mock = MiniTest::Mock.new.expect(:call, nil)
|
39
|
+
bus.stub(:reset, mock) do
|
40
|
+
part.match
|
41
|
+
end
|
42
|
+
mock.verify
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_match_skips_rom_if_alone
|
46
|
+
mock = MiniTest::Mock.new.expect(:call, nil, [0xCC])
|
47
|
+
bus.stub(:write, mock) do
|
48
|
+
part.match
|
49
|
+
end
|
50
|
+
mock.verify
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_match_matches_rom_if_not_alone
|
54
|
+
mock = MiniTest::Mock.new
|
55
|
+
mock.expect(:call, nil, [0x55])
|
56
|
+
mock.expect(:call, nil, [[255,255,255,255,255,255,255,255]])
|
57
|
+
bus.instance_variable_set(:@found_devices, [1,2])
|
58
|
+
bus.stub(:write, mock) do
|
59
|
+
part.match
|
60
|
+
end
|
61
|
+
mock.verify
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_copy_scratch_is_atomic
|
65
|
+
mock = MiniTest::Mock.new.expect(:call, nil)
|
66
|
+
part.stub(:atomically, mock) { part.copy_scratch }
|
67
|
+
mock.verify
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_copy_scratch_matches_first
|
71
|
+
mock = MiniTest::Mock.new.expect(:call, nil)
|
72
|
+
part.stub(:match, mock) { part.copy_scratch }
|
73
|
+
mock.verify
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_copy_scratch_sends_the_command
|
77
|
+
mock = MiniTest::Mock.new
|
78
|
+
mock.expect(:call, nil, [0xCC])
|
79
|
+
mock.expect(:call, nil, [0x48])
|
80
|
+
bus.stub(:write, mock) { part.copy_scratch }
|
81
|
+
mock.verify
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_copy_scratch_resets_after_command_if_parasite_power
|
85
|
+
mock = MiniTest::Mock.new.expect(:call, nil).expect(:call, nil)
|
86
|
+
bus.stub(:parasite_power, true) do
|
87
|
+
bus.stub(:reset, mock) { part.copy_scratch }
|
88
|
+
end
|
89
|
+
mock.verify
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_read_scratch_is_atomic
|
93
|
+
# Pre-initialize the bus.
|
94
|
+
bus
|
95
|
+
# Will read 9 bytes.
|
96
|
+
board.inject_read_for_component(bus, 1, "255,255,255,255,255,255,255,255")
|
97
|
+
|
98
|
+
mock = MiniTest::Mock.new.expect(:call, nil)
|
99
|
+
part.stub(:atomically, mock) { part.read_scratch(9) }
|
100
|
+
mock.verify
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_read_scratch_matches_first
|
104
|
+
# Pre-initialize the bus.
|
105
|
+
bus
|
106
|
+
# Will read 9 bytes.
|
107
|
+
board.inject_read_for_component(bus, 1, "255,255,255,255,255,255,255,255")
|
108
|
+
|
109
|
+
mock = MiniTest::Mock.new.expect(:call, nil)
|
110
|
+
part.stub(:match, mock) { part.read_scratch(9) }
|
111
|
+
mock.verify
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_read_scratch_sends_the_command
|
115
|
+
# Pre-initialize the bus.
|
116
|
+
bus
|
117
|
+
# Will read 9 bytes.
|
118
|
+
board.inject_read_for_component(bus, 1, "255,255,255,255,255,255,255,255")
|
119
|
+
|
120
|
+
mock = MiniTest::Mock.new
|
121
|
+
mock.expect(:call, nil, [0xCC])
|
122
|
+
mock.expect(:call, nil, [0xBE])
|
123
|
+
bus.stub(:write, mock) { part.read_scratch(9) }
|
124
|
+
mock.verify
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_read_scratch_reads_bytes_from_bus
|
128
|
+
# Pre-initialize the bus.
|
129
|
+
bus
|
130
|
+
# Will read 9 bytes.
|
131
|
+
board.inject_read_for_component(bus, 1, "255,255,255,255,255,255,255,255")
|
132
|
+
|
133
|
+
mock = MiniTest::Mock.new.expect(:call, nil, [9])
|
134
|
+
bus.stub(:read, mock) { part.read_scratch(9) }
|
135
|
+
mock.verify
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_write_scratch_is_atomic
|
139
|
+
mock = MiniTest::Mock.new.expect(:call, nil)
|
140
|
+
part.stub(:atomically, mock) { part.write_scratch(1) }
|
141
|
+
mock.verify
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_write_scratch_matches_first
|
145
|
+
mock = MiniTest::Mock.new.expect(:call, nil)
|
146
|
+
part.stub(:match, mock) { part.write_scratch(1) }
|
147
|
+
mock.verify
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_write_scratch_sends_the_command_and_data
|
151
|
+
mock = MiniTest::Mock.new
|
152
|
+
mock.expect(:call, nil, [0xCC])
|
153
|
+
mock.expect(:call, nil, [0x4E])
|
154
|
+
mock.expect(:call, nil, [1,2,3])
|
155
|
+
bus.stub(:write, mock) { part.write_scratch(1, 2, 3) }
|
156
|
+
mock.verify
|
157
|
+
end
|
158
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
class BuzzerTest < MiniTest::Test
|
4
|
+
def board
|
5
|
+
@board ||= BoardMock.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def part
|
9
|
+
@part ||= Denko::PulseIO::Buzzer.new(board: board, pin:8)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_low_on_initialize
|
13
|
+
assert_equal part.state, board.low
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_tone
|
17
|
+
mock = MiniTest::Mock.new
|
18
|
+
mock.expect :call, nil, [part.pin, 60, nil]
|
19
|
+
mock.expect :call, nil, [part.pin, 120, 2000]
|
20
|
+
board.stub(:tone, mock) do
|
21
|
+
part.tone(60)
|
22
|
+
part.tone(120, 2000)
|
23
|
+
end
|
24
|
+
mock.verify
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_no_tone
|
28
|
+
part
|
29
|
+
mock = MiniTest::Mock.new
|
30
|
+
mock.expect :call, nil, [part.pin]
|
31
|
+
board.stub(:no_tone, mock) do
|
32
|
+
part.no_tone
|
33
|
+
end
|
34
|
+
mock.verify
|
35
|
+
end
|
36
|
+
|
37
|
+
def stop
|
38
|
+
mock = MiniTest::Mock.new
|
39
|
+
mock.expect :call, nil
|
40
|
+
mock.expect :call, nil
|
41
|
+
part.stub(:kill_thread, mock) do
|
42
|
+
part.stub(:no_tone, mock) do
|
43
|
+
part.stop
|
44
|
+
end
|
45
|
+
end
|
46
|
+
mock.verify
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
class IRTransmitterTest < MiniTest::Test
|
4
|
+
def board
|
5
|
+
@board ||= BoardMock.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def part
|
9
|
+
@part ||= Denko::PulseIO::IRTransmitter.new(board: board, pin:1)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_pulse_count_validation
|
13
|
+
assert_raises(ArgumentError) do
|
14
|
+
part.emit Array.new(257) { 0 }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_numeric_validation
|
19
|
+
assert_raises(ArgumentError) do
|
20
|
+
part.emit ["a", "b", "c"]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_pulse_length_validation
|
25
|
+
assert_raises(ArgumentError) do
|
26
|
+
part.emit [65536]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_emits
|
31
|
+
part
|
32
|
+
mock = MiniTest::Mock.new.expect(:call, nil, [1, 38, [127,0]])
|
33
|
+
board.stub(:infrared_emit, mock) do
|
34
|
+
part.emit([127,0])
|
35
|
+
end
|
36
|
+
mock.verify
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
class PWMOutTest < Minitest::Test
|
4
|
+
def board
|
5
|
+
@board ||= BoardMock.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def part
|
9
|
+
@part ||= Denko::PulseIO::PWMOutput.new(board: board, pin: 14)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_pwm_write
|
13
|
+
enable_mock = MiniTest::Mock.new.expect :call, nil
|
14
|
+
write_mock = MiniTest::Mock.new
|
15
|
+
write_mock.expect :call, nil, [14, 128]
|
16
|
+
|
17
|
+
board.stub(:pwm_write, write_mock) do
|
18
|
+
part.stub(:pwm_enable, enable_mock) do
|
19
|
+
assert_equal :output, part.mode
|
20
|
+
part.pwm_write(128)
|
21
|
+
assert_equal 128, part.state
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
part.pwm_write(64)
|
26
|
+
assert_equal 64, part.state
|
27
|
+
assert_equal :output_pwm, part.mode
|
28
|
+
|
29
|
+
write_mock.verify
|
30
|
+
enable_mock.verify
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_write_uses_digital_write_at_limits
|
34
|
+
mock = MiniTest::Mock.new
|
35
|
+
mock.expect :call, nil, [board.high]
|
36
|
+
mock.expect :call, nil, [board.low]
|
37
|
+
part.stub(:digital_write, mock) do
|
38
|
+
part.write(board.pwm_high)
|
39
|
+
part.write(board.low)
|
40
|
+
end
|
41
|
+
mock.verify
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_write_uses_analog_write_between_limits
|
45
|
+
mock = MiniTest::Mock.new.expect :call, nil, [128]
|
46
|
+
part.stub(:pwm_write, mock) do
|
47
|
+
part.write(128)
|
48
|
+
end
|
49
|
+
mock.verify
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_pwm_enable
|
53
|
+
part
|
54
|
+
mock = Minitest::Mock.new.expect :call, nil, [14, :output_pwm]
|
55
|
+
board.stub(:set_pin_mode, mock) do
|
56
|
+
part.pwm_enable
|
57
|
+
end
|
58
|
+
mock.verify
|
59
|
+
assert_equal :output_pwm, part.mode
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_pwm_disable
|
63
|
+
part.pwm_enable
|
64
|
+
mock = Minitest::Mock.new
|
65
|
+
mock.expect :call, nil, [14, :output]
|
66
|
+
board.stub(:set_pin_mode, mock) do
|
67
|
+
part.pwm_disable
|
68
|
+
end
|
69
|
+
mock.verify
|
70
|
+
assert_equal :output, part.mode
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
class DS3231Test < MiniTest::Test
|
4
|
+
def board
|
5
|
+
@board ||= BoardMock.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def bus
|
9
|
+
return @bus if @bus
|
10
|
+
@bus = Denko::I2C::Bus.new(board: board, pin:5)
|
11
|
+
@bus
|
12
|
+
end
|
13
|
+
|
14
|
+
def part
|
15
|
+
@part ||= Denko::RTC::DS3231.new(bus: bus, address: 0x68)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_time_to_bcd
|
19
|
+
time = Time.new(2000, 1, 1, 0, 0, 0.0)
|
20
|
+
bytes = part.time_to_bcd(time)
|
21
|
+
assert_equal bytes, [0, 0, 0, 6, 1, 1, 48]
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_bcd_to_time
|
25
|
+
bytes = [0, 0, 0, 6, 1, 1, 48]
|
26
|
+
time = part.bcd_to_time(bytes)
|
27
|
+
assert_equal time, Time.new(2000, 1, 1, 0, 0, 0.0)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_time=
|
31
|
+
mock = MiniTest::Mock.new.expect :call, nil, [[0, [0, 0, 0, 6, 1, 1, 48]]]
|
32
|
+
part.stub(:i2c_write, mock) do
|
33
|
+
part.time = Time.new(2000, 1, 1, 0, 0, 0.0)
|
34
|
+
end
|
35
|
+
mock.verify
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_read
|
39
|
+
board.inject_read_for_component(part, 5, "104-0,0,0,6,1,1,48")
|
40
|
+
|
41
|
+
mock = MiniTest::Mock.new.expect :call, nil, [part.address, 0x00, 7, 100000, false]
|
42
|
+
bus.stub(:_read, mock) do
|
43
|
+
part.time
|
44
|
+
end
|
45
|
+
mock.verify
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_pre_callback_filter
|
49
|
+
mock = MiniTest::Mock.new.expect :call, nil, [Time.new(2000, 1, 1, 0, 0, 0.0)]
|
50
|
+
part.stub(:update_state, mock) do
|
51
|
+
bus.send(:update, "104-0,0,0,6,1,1,48")
|
52
|
+
end
|
53
|
+
mock.verify
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
class DHTTest < MiniTest::Test
|
4
|
+
PIN = 1
|
5
|
+
|
6
|
+
# Actual raw data from a sensor
|
7
|
+
GOOD_STRING = "14,82,77,57,26,52,26,57,26,51,32,51,26,57,26,52,72,57,26,67,72,57,26,51,27,56,72,52,77,52,77,51,26,57,72,67,26,52,26,57,26,52,26,57,26,51,31,52,26,57,72,67,26,52,26,56,72,57,26,52,26,57,72,52,77,51,72,67,72,57,72,51,32,51,26,57,26,52,72,57,72,56,72,47"
|
8
|
+
GOOD_ARRAY = [14, 82, 77, 57, 26, 52, 26, 57, 26, 51, 32, 51, 26, 57, 26, 52, 72, 57, 26, 67, 72, 57, 26, 51, 27, 56, 72, 52, 77, 52, 77, 51, 26, 57, 72, 67, 26, 52, 26, 57, 26, 52, 26, 57, 26, 51, 31, 52, 26, 57, 72, 67, 26, 52, 26, 56, 72, 57, 26, 52, 26, 57, 72, 52, 77, 51, 72, 67, 72, 57, 72, 51, 32, 51, 26, 57, 26, 52, 72, 57, 72, 56, 72, 47]
|
9
|
+
SHORT_ARRAY = [1,2,3,4,5,6]
|
10
|
+
|
11
|
+
# Make test data with a bad CRC byte (all 1s = 255).
|
12
|
+
def bad_crc
|
13
|
+
bad_crc = GOOD_ARRAY.dup
|
14
|
+
(67..82).each { |i| bad_crc[i] = 56 }
|
15
|
+
bad_crc
|
16
|
+
end
|
17
|
+
|
18
|
+
def board
|
19
|
+
@board ||= BoardMock.new
|
20
|
+
end
|
21
|
+
|
22
|
+
def part
|
23
|
+
@part ||= Denko::Sensor::DHT.new(board: board, pin:PIN)
|
24
|
+
end
|
25
|
+
|
26
|
+
# It should tell the board to do a #pulse_read
|
27
|
+
def test__read
|
28
|
+
part
|
29
|
+
mock = MiniTest::Mock.new.expect(:call, nil, [PIN], reset: board.low, reset_time: 20000, pulse_limit: 84, timeout: 100)
|
30
|
+
board.stub(:pulse_read, mock) do
|
31
|
+
part._read
|
32
|
+
end
|
33
|
+
mock.verify
|
34
|
+
end
|
35
|
+
|
36
|
+
# Callback pre filter should convert string of bytes to array and call #decode with it.
|
37
|
+
def test_pre_callback_filter
|
38
|
+
part
|
39
|
+
mock = MiniTest::Mock.new.expect(:call, nil, [GOOD_ARRAY])
|
40
|
+
part.stub(:decode, mock) do
|
41
|
+
part.update(GOOD_STRING)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_decode
|
46
|
+
# Error message in output if data is missing.
|
47
|
+
result = part.decode(SHORT_ARRAY)
|
48
|
+
assert result.keys.include? :error
|
49
|
+
assert result[:error].match(/missing/i)
|
50
|
+
|
51
|
+
# Error message in output if bad CRC.
|
52
|
+
result = part.decode(bad_crc)
|
53
|
+
assert result.keys.include? :error
|
54
|
+
assert result[:error].match(/crc/i)
|
55
|
+
|
56
|
+
# It should calculate output correctly.
|
57
|
+
result = part.decode(GOOD_ARRAY)
|
58
|
+
assert_equal result, {celsius: 29.5, fahrenheit: 85.1, humidity: 66.9}
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_crc
|
62
|
+
refute part.crc(bad_crc)
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
class DS18B20Test < MiniTest::Test
|
4
|
+
def board
|
5
|
+
@board ||= BoardMock.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def bus
|
9
|
+
return @bus if @bus
|
10
|
+
# Respond with disabled parasite power.
|
11
|
+
board.inject_read_for_pin(1, "1")
|
12
|
+
@bus ||= Denko::OneWire::Bus.new(board: board, pin: 1)
|
13
|
+
end
|
14
|
+
|
15
|
+
def part
|
16
|
+
@part ||= Denko::Sensor::DS18B20.new(bus: bus, address: 0xFFFFFFFFFFFFFFFF)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_decode_temperatures
|
20
|
+
assert_equal({ celsius: 125, fahrenheit: 257 },
|
21
|
+
part.decode_temperature([0b1101_0000,0b0000_0111]))
|
22
|
+
assert_equal({ celsius: 0, fahrenheit: 32 },
|
23
|
+
part.decode_temperature([0b0000_0000,0b0000_0000]))
|
24
|
+
assert_equal({ celsius: -10.125, fahrenheit: 13.775 },
|
25
|
+
part.decode_temperature([0b0101_1110,0b1111_1111]))
|
26
|
+
assert_equal({ celsius: -55, fahrenheit: -67 },
|
27
|
+
part.decode_temperature([0b1001_0000,0b1111_1100]))
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_decode_resolution
|
31
|
+
assert_equal 12, part.decode_resolution([0,0,0,0,0b01100000])
|
32
|
+
assert_equal 11, part.decode_resolution([0,0,0,0,0b01000000])
|
33
|
+
assert_equal 10, part.decode_resolution([0,0,0,0,0b00100000])
|
34
|
+
assert_equal 9, part.decode_resolution([0,0,0,0,0b00000000])
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_set_convert_time
|
38
|
+
part.instance_variable_set(:@resolution, 9)
|
39
|
+
part.set_convert_time
|
40
|
+
assert_equal 0.09375, part.instance_variable_get(:@convert_time)
|
41
|
+
part.instance_variable_set(:@resolution, 12)
|
42
|
+
part.set_convert_time
|
43
|
+
assert_equal 0.75, part.instance_variable_get(:@convert_time)
|
44
|
+
end
|
45
|
+
|
46
|
+
# test resolution=
|
47
|
+
|
48
|
+
def test_convert_is_atomic
|
49
|
+
mock = MiniTest::Mock.new.expect(:call, nil)
|
50
|
+
part.stub(:atomically, mock) do
|
51
|
+
part.convert
|
52
|
+
end
|
53
|
+
mock.verify
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_convert_matches_first
|
57
|
+
match_mock = MiniTest::Mock.new.expect(:call, nil)
|
58
|
+
sleep_mock = MiniTest::Mock.new.expect(:call, nil, [0.75])
|
59
|
+
|
60
|
+
part.stub(:match, match_mock) do
|
61
|
+
part.stub(:sleep, sleep_mock) do
|
62
|
+
part.convert
|
63
|
+
end
|
64
|
+
end
|
65
|
+
match_mock.verify
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_convert_sends_the_command
|
69
|
+
write_mock = MiniTest::Mock.new
|
70
|
+
write_mock.expect(:call, nil, [0xCC])
|
71
|
+
write_mock.expect(:call, nil, [0x44])
|
72
|
+
sleep_mock = MiniTest::Mock.new.expect(:call, nil, [0.75])
|
73
|
+
|
74
|
+
bus.stub(:write, write_mock) do
|
75
|
+
part.stub(:sleep, sleep_mock) do
|
76
|
+
part.convert
|
77
|
+
end
|
78
|
+
end
|
79
|
+
write_mock.verify
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_convert_sets_max_convert_time_first
|
83
|
+
sleep_mock = MiniTest::Mock.new.expect(:call, nil, [0.75])
|
84
|
+
part.stub(:sleep, sleep_mock) do
|
85
|
+
part.convert
|
86
|
+
end
|
87
|
+
|
88
|
+
assert_equal 0.75, part.instance_variable_get(:@convert_time)
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_convert_sleeps_for_convert_time
|
92
|
+
mock = MiniTest::Mock.new.expect(:call, nil, [0.75])
|
93
|
+
part.stub(:sleep, mock) do
|
94
|
+
part.convert
|
95
|
+
end
|
96
|
+
mock.verify
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_convert_sleeps_inside_lock_if_parasite_power
|
100
|
+
bus.instance_variable_set(:@parasite_power, true)
|
101
|
+
Thread.new do
|
102
|
+
part.convert
|
103
|
+
end
|
104
|
+
sleep 0.05
|
105
|
+
assert_equal true, bus.mutex.locked?
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
class BaseRegisterTest < Minitest::Test
|
4
|
+
def board
|
5
|
+
@board ||= BoardMock.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def bus
|
9
|
+
@bus ||= Denko::SPI::Bus.new(board: board)
|
10
|
+
end
|
11
|
+
|
12
|
+
def options
|
13
|
+
{ bus: bus, pin: 9, bytes: 2, spi_frequency: 800000, spi_mode: 2, spi_bit_order: :lsbfirst }
|
14
|
+
end
|
15
|
+
|
16
|
+
def part
|
17
|
+
@part ||= Denko::SPI::BaseRegister.new(options)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_defaults
|
21
|
+
new_part = Denko::SPI::BaseRegister.new bus: bus, pin: 9
|
22
|
+
assert_equal 1, new_part.bytes
|
23
|
+
assert_equal Array.new(8) {|i| 0}, new_part.state
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_options
|
27
|
+
assert_equal 800000, part.spi_frequency
|
28
|
+
assert_equal 2, part.spi_mode
|
29
|
+
assert_equal :lsbfirst, part.spi_bit_order
|
30
|
+
assert_equal 2, part.bytes
|
31
|
+
new_part = Denko::SPI::BaseRegister.new(options.merge(bytes: 3, pin: 10))
|
32
|
+
assert_equal new_part.state, Array.new(24) {|i| 0}
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
class TempSpiPeripheral
|
4
|
+
def initialize(pin)
|
5
|
+
@pin = pin
|
6
|
+
end
|
7
|
+
|
8
|
+
attr_reader :pin
|
9
|
+
end
|
10
|
+
|
11
|
+
class SPIBusTest < Minitest::Test
|
12
|
+
def board
|
13
|
+
@board ||= BoardMock.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def part
|
17
|
+
@bus ||= Denko::SPI::Bus.new(board: board)
|
18
|
+
end
|
19
|
+
|
20
|
+
PIN = 9
|
21
|
+
OPTIONS = { read: 2, frequency: 800000, mode: 2, bit_order: :lsbfirst }
|
22
|
+
|
23
|
+
def test_transfer
|
24
|
+
mock = MiniTest::Mock.new.expect :call, nil, [PIN], **OPTIONS
|
25
|
+
board.stub(:spi_transfer, mock) do
|
26
|
+
part.transfer(PIN, **OPTIONS)
|
27
|
+
end
|
28
|
+
mock.verify
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_listen
|
32
|
+
mock = MiniTest::Mock.new.expect :call, nil, [PIN], **OPTIONS
|
33
|
+
board.stub(:spi_listen, mock) do
|
34
|
+
part.listen(PIN, **OPTIONS)
|
35
|
+
end
|
36
|
+
mock.verify
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_stop
|
40
|
+
mock = MiniTest::Mock.new.expect :call, nil, [PIN]
|
41
|
+
board.stub(:spi_stop, mock) do
|
42
|
+
part.stop(PIN)
|
43
|
+
end
|
44
|
+
mock.verify
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_add_and_remove_component
|
48
|
+
obj = TempSpiPeripheral.new(1)
|
49
|
+
part.add_component(obj)
|
50
|
+
assert board.components.include?(obj)
|
51
|
+
|
52
|
+
part.remove_component(obj)
|
53
|
+
refute board.components.include?(obj)
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_set_pin_mode
|
57
|
+
mock = MiniTest::Mock.new.expect :call, nil, [9, :output]
|
58
|
+
board.stub(:set_pin_mode, mock) do
|
59
|
+
part.set_pin_mode(9, :output)
|
60
|
+
end
|
61
|
+
mock.verify
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_unique_select_pins
|
65
|
+
part.add_component TempSpiPeripheral.new(1)
|
66
|
+
|
67
|
+
assert_raises do
|
68
|
+
part.add_component TempSpiPeripheral.new(1)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_no_select_pin
|
73
|
+
part.add_component TempSpiPeripheral.new(255)
|
74
|
+
assert_empty part.components
|
75
|
+
end
|
76
|
+
end
|