denko 0.13.6 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/{build_avr.yml → build_atmega_avr.yml} +18 -18
- data/.github/workflows/{build_megaavr.yml → build_atmega_megaavr.yml} +18 -18
- data/.github/workflows/{build_sam3x.yml → build_atsam3x.yml} +17 -17
- data/.github/workflows/{build_samd.yml → build_atsamd21.yml} +18 -18
- data/.github/workflows/build_esp32.yml +17 -18
- data/.github/workflows/build_esp32c3.yml +57 -0
- data/.github/workflows/build_esp32c6.yml +57 -0
- data/.github/workflows/build_esp32h2.yml +56 -0
- data/.github/workflows/build_esp32s2.yml +57 -0
- data/.github/workflows/build_esp32s3.yml +57 -0
- data/.github/workflows/build_esp8266.yml +15 -15
- data/.github/workflows/build_ra4m1.yml +16 -16
- data/.github/workflows/build_rp2040.yml +17 -16
- data/.github/workflows/ruby.yml +20 -20
- data/CHANGELOG.md +195 -11
- data/DEPS_CLI.md +9 -9
- data/DEPS_IDE.md +17 -18
- data/HARDWARE.md +50 -51
- data/README.md +61 -53
- data/Rakefile +1 -1
- data/benchmarks/analog_listen.rb +49 -0
- data/benchmarks/digital_write.rb +28 -0
- data/benchmarks/i2c_ssd1306_refresh.rb +13 -6
- data/build +1 -1
- data/denko.gemspec +5 -2
- data/examples/advanced/{m5_env.rb → m5_env3.rb} +12 -14
- data/examples/advanced/rotary_encoder_mac_volume.rb +18 -13
- data/examples/advanced/ssd1306_time_temp_rh.rb +8 -13
- data/examples/analog_io/ads1100.rb +48 -0
- data/examples/analog_io/ads1115.rb +2 -2
- data/examples/analog_io/ads1118.rb +3 -11
- data/examples/analog_io/input.rb +17 -16
- data/examples/analog_io/input_smoothing.rb +27 -0
- data/examples/analog_io/potentiometer.rb +31 -0
- data/examples/connection/binary_echo.rb +34 -0
- data/examples/connection/tcp.rb +12 -27
- data/examples/digital_io/button.rb +7 -3
- data/examples/digital_io/relay.rb +17 -0
- data/examples/digital_io/rotary_encoder.rb +21 -11
- data/examples/display/hd44780.rb +13 -5
- data/examples/display/ssd1306.rb +20 -17
- data/examples/display/ssd1306_s2_pico.rb +2 -2
- data/examples/i2c/search.rb +10 -26
- data/examples/led/apa102_bounce.rb +3 -4
- data/examples/led/apa102_fade.rb +44 -0
- data/examples/led/builtin_blink.rb +3 -1
- data/examples/led/builtin_fade.rb +19 -0
- data/examples/led/rgb_led.rb +31 -0
- data/examples/led/seven_segment_char_echo.rb +4 -2
- data/examples/led/ws2812_bounce.rb +5 -7
- data/examples/led/ws2812_builtin_blink.rb +3 -2
- data/examples/led/ws2812_fade.rb +43 -0
- data/examples/motor/l298.rb +10 -8
- data/examples/motor/servo.rb +4 -3
- data/examples/motor/stepper.rb +13 -13
- data/examples/one_wire/search.rb +32 -0
- data/examples/pulse_io/buzzer.rb +8 -3
- data/examples/pulse_io/ir_output.rb +51 -0
- data/examples/pulse_io/pwm_output.rb +30 -0
- data/examples/rtc/ds3231.rb +18 -35
- data/examples/sensor/aht10.rb +4 -6
- data/examples/sensor/aht20.rb +4 -6
- data/examples/sensor/bme280.rb +4 -4
- data/examples/sensor/bmp180.rb +9 -5
- data/examples/sensor/dht.rb +20 -15
- data/examples/sensor/ds18b20.rb +20 -21
- data/examples/sensor/generic_pir.rb +4 -2
- data/examples/sensor/hcsr04.rb +5 -2
- data/examples/sensor/htu21d.rb +9 -20
- data/examples/sensor/htu31d.rb +7 -9
- data/examples/sensor/neat_tph_readings.rb +15 -9
- data/examples/sensor/qmp6988.rb +5 -7
- data/examples/sensor/rcwl9620.rb +3 -3
- data/examples/sensor/sht3x.rb +4 -6
- data/examples/spi/bitbang_loopback.rb +46 -0
- data/examples/spi/input_register.rb +9 -19
- data/examples/spi/output_register.rb +9 -17
- data/examples/spi/ssd_through_registers.rb +28 -0
- data/examples/spi/two_registers.rb +18 -24
- data/examples/uart/bit_bang_demo.rb +25 -0
- data/examples/uart/board_passthrough.rb +19 -13
- data/examples/uart/hardware_loopback.rb +1 -1
- data/lib/denko/analog_io/ads1100.rb +127 -0
- data/lib/denko/analog_io/ads1115.rb +8 -25
- data/lib/denko/analog_io/ads1118.rb +10 -25
- data/lib/denko/analog_io/ads111x.rb +25 -11
- data/lib/denko/analog_io/input.rb +29 -55
- data/lib/denko/analog_io/input_helper.rb +42 -0
- data/lib/denko/analog_io/output.rb +5 -5
- data/lib/denko/analog_io/potentiometer.rb +6 -8
- data/lib/denko/analog_io.rb +2 -1
- data/lib/denko/behaviors/board_proxy.rb +13 -1
- data/lib/denko/behaviors/bus_controller.rb +1 -0
- data/lib/denko/behaviors/bus_controller_addressed.rb +1 -0
- data/lib/denko/behaviors/bus_peripheral.rb +3 -4
- data/lib/denko/behaviors/bus_peripheral_addressed.rb +8 -6
- data/lib/denko/behaviors/callbacks.rb +9 -7
- data/lib/denko/behaviors/component.rb +16 -14
- data/lib/denko/behaviors/input_pin.rb +14 -15
- data/lib/denko/behaviors/lifecycle.rb +51 -0
- data/lib/denko/behaviors/multi_pin.rb +22 -18
- data/lib/denko/behaviors/output_pin.rb +9 -4
- data/lib/denko/behaviors/single_pin.rb +1 -0
- data/lib/denko/behaviors/state.rb +15 -9
- data/lib/denko/behaviors/subcomponents.rb +72 -12
- data/lib/denko/behaviors.rb +2 -1
- data/lib/denko/board/core.rb +36 -18
- data/lib/denko/board/i2c.rb +14 -14
- data/lib/denko/board/i2c_bit_bang.rb +49 -0
- data/lib/denko/board/infrared.rb +6 -6
- data/lib/denko/board/led_array.rb +6 -5
- data/lib/denko/board/spi.rb +15 -10
- data/lib/denko/board/spi_bit_bang.rb +9 -7
- data/lib/denko/board.rb +35 -33
- data/lib/denko/connection/binary_echo.rb +17 -0
- data/lib/denko/connection/flow_control.rb +11 -15
- data/lib/denko/connection/handshake.rb +2 -0
- data/lib/denko/digital_io/button.rb +4 -0
- data/lib/denko/digital_io/c_bit_bang.rb +15 -0
- data/lib/denko/digital_io/input.rb +4 -5
- data/lib/denko/digital_io/output.rb +7 -6
- data/lib/denko/digital_io/relay.rb +2 -0
- data/lib/denko/digital_io/rotary_encoder.rb +78 -60
- data/lib/denko/digital_io.rb +1 -0
- data/lib/denko/display/hd44780.rb +136 -93
- data/lib/denko/display/sh1106.rb +42 -0
- data/lib/denko/display/ssd1306.rb +105 -45
- data/lib/denko/display.rb +1 -0
- data/lib/denko/eeprom/built_in.rb +19 -16
- data/lib/denko/i2c/bit_bang.rb +31 -0
- data/lib/denko/i2c/bus.rb +8 -36
- data/lib/denko/i2c/bus_common.rb +45 -0
- data/lib/denko/i2c/peripheral.rb +28 -19
- data/lib/denko/i2c.rb +2 -0
- data/lib/denko/led/apa102.rb +43 -29
- data/lib/denko/led/base.rb +8 -2
- data/lib/denko/led/rgb.rb +5 -7
- data/lib/denko/led/seven_segment.rb +24 -9
- data/lib/denko/led/ws2812.rb +10 -7
- data/lib/denko/message.rb +5 -0
- data/lib/denko/motor/l298.rb +11 -10
- data/lib/denko/motor/servo.rb +22 -10
- data/lib/denko/motor/stepper.rb +11 -14
- data/lib/denko/mutex_stub.rb +7 -0
- data/lib/denko/one_wire/bus.rb +9 -5
- data/lib/denko/one_wire/peripheral.rb +0 -3
- data/lib/denko/pulse_io/buzzer.rb +9 -3
- data/lib/denko/pulse_io/{ir_transmitter.rb → ir_output.rb} +9 -4
- data/lib/denko/pulse_io/pwm_output.rb +69 -15
- data/lib/denko/pulse_io.rb +3 -3
- data/lib/denko/rtc/ds3231.rb +11 -13
- data/lib/denko/sensor/aht.rb +22 -21
- data/lib/denko/sensor/bme280.rb +60 -63
- data/lib/denko/sensor/bmp180.rb +41 -38
- data/lib/denko/sensor/dht.rb +22 -5
- data/lib/denko/sensor/ds18b20.rb +40 -34
- data/lib/denko/sensor/hcsr04.rb +7 -5
- data/lib/denko/sensor/helper.rb +37 -0
- data/lib/denko/sensor/htu21d.rb +44 -55
- data/lib/denko/sensor/htu31d.rb +32 -33
- data/lib/denko/sensor/qmp6988.rb +25 -23
- data/lib/denko/sensor/rcwl9620.rb +2 -5
- data/lib/denko/sensor/sht3x.rb +23 -21
- data/lib/denko/sensor.rb +1 -2
- data/lib/denko/spi/base_register.rb +22 -22
- data/lib/denko/spi/bit_bang.rb +17 -51
- data/lib/denko/spi/bus.rb +15 -29
- data/lib/denko/spi/bus_common.rb +36 -0
- data/lib/denko/spi/input_register.rb +36 -30
- data/lib/denko/spi/output_register.rb +25 -40
- data/lib/denko/spi/peripheral.rb +93 -24
- data/lib/denko/spi.rb +6 -1
- data/lib/denko/uart/bit_bang.rb +5 -3
- data/lib/denko/uart/hardware.rb +9 -8
- data/lib/denko/version.rb +1 -1
- data/lib/denko.rb +10 -0
- data/lib/denko_cli/generator.rb +2 -2
- data/lib/denko_cli/packages.rb +8 -10
- data/lib/denko_cli/targets.rb +8 -8
- data/lib/denko_cli/targets.txt +4 -4
- data/lib/denko_cli/usage.txt +1 -1
- data/src/denko_ethernet.ino +0 -14
- data/src/denko_serial.ino +0 -14
- data/src/denko_wifi.ino +6 -15
- data/src/lib/Denko.cpp +39 -3
- data/src/lib/Denko.h +42 -26
- data/src/lib/DenkoCoreIO.cpp +57 -102
- data/src/lib/DenkoDefines.h +36 -31
- data/src/lib/DenkoI2C.cpp +54 -45
- data/src/lib/DenkoI2CBB.cpp +238 -0
- data/src/lib/DenkoIROut.cpp +12 -7
- data/src/lib/DenkoLEDArray.cpp +36 -13
- data/src/lib/DenkoSPI.cpp +6 -5
- data/src/lib/DenkoSPIBB.cpp +7 -6
- data/target.yml +37 -2
- data/test/analog_io/potentiometer_test.rb +10 -10
- data/test/behaviors/board_proxy_test.rb +1 -1
- data/test/behaviors/callbacks_test.rb +11 -3
- data/test/behaviors/component_test.rb +17 -9
- data/test/behaviors/input_pin_test.rb +14 -9
- data/test/behaviors/multi_pin_test.rb +14 -4
- data/test/behaviors/output_pin_test.rb +11 -8
- data/test/behaviors/poller_test.rb +1 -0
- data/test/behaviors/reader_test.rb +3 -2
- data/test/behaviors/subcomponents_test.rb +22 -2
- data/test/board/core_test.rb +15 -11
- data/test/board/i2c_test.rb +39 -33
- data/test/board/infrared_test.rb +1 -1
- data/test/board/message_test.rb +17 -11
- data/test/board/spi_test.rb +21 -21
- data/test/digital_io/button_test.rb +15 -0
- data/test/digital_io/relay_test.rb +18 -0
- data/test/digital_io/rotary_encoder_test.rb +80 -60
- data/test/eeprom/built_in_test.rb +9 -9
- data/test/i2c/bus_test.rb +30 -14
- data/test/i2c/peripheral_test.rb +36 -17
- data/test/led/base_test.rb +2 -1
- data/test/led/rgb_test.rb +6 -6
- data/test/led/seven_segment_test.rb +7 -7
- data/test/motor/servo_test.rb +1 -1
- data/test/motor/stepper_test.rb +2 -2
- data/test/one_wire/bus_test.rb +1 -0
- data/test/pulse_io/buzzer_test.rb +7 -4
- data/test/pulse_io/{ir_transmitter_test.rb → ir_output_test.rb} +10 -10
- data/test/pulse_io/pwm_output_test.rb +74 -18
- data/test/rtc/ds3231_test.rb +11 -13
- data/test/sensor/dht_test.rb +1 -1
- data/test/sensor/ds18b20_test.rb +4 -8
- data/test/spi/bus_test.rb +7 -7
- data/test/spi/input_register_test.rb +15 -15
- data/test/spi/output_register_test.rb +10 -28
- data/test/spi/peripheral_multi_pin_test.rb +53 -0
- data/test/spi/peripheral_single_pin_test.rb +48 -0
- data/test/test_helper.rb +36 -33
- data/tutorial/02-button/button.rb +5 -4
- data/tutorial/03-potentiometer/potentiometer.rb +9 -5
- data/tutorial/04-pwm_led/pwm_led.rb +14 -16
- data/tutorial/05-rgb_led/rgb_led.rb +6 -6
- data/tutorial/05-rgb_led/rgb_mapping.rb +11 -11
- data/vendor/board-maps/BoardMap.h +416 -56
- data/vendor/board-maps/lib/header_parser.rb +12 -2
- data/vendor/board-maps/yaml/ADAFRUIT_CAMERA_ESP32S3.yml +2 -2
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32C6.yml +15 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32_V2.yml +1 -1
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_RP2040_ADALOGGER.yml +44 -0
- data/vendor/board-maps/yaml/ADAFRUIT_QTPY_ESP32C3.yml +1 -0
- data/vendor/board-maps/yaml/ADAFRUIT_QTPY_ESP32S2.yml +1 -0
- data/vendor/board-maps/yaml/ADAFRUIT_QTPY_ESP32S3_N4R2.yml +1 -0
- data/vendor/board-maps/yaml/ADAFRUIT_QTPY_ESP32S3_NOPSRAM.yml +1 -0
- data/vendor/board-maps/yaml/ADAFRUIT_QTPY_ESP32_PICO.yml +1 -0
- data/vendor/board-maps/yaml/AMKEN_BB.yml +48 -0
- data/vendor/board-maps/yaml/AMKEN_ES.yml +48 -0
- data/vendor/board-maps/yaml/AMKEN_REVELOP.yml +48 -0
- data/vendor/board-maps/yaml/AMKEN_REVELOP_PLUS.yml +48 -0
- data/vendor/board-maps/yaml/ASL_CAN_X2.yml +41 -0
- data/vendor/board-maps/yaml/BLING.yml +25 -0
- data/vendor/board-maps/yaml/BPI_LEAF_S3.yml +1 -0
- data/vendor/board-maps/yaml/BRIDGETEK_IDM2040_7A.yml +48 -0
- data/vendor/board-maps/yaml/Bee_Motion_Mini.yml +13 -1
- data/vendor/board-maps/yaml/Breadstick_Raspberry.yml +31 -0
- data/vendor/board-maps/yaml/DFROBOT_BEETLE_ESP32C6.yml +8 -0
- data/vendor/board-maps/yaml/DFROBOT_FIREBEETLE_2_ESP32C6.yml +20 -0
- data/vendor/board-maps/yaml/DFROBOT_FIREBEETLE_ESP32.yml +46 -0
- data/vendor/board-maps/yaml/DPTECHNICS_WALTER.yml +39 -0
- data/vendor/board-maps/yaml/ELECROW_CROWPANEL_7.yml +8 -0
- data/vendor/board-maps/yaml/ESP32C2_DEV.yml +12 -0
- data/vendor/board-maps/yaml/ESP32C3_DEVKIT_LIPO.yml +14 -0
- data/vendor/board-maps/yaml/ESP32C6_DEV.yml +15 -0
- data/vendor/board-maps/yaml/ESP32C6_EVB.yml +15 -0
- data/vendor/board-maps/yaml/ESP32C6_QWIIC_POCKET.yml +15 -0
- data/vendor/board-maps/yaml/ESP32C6_THING_PLUS.yml +15 -0
- data/vendor/board-maps/yaml/ESP32H2_DEV.yml +13 -0
- data/vendor/board-maps/yaml/ESP32H2_DEVKIT_LIPO.yml +13 -0
- data/vendor/board-maps/yaml/ESP32S2_DEV.yml +1 -0
- data/vendor/board-maps/yaml/{RMP.yml → ESP32S2_DEVKIT_LIPO.yml} +2 -1
- data/vendor/board-maps/yaml/ESP32S2_DEVKIT_LIPO_USB.yml +44 -0
- data/vendor/board-maps/yaml/ESP32S3_DEVKIT_LIPO.yml +42 -0
- data/vendor/board-maps/yaml/ESP32S3_POWERFEATHER.yml +22 -0
- data/vendor/board-maps/yaml/ESP32_SBC_FABGL.yml +35 -0
- data/vendor/board-maps/yaml/EVN_ALPHA.yml +48 -0
- data/vendor/board-maps/yaml/FEATHERS3NEO.yml +32 -0
- data/vendor/board-maps/yaml/GEEKBLE_ESP32C3.yml +14 -0
- data/vendor/board-maps/yaml/HELTEC_CAPSULE_SENSOR_V3.yml +43 -0
- data/vendor/board-maps/yaml/HELTEC_WIFI_LORA_32_V3.yml +42 -0
- data/vendor/board-maps/yaml/HELTEC_WIRELESS_BRIDGE.yml +8 -0
- data/vendor/board-maps/yaml/HELTEC_WIRELESS_MINI_SHELL.yml +13 -0
- data/vendor/board-maps/yaml/HELTEC_WIRELESS_PAPER.yml +42 -0
- data/vendor/board-maps/yaml/HELTEC_WIRELESS_SHELL_V3.yml +42 -0
- data/vendor/board-maps/yaml/HELTEC_WIRELESS_STICK_LITE_V3.yml +30 -0
- data/vendor/board-maps/yaml/HELTEC_WIRELESS_TRACKER.yml +41 -0
- data/vendor/board-maps/yaml/HT_DE01.yml +42 -0
- data/vendor/board-maps/yaml/IMBRIOS_LOGSENS_V1P1.yml +1 -1
- data/vendor/board-maps/yaml/LILYGO_T3S3_LR1121.yml +9 -0
- data/vendor/board-maps/yaml/LILYGO_T3S3_SX1262.yml +9 -0
- data/vendor/board-maps/yaml/LILYGO_T3S3_SX1276.yml +9 -0
- data/vendor/board-maps/yaml/LILYGO_T3S3_SX1278.yml +9 -0
- data/vendor/board-maps/yaml/LILYGO_T3S3_SX1280.yml +9 -0
- data/vendor/board-maps/yaml/LILYGO_T3S3_SX1280PA.yml +8 -0
- data/vendor/board-maps/yaml/LILYGO_T_ETH_LITE.yml +21 -0
- data/vendor/board-maps/yaml/LOLIN_C3_PICO.yml +14 -0
- data/vendor/board-maps/yaml/LOLIN_S3.yml +1 -0
- data/vendor/board-maps/yaml/LOLIN_S3_MINI_PRO.yml +40 -0
- data/vendor/board-maps/yaml/Lion_Bit_Dev_Board.yml +0 -2
- data/vendor/board-maps/yaml/LoPy.yml +1 -0
- data/vendor/board-maps/yaml/LoPy4.yml +1 -0
- data/vendor/board-maps/yaml/M5STACK_CAPSULE.yml +8 -0
- data/vendor/board-maps/yaml/M5STACK_CARDPUTER.yml +8 -0
- data/vendor/board-maps/yaml/M5STACK_DIAL.yml +8 -0
- data/vendor/board-maps/yaml/M5STACK_FIRE.yml +0 -1
- data/vendor/board-maps/yaml/M5STACK_NANOC6.yml +17 -0
- data/vendor/board-maps/yaml/M5STACK_PAPER.yml +9 -0
- data/vendor/board-maps/yaml/M5STACK_POE_CAM.yml +5 -0
- data/vendor/board-maps/yaml/M5STACK_STAMP_C3.yml +13 -0
- data/vendor/board-maps/yaml/M5STACK_STAMP_S3.yml +4 -0
- data/vendor/board-maps/yaml/{M5Stick_C.yml → M5STACK_STICKC.yml} +0 -1
- data/vendor/board-maps/yaml/M5STACK_STICKC_PLUS.yml +9 -0
- data/vendor/board-maps/yaml/M5STACK_STICKC_PLUS2.yml +9 -0
- data/vendor/board-maps/yaml/M5STACK_TOUGH.yml +9 -0
- data/vendor/board-maps/yaml/M5STACK_UNIT_CAM.yml +10 -0
- data/vendor/board-maps/yaml/M5STACK_UNIT_CAMS3.yml +4 -0
- data/vendor/board-maps/yaml/M5Stack_ATOM.yml +0 -1
- data/vendor/board-maps/yaml/MAKERGO_C3_SUPERMINI.yml +14 -0
- data/vendor/board-maps/yaml/MARBLE_PICO.yml +48 -0
- data/vendor/board-maps/yaml/METEHOCA_AKANA_R1.yml +46 -0
- data/vendor/board-maps/yaml/NAMINO_BIANCO.yml +13 -0
- data/vendor/board-maps/yaml/NEBULAS3.yml +0 -1
- data/vendor/board-maps/yaml/NEWSAN_ARCHI.yml +48 -0
- data/vendor/board-maps/yaml/NOLOGO_ESP32C3_SUPER_MINI.yml +14 -0
- data/vendor/board-maps/yaml/NOLOGO_ESP32S3_PICO.yml +12 -0
- data/vendor/board-maps/yaml/OLIMEX_RP2040_PICO30_16MB.yml +48 -0
- data/vendor/board-maps/yaml/OLIMEX_RP2040_PICO30_2MB.yml +48 -0
- data/vendor/board-maps/yaml/OPTA_ANALOG.yml +7 -0
- data/vendor/board-maps/yaml/OPTA_DIGITAL.yml +5 -0
- data/vendor/board-maps/yaml/PINTRONIX_PINMAX.yml +42 -0
- data/vendor/board-maps/yaml/PYCOM_GPY.yml +1 -0
- data/vendor/board-maps/yaml/REDPILL_ESP32S3.yml +0 -1
- data/vendor/board-maps/yaml/SENSEBOX_MCU_ESP32S2.yml +12 -0
- data/vendor/board-maps/yaml/SPARKFUN_MICROMOD_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/SPARKFUN_PRO_MICRO_ESP32C3.yml +24 -0
- data/vendor/board-maps/yaml/THINGPULSE_EPULSE_FEATHER.yml +31 -0
- data/vendor/board-maps/yaml/THINGPULSE_EPULSE_FEATHER_C6.yml +15 -0
- data/vendor/board-maps/yaml/TINYC6.yml +25 -0
- data/vendor/board-maps/yaml/UPESY_EDU_ESP32.yml +28 -0
- data/vendor/board-maps/yaml/UPESY_ESP32C3_BASIC.yml +13 -0
- data/vendor/board-maps/yaml/UPESY_ESP32C3_MINI.yml +12 -0
- data/vendor/board-maps/yaml/UPESY_ESP32S3_BASIC.yml +42 -0
- data/vendor/board-maps/yaml/VIRALINK_GATE32_01.yml +6 -0
- data/vendor/board-maps/yaml/VIRALINK_GATE32_11.yml +7 -0
- data/vendor/board-maps/yaml/WAVESHARE_ESP32S3_TOUCH_LCD_128.yml +8 -0
- data/vendor/board-maps/yaml/WAVESHARE_RP2040_MATRIX.yml +48 -0
- data/vendor/board-maps/yaml/WAVESHARE_RP2040_ONE.yml +1 -0
- data/vendor/board-maps/yaml/WAVESHARE_RP2040_PIZERO.yml +47 -0
- data/vendor/board-maps/yaml/WAVESHARE_RP2040_ZERO.yml +1 -0
- data/vendor/board-maps/yaml/WEACT_STUDIO_ESP32C3.yml +14 -0
- data/vendor/board-maps/yaml/WIPY3.yml +1 -0
- data/vendor/board-maps/yaml/WT32_SC01_PLUS.yml +7 -0
- data/vendor/board-maps/yaml/WiFiduinoV2.yml +1 -0
- data/vendor/board-maps/yaml/XIAO_ESP32C3.yml +0 -1
- data/vendor/board-maps/yaml/XIAO_ESP32C6.yml +22 -0
- data/vendor/board-maps/yaml/unphone9.yml +8 -0
- metadata +169 -30
- data/examples/led/apa102_breathe.rb +0 -45
- data/examples/pulse_io/ir_transmitter.rb +0 -55
- data/examples/spi/ssd_through_register.rb +0 -40
- data/examples/uart/bit_bang_read.rb +0 -16
- data/examples/uart/bit_bang_write.rb +0 -16
- data/lib/denko/analog_io/sensor.rb +0 -6
- data/lib/denko/sensor/virtual.rb +0 -42
- data/src/lib/DenkoIROutESP.cpp +0 -26
- data/vendor/board-maps/yaml/STAMP_S3.yml +0 -8
- /data/vendor/board-maps/yaml/{BRIDGETEK_IDM2040-7A.yml → BRIDGETEK_IDM2040_43A.yml} +0 -0
- /data/vendor/board-maps/yaml/{heltec_wifi_32_lora_V3.yml → HELTEC_WIRELESS_STICK_V3.yml} +0 -0
- /data/vendor/board-maps/yaml/{M5Stack_Core_ESP32.yml → M5STACK_CORE.yml} +0 -0
- /data/vendor/board-maps/yaml/{M5Stamp_Pico.yml → M5STACK_STAMP_PICO.yml} +0 -0
- /data/vendor/board-maps/yaml/{M5Stack-Timer-CAM.yml → M5STACK_TIMER_CAM.yml} +0 -0
@@ -5,8 +5,9 @@ class MultiPinComponent
|
|
5
5
|
|
6
6
|
def initialize_pins(options={})
|
7
7
|
require_pin :one
|
8
|
-
proxy_pin :two,
|
9
|
-
proxy_pin :maybe,
|
8
|
+
proxy_pin :two, Denko::DigitalIO::Output
|
9
|
+
proxy_pin :maybe, Denko::DigitalIO::Input, optional: true
|
10
|
+
proxy_pin :other_board, Denko::DigitalIO::Output, board: options[:board2], optional: true
|
10
11
|
end
|
11
12
|
end
|
12
13
|
|
@@ -15,9 +16,14 @@ class MultiPinTest < Minitest::Test
|
|
15
16
|
@board ||= BoardMock.new
|
16
17
|
end
|
17
18
|
|
19
|
+
def board2
|
20
|
+
@board2 ||= BoardMock.new
|
21
|
+
end
|
22
|
+
|
18
23
|
def part
|
19
24
|
@part ||= MultiPinComponent.new board: board,
|
20
|
-
|
25
|
+
board2: board2,
|
26
|
+
pins: { one: 9, two: 10, maybe: 11, other_board: 13 }
|
21
27
|
end
|
22
28
|
|
23
29
|
def test_validate_pins
|
@@ -38,6 +44,10 @@ class MultiPinTest < Minitest::Test
|
|
38
44
|
assert_equal Denko::DigitalIO::Output, part.proxies[:two].class
|
39
45
|
assert_equal Denko::DigitalIO::Input, part.proxies[:maybe].class
|
40
46
|
end
|
47
|
+
|
48
|
+
def test_build_proxy_on_other_board
|
49
|
+
assert_equal board2, part.proxies[:other_board].board
|
50
|
+
end
|
41
51
|
|
42
52
|
def attr_reader_exists_for_optional_pins
|
43
53
|
part = MultiPinComponent.new board: board, pins: { one: 9, two:10 }
|
@@ -56,7 +66,7 @@ class MultiPinTest < Minitest::Test
|
|
56
66
|
|
57
67
|
def test_proxy_states
|
58
68
|
part.two.high
|
59
|
-
assert_equal({two: board.high, maybe: nil}, part.proxy_states)
|
69
|
+
assert_equal({two: board.high, maybe: nil, other_board: nil}, part.proxy_states)
|
60
70
|
|
61
71
|
part2 = MultiPinComponent.new board: board, pins: { one: 'A1', two:12 }
|
62
72
|
part2.two.low
|
@@ -9,19 +9,22 @@ class OutputPinTest < Minitest::Test
|
|
9
9
|
@board ||= BoardMock.new
|
10
10
|
end
|
11
11
|
|
12
|
-
def part
|
13
|
-
@part ||= OutputComponent.new(board: board, pin: 1)
|
14
|
-
end
|
15
|
-
|
16
12
|
def test_set_mode
|
13
|
+
modes = [:output, :output_pwm, :output_dac, :output_open_drain, :output_open_source]
|
14
|
+
|
17
15
|
mock = Minitest::Mock.new
|
18
|
-
|
19
|
-
|
16
|
+
modes.each_with_index do |mode, pin|
|
17
|
+
mock.expect :call, nil, [pin+1, mode]
|
18
|
+
end
|
19
|
+
|
20
20
|
board.stub(:set_pin_mode, mock) do
|
21
|
-
|
21
|
+
modes.each_with_index do |mode, pin|
|
22
|
+
part = OutputComponent.new(board: board, pin: pin+1, mode: mode)
|
23
|
+
assert_equal mode, part.mode
|
24
|
+
end
|
22
25
|
end
|
23
26
|
mock.verify
|
24
27
|
|
25
|
-
|
28
|
+
assert_raises { OutputComponent.new(board: board, pin: modes.count+1, mode: :wrong_mode) }
|
26
29
|
end
|
27
30
|
end
|
@@ -18,6 +18,7 @@ class ReaderTest < Minitest::Test
|
|
18
18
|
def inject(data, wait_for_callbacks = true)
|
19
19
|
Thread.new do
|
20
20
|
if wait_for_callbacks
|
21
|
+
while (!part.callbacks) do; sleep 0.01; end
|
21
22
|
while (!part.callbacks[:read]) do; sleep 0.01; end
|
22
23
|
end
|
23
24
|
loop do
|
@@ -39,7 +40,7 @@ class ReaderTest < Minitest::Test
|
|
39
40
|
def test_read_once
|
40
41
|
mock = Minitest::Mock.new.expect :call, nil
|
41
42
|
inject(1)
|
42
|
-
|
43
|
+
|
43
44
|
part.stub(:_read, mock) do
|
44
45
|
part.read
|
45
46
|
end
|
@@ -50,7 +51,7 @@ class ReaderTest < Minitest::Test
|
|
50
51
|
inject(42)
|
51
52
|
assert_equal part.read, 42
|
52
53
|
end
|
53
|
-
|
54
|
+
|
54
55
|
def test_read_using_with_lambda
|
55
56
|
inject(1)
|
56
57
|
reader = Minitest::Mock.new.expect :call, nil
|
@@ -15,7 +15,7 @@ class MultiPinComponentMock
|
|
15
15
|
def pin
|
16
16
|
{a: 1, b: 2}
|
17
17
|
end
|
18
|
-
end
|
18
|
+
end
|
19
19
|
|
20
20
|
class SubcomponentsTest < Minitest::Test
|
21
21
|
def connection
|
@@ -60,7 +60,7 @@ class SubcomponentsTest < Minitest::Test
|
|
60
60
|
board.remove_component(multi_pin)
|
61
61
|
assert_empty board.components
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
def test_calls_stop_on_remove
|
65
65
|
pinless = PinlessComponentMock.new
|
66
66
|
board.add_component(pinless)
|
@@ -72,4 +72,24 @@ class SubcomponentsTest < Minitest::Test
|
|
72
72
|
|
73
73
|
mock.verify
|
74
74
|
end
|
75
|
+
|
76
|
+
def test_disallows_duplicate_hw_i2c_buses
|
77
|
+
i2c0 = Denko::I2C::Bus.new(board: board, pin: 0)
|
78
|
+
assert_raises { Denko::I2C::Bus.new(board: board) }
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_hw_i2c_buses_add_and_remove_properly
|
82
|
+
i2c0 = Denko::I2C::Bus.new(board: board, i2c_index: 0)
|
83
|
+
i2c1 = Denko::I2C::Bus.new(board: board, i2c_index: 1)
|
84
|
+
assert_equal [i2c0, i2c1], board.components
|
85
|
+
|
86
|
+
# Have the right hash keys.
|
87
|
+
assert_equal i2c0, board.hw_i2c_comps[0]
|
88
|
+
assert_equal i2c1, board.hw_i2c_comps[1]
|
89
|
+
|
90
|
+
# Get removed correctly.
|
91
|
+
board.remove_component(i2c0)
|
92
|
+
hash = { 1 => i2c1 }
|
93
|
+
assert_equal hash, board.hw_i2c_comps
|
94
|
+
end
|
75
95
|
end
|
data/test/board/core_test.rb
CHANGED
@@ -14,27 +14,31 @@ class BoardCoreTest < Minitest::Test
|
|
14
14
|
def test_set_pin_mode
|
15
15
|
mock = Minitest::Mock.new
|
16
16
|
mock.expect(:call, nil, [Denko::Message.encode(command: 0, pin: 1, value: 0b000)])
|
17
|
-
mock.expect(:call, nil, [Denko::Message.encode(command: 0, pin: 1, value: 0b010)])
|
17
|
+
mock.expect(:call, nil, [Denko::Message.encode(command: 0, pin: 1, value: 0b010, aux_message: pack(:uint32, [0, 0]))])
|
18
|
+
mock.expect(:call, nil, [Denko::Message.encode(command: 0, pin: 1, value: 0b010, aux_message: pack(:uint32, [1000, 12]))])
|
18
19
|
mock.expect(:call, nil, [Denko::Message.encode(command: 0, pin: 1, value: 0b100)])
|
19
20
|
mock.expect(:call, nil, [Denko::Message.encode(command: 0, pin: 1, value: 0b001)])
|
20
21
|
mock.expect(:call, nil, [Denko::Message.encode(command: 0, pin: 1, value: 0b011)])
|
21
22
|
mock.expect(:call, nil, [Denko::Message.encode(command: 0, pin: 1, value: 0b101)])
|
22
|
-
mock.expect(:call, nil, [Denko::Message.encode(command: 0, pin: 1, value: 0b111)])
|
23
23
|
|
24
24
|
board.stub(:write, mock) do
|
25
25
|
board.set_pin_mode 1, :output
|
26
26
|
board.set_pin_mode 1, :output_pwm
|
27
|
+
board.set_pin_mode 1, :output_pwm, frequency: 1000, resolution: 12
|
27
28
|
board.set_pin_mode 1, :output_dac
|
28
29
|
board.set_pin_mode 1, :input
|
29
30
|
board.set_pin_mode 1, :input_pulldown
|
30
31
|
board.set_pin_mode 1, :input_pullup
|
31
|
-
board.set_pin_mode 1, :input_output
|
32
32
|
end
|
33
33
|
mock.verify
|
34
34
|
|
35
35
|
assert_raises { board.set_pin_mode 1, "wrong" }
|
36
36
|
end
|
37
37
|
|
38
|
+
def test_set_pin_debounce
|
39
|
+
board.set_pin_debounce(1, 1)
|
40
|
+
end
|
41
|
+
|
38
42
|
def test_digital_write
|
39
43
|
mock = Minitest::Mock.new
|
40
44
|
mock.expect(:call, nil, [Denko::Message.encode(command: 1, pin: 1, value: board.low)])
|
@@ -74,7 +78,7 @@ class BoardCoreTest < Minitest::Test
|
|
74
78
|
|
75
79
|
assert_raises { board.pwm_write 1, "wrong" }
|
76
80
|
end
|
77
|
-
|
81
|
+
|
78
82
|
def test_dac_write
|
79
83
|
mock = Minitest::Mock.new
|
80
84
|
mock.expect(:call, nil, [Denko::Message.encode(command: 4, pin: 1, value: board.low)])
|
@@ -153,11 +157,11 @@ class BoardCoreTest < Minitest::Test
|
|
153
157
|
def test_analog_resolution
|
154
158
|
mock = Minitest::Mock.new
|
155
159
|
mock.expect(:call, nil, [Denko::Message.encode(command: 96, value: 10)])
|
156
|
-
mock.expect(:call, nil, [Denko::Message.encode(command: 97, value:
|
160
|
+
mock.expect(:call, nil, [Denko::Message.encode(command: 97, value: 8)])
|
157
161
|
|
158
162
|
board.stub(:write, mock) do
|
159
163
|
board.analog_write_resolution = 10
|
160
|
-
board.analog_read_resolution =
|
164
|
+
board.analog_read_resolution = 8
|
161
165
|
end
|
162
166
|
mock.verify
|
163
167
|
|
@@ -167,16 +171,16 @@ class BoardCoreTest < Minitest::Test
|
|
167
171
|
assert_raises { board.analog_read_resolution= "wrong" }
|
168
172
|
end
|
169
173
|
|
170
|
-
def micro_delay
|
174
|
+
def micro_delay
|
171
175
|
aux = pack(:uint16, [1000])
|
172
176
|
message = Denko::Message.encode command: 99, aux_message: aux
|
173
177
|
mock = Minitest::Mock.new.expect :call, nil, [message]
|
174
|
-
|
178
|
+
|
175
179
|
board.stub(:write, mock) do
|
176
180
|
board.micro_delay(1000)
|
177
181
|
end
|
178
|
-
|
179
|
-
assert_raises(ArgumentError) { board.micro_delay(65536) }
|
180
|
-
assert_raises(ArgumentError) { board.micro_delay("wrong") }
|
182
|
+
|
183
|
+
assert_raises(ArgumentError) { board.micro_delay(65536) }
|
184
|
+
assert_raises(ArgumentError) { board.micro_delay("wrong") }
|
181
185
|
end
|
182
186
|
end
|
data/test/board/i2c_test.rb
CHANGED
@@ -2,7 +2,7 @@ require_relative '../test_helper'
|
|
2
2
|
|
3
3
|
class APII2CTest < Minitest::Test
|
4
4
|
include TestPacker
|
5
|
-
|
5
|
+
|
6
6
|
def connection
|
7
7
|
@connection ||= ConnectionMock.new
|
8
8
|
end
|
@@ -10,91 +10,97 @@ class APII2CTest < Minitest::Test
|
|
10
10
|
def board
|
11
11
|
@board ||= Denko::Board.new(connection)
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
def test_search
|
15
15
|
board
|
16
16
|
message = Denko::Message.encode command: 33
|
17
|
-
|
17
|
+
|
18
18
|
mock = Minitest::Mock.new.expect :call, nil, [message]
|
19
19
|
connection.stub(:write, mock) do
|
20
|
-
board.i2c_search
|
20
|
+
board.i2c_search(0)
|
21
21
|
end
|
22
22
|
mock.verify
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_write
|
26
26
|
board
|
27
|
-
aux = pack(:uint8, 0x00) + pack(:uint8, [1,2,3,4])
|
28
27
|
address = 0x30
|
29
|
-
|
28
|
+
data = [1,2,3,4]
|
29
|
+
|
30
30
|
# Normal
|
31
|
-
|
31
|
+
aux_stop = pack(:uint8, 0x00) + pack(:uint8, address | (1 << 7)) + pack(:uint8, data.length) + pack(:uint8, data)
|
32
|
+
message1 = Denko::Message.encode command: 34, aux_message: aux_stop
|
32
33
|
# Repeated start
|
33
|
-
|
34
|
+
aux_repeat = pack(:uint8, 0x00) + pack(:uint8, address | (0 << 7)) + pack(:uint8, data.length) + pack(:uint8, data)
|
35
|
+
message2 = Denko::Message.encode command: 34, aux_message: aux_repeat
|
34
36
|
|
35
37
|
mock = Minitest::Mock.new
|
36
38
|
mock.expect :call, nil, [message1]
|
37
39
|
mock.expect :call, nil, [message2]
|
38
|
-
|
40
|
+
|
39
41
|
connection.stub(:write, mock) do
|
40
|
-
board.i2c_write(0x30, [1,2,3,4])
|
41
|
-
board.i2c_write(0x30, [1,2,3,4], 100000, true)
|
42
|
+
board.i2c_write(0, 0x30, [1,2,3,4])
|
43
|
+
board.i2c_write(0, 0x30, [1,2,3,4], 100000, true)
|
42
44
|
end
|
43
45
|
mock.verify
|
44
46
|
end
|
45
47
|
|
46
48
|
def test_write_limits
|
47
|
-
assert_raises { board.i2c_write(0x30, Array.new(33) {0x00}) }
|
48
|
-
assert_raises { board.i2c_write(0x30, Array.new(0) {0x00}) }
|
49
|
+
assert_raises { board.i2c_write(0, 0x30, Array.new(33) {0x00}) }
|
50
|
+
assert_raises { board.i2c_write(0, 0x30, Array.new(0) {0x00}) }
|
49
51
|
end
|
50
52
|
|
51
53
|
def test_read
|
52
54
|
board
|
53
|
-
|
55
|
+
address = 0x30
|
56
|
+
|
54
57
|
# Normal
|
55
|
-
|
58
|
+
aux_stop = pack(:uint8, 0x00) + pack(:uint8, address | (1 << 7)) + pack(:uint8, 4) + pack(:uint8, [1, 0x03])
|
59
|
+
message1 = Denko::Message.encode command: 35, aux_message: aux_stop
|
56
60
|
# Repeated start
|
57
|
-
|
61
|
+
aux_repeat = pack(:uint8, 0x00) + pack(:uint8, address | (0 << 7)) + pack(:uint8, 4) + pack(:uint8, [1, 0x03])
|
62
|
+
message2 = Denko::Message.encode command: 35, aux_message: aux_repeat
|
58
63
|
|
59
64
|
mock = Minitest::Mock.new
|
60
65
|
mock.expect :call, nil, [message1]
|
61
66
|
mock.expect :call, nil, [message2]
|
62
|
-
|
67
|
+
|
63
68
|
connection.stub(:write, mock) do
|
64
|
-
board.i2c_read(0x30, 0x03, 4)
|
65
|
-
board.i2c_read(0x30, 0x03, 4, 100000, true)
|
69
|
+
board.i2c_read(0, 0x30, 0x03, 4)
|
70
|
+
board.i2c_read(0, 0x30, 0x03, 4, 100000, true)
|
66
71
|
end
|
67
72
|
mock.verify
|
68
73
|
end
|
69
|
-
|
74
|
+
|
70
75
|
def test_read_without_register
|
71
76
|
board
|
72
|
-
aux = pack(:uint8, 0x00) + pack(:uint8, [0])
|
73
|
-
message = Denko::Message.encode command: 35,
|
77
|
+
aux = pack(:uint8, 0x00) + pack(:uint8, 0x30 | (1 << 7)) + pack(:uint8, 4) + pack(:uint8, [0])
|
78
|
+
message = Denko::Message.encode command: 35, aux_message: aux
|
74
79
|
|
75
80
|
mock = Minitest::Mock.new
|
76
81
|
mock.expect :call, nil, [message]
|
77
|
-
|
82
|
+
|
78
83
|
connection.stub(:write, mock) do
|
79
|
-
board.i2c_read(0x30, nil, 4)
|
84
|
+
board.i2c_read(0, 0x30, nil, 4)
|
80
85
|
end
|
81
86
|
mock.verify
|
82
87
|
end
|
83
88
|
|
84
89
|
def test_read_limits
|
85
|
-
assert_raises { board.i2c_read(0x30, nil, 33) }
|
86
|
-
assert_raises { board.i2c_read(0x30, nil, 0) }
|
90
|
+
assert_raises { board.i2c_read(0, 0x30, nil, 33) }
|
91
|
+
assert_raises { board.i2c_read(0, 0x30, nil, 0) }
|
87
92
|
end
|
88
93
|
|
89
94
|
def test_frequencies
|
90
95
|
board
|
91
96
|
data = [1,2,3,4]
|
92
97
|
address = 0x30
|
93
|
-
|
98
|
+
|
94
99
|
messages = []
|
95
100
|
# 100 kHz, 400 kHz, 1 Mhz, 3.4 MHz
|
101
|
+
aux_after_config = pack(:uint8, 0x30 | (1 << 7)) + pack(:uint8, data.length) + pack(:uint8, data)
|
96
102
|
[0x00, 0x01, 0x02, 0x03].each do |code|
|
97
|
-
messages << Denko::Message.encode(command: 34,
|
103
|
+
messages << Denko::Message.encode(command: 34, aux_message: pack(:uint8, code) + aux_after_config)
|
98
104
|
end
|
99
105
|
|
100
106
|
mock = Minitest::Mock.new
|
@@ -102,13 +108,13 @@ class APII2CTest < Minitest::Test
|
|
102
108
|
mock.expect :call, nil, [message]
|
103
109
|
end
|
104
110
|
connection.stub(:write, mock) do
|
105
|
-
board.i2c_write(address, data, 100000)
|
106
|
-
board.i2c_write(address, data, 400000)
|
107
|
-
board.i2c_write(address, data, 1000000)
|
108
|
-
board.i2c_write(address, data, 3400000)
|
111
|
+
board.i2c_write(0, address, data, 100000)
|
112
|
+
board.i2c_write(0, address, data, 400000)
|
113
|
+
board.i2c_write(0, address, data, 1000000)
|
114
|
+
board.i2c_write(0, address, data, 3400000)
|
109
115
|
end
|
110
116
|
mock.verify
|
111
117
|
|
112
|
-
assert_raises(ArgumentError) { board.i2c_write(0x30, [1,2,3,4], 5000000, false) }
|
118
|
+
assert_raises(ArgumentError) { board.i2c_write(0, 0x30, [1,2,3,4], 5000000, false) }
|
113
119
|
end
|
114
120
|
end
|
data/test/board/infrared_test.rb
CHANGED
@@ -13,7 +13,7 @@ class APIInfraredTest < Minitest::Test
|
|
13
13
|
|
14
14
|
def test_infrared_emit
|
15
15
|
board
|
16
|
-
aux = pack(:
|
16
|
+
aux = pack(:uint16, 4) + pack(:uint16, [255,0,255,0])
|
17
17
|
message = Denko::Message.encode command: 16, pin: 8, value: 38, aux_message: aux
|
18
18
|
|
19
19
|
mock = Minitest::Mock.new.expect :call, nil, [message]
|
data/test/board/message_test.rb
CHANGED
@@ -30,25 +30,31 @@ class MessageTest < Minitest::Test
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_build_messages_correctly
|
33
|
-
assert_equal "
|
34
|
-
assert_equal "
|
35
|
-
assert_equal "
|
36
|
-
assert_equal "
|
37
|
-
assert_equal "
|
33
|
+
assert_equal "0.1.1\n", Denko::Message.encode(command: 0, pin: 1, value: 1)
|
34
|
+
assert_equal "0.1\n", Denko::Message.encode(command: 0, pin: 1)
|
35
|
+
assert_equal "0..1\n", Denko::Message.encode(command: 0, value: 1)
|
36
|
+
assert_equal "0\n", Denko::Message.encode(command: 0)
|
37
|
+
assert_equal "0...test\n", Denko::Message.encode(command: 0, aux_message: "test")
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_single_byte_digital_write
|
41
|
+
assert_equal 0b11000100.chr, Denko::Message.encode(command: 1, pin: 4, value: 1)
|
42
|
+
assert_equal 0b10000100.chr, Denko::Message.encode(command: 1, pin: 4, value: 0)
|
43
|
+
assert_equal "1.64.1\n", Denko::Message.encode(command: 1, pin: 64, value: 1)
|
38
44
|
end
|
39
45
|
|
40
46
|
def test_escape_newline_in_aux
|
41
|
-
assert_equal "
|
42
|
-
Denko::Message.encode(command:
|
47
|
+
assert_equal "0...line1\\\nline2\\\n\n",
|
48
|
+
Denko::Message.encode(command: 0, aux_message: "line1\nline2\n")
|
43
49
|
end
|
44
50
|
|
45
51
|
def test_escape_backslash_in_aux
|
46
|
-
assert_equal "
|
47
|
-
Denko::Message.encode(command:
|
52
|
+
assert_equal "0...line1\\\\line2\\\\\n",
|
53
|
+
Denko::Message.encode(command: 0, aux_message: "line1\\line2\\")
|
48
54
|
end
|
49
55
|
|
50
56
|
def test_escape_newline_and_backslashes_together
|
51
|
-
assert_equal "
|
52
|
-
Denko::Message.encode(command:
|
57
|
+
assert_equal "0...line1\\\\\\\nline2\\\\\\\n\n",
|
58
|
+
Denko::Message.encode(command: 0, aux_message: "line1\\\nline2\\\n")
|
53
59
|
end
|
54
60
|
end
|
data/test/board/spi_test.rb
CHANGED
@@ -5,7 +5,7 @@ require_relative '../test_helper'
|
|
5
5
|
|
6
6
|
class APISPITest < Minitest::Test
|
7
7
|
include TestPacker
|
8
|
-
|
8
|
+
|
9
9
|
def connection
|
10
10
|
@connection ||= ConnectionMock.new
|
11
11
|
end
|
@@ -13,43 +13,43 @@ class APISPITest < Minitest::Test
|
|
13
13
|
def board
|
14
14
|
@board ||= Denko::Board.new(connection)
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def test_spi_modes
|
18
18
|
# Start with mode = 0.
|
19
|
-
args = [[], 0, 1000000, 0, :msbfirst]
|
19
|
+
args = [nil, [], 0, 1000000, 0, :msbfirst]
|
20
20
|
assert_equal (pack :uint8, 0b10000000), board.spi_header(*args)[0]
|
21
21
|
|
22
|
-
args[
|
22
|
+
args[4] = 1
|
23
23
|
assert_equal (pack :uint8, 0b10000001), board.spi_header(*args)[0]
|
24
24
|
|
25
|
-
args[
|
25
|
+
args[4] = 2
|
26
26
|
assert_equal (pack :uint8, 0b10000010), board.spi_header(*args)[0]
|
27
27
|
|
28
|
-
args[
|
28
|
+
args[4] = 3
|
29
29
|
assert_equal (pack :uint8, 0b10000011), board.spi_header(*args)[0]
|
30
30
|
|
31
31
|
# Invalid mode = 4.
|
32
32
|
assert_raises(ArgumentError) { board.spi_header(*args[3] = 4) }
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
def test_spi_lsbfirst
|
36
|
-
args = [[], 0, 1000000, 0, :lsbfirst]
|
36
|
+
args = [nil, [], 0, 1000000, 0, :lsbfirst]
|
37
37
|
assert_equal (pack :uint8, 0b00000000), board.spi_header(*args)[0]
|
38
38
|
end
|
39
39
|
|
40
40
|
def test_spi_frequency
|
41
|
-
args = [[], 0, 1000000, 0, :msbfirst]
|
41
|
+
args = [nil, [], 0, 1000000, 0, :msbfirst]
|
42
42
|
assert_equal (pack :uint32, 1000000), board.spi_header(*args)[3..6]
|
43
43
|
|
44
|
-
args[
|
44
|
+
args[3] = 8000000
|
45
45
|
assert_equal (pack :uint32, 8000000), board.spi_header(*args)[3..6]
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
def test_spi_too_many_bytes
|
49
49
|
assert_raises(ArgumentError) { board.spi_header(read: 256) }
|
50
50
|
assert_raises(ArgumentError) { board.spi_header(write: Array.new(256){0})}
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
def test_spi_no_bytes
|
54
54
|
assert_raises(ArgumentError) { board.spi_transfer(3, read: 0) }
|
55
55
|
assert_raises(ArgumentError) { board.spi_listen(3, read: 0) }
|
@@ -58,34 +58,34 @@ class APISPITest < Minitest::Test
|
|
58
58
|
def test_spi_bad_frequency
|
59
59
|
assert_raises(ArgumentError) { board.spi_transfer(3, read: 0, frequency: "string") }
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
def test_spi_transfer
|
63
63
|
board
|
64
64
|
bytes = [1,2,3,4]
|
65
|
-
header = board.spi_header(bytes, 4, 8000000, 2, :lsbfirst)
|
65
|
+
header = board.spi_header(3, bytes, 4, 8000000, 2, :lsbfirst)
|
66
66
|
aux = header + pack(:uint8, bytes)
|
67
67
|
mock = Minitest::Mock.new.expect :call, nil,
|
68
68
|
[Denko::Message.encode(command: 26, pin: 3, aux_message: aux)]
|
69
|
-
|
69
|
+
|
70
70
|
board.stub(:write, mock) do
|
71
71
|
args = { write: [1,2,3,4], read: 4, bit_order: :lsbfirst, frequency: 8000000, mode: 2 }
|
72
|
-
board.spi_transfer(3, **args)
|
72
|
+
board.spi_transfer(0, 3, **args)
|
73
73
|
end
|
74
74
|
mock.verify
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
def test_spi_listen
|
78
78
|
board
|
79
|
-
header = board.spi_header([], 8, 1000000, 0, :lsbfirst)
|
79
|
+
header = board.spi_header(3, [], 8, 1000000, 0, :lsbfirst)
|
80
80
|
mock = Minitest::Mock.new.expect :call, nil,
|
81
81
|
[Denko::Message.encode(command: 27, pin: 3, aux_message: header)]
|
82
|
-
|
82
|
+
|
83
83
|
board.stub(:write, mock) do
|
84
|
-
board.spi_listen(3, read: 8, bit_order: :lsbfirst)
|
84
|
+
board.spi_listen(0, 3, read: 8, bit_order: :lsbfirst)
|
85
85
|
end
|
86
86
|
mock.verify
|
87
87
|
end
|
88
|
-
|
88
|
+
|
89
89
|
def test_spi_stop
|
90
90
|
board
|
91
91
|
mock = Minitest::Mock.new.expect :call, nil, [Denko::Message.encode(command: 28, pin: 3)]
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
class DigitalIOButtonTest < Minitest::Test
|
4
|
+
def board
|
5
|
+
@board ||= BoardMock.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def part
|
9
|
+
@part ||= Denko::DigitalIO::Button.new(board: board, pin: 14)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_divider_set_correctly
|
13
|
+
assert_equal 1, part.divider
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
class DigitalIORelaynTest < Minitest::Test
|
4
|
+
def board
|
5
|
+
@board ||= BoardMock.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def relay
|
9
|
+
@relay ||= Denko::DigitalIO::Relay.new(board: board, pin: 14)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_open_and_close
|
13
|
+
relay.close
|
14
|
+
assert_equal 1, relay.state
|
15
|
+
relay.open
|
16
|
+
assert_equal 0, relay.state
|
17
|
+
end
|
18
|
+
end
|