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,322 @@
|
|
1
|
+
#include "Denko.h"
|
2
|
+
|
3
|
+
// CMD = 00
|
4
|
+
// Set up a single pin for the desired type of input or output.
|
5
|
+
void Denko::setMode(byte p, byte m) {
|
6
|
+
//
|
7
|
+
// Use the lowest 3 bits of m to set different input/output modes, and enable
|
8
|
+
// or disable needed peripherals on different platforms.
|
9
|
+
//
|
10
|
+
// OUTPUT MODES:
|
11
|
+
// 000 = Digital Output
|
12
|
+
// 010 = PWM Ouptut
|
13
|
+
// 100 = DAC Output
|
14
|
+
//
|
15
|
+
// INPUT MODES
|
16
|
+
// 001 = Digital Input
|
17
|
+
// 011 = Digital Input with internal pulldown if available.
|
18
|
+
// 101 = Digital Input with internal pullup if available.
|
19
|
+
// 111 = Digital Input/Output (ESP32 Only?)
|
20
|
+
m = m & 0b00000111;
|
21
|
+
|
22
|
+
#if defined(ESP32) && defined(SOC_DAC_SUPPORTED)
|
23
|
+
// Free the LEDC channel if leaving PWM mode.
|
24
|
+
if (m != 0b010) releaseLEDC(p);
|
25
|
+
|
26
|
+
// Disable attached DAC if leaving DAC mode.
|
27
|
+
if (m != 0b100) dacDisable(p);
|
28
|
+
#endif
|
29
|
+
|
30
|
+
// On the SAMD21, mode needs to be INPUT when using the DAC.
|
31
|
+
#ifdef __SAMD21G18A__
|
32
|
+
if (m == 0b100){
|
33
|
+
pinMode(p, INPUT);
|
34
|
+
return;
|
35
|
+
}
|
36
|
+
#endif
|
37
|
+
|
38
|
+
// Handle the named INPUT_* states on boards implementing them.
|
39
|
+
#ifdef INPUT_PULLDOWN
|
40
|
+
if (m == 0b011) {
|
41
|
+
pinMode(p, INPUT_PULLDOWN);
|
42
|
+
return;
|
43
|
+
}
|
44
|
+
#endif
|
45
|
+
|
46
|
+
#ifdef INPUT_OUTPUT
|
47
|
+
if (m == 0b111) {
|
48
|
+
pinMode(p, INPUT_OUTPUT);
|
49
|
+
return;
|
50
|
+
}
|
51
|
+
#endif
|
52
|
+
|
53
|
+
#ifdef INPUT_PULLUP
|
54
|
+
if (m == 0b101) {
|
55
|
+
pinMode(p, INPUT_PULLUP);
|
56
|
+
return;
|
57
|
+
}
|
58
|
+
#endif
|
59
|
+
|
60
|
+
// Handle the standard INPUT and OUTPUT states.
|
61
|
+
// Allows INPUT_* to fallback to INPUT when not implemented.
|
62
|
+
if (bitRead(m, 0) == 0) {
|
63
|
+
pinMode(p, OUTPUT);
|
64
|
+
} else {
|
65
|
+
pinMode(p, INPUT);
|
66
|
+
}
|
67
|
+
|
68
|
+
// Write high to set pullup for AVRs that use this method.
|
69
|
+
#ifdef __AVR__
|
70
|
+
if (m == 0b101) digitalWrite(p, HIGH);
|
71
|
+
#endif
|
72
|
+
}
|
73
|
+
|
74
|
+
// CMD = 01
|
75
|
+
// Write a digital output pin. 0 for LOW, 1 or >0 for HIGH.
|
76
|
+
void Denko::dWrite(byte p, byte v, boolean echo) {
|
77
|
+
|
78
|
+
#ifdef __SAMD21G18A__
|
79
|
+
// digitalWrite doesn't implicitly disconnect PWM on the SAMD21.
|
80
|
+
pinMode(p, OUTPUT);
|
81
|
+
#endif
|
82
|
+
|
83
|
+
#ifdef ESP32
|
84
|
+
// Disconnect any DAC or LEDC peripheral the pin was using.
|
85
|
+
// Without this, setting GPIO level has no effect.
|
86
|
+
// NOTE: Does not release the LEDC channel or config. Can reattach in aWrite.
|
87
|
+
#if defined(SOC_DAC_SUPPORTED)
|
88
|
+
dacDisable(p);
|
89
|
+
#endif
|
90
|
+
ledcDetachPin(p);
|
91
|
+
#endif
|
92
|
+
|
93
|
+
if (v == 0) {
|
94
|
+
digitalWrite(p, LOW);
|
95
|
+
}
|
96
|
+
else {
|
97
|
+
digitalWrite(p, HIGH);
|
98
|
+
}
|
99
|
+
if (echo) coreResponse(p, v);
|
100
|
+
}
|
101
|
+
|
102
|
+
// CMD = 02
|
103
|
+
// Read a digital input pin. 0 for LOW, 1 for HIGH.
|
104
|
+
byte Denko::dRead(byte p) {
|
105
|
+
byte rval = digitalRead(p);
|
106
|
+
coreResponse(p, rval);
|
107
|
+
return rval;
|
108
|
+
}
|
109
|
+
|
110
|
+
// CMD = 03
|
111
|
+
// Write an analog output pin. 0 for LOW, up to 255 for HIGH @ 8-bit resolution.
|
112
|
+
void Denko::pwmWrite(byte p, int v, boolean echo) {
|
113
|
+
#ifdef ESP32
|
114
|
+
// Assign new or find existing LEDC channel for this pin.
|
115
|
+
byte channel = ledcChannel(p);
|
116
|
+
|
117
|
+
// Reattach the pin in case dWrite detached it.
|
118
|
+
ledcAttachPin(p, channel);
|
119
|
+
|
120
|
+
ledcWrite(channel, v);
|
121
|
+
#else
|
122
|
+
analogWrite(p,v);
|
123
|
+
#endif
|
124
|
+
|
125
|
+
if (echo) coreResponse(p, v);
|
126
|
+
}
|
127
|
+
|
128
|
+
//
|
129
|
+
// Manage ESP32 LEDC channels so we can do PWM write.
|
130
|
+
//
|
131
|
+
#ifdef ESP32
|
132
|
+
byte Denko::ledcChannel(byte p) {
|
133
|
+
// Search for enabled LEDC channel with given pin and use that if found.
|
134
|
+
for (int i = LEDC_CHANNEL_COUNT -1; i > 0; i--){
|
135
|
+
if ((ledcPins[i][0] == 1) && (ledcPins[i][1] == p)){
|
136
|
+
return i;
|
137
|
+
}
|
138
|
+
}
|
139
|
+
|
140
|
+
// We didn't find a channel to reuse.
|
141
|
+
for (int i = LEDC_CHANNEL_COUNT -1; i > 0; i--){
|
142
|
+
// If the channel isn't initialized and it isn't marked as used, use it.
|
143
|
+
// should find some way to check if the channel itslef is being used
|
144
|
+
if ((ledcPins[i][0] == 0)) {
|
145
|
+
assignLEDC(i, p);
|
146
|
+
return i;
|
147
|
+
}
|
148
|
+
}
|
149
|
+
|
150
|
+
// Return a useless channel if none available.
|
151
|
+
return 255;
|
152
|
+
};
|
153
|
+
|
154
|
+
// Assign a LEDC channel to a pin and save it.
|
155
|
+
byte Denko::assignLEDC(byte channel, byte p){
|
156
|
+
// First 8 channels: up to 40Mhz @ 16-bits
|
157
|
+
// Last 8 channels: up to 500kHz @ 13-bits
|
158
|
+
// Just use similar settings to ATmega for now.
|
159
|
+
ledcSetup(channel, 1000, 8);
|
160
|
+
ledcAttachPin(p, channel);
|
161
|
+
|
162
|
+
// Save the pin and mark it as in use.
|
163
|
+
ledcPins[channel][0] = 1;
|
164
|
+
ledcPins[channel][1] = p;
|
165
|
+
return channel;
|
166
|
+
}
|
167
|
+
|
168
|
+
// Release a LEDC channel when done with it.
|
169
|
+
void Denko::releaseLEDC(byte p){
|
170
|
+
// Detach the pin from the channel.
|
171
|
+
ledcDetachPin(p);
|
172
|
+
|
173
|
+
// Mark any channel associated with the pin as unused.
|
174
|
+
for (int i = LEDC_CHANNEL_COUNT -1; i > 0; i--){
|
175
|
+
if (ledcPins[i][1] == p) ledcPins[i][0] = 0;
|
176
|
+
}
|
177
|
+
}
|
178
|
+
|
179
|
+
// Clear all the LEDC channels on reset.
|
180
|
+
void Denko::clearLedcChannels(){
|
181
|
+
for (int i = LEDC_CHANNEL_COUNT -1; i > 0; i--){
|
182
|
+
// Stop the channel if it was still enabled.
|
183
|
+
if (ledcPins[i][0] != 0) ledcDetachPin(ledcPins[i][1]);
|
184
|
+
|
185
|
+
// Mark the channel as unused.
|
186
|
+
ledcPins[i][0] = 0;
|
187
|
+
}
|
188
|
+
}
|
189
|
+
#endif
|
190
|
+
|
191
|
+
// CMD = 04
|
192
|
+
// Write to a DAC (digital to analog converter) pin.
|
193
|
+
// This outputs a true analog resolution, unlike PWM.
|
194
|
+
void Denko::dacWrite(byte p, int v, boolean echo) {
|
195
|
+
#if defined(ESP32) && defined(SOC_DAC_SUPPORTED)
|
196
|
+
::dacWrite(p, v);
|
197
|
+
#endif
|
198
|
+
|
199
|
+
#if defined(__SAM3X8E__) || defined(__SAMD21G18A__)
|
200
|
+
analogWrite(p, v);
|
201
|
+
#endif
|
202
|
+
}
|
203
|
+
|
204
|
+
// CMD = 05
|
205
|
+
// Read an analog input pin. 0 for LOW, up to 1023 for HIGH @ 10-bit resolution.
|
206
|
+
int Denko::aRead(byte p) {
|
207
|
+
int rval = analogRead(p);
|
208
|
+
coreResponse(p, rval);
|
209
|
+
return rval;
|
210
|
+
}
|
211
|
+
|
212
|
+
// Simple response for core listeners, or any response with the pin:value pattern.
|
213
|
+
void Denko::coreResponse(int p, int v){
|
214
|
+
stream->print(p);
|
215
|
+
stream->print(':');
|
216
|
+
stream->print(v);
|
217
|
+
stream->print('\n');
|
218
|
+
}
|
219
|
+
|
220
|
+
// CMD = 06
|
221
|
+
// Enable, disable and change settings for core (digital/analog) listeners.
|
222
|
+
// See Denko.h for settings and mask layout.
|
223
|
+
void Denko::setListener(byte p, boolean enabled, byte analog, byte exponent, boolean local){
|
224
|
+
// Pre-format the settings into a mask byte.
|
225
|
+
byte settingMask = 0;
|
226
|
+
if (enabled) settingMask = settingMask | 0b10000000;
|
227
|
+
if (analog) settingMask = settingMask | 0b1000000;
|
228
|
+
if (local) settingMask = settingMask | 0b0010000;
|
229
|
+
settingMask = settingMask | exponent;
|
230
|
+
|
231
|
+
// If an existing listener was already using this pin, just update settings.
|
232
|
+
boolean found = false;
|
233
|
+
for(byte i=0; i<PIN_COUNT; i++){
|
234
|
+
if (listeners[i][1] == p){
|
235
|
+
found = true;
|
236
|
+
if (bitRead(listeners[i][0], 4) == 0) {
|
237
|
+
listeners[i][0] = settingMask;
|
238
|
+
} else if(local) {
|
239
|
+
// Only allow local code to update local listeners.
|
240
|
+
listeners[i][0] = settingMask;
|
241
|
+
}
|
242
|
+
break;
|
243
|
+
}
|
244
|
+
}
|
245
|
+
|
246
|
+
// If this pin wasn't used before, take the lowest index inactive listener.
|
247
|
+
if (!found){
|
248
|
+
for(byte i=0; i<PIN_COUNT; i++){
|
249
|
+
if (bitRead(listeners[i][0], 7) == 0){
|
250
|
+
listeners[i][0] = settingMask;
|
251
|
+
listeners[i][1] = p;
|
252
|
+
break;
|
253
|
+
}
|
254
|
+
}
|
255
|
+
}
|
256
|
+
|
257
|
+
// Keep track of how far into the listener array to go when updating.
|
258
|
+
findLastActiveListener();
|
259
|
+
}
|
260
|
+
|
261
|
+
// Runs once on every loop to update necessary listeners.
|
262
|
+
void Denko::updateCoreListeners() {
|
263
|
+
for (byte i = 0; i <= lastActiveListener; i++){
|
264
|
+
// Check if active.
|
265
|
+
if (bitRead(listeners[i][0], 7) == 1){
|
266
|
+
// Check if to update it on this tick.
|
267
|
+
// Divider exponent is last 3 bits of settings.
|
268
|
+
byte exponent = listeners[i][0] & 0B00000111;
|
269
|
+
byte divider = dividerMap[exponent];
|
270
|
+
if(tickCount % divider == 0){
|
271
|
+
// Check if digital or analog.
|
272
|
+
if (bitRead(listeners[i][0], 6) == 1){
|
273
|
+
analogListenerUpdate(i);
|
274
|
+
} else {
|
275
|
+
digitalListenerUpdate(i);
|
276
|
+
}
|
277
|
+
}
|
278
|
+
}
|
279
|
+
}
|
280
|
+
}
|
281
|
+
|
282
|
+
// Handle a single analog listener when it needs to read.
|
283
|
+
void Denko::analogListenerUpdate(byte i){
|
284
|
+
int rval = analogRead(listeners[i][1]);
|
285
|
+
analogListenCallback(listeners[i][1], rval);
|
286
|
+
coreResponse(listeners[i][1], rval);
|
287
|
+
}
|
288
|
+
|
289
|
+
// Handle a single digital listener when it needs to read.
|
290
|
+
void Denko::digitalListenerUpdate(byte i){
|
291
|
+
byte rval = digitalRead(listeners[i][1]);
|
292
|
+
|
293
|
+
if (rval != bitRead(listeners[i][0], 5)){
|
294
|
+
// State for digital listeners is stored in byte 5 of the listener itself.
|
295
|
+
bitWrite(listeners[i][0], 5, rval);
|
296
|
+
digitalListenCallback(listeners[i][1], rval);
|
297
|
+
coreResponse(listeners[i][1], rval);
|
298
|
+
}
|
299
|
+
}
|
300
|
+
|
301
|
+
// Gets called by Denko::reset to clear all listeners set by the remote client.
|
302
|
+
void Denko::clearCoreListeners(){
|
303
|
+
for (int i = 0; i < PIN_COUNT; i++){
|
304
|
+
// Only clear listeners if they were started by the remote client.
|
305
|
+
// Leaves listeners started by local code running.
|
306
|
+
if (bitRead(listeners[i][0], 4) == 0) {
|
307
|
+
listeners[i][0] = 0;
|
308
|
+
listeners[i][1] = 0;
|
309
|
+
}
|
310
|
+
}
|
311
|
+
findLastActiveListener();
|
312
|
+
}
|
313
|
+
|
314
|
+
// Track the last active listener whenever changes are made.
|
315
|
+
// Call this after setting or clearing any listeners.
|
316
|
+
void Denko::findLastActiveListener(){
|
317
|
+
for(byte i=0; i<PIN_COUNT; i++){
|
318
|
+
if (bitRead(listeners[i][0], 7) == 1){
|
319
|
+
lastActiveListener = i;
|
320
|
+
}
|
321
|
+
}
|
322
|
+
}
|
@@ -0,0 +1,116 @@
|
|
1
|
+
// If using Wi-Fi or Ethernet shield, uncomment this to let the SPI library know.
|
2
|
+
// #define TXRX_SPI
|
3
|
+
|
4
|
+
// Uncomment this line to enable debugging mode.
|
5
|
+
// #define debug
|
6
|
+
|
7
|
+
// Define the version of Denko the board was flashed with so we can verify in Ruby.
|
8
|
+
#define DENKO_VERSION __VERSION__
|
9
|
+
|
10
|
+
// Uncomment these to include features beyond core features.
|
11
|
+
// #define DENKO_ONE_WIRE
|
12
|
+
// #define DENKO_TONE
|
13
|
+
// #define DENKO_SPI_BB
|
14
|
+
// #define DENKO_I2C
|
15
|
+
// #define DENKO_SPI
|
16
|
+
// #define DENKO_SERVO
|
17
|
+
// #define DENKO_UART
|
18
|
+
// #define DENKO_UART_BB
|
19
|
+
// #define DENKO_IR_OUT
|
20
|
+
// #define DENKO_LED_ARRAY
|
21
|
+
|
22
|
+
// Include libraries for specific LED array protocols.
|
23
|
+
#ifdef DENKO_LED_ARRAY
|
24
|
+
#define DENKO_LED_WS2812
|
25
|
+
#endif
|
26
|
+
|
27
|
+
// Define number of pins to set up listener storage.
|
28
|
+
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
29
|
+
#define PIN_COUNT 70
|
30
|
+
#elif defined(__SAM3X8E__)
|
31
|
+
#define PIN_COUNT 72
|
32
|
+
#elif defined(ESP8266)
|
33
|
+
#define PIN_COUNT 18
|
34
|
+
#elif defined(ESP32)
|
35
|
+
#define PIN_COUNT 40
|
36
|
+
#elif defined(ARDUINO_ARCH_RP2040)
|
37
|
+
#define PIN_COUNT 26
|
38
|
+
#else
|
39
|
+
#define PIN_COUNT 22
|
40
|
+
#endif
|
41
|
+
|
42
|
+
// No EEPROM on the Due or Zero.
|
43
|
+
#if !defined(__SAM3X8E__) && !defined(__SAMD21G18A__)
|
44
|
+
#define EEPROM_PRESENT
|
45
|
+
#include <EEPROM.h>
|
46
|
+
#endif
|
47
|
+
|
48
|
+
// Emulate 512 bytes of EEPROM on ESP chips and the RP2040.
|
49
|
+
#if defined(ESP8266) || defined(ESP32) || defined(ARDUINO_ARCH_RP2040)
|
50
|
+
# define EEPROM_EMULATED
|
51
|
+
# define EMULATED_EEPROM_LENGTH 512
|
52
|
+
#endif
|
53
|
+
|
54
|
+
// Figure out how many LEDC channels are available on ESP32 boards.
|
55
|
+
#ifdef ESP32
|
56
|
+
#define LEDC_CHANNEL_COUNT 16
|
57
|
+
#endif
|
58
|
+
|
59
|
+
// Filter for boards that can set their analog write resolution.
|
60
|
+
#if defined(__SAM3X8E__) || defined(__SAMD21G18A__) || defined(ESP32) || defined(ARDUINO_ARCH_RP2040) || defined(ESP8266)
|
61
|
+
#define WRITE_RESOLUTION_SETTER
|
62
|
+
#endif
|
63
|
+
|
64
|
+
// Filter for boards that can set their analog read resolution.
|
65
|
+
#if defined(__SAM3X8E__) || defined(__SAMD21G18A__) || defined(ESP32) || defined(ARDUINO_ARCH_RP2040)
|
66
|
+
#define READ_RESOLUTION_SETTER
|
67
|
+
#endif
|
68
|
+
|
69
|
+
// Figure out how many open (not connected to a USB port) hardware UARTS there are on the board.
|
70
|
+
#ifdef DENKO_UART
|
71
|
+
// Look for TX pin definitions on RP2040.
|
72
|
+
#if defined(RP2040)
|
73
|
+
#if defined(PIN_SERIAL2_TX)
|
74
|
+
#define DENKO_UARTS 2
|
75
|
+
#elif defined(PIN_SERIAL_1_TX)
|
76
|
+
#define DENKO_UARTS 1
|
77
|
+
#endif
|
78
|
+
|
79
|
+
// ESP32 has either 1 or 2 extra UARTS enabled, depending on chip and board.
|
80
|
+
#elif defined(ESP32)
|
81
|
+
#if SOC_UART_NUM == 3
|
82
|
+
#define DENKO_UARTS 2
|
83
|
+
#elif SOC_UART_NUM == 2
|
84
|
+
#define DENKO_UARTS 1
|
85
|
+
#endif
|
86
|
+
|
87
|
+
// ESP8266 has a single open transmit-only UART.
|
88
|
+
#elif defined(ESP8266) && defined(SERIAL_PORT_HARDWARE_OPEN)
|
89
|
+
#define DENKO_UARTS 1
|
90
|
+
|
91
|
+
// This works for all the Atmel cores.
|
92
|
+
#else
|
93
|
+
#if defined(SERIAL_PORT_HARDWARE3)
|
94
|
+
#define DENKO_UARTS 3
|
95
|
+
#elif defined(SERIAL_PORT_HARDWARE2)
|
96
|
+
#define DENKO_UARTS 2
|
97
|
+
#elif defined(SERIAL_PORT_HARDWARE1)
|
98
|
+
#define DENKO_UARTS 1
|
99
|
+
#endif
|
100
|
+
#endif
|
101
|
+
#endif
|
102
|
+
|
103
|
+
#ifdef DENKO_UART_BB
|
104
|
+
#include <SoftwareSerial.h>
|
105
|
+
#endif
|
106
|
+
|
107
|
+
// If no high usage features (core sketch), 32 + 16.
|
108
|
+
#if !defined(DENKO_SHIFT) && !defined (DENKO_I2C) && !defined(DENKO_SPI) && !defined(DENKO_UARTS) && !defined(DENKO_UART_BB) && !defined(DENKO_IR_OUT) && !defined(DENKO_LED_ARRAY)
|
109
|
+
#define AUX_SIZE 48
|
110
|
+
// If using IR_OUT or LED_ARRAY, and not on the ATmega168, 512 + 16.
|
111
|
+
#elif (defined(DENKO_IR_OUT) || defined(DENKO_LED_ARRAY)) && !defined(__AVR_ATmega168__)
|
112
|
+
#define AUX_SIZE 528
|
113
|
+
// Default aux message size to 256 + 16 bytes.
|
114
|
+
#else
|
115
|
+
#define AUX_SIZE 272
|
116
|
+
#endif
|
@@ -0,0 +1,64 @@
|
|
1
|
+
//
|
2
|
+
// Basic EEPROM read and write functionality.
|
3
|
+
//
|
4
|
+
#include "Denko.h"
|
5
|
+
|
6
|
+
#ifdef EEPROM_PRESENT
|
7
|
+
// CMD = 6
|
8
|
+
// Read from the microcontroller's EEPROM.
|
9
|
+
//
|
10
|
+
// pin = empty
|
11
|
+
// val = number of bytes to read
|
12
|
+
// auxMsg[0-1] = start address
|
13
|
+
//
|
14
|
+
void Denko::eepromRead(){
|
15
|
+
if (val > 0) {
|
16
|
+
#if defined(EEPROM_EMULATED)
|
17
|
+
EEPROM.begin(EMULATED_EEPROM_LENGTH);
|
18
|
+
#endif
|
19
|
+
|
20
|
+
uint16_t startAddress = ((uint16_t)auxMsg[1] << 8) | auxMsg[0];
|
21
|
+
|
22
|
+
// Use pin 254 as a "virtual pin" for the built-in EEPROM.
|
23
|
+
stream->print("254");
|
24
|
+
stream->print(':');
|
25
|
+
stream->print(startAddress);
|
26
|
+
stream->print('-');
|
27
|
+
|
28
|
+
for (byte i = 0; (i < val); i++) {
|
29
|
+
stream->print(EEPROM.read(startAddress + i));
|
30
|
+
stream->print((i+1 == val) ? '\n' : ',');
|
31
|
+
}
|
32
|
+
|
33
|
+
#if defined(EEPROM_EMULATED)
|
34
|
+
EEPROM.end();
|
35
|
+
#endif
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
// CMD = 7
|
40
|
+
// Write to the microcontroller's EEPROM.
|
41
|
+
//
|
42
|
+
// pin = empty
|
43
|
+
// val = number of bytes to write
|
44
|
+
// auxMsg[0-1] = start address
|
45
|
+
// auxMsg[2+] = bytes to write
|
46
|
+
//
|
47
|
+
void Denko::eepromWrite(){
|
48
|
+
if (val > 0) {
|
49
|
+
#if defined(EEPROM_EMULATED)
|
50
|
+
EEPROM.begin(EMULATED_EEPROM_LENGTH);
|
51
|
+
#endif
|
52
|
+
|
53
|
+
uint16_t startAddress = ((uint16_t)auxMsg[1] << 8) | auxMsg[0];
|
54
|
+
|
55
|
+
for (byte i = 0; (i < val); i++) {
|
56
|
+
EEPROM.write(startAddress + i, auxMsg[2+i]);
|
57
|
+
}
|
58
|
+
|
59
|
+
#if defined(EEPROM_EMULATED)
|
60
|
+
EEPROM.end();
|
61
|
+
#endif
|
62
|
+
}
|
63
|
+
}
|
64
|
+
#endif
|
@@ -0,0 +1,155 @@
|
|
1
|
+
//
|
2
|
+
// This file adds to the Denko class only if DENKO_I2C is defined in Denko.h.
|
3
|
+
//
|
4
|
+
#include "Denko.h"
|
5
|
+
#ifdef DENKO_I2C
|
6
|
+
|
7
|
+
#include <Wire.h>
|
8
|
+
|
9
|
+
bool i2cStarted = false;
|
10
|
+
|
11
|
+
// Only start the I2C interface if not already started.
|
12
|
+
// Lazy initialization in case user wants to use I2C pins for something else.
|
13
|
+
void Denko::i2cBegin() {
|
14
|
+
if (!i2cStarted) {
|
15
|
+
Wire.begin();
|
16
|
+
i2cStarted = true;
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
// End the I2C interface.
|
21
|
+
// This is mostly used as a Reset in Denko::handshake.
|
22
|
+
void Denko::i2cEnd(){
|
23
|
+
// ESP8266 core does not define Wire.end()
|
24
|
+
#ifndef ESP8266
|
25
|
+
Wire.end();
|
26
|
+
#endif
|
27
|
+
i2cStarted = false;
|
28
|
+
}
|
29
|
+
|
30
|
+
// Configurable I2C speed each time read or write is called.
|
31
|
+
void Denko::i2cSetSpeed(uint8_t code) {
|
32
|
+
switch(code) {
|
33
|
+
case 0: Wire.setClock(100000); break;
|
34
|
+
case 1: Wire.setClock(400000); break;
|
35
|
+
case 2: Wire.setClock(1000000); break;
|
36
|
+
case 3: Wire.setClock(3400000); break;
|
37
|
+
default: Wire.setClock(100000); break;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
// CMD = 33
|
42
|
+
// Ask each address for a single byte to see if it exists on the bus.
|
43
|
+
void Denko::i2cSearch() {
|
44
|
+
byte error;
|
45
|
+
uint8_t addr;
|
46
|
+
i2cBegin();
|
47
|
+
stream->print(SDA);
|
48
|
+
|
49
|
+
// Only addresses from 0x08 to 0x77 are usable (8 to 127).
|
50
|
+
for (addr = 0x08; addr < 0x78; addr++) {
|
51
|
+
Wire.beginTransmission(addr);
|
52
|
+
error = Wire.endTransmission();
|
53
|
+
if (error == 0){
|
54
|
+
stream->print(':'); stream->print(addr);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
stream->print('\n');
|
58
|
+
}
|
59
|
+
|
60
|
+
// CMD = 34
|
61
|
+
// Write to an I2C device over a harwdare I2C interface.
|
62
|
+
//
|
63
|
+
// pin
|
64
|
+
// bits 0..6 = Device address
|
65
|
+
// bit 7 = Send stop condition. 0 = no, repeated start. 1 = yes.
|
66
|
+
//
|
67
|
+
// val
|
68
|
+
// bits 0..4 = Data length. NOTE: maximum of 32. Anything more is ignored.
|
69
|
+
//
|
70
|
+
// auxMsg[0] = I2C settings. Just speed selection for now.
|
71
|
+
//
|
72
|
+
// auxMsg[1]+ = data
|
73
|
+
//
|
74
|
+
void Denko::i2cWrite() {
|
75
|
+
// Get parameters from message.
|
76
|
+
uint8_t address = (uint8_t)pin & 0b01111111;
|
77
|
+
uint8_t dataLength = (uint8_t)val;
|
78
|
+
|
79
|
+
// Limit to 32 bytes.
|
80
|
+
if (dataLength > 32) dataLength = 32;
|
81
|
+
|
82
|
+
i2cBegin();
|
83
|
+
i2cSetSpeed(auxMsg[0]);
|
84
|
+
|
85
|
+
Wire.beginTransmission(address);
|
86
|
+
Wire.write(&auxMsg[1], dataLength);
|
87
|
+
|
88
|
+
// No repeated start on ESP32.
|
89
|
+
#if defined(ESP32)
|
90
|
+
Wire.endTransmission();
|
91
|
+
#else
|
92
|
+
uint8_t sendStop = (uint8_t)pin >> 7;
|
93
|
+
Wire.endTransmission(sendStop);
|
94
|
+
#endif
|
95
|
+
}
|
96
|
+
|
97
|
+
// CMD = 35
|
98
|
+
// Read from an I2C device over a harwdare I2C interface.
|
99
|
+
//
|
100
|
+
// pin
|
101
|
+
// bits 0..6 = Device address
|
102
|
+
// bit 7 = Send stop condition. 0 = no, repeated start. 1 = yes.
|
103
|
+
//
|
104
|
+
// val
|
105
|
+
// bits 0..4 = Data length. NOTE: maximum of 32. Anything more is ignored.
|
106
|
+
//
|
107
|
+
// auxMsg[0] = I2C settings. Just speed selection for now.
|
108
|
+
//
|
109
|
+
// auxMsg[1] = If > 0, write a register address of that many bytes before reading.
|
110
|
+
// auxMsg[2]+ = Register address bytes in order.
|
111
|
+
//
|
112
|
+
void Denko::i2cRead() {
|
113
|
+
// Get parameters from message.
|
114
|
+
uint8_t address = (uint8_t)pin & 0b01111111;
|
115
|
+
uint8_t sendStop = (uint8_t)pin >> 7;
|
116
|
+
uint8_t dataLength = (uint8_t)val;
|
117
|
+
|
118
|
+
// Limit to 32 bytes.
|
119
|
+
if (dataLength > 32) dataLength = 32;
|
120
|
+
|
121
|
+
i2cBegin();
|
122
|
+
i2cSetSpeed(auxMsg[0]);
|
123
|
+
|
124
|
+
// Optionally write up to a 4 byte register address before reading.
|
125
|
+
if ((auxMsg[1] > 0) && (auxMsg[1] < 5)) {
|
126
|
+
Wire.beginTransmission(address);
|
127
|
+
Wire.write(&auxMsg[2], auxMsg[1]);
|
128
|
+
Wire.endTransmission(sendStop);
|
129
|
+
}
|
130
|
+
|
131
|
+
// ESP32 crashes if requestFrom gets the 3rd arg.
|
132
|
+
#if defined(ESP32)
|
133
|
+
Wire.requestFrom(address, dataLength);
|
134
|
+
#else
|
135
|
+
Wire.requestFrom(address, dataLength, sendStop);
|
136
|
+
#endif
|
137
|
+
|
138
|
+
// Send data as if coming from SDA pin. Prefix with device adddress.
|
139
|
+
// Fail silently if no bytes read / invalid device address.
|
140
|
+
stream->print(SDA); stream->print(':');
|
141
|
+
stream->print(address); stream->print('-');
|
142
|
+
while(Wire.available()){
|
143
|
+
stream->print(Wire.read());
|
144
|
+
stream->print(',');
|
145
|
+
}
|
146
|
+
stream->print('\n');
|
147
|
+
|
148
|
+
// No repeated start on ESP32.
|
149
|
+
#if defined(ESP32)
|
150
|
+
Wire.endTransmission();
|
151
|
+
#else
|
152
|
+
Wire.endTransmission(sendStop);
|
153
|
+
#endif
|
154
|
+
}
|
155
|
+
#endif
|
@@ -0,0 +1,33 @@
|
|
1
|
+
//
|
2
|
+
// This file adds to the Denko class only if DENKO_IR_OUT is defined in Denko.h.
|
3
|
+
//
|
4
|
+
#include "Denko.h"
|
5
|
+
#if defined(DENKO_IR_OUT) && !defined(ESP8266) && !defined(ESP32)
|
6
|
+
|
7
|
+
// Save memory by disabling receiver.
|
8
|
+
#undef RAW_BUFFER_LENGTH
|
9
|
+
#define RAW_BUFFER_LENGTH 0
|
10
|
+
#define DISABLE_CODE_FOR_RECEIVER
|
11
|
+
|
12
|
+
// Save more memory.
|
13
|
+
#define IR_REMOTE_DISABLE_RECEIVE_COMPLETE_CALLBACK true
|
14
|
+
#define EXCLUDE_UNIVERSAL_PROTOCOLS
|
15
|
+
#define EXCLUDE_EXOTIC_PROTOCOLS
|
16
|
+
#define NO_LED_FEEDBACK_CODE
|
17
|
+
|
18
|
+
#include <IRremote.hpp>
|
19
|
+
|
20
|
+
// CMD = 16
|
21
|
+
// Send an infrared signal.
|
22
|
+
void Denko::irSend(){
|
23
|
+
// Byte 1+ of auxMsg is already little-endian uint16 pulses.
|
24
|
+
uint16_t *pulseArray = reinterpret_cast<uint16_t *>(auxMsg + 1);
|
25
|
+
|
26
|
+
// Dynamically set the sending pin. Needs to be PWM capable.
|
27
|
+
IrSender.setSendPin(pin);
|
28
|
+
|
29
|
+
// auxMsg[0] contains number of uint16_t
|
30
|
+
// Val contains frequency
|
31
|
+
IrSender.sendRaw(pulseArray, auxMsg[0], val);
|
32
|
+
}
|
33
|
+
#endif
|