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,72 @@
|
|
1
|
+
module Denko
|
2
|
+
module Behaviors
|
3
|
+
module MultiPin
|
4
|
+
#
|
5
|
+
# Model complex components, using multiple pins, by using proxy components
|
6
|
+
# with one pin each.
|
7
|
+
#
|
8
|
+
include Component
|
9
|
+
attr_reader :pin, :pins, :proxies
|
10
|
+
|
11
|
+
# Return a hash with the state of each proxy component.
|
12
|
+
def proxy_states
|
13
|
+
hash = {}
|
14
|
+
proxies.each_key do |key|
|
15
|
+
hash[key] = proxies[key].state if self.proxies[key]
|
16
|
+
end
|
17
|
+
hash
|
18
|
+
end
|
19
|
+
|
20
|
+
def before_initialize(options={})
|
21
|
+
# Get given pins early. Avoids giving them again to require or proxy.
|
22
|
+
self.pins = options[:pins]
|
23
|
+
self.proxies = {}
|
24
|
+
super(options)
|
25
|
+
end
|
26
|
+
|
27
|
+
def convert_pins(options={})
|
28
|
+
super(options)
|
29
|
+
self.pins.each { |key,pin| self.pins[key] = board.convert_pin(pin) }
|
30
|
+
pin_array = pins.values
|
31
|
+
raise ArgumentError, "duplicate pins in: #{pins.inspect}" unless pin_array == pin_array.uniq
|
32
|
+
end
|
33
|
+
|
34
|
+
#
|
35
|
+
# Proxy a pin to a single-pin component. Set this up in the including
|
36
|
+
# component's #initialize_pins method. Additional options for each proxy
|
37
|
+
# (eg. pullup/pulldown) can be injected there.
|
38
|
+
#
|
39
|
+
def proxy_pin(name, klass, pin_options={})
|
40
|
+
# Proxied pins are required by default.
|
41
|
+
require_pin(name) unless pin_options[:optional]
|
42
|
+
|
43
|
+
# Make the proxy, passing through options, and store it.
|
44
|
+
if self.pins[name]
|
45
|
+
proxy = klass.new pin_options.merge(board: self.board, pin: self.pins[name])
|
46
|
+
self.proxies[name] = proxy
|
47
|
+
instance_variable_set("@#{name}", proxy)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Accessor for the proxy's instance var, or nil, if not given.
|
51
|
+
singleton_class.class_eval { attr_reader name }
|
52
|
+
end
|
53
|
+
|
54
|
+
#
|
55
|
+
# Require a single pin that may or may not be proxied. This is useful for
|
56
|
+
# components using libraries running on the board, where we need to specify
|
57
|
+
# the pin, but not do anything with it.
|
58
|
+
#
|
59
|
+
def require_pin(name)
|
60
|
+
raise ArgumentError, "missing #{name.inspect} pin" unless self.pins[name]
|
61
|
+
end
|
62
|
+
|
63
|
+
def require_pins(*array)
|
64
|
+
[array].flatten.each { |name| require_pin(name) }
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
attr_writer :pins, :proxies
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Denko
|
2
|
+
module Behaviors
|
3
|
+
module Poller
|
4
|
+
include Reader
|
5
|
+
include Threaded
|
6
|
+
|
7
|
+
def poll_using(method, interval, *args, &block)
|
8
|
+
unless [Integer, Float].include? interval.class
|
9
|
+
raise ArgumentError, "wrong interval given to #poll : #{interval.inspect}"
|
10
|
+
end
|
11
|
+
|
12
|
+
stop
|
13
|
+
add_callback(:poll, &block) if block_given?
|
14
|
+
|
15
|
+
threaded_loop do
|
16
|
+
method.call(*args)
|
17
|
+
sleep interval
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def poll(interval, *args, &block)
|
22
|
+
poll_using(self.method(:_read), interval, *args, &block)
|
23
|
+
end
|
24
|
+
|
25
|
+
def stop
|
26
|
+
super if defined?(super)
|
27
|
+
remove_callbacks :poll
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Denko
|
2
|
+
module Behaviors
|
3
|
+
module Reader
|
4
|
+
include Callbacks
|
5
|
+
|
6
|
+
#
|
7
|
+
# Defalt behavior for #read is to delegate to #_read.
|
8
|
+
# Define #_read in including classes.
|
9
|
+
#
|
10
|
+
def read(*args, **kwargs, &block)
|
11
|
+
read_using(self.method(:_read), *args, **kwargs, &block)
|
12
|
+
end
|
13
|
+
|
14
|
+
#
|
15
|
+
# Delegate reading to another method that sends a command to the board.
|
16
|
+
# Accepts blocks as one-time callbacks stored in the :read key.
|
17
|
+
# Blocks until a value is recieved from the board.
|
18
|
+
# Returns the value after #pre_callback_filter runs on it.
|
19
|
+
#
|
20
|
+
# Give procs as methods to build more complex functionality for buses.
|
21
|
+
#
|
22
|
+
def read_using(method, *args, **kwargs, &block)
|
23
|
+
add_callback(:read, &block) if block_given?
|
24
|
+
|
25
|
+
value = nil
|
26
|
+
add_callback(:read) do |filtered_data|
|
27
|
+
value = filtered_data
|
28
|
+
end
|
29
|
+
|
30
|
+
method.call(*args, **kwargs)
|
31
|
+
block_until_read
|
32
|
+
|
33
|
+
value
|
34
|
+
end
|
35
|
+
|
36
|
+
def block_until_read
|
37
|
+
loop do
|
38
|
+
break if !callbacks[:read]
|
39
|
+
sleep 0.001
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def _read
|
44
|
+
raise NotImplementedError
|
45
|
+
.new("#{self.class.name}#_read is not defined.")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Denko
|
2
|
+
module Behaviors
|
3
|
+
module SinglePin
|
4
|
+
include Component
|
5
|
+
attr_reader :pin, :mode
|
6
|
+
|
7
|
+
def mode=(mode)
|
8
|
+
board.set_pin_mode(pin, mode)
|
9
|
+
@mode = mode
|
10
|
+
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
attr_writer :pin
|
15
|
+
|
16
|
+
def convert_pins(options={})
|
17
|
+
raise ArgumentError, 'a pin is required for this component' unless options[:pin]
|
18
|
+
options[:pin] = board.convert_pin(options[:pin])
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize_pins(options={})
|
22
|
+
self.pin = options[:pin]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Denko
|
2
|
+
module Behaviors
|
3
|
+
module State
|
4
|
+
def initialize(options={})
|
5
|
+
@state_mutex = Mutex.new
|
6
|
+
@state = nil
|
7
|
+
end
|
8
|
+
|
9
|
+
def state
|
10
|
+
@state_mutex.synchronize { @state }
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
def state=(value)
|
16
|
+
@state_mutex.synchronize { @state = value }
|
17
|
+
end
|
18
|
+
|
19
|
+
def update_state(value)
|
20
|
+
self.state = value if value
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Denko
|
2
|
+
module Behaviors
|
3
|
+
module Subcomponents
|
4
|
+
def components
|
5
|
+
@components ||= []
|
6
|
+
end
|
7
|
+
|
8
|
+
def single_pin_components
|
9
|
+
@single_pin_components ||= {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def add_component(component)
|
13
|
+
components << component
|
14
|
+
|
15
|
+
if component.respond_to?(:pin) && component.pin.class == Integer
|
16
|
+
unless single_pin_components[component.pin]
|
17
|
+
single_pin_components[component.pin] = component
|
18
|
+
else
|
19
|
+
raise StandardError, "Error adding #{component} to #{self}. Pin: #{component.pin} " \
|
20
|
+
"already in use by: #{single_pin_components[component.pin]}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def remove_component(component)
|
26
|
+
if component.respond_to?(:pin) && component.pin.class == Integer
|
27
|
+
single_pin_components[component.pin] = nil
|
28
|
+
end
|
29
|
+
|
30
|
+
deleted = components.delete(component)
|
31
|
+
component.stop if deleted && component.respond_to?(:stop)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Denko
|
2
|
+
module Behaviors
|
3
|
+
module Threaded
|
4
|
+
attr_reader :thread, :interrupts_enabled
|
5
|
+
|
6
|
+
module ClassMethods
|
7
|
+
def interrupt_with(*args)
|
8
|
+
interrupts = self.class_eval('@@interrupts') rescue []
|
9
|
+
interrupts = (interrupts + args).uniq
|
10
|
+
self.class_variable_set(:@@interrupts, interrupts)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.included(base)
|
15
|
+
base.extend ClassMethods
|
16
|
+
end
|
17
|
+
|
18
|
+
def threaded(&block)
|
19
|
+
stop_thread
|
20
|
+
enable_interrupts unless interrupts_enabled
|
21
|
+
@thread = Thread.new(&block)
|
22
|
+
end
|
23
|
+
|
24
|
+
def threaded_loop(&block)
|
25
|
+
threaded do
|
26
|
+
loop(&block)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def stop_thread
|
31
|
+
@thread.kill if @thread
|
32
|
+
end
|
33
|
+
|
34
|
+
def stop
|
35
|
+
stop_thread
|
36
|
+
super if defined?(super)
|
37
|
+
end
|
38
|
+
|
39
|
+
def enable_interrupts
|
40
|
+
interrupts = self.class.class_eval('@@interrupts') rescue []
|
41
|
+
interrupts.each do |method_name|
|
42
|
+
standard_method = self.method(method_name)
|
43
|
+
|
44
|
+
singleton_class.send(:define_method, method_name) do |*args|
|
45
|
+
stop_thread unless (Thread.current == @thread)
|
46
|
+
standard_method.call(*args)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
@interrupts_enabled = true
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Denko
|
2
|
+
module Behaviors
|
3
|
+
# Pin and component setup stuff
|
4
|
+
autoload :State, "#{__dir__}/behaviors/state"
|
5
|
+
autoload :Component, "#{__dir__}/behaviors/component"
|
6
|
+
autoload :SinglePin, "#{__dir__}/behaviors/single_pin"
|
7
|
+
autoload :InputPin, "#{__dir__}/behaviors/input_pin"
|
8
|
+
autoload :OutputPin, "#{__dir__}/behaviors/output_pin"
|
9
|
+
autoload :MultiPin, "#{__dir__}/behaviors/multi_pin"
|
10
|
+
|
11
|
+
# Subcomponent stuff
|
12
|
+
autoload :Subcomponents, "#{__dir__}/behaviors/subcomponents"
|
13
|
+
autoload :BusController, "#{__dir__}/behaviors/bus_controller"
|
14
|
+
autoload :BusControllerAddressed, "#{__dir__}/behaviors/bus_controller_addressed"
|
15
|
+
autoload :BusPeripheral, "#{__dir__}/behaviors/bus_peripheral"
|
16
|
+
autoload :BusPeripheralAddressed, "#{__dir__}/behaviors/bus_peripheral_addressed"
|
17
|
+
autoload :BoardProxy, "#{__dir__}/behaviors/board_proxy"
|
18
|
+
|
19
|
+
# Async stuff
|
20
|
+
autoload :Threaded, "#{__dir__}/behaviors/threaded"
|
21
|
+
autoload :Callbacks, "#{__dir__}/behaviors/callbacks"
|
22
|
+
autoload :Reader, "#{__dir__}/behaviors/reader"
|
23
|
+
autoload :Poller, "#{__dir__}/behaviors/poller"
|
24
|
+
autoload :Listener, "#{__dir__}/behaviors/listener"
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,151 @@
|
|
1
|
+
module Denko
|
2
|
+
class Board
|
3
|
+
DIVIDERS = [1, 2, 4, 8, 16, 32, 64, 128]
|
4
|
+
|
5
|
+
PIN_MODES = {
|
6
|
+
output: 0b000,
|
7
|
+
output_pwm: 0b010,
|
8
|
+
output_dac: 0b100,
|
9
|
+
input: 0b001,
|
10
|
+
input_pulldown: 0b011,
|
11
|
+
input_pullup: 0b101,
|
12
|
+
input_output: 0b111
|
13
|
+
}
|
14
|
+
|
15
|
+
# CMD = 0
|
16
|
+
def set_pin_mode(pin, mode=:input)
|
17
|
+
unless PIN_MODES.keys.include? mode
|
18
|
+
raise ArgumentError, "cannot set mode: #{mode}. Should be one of: #{PIN_MODES.keys.inspect}"
|
19
|
+
end
|
20
|
+
write Message.encode command: 0,
|
21
|
+
pin: pin,
|
22
|
+
value: PIN_MODES[mode]
|
23
|
+
end
|
24
|
+
|
25
|
+
# CMD = 1
|
26
|
+
def digital_write(pin,value)
|
27
|
+
unless (value == 1) || (value == 0)
|
28
|
+
raise ArgumentError, "cannot write digital value: #{value}. Should be Integer either 0 or 1"
|
29
|
+
end
|
30
|
+
write Message.encode command: 1, pin: pin, value: value
|
31
|
+
end
|
32
|
+
|
33
|
+
# CMD = 2
|
34
|
+
def digital_read(pin)
|
35
|
+
write Message.encode command: 2, pin: pin
|
36
|
+
end
|
37
|
+
|
38
|
+
# CMD = 3
|
39
|
+
def pwm_write(pin,value)
|
40
|
+
if (value < 0) || (value > pwm_high)
|
41
|
+
raise ArgumentError, "cannot write PWM value: #{value}. Should be Integer in range 0..#{pwm_high} "
|
42
|
+
end
|
43
|
+
write Message.encode command: 3, pin: pin, value: value.round
|
44
|
+
end
|
45
|
+
|
46
|
+
# CMD = 4
|
47
|
+
def dac_write(pin,value)
|
48
|
+
if (value < 0) || (value > dac_high)
|
49
|
+
raise ArgumentError, "cannot write DAC value: #{value}. Should be Integer in range 0..#{dac_high} "
|
50
|
+
end
|
51
|
+
write Message.encode command: 4, pin: pin, value: value.round
|
52
|
+
end
|
53
|
+
|
54
|
+
# CMD = 5
|
55
|
+
def analog_read(pin, negative_pin=nil, gain=nil, sample_rate=nil)
|
56
|
+
write Message.encode command: 5, pin: pin
|
57
|
+
end
|
58
|
+
|
59
|
+
# CMD = 6
|
60
|
+
def set_listener(pin, state=:off, **options)
|
61
|
+
# Default to digital listener and validate.
|
62
|
+
options[:mode] ||= :digital
|
63
|
+
unless (options[:mode] == :digital) || (options[:mode] == :analog)
|
64
|
+
raise ArgumentError, "error in mode: #{options[:mode]}. Should be one of: [:digital, :analog]"
|
65
|
+
end
|
66
|
+
mode_byte = (options[:mode] == :digital) ? 0 : 1
|
67
|
+
|
68
|
+
# Default to 4ms divider if digital, 16ms if analog.
|
69
|
+
if options[:mode] == :digital
|
70
|
+
options[:divider] ||= 4
|
71
|
+
else
|
72
|
+
options[:divider] ||= 16
|
73
|
+
end
|
74
|
+
|
75
|
+
# Convert divider to exponent and validate.
|
76
|
+
exponent = Math.log2(options[:divider]).round
|
77
|
+
if (exponent < 0) || (exponent > 7)
|
78
|
+
raise ArgumentError, "error in divider: #{options[:divider]}. Should be one of: #{DIVIDERS.inspect}"
|
79
|
+
end
|
80
|
+
|
81
|
+
# Validate state.
|
82
|
+
unless (state == :on) || (state == :off)
|
83
|
+
raise ArgumentError, "error in state: #{options[:state]}. Should be one of: [:on, :off]"
|
84
|
+
end
|
85
|
+
state_byte = (state == :on) ? 1 : 0
|
86
|
+
|
87
|
+
# Send it.
|
88
|
+
write Message.encode command: 6,
|
89
|
+
pin: pin,
|
90
|
+
value: state_byte,
|
91
|
+
aux_message: pack(:uint8, [mode_byte, exponent])
|
92
|
+
end
|
93
|
+
|
94
|
+
# Convenience methods that wrap set_listener.
|
95
|
+
def digital_listen(pin, divider=4)
|
96
|
+
set_listener(pin, :on, mode: :digital, divider: divider)
|
97
|
+
end
|
98
|
+
|
99
|
+
def analog_listen(pin, divider=16)
|
100
|
+
set_listener(pin, :on, mode: :analog, divider: divider)
|
101
|
+
end
|
102
|
+
|
103
|
+
def stop_listener(pin)
|
104
|
+
set_listener(pin, :off)
|
105
|
+
end
|
106
|
+
|
107
|
+
# CMD = 92
|
108
|
+
#
|
109
|
+
# For diagnostics and testing mostly. What this does:
|
110
|
+
# 1) Tell the Connection to halt transmission immediately, after this message.
|
111
|
+
# 2) The board will send back a ready signal, which the Connection should read and resume transmisison.
|
112
|
+
#
|
113
|
+
# See comments on Board#write_and_halt for more info and use case.
|
114
|
+
#
|
115
|
+
def halt_resume_check
|
116
|
+
write_and_halt Message.encode command: 92
|
117
|
+
end
|
118
|
+
|
119
|
+
# CMD = 95
|
120
|
+
def set_register_divider(value)
|
121
|
+
unless DIVIDERS.include?(value)
|
122
|
+
raise ArgumentError, "error in divider: #{options[:divider]}. Should be one of: #{DIVIDERS.inspect}"
|
123
|
+
end
|
124
|
+
write Message.encode(command: 95, value: value)
|
125
|
+
end
|
126
|
+
|
127
|
+
# CMD = 96
|
128
|
+
def set_analog_write_resolution(value)
|
129
|
+
if (value < 0) || (value > 16)
|
130
|
+
raise ArgumentError, "cannot set resolution: #{value}. Should be Integer in range 0..16"
|
131
|
+
end
|
132
|
+
write Message.encode(command: 96, value: value)
|
133
|
+
end
|
134
|
+
|
135
|
+
# CMD = 97
|
136
|
+
def set_analog_read_resolution(value)
|
137
|
+
if (value < 0) || (value > 16)
|
138
|
+
raise ArgumentError, "cannot set resolution: #{value}. Should be Integer in range 0..16"
|
139
|
+
end
|
140
|
+
write Message.encode(command: 97, value: value)
|
141
|
+
end
|
142
|
+
|
143
|
+
# CMD = 99
|
144
|
+
def micro_delay(duration)
|
145
|
+
if (duration < 0) || (duration > 0xFFFF)
|
146
|
+
raise ArgumentError, "error in duration: #{duration}. Should be Integer in range 0..65535"
|
147
|
+
end
|
148
|
+
write Message.encode command: 99, aux_message: pack(:uint16, [duration])
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Denko
|
2
|
+
class Board
|
3
|
+
# CMD = 7
|
4
|
+
def eeprom_read(address, num_bytes)
|
5
|
+
address = pack :uint16, address
|
6
|
+
write Message.encode command: 7,
|
7
|
+
value: num_bytes,
|
8
|
+
aux_message: address
|
9
|
+
end
|
10
|
+
|
11
|
+
# CMD = 8
|
12
|
+
def eeprom_write(address, bytes)
|
13
|
+
address = pack :uint16, address
|
14
|
+
bytes = pack :uint8, bytes, min: 1, max: 128
|
15
|
+
write Message.encode command: 8,
|
16
|
+
value: bytes.length,
|
17
|
+
aux_message: address + bytes
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Denko
|
2
|
+
class Board
|
3
|
+
I2C_FREQUENCIES = {
|
4
|
+
100000 => 0x00,
|
5
|
+
400000 => 0x01,
|
6
|
+
1000000 => 0x02,
|
7
|
+
3400000 => 0x03,
|
8
|
+
}
|
9
|
+
|
10
|
+
# Might make this bigger based on board maps later, but stick with the lowest limit of the AVR boards for now.
|
11
|
+
def i2c_limit
|
12
|
+
32
|
13
|
+
end
|
14
|
+
|
15
|
+
def i2c_convert_frequency(freq)
|
16
|
+
# Default to 100 kHz.
|
17
|
+
freq = 100000 unless freq
|
18
|
+
|
19
|
+
unless I2C_FREQUENCIES.include?(freq)
|
20
|
+
raise ArgumentError, "I2C frequency must be in: #{I2C_FREQUENCIES.keys.inspect}"
|
21
|
+
end
|
22
|
+
I2C_FREQUENCIES[freq]
|
23
|
+
end
|
24
|
+
|
25
|
+
# CMD = 33
|
26
|
+
def i2c_search
|
27
|
+
write Message.encode command: 33
|
28
|
+
end
|
29
|
+
|
30
|
+
# CMD = 34
|
31
|
+
def i2c_write(address, bytes, frequency=100000, repeated_start=false)
|
32
|
+
bytes = [bytes] unless bytes.class == Array
|
33
|
+
raise ArgumentError, "I2C write must be 1..#{i2c_limit} bytes long" if (bytes.length > i2c_limit || bytes.length < 1)
|
34
|
+
|
35
|
+
# Use top bit of address to select stop condition (1), or repated start (0).
|
36
|
+
send_stop = repeated_start ? 0 : 1
|
37
|
+
frequency = i2c_convert_frequency(frequency)
|
38
|
+
|
39
|
+
write Message.encode command: 34,
|
40
|
+
pin: address | (send_stop << 7),
|
41
|
+
value: bytes.length,
|
42
|
+
aux_message: pack(:uint8, frequency) + pack(:uint8, bytes)
|
43
|
+
end
|
44
|
+
|
45
|
+
# CMD = 35
|
46
|
+
def i2c_read(address, register, read_length, frequency=100000, repeated_start=false)
|
47
|
+
raise ArgumentError, "I2C read must be 1..#{i2c_limit} bytes long" if (read_length > i2c_limit || read_length < 1)
|
48
|
+
|
49
|
+
# Use top bit of address to select stop condition (1), or repated start (0).
|
50
|
+
send_stop = repeated_start ? 0 : 1
|
51
|
+
frequency = i2c_convert_frequency(frequency)
|
52
|
+
|
53
|
+
# A register address starting register address can be given (up to 4 bytes)
|
54
|
+
if register
|
55
|
+
register = [register].flatten
|
56
|
+
raise ArgumentError, 'maximum 4 byte register address for I2C read' if register.length > 4
|
57
|
+
register_packed = pack(:uint8, [register.length] + register)
|
58
|
+
else
|
59
|
+
register_packed = pack(:uint8, [0])
|
60
|
+
end
|
61
|
+
|
62
|
+
write Message.encode command: 35,
|
63
|
+
pin: address | (send_stop << 7),
|
64
|
+
value: read_length,
|
65
|
+
aux_message: pack(:uint8, frequency) + register_packed
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Denko
|
2
|
+
class Board
|
3
|
+
def infrared_emit(pin, frequency, pulses)
|
4
|
+
#
|
5
|
+
# Limit to 255 marks/spaces (not pairs) for now.
|
6
|
+
#
|
7
|
+
# Length must be 1-byte long, not literally 1
|
8
|
+
# Pulses max is 2x255 bytes long since each is 2 bytes.
|
9
|
+
length = pack :uint8, pulses.length, max: 1
|
10
|
+
bytes = pack :uint16, pulses, min: 1, max: 510
|
11
|
+
|
12
|
+
write Message.encode command: 16,
|
13
|
+
pin: pin,
|
14
|
+
value: frequency,
|
15
|
+
aux_message: length + bytes
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Denko
|
2
|
+
class Board
|
3
|
+
def show_ws2812(pin, pixel_buffer)
|
4
|
+
length = pixel_buffer.length
|
5
|
+
|
6
|
+
# Settings are blank for now.
|
7
|
+
settings = pack :uint8, [0, 0, 0, 0]
|
8
|
+
|
9
|
+
# Limit to 100 pixels (3-bytes each) for now
|
10
|
+
packed_pixels = pack :uint8, pixel_buffer, max: 300
|
11
|
+
|
12
|
+
write_and_halt Message.encode command: 19,
|
13
|
+
pin: pin,
|
14
|
+
value: length,
|
15
|
+
aux_message: settings + packed_pixels
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Denko
|
4
|
+
class Board
|
5
|
+
MAPS_FOLDER = File.join(Denko.root, "vendor/board-maps/yaml")
|
6
|
+
|
7
|
+
attr_reader :map
|
8
|
+
|
9
|
+
def load_map(board_name)
|
10
|
+
if board_name
|
11
|
+
map_path = File.join(MAPS_FOLDER, "#{board_name}.yml")
|
12
|
+
@map = YAML.load_file(map_path)
|
13
|
+
else
|
14
|
+
@map = nil
|
15
|
+
end
|
16
|
+
rescue
|
17
|
+
raise StandardError, "error loading board map from file for board name: '#{board_name}'"
|
18
|
+
end
|
19
|
+
|
20
|
+
def convert_pin(pin)
|
21
|
+
# Convert non numerical strings to symbols.
|
22
|
+
pin = pin.to_sym if (pin.class == String) && !(pin.match (/\A\d+\.*\d*/))
|
23
|
+
|
24
|
+
# Handle symbols.
|
25
|
+
if (pin.class == Symbol)
|
26
|
+
if map && map[pin]
|
27
|
+
return map[pin]
|
28
|
+
elsif map
|
29
|
+
raise ArgumentError, "error in pin: #{pin.inspect}. Make sure that pin is defined for this board by calling Board#map"
|
30
|
+
else
|
31
|
+
raise ArgumentError, "error in pin: #{pin.inspect}. Given a Symbol, but board has no map. Try using GPIO integer instead"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Handle integers.
|
36
|
+
return pin if pin.class == Integer
|
37
|
+
|
38
|
+
# Try #to_i on anyting else. Will catch numerical strings.
|
39
|
+
begin
|
40
|
+
return pin.to_i
|
41
|
+
rescue
|
42
|
+
raise ArgumentError, "error in pin: #{pin.inspect}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|