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
@@ -6,94 +6,114 @@ class RotaryEncoderTest < Minitest::Test
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def part
|
9
|
-
@part ||= Denko::DigitalIO::RotaryEncoder.new board: board, pins: {
|
9
|
+
@part ||= Denko::DigitalIO::RotaryEncoder.new board: board, pins: {b: 3, a: 4}
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
|
14
|
-
assert_equal
|
12
|
+
def test_alternate_pin_names
|
13
|
+
short = Denko::DigitalIO::RotaryEncoder.new board: board, pins: {dt: 3, clk: 4}
|
14
|
+
assert_equal 3, short.b.pin
|
15
|
+
assert_equal 4, short.a.pin
|
16
|
+
|
17
|
+
long = Denko::DigitalIO::RotaryEncoder.new board: board, pins: {data: 5, clock: 6}
|
18
|
+
assert_equal 5, long.b.pin
|
19
|
+
assert_equal 6, long.a.pin
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_counts_per_revolution
|
23
|
+
assert_equal 60, part.counts_per_revolution
|
24
|
+
assert_equal 6.to_f, part.degrees_per_count
|
15
25
|
end
|
16
|
-
|
26
|
+
|
17
27
|
def test_resets_on_initialize
|
18
|
-
assert_equal
|
28
|
+
assert_equal({count: 0, angle: 0}, part.state)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_sets_debounce_time_for_both_pins
|
32
|
+
a_mock = Minitest::Mock.new.expect(:call, nil, [1])
|
33
|
+
b_mock = Minitest::Mock.new.expect(:call, nil, [1])
|
34
|
+
|
35
|
+
part.a.stub(:debounce_time=, a_mock) do
|
36
|
+
part.b.stub(:debounce_time=, b_mock) do
|
37
|
+
part.send(:run_after_initialize_cbs)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
a_mock.verify
|
41
|
+
b_mock.verify
|
19
42
|
end
|
20
|
-
|
43
|
+
|
21
44
|
def test_calls_listen_on_both_pins_with_given_divider
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
part.data.stub(:listen, data_mock) do
|
29
|
-
part.send(:after_initialize)
|
30
|
-
part.send(:after_initialize, divider: 2)
|
45
|
+
a_mock = Minitest::Mock.new.expect(:call, nil, [1])
|
46
|
+
b_mock = Minitest::Mock.new.expect(:call, nil, [1])
|
47
|
+
|
48
|
+
part.a.stub(:listen, a_mock) do
|
49
|
+
part.b.stub(:listen, b_mock) do
|
50
|
+
part.send(:run_after_initialize_cbs)
|
31
51
|
end
|
32
52
|
end
|
53
|
+
a_mock.verify
|
54
|
+
b_mock.verify
|
33
55
|
end
|
34
|
-
|
56
|
+
|
35
57
|
def test_observes_on_initialize
|
36
58
|
mock = Minitest::Mock.new.expect(:call, nil)
|
37
59
|
part.stub(:observe_pins, mock) do
|
38
|
-
part.send(:
|
60
|
+
part.send(:run_after_initialize_cbs)
|
39
61
|
end
|
62
|
+
mock.verify
|
40
63
|
end
|
41
|
-
|
42
|
-
def
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
part2 = Denko::DigitalIO::RotaryEncoder.new board: board, pins: {data:6, clock: 5}
|
47
|
-
|
48
|
-
refute_empty part2.data.callbacks
|
49
|
-
assert_empty part2.clock.callbacks
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_goes_the_right_direction
|
53
|
-
part.data.send(:update, 1)
|
54
|
-
part.clock.send(:update, 1)
|
55
|
-
assert_equal({ steps: -1, angle: 348.0 }, part.state)
|
56
|
-
|
57
|
-
part.reset
|
58
|
-
|
59
|
-
part.data.send(:update, 1)
|
60
|
-
part.clock.send(:update, 0)
|
61
|
-
assert_equal({ steps: 1, angle: 12.0 }, part.state)
|
64
|
+
|
65
|
+
def test_observes_the_pins
|
66
|
+
part2 = Denko::DigitalIO::RotaryEncoder.new board: board, pins: {b: 6, a: 5}
|
67
|
+
refute_empty part2.b.callbacks
|
68
|
+
refute_empty part2.a.callbacks
|
62
69
|
end
|
63
70
|
|
64
71
|
def test_reverse
|
65
72
|
part.reverse
|
66
73
|
assert part.reversed
|
67
74
|
|
68
|
-
part.
|
69
|
-
part.
|
70
|
-
assert_equal({
|
75
|
+
part.a.send(:update, 1)
|
76
|
+
part.b.send(:update, 1)
|
77
|
+
assert_equal({ count: 2, angle: 12.0 }, part.state)
|
71
78
|
end
|
72
79
|
|
73
|
-
def
|
74
|
-
|
75
|
-
|
76
|
-
part2.clock.send(:update, 1)
|
77
|
-
part2.data.send(:update, 1)
|
78
|
-
assert_equal({ steps: 1, angle: 12.0 }, part2.state)
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_callback_prefilter
|
82
|
-
part.data.send(:update, 1)
|
83
|
-
part.clock.send(:update, 0)
|
80
|
+
def test_quadrature_decoding
|
81
|
+
part.b.send(:update, 0)
|
82
|
+
part.a.send(:update, 0)
|
84
83
|
callback_value = nil
|
85
84
|
part.add_callback do |value|
|
86
85
|
callback_value = value.dup
|
87
86
|
end
|
88
|
-
|
89
|
-
part.
|
90
|
-
|
91
|
-
assert_equal({change: 1,
|
87
|
+
|
88
|
+
part.reset
|
89
|
+
part.a.send(:update, 1)
|
90
|
+
assert_equal({change: -1, count: -1, angle: 354.0}, callback_value)
|
91
|
+
|
92
|
+
part.b.send(:update, 1)
|
93
|
+
assert_equal({change: -1, count: -2, angle: 348.0}, callback_value)
|
94
|
+
|
95
|
+
part.a.send(:update, 0)
|
96
|
+
assert_equal({change: -1, count: -3, angle: 342.0}, callback_value)
|
97
|
+
|
98
|
+
part.b.send(:update, 0)
|
99
|
+
assert_equal({change: -1, count: -4, angle: 336.0}, callback_value)
|
100
|
+
|
101
|
+
part.b.send(:update, 1)
|
102
|
+
assert_equal({change: 1, count: -3, angle: 342.0}, callback_value)
|
103
|
+
|
104
|
+
part.a.send(:update, 1)
|
105
|
+
assert_equal({change: 1, count: -2, angle: 348.0}, callback_value)
|
106
|
+
|
107
|
+
part.b.send(:update, 0)
|
108
|
+
assert_equal({change: 1, count: -1, angle: 354.0}, callback_value)
|
109
|
+
|
110
|
+
part.a.send(:update, 0)
|
111
|
+
assert_equal({change: 1, count: 0, angle: 0.0}, callback_value)
|
92
112
|
end
|
93
|
-
|
113
|
+
|
94
114
|
def test_update_state_removes_change
|
95
|
-
part.
|
96
|
-
part.
|
115
|
+
part.b.send(:update, 1)
|
116
|
+
part.a.send(:update, 1)
|
97
117
|
assert_nil part.state[:change]
|
98
118
|
end
|
99
119
|
end
|
@@ -2,14 +2,14 @@ require_relative '../test_helper'
|
|
2
2
|
|
3
3
|
class BoardMock < Denko::Board
|
4
4
|
attr_reader :eeprom_stub
|
5
|
-
|
5
|
+
|
6
6
|
def eeprom_read(start_address, length)
|
7
7
|
# Initialize a fake EEPROM
|
8
8
|
@eeprom_stub ||= Array.new(eeprom_length){255}
|
9
|
-
|
9
|
+
|
10
10
|
# Pack it up like a string coming from the board.
|
11
11
|
string = @eeprom_stub[start_address, length].map{ |x| x.to_s }.join(",")
|
12
|
-
|
12
|
+
|
13
13
|
# Update ourselves with it.
|
14
14
|
self.update("254:#{start_address}-#{string}\n")
|
15
15
|
end
|
@@ -27,7 +27,7 @@ class BuiltInEEPROMTest < Minitest::Test
|
|
27
27
|
def part
|
28
28
|
@part ||= board.eeprom
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
def test_pin_ee
|
32
32
|
assert_equal part.pin, 254
|
33
33
|
end
|
@@ -35,14 +35,14 @@ class BuiltInEEPROMTest < Minitest::Test
|
|
35
35
|
def test_loads_on_initialize_and_updates_correctly
|
36
36
|
assert_equal part.state, Array.new(board.eeprom_length){255}
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
def test_delegates_to_state_array
|
40
40
|
mock = Minitest::Mock.new
|
41
41
|
mock.expect(:[], 255, [0])
|
42
42
|
mock.expect(:[]=, 128, [1, 128])
|
43
43
|
mock.expect(:each, nil)
|
44
44
|
mock.expect(:each_with_index, nil)
|
45
|
-
|
45
|
+
|
46
46
|
part.stub(:state, mock) do
|
47
47
|
part[0]
|
48
48
|
part[1] = 128
|
@@ -50,12 +50,12 @@ class BuiltInEEPROMTest < Minitest::Test
|
|
50
50
|
part.each_with_index { |el| el }
|
51
51
|
end
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
def test_saves_to_the_board
|
55
55
|
part[0] = 128
|
56
56
|
part[part.length] = 127
|
57
57
|
part.save
|
58
|
-
assert_equal board.eeprom_stub[0]
|
59
|
-
assert_equal board.eeprom_stub[board.eeprom_length]
|
58
|
+
assert_equal 128, board.eeprom_stub[0]
|
59
|
+
assert_equal 127, board.eeprom_stub[board.eeprom_length]
|
60
60
|
end
|
61
61
|
end
|
data/test/i2c/bus_test.rb
CHANGED
@@ -10,24 +10,30 @@ class I2CBusTest < Minitest::Test
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def part
|
13
|
-
|
14
|
-
@part = Denko::I2C::Bus.new(board: board, pin:5)
|
15
|
-
@part
|
13
|
+
@part ||= Denko::I2C::Bus.new(board: board)
|
16
14
|
end
|
17
|
-
|
15
|
+
|
18
16
|
def peripheral
|
19
17
|
@peripheral ||= I2CPeripheralBase.new(bus: part, address: 0x30)
|
20
18
|
end
|
21
19
|
|
22
20
|
def test_initialize
|
23
21
|
assert_equal part.found_devices, []
|
22
|
+
assert_equal 0, part.i2c_index
|
24
23
|
refute_nil part.callbacks[:bus_controller]
|
24
|
+
|
25
|
+
part2 = Denko::I2C::Bus.new(board: board, index: 10)
|
26
|
+
assert_equal 10, part2.i2c_index
|
27
|
+
|
28
|
+
part3 = Denko::I2C::Bus.new(board: board, i2c_index: 11)
|
29
|
+
assert_equal 11, part3.i2c_index
|
25
30
|
end
|
26
31
|
|
27
32
|
def test_search
|
28
|
-
|
33
|
+
# Reject 0s created by leading and trailing colons.
|
34
|
+
board.inject_read_for_i2c(0, ":48:50:")
|
29
35
|
|
30
|
-
mock = Minitest::Mock.new.expect :call, nil
|
36
|
+
mock = Minitest::Mock.new.expect :call, nil, [0]
|
31
37
|
board.stub(:i2c_search, mock) do
|
32
38
|
part.search
|
33
39
|
end
|
@@ -37,26 +43,36 @@ class I2CBusTest < Minitest::Test
|
|
37
43
|
end
|
38
44
|
|
39
45
|
def test_write
|
40
|
-
mock = Minitest::Mock.new.expect :call, nil, [0x30, [0x01, 0x02], 100000, false]
|
46
|
+
mock = Minitest::Mock.new.expect :call, nil, [0, 0x30, [0x01, 0x02], 100000, false]
|
41
47
|
board.stub(:i2c_write, mock) do
|
42
48
|
part.write 0x30, [0x01, 0x02]
|
43
49
|
end
|
44
50
|
mock.verify
|
45
51
|
end
|
46
|
-
|
47
|
-
def
|
48
|
-
board.
|
49
|
-
|
50
|
-
mock = Minitest::Mock.new.expect :call, nil, [0x32, 0x03, 6, 100000, false]
|
52
|
+
|
53
|
+
def test__read_string
|
54
|
+
board.inject_read_for_i2c(0, "48-255,0,255,0,255,0")
|
55
|
+
|
56
|
+
mock = Minitest::Mock.new.expect :call, nil, [0, 0x32, 0x03, 6, 100000, false]
|
57
|
+
board.stub(:i2c_read, mock) do
|
58
|
+
part.read 0x32, 0x03, 6
|
59
|
+
end
|
60
|
+
mock.verify
|
61
|
+
end
|
62
|
+
|
63
|
+
def test__read_array
|
64
|
+
board.inject_read_for_i2c(0, [48,255,0,255,0,255,0])
|
65
|
+
|
66
|
+
mock = Minitest::Mock.new.expect :call, nil, [0, 0x32, 0x03, 6, 100000, false]
|
51
67
|
board.stub(:i2c_read, mock) do
|
52
68
|
part.read 0x32, 0x03, 6
|
53
69
|
end
|
54
70
|
mock.verify
|
55
71
|
end
|
56
|
-
|
72
|
+
|
57
73
|
def test_updates_peripherals
|
58
74
|
mock = Minitest::Mock.new.expect :call, nil, [[255, 127]]
|
59
|
-
|
75
|
+
|
60
76
|
peripheral.stub(:update, mock) do
|
61
77
|
part.send(:update, "48-255,127")
|
62
78
|
part.send(:update, "50-128,0")
|
data/test/i2c/peripheral_test.rb
CHANGED
@@ -2,6 +2,9 @@ require_relative '../test_helper'
|
|
2
2
|
|
3
3
|
class I2CPeripheralBase
|
4
4
|
include Denko::I2C::Peripheral
|
5
|
+
I2C_ADDRESS = 0x30
|
6
|
+
I2C_FREQUENCY = 400_000
|
7
|
+
I2C_REPEATED_START = true
|
5
8
|
end
|
6
9
|
|
7
10
|
class I2CPeripheralTest < Minitest::Test
|
@@ -10,41 +13,57 @@ class I2CPeripheralTest < Minitest::Test
|
|
10
13
|
end
|
11
14
|
|
12
15
|
def bus
|
13
|
-
|
14
|
-
@bus = Denko::I2C::Bus.new(board: board, pin:5)
|
15
|
-
@bus
|
16
|
+
@bus ||= Denko::I2C::Bus.new(board: board, pin:5)
|
16
17
|
end
|
17
|
-
|
18
|
+
|
18
19
|
def part
|
19
|
-
@part ||= I2CPeripheralBase.new(bus: bus
|
20
|
+
@part ||= I2CPeripheralBase.new(bus: bus)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_address
|
24
|
+
assert_equal 0x30, part.address
|
25
|
+
part2 = I2CPeripheralBase.new(bus: bus, address: 0x31)
|
26
|
+
assert_equal 0x31, part2.address
|
20
27
|
end
|
21
|
-
|
28
|
+
|
22
29
|
def test_write_and_repeated_start
|
23
|
-
part.i2c_repeated_start
|
24
|
-
|
25
|
-
|
30
|
+
assert_equal true, part.i2c_repeated_start
|
31
|
+
mock = Minitest::Mock.new.expect :call, nil, [0x30, [1,2], 400_000, true]
|
32
|
+
bus.stub(:write, mock) do
|
33
|
+
part.i2c_write [1,2]
|
34
|
+
end
|
35
|
+
|
36
|
+
part.i2c_repeated_start = false
|
37
|
+
assert_equal false, part.i2c_repeated_start
|
38
|
+
mock = Minitest::Mock.new.expect :call, nil, [0x30, [1,2], 400_000, false]
|
26
39
|
bus.stub(:write, mock) do
|
27
40
|
part.i2c_write [1,2]
|
28
41
|
end
|
29
42
|
end
|
30
43
|
|
31
44
|
def test_frequency
|
32
|
-
part.i2c_frequency
|
33
|
-
|
34
|
-
|
45
|
+
assert_equal 400_000, part.i2c_frequency
|
46
|
+
mock = Minitest::Mock.new.expect :call, nil, [0x30, [1,2], 400_000, true]
|
47
|
+
bus.stub(:write, mock) do
|
48
|
+
part.i2c_write [1,2]
|
49
|
+
end
|
50
|
+
|
51
|
+
part.i2c_frequency = 100_000
|
52
|
+
assert_equal 100_000, part.i2c_frequency
|
53
|
+
mock = Minitest::Mock.new.expect :call, nil, [0x30, [1,2], 100_000, true]
|
35
54
|
bus.stub(:write, mock) do
|
36
55
|
part.i2c_write [1,2]
|
37
56
|
end
|
38
57
|
end
|
39
|
-
|
58
|
+
|
40
59
|
def test__read_and_repeated_start
|
41
60
|
part.i2c_repeated_start = true
|
42
|
-
|
61
|
+
|
43
62
|
board.inject_read_for_component(part, 5, "48-127,127,127,127,127,127")
|
44
|
-
|
45
|
-
mock = Minitest::Mock.new.expect :call, nil, [0x30, 0x03, 6,
|
63
|
+
|
64
|
+
mock = Minitest::Mock.new.expect :call, nil, [0x30, 0x03, 6, 400_000, true]
|
46
65
|
bus.stub(:read, mock) do
|
47
|
-
part.i2c_read(
|
66
|
+
part.i2c_read(6, register: 0x03)
|
48
67
|
end
|
49
68
|
end
|
50
69
|
end
|
data/test/led/base_test.rb
CHANGED
@@ -14,11 +14,12 @@ class BaseLEDTest < Minitest::Test
|
|
14
14
|
assert_equal Denko::LED::Base, part.class
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
17
|
+
def test_blink_runs_in_thread_and_sets_ivar
|
18
18
|
mock = Minitest::Mock.new.expect :call, nil
|
19
19
|
part.stub(:threaded_loop, mock) do
|
20
20
|
part.blink(0.5)
|
21
21
|
end
|
22
22
|
mock.verify
|
23
|
+
assert_equal 0.5, part.blink_interval
|
23
24
|
end
|
24
25
|
end
|
data/test/led/rgb_test.rb
CHANGED
@@ -27,7 +27,7 @@ class RGBLEDTest < Minitest::Test
|
|
27
27
|
part.stub(:red, red_mock) do
|
28
28
|
part.stub(:green, green_mock) do
|
29
29
|
part.stub(:blue, blue_mock) do
|
30
|
-
part.write
|
30
|
+
part.write(0, 128, 0)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -36,10 +36,10 @@ class RGBLEDTest < Minitest::Test
|
|
36
36
|
blue_mock.verify
|
37
37
|
end
|
38
38
|
|
39
|
-
def
|
40
|
-
mock = Minitest::Mock.new.expect :call, nil, [
|
39
|
+
def test_raw_rgb_values
|
40
|
+
mock = Minitest::Mock.new.expect :call, nil, [128,0,0]
|
41
41
|
part.stub(:write, mock) do
|
42
|
-
part.
|
42
|
+
part.write(128,0,0)
|
43
43
|
end
|
44
44
|
mock.verify
|
45
45
|
end
|
@@ -49,8 +49,8 @@ class RGBLEDTest < Minitest::Test
|
|
49
49
|
|
50
50
|
mock = Minitest::Mock.new
|
51
51
|
colors.each_value do |color|
|
52
|
-
mock.expect :call, nil, [color]
|
53
|
-
mock.expect :call, nil, [color]
|
52
|
+
mock.expect :call, nil, [*color]
|
53
|
+
mock.expect :call, nil, [*color]
|
54
54
|
end
|
55
55
|
|
56
56
|
part.stub(:write, mock) do
|
@@ -87,13 +87,13 @@ class SevenSegmentLEDTest < Minitest::Test
|
|
87
87
|
part.segments.each do
|
88
88
|
mocks << Minitest::Mock.new.expect(:call, nil, [1])
|
89
89
|
end
|
90
|
-
part.segments[0].stub(:
|
91
|
-
part.segments[1].stub(:
|
92
|
-
part.segments[2].stub(:
|
93
|
-
part.segments[3].stub(:
|
94
|
-
part.segments[4].stub(:
|
95
|
-
part.segments[5].stub(:
|
96
|
-
part.segments[6].stub(:
|
90
|
+
part.segments[0].stub(:digital_write, mocks[0]) do
|
91
|
+
part.segments[1].stub(:digital_write, mocks[1]) do
|
92
|
+
part.segments[2].stub(:digital_write, mocks[2]) do
|
93
|
+
part.segments[3].stub(:digital_write, mocks[3]) do
|
94
|
+
part.segments[4].stub(:digital_write, mocks[4]) do
|
95
|
+
part.segments[5].stub(:digital_write, mocks[5]) do
|
96
|
+
part.segments[6].stub(:digital_write, mocks[6]) do
|
97
97
|
part.display('+')
|
98
98
|
end
|
99
99
|
end
|
data/test/motor/servo_test.rb
CHANGED
@@ -10,7 +10,7 @@ class ServoMotorTest < Minitest::Test
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_toggle_on_initialize
|
13
|
-
mock = Minitest::Mock.new.expect(:call, nil, [1, :on], min:
|
13
|
+
mock = Minitest::Mock.new.expect(:call, nil, [1, :on], min: 500, max: 2500)
|
14
14
|
board.stub(:servo_toggle, mock) do
|
15
15
|
Denko::Motor::Servo.new(board: board, pin:1)
|
16
16
|
end
|
data/test/motor/stepper_test.rb
CHANGED
@@ -32,7 +32,7 @@ class StepperMotorTest < Minitest::Test
|
|
32
32
|
step_mock.verify
|
33
33
|
end
|
34
34
|
|
35
|
-
def
|
35
|
+
def test_step_ccw
|
36
36
|
dir_mock = Minitest::Mock.new
|
37
37
|
dir_mock.expect :high?, false
|
38
38
|
dir_mock.expect :high, nil
|
@@ -42,7 +42,7 @@ class StepperMotorTest < Minitest::Test
|
|
42
42
|
|
43
43
|
part.stub(:direction, dir_mock) do
|
44
44
|
part.stub(:step, step_mock) do
|
45
|
-
part.
|
45
|
+
part.step_ccw
|
46
46
|
end
|
47
47
|
end
|
48
48
|
dir_mock.verify
|
data/test/one_wire/bus_test.rb
CHANGED
@@ -92,6 +92,7 @@ class OneWireBusTest < Minitest::Test
|
|
92
92
|
def test_pre_callback_filter
|
93
93
|
assert_equal [255, 180, 120], part.pre_callback_filter("255,180,120")
|
94
94
|
assert_equal 127, part.pre_callback_filter("127")
|
95
|
+
assert_equal [123, 111, 187], part.pre_callback_filter([123,111,187])
|
95
96
|
end
|
96
97
|
|
97
98
|
def test_reset
|
@@ -10,9 +10,12 @@ class BuzzerTest < Minitest::Test
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_low_on_initialize
|
13
|
-
|
13
|
+
mock = Minitest::Mock.new.expect :call, [part.pin]
|
14
|
+
board.stub(:no_tone, mock) do
|
15
|
+
part
|
16
|
+
end
|
14
17
|
end
|
15
|
-
|
18
|
+
|
16
19
|
def test_tone
|
17
20
|
mock = Minitest::Mock.new
|
18
21
|
mock.expect :call, nil, [part.pin, 60, nil]
|
@@ -23,7 +26,7 @@ class BuzzerTest < Minitest::Test
|
|
23
26
|
end
|
24
27
|
mock.verify
|
25
28
|
end
|
26
|
-
|
29
|
+
|
27
30
|
def test_no_tone
|
28
31
|
part
|
29
32
|
mock = Minitest::Mock.new
|
@@ -33,7 +36,7 @@ class BuzzerTest < Minitest::Test
|
|
33
36
|
end
|
34
37
|
mock.verify
|
35
38
|
end
|
36
|
-
|
39
|
+
|
37
40
|
def stop
|
38
41
|
mock = Minitest::Mock.new
|
39
42
|
mock.expect :call, nil
|
@@ -1,37 +1,37 @@
|
|
1
1
|
require_relative '../test_helper'
|
2
2
|
|
3
|
-
class
|
3
|
+
class IROutPutTest < Minitest::Test
|
4
4
|
def board
|
5
5
|
@board ||= BoardMock.new
|
6
6
|
end
|
7
7
|
|
8
8
|
def part
|
9
|
-
@part ||= Denko::PulseIO::
|
9
|
+
@part ||= Denko::PulseIO::IROutput.new(board: board, pin:1)
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def test_pulse_count_validation
|
13
13
|
assert_raises(ArgumentError) do
|
14
|
-
part.
|
14
|
+
part.write Array.new(256) { 0 }
|
15
15
|
end
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def test_numeric_validation
|
19
19
|
assert_raises(ArgumentError) do
|
20
|
-
part.
|
20
|
+
part.write ["a", "b", "c"]
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
def test_pulse_length_validation
|
25
25
|
assert_raises(ArgumentError) do
|
26
|
-
part.
|
26
|
+
part.write [65536]
|
27
27
|
end
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
def test_emits
|
31
31
|
part
|
32
32
|
mock = Minitest::Mock.new.expect(:call, nil, [1, 38, [127,0]])
|
33
33
|
board.stub(:infrared_emit, mock) do
|
34
|
-
part.
|
34
|
+
part.write([127,0])
|
35
35
|
end
|
36
36
|
mock.verify
|
37
37
|
end
|