denko 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/build_avr.yml +61 -0
- data/.github/workflows/build_esp32.yml +58 -0
- data/.github/workflows/build_esp8266.yml +57 -0
- data/.github/workflows/build_megaavr.yml +61 -0
- data/.github/workflows/build_rp2040.yml +61 -0
- data/.github/workflows/build_sam3x.yml +59 -0
- data/.github/workflows/build_samd.yml +61 -0
- data/.github/workflows/ruby.yml +47 -0
- data/.gitignore +24 -0
- data/.gitmodules +3 -0
- data/.vscode/settings.json +5 -0
- data/.vscode/tasks.json +20 -0
- data/CHANGELOG.md +466 -0
- data/DEPS_CLI.md +80 -0
- data/DEPS_IDE.md +120 -0
- data/Gemfile +4 -0
- data/HARDWARE.md +195 -0
- data/LICENSE +22 -0
- data/README.md +152 -0
- data/Rakefile +11 -0
- data/bin/denko +22 -0
- data/build +27 -0
- data/denko.gemspec +47 -0
- data/examples/advanced/rotary_encoder_mac_volume.rb +48 -0
- data/examples/advanced/ssd1306_time_temp_rh.rb +48 -0
- data/examples/analog_io/ads1118.rb +74 -0
- data/examples/analog_io/dac_loopback.rb +32 -0
- data/examples/analog_io/input.rb +52 -0
- data/examples/connection/tcp.rb +34 -0
- data/examples/digital_io/rotary_encoder.rb +26 -0
- data/examples/display/hd44780.png +0 -0
- data/examples/display/hd44780.rb +39 -0
- data/examples/display/ssd1306.rb +40 -0
- data/examples/display/ssd1306_s2_pico.rb +29 -0
- data/examples/eeprom/built_in.rb +32 -0
- data/examples/i2c/search.rb +53 -0
- data/examples/led/apa102_bounce.rb +33 -0
- data/examples/led/apa102_breathe.rb +45 -0
- data/examples/led/builtin_blink.rb +12 -0
- data/examples/led/seven_segment_char_echo.rb +15 -0
- data/examples/led/ws2812_bounce.rb +32 -0
- data/examples/led/ws2812_builtin_blink.rb +21 -0
- data/examples/motor/l298.rb +43 -0
- data/examples/motor/servo.rb +16 -0
- data/examples/motor/stepper.png +0 -0
- data/examples/motor/stepper.rb +43 -0
- data/examples/pulse_io/buzzer.rb +30 -0
- data/examples/pulse_io/ir_transmitter.rb +55 -0
- data/examples/rtc/ds3231.rb +48 -0
- data/examples/sensor/aht10.rb +15 -0
- data/examples/sensor/aht20.rb +15 -0
- data/examples/sensor/bme280.rb +75 -0
- data/examples/sensor/dht.rb +24 -0
- data/examples/sensor/ds18b20.rb +58 -0
- data/examples/sensor/htu21d.rb +54 -0
- data/examples/sensor/htu31d.rb +31 -0
- data/examples/spi/input_register.rb +50 -0
- data/examples/spi/output_register.rb +49 -0
- data/examples/spi/ssd_through_register.rb +40 -0
- data/examples/spi/two_registers.rb +46 -0
- data/examples/uart/bit_bang_read.rb +16 -0
- data/examples/uart/bit_bang_write.rb +16 -0
- data/examples/uart/board_passthrough.rb +34 -0
- data/examples/uart/hardware_loopback.rb +16 -0
- data/lib/denko/analog_io/ads1118.rb +182 -0
- data/lib/denko/analog_io/input.rb +79 -0
- data/lib/denko/analog_io/output.rb +20 -0
- data/lib/denko/analog_io/potentiometer.rb +15 -0
- data/lib/denko/analog_io/sensor.rb +6 -0
- data/lib/denko/analog_io.rb +9 -0
- data/lib/denko/behaviors/board_proxy.rb +23 -0
- data/lib/denko/behaviors/bus_controller.rb +11 -0
- data/lib/denko/behaviors/bus_controller_addressed.rb +15 -0
- data/lib/denko/behaviors/bus_peripheral.rb +21 -0
- data/lib/denko/behaviors/bus_peripheral_addressed.rb +15 -0
- data/lib/denko/behaviors/callbacks.rb +67 -0
- data/lib/denko/behaviors/component.rb +48 -0
- data/lib/denko/behaviors/input_pin.rb +24 -0
- data/lib/denko/behaviors/listener.rb +22 -0
- data/lib/denko/behaviors/multi_pin.rb +72 -0
- data/lib/denko/behaviors/output_pin.rb +13 -0
- data/lib/denko/behaviors/poller.rb +31 -0
- data/lib/denko/behaviors/reader.rb +49 -0
- data/lib/denko/behaviors/single_pin.rb +26 -0
- data/lib/denko/behaviors/state.rb +24 -0
- data/lib/denko/behaviors/subcomponents.rb +35 -0
- data/lib/denko/behaviors/threaded.rb +54 -0
- data/lib/denko/behaviors.rb +26 -0
- data/lib/denko/board/core.rb +151 -0
- data/lib/denko/board/eeprom.rb +20 -0
- data/lib/denko/board/i2c.rb +68 -0
- data/lib/denko/board/infrared.rb +18 -0
- data/lib/denko/board/led_array.rb +18 -0
- data/lib/denko/board/map.rb +46 -0
- data/lib/denko/board/message_pack.rb +7 -0
- data/lib/denko/board/one_wire.rb +34 -0
- data/lib/denko/board/pulse.rb +26 -0
- data/lib/denko/board/servo.rb +22 -0
- data/lib/denko/board/spi.rb +65 -0
- data/lib/denko/board/spi_bit_bang.rb +41 -0
- data/lib/denko/board/tone.rb +23 -0
- data/lib/denko/board/uart.rb +42 -0
- data/lib/denko/board/uart_bit_bang.rb +33 -0
- data/lib/denko/board.rb +104 -0
- data/lib/denko/connection/base.rb +75 -0
- data/lib/denko/connection/board_uart.rb +36 -0
- data/lib/denko/connection/flow_control.rb +153 -0
- data/lib/denko/connection/handshake.rb +60 -0
- data/lib/denko/connection/serial.rb +90 -0
- data/lib/denko/connection/tcp.rb +44 -0
- data/lib/denko/connection.rb +10 -0
- data/lib/denko/digital_io/button.rb +8 -0
- data/lib/denko/digital_io/input.rb +44 -0
- data/lib/denko/digital_io/output.rb +47 -0
- data/lib/denko/digital_io/relay.rb +6 -0
- data/lib/denko/digital_io/rotary_encoder.rb +107 -0
- data/lib/denko/digital_io.rb +9 -0
- data/lib/denko/display/canvas.rb +282 -0
- data/lib/denko/display/hd44780.rb +266 -0
- data/lib/denko/display/ssd1306.rb +179 -0
- data/lib/denko/display.rb +7 -0
- data/lib/denko/eeprom/built_in.rb +69 -0
- data/lib/denko/eeprom.rb +5 -0
- data/lib/denko/fonts.rb +106 -0
- data/lib/denko/i2c/bus.rb +52 -0
- data/lib/denko/i2c/peripheral.rb +38 -0
- data/lib/denko/i2c.rb +6 -0
- data/lib/denko/led/apa102.rb +87 -0
- data/lib/denko/led/base.rb +12 -0
- data/lib/denko/led/rgb.rb +38 -0
- data/lib/denko/led/seven_segment.rb +111 -0
- data/lib/denko/led/ws2812.rb +48 -0
- data/lib/denko/led.rb +13 -0
- data/lib/denko/message.rb +92 -0
- data/lib/denko/motor/l298.rb +49 -0
- data/lib/denko/motor/servo.rb +51 -0
- data/lib/denko/motor/stepper.rb +71 -0
- data/lib/denko/motor.rb +7 -0
- data/lib/denko/one_wire/bus.rb +61 -0
- data/lib/denko/one_wire/bus_enumeration.rb +88 -0
- data/lib/denko/one_wire/constants.rb +17 -0
- data/lib/denko/one_wire/helper.rb +33 -0
- data/lib/denko/one_wire/peripheral.rb +62 -0
- data/lib/denko/one_wire.rb +9 -0
- data/lib/denko/pulse_io/buzzer.rb +25 -0
- data/lib/denko/pulse_io/ir_transmitter.rb +22 -0
- data/lib/denko/pulse_io/pwm_output.rb +34 -0
- data/lib/denko/pulse_io.rb +7 -0
- data/lib/denko/rtc/ds3231.rb +48 -0
- data/lib/denko/rtc.rb +5 -0
- data/lib/denko/sensor/aht.rb +165 -0
- data/lib/denko/sensor/bme280.rb +366 -0
- data/lib/denko/sensor/dht.rb +43 -0
- data/lib/denko/sensor/ds18b20.rb +74 -0
- data/lib/denko/sensor/htu21d.rb +168 -0
- data/lib/denko/sensor/htu31d.rb +187 -0
- data/lib/denko/sensor/virtual.rb +42 -0
- data/lib/denko/sensor.rb +13 -0
- data/lib/denko/spi/base_register.rb +37 -0
- data/lib/denko/spi/bit_bang.rb +74 -0
- data/lib/denko/spi/bus.rb +44 -0
- data/lib/denko/spi/input_register.rb +130 -0
- data/lib/denko/spi/output_register.rb +67 -0
- data/lib/denko/spi/peripheral.rb +43 -0
- data/lib/denko/spi.rb +10 -0
- data/lib/denko/uart/bit_bang.rb +69 -0
- data/lib/denko/uart/hardware.rb +65 -0
- data/lib/denko/uart.rb +6 -0
- data/lib/denko/version.rb +3 -0
- data/lib/denko.rb +39 -0
- data/lib/denko_cli/generator.rb +171 -0
- data/lib/denko_cli/helper.rb +29 -0
- data/lib/denko_cli/missing_files.txt +20 -0
- data/lib/denko_cli/packages.rb +101 -0
- data/lib/denko_cli/parser.rb +73 -0
- data/lib/denko_cli/targets.rb +30 -0
- data/lib/denko_cli/targets.txt +113 -0
- data/lib/denko_cli/usage.txt +34 -0
- data/lib/denko_cli.rb +18 -0
- data/src/denko_ethernet.ino +78 -0
- data/src/denko_serial.ino +41 -0
- data/src/denko_wifi.ino +157 -0
- data/src/lib/Denko.cpp +330 -0
- data/src/lib/Denko.h +259 -0
- data/src/lib/DenkoCoreIO.cpp +322 -0
- data/src/lib/DenkoDefines.h +116 -0
- data/src/lib/DenkoEEPROM.cpp +64 -0
- data/src/lib/DenkoI2C.cpp +155 -0
- data/src/lib/DenkoIROut.cpp +33 -0
- data/src/lib/DenkoIROutESP.cpp +26 -0
- data/src/lib/DenkoLEDArray.cpp +49 -0
- data/src/lib/DenkoOneWire.cpp +156 -0
- data/src/lib/DenkoPulseInput.cpp +57 -0
- data/src/lib/DenkoSPI.cpp +165 -0
- data/src/lib/DenkoSPIBB.cpp +156 -0
- data/src/lib/DenkoServo.cpp +83 -0
- data/src/lib/DenkoTone.cpp +25 -0
- data/src/lib/DenkoUART.cpp +118 -0
- data/src/lib/DenkoUARTBB.cpp +62 -0
- data/target.yml +3 -0
- data/test/analog_io/input_test.rb +38 -0
- data/test/analog_io/output_test.rb +26 -0
- data/test/analog_io/potentiometer_test.rb +62 -0
- data/test/behaviors/board_proxy_test.rb +24 -0
- data/test/behaviors/bus_controller_addressed_test.rb +40 -0
- data/test/behaviors/bus_controller_test.rb +28 -0
- data/test/behaviors/bus_peripheral_addressed.rb +44 -0
- data/test/behaviors/bus_peripheral_test.rb +39 -0
- data/test/behaviors/callbacks_test.rb +118 -0
- data/test/behaviors/component_test.rb +56 -0
- data/test/behaviors/input_pin_test.rb +42 -0
- data/test/behaviors/listener_test.rb +60 -0
- data/test/behaviors/multi_pin_test.rb +70 -0
- data/test/behaviors/output_pin_test.rb +27 -0
- data/test/behaviors/poller_test.rb +64 -0
- data/test/behaviors/reader_test.rb +68 -0
- data/test/behaviors/single_pin_test.rb +41 -0
- data/test/behaviors/subcomponents_test.rb +75 -0
- data/test/behaviors/threaded_test.rb +98 -0
- data/test/board/board_test.rb +130 -0
- data/test/board/core_test.rb +182 -0
- data/test/board/eeprom_test.rb +34 -0
- data/test/board/helper_test.rb +38 -0
- data/test/board/i2c_test.rb +114 -0
- data/test/board/infrared_test.rb +37 -0
- data/test/board/message_test.rb +54 -0
- data/test/board/one_wire_test.rb +69 -0
- data/test/board/pulse_test.rb +51 -0
- data/test/board/servo_test.rb +47 -0
- data/test/board/spi_test.rb +97 -0
- data/test/board/tone_test.rb +42 -0
- data/test/connection/serial_test.rb +172 -0
- data/test/connection/tcp_test.rb +37 -0
- data/test/digital_io/input_test.rb +65 -0
- data/test/digital_io/output_test.rb +64 -0
- data/test/digital_io/rotary_encoder_test.rb +99 -0
- data/test/display/hd44780_test.rb +23 -0
- data/test/eeprom/built_in_test.rb +61 -0
- data/test/i2c/bus_test.rb +66 -0
- data/test/i2c/peripheral_test.rb +50 -0
- data/test/led/base_test.rb +24 -0
- data/test/led/rgb_test.rb +64 -0
- data/test/led/seven_segment_test.rb +86 -0
- data/test/motor/servo_test.rb +62 -0
- data/test/motor/stepper_test.rb +51 -0
- data/test/one_wire/bus_enumerator_test.rb +134 -0
- data/test/one_wire/bus_test.rb +142 -0
- data/test/one_wire/helper_test.rb +18 -0
- data/test/one_wire/peripheral_test.rb +158 -0
- data/test/pulse_io/buzzer_test.rb +48 -0
- data/test/pulse_io/ir_transmitter_test.rb +38 -0
- data/test/pulse_io/pwm_output_test.rb +72 -0
- data/test/rtc/ds3231_test.rb +55 -0
- data/test/sensor/dht_test.rb +64 -0
- data/test/sensor/ds18b20_test.rb +107 -0
- data/test/spi/base_register_test.rb +34 -0
- data/test/spi/bus_test.rb +76 -0
- data/test/spi/input_register_test.rb +140 -0
- data/test/spi/output_register_test.rb +93 -0
- data/test/test_helper.rb +223 -0
- data/test/uart/bitbang_test.rb +37 -0
- data/tutorial/01-led/led.fzz +0 -0
- data/tutorial/01-led/led.pdf +0 -0
- data/tutorial/01-led/led.rb +73 -0
- data/tutorial/02-button/button.fzz +0 -0
- data/tutorial/02-button/button.pdf +0 -0
- data/tutorial/02-button/button.rb +64 -0
- data/tutorial/03-potentiometer/potentiometer.fzz +0 -0
- data/tutorial/03-potentiometer/potentiometer.pdf +0 -0
- data/tutorial/03-potentiometer/potentiometer.rb +62 -0
- data/tutorial/04-pwm_led/pwm_led.fzz +0 -0
- data/tutorial/04-pwm_led/pwm_led.pdf +0 -0
- data/tutorial/04-pwm_led/pwm_led.rb +66 -0
- data/tutorial/05-rgb_led/rgb_led.fzz +0 -0
- data/tutorial/05-rgb_led/rgb_led.pdf +0 -0
- data/tutorial/05-rgb_led/rgb_led.rb +58 -0
- data/tutorial/05-rgb_led/rgb_mapping.rb +76 -0
- data/vendor/board-maps/.gitignore +56 -0
- data/vendor/board-maps/.gitmodules +21 -0
- data/vendor/board-maps/BoardMap.h +1364 -0
- data/vendor/board-maps/README.md +51 -0
- data/vendor/board-maps/lib/boards_parser.rb +66 -0
- data/vendor/board-maps/lib/header_parser.rb +164 -0
- data/vendor/board-maps/run.rb +47 -0
- data/vendor/board-maps/yaml/0XCB_HELIOS.yml +48 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32S2.yml +25 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32S2_REVTFT.yml +25 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32S2_TFT.yml +27 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32S3.yml +29 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32S3_NOPSRAM.yml +29 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32S3_REVTFT.yml +25 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32S3_TFT.yml +27 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32_V2.yml +30 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_RP2040_CAN.yml +48 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_RP2040_DVI.yml +48 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_RP2040_PROP_MAKER.yml +48 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_RP2040_RFM.yml +48 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_RP2040_SCORPIO.yml +48 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_RP2040_THINKINK.yml +48 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_RP2040_USB_HOST.yml +48 -0
- data/vendor/board-maps/yaml/ADAFRUIT_ITSYBITSY_ESP32.yml +24 -0
- data/vendor/board-maps/yaml/ADAFRUIT_ITSYBITSY_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/ADAFRUIT_KB2040_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/ADAFRUIT_MACROPAD_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/ADAFRUIT_MATRIXPORTAL_ESP32S3.yml +16 -0
- data/vendor/board-maps/yaml/ADAFRUIT_QTPY_ESP32C3.yml +12 -0
- data/vendor/board-maps/yaml/ADAFRUIT_QTPY_ESP32S2.yml +22 -0
- data/vendor/board-maps/yaml/ADAFRUIT_QTPY_ESP32S3_NOPSRAM.yml +20 -0
- data/vendor/board-maps/yaml/ADAFRUIT_QTPY_ESP32_PICO.yml +27 -0
- data/vendor/board-maps/yaml/ADAFRUIT_QTPY_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/ADAFRUIT_STEMMAFRIEND_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/ADAFRUIT_TRINKEYQT_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/ALKS.yml +34 -0
- data/vendor/board-maps/yaml/AMPERKA_WIFI_SLOT.yml +16 -0
- data/vendor/board-maps/yaml/AVR_ADK.yml +24 -0
- data/vendor/board-maps/yaml/AVR_BT.yml +16 -0
- data/vendor/board-maps/yaml/AVR_CIRCUITPLAY.yml +14 -0
- data/vendor/board-maps/yaml/AVR_DUEMILANOVE.yml +16 -0
- data/vendor/board-maps/yaml/AVR_ESPLORA.yml +20 -0
- data/vendor/board-maps/yaml/AVR_ETHERNET.yml +16 -0
- data/vendor/board-maps/yaml/AVR_FIO.yml +16 -0
- data/vendor/board-maps/yaml/AVR_GEMMA.yml +6 -0
- data/vendor/board-maps/yaml/AVR_INDUSTRIAL101.yml +20 -0
- data/vendor/board-maps/yaml/AVR_LEONARDO.yml +20 -0
- data/vendor/board-maps/yaml/AVR_LEONARDO_ETH.yml +20 -0
- data/vendor/board-maps/yaml/AVR_LILYPAD.yml +16 -0
- data/vendor/board-maps/yaml/AVR_LILYPAD_USB.yml +20 -0
- data/vendor/board-maps/yaml/AVR_LININO_ONE.yml +20 -0
- data/vendor/board-maps/yaml/AVR_MEGA.yml +24 -0
- data/vendor/board-maps/yaml/AVR_MEGA2560.yml +24 -0
- data/vendor/board-maps/yaml/AVR_MICRO.yml +20 -0
- data/vendor/board-maps/yaml/AVR_MINI.yml +16 -0
- data/vendor/board-maps/yaml/AVR_NANO.yml +16 -0
- data/vendor/board-maps/yaml/AVR_NANO_EVERY.yml +22 -0
- data/vendor/board-maps/yaml/AVR_NG.yml +16 -0
- data/vendor/board-maps/yaml/AVR_PRO.yml +16 -0
- data/vendor/board-maps/yaml/AVR_ROBOT_CONTROL.yml +22 -0
- data/vendor/board-maps/yaml/AVR_ROBOT_MOTOR.yml +19 -0
- data/vendor/board-maps/yaml/AVR_UNO.yml +16 -0
- data/vendor/board-maps/yaml/AVR_UNO_WIFI_DEV_ED.yml +16 -0
- data/vendor/board-maps/yaml/AVR_UNO_WIFI_REV2.yml +22 -0
- data/vendor/board-maps/yaml/AVR_YUN.yml +20 -0
- data/vendor/board-maps/yaml/AVR_YUNMINI.yml +20 -0
- data/vendor/board-maps/yaml/AirM2M_CORE_ESP32C3.yml +14 -0
- data/vendor/board-maps/yaml/BEE_DATA_LOGGER.yml +39 -0
- data/vendor/board-maps/yaml/BPI_BIT.yml +9 -0
- data/vendor/board-maps/yaml/BPI_LEAF_S3.yml +31 -0
- data/vendor/board-maps/yaml/BRIDGETEK_IDM2040-7A.yml +48 -0
- data/vendor/board-maps/yaml/BeeMotionS3.yml +40 -0
- data/vendor/board-maps/yaml/Bee_Motion.yml +27 -0
- data/vendor/board-maps/yaml/Bee_Motion_Mini.yml +1 -0
- data/vendor/board-maps/yaml/Bee_S3.yml +38 -0
- data/vendor/board-maps/yaml/CHALLENGER_2040_LORA_RP2040.yml +39 -0
- data/vendor/board-maps/yaml/CHALLENGER_2040_LTE_RP2040.yml +38 -0
- data/vendor/board-maps/yaml/CHALLENGER_2040_NFC_RP2040.yml +32 -0
- data/vendor/board-maps/yaml/CHALLENGER_2040_SDRTC_RP2040.yml +36 -0
- data/vendor/board-maps/yaml/CHALLENGER_2040_SUBGHZ_RP2040.yml +39 -0
- data/vendor/board-maps/yaml/CHALLENGER_2040_UWB_RP2040.yml +39 -0
- data/vendor/board-maps/yaml/CHALLENGER_2040_WIFI_BLE_RP2040.yml +42 -0
- data/vendor/board-maps/yaml/CHALLENGER_2040_WIFI_RP2040.yml +38 -0
- data/vendor/board-maps/yaml/CHALLENGER_NB_2040_WIFI_RP2040.yml +38 -0
- data/vendor/board-maps/yaml/CRABIK_SLOT_ESP32_S3.yml +19 -0
- data/vendor/board-maps/yaml/CYTRON_MAKER_FEATHER_AIOT_S3.yml +26 -0
- data/vendor/board-maps/yaml/CYTRON_MAKER_NANO_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/CYTRON_MAKER_PI_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/CoreESP32.yml +49 -0
- data/vendor/board-maps/yaml/D1_MINI32.yml +36 -0
- data/vendor/board-maps/yaml/D1_UNO32.yml +28 -0
- data/vendor/board-maps/yaml/DATANOISETV_PICOADK.yml +48 -0
- data/vendor/board-maps/yaml/DENKY.yml +26 -0
- data/vendor/board-maps/yaml/DENKY_PICOV3.yml +26 -0
- data/vendor/board-maps/yaml/DENKY_WROOM32.yml +26 -0
- data/vendor/board-maps/yaml/DEPARTMENT_OF_ALCHEMY_MINIMAIN_ESP32S2.yml +26 -0
- data/vendor/board-maps/yaml/DFROBOT_BEETLE_ESP32_C3.yml +14 -0
- data/vendor/board-maps/yaml/DFROBOT_BEETLE_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/DFROBOT_FIREBEETLE_2_ESP32E.yml +44 -0
- data/vendor/board-maps/yaml/DFROBOT_FIREBEETLE_2_ESP32S3.yml +38 -0
- data/vendor/board-maps/yaml/DFROBOT_ROMEO_ESP32S3.yml +7 -0
- data/vendor/board-maps/yaml/DPU_ESP32.yml +26 -0
- data/vendor/board-maps/yaml/DYDK.yml +38 -0
- data/vendor/board-maps/yaml/DYDK1A.yml +37 -0
- data/vendor/board-maps/yaml/DYDK1Av2.yml +45 -0
- data/vendor/board-maps/yaml/DYG.yml +20 -0
- data/vendor/board-maps/yaml/DYM.yml +40 -0
- data/vendor/board-maps/yaml/DYMv2.yml +39 -0
- data/vendor/board-maps/yaml/D_Duino_32.yml +29 -0
- data/vendor/board-maps/yaml/ELECTRONICCATS_HUNTERCAT_NFC.yml +44 -0
- data/vendor/board-maps/yaml/ESP320.yml +8 -0
- data/vendor/board-maps/yaml/ESP32C3_DEV.yml +14 -0
- data/vendor/board-maps/yaml/ESP32C3_M1_I_KIT.yml +13 -0
- data/vendor/board-maps/yaml/ESP32S2_DEV.yml +33 -0
- data/vendor/board-maps/yaml/ESP32S2_THING_PLUS.yml +34 -0
- data/vendor/board-maps/yaml/ESP32S2_USB.yml +33 -0
- data/vendor/board-maps/yaml/ESP32S3_CAM_LCD.yml +7 -0
- data/vendor/board-maps/yaml/ESP32S3_DEV.yml +38 -0
- data/vendor/board-maps/yaml/ESP32_DEV.yml +26 -0
- data/vendor/board-maps/yaml/ESP32_DEVKIT_LIPO.yml +26 -0
- data/vendor/board-maps/yaml/ESP32_EVB.yml +7 -0
- data/vendor/board-maps/yaml/ESP32_GATEWAY.yml +13 -0
- data/vendor/board-maps/yaml/ESP32_GATEWAY_C.yml +13 -0
- data/vendor/board-maps/yaml/ESP32_GATEWAY_E.yml +13 -0
- data/vendor/board-maps/yaml/ESP32_GATEWAY_F.yml +13 -0
- data/vendor/board-maps/yaml/ESP32_IOT_REDBOARD.yml +27 -0
- data/vendor/board-maps/yaml/ESP32_MICROMOD.yml +24 -0
- data/vendor/board-maps/yaml/ESP32_PICO.yml +26 -0
- data/vendor/board-maps/yaml/ESP32_POE.yml +7 -0
- data/vendor/board-maps/yaml/ESP32_POE_ISO.yml +7 -0
- data/vendor/board-maps/yaml/ESP32_S3_BOX.yml +16 -0
- data/vendor/board-maps/yaml/ESP32_S3_USB_OTG.yml +11 -0
- data/vendor/board-maps/yaml/ESP32_THING.yml +27 -0
- data/vendor/board-maps/yaml/ESP32_THING_PLUS.yml +30 -0
- data/vendor/board-maps/yaml/ESP32_THING_PLUS_C.yml +30 -0
- data/vendor/board-maps/yaml/ESP32_WROOM_DA.yml +26 -0
- data/vendor/board-maps/yaml/ESP32_WROVER_KIT.yml +26 -0
- data/vendor/board-maps/yaml/ESP8266_ADAFRUIT_HUZZAH.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_AGRUMINO_LEMON_V4.yml +8 -0
- data/vendor/board-maps/yaml/ESP8266_ARDUINO_PRIMO.yml +7 -0
- data/vendor/board-maps/yaml/ESP8266_ARDUINO_STAR_OTTO.yml +7 -0
- data/vendor/board-maps/yaml/ESP8266_ARDUINO_UNOWIFI.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_ESP01.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_ESP07.yml +20 -0
- data/vendor/board-maps/yaml/ESP8266_ESP12.yml +20 -0
- data/vendor/board-maps/yaml/ESP8266_ESP13.yml +17 -0
- data/vendor/board-maps/yaml/ESP8266_ESP210.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_ESPECTRO_CORE.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_ESPINO_ESP12.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_ESPINO_ESP13.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_ESPRESSO_LITE_V1.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_ESPRESSO_LITE_V2.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_GENERIC.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_INVENT_ONE.yml +22 -0
- data/vendor/board-maps/yaml/ESP8266_NODEMCU_ESP12.yml +20 -0
- data/vendor/board-maps/yaml/ESP8266_NODEMCU_ESP12E.yml +20 -0
- data/vendor/board-maps/yaml/ESP8266_OAK.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_PHOENIX_V1.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_PHOENIX_V2.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_SCHIRMILABS_EDUINO_WIFI.yml +25 -0
- data/vendor/board-maps/yaml/ESP8266_SONOFF_BASIC.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_SONOFF_S20.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_SONOFF_SV.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_SONOFF_TH.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_THING.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_THING_DEV.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_WEMOS_D1MINI.yml +18 -0
- data/vendor/board-maps/yaml/ESP8266_WEMOS_D1MINILITE.yml +18 -0
- data/vendor/board-maps/yaml/ESP8266_WEMOS_D1MINIPRO.yml +18 -0
- data/vendor/board-maps/yaml/ESP8266_WEMOS_D1R1.yml +25 -0
- data/vendor/board-maps/yaml/ESP8266_WEMOS_D1WROOM02.yml +18 -0
- data/vendor/board-maps/yaml/ESP8266_WIO_LINK.yml +9 -0
- data/vendor/board-maps/yaml/ESP8266_XINABOX_CW01.yml +9 -0
- data/vendor/board-maps/yaml/ESPECTRO32.yml +27 -0
- data/vendor/board-maps/yaml/ESPea32.yml +27 -0
- data/vendor/board-maps/yaml/ESPino32.yml +27 -0
- data/vendor/board-maps/yaml/ET-Board.yml +26 -0
- data/vendor/board-maps/yaml/EXTREMEELEXTRONICS_RC2040.yml +46 -0
- data/vendor/board-maps/yaml/Edgebox-ESP-100.yml +7 -0
- data/vendor/board-maps/yaml/FEATHERS2.yml +33 -0
- data/vendor/board-maps/yaml/FEATHERS2NEO.yml +30 -0
- data/vendor/board-maps/yaml/FEATHERS3.yml +29 -0
- data/vendor/board-maps/yaml/FEATHER_ESP32.yml +28 -0
- data/vendor/board-maps/yaml/FLYBOARD2040_CORE.yml +48 -0
- data/vendor/board-maps/yaml/FRANZININHO_WIFI.yml +33 -0
- data/vendor/board-maps/yaml/FRANZININHO_WIFI_MSC.yml +33 -0
- data/vendor/board-maps/yaml/FROG_ESP32.yml +26 -0
- data/vendor/board-maps/yaml/FUNHOUSE_ESP32S2.yml +22 -0
- data/vendor/board-maps/yaml/GEN4_IOD.yml +9 -0
- data/vendor/board-maps/yaml/GENERIC_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/HEALTHYPI_4.yml +27 -0
- data/vendor/board-maps/yaml/HONEYLEMON.yml +27 -0
- data/vendor/board-maps/yaml/HORNBILL_ESP32_DEV.yml +27 -0
- data/vendor/board-maps/yaml/HORNBILL_ESP32_MINIMA.yml +16 -0
- data/vendor/board-maps/yaml/ILABS_2040_RPICO32_RP2040.yml +47 -0
- data/vendor/board-maps/yaml/IMBRIOS_LOGSENS_V1P1.yml +19 -0
- data/vendor/board-maps/yaml/INTOROBOT_ESP32_DEV.yml +34 -0
- data/vendor/board-maps/yaml/LILYGO_T_DISPLAY_S3.yml +26 -0
- data/vendor/board-maps/yaml/LOLIN32.yml +27 -0
- data/vendor/board-maps/yaml/LOLIN32_LITE.yml +27 -0
- data/vendor/board-maps/yaml/LOLIN_C3_MINI.yml +14 -0
- data/vendor/board-maps/yaml/LOLIN_D32.yml +27 -0
- data/vendor/board-maps/yaml/LOLIN_D32_PRO.yml +27 -0
- data/vendor/board-maps/yaml/LOLIN_S2_MINI.yml +34 -0
- data/vendor/board-maps/yaml/LOLIN_S2_PICO.yml +34 -0
- data/vendor/board-maps/yaml/LOLIN_S3.yml +32 -0
- data/vendor/board-maps/yaml/LOLIN_S3_MINI.yml +32 -0
- data/vendor/board-maps/yaml/LOLIN_S3_PRO.yml +32 -0
- data/vendor/board-maps/yaml/Lion_Bit_Dev_Board.yml +18 -0
- data/vendor/board-maps/yaml/LoPy.yml +27 -0
- data/vendor/board-maps/yaml/LoPy4.yml +27 -0
- data/vendor/board-maps/yaml/M5STACK_CORES3.yml +8 -0
- data/vendor/board-maps/yaml/M5STACK_Core2.yml +9 -0
- data/vendor/board-maps/yaml/M5STACK_FIRE.yml +10 -0
- data/vendor/board-maps/yaml/M5Stack-Timer-CAM.yml +10 -0
- data/vendor/board-maps/yaml/M5Stack_ATOM.yml +10 -0
- data/vendor/board-maps/yaml/M5Stack_ATOMS3.yml +7 -0
- data/vendor/board-maps/yaml/M5Stack_CoreInk.yml +9 -0
- data/vendor/board-maps/yaml/M5Stack_Core_ESP32.yml +10 -0
- data/vendor/board-maps/yaml/M5Stack_Station.yml +10 -0
- data/vendor/board-maps/yaml/M5Stick_C.yml +10 -0
- data/vendor/board-maps/yaml/MAGTAG29_ESP32S2.yml +21 -0
- data/vendor/board-maps/yaml/MELOPERO_COOKIE_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/MELOPERO_SHAKE_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/METRO_ESP32S2.yml +34 -0
- data/vendor/board-maps/yaml/MGBOT_IOTIK32A.yml +27 -0
- data/vendor/board-maps/yaml/MGBOT_IOTIK32B.yml +27 -0
- data/vendor/board-maps/yaml/MH_ET_LIVE_ESP32DEVKIT.yml +27 -0
- data/vendor/board-maps/yaml/MH_ET_LIVE_ESP32MINIKIT.yml +27 -0
- data/vendor/board-maps/yaml/MICROS2.yml +34 -0
- data/vendor/board-maps/yaml/MOD_WIFI_ESP8266.yml +9 -0
- data/vendor/board-maps/yaml/Metro.yml +8 -0
- data/vendor/board-maps/yaml/NANO32.yml +27 -0
- data/vendor/board-maps/yaml/NANO_RP2040_CONNECT.yml +35 -0
- data/vendor/board-maps/yaml/NEBULAS3.yml +33 -0
- data/vendor/board-maps/yaml/NEKOSYSTEMS_BL2040_MINI.yml +48 -0
- data/vendor/board-maps/yaml/NULLBITS_BIT_C_PRO.yml +48 -0
- data/vendor/board-maps/yaml/Node32s.yml +27 -0
- data/vendor/board-maps/yaml/NodeMCU_32S.yml +27 -0
- data/vendor/board-maps/yaml/ODROID_ESP32.yml +10 -0
- data/vendor/board-maps/yaml/ONEHORSE_ESP32_DEV.yml +24 -0
- data/vendor/board-maps/yaml/OROCA_EDUBOT.yml +33 -0
- data/vendor/board-maps/yaml/PIMORONI_PGA2040.yml +48 -0
- data/vendor/board-maps/yaml/PROS3.yml +28 -0
- data/vendor/board-maps/yaml/PYCOM_GPY.yml +27 -0
- data/vendor/board-maps/yaml/Piranha.yml +16 -0
- data/vendor/board-maps/yaml/Pocket32.yml +27 -0
- data/vendor/board-maps/yaml/QUANTUM.yml +26 -0
- data/vendor/board-maps/yaml/RASPBERRY_PI_PICO.yml +48 -0
- data/vendor/board-maps/yaml/RASPBERRY_PI_PICO_W.yml +48 -0
- data/vendor/board-maps/yaml/REDPILL_ESP32S3.yml +32 -0
- data/vendor/board-maps/yaml/RMP.yml +33 -0
- data/vendor/board-maps/yaml/SAMD_CIRCUITPLAYGROUND_EXPRESS.yml +12 -0
- data/vendor/board-maps/yaml/SAMD_MKR1000.yml +20 -0
- data/vendor/board-maps/yaml/SAMD_MKRFox1200.yml +19 -0
- data/vendor/board-maps/yaml/SAMD_MKRGSM1400.yml +15 -0
- data/vendor/board-maps/yaml/SAMD_MKRNB1500.yml +15 -0
- data/vendor/board-maps/yaml/SAMD_MKRVIDOR4000.yml +19 -0
- data/vendor/board-maps/yaml/SAMD_MKRWAN1300.yml +18 -0
- data/vendor/board-maps/yaml/SAMD_MKRWAN1310.yml +18 -0
- data/vendor/board-maps/yaml/SAMD_MKRWIFI1010.yml +19 -0
- data/vendor/board-maps/yaml/SAMD_MKRZERO.yml +19 -0
- data/vendor/board-maps/yaml/SAMD_NANO_33_IOT.yml +13 -0
- data/vendor/board-maps/yaml/SAMD_TIAN.yml +15 -0
- data/vendor/board-maps/yaml/SAMD_ZERO.yml +14 -0
- data/vendor/board-maps/yaml/SAM_DUE.yml +26 -0
- data/vendor/board-maps/yaml/SAM_ZERO.yml +15 -0
- data/vendor/board-maps/yaml/SEEED_INDICATOR_RP2040.yml +47 -0
- data/vendor/board-maps/yaml/SEEED_XIAO_RP2040.yml +29 -0
- data/vendor/board-maps/yaml/SOLDERPARTY_RP2040_STAMP.yml +48 -0
- data/vendor/board-maps/yaml/SONOFF_DUALR3.yml +26 -0
- data/vendor/board-maps/yaml/SPARKFUN_PROMICRO_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/SPARKFUN_THINGPLUS_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/STAMP_S3.yml +4 -0
- data/vendor/board-maps/yaml/TAMC_TERMOD_S3.yml +31 -0
- data/vendor/board-maps/yaml/TBEAM_USE_RADIO_SX1262.yml +23 -0
- data/vendor/board-maps/yaml/TBEAM_USE_RADIO_SX1268.yml +23 -0
- data/vendor/board-maps/yaml/TBEAM_USE_RADIO_SX1276.yml +23 -0
- data/vendor/board-maps/yaml/TBEAM_USE_RADIO_SX1278.yml +23 -0
- data/vendor/board-maps/yaml/TBEAM_USE_RADIO_SX1280.yml +23 -0
- data/vendor/board-maps/yaml/TBeam.yml +23 -0
- data/vendor/board-maps/yaml/TINYPICO.yml +26 -0
- data/vendor/board-maps/yaml/TINYS2.yml +33 -0
- data/vendor/board-maps/yaml/TINYS3.yml +25 -0
- data/vendor/board-maps/yaml/TTGO-T-OI-PLUS_DEV.yml +11 -0
- data/vendor/board-maps/yaml/TTGO_LoRa32_V1.yml +28 -0
- data/vendor/board-maps/yaml/TTGO_LoRa32_V2.yml +28 -0
- data/vendor/board-maps/yaml/TTGO_LoRa32_v21new.yml +28 -0
- data/vendor/board-maps/yaml/TTGO_T1.yml +27 -0
- data/vendor/board-maps/yaml/TTGO_T7_V13_Mini32.yml +27 -0
- data/vendor/board-maps/yaml/TTGO_T7_V14_Mini32.yml +27 -0
- data/vendor/board-maps/yaml/TWATCH_2020_V1.yml +10 -0
- data/vendor/board-maps/yaml/TWATCH_2020_V2.yml +10 -0
- data/vendor/board-maps/yaml/TWATCH_2020_V3.yml +10 -0
- data/vendor/board-maps/yaml/TWATCH_BASE.yml +10 -0
- data/vendor/board-maps/yaml/TWatch.yml +10 -0
- data/vendor/board-maps/yaml/Trueverit_ESP32_Universal_IoT_Driver.yml +18 -0
- data/vendor/board-maps/yaml/Trueverit_ESP32_Universal_IoT_Driver_MK_II.yml +18 -0
- data/vendor/board-maps/yaml/UBLOX_NINA_W10.yml +48 -0
- data/vendor/board-maps/yaml/UBLOX_NORA_W10.yml +43 -0
- data/vendor/board-maps/yaml/UPESY_RP2040_DEVKIT.yml +48 -0
- data/vendor/board-maps/yaml/VALTRACK_V4_MFW_ESP32_C3.yml +23 -0
- data/vendor/board-maps/yaml/VALTRACK_V4_VTS_ESP32_C3.yml +23 -0
- data/vendor/board-maps/yaml/VIYALAB_MIZU_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/WATCHY.yml +7 -0
- data/vendor/board-maps/yaml/WATCHY_V10.yml +7 -0
- data/vendor/board-maps/yaml/WATCHY_V15.yml +7 -0
- data/vendor/board-maps/yaml/WATCHY_V20.yml +7 -0
- data/vendor/board-maps/yaml/WAVESHARE_RP2040_LCD_0_96.yml +47 -0
- data/vendor/board-maps/yaml/WAVESHARE_RP2040_LCD_1_28.yml +47 -0
- data/vendor/board-maps/yaml/WAVESHARE_RP2040_ONE.yml +47 -0
- data/vendor/board-maps/yaml/WAVESHARE_RP2040_PLUS.yml +48 -0
- data/vendor/board-maps/yaml/WAVESHARE_RP2040_ZERO.yml +47 -0
- data/vendor/board-maps/yaml/WESP32.yml +17 -0
- data/vendor/board-maps/yaml/WIDORA_AIR.yml +34 -0
- data/vendor/board-maps/yaml/WIFIDUINO_ESP8266.yml +23 -0
- data/vendor/board-maps/yaml/WIFINFO.yml +20 -0
- data/vendor/board-maps/yaml/WIPY3.yml +27 -0
- data/vendor/board-maps/yaml/WIZNET_5100S_EVB_PICO.yml +48 -0
- data/vendor/board-maps/yaml/WIZNET_5500_EVB_PICO.yml +48 -0
- data/vendor/board-maps/yaml/WIZNET_WIZFI360_EVB_PICO.yml +48 -0
- data/vendor/board-maps/yaml/WT32_ETH01.yml +8 -0
- data/vendor/board-maps/yaml/WiFiduino32S3.yml +27 -0
- data/vendor/board-maps/yaml/WiFiduinoV2.yml +27 -0
- data/vendor/board-maps/yaml/Wifiduino32.yml +40 -0
- data/vendor/board-maps/yaml/XIAO_ESP32C3.yml +22 -0
- data/vendor/board-maps/yaml/XIAO_ESP32S3.yml +36 -0
- data/vendor/board-maps/yaml/YD_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/atmegazero_esp32s2.yml +30 -0
- data/vendor/board-maps/yaml/connaxio_espoir.yml +18 -0
- data/vendor/board-maps/yaml/esp32vn_iot_uno.yml +22 -0
- data/vendor/board-maps/yaml/fm_devkit.yml +15 -0
- data/vendor/board-maps/yaml/heltec_wifi_32_lora_V3.yml +31 -0
- data/vendor/board-maps/yaml/heltec_wifi_kit_32.yml +28 -0
- data/vendor/board-maps/yaml/heltec_wifi_kit_32_V3.yml +32 -0
- data/vendor/board-maps/yaml/heltec_wifi_lora_32.yml +27 -0
- data/vendor/board-maps/yaml/heltec_wifi_lora_32_V2.yml +27 -0
- data/vendor/board-maps/yaml/heltec_wireless_stick.yml +27 -0
- data/vendor/board-maps/yaml/heltec_wireless_stick_LITE.yml +27 -0
- data/vendor/board-maps/yaml/openkb.yml +27 -0
- data/vendor/board-maps/yaml/roboheart_hercules.yml +17 -0
- data/vendor/board-maps/yaml/sensesiot_weizen.yml +26 -0
- data/vendor/board-maps/yaml/uPesy_WROOM.yml +27 -0
- data/vendor/board-maps/yaml/uPesy_WROVER.yml +27 -0
- data/vendor/board-maps/yaml/unphone8.yml +32 -0
- data/vendor/board-maps/yaml/unphone9.yml +32 -0
- data/vendor/board-maps/yaml/wifi_kit_8.yml +15 -0
- metadata +800 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
#
|
2
|
+
# This is an example of how to use the servo class
|
3
|
+
#
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'denko'
|
6
|
+
|
7
|
+
board = Denko::Board.new(Denko::Connection::Serial.new)
|
8
|
+
servo = Denko::Motor::Servo.new(pin: 9, board: board)
|
9
|
+
|
10
|
+
# Add different angles (in degrees) to the array below to try out your servo.
|
11
|
+
# Note: Some servos may not have a full 180 degree sweep.
|
12
|
+
|
13
|
+
[0, 90].cycle do |angle|
|
14
|
+
servo.position = angle
|
15
|
+
sleep 0.5
|
16
|
+
end
|
Binary file
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#
|
2
|
+
# Example driving a stepper motor with the EasyDriver board: https://www.sparkfun.com/products/10267?
|
3
|
+
#
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'denko'
|
6
|
+
|
7
|
+
board = Denko::Board.new(Denko::Connection::Serial.new)
|
8
|
+
stepper = Denko::Motor::Stepper.new board: board,
|
9
|
+
pins: { slp: 6, enable: 7, direction: 8, step: 10, ms1: 11, ms2: 12 }
|
10
|
+
|
11
|
+
# Default is 8 microsteps. Set to 2 so we can move faster.
|
12
|
+
stepper.microsteps = 2
|
13
|
+
|
14
|
+
# 400 steps is now 1 revolution for a 200 step motor.
|
15
|
+
400.times do
|
16
|
+
stepper.step_cc
|
17
|
+
sleep 0.002
|
18
|
+
end
|
19
|
+
|
20
|
+
# Sleep the driver chip and wait a while.
|
21
|
+
stepper.sleep
|
22
|
+
sleep 1
|
23
|
+
|
24
|
+
# Wake it up and set to full steps.
|
25
|
+
stepper.wake
|
26
|
+
stepper.microsteps = 1
|
27
|
+
|
28
|
+
#
|
29
|
+
# Now 200 steps the other way will move us back to the start.
|
30
|
+
# Note the longer sleep here since the steps are bigger.
|
31
|
+
# Adjust both sleep vales to suit your motor.
|
32
|
+
#
|
33
|
+
200.times do
|
34
|
+
stepper.step_cw
|
35
|
+
sleep 0.006
|
36
|
+
end
|
37
|
+
|
38
|
+
# Sleep the driver once we're done.
|
39
|
+
stepper.sleep
|
40
|
+
|
41
|
+
# We write to the board asynchronously.
|
42
|
+
# Make sure we send all step commands before exit.
|
43
|
+
board.finish_write
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#
|
2
|
+
# Example of playing a melody on a piezoelectric buzzer.
|
3
|
+
#
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'denko'
|
6
|
+
|
7
|
+
board = Denko::Board.new(Denko::Connection::Serial.new)
|
8
|
+
buzzer = Denko::PulseIO::Buzzer.new(board: board, pin: 9)
|
9
|
+
|
10
|
+
C4 = 262
|
11
|
+
D4 = 294
|
12
|
+
E4 = 330
|
13
|
+
|
14
|
+
notes = [
|
15
|
+
[E4, 1], [D4, 1], [C4, 1], [D4, 1], [E4, 1], [E4, 1], [E4, 2],
|
16
|
+
[D4, 1], [D4, 1], [D4, 2], [E4, 1], [E4, 1], [E4, 2],
|
17
|
+
[E4, 1], [D4, 1], [C4, 1], [D4, 1], [E4, 1], [E4, 1], [E4, 1], [E4, 1],
|
18
|
+
[D4, 1], [D4, 1], [E4, 1], [D4, 1], [C4, 4],
|
19
|
+
]
|
20
|
+
|
21
|
+
bpm = 240
|
22
|
+
beat_time = 60.to_f / bpm
|
23
|
+
|
24
|
+
notes.each do |note|
|
25
|
+
buzzer.tone(note[0])
|
26
|
+
sleep note[1] * beat_time
|
27
|
+
end
|
28
|
+
|
29
|
+
buzzer.stop
|
30
|
+
board.finish_write
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#
|
2
|
+
# This is a simple test of the IREmitter (infrared blaster) class.
|
3
|
+
# It is based on this example from the Arduino library:
|
4
|
+
# https://github.com/Arduino-IRremote/Arduino-IRremote/tree/master/examples/SendDemo
|
5
|
+
#
|
6
|
+
# To verify your emitter is working, you can flash this sketch on a second board:
|
7
|
+
# https://github.com/Arduino-IRremote/Arduino-IRremote/tree/master/examples/ReceiveDemo
|
8
|
+
#
|
9
|
+
# Attach an IR receiver to the receive pin (2 for Atmel AVR) and observe for serial output.
|
10
|
+
#
|
11
|
+
# If you don't have 2 boards, use the receive sketch to capture a code from a button
|
12
|
+
# of a remote you have. Copy the raw code (long list of numbers in curly braces),
|
13
|
+
# and modify it into a Ruby array.
|
14
|
+
#
|
15
|
+
# Reflash the denko sketch onto your board and test the IR code operates your device.
|
16
|
+
#
|
17
|
+
# Both of these methods require you to have an IR receiver handy.
|
18
|
+
# If you do not have one, there are IR codes in Raw format for many devices
|
19
|
+
# available on sites like http://irdb.tk/codes/
|
20
|
+
# When formatted as a string of numbers with + and - in front of each number,
|
21
|
+
# you will need to convert them to the array format before use.
|
22
|
+
#
|
23
|
+
require 'bundler/setup'
|
24
|
+
require 'denko'
|
25
|
+
|
26
|
+
# Note: If testing with 2 boards connected to the same computer, you want to be
|
27
|
+
# explicit about which serial device this script must use. The relevant
|
28
|
+
# Connection call is below, but commented out. Enable it and substitute the approriate
|
29
|
+
# device for the board that has the IR emitter connected and denko sketch loaded.
|
30
|
+
# Open the receiver board in the Arduino IDE's or another serial monitor.
|
31
|
+
#
|
32
|
+
connection = Denko::Connection::Serial.new
|
33
|
+
# connection = Denko::Connection::Serial.new(device: "/dev/ttyACM0")
|
34
|
+
board = Denko::Board.new(connection)
|
35
|
+
|
36
|
+
#
|
37
|
+
# The IR emitter can be set up on most pins for most boards, but there might be conflicts
|
38
|
+
# with other hardware or libraries. Try different pins if one doesn't work.
|
39
|
+
#
|
40
|
+
ir = Denko::PulseIO::IRTransmitter.new(board: board, pin: 3)
|
41
|
+
|
42
|
+
# NEC Raw-Data=0xF708FB04. LSBFIRST, so the binary for each hex digit below is backward.
|
43
|
+
code = [ 9000, 4500, # Start bit
|
44
|
+
560, 560, 560, 560, 560, 1690, 560, 560, # 0010 0x4 command
|
45
|
+
560, 560, 560, 560, 560, 560, 560, 560, # 0000 0x0 command
|
46
|
+
560, 1690, 560, 1690, 560,560, 560, 1690, # 1101 0xB command inverted
|
47
|
+
560, 1690, 560, 1690, 560, 1690, 560, 1690, # 1111 0xF command inverted
|
48
|
+
560, 560, 560, 560, 560, 560, 560, 1690, # 0001 0x8 address
|
49
|
+
560, 560, 560, 560, 560, 560, 560, 560, # 0000 0x0 address
|
50
|
+
560, 1690, 560, 1690, 560, 1690, 560, 560, # 1110 0x7 address inverted
|
51
|
+
560, 1690, 560, 1690, 560, 1690, 560, 1690, # 1111 0xF address inverted
|
52
|
+
560] # Stop bit
|
53
|
+
|
54
|
+
ir.emit(code)
|
55
|
+
board.finish_write
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#
|
2
|
+
# Example using a D3231 real-time-clock over I2C. Sets the time and reads it
|
3
|
+
# back every 5 seconds.
|
4
|
+
#
|
5
|
+
require 'bundler/setup'
|
6
|
+
require 'denko'
|
7
|
+
|
8
|
+
board = Denko::Board.new(Denko::Connection::Serial.new)
|
9
|
+
|
10
|
+
#
|
11
|
+
# Default pins for the I2C0 (first) interface on most chips:
|
12
|
+
#
|
13
|
+
# ATmega 328p: SDA = 'A4' SCL = 'A5' - Arduino Uno, Nano
|
14
|
+
# ATmega 32u4: SDA = 2 SCL = 3 - Arduino Leonardo, Pro Micro
|
15
|
+
# ATmega1280 / 2560: SDA = 20 SCL = 21 - Arduino Mega
|
16
|
+
# SAM3X8E: SDA = 20 SCL = 21 - Arduino Due
|
17
|
+
# SAMD21G18: SDA = 20 SCL = 21 - Arduino Zero, M0, M0 Pro
|
18
|
+
# ESP8266: SDA = 4 SCL = 5
|
19
|
+
# ESP32: SDA = 21 SCL = 22
|
20
|
+
# RP2040: SDA = 4 SCL = 5 - Raspberry Pi Pico (W)
|
21
|
+
#
|
22
|
+
# Only give the SDA pin of the I2C bus. SCL (clock) pin must be
|
23
|
+
# connected for it to work, but we don't need to control it.
|
24
|
+
#
|
25
|
+
bus = Denko::I2C::Bus.new(board: board, pin: 'A4')
|
26
|
+
|
27
|
+
# Tell the bus to search for devices.
|
28
|
+
bus.search
|
29
|
+
|
30
|
+
# Show the found devices.
|
31
|
+
puts "No I2C devices connected!" if bus.found_devices.empty?
|
32
|
+
bus.found_devices.each do |address|
|
33
|
+
puts "I2C device connected with address: 0x#{address.to_s(16)}"
|
34
|
+
end
|
35
|
+
|
36
|
+
# 0x68 or 140 is the I2C address for most real time clocks.
|
37
|
+
unless (bus.found_devices.include? 0x68)
|
38
|
+
puts "No real time clock found!" unless bus.found_devices.empty?
|
39
|
+
else
|
40
|
+
puts; puts "Using real time clock at address 0x68"; puts
|
41
|
+
rtc = Denko::RTC::DS3231.new(bus: bus, address: 0x68)
|
42
|
+
rtc.time = Time.now
|
43
|
+
|
44
|
+
5.times do
|
45
|
+
puts rtc.time
|
46
|
+
sleep 5
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#
|
2
|
+
# Example using AHT21 sensor over I2C, for temperature and humidity.
|
3
|
+
#
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'denko'
|
6
|
+
|
7
|
+
board = Denko::Board.new(Denko::Connection::Serial.new)
|
8
|
+
bus = Denko::I2C::Bus.new(board: board, pin: :SDA)
|
9
|
+
aht10 = Denko::Sensor::AHT10.new(bus: bus)
|
10
|
+
|
11
|
+
aht10.poll(2) do |reading|
|
12
|
+
puts "Polled Reading: #{reading[:temperature].round(3)} \xC2\xB0C | #{reading[:humidity].round(3)} % RH"
|
13
|
+
end
|
14
|
+
|
15
|
+
sleep
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#
|
2
|
+
# Example using AHT21 sensor over I2C, for temperature and humidity.
|
3
|
+
#
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'denko'
|
6
|
+
|
7
|
+
board = Denko::Board.new(Denko::Connection::Serial.new)
|
8
|
+
bus = Denko::I2C::Bus.new(board: board, pin: :SDA0)
|
9
|
+
aht20 = Denko::Sensor::AHT20.new(bus: bus)
|
10
|
+
|
11
|
+
aht20.poll(2) do |reading|
|
12
|
+
puts "Polled Reading: #{reading[:temperature].round(3)} \xC2\xB0C | #{reading[:humidity].round(3)} % RH"
|
13
|
+
end
|
14
|
+
|
15
|
+
sleep
|
@@ -0,0 +1,75 @@
|
|
1
|
+
#
|
2
|
+
# Example using a BME280 sensor over I2C, for temperature, pressure and humidity.
|
3
|
+
#
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'denko'
|
6
|
+
|
7
|
+
board = Denko::Board.new(Denko::Connection::Serial.new)
|
8
|
+
|
9
|
+
#
|
10
|
+
# Default pins for the I2C0 (first) interface on most chips:
|
11
|
+
#
|
12
|
+
# ATmega 328p: SDA = 'A4' SCL = 'A5' - Arduino Uno, Nano
|
13
|
+
# ATmega 32u4: SDA = 2 SCL = 3 - Arduino Leonardo, Pro Micro
|
14
|
+
# ATmega1280 / 2560: SDA = 20 SCL = 21 - Arduino Mega
|
15
|
+
# SAM3X8E: SDA = 20 SCL = 21 - Arduino Due
|
16
|
+
# SAMD21G18: SDA = 20 SCL = 21 - Arduino Zero, M0, M0 Pro
|
17
|
+
# ESP8266: SDA = 4 SCL = 5
|
18
|
+
# ESP32: SDA = 21 SCL = 22
|
19
|
+
# RP2040: SDA = 4 SCL = 5 - Raspberry Pi Pico (W)
|
20
|
+
#
|
21
|
+
# Only give the SDA pin of the I2C bus. SCL (clock) pin must be
|
22
|
+
# connected for it to work, but we don't need to control it.
|
23
|
+
#
|
24
|
+
bus = Denko::I2C::Bus.new(board: board, pin: :SDA)
|
25
|
+
|
26
|
+
sensor = Denko::Sensor::BME280.new(bus: bus, address: 0x76)
|
27
|
+
|
28
|
+
# Use A BMP280 with no humidity instead.
|
29
|
+
# sensor = Denko::Sensor::BMP280.new(bus: bus, address: 0x76)
|
30
|
+
|
31
|
+
# Default reading mode is oneshot ("forced" in datasheet).
|
32
|
+
# sensor.oneshot_mode
|
33
|
+
|
34
|
+
# Enable oversampling independently on each sensor.
|
35
|
+
# sensor.temperature_samples = 8
|
36
|
+
# sensor.pressure_samples = 2
|
37
|
+
# sensor.humidity_samples = 4
|
38
|
+
|
39
|
+
# Enable continuous reading mode ("normal" in datasheet), with standby time and IIR filter.
|
40
|
+
# sensor.continuous_mode
|
41
|
+
# sensor.standby_time = 62.5
|
42
|
+
# sensor.iir_coefficient = 4
|
43
|
+
|
44
|
+
# Print raw config register bits.
|
45
|
+
# print sensor.config_register_bits
|
46
|
+
|
47
|
+
def display_reading(reading)
|
48
|
+
# Time
|
49
|
+
print "#{Time.now.strftime '%Y-%m-%d %H:%M:%S'} - "
|
50
|
+
|
51
|
+
# Temperature
|
52
|
+
formatted_temp = reading[:temperature].round(2).to_s.ljust(5, '0')
|
53
|
+
print "Temperature: #{formatted_temp} \xC2\xB0C"
|
54
|
+
|
55
|
+
# Pressure
|
56
|
+
if reading[:pressure]
|
57
|
+
formatted_pressure = (reading[:pressure] / 101325).round(5).to_s.ljust(7, '0')
|
58
|
+
print " | Pressure #{formatted_pressure} atm"
|
59
|
+
end
|
60
|
+
|
61
|
+
# Humidity
|
62
|
+
if reading[:humidity]
|
63
|
+
formatted_humidity = reading[:humidity].round(2).to_s.ljust(5, '0')
|
64
|
+
print " | Humidity #{formatted_humidity} %"
|
65
|
+
end
|
66
|
+
|
67
|
+
puts
|
68
|
+
end
|
69
|
+
|
70
|
+
# Poll the sensor and print readings.
|
71
|
+
sensor.poll(5) do |reading|
|
72
|
+
display_reading(reading)
|
73
|
+
end
|
74
|
+
|
75
|
+
sleep
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#
|
2
|
+
# Example of how to use the DHT class for DHT 11 and DHT 22 sensors.
|
3
|
+
#
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'denko'
|
6
|
+
|
7
|
+
board = Denko::Board.new(Denko::Connection::Serial.new)
|
8
|
+
dht = Denko::Sensor::DHT.new(pin: 5, board: board)
|
9
|
+
|
10
|
+
# The DHT class pre-processes raw data from the board. When it reaches callbacks
|
11
|
+
# it's already hash of :temperature and :humidity keys, both with Float values.
|
12
|
+
dht.add_callback do |reading|
|
13
|
+
print "#{Time.now.strftime '%Y-%m-%d %H:%M:%S'} | "
|
14
|
+
if reading[:error]
|
15
|
+
puts "Error: #{reading[:error]}"
|
16
|
+
else
|
17
|
+
print "#{reading[:celsius]} \xC2\xB0C | #{reading[:fahrenheit]} \xC2\xB0F | "
|
18
|
+
puts "#{reading[:humidity]}% relative humidity"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Read it every 5 seconds.
|
23
|
+
dht.poll(5)
|
24
|
+
sleep
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#
|
2
|
+
# Example of how to use the Dallas DS18B20 temperature sensor.
|
3
|
+
#
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'denko'
|
6
|
+
|
7
|
+
board = Denko::Board.new(Denko::Connection::Serial.new)
|
8
|
+
bus = Denko::OneWire::Bus.new(pin:4, board: board)
|
9
|
+
|
10
|
+
# The bus detects parasite power automatically when initialized.
|
11
|
+
# It can tell that parasite power is in use, but not by WHICH devices.
|
12
|
+
if bus.parasite_power
|
13
|
+
puts "Parasite power detected..."; puts
|
14
|
+
end
|
15
|
+
|
16
|
+
# Call #device_present to reset the bus and return presence pulse as a boolean.
|
17
|
+
if bus.device_present?
|
18
|
+
puts "Devices present on bus..."; puts
|
19
|
+
else
|
20
|
+
puts "No devices present on bus... Quitting..."
|
21
|
+
return
|
22
|
+
end
|
23
|
+
|
24
|
+
# Calling #search finds connected devices and stores them in #found_devices.
|
25
|
+
# Each hash contains a device's ROM address and matching Ruby class if one exists.
|
26
|
+
bus.search
|
27
|
+
count = bus.found_devices.count
|
28
|
+
puts "Found #{count} device#{'s' if count > 1} on the bus:"
|
29
|
+
puts bus.found_devices.inspect; puts
|
30
|
+
|
31
|
+
# We can use the search results to setup instances of the device classes.
|
32
|
+
ds18b20s = []
|
33
|
+
bus.found_devices.each do |d|
|
34
|
+
if d[:class] == Denko::Sensor::DS18B20
|
35
|
+
ds18b20s << d[:class].new(bus: bus, address: d[:address])
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Format a reading for printing on a line.
|
40
|
+
def print_reading(reading, sensor)
|
41
|
+
print "#{Time.now.strftime '%Y-%m-%d %H:%M:%S'} - "
|
42
|
+
print "Serial(HEX): #{sensor.serial_number} | Res: #{sensor.resolution} bits | "
|
43
|
+
|
44
|
+
if reading[:crc_error]
|
45
|
+
puts "CRC check failed for this reading!"
|
46
|
+
else
|
47
|
+
print "#{reading[:celsius]} \xC2\xB0C | #{reading[:fahrenheit]} \xC2\xB0F | "
|
48
|
+
puts "Raw: #{reading[:raw].inspect}"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
ds18b20s.each do |sensor|
|
53
|
+
sensor.poll(5) do |reading|
|
54
|
+
print_reading(reading, sensor)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
sleep
|
@@ -0,0 +1,54 @@
|
|
1
|
+
#
|
2
|
+
# Example using HTU21D sensor over I2C, for temperature and humidity.
|
3
|
+
#
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'denko'
|
6
|
+
|
7
|
+
board = Denko::Board.new(Denko::Connection::Serial.new)
|
8
|
+
bus = Denko::I2C::Bus.new(board: board, pin: :SDA)
|
9
|
+
htu21d = Denko::Sensor::HTU21D.new(bus: bus)
|
10
|
+
|
11
|
+
# Get and set heater state.
|
12
|
+
htu21d.heater_on
|
13
|
+
puts "Heater on: #{htu21d.heater_on?}"
|
14
|
+
htu21d.heater_off
|
15
|
+
puts "Heater off: #{htu21d.heater_off?}"
|
16
|
+
puts
|
17
|
+
|
18
|
+
# Back to default settings, except heater state.
|
19
|
+
htu21d.reset
|
20
|
+
|
21
|
+
# Only 4 resolution combinations are available, and need to be
|
22
|
+
# set by giving a bitmask from the datasheet:
|
23
|
+
# 0x00 = 14-bit temperature, 12-bit humidity
|
24
|
+
# 0x01 = 12-bit temperature, 8-bit humidity (default)
|
25
|
+
# 0x80 = 13-bit temperature, 10-bit humidity
|
26
|
+
# 0x81 = 11-bit temperature, 11-bit humidity
|
27
|
+
#
|
28
|
+
htu21d.resolution = 0x81
|
29
|
+
puts "Temperature resolution: #{htu21d.resolution[:temperature]} bits"
|
30
|
+
puts "Humidity resolution: #{htu21d.resolution[:humidity]} bits"
|
31
|
+
puts
|
32
|
+
|
33
|
+
# Take direct readings by calling methods on the HTU21D instance.
|
34
|
+
# Note: These methods do not take block callbacks like other components.
|
35
|
+
# The HTU21D class doesn't directly implement polling methods either.
|
36
|
+
#
|
37
|
+
puts "Direct Temperature: #{htu21d.read_temperature.round(3)} \xC2\xB0C"
|
38
|
+
puts "Direct Humidity: #{htu21d.read_humidity.round(3)} %"
|
39
|
+
puts
|
40
|
+
|
41
|
+
# The last read state can be accessed through sub-objects or [].
|
42
|
+
puts "Last Temperature: #{htu21d.temperature.fahrenheit.round(3)} \xC2\xB0F"
|
43
|
+
puts "Last Humidity: #{htu21d[:humidity].round(3)} %"
|
44
|
+
puts
|
45
|
+
|
46
|
+
# Poll temperature and humidity at different rates by calling methods on the sub-objects.
|
47
|
+
htu21d.temperature.poll(2) do |value|
|
48
|
+
puts "Sub-Object Temperature: #{value.round(3)} \xC2\xB0C"
|
49
|
+
end
|
50
|
+
htu21d.humidity.poll(4) do |value|
|
51
|
+
puts "Sub-Object Humidity: #{value.round(3)} %"
|
52
|
+
end
|
53
|
+
|
54
|
+
sleep
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#
|
2
|
+
# Example using HTU31D sensor over I2C, for temperature and humidity.
|
3
|
+
#
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'denko'
|
6
|
+
|
7
|
+
board = Denko::Board.new(Denko::Connection::Serial.new)
|
8
|
+
bus = Denko::I2C::Bus.new(board: board, pin: :SDA)
|
9
|
+
htu31d = Denko::Sensor::HTU31D.new(bus: bus)
|
10
|
+
|
11
|
+
# Get and set heater state.
|
12
|
+
htu31d.heater_on
|
13
|
+
puts "Heater on: #{htu31d.heater_on?}"
|
14
|
+
htu31d.heater_off
|
15
|
+
puts "Heater off: #{htu31d.heater_off?}"
|
16
|
+
|
17
|
+
# Back to default settings, including heater off, unlike HTU21D.
|
18
|
+
htu31d.reset
|
19
|
+
puts "Resetting HTU31D... Heater off: #{htu31d.heater_off?}"
|
20
|
+
puts
|
21
|
+
|
22
|
+
# Resolution goes from 0..3 separately for temperature and humidity. See datasheet.
|
23
|
+
htu31d.temperature_resolution = 3
|
24
|
+
htu31d.humidity_resolution = 3
|
25
|
+
|
26
|
+
# Unlike HTU21D, HTU31D works as a regular polled sensor.
|
27
|
+
htu31d.poll(2) do |reading|
|
28
|
+
puts "Polled Reading: #{reading[:temperature].round(3)} \xC2\xB0C | #{reading[:humidity].round(3)} % RH"
|
29
|
+
end
|
30
|
+
|
31
|
+
sleep
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#
|
2
|
+
# Example of a Button connected through an input shift register (CD4021B).
|
3
|
+
# Can be used over either a bit bang or hardware SPI interface.
|
4
|
+
#
|
5
|
+
require 'bundler/setup'
|
6
|
+
require 'denko'
|
7
|
+
|
8
|
+
# SPI pins (on board)
|
9
|
+
SPI_BIT_BANG_PINS = { clock: 13, input: 12 }
|
10
|
+
REGISTER_SELECT_PIN = 9
|
11
|
+
|
12
|
+
# Button pin (on register parallel outputs)
|
13
|
+
BUTTON_PIN = 0
|
14
|
+
|
15
|
+
board = Denko::Board.new(Denko::Connection::Serial.new)
|
16
|
+
|
17
|
+
# 1-way (input) bit bang SPI interface on any pins (slower, but flexible).
|
18
|
+
bus = Denko::SPI::BitBang.new(board: board, pins: SPI_BIT_BANG_PINS)
|
19
|
+
|
20
|
+
# Use the default hardware SPI bus (faster, but predetermined pins).
|
21
|
+
# bus = Denko::SPI::Bus.new(board: board)
|
22
|
+
|
23
|
+
# Show the hardware SPI pins to aid connection.
|
24
|
+
# MOSI = output | MISO = input | SCK = clock
|
25
|
+
# puts board.map.select { |name, number| [:MOSI, :MISO, :SCK].include?(name) }
|
26
|
+
|
27
|
+
# InputRegister needs a bus and its select pin. The CD4021 likes SPI mode 2.
|
28
|
+
# Other options and their defaults:
|
29
|
+
# bytes: 1 - For daisy-chaining registers
|
30
|
+
# spi_frequency: 1000000 - Only affects hardware SPI interfaces
|
31
|
+
# spi_mode: 0
|
32
|
+
# spi_bit_order: :msbfirst
|
33
|
+
#
|
34
|
+
register = Denko::SPI::InputRegister.new(bus: bus, pin: REGISTER_SELECT_PIN, spi_mode: 2)
|
35
|
+
|
36
|
+
# InputRegister implements enough of the Board interface that digital input
|
37
|
+
# components can treat it as a Board. Do that with the Button.
|
38
|
+
#
|
39
|
+
# button starts listening automatically, which triggers register to start listening,
|
40
|
+
# so it can update button as needed. Registers listen with an 8ms interval by default,
|
41
|
+
# compared to the 4ms default for a Button directly connected to a Board.
|
42
|
+
#
|
43
|
+
button = Denko::DigitalIO::Button.new(pin: 0, board: register)
|
44
|
+
|
45
|
+
# Button callbacks.
|
46
|
+
button.down { puts "Button pressed" }
|
47
|
+
button.up { puts "Button released" }
|
48
|
+
|
49
|
+
# Sleep the main thread. Press the button and callbacks will run.
|
50
|
+
sleep
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#
|
2
|
+
# Example of LED connected through an output shift register (74HC595).
|
3
|
+
# Can be used over either a bit bang or hardware SPI interface.
|
4
|
+
#
|
5
|
+
require 'bundler/setup'
|
6
|
+
require 'denko'
|
7
|
+
|
8
|
+
# SPI pins (on board)
|
9
|
+
SPI_BIT_BANG_PINS = { clock: 13, output: 11 }
|
10
|
+
REGISTER_SELECT_PIN = 10
|
11
|
+
|
12
|
+
# LED pin (on register parallel outputs)
|
13
|
+
LED_PIN = 0
|
14
|
+
|
15
|
+
board = Denko::Board.new(Denko::Connection::Serial.new)
|
16
|
+
|
17
|
+
# 1-way (output) bit bang SPI interface on any pins (slower, but flexible).
|
18
|
+
bus = Denko::SPI::BitBang.new(board: board, pins: SPI_BIT_BANG_PINS)
|
19
|
+
|
20
|
+
# Use the default hardware SPI bus (faster, but predetermined pins).
|
21
|
+
# bus = Denko::SPI::Bus.new(board: board)
|
22
|
+
|
23
|
+
# Show the hardware SPI pins to aid connection.
|
24
|
+
# MOSI = output | MISO = input | SCK = clock
|
25
|
+
# puts board.map.select { |name, number| [:MOSI, :MISO, :SCK].include?(name) }
|
26
|
+
|
27
|
+
# OutputRegister needs a bus and its select pin.
|
28
|
+
# Other options and their defaults:
|
29
|
+
# bytes: 1 - For daisy-chaining registers
|
30
|
+
# spi_frequency: 1000000 - Only affects hardware SPI interfaces
|
31
|
+
# spi_mode: 0
|
32
|
+
# spi_bit_order: :msbfirst
|
33
|
+
# write_delay: 0.001 - How long to buffer writes, in seconds
|
34
|
+
# buffer_writes: true - Wait for write_delay before writing whole register state.
|
35
|
+
# Makes proxied components write pseudo-parallelly.
|
36
|
+
#
|
37
|
+
register = Denko::SPI::OutputRegister.new(bus: bus, pin: REGISTER_SELECT_PIN)
|
38
|
+
|
39
|
+
# We can turn the LED on by writing a 1 to the lowest bit (0) of the register.
|
40
|
+
register.write(0b00000001)
|
41
|
+
|
42
|
+
# OutputRegister implements enough of the Board interface that digital output
|
43
|
+
# components can treat it as a Board. Do that with the LED instead.
|
44
|
+
#
|
45
|
+
led = Denko::LED.new(board: register, pin: 0)
|
46
|
+
|
47
|
+
# Blink the LED and sleep the main thread.
|
48
|
+
led.blink 0.5
|
49
|
+
sleep
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#
|
2
|
+
# Example of SevenSegment LED driven though an output shift register (74HC595).
|
3
|
+
# Can be used on either a bit bang or hardware SPI interface.
|
4
|
+
#
|
5
|
+
require 'bundler/setup'
|
6
|
+
require 'denko'
|
7
|
+
|
8
|
+
# SPI pins (on board)
|
9
|
+
SPI_BIT_BANG_PINS = { clock: 13, output: 11 }
|
10
|
+
REGISTER_SELECT_PIN = 10
|
11
|
+
|
12
|
+
# SevenSegment pins (on register parallel outputs)
|
13
|
+
SEVEN_SEGMENT_PINS = { cathode: 0, a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7 }
|
14
|
+
|
15
|
+
board = Denko::Board.new(Denko::Connection::Serial.new)
|
16
|
+
|
17
|
+
# 1-way bit bang SPI bus (slower, but use any pins).
|
18
|
+
bus = Denko::SPI::BitBang.new(board: board, pins: SPI_BIT_BANG_PINS)
|
19
|
+
|
20
|
+
# Use the default hardware SPI bus (faster, but predetermined pins).
|
21
|
+
# bus = Denko::SPI::Bus.new(board: board)
|
22
|
+
|
23
|
+
# Show the hardware SPI pins to aid connection.
|
24
|
+
# MOSI = output | MISO = input | SCK = clock
|
25
|
+
# puts board.map.select { |name, number| [:MOSI, :MISO, :SCK].include?(name) }
|
26
|
+
|
27
|
+
# OutputRegister needs a bus and its select pin.
|
28
|
+
register = Denko::SPI::OutputRegister.new(bus: bus, pin: REGISTER_SELECT_PIN)
|
29
|
+
|
30
|
+
#
|
31
|
+
# OutputRegister implements enough of the Board interface that digital output
|
32
|
+
# components can treat it as a Board. Do that with the SSD.
|
33
|
+
#
|
34
|
+
ssd = Denko::LED::SevenSegment.new(board: register, pins: SEVEN_SEGMENT_PINS)
|
35
|
+
|
36
|
+
# Turn off the ssd on exit.
|
37
|
+
trap("SIGINT") { exit !ssd.off }
|
38
|
+
|
39
|
+
# Type a character and press Enter to show it on the SevenSegment LED.
|
40
|
+
loop { ssd.display(gets.chomp) }
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#
|
2
|
+
# Example of 2 SPI devices on the same bus with different select pins.
|
3
|
+
# Combination of input_register.rb and output_register.rb
|
4
|
+
#
|
5
|
+
require 'bundler/setup'
|
6
|
+
require 'denko'
|
7
|
+
|
8
|
+
# SPI pins (on board)
|
9
|
+
SPI_BIT_BANG_PINS = { clock: 13, input: 12, output: 11 }
|
10
|
+
OUT_REGISTER_SELECT = 10
|
11
|
+
IN_REGISTER_SELECT = 9
|
12
|
+
|
13
|
+
# LED and Button pins (on their respective registers' parallel pins)
|
14
|
+
LED_PIN = 0
|
15
|
+
BUTTON_PIN = 0
|
16
|
+
|
17
|
+
board = Denko::Board.new(Denko::Connection::Serial.new)
|
18
|
+
|
19
|
+
# 2-way bit bang SPI bus (slower, but use any pins).
|
20
|
+
bus = Denko::SPI::BitBang.new(board: board, pins: SPI_BIT_BANG_PINS)
|
21
|
+
|
22
|
+
# Use the default hardware SPI bus (faster, but predetermined pins).
|
23
|
+
# bus = Denko::SPI::Bus.new(board: board)
|
24
|
+
|
25
|
+
# Show the hardware SPI pins to aid connection.
|
26
|
+
# MOSI = output | MISO = input | SCK = clock
|
27
|
+
# puts board.map.select { |name, number| [:MOSI, :MISO, :SCK].include?(name) }
|
28
|
+
|
29
|
+
# OutputRegister needs a bus and its select pin.
|
30
|
+
out_register = Denko::SPI::OutputRegister.new(bus: bus, pin: OUT_REGISTER_SELECT)
|
31
|
+
|
32
|
+
# InputRegister needs a bus and its select pin. The CD4021 likes SPI mode 2.
|
33
|
+
in_register = Denko::SPI::InputRegister.new(bus: bus, pin: IN_REGISTER_SELECT, spi_mode: 2)
|
34
|
+
|
35
|
+
# LED connected to the output register.
|
36
|
+
led = Denko::LED.new(board: out_register, pin: LED_PIN)
|
37
|
+
|
38
|
+
# Button connected to the input register.
|
39
|
+
button = Denko::DigitalIO::Button.new(board: in_register, pin: BUTTON_PIN)
|
40
|
+
|
41
|
+
# Button callbacks.
|
42
|
+
button.down { led.on; puts "Button pressed" }
|
43
|
+
button.up { led.off; puts "Button released" }
|
44
|
+
|
45
|
+
# Sleep the main thread. Press the button and callbacks will run.
|
46
|
+
sleep
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#
|
2
|
+
# Example that writes to hardware UART1 and reads back on bit bang UART. Tested on Arduino Mega.
|
3
|
+
#
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'denko'
|
6
|
+
|
7
|
+
board = Denko::Board.new(Denko::Connection::Serial.new)
|
8
|
+
|
9
|
+
hw_uart = Denko::UART::Hardware.new(board: board, index: 1, baud: 31250)
|
10
|
+
bb_uart = Denko::UART::BitBang.new(board: board, pins: { rx:10, tx:11 }, baud: 31250)
|
11
|
+
|
12
|
+
hw_uart.write("Hello World!\n")
|
13
|
+
|
14
|
+
sleep 1
|
15
|
+
|
16
|
+
puts bb_uart.gets
|