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
data/lib/denko/spi/bit_bang.rb
CHANGED
@@ -2,28 +2,28 @@ module Denko
|
|
2
2
|
module SPI
|
3
3
|
class BitBang
|
4
4
|
include Behaviors::MultiPin
|
5
|
-
include Behaviors::
|
6
|
-
include
|
5
|
+
include Behaviors::Lifecycle
|
6
|
+
include BusCommon
|
7
7
|
|
8
|
-
|
8
|
+
before_initialize do
|
9
|
+
param_pins = params[:pins]
|
9
10
|
# Allow pin aliases.
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
# Clean up the pins hash.
|
15
|
-
[:poci, :miso, :pico, :mosi, :sck, :clk].each { |key| pins.delete(key) }
|
11
|
+
param_pins[:input] = param_pins[:input] || param_pins[:poci] || param_pins[:miso]
|
12
|
+
param_pins[:output] = param_pins[:output] || param_pins[:pico] || param_pins[:mosi]
|
13
|
+
param_pins[:clock] = param_pins[:clock] || param_pins[:sck] || param_pins[:clk]
|
16
14
|
|
17
|
-
#
|
18
|
-
|
19
|
-
raise ArgumentError, "no input or output pin given. Require either or both"
|
20
|
-
end
|
15
|
+
# Clean up the params hash.
|
16
|
+
[:poci, :miso, :pico, :mosi, :sck, :clk].each { |key| param_pins.delete(key) }
|
21
17
|
|
22
|
-
#
|
23
|
-
|
24
|
-
|
18
|
+
# Validate param_pins.
|
19
|
+
raise ArgumentError, "either output or input pin required" unless param_pins[:input] || param_pins[:output]
|
20
|
+
raise ArgumentError, "clock pin required" unless param_pins[:clock]
|
21
|
+
end
|
25
22
|
|
26
|
-
|
23
|
+
def initialize_pins(options={})
|
24
|
+
proxy_pin :clock, DigitalIO::CBitBang
|
25
|
+
proxy_pin :output, DigitalIO::CBitBang if pins[:output]
|
26
|
+
proxy_pin :input, DigitalIO::CBitBang if pins[:input]
|
27
27
|
end
|
28
28
|
|
29
29
|
def transfer(select_pin, write: [], read: 0, frequency: nil, mode: 0, bit_order: :msbfirst)
|
@@ -35,40 +35,6 @@ module Denko
|
|
35
35
|
board.spi_bb_listen select_pin, clock: pins[:clock], input: pins[:input],
|
36
36
|
read: read, mode: mode, bit_order: bit_order
|
37
37
|
end
|
38
|
-
|
39
|
-
# Uses regular Board#spi_stop since listeners are shared.
|
40
|
-
def stop(pin)
|
41
|
-
board.spi_stop(pin)
|
42
|
-
end
|
43
|
-
|
44
|
-
# Delegate this to board so peripherals can initialize their select pins.
|
45
|
-
def set_pin_mode(*args)
|
46
|
-
board.set_pin_mode(*args)
|
47
|
-
end
|
48
|
-
|
49
|
-
def convert_pin(pin)
|
50
|
-
board.convert_pin(pin)
|
51
|
-
end
|
52
|
-
|
53
|
-
# Add peripheral to self and the board. It gets callbacks directly from the board.
|
54
|
-
def add_component(component)
|
55
|
-
# Treat pin 255 as the component having no select pin. Mostly for APA102.
|
56
|
-
return if component.pin == 255
|
57
|
-
|
58
|
-
pins = components.map { |c| c.pin }
|
59
|
-
if pins.include? component.pin
|
60
|
-
raise ArgumentError, "duplicate select pin for #{component}"
|
61
|
-
end
|
62
|
-
|
63
|
-
components << component
|
64
|
-
board.add_component(component)
|
65
|
-
end
|
66
|
-
|
67
|
-
# Remove peripheral from self and the board.
|
68
|
-
def remove_component(component)
|
69
|
-
components.delete(component)
|
70
|
-
board.remove_component(component)
|
71
|
-
end
|
72
38
|
end
|
73
39
|
end
|
74
40
|
end
|
data/lib/denko/spi/bus.rb
CHANGED
@@ -1,43 +1,29 @@
|
|
1
1
|
module Denko
|
2
2
|
module SPI
|
3
3
|
class Bus
|
4
|
-
include
|
5
|
-
include Behaviors::BusController
|
6
|
-
include Behaviors::Reader
|
4
|
+
include BusCommon
|
7
5
|
|
8
6
|
# Board expects all components to have #pin.
|
9
7
|
attr_reader :pin
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
# Forward SPI methods with prefixed names.
|
15
|
-
def_delegator :board, :spi_transfer, :transfer
|
16
|
-
def_delegator :board, :spi_listen, :listen
|
17
|
-
def_delegator :board, :spi_stop, :stop
|
18
|
-
|
19
|
-
# Forward pin control methods with same names for board proxying.
|
20
|
-
def_delegator :board, :convert_pin
|
21
|
-
def_delegator :board, :set_pin_mode
|
22
|
-
|
23
|
-
# Add peripheral to self and the board. It gets callbacks directly from the board.
|
24
|
-
def add_component(component)
|
25
|
-
# Treat pin 255 as the component having no select pin. Mostly for APA102.
|
26
|
-
return if component.pin == 255
|
9
|
+
def spi_index
|
10
|
+
@spi_index ||= params[:spi_index] || params[:index] || 0
|
11
|
+
end
|
27
12
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
13
|
+
# Prepend spi_index to these and forward to the board.
|
14
|
+
def transfer(*args, **kwargs)
|
15
|
+
args.unshift(spi_index)
|
16
|
+
board.spi_transfer(*args, **kwargs)
|
17
|
+
end
|
32
18
|
|
33
|
-
|
34
|
-
|
19
|
+
def listen(*args, **kwargs)
|
20
|
+
args.unshift(spi_index)
|
21
|
+
board.spi_listen(*args, **kwargs)
|
35
22
|
end
|
36
23
|
|
37
|
-
#
|
38
|
-
def
|
39
|
-
|
40
|
-
board.remove_component(component)
|
24
|
+
# This is for WS2812 strips on PiBoard.
|
25
|
+
def show_ws2812(*args)
|
26
|
+
board.show_ws2812(*args, spi_index: spi_index)
|
41
27
|
end
|
42
28
|
end
|
43
29
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Denko
|
2
|
+
module SPI
|
3
|
+
module BusCommon
|
4
|
+
include Behaviors::BusController
|
5
|
+
include Behaviors::Reader
|
6
|
+
extend Forwardable
|
7
|
+
|
8
|
+
# Add peripheral to self and the board. It gets callbacks directly from the board.
|
9
|
+
def add_component(component)
|
10
|
+
# Ignore components with no select pin. Mostly for APA102.
|
11
|
+
return unless component.pin
|
12
|
+
|
13
|
+
pins = components.map { |c| c.pin }
|
14
|
+
if pins.include? component.pin
|
15
|
+
raise ArgumentError, "duplicate select pin for #{component}"
|
16
|
+
end
|
17
|
+
|
18
|
+
components << component
|
19
|
+
board.add_component(component)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Remove peripheral from self and the board.
|
23
|
+
def remove_component(component)
|
24
|
+
components.delete(component)
|
25
|
+
board.remove_component(component)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Forward pin control methods to the board, for select pin setup.
|
29
|
+
def_delegator :board, :convert_pin
|
30
|
+
def_delegator :board, :set_pin_mode
|
31
|
+
|
32
|
+
# If a component calls #stop, that's just a call to Board#spi_stop giving its select pin.
|
33
|
+
def_delegator :board, :spi_stop, :stop
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -1,28 +1,30 @@
|
|
1
1
|
module Denko
|
2
2
|
module SPI
|
3
3
|
class InputRegister < BaseRegister
|
4
|
+
include Behaviors::Lifecycle
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
#
|
7
|
+
# Keep track of whether anything is listening or reading a specific pin.
|
8
|
+
# This might be separate from whether a component is attached or not.
|
9
|
+
#
|
10
|
+
def reading_pins
|
11
|
+
@reading_pins ||= Array.new(bytes*8) { false }
|
12
|
+
end
|
13
|
+
|
14
|
+
def listening_pins
|
15
|
+
@listening_pins ||= Array.new(bytes*8) { false }
|
13
16
|
end
|
14
17
|
|
15
|
-
|
16
|
-
super(options)
|
18
|
+
after_initialize do
|
17
19
|
enable_proxy
|
18
20
|
end
|
19
21
|
|
20
22
|
def read
|
21
|
-
spi_read(
|
23
|
+
spi_read(bytes)
|
22
24
|
end
|
23
25
|
|
24
26
|
def listen
|
25
|
-
spi_listen(
|
27
|
+
spi_listen(bytes)
|
26
28
|
end
|
27
29
|
|
28
30
|
def stop
|
@@ -35,7 +37,7 @@ module Denko
|
|
35
37
|
def digital_read(pin)
|
36
38
|
# Remember what pin was read and force callbacks to run next update.
|
37
39
|
add_callback(:force_update) { Proc.new{} }
|
38
|
-
|
40
|
+
reading_pins[pin] = true
|
39
41
|
|
40
42
|
# Don't actually call #read if already listening.
|
41
43
|
read unless any_listening
|
@@ -43,16 +45,16 @@ module Denko
|
|
43
45
|
|
44
46
|
def digital_listen(pin, divider)
|
45
47
|
listen unless any_listening
|
46
|
-
|
48
|
+
listening_pins[pin] = true
|
47
49
|
end
|
48
50
|
|
49
51
|
def stop_listener(pin)
|
50
|
-
|
52
|
+
listening_pins[pin] = false
|
51
53
|
stop unless any_listening
|
52
54
|
end
|
53
55
|
|
54
56
|
def any_listening
|
55
|
-
|
57
|
+
listening_pins.each { |p| return true if p }
|
56
58
|
false
|
57
59
|
end
|
58
60
|
|
@@ -67,7 +69,7 @@ module Denko
|
|
67
69
|
components.each do |part|
|
68
70
|
update_component(part, pin, value) if pin == part.pin
|
69
71
|
end
|
70
|
-
|
72
|
+
reading_pins[pin] = false
|
71
73
|
end
|
72
74
|
end
|
73
75
|
end
|
@@ -77,14 +79,17 @@ module Denko
|
|
77
79
|
# within the main mutex lock.
|
78
80
|
#
|
79
81
|
def update(message)
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
if
|
82
|
+
# Since overriding update, make sure this is a byte array first.
|
83
|
+
byte_array = ensure_byte_array(message)
|
84
|
+
|
85
|
+
bits = byte_array_to_bit_array(byte_array)
|
86
|
+
|
87
|
+
callback_mutex.synchronize {
|
88
|
+
break unless @callbacks
|
89
|
+
break if @callbacks.empty?
|
90
|
+
|
91
|
+
# Arduino doesn't de-duplicate state. Do it, but honor :force_update callbacks.
|
92
|
+
if (bits != state) || @callbacks[:force_update]
|
88
93
|
@callbacks.each_value do |array|
|
89
94
|
array.each { |callback| callback.call(bits) }
|
90
95
|
end
|
@@ -94,15 +99,16 @@ module Denko
|
|
94
99
|
@callbacks.delete(:read)
|
95
100
|
@callbacks.delete(:force_update)
|
96
101
|
}
|
97
|
-
|
102
|
+
self.state = bits
|
98
103
|
end
|
99
104
|
|
100
105
|
def update_component(part, pin, value)
|
101
106
|
# Update if component is listening and value has changed.
|
102
|
-
if
|
107
|
+
if listening_pins[pin] && (value != state[pin])
|
103
108
|
part.update(value)
|
104
109
|
# Also update if the component forced a read.
|
105
|
-
|
110
|
+
# Always called inside callback_mutex, so @callbacks, not callbacks
|
111
|
+
elsif reading_pins[pin] && @callbacks[:force_update]
|
106
112
|
part.update(value)
|
107
113
|
end
|
108
114
|
end
|
@@ -114,14 +120,14 @@ module Denko
|
|
114
120
|
def byte_array_to_bit_array(byte_array)
|
115
121
|
#
|
116
122
|
# For each array element (1 byte):
|
117
|
-
# decimal number as string -> integer -> padded string of binary digits
|
123
|
+
# decimal number as string -> integer -> padded string of binary digits
|
118
124
|
# -> reverse digits from reading order to array indexing order
|
119
125
|
# -> join digits of all bytes into one string
|
120
126
|
#
|
121
127
|
binary_string = byte_array.map do |byte|
|
122
128
|
byte.to_i.to_s(2).rjust(8, "0").reverse
|
123
129
|
end.join
|
124
|
-
|
130
|
+
|
125
131
|
# Split the digits out of the string into individual integers.
|
126
132
|
binary_string.split("").map { |bit| bit.to_i }
|
127
133
|
end
|
@@ -1,39 +1,33 @@
|
|
1
1
|
module Denko
|
2
2
|
module SPI
|
3
3
|
class OutputRegister < BaseRegister
|
4
|
+
include Behaviors::Lifecycle
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
#
|
8
|
-
# When used as a board proxy, only write sate if @write_delay seconds
|
9
|
-
# have passed since this object last got input. Better for things like SSDs
|
10
|
-
# where many bits change in sequence, but not at exactly the same time.
|
11
|
-
#
|
12
|
-
@buffer_writes = true
|
13
|
-
@buffer_writes = false if options[:buffer_writes] == false
|
14
|
-
@write_delay = options[:write_delay] || 0.001
|
15
|
-
end
|
16
|
-
|
17
|
-
def after_initialize(options={})
|
6
|
+
after_initialize do
|
7
|
+
state
|
18
8
|
write
|
19
9
|
end
|
20
10
|
|
21
11
|
#
|
22
|
-
# Overrides Peripheral#write to always write
|
12
|
+
# Overrides Peripheral#write to always write state.
|
23
13
|
# Convert bit state to array of 0-255 integers (bytes) first.
|
24
14
|
#
|
25
15
|
def write
|
26
16
|
bytes = []
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
17
|
+
state_mutex.synchronize do
|
18
|
+
return if @previous_state == @state
|
19
|
+
@state.each_slice(8) do |slice|
|
20
|
+
# Convert nils in the slice to zero.
|
21
|
+
zeroed = slice.map { |bit| bit.to_i }
|
22
|
+
|
23
|
+
# Each slice is 8 bits of a byte, with the lowest on the left.
|
24
|
+
# Reverse to reading order (lowest right) then join into string, and convert to integer.
|
25
|
+
byte = zeroed.reverse.join.to_i(2)
|
26
|
+
|
27
|
+
# Pack bytes in reverse order.
|
28
|
+
bytes.unshift byte
|
29
|
+
end
|
30
|
+
@previous_state = @state.dup
|
37
31
|
end
|
38
32
|
spi_write(bytes)
|
39
33
|
end
|
@@ -42,25 +36,16 @@ module Denko
|
|
42
36
|
# BoardProxy interface
|
43
37
|
#
|
44
38
|
def digital_write(pin, value)
|
45
|
-
|
46
|
-
|
39
|
+
bit_set(pin, value)
|
40
|
+
write
|
47
41
|
end
|
48
|
-
|
49
|
-
def
|
50
|
-
state[pin]
|
42
|
+
|
43
|
+
def bit_set(pin, value)
|
44
|
+
state_mutex.synchronize { @state[pin] = value }
|
51
45
|
end
|
52
46
|
|
53
|
-
|
54
|
-
|
55
|
-
# Lets us catch multiple changed bits, like when hosting an SSD.
|
56
|
-
#
|
57
|
-
include Behaviors::Threaded
|
58
|
-
def write_buffered(old_state)
|
59
|
-
threaded do
|
60
|
-
sleep @write_delay
|
61
|
-
# Keep delaying if state has changed.
|
62
|
-
write if (old_state == state)
|
63
|
-
end
|
47
|
+
def digital_read(pin)
|
48
|
+
state[pin]
|
64
49
|
end
|
65
50
|
end
|
66
51
|
end
|
data/lib/denko/spi/peripheral.rb
CHANGED
@@ -1,42 +1,111 @@
|
|
1
1
|
module Denko
|
2
2
|
module SPI
|
3
3
|
module Peripheral
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
module Core
|
5
|
+
include Behaviors::BusPeripheral
|
6
|
+
include Behaviors::Callbacks
|
7
7
|
|
8
|
-
|
8
|
+
def spi_frequency
|
9
|
+
@spi_frequency ||= params[:spi_frequency] || 1_000_000
|
10
|
+
end
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
+
def spi_mode
|
13
|
+
@spi_mode ||= params[:spi_mode] || 0
|
14
|
+
end
|
12
15
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
def spi_bit_order
|
17
|
+
@spi_bit_order ||= params[:spi_bit_order] || :msbfirst
|
18
|
+
end
|
19
|
+
|
20
|
+
attr_writer :spi_frequency, :spi_mode, :spi_bit_order
|
21
|
+
|
22
|
+
#
|
23
|
+
# Delegate methods to the bus.
|
24
|
+
#
|
25
|
+
def spi_transfer(write: [], read: 0)
|
26
|
+
bus.transfer(select_pin, write: write, read: read, frequency: spi_frequency, mode: spi_mode, bit_order: spi_bit_order)
|
27
|
+
end
|
28
|
+
|
29
|
+
def spi_write(byte_array)
|
30
|
+
bus.transfer(select_pin, write: byte_array, frequency: spi_frequency, mode: spi_mode, bit_order: spi_bit_order)
|
31
|
+
end
|
32
|
+
|
33
|
+
def spi_read(num_bytes)
|
34
|
+
bus.transfer(select_pin, read: num_bytes, frequency: spi_frequency, mode: spi_mode, bit_order: spi_bit_order)
|
35
|
+
end
|
36
|
+
|
37
|
+
def spi_listen(num_bytes)
|
38
|
+
bus.listen(select_pin, read: num_bytes, frequency: spi_frequency, mode: spi_mode, bit_order: spi_bit_order)
|
39
|
+
end
|
40
|
+
|
41
|
+
def spi_stop
|
42
|
+
bus.stop(select_pin)
|
43
|
+
end
|
18
44
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
45
|
+
def ensure_byte_array(message)
|
46
|
+
if message.class == Array
|
47
|
+
# Byte array coming from PiBoard.
|
48
|
+
return message
|
49
|
+
else
|
50
|
+
# Split up comma delimited bytes coming from a microcontroller.
|
51
|
+
return message.split(",").map { |b| b.to_i }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def update(message)
|
56
|
+
super(ensure_byte_array(message))
|
57
|
+
end
|
24
58
|
end
|
25
59
|
|
26
|
-
|
27
|
-
|
60
|
+
module ChipSelectBehavior
|
61
|
+
include Behaviors::SinglePin
|
62
|
+
include Behaviors::Callbacks
|
63
|
+
include Behaviors::Lifecycle
|
64
|
+
|
65
|
+
before_initialize do
|
66
|
+
# It actually functions as an output.
|
67
|
+
params[:mode] = :output
|
68
|
+
|
69
|
+
# But we can't claim it on Linux (the SPI hardware handles it), so don't.
|
70
|
+
if Object.const_defined?("Denko::PiBoard")
|
71
|
+
bus = params[:bus] || params[:board]
|
72
|
+
if bus.board.class.ancestors.include?(Denko::PiBoard)
|
73
|
+
params[:mode] = nil
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
28
77
|
end
|
29
78
|
|
30
|
-
|
31
|
-
|
79
|
+
class ChipSelect
|
80
|
+
include ChipSelectBehavior
|
32
81
|
end
|
33
82
|
|
34
|
-
|
35
|
-
|
83
|
+
module SinglePin
|
84
|
+
include Core
|
85
|
+
include ChipSelectBehavior
|
86
|
+
|
87
|
+
def select_pin
|
88
|
+
pin
|
89
|
+
end
|
36
90
|
end
|
37
91
|
|
38
|
-
|
39
|
-
|
92
|
+
module MultiPin
|
93
|
+
include Core
|
94
|
+
include Behaviors::MultiPin
|
95
|
+
include Behaviors::Lifecycle
|
96
|
+
|
97
|
+
def select_pin
|
98
|
+
self.select.pin
|
99
|
+
end
|
100
|
+
|
101
|
+
def initialize_pins(params={})
|
102
|
+
super(params)
|
103
|
+
proxy_pin :select, ChipSelect, { board: bus.board, mode: :output }
|
104
|
+
end
|
105
|
+
|
106
|
+
after_initialize do
|
107
|
+
select.add_callback(:peripheral_forwarder) { |data| self.update(data) }
|
108
|
+
end
|
40
109
|
end
|
41
110
|
end
|
42
111
|
end
|
data/lib/denko/spi.rb
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
module Denko
|
2
2
|
module SPI
|
3
|
+
autoload :BusCommon, "#{__dir__}/spi/bus_common"
|
3
4
|
autoload :Bus, "#{__dir__}/spi/bus"
|
4
5
|
autoload :BitBang, "#{__dir__}/spi/bit_bang"
|
5
|
-
|
6
|
+
module Peripheral
|
7
|
+
autoload :Core, "#{__dir__}/spi/peripheral"
|
8
|
+
autoload :SinglePin, "#{__dir__}/spi/peripheral"
|
9
|
+
autoload :MultiPin, "#{__dir__}/spi/peripheral"
|
10
|
+
end
|
6
11
|
autoload :BaseRegister, "#{__dir__}/spi/base_register"
|
7
12
|
autoload :InputRegister, "#{__dir__}/spi/input_register"
|
8
13
|
autoload :OutputRegister, "#{__dir__}/spi/output_register"
|
data/lib/denko/uart/bit_bang.rb
CHANGED
@@ -3,12 +3,14 @@ module Denko
|
|
3
3
|
class UARTRxPin
|
4
4
|
include Behaviors::InputPin
|
5
5
|
include Behaviors::Callbacks
|
6
|
+
include Behaviors::Lifecycle
|
6
7
|
end
|
7
8
|
|
8
9
|
class BitBang
|
9
10
|
include Behaviors::MultiPin
|
10
11
|
include Behaviors::Callbacks
|
11
|
-
|
12
|
+
include Behaviors::Lifecycle
|
13
|
+
|
12
14
|
attr_reader :baud
|
13
15
|
|
14
16
|
def initialize_pins(options={})
|
@@ -16,10 +18,10 @@ module Denko
|
|
16
18
|
proxy_pin(:rx, UARTRxPin)
|
17
19
|
end
|
18
20
|
|
19
|
-
|
21
|
+
after_initialize do
|
20
22
|
hook_rx_callback
|
21
23
|
initialize_buffer
|
22
|
-
start(
|
24
|
+
start(params[:baud] || 9600)
|
23
25
|
end
|
24
26
|
|
25
27
|
def initialize_buffer
|
data/lib/denko/uart/hardware.rb
CHANGED
@@ -3,23 +3,24 @@ module Denko
|
|
3
3
|
class Hardware
|
4
4
|
include Behaviors::SinglePin
|
5
5
|
include Behaviors::Callbacks
|
6
|
+
include Behaviors::Lifecycle
|
6
7
|
|
7
8
|
attr_reader :index, :baud
|
8
|
-
|
9
|
-
|
10
|
-
if
|
11
|
-
@index =
|
9
|
+
|
10
|
+
before_initialize do
|
11
|
+
if params[:index] && (params[:index] > 0) && (params[:index] < 4)
|
12
|
+
@index = params[:index]
|
12
13
|
else
|
13
|
-
raise ArgumentError, "UART index (#{
|
14
|
+
raise ArgumentError, "UART index (#{params[:index]}) not given or out of range (1..3)"
|
14
15
|
end
|
15
16
|
|
16
17
|
# Set pin to a "virtual pin" in 251 - 253 that will match the board.
|
17
|
-
|
18
|
+
params[:pin] = 250 + params[:index]
|
18
19
|
end
|
19
20
|
|
20
|
-
|
21
|
+
after_initialize do
|
21
22
|
initialize_buffer
|
22
|
-
start(
|
23
|
+
start(params[:baud] ||= 9600)
|
23
24
|
end
|
24
25
|
|
25
26
|
def initialize_buffer
|
data/lib/denko/version.rb
CHANGED
data/lib/denko.rb
CHANGED
@@ -4,11 +4,18 @@ module Denko
|
|
4
4
|
def self.root
|
5
5
|
File.expand_path '../..', __FILE__
|
6
6
|
end
|
7
|
+
|
8
|
+
def self.cruby?
|
9
|
+
RUBY_ENGINE == "ruby"
|
10
|
+
end
|
7
11
|
end
|
8
12
|
|
9
13
|
# For method delegation.
|
10
14
|
require 'forwardable'
|
11
15
|
|
16
|
+
# Bypass mutexes where possible for CRuby.
|
17
|
+
require_relative 'denko/mutex_stub'
|
18
|
+
|
12
19
|
# Component support stuff.
|
13
20
|
require_relative 'denko/version'
|
14
21
|
require_relative 'denko/behaviors'
|
@@ -37,3 +44,6 @@ require_relative 'denko/led'
|
|
37
44
|
require_relative 'denko/motor'
|
38
45
|
require_relative 'denko/rtc'
|
39
46
|
require_relative 'denko/sensor'
|
47
|
+
|
48
|
+
# Diagnostics
|
49
|
+
require_relative 'denko/connection/binary_echo'
|