denko 0.13.6 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/{build_avr.yml → build_atmega_avr.yml} +18 -18
- data/.github/workflows/{build_megaavr.yml → build_atmega_megaavr.yml} +18 -18
- data/.github/workflows/{build_sam3x.yml → build_atsam3x.yml} +17 -17
- data/.github/workflows/{build_samd.yml → build_atsamd21.yml} +18 -18
- data/.github/workflows/build_esp32.yml +17 -18
- data/.github/workflows/build_esp32c3.yml +57 -0
- data/.github/workflows/build_esp32c6.yml +57 -0
- data/.github/workflows/build_esp32h2.yml +56 -0
- data/.github/workflows/build_esp32s2.yml +57 -0
- data/.github/workflows/build_esp32s3.yml +57 -0
- data/.github/workflows/build_esp8266.yml +15 -15
- data/.github/workflows/build_ra4m1.yml +16 -16
- data/.github/workflows/build_rp2040.yml +17 -16
- data/.github/workflows/ruby.yml +20 -20
- data/CHANGELOG.md +195 -11
- data/DEPS_CLI.md +9 -9
- data/DEPS_IDE.md +17 -18
- data/HARDWARE.md +50 -51
- data/README.md +61 -53
- data/Rakefile +1 -1
- data/benchmarks/analog_listen.rb +49 -0
- data/benchmarks/digital_write.rb +28 -0
- data/benchmarks/i2c_ssd1306_refresh.rb +13 -6
- data/build +1 -1
- data/denko.gemspec +5 -2
- data/examples/advanced/{m5_env.rb → m5_env3.rb} +12 -14
- data/examples/advanced/rotary_encoder_mac_volume.rb +18 -13
- data/examples/advanced/ssd1306_time_temp_rh.rb +8 -13
- data/examples/analog_io/ads1100.rb +48 -0
- data/examples/analog_io/ads1115.rb +2 -2
- data/examples/analog_io/ads1118.rb +3 -11
- data/examples/analog_io/input.rb +17 -16
- data/examples/analog_io/input_smoothing.rb +27 -0
- data/examples/analog_io/potentiometer.rb +31 -0
- data/examples/connection/binary_echo.rb +34 -0
- data/examples/connection/tcp.rb +12 -27
- data/examples/digital_io/button.rb +7 -3
- data/examples/digital_io/relay.rb +17 -0
- data/examples/digital_io/rotary_encoder.rb +21 -11
- data/examples/display/hd44780.rb +13 -5
- data/examples/display/ssd1306.rb +20 -17
- data/examples/display/ssd1306_s2_pico.rb +2 -2
- data/examples/i2c/search.rb +10 -26
- data/examples/led/apa102_bounce.rb +3 -4
- data/examples/led/apa102_fade.rb +44 -0
- data/examples/led/builtin_blink.rb +3 -1
- data/examples/led/builtin_fade.rb +19 -0
- data/examples/led/rgb_led.rb +31 -0
- data/examples/led/seven_segment_char_echo.rb +4 -2
- data/examples/led/ws2812_bounce.rb +5 -7
- data/examples/led/ws2812_builtin_blink.rb +3 -2
- data/examples/led/ws2812_fade.rb +43 -0
- data/examples/motor/l298.rb +10 -8
- data/examples/motor/servo.rb +4 -3
- data/examples/motor/stepper.rb +13 -13
- data/examples/one_wire/search.rb +32 -0
- data/examples/pulse_io/buzzer.rb +8 -3
- data/examples/pulse_io/ir_output.rb +51 -0
- data/examples/pulse_io/pwm_output.rb +30 -0
- data/examples/rtc/ds3231.rb +18 -35
- data/examples/sensor/aht10.rb +4 -6
- data/examples/sensor/aht20.rb +4 -6
- data/examples/sensor/bme280.rb +4 -4
- data/examples/sensor/bmp180.rb +9 -5
- data/examples/sensor/dht.rb +20 -15
- data/examples/sensor/ds18b20.rb +20 -21
- data/examples/sensor/generic_pir.rb +4 -2
- data/examples/sensor/hcsr04.rb +5 -2
- data/examples/sensor/htu21d.rb +9 -20
- data/examples/sensor/htu31d.rb +7 -9
- data/examples/sensor/neat_tph_readings.rb +15 -9
- data/examples/sensor/qmp6988.rb +5 -7
- data/examples/sensor/rcwl9620.rb +3 -3
- data/examples/sensor/sht3x.rb +4 -6
- data/examples/spi/bitbang_loopback.rb +46 -0
- data/examples/spi/input_register.rb +9 -19
- data/examples/spi/output_register.rb +9 -17
- data/examples/spi/ssd_through_registers.rb +28 -0
- data/examples/spi/two_registers.rb +18 -24
- data/examples/uart/bit_bang_demo.rb +25 -0
- data/examples/uart/board_passthrough.rb +19 -13
- data/examples/uart/hardware_loopback.rb +1 -1
- data/lib/denko/analog_io/ads1100.rb +127 -0
- data/lib/denko/analog_io/ads1115.rb +8 -25
- data/lib/denko/analog_io/ads1118.rb +10 -25
- data/lib/denko/analog_io/ads111x.rb +25 -11
- data/lib/denko/analog_io/input.rb +29 -55
- data/lib/denko/analog_io/input_helper.rb +42 -0
- data/lib/denko/analog_io/output.rb +5 -5
- data/lib/denko/analog_io/potentiometer.rb +6 -8
- data/lib/denko/analog_io.rb +2 -1
- data/lib/denko/behaviors/board_proxy.rb +13 -1
- data/lib/denko/behaviors/bus_controller.rb +1 -0
- data/lib/denko/behaviors/bus_controller_addressed.rb +1 -0
- data/lib/denko/behaviors/bus_peripheral.rb +3 -4
- data/lib/denko/behaviors/bus_peripheral_addressed.rb +8 -6
- data/lib/denko/behaviors/callbacks.rb +9 -7
- data/lib/denko/behaviors/component.rb +16 -14
- data/lib/denko/behaviors/input_pin.rb +14 -15
- data/lib/denko/behaviors/lifecycle.rb +51 -0
- data/lib/denko/behaviors/multi_pin.rb +22 -18
- data/lib/denko/behaviors/output_pin.rb +9 -4
- data/lib/denko/behaviors/single_pin.rb +1 -0
- data/lib/denko/behaviors/state.rb +15 -9
- data/lib/denko/behaviors/subcomponents.rb +72 -12
- data/lib/denko/behaviors.rb +2 -1
- data/lib/denko/board/core.rb +36 -18
- data/lib/denko/board/i2c.rb +14 -14
- data/lib/denko/board/i2c_bit_bang.rb +49 -0
- data/lib/denko/board/infrared.rb +6 -6
- data/lib/denko/board/led_array.rb +6 -5
- data/lib/denko/board/spi.rb +15 -10
- data/lib/denko/board/spi_bit_bang.rb +9 -7
- data/lib/denko/board.rb +35 -33
- data/lib/denko/connection/binary_echo.rb +17 -0
- data/lib/denko/connection/flow_control.rb +11 -15
- data/lib/denko/connection/handshake.rb +2 -0
- data/lib/denko/digital_io/button.rb +4 -0
- data/lib/denko/digital_io/c_bit_bang.rb +15 -0
- data/lib/denko/digital_io/input.rb +4 -5
- data/lib/denko/digital_io/output.rb +7 -6
- data/lib/denko/digital_io/relay.rb +2 -0
- data/lib/denko/digital_io/rotary_encoder.rb +78 -60
- data/lib/denko/digital_io.rb +1 -0
- data/lib/denko/display/hd44780.rb +136 -93
- data/lib/denko/display/sh1106.rb +42 -0
- data/lib/denko/display/ssd1306.rb +105 -45
- data/lib/denko/display.rb +1 -0
- data/lib/denko/eeprom/built_in.rb +19 -16
- data/lib/denko/i2c/bit_bang.rb +31 -0
- data/lib/denko/i2c/bus.rb +8 -36
- data/lib/denko/i2c/bus_common.rb +45 -0
- data/lib/denko/i2c/peripheral.rb +28 -19
- data/lib/denko/i2c.rb +2 -0
- data/lib/denko/led/apa102.rb +43 -29
- data/lib/denko/led/base.rb +8 -2
- data/lib/denko/led/rgb.rb +5 -7
- data/lib/denko/led/seven_segment.rb +24 -9
- data/lib/denko/led/ws2812.rb +10 -7
- data/lib/denko/message.rb +5 -0
- data/lib/denko/motor/l298.rb +11 -10
- data/lib/denko/motor/servo.rb +22 -10
- data/lib/denko/motor/stepper.rb +11 -14
- data/lib/denko/mutex_stub.rb +7 -0
- data/lib/denko/one_wire/bus.rb +9 -5
- data/lib/denko/one_wire/peripheral.rb +0 -3
- data/lib/denko/pulse_io/buzzer.rb +9 -3
- data/lib/denko/pulse_io/{ir_transmitter.rb → ir_output.rb} +9 -4
- data/lib/denko/pulse_io/pwm_output.rb +69 -15
- data/lib/denko/pulse_io.rb +3 -3
- data/lib/denko/rtc/ds3231.rb +11 -13
- data/lib/denko/sensor/aht.rb +22 -21
- data/lib/denko/sensor/bme280.rb +60 -63
- data/lib/denko/sensor/bmp180.rb +41 -38
- data/lib/denko/sensor/dht.rb +22 -5
- data/lib/denko/sensor/ds18b20.rb +40 -34
- data/lib/denko/sensor/hcsr04.rb +7 -5
- data/lib/denko/sensor/helper.rb +37 -0
- data/lib/denko/sensor/htu21d.rb +44 -55
- data/lib/denko/sensor/htu31d.rb +32 -33
- data/lib/denko/sensor/qmp6988.rb +25 -23
- data/lib/denko/sensor/rcwl9620.rb +2 -5
- data/lib/denko/sensor/sht3x.rb +23 -21
- data/lib/denko/sensor.rb +1 -2
- data/lib/denko/spi/base_register.rb +22 -22
- data/lib/denko/spi/bit_bang.rb +17 -51
- data/lib/denko/spi/bus.rb +15 -29
- data/lib/denko/spi/bus_common.rb +36 -0
- data/lib/denko/spi/input_register.rb +36 -30
- data/lib/denko/spi/output_register.rb +25 -40
- data/lib/denko/spi/peripheral.rb +93 -24
- data/lib/denko/spi.rb +6 -1
- data/lib/denko/uart/bit_bang.rb +5 -3
- data/lib/denko/uart/hardware.rb +9 -8
- data/lib/denko/version.rb +1 -1
- data/lib/denko.rb +10 -0
- data/lib/denko_cli/generator.rb +2 -2
- data/lib/denko_cli/packages.rb +8 -10
- data/lib/denko_cli/targets.rb +8 -8
- data/lib/denko_cli/targets.txt +4 -4
- data/lib/denko_cli/usage.txt +1 -1
- data/src/denko_ethernet.ino +0 -14
- data/src/denko_serial.ino +0 -14
- data/src/denko_wifi.ino +6 -15
- data/src/lib/Denko.cpp +39 -3
- data/src/lib/Denko.h +42 -26
- data/src/lib/DenkoCoreIO.cpp +57 -102
- data/src/lib/DenkoDefines.h +36 -31
- data/src/lib/DenkoI2C.cpp +54 -45
- data/src/lib/DenkoI2CBB.cpp +238 -0
- data/src/lib/DenkoIROut.cpp +12 -7
- data/src/lib/DenkoLEDArray.cpp +36 -13
- data/src/lib/DenkoSPI.cpp +6 -5
- data/src/lib/DenkoSPIBB.cpp +7 -6
- data/target.yml +37 -2
- data/test/analog_io/potentiometer_test.rb +10 -10
- data/test/behaviors/board_proxy_test.rb +1 -1
- data/test/behaviors/callbacks_test.rb +11 -3
- data/test/behaviors/component_test.rb +17 -9
- data/test/behaviors/input_pin_test.rb +14 -9
- data/test/behaviors/multi_pin_test.rb +14 -4
- data/test/behaviors/output_pin_test.rb +11 -8
- data/test/behaviors/poller_test.rb +1 -0
- data/test/behaviors/reader_test.rb +3 -2
- data/test/behaviors/subcomponents_test.rb +22 -2
- data/test/board/core_test.rb +15 -11
- data/test/board/i2c_test.rb +39 -33
- data/test/board/infrared_test.rb +1 -1
- data/test/board/message_test.rb +17 -11
- data/test/board/spi_test.rb +21 -21
- data/test/digital_io/button_test.rb +15 -0
- data/test/digital_io/relay_test.rb +18 -0
- data/test/digital_io/rotary_encoder_test.rb +80 -60
- data/test/eeprom/built_in_test.rb +9 -9
- data/test/i2c/bus_test.rb +30 -14
- data/test/i2c/peripheral_test.rb +36 -17
- data/test/led/base_test.rb +2 -1
- data/test/led/rgb_test.rb +6 -6
- data/test/led/seven_segment_test.rb +7 -7
- data/test/motor/servo_test.rb +1 -1
- data/test/motor/stepper_test.rb +2 -2
- data/test/one_wire/bus_test.rb +1 -0
- data/test/pulse_io/buzzer_test.rb +7 -4
- data/test/pulse_io/{ir_transmitter_test.rb → ir_output_test.rb} +10 -10
- data/test/pulse_io/pwm_output_test.rb +74 -18
- data/test/rtc/ds3231_test.rb +11 -13
- data/test/sensor/dht_test.rb +1 -1
- data/test/sensor/ds18b20_test.rb +4 -8
- data/test/spi/bus_test.rb +7 -7
- data/test/spi/input_register_test.rb +15 -15
- data/test/spi/output_register_test.rb +10 -28
- data/test/spi/peripheral_multi_pin_test.rb +53 -0
- data/test/spi/peripheral_single_pin_test.rb +48 -0
- data/test/test_helper.rb +36 -33
- data/tutorial/02-button/button.rb +5 -4
- data/tutorial/03-potentiometer/potentiometer.rb +9 -5
- data/tutorial/04-pwm_led/pwm_led.rb +14 -16
- data/tutorial/05-rgb_led/rgb_led.rb +6 -6
- data/tutorial/05-rgb_led/rgb_mapping.rb +11 -11
- data/vendor/board-maps/BoardMap.h +416 -56
- data/vendor/board-maps/lib/header_parser.rb +12 -2
- data/vendor/board-maps/yaml/ADAFRUIT_CAMERA_ESP32S3.yml +2 -2
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32C6.yml +15 -0
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32_V2.yml +1 -1
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_RP2040_ADALOGGER.yml +44 -0
- data/vendor/board-maps/yaml/ADAFRUIT_QTPY_ESP32C3.yml +1 -0
- data/vendor/board-maps/yaml/ADAFRUIT_QTPY_ESP32S2.yml +1 -0
- data/vendor/board-maps/yaml/ADAFRUIT_QTPY_ESP32S3_N4R2.yml +1 -0
- data/vendor/board-maps/yaml/ADAFRUIT_QTPY_ESP32S3_NOPSRAM.yml +1 -0
- data/vendor/board-maps/yaml/ADAFRUIT_QTPY_ESP32_PICO.yml +1 -0
- data/vendor/board-maps/yaml/AMKEN_BB.yml +48 -0
- data/vendor/board-maps/yaml/AMKEN_ES.yml +48 -0
- data/vendor/board-maps/yaml/AMKEN_REVELOP.yml +48 -0
- data/vendor/board-maps/yaml/AMKEN_REVELOP_PLUS.yml +48 -0
- data/vendor/board-maps/yaml/ASL_CAN_X2.yml +41 -0
- data/vendor/board-maps/yaml/BLING.yml +25 -0
- data/vendor/board-maps/yaml/BPI_LEAF_S3.yml +1 -0
- data/vendor/board-maps/yaml/BRIDGETEK_IDM2040_7A.yml +48 -0
- data/vendor/board-maps/yaml/Bee_Motion_Mini.yml +13 -1
- data/vendor/board-maps/yaml/Breadstick_Raspberry.yml +31 -0
- data/vendor/board-maps/yaml/DFROBOT_BEETLE_ESP32C6.yml +8 -0
- data/vendor/board-maps/yaml/DFROBOT_FIREBEETLE_2_ESP32C6.yml +20 -0
- data/vendor/board-maps/yaml/DFROBOT_FIREBEETLE_ESP32.yml +46 -0
- data/vendor/board-maps/yaml/DPTECHNICS_WALTER.yml +39 -0
- data/vendor/board-maps/yaml/ELECROW_CROWPANEL_7.yml +8 -0
- data/vendor/board-maps/yaml/ESP32C2_DEV.yml +12 -0
- data/vendor/board-maps/yaml/ESP32C3_DEVKIT_LIPO.yml +14 -0
- data/vendor/board-maps/yaml/ESP32C6_DEV.yml +15 -0
- data/vendor/board-maps/yaml/ESP32C6_EVB.yml +15 -0
- data/vendor/board-maps/yaml/ESP32C6_QWIIC_POCKET.yml +15 -0
- data/vendor/board-maps/yaml/ESP32C6_THING_PLUS.yml +15 -0
- data/vendor/board-maps/yaml/ESP32H2_DEV.yml +13 -0
- data/vendor/board-maps/yaml/ESP32H2_DEVKIT_LIPO.yml +13 -0
- data/vendor/board-maps/yaml/ESP32S2_DEV.yml +1 -0
- data/vendor/board-maps/yaml/{RMP.yml → ESP32S2_DEVKIT_LIPO.yml} +2 -1
- data/vendor/board-maps/yaml/ESP32S2_DEVKIT_LIPO_USB.yml +44 -0
- data/vendor/board-maps/yaml/ESP32S3_DEVKIT_LIPO.yml +42 -0
- data/vendor/board-maps/yaml/ESP32S3_POWERFEATHER.yml +22 -0
- data/vendor/board-maps/yaml/ESP32_SBC_FABGL.yml +35 -0
- data/vendor/board-maps/yaml/EVN_ALPHA.yml +48 -0
- data/vendor/board-maps/yaml/FEATHERS3NEO.yml +32 -0
- data/vendor/board-maps/yaml/GEEKBLE_ESP32C3.yml +14 -0
- data/vendor/board-maps/yaml/HELTEC_CAPSULE_SENSOR_V3.yml +43 -0
- data/vendor/board-maps/yaml/HELTEC_WIFI_LORA_32_V3.yml +42 -0
- data/vendor/board-maps/yaml/HELTEC_WIRELESS_BRIDGE.yml +8 -0
- data/vendor/board-maps/yaml/HELTEC_WIRELESS_MINI_SHELL.yml +13 -0
- data/vendor/board-maps/yaml/HELTEC_WIRELESS_PAPER.yml +42 -0
- data/vendor/board-maps/yaml/HELTEC_WIRELESS_SHELL_V3.yml +42 -0
- data/vendor/board-maps/yaml/HELTEC_WIRELESS_STICK_LITE_V3.yml +30 -0
- data/vendor/board-maps/yaml/HELTEC_WIRELESS_TRACKER.yml +41 -0
- data/vendor/board-maps/yaml/HT_DE01.yml +42 -0
- data/vendor/board-maps/yaml/IMBRIOS_LOGSENS_V1P1.yml +1 -1
- data/vendor/board-maps/yaml/LILYGO_T3S3_LR1121.yml +9 -0
- data/vendor/board-maps/yaml/LILYGO_T3S3_SX1262.yml +9 -0
- data/vendor/board-maps/yaml/LILYGO_T3S3_SX1276.yml +9 -0
- data/vendor/board-maps/yaml/LILYGO_T3S3_SX1278.yml +9 -0
- data/vendor/board-maps/yaml/LILYGO_T3S3_SX1280.yml +9 -0
- data/vendor/board-maps/yaml/LILYGO_T3S3_SX1280PA.yml +8 -0
- data/vendor/board-maps/yaml/LILYGO_T_ETH_LITE.yml +21 -0
- data/vendor/board-maps/yaml/LOLIN_C3_PICO.yml +14 -0
- data/vendor/board-maps/yaml/LOLIN_S3.yml +1 -0
- data/vendor/board-maps/yaml/LOLIN_S3_MINI_PRO.yml +40 -0
- data/vendor/board-maps/yaml/Lion_Bit_Dev_Board.yml +0 -2
- data/vendor/board-maps/yaml/LoPy.yml +1 -0
- data/vendor/board-maps/yaml/LoPy4.yml +1 -0
- data/vendor/board-maps/yaml/M5STACK_CAPSULE.yml +8 -0
- data/vendor/board-maps/yaml/M5STACK_CARDPUTER.yml +8 -0
- data/vendor/board-maps/yaml/M5STACK_DIAL.yml +8 -0
- data/vendor/board-maps/yaml/M5STACK_FIRE.yml +0 -1
- data/vendor/board-maps/yaml/M5STACK_NANOC6.yml +17 -0
- data/vendor/board-maps/yaml/M5STACK_PAPER.yml +9 -0
- data/vendor/board-maps/yaml/M5STACK_POE_CAM.yml +5 -0
- data/vendor/board-maps/yaml/M5STACK_STAMP_C3.yml +13 -0
- data/vendor/board-maps/yaml/M5STACK_STAMP_S3.yml +4 -0
- data/vendor/board-maps/yaml/{M5Stick_C.yml → M5STACK_STICKC.yml} +0 -1
- data/vendor/board-maps/yaml/M5STACK_STICKC_PLUS.yml +9 -0
- data/vendor/board-maps/yaml/M5STACK_STICKC_PLUS2.yml +9 -0
- data/vendor/board-maps/yaml/M5STACK_TOUGH.yml +9 -0
- data/vendor/board-maps/yaml/M5STACK_UNIT_CAM.yml +10 -0
- data/vendor/board-maps/yaml/M5STACK_UNIT_CAMS3.yml +4 -0
- data/vendor/board-maps/yaml/M5Stack_ATOM.yml +0 -1
- data/vendor/board-maps/yaml/MAKERGO_C3_SUPERMINI.yml +14 -0
- data/vendor/board-maps/yaml/MARBLE_PICO.yml +48 -0
- data/vendor/board-maps/yaml/METEHOCA_AKANA_R1.yml +46 -0
- data/vendor/board-maps/yaml/NAMINO_BIANCO.yml +13 -0
- data/vendor/board-maps/yaml/NEBULAS3.yml +0 -1
- data/vendor/board-maps/yaml/NEWSAN_ARCHI.yml +48 -0
- data/vendor/board-maps/yaml/NOLOGO_ESP32C3_SUPER_MINI.yml +14 -0
- data/vendor/board-maps/yaml/NOLOGO_ESP32S3_PICO.yml +12 -0
- data/vendor/board-maps/yaml/OLIMEX_RP2040_PICO30_16MB.yml +48 -0
- data/vendor/board-maps/yaml/OLIMEX_RP2040_PICO30_2MB.yml +48 -0
- data/vendor/board-maps/yaml/OPTA_ANALOG.yml +7 -0
- data/vendor/board-maps/yaml/OPTA_DIGITAL.yml +5 -0
- data/vendor/board-maps/yaml/PINTRONIX_PINMAX.yml +42 -0
- data/vendor/board-maps/yaml/PYCOM_GPY.yml +1 -0
- data/vendor/board-maps/yaml/REDPILL_ESP32S3.yml +0 -1
- data/vendor/board-maps/yaml/SENSEBOX_MCU_ESP32S2.yml +12 -0
- data/vendor/board-maps/yaml/SPARKFUN_MICROMOD_RP2040.yml +48 -0
- data/vendor/board-maps/yaml/SPARKFUN_PRO_MICRO_ESP32C3.yml +24 -0
- data/vendor/board-maps/yaml/THINGPULSE_EPULSE_FEATHER.yml +31 -0
- data/vendor/board-maps/yaml/THINGPULSE_EPULSE_FEATHER_C6.yml +15 -0
- data/vendor/board-maps/yaml/TINYC6.yml +25 -0
- data/vendor/board-maps/yaml/UPESY_EDU_ESP32.yml +28 -0
- data/vendor/board-maps/yaml/UPESY_ESP32C3_BASIC.yml +13 -0
- data/vendor/board-maps/yaml/UPESY_ESP32C3_MINI.yml +12 -0
- data/vendor/board-maps/yaml/UPESY_ESP32S3_BASIC.yml +42 -0
- data/vendor/board-maps/yaml/VIRALINK_GATE32_01.yml +6 -0
- data/vendor/board-maps/yaml/VIRALINK_GATE32_11.yml +7 -0
- data/vendor/board-maps/yaml/WAVESHARE_ESP32S3_TOUCH_LCD_128.yml +8 -0
- data/vendor/board-maps/yaml/WAVESHARE_RP2040_MATRIX.yml +48 -0
- data/vendor/board-maps/yaml/WAVESHARE_RP2040_ONE.yml +1 -0
- data/vendor/board-maps/yaml/WAVESHARE_RP2040_PIZERO.yml +47 -0
- data/vendor/board-maps/yaml/WAVESHARE_RP2040_ZERO.yml +1 -0
- data/vendor/board-maps/yaml/WEACT_STUDIO_ESP32C3.yml +14 -0
- data/vendor/board-maps/yaml/WIPY3.yml +1 -0
- data/vendor/board-maps/yaml/WT32_SC01_PLUS.yml +7 -0
- data/vendor/board-maps/yaml/WiFiduinoV2.yml +1 -0
- data/vendor/board-maps/yaml/XIAO_ESP32C3.yml +0 -1
- data/vendor/board-maps/yaml/XIAO_ESP32C6.yml +22 -0
- data/vendor/board-maps/yaml/unphone9.yml +8 -0
- metadata +169 -30
- data/examples/led/apa102_breathe.rb +0 -45
- data/examples/pulse_io/ir_transmitter.rb +0 -55
- data/examples/spi/ssd_through_register.rb +0 -40
- data/examples/uart/bit_bang_read.rb +0 -16
- data/examples/uart/bit_bang_write.rb +0 -16
- data/lib/denko/analog_io/sensor.rb +0 -6
- data/lib/denko/sensor/virtual.rb +0 -42
- data/src/lib/DenkoIROutESP.cpp +0 -26
- data/vendor/board-maps/yaml/STAMP_S3.yml +0 -8
- /data/vendor/board-maps/yaml/{BRIDGETEK_IDM2040-7A.yml → BRIDGETEK_IDM2040_43A.yml} +0 -0
- /data/vendor/board-maps/yaml/{heltec_wifi_32_lora_V3.yml → HELTEC_WIRELESS_STICK_V3.yml} +0 -0
- /data/vendor/board-maps/yaml/{M5Stack_Core_ESP32.yml → M5STACK_CORE.yml} +0 -0
- /data/vendor/board-maps/yaml/{M5Stamp_Pico.yml → M5STACK_STAMP_PICO.yml} +0 -0
- /data/vendor/board-maps/yaml/{M5Stack-Timer-CAM.yml → M5STACK_TIMER_CAM.yml} +0 -0
data/src/lib/DenkoCoreIO.cpp
CHANGED
@@ -4,62 +4,82 @@
|
|
4
4
|
// Set up a single pin for the desired type of input or output.
|
5
5
|
void Denko::setMode(byte p, byte m) {
|
6
6
|
//
|
7
|
-
// Use the lowest
|
8
|
-
//
|
7
|
+
// Use the lowest 4 bits of m to set different input/output modes.
|
8
|
+
// Also enables/disables peripherals for certain targets.
|
9
9
|
//
|
10
|
-
// OUTPUT MODES:
|
11
|
-
//
|
12
|
-
//
|
13
|
-
//
|
10
|
+
// OUTPUT MODES:
|
11
|
+
// 0000 = Digital Output
|
12
|
+
// 0010 = PWM Ouptut
|
13
|
+
// 0100 = DAC Output
|
14
|
+
// 0110 = Open Drain Output (Only ESP32 implements this, and we don't really use it)
|
15
|
+
// 1000 = Open Source Output (Nothing implements this yet)
|
14
16
|
//
|
15
17
|
// INPUT MODES
|
16
|
-
//
|
17
|
-
//
|
18
|
-
//
|
19
|
-
|
20
|
-
m = m & 0b00000111;
|
18
|
+
// 0001 = Input with no pull bias
|
19
|
+
// 0011 = Input with internal pulldown, if available.
|
20
|
+
// 0101 = Input with internal pullup, if available.
|
21
|
+
m = m & 0b00001111;
|
21
22
|
|
22
23
|
#if defined(ESP32)
|
23
|
-
// Free the LEDC channel if leaving PWM mode.
|
24
|
-
if (m != 0b010) releaseLEDC(p);
|
25
|
-
|
26
24
|
// Disable attached DAC if leaving DAC mode.
|
27
25
|
#if defined(SOC_DAC_SUPPORTED)
|
28
|
-
|
26
|
+
if (m != 0b0100) dacDisable(p);
|
29
27
|
#endif
|
28
|
+
|
29
|
+
// Attach or detach LEDC channel whether entering or leaving PWM mode.
|
30
|
+
if (m == 0b0010) {
|
31
|
+
// auxMsg[0..3] is frequency, [4..7] is resolution.
|
32
|
+
uint32_t freq = *reinterpret_cast<uint32_t *>(auxMsg);
|
33
|
+
uint8_t res = *reinterpret_cast<uint8_t *>(auxMsg + 4);
|
34
|
+
// Fallback to defaults.
|
35
|
+
if (freq == 0) freq = 1000;
|
36
|
+
if (res == 0) res = esp32AnalogWRes;
|
37
|
+
ledcAttach(p, freq, res);
|
38
|
+
return;
|
39
|
+
} else {
|
40
|
+
ledcDetach(p);
|
41
|
+
}
|
30
42
|
#endif
|
31
|
-
|
43
|
+
|
32
44
|
// On the SAMD21 and RA4M1, mode needs to be INPUT when using the DAC.
|
33
45
|
#if defined(__SAMD21G18A__) || defined(_RENESAS_RA_)
|
34
|
-
if (m ==
|
46
|
+
if (m == 0b0100){
|
35
47
|
pinMode(p, INPUT);
|
36
48
|
return;
|
37
49
|
}
|
38
50
|
#endif
|
39
|
-
|
40
|
-
// Handle
|
51
|
+
|
52
|
+
// Handle INPUT_* states on boards implementing them.
|
41
53
|
#ifdef INPUT_PULLDOWN
|
42
|
-
if (m ==
|
54
|
+
if (m == 0b0011) {
|
43
55
|
pinMode(p, INPUT_PULLDOWN);
|
44
56
|
return;
|
45
57
|
}
|
46
58
|
#endif
|
47
|
-
|
48
|
-
#ifdef
|
49
|
-
if (m ==
|
50
|
-
pinMode(p,
|
59
|
+
|
60
|
+
#ifdef INPUT_PULLUP
|
61
|
+
if (m == 0b0101) {
|
62
|
+
pinMode(p, INPUT_PULLUP);
|
51
63
|
return;
|
52
64
|
}
|
53
65
|
#endif
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
66
|
+
|
67
|
+
// Handle OUTPUT_* states on boards implementing them.
|
68
|
+
#ifdef OUTPUT_OPEN_DRAIN
|
69
|
+
if (m == 0b0110) {
|
70
|
+
pinMode(p, OUTPUT_OPEN_DRAIN);
|
71
|
+
return;
|
72
|
+
}
|
73
|
+
#endif
|
74
|
+
|
75
|
+
#ifdef OUTPUT_OPEN_SOURCE
|
76
|
+
if (m == 0b1000) {
|
77
|
+
pinMode(p, OUTPUT_OPEN_SOURCE);
|
58
78
|
return;
|
59
79
|
}
|
60
80
|
#endif
|
61
|
-
|
62
|
-
// Handle
|
81
|
+
|
82
|
+
// Handle standard INPUT and OUTPUT states.
|
63
83
|
// Allows INPUT_* to fallback to INPUT when not implemented.
|
64
84
|
if (bitRead(m, 0) == 0) {
|
65
85
|
pinMode(p, OUTPUT);
|
@@ -69,7 +89,7 @@ void Denko::setMode(byte p, byte m) {
|
|
69
89
|
|
70
90
|
// Write high to set pullup for AVRs that use this method.
|
71
91
|
#ifdef __AVR__
|
72
|
-
if (m ==
|
92
|
+
if (m == 0b0101) digitalWrite(p, HIGH);
|
73
93
|
#endif
|
74
94
|
}
|
75
95
|
|
@@ -89,9 +109,9 @@ void Denko::dWrite(byte p, byte v, boolean echo) {
|
|
89
109
|
#if defined(SOC_DAC_SUPPORTED)
|
90
110
|
dacDisable(p);
|
91
111
|
#endif
|
92
|
-
|
112
|
+
ledcDetach(p);
|
93
113
|
#endif
|
94
|
-
|
114
|
+
|
95
115
|
if (v == 0) {
|
96
116
|
digitalWrite(p, LOW);
|
97
117
|
}
|
@@ -113,13 +133,7 @@ byte Denko::dRead(byte p) {
|
|
113
133
|
// Write an analog output pin. 0 for LOW, up to 255 for HIGH @ 8-bit resolution.
|
114
134
|
void Denko::pwmWrite(byte p, int v, boolean echo) {
|
115
135
|
#ifdef ESP32
|
116
|
-
|
117
|
-
byte channel = ledcChannel(p);
|
118
|
-
|
119
|
-
// Reattach the pin in case dWrite detached it.
|
120
|
-
ledcAttachPin(p, channel);
|
121
|
-
|
122
|
-
ledcWrite(channel, v);
|
136
|
+
ledcWrite(p, v);
|
123
137
|
#else
|
124
138
|
analogWrite(p,v);
|
125
139
|
#endif
|
@@ -127,66 +141,9 @@ void Denko::pwmWrite(byte p, int v, boolean echo) {
|
|
127
141
|
if (echo) coreResponse(p, v);
|
128
142
|
}
|
129
143
|
|
130
|
-
//
|
131
|
-
// Manage ESP32 LEDC channels so we can do PWM write.
|
132
|
-
//
|
133
144
|
#ifdef ESP32
|
134
|
-
|
135
|
-
|
136
|
-
for (int i = LEDC_CHANNEL_COUNT -1; i > 0; i--){
|
137
|
-
if ((ledcPins[i][0] == 1) && (ledcPins[i][1] == p)){
|
138
|
-
return i;
|
139
|
-
}
|
140
|
-
}
|
141
|
-
|
142
|
-
// We didn't find a channel to reuse.
|
143
|
-
for (int i = LEDC_CHANNEL_COUNT -1; i > 0; i--){
|
144
|
-
// If the channel isn't initialized and it isn't marked as used, use it.
|
145
|
-
// should find some way to check if the channel itslef is being used
|
146
|
-
if ((ledcPins[i][0] == 0)) {
|
147
|
-
assignLEDC(i, p);
|
148
|
-
return i;
|
149
|
-
}
|
150
|
-
}
|
151
|
-
|
152
|
-
// Return a useless channel if none available.
|
153
|
-
return 255;
|
154
|
-
};
|
155
|
-
|
156
|
-
// Assign a LEDC channel to a pin and save it.
|
157
|
-
byte Denko::assignLEDC(byte channel, byte p){
|
158
|
-
// First 8 channels: up to 40Mhz @ 16-bits
|
159
|
-
// Last 8 channels: up to 500kHz @ 13-bits
|
160
|
-
// Just use similar settings to ATmega for now.
|
161
|
-
ledcSetup(channel, 1000, 8);
|
162
|
-
ledcAttachPin(p, channel);
|
163
|
-
|
164
|
-
// Save the pin and mark it as in use.
|
165
|
-
ledcPins[channel][0] = 1;
|
166
|
-
ledcPins[channel][1] = p;
|
167
|
-
return channel;
|
168
|
-
}
|
169
|
-
|
170
|
-
// Release a LEDC channel when done with it.
|
171
|
-
void Denko::releaseLEDC(byte p){
|
172
|
-
// Detach the pin from the channel.
|
173
|
-
ledcDetachPin(p);
|
174
|
-
|
175
|
-
// Mark any channel associated with the pin as unused.
|
176
|
-
for (int i = LEDC_CHANNEL_COUNT -1; i > 0; i--){
|
177
|
-
if (ledcPins[i][1] == p) ledcPins[i][0] = 0;
|
178
|
-
}
|
179
|
-
}
|
180
|
-
|
181
|
-
// Clear all the LEDC channels on reset.
|
182
|
-
void Denko::clearLedcChannels(){
|
183
|
-
for (int i = LEDC_CHANNEL_COUNT -1; i > 0; i--){
|
184
|
-
// Stop the channel if it was still enabled.
|
185
|
-
if (ledcPins[i][0] != 0) ledcDetachPin(ledcPins[i][1]);
|
186
|
-
|
187
|
-
// Mark the channel as unused.
|
188
|
-
ledcPins[i][0] = 0;
|
189
|
-
}
|
145
|
+
void Denko::ledcDetachAll() {
|
146
|
+
for(byte i=0; i++; i<256) ledcDetach(i);
|
190
147
|
}
|
191
148
|
#endif
|
192
149
|
|
@@ -197,7 +154,7 @@ void Denko::dacWrite(byte p, int v, boolean echo) {
|
|
197
154
|
#if defined(ESP32) && defined(SOC_DAC_SUPPORTED)
|
198
155
|
::dacWrite(p, v);
|
199
156
|
#endif
|
200
|
-
|
157
|
+
|
201
158
|
#if defined(__SAM3X8E__) || defined(__SAMD21G18A__) || defined(_RENESAS_RA_)
|
202
159
|
analogWrite(p, v);
|
203
160
|
#endif
|
@@ -284,7 +241,6 @@ void Denko::updateCoreListeners() {
|
|
284
241
|
// Handle a single analog listener when it needs to read.
|
285
242
|
void Denko::analogListenerUpdate(byte i){
|
286
243
|
int rval = analogRead(listeners[i][1]);
|
287
|
-
analogListenCallback(listeners[i][1], rval);
|
288
244
|
coreResponse(listeners[i][1], rval);
|
289
245
|
}
|
290
246
|
|
@@ -295,7 +251,6 @@ void Denko::digitalListenerUpdate(byte i){
|
|
295
251
|
if (rval != bitRead(listeners[i][0], 5)){
|
296
252
|
// State for digital listeners is stored in byte 5 of the listener itself.
|
297
253
|
bitWrite(listeners[i][0], 5, rval);
|
298
|
-
digitalListenCallback(listeners[i][1], rval);
|
299
254
|
coreResponse(listeners[i][1], rval);
|
300
255
|
}
|
301
256
|
}
|
data/src/lib/DenkoDefines.h
CHANGED
@@ -11,6 +11,7 @@
|
|
11
11
|
// #define DENKO_EEPROM
|
12
12
|
// #define DENKO_ONE_WIRE
|
13
13
|
// #define DENKO_TONE
|
14
|
+
// #define DENKO_I2C_BB
|
14
15
|
// #define DENKO_SPI_BB
|
15
16
|
// #define DENKO_I2C
|
16
17
|
// #define DENKO_SPI
|
@@ -26,16 +27,19 @@
|
|
26
27
|
#endif
|
27
28
|
|
28
29
|
// Define number of pins to set up listener storage.
|
29
|
-
#if defined(
|
30
|
-
#define PIN_COUNT
|
31
|
-
#elif defined(__SAM3X8E__)
|
32
|
-
#define PIN_COUNT 72
|
30
|
+
#if defined(ESP32)
|
31
|
+
#define PIN_COUNT 45
|
33
32
|
#elif defined(ESP8266)
|
34
33
|
#define PIN_COUNT 18
|
35
|
-
#elif defined(ESP32)
|
36
|
-
#define PIN_COUNT 40
|
37
34
|
#elif defined(ARDUINO_ARCH_RP2040)
|
38
|
-
#define PIN_COUNT
|
35
|
+
#define PIN_COUNT 30
|
36
|
+
// These may have more physical pins, but limited to 54 by the Arduino cores.
|
37
|
+
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__SAM3X8E__)
|
38
|
+
#define PIN_COUNT 54
|
39
|
+
// Very small optimization for the 328P/UNO.
|
40
|
+
#elif defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)
|
41
|
+
#define PIN_COUNT 20
|
42
|
+
// This catches ATmega32u4, SAMD21, RA4M1 etc.
|
39
43
|
#else
|
40
44
|
#define PIN_COUNT 22
|
41
45
|
#endif
|
@@ -44,10 +48,8 @@
|
|
44
48
|
#ifdef ESP32
|
45
49
|
#if CONFIG_IDF_TARGET_ESP32
|
46
50
|
#define LEDC_CHANNEL_COUNT 16
|
47
|
-
#
|
48
|
-
#define LEDC_CHANNEL_COUNT
|
49
|
-
#elif CONFIG_IDF_TARGET_ESP32C3
|
50
|
-
#define LEDC_CHANNEL_COUNT 6
|
51
|
+
#else
|
52
|
+
#define LEDC_CHANNEL_COUNT SOC_LEDC_CHANNEL_NUM
|
51
53
|
#endif
|
52
54
|
#endif
|
53
55
|
|
@@ -73,11 +75,7 @@
|
|
73
75
|
|
74
76
|
// ESP32 has either 1 or 2 extra UARTS enabled, depending on chip and board.
|
75
77
|
#elif defined(ESP32)
|
76
|
-
#
|
77
|
-
#define DENKO_UARTS 2
|
78
|
-
#elif SOC_UART_NUM == 2
|
79
|
-
#define DENKO_UARTS 1
|
80
|
-
#endif
|
78
|
+
#define DENKO_UARTS (SOC_UART_NUM - 1)
|
81
79
|
|
82
80
|
// ESP8266 has a single open transmit-only UART.
|
83
81
|
#elif defined(ESP8266) && defined(SERIAL_PORT_HARDWARE_OPEN)
|
@@ -122,9 +120,9 @@
|
|
122
120
|
// Uses SerialUSB (left port), which is native USB, on Arduino Due & Zero, or Serial otherwise.
|
123
121
|
// On many boards, eg. Arduino Leonardo, RP2040, ESP32-S3, Serial is native USB regardless.
|
124
122
|
#if defined(__SAM3X8E__) || defined(__SAMD21G18A__)
|
125
|
-
#define DENKO_SERIAL_IF
|
123
|
+
#define DENKO_SERIAL_IF SERIAL_PORT_USBVIRTUAL
|
126
124
|
#define DENKO_USB_CDC
|
127
|
-
//
|
125
|
+
// "Serial" is UART (right port) on Due and Zero, but may be native USB on boards with one port.
|
128
126
|
// #define DENKO_SERIAL_IF Serial
|
129
127
|
#else
|
130
128
|
#define DENKO_SERIAL_IF Serial
|
@@ -135,30 +133,37 @@
|
|
135
133
|
//
|
136
134
|
// These are 256/64 regardless of whether native USB CDC or UART bridge.
|
137
135
|
#if defined(ARDUINO_ARCH_RP2040) || defined(ESP8266) || defined(__SAM3X8E__)
|
138
|
-
#define DENKO_SERIAL_BUFFER_SIZE
|
136
|
+
#define DENKO_SERIAL_BUFFER_SIZE 248
|
139
137
|
#define DENKO_RX_ACK_INTERVAL 64
|
138
|
+
|
140
139
|
// ESP32 defaults to 256 buffer. Stay one under.
|
141
140
|
#elif defined(ESP32)
|
142
|
-
#define DENKO_SERIAL_BUFFER_SIZE
|
143
|
-
|
144
|
-
|
145
|
-
#
|
146
|
-
|
147
|
-
|
141
|
+
#define DENKO_SERIAL_BUFFER_SIZE 248
|
142
|
+
// H2 and C6 unreliable with CDC. Use UART bridge. Still unreliable ACK before buffer full, like S2.
|
143
|
+
#if defined(CONFIG_IDF_TARGET_ESP32H2) || defined(CONFIG_IDF_TARGET_ESP32C6)
|
144
|
+
#define DENKO_RX_ACK_INTERVAL 248
|
145
|
+
#else
|
146
|
+
#ifdef ARDUINO_USB_CDC_ON_BOOT
|
147
|
+
// S2 unreliable with acknowledgement before buffer is full.
|
148
|
+
#ifdef CONFIG_IDF_TARGET_ESP32S2
|
149
|
+
#define DENKO_RX_ACK_INTERVAL 248
|
150
|
+
// S3 and C3 are fine acknowledging at half buffer filled.
|
151
|
+
#else
|
152
|
+
#define DENKO_RX_ACK_INTERVAL 128
|
153
|
+
#endif
|
154
|
+
// Fall back to 64 if using a UART bridge.
|
148
155
|
#else
|
149
|
-
|
156
|
+
#define DENKO_RX_ACK_INTERVAL 64
|
150
157
|
#endif
|
151
|
-
// Default to 64 if using a UART bridge.
|
152
|
-
#else
|
153
|
-
#define DENKO_RX_ACK_INTERVAL 64
|
154
158
|
#endif
|
159
|
+
|
155
160
|
// RA4M1 has a 512 Serial buffer.
|
156
161
|
#elif defined(_RENESAS_RA_)
|
157
|
-
#define DENKO_SERIAL_BUFFER_SIZE
|
162
|
+
#define DENKO_SERIAL_BUFFER_SIZE 504
|
158
163
|
#define DENKO_RX_ACK_INTERVAL 64
|
159
164
|
// SAMD21 is 256/128 in native USB mode ONLY. Must use defaults on programming port to avoid data loss.
|
160
165
|
#elif defined(__SAMD21G18A__) && defined(DENKO_USB_CDC)
|
161
|
-
#define DENKO_SERIAL_BUFFER_SIZE
|
166
|
+
#define DENKO_SERIAL_BUFFER_SIZE 248
|
162
167
|
#define DENKO_RX_ACK_INTERVAL 128
|
163
168
|
// 32u4 is odd. Size is 63 instead of 64. Interval must be 31. 32 doesn't work at all. Off by 1 errors?
|
164
169
|
#elif defined(__AVR_ATmega32U4__)
|
data/src/lib/DenkoI2C.cpp
CHANGED
@@ -37,6 +37,14 @@ void Denko::i2cSetSpeed(uint8_t code) {
|
|
37
37
|
default: Wire.setClock(100000); break;
|
38
38
|
}
|
39
39
|
i2cSpeed = code;
|
40
|
+
|
41
|
+
// ESP32-H2 doesn't safely fallback if speed > 400kHz is chosen.
|
42
|
+
#ifdef CONFIG_IDF_TARGET_ESP32H2
|
43
|
+
if (i2cSpeed > 1) {
|
44
|
+
i2cSpeed = 1;
|
45
|
+
Wire.setClock(400000);
|
46
|
+
}
|
47
|
+
#endif
|
40
48
|
}
|
41
49
|
|
42
50
|
// CMD = 33
|
@@ -46,7 +54,7 @@ void Denko::i2cSearch() {
|
|
46
54
|
uint8_t addr;
|
47
55
|
if (!i2cStarted) i2cBegin();
|
48
56
|
i2cSetSpeed(0);
|
49
|
-
stream->print(
|
57
|
+
stream->print("I2C0");
|
50
58
|
|
51
59
|
// Only addresses from 0x08 to 0x77 are usable (8 to 127).
|
52
60
|
for (addr = 0x08; addr < 0x78; addr++) {
|
@@ -59,88 +67,89 @@ void Denko::i2cSearch() {
|
|
59
67
|
stream->print('\n');
|
60
68
|
}
|
61
69
|
|
62
|
-
// CMD = 34
|
63
|
-
// Write to an I2C device over a harwdare I2C interface.
|
64
|
-
//
|
65
|
-
// pin
|
66
|
-
// bits 0..6 = Device address
|
67
|
-
// bit 7 = Send stop condition. 0 = no, repeated start. 1 = yes.
|
68
70
|
//
|
69
|
-
//
|
70
|
-
//
|
71
|
-
//
|
72
|
-
// auxMsg[0]
|
73
|
-
//
|
74
|
-
//
|
71
|
+
// cmd = 34
|
72
|
+
// pin = <reseverd>
|
73
|
+
// val = <reserved>
|
74
|
+
// auxMsg[0] = I2C settings
|
75
|
+
// Bits[7..2] = <reserved>
|
76
|
+
// Bits[1..0] = Bitmask for I2C speed
|
77
|
+
// auxMsg[1] = Device address in bits [6..0] + repeated start in bit 7
|
78
|
+
// auxMsg[2] = Data length to write
|
79
|
+
// auxMsg[3]+ = Data
|
75
80
|
//
|
76
81
|
void Denko::i2cWrite() {
|
77
82
|
// Get parameters from message.
|
78
|
-
uint8_t
|
79
|
-
uint8_t
|
83
|
+
uint8_t speedMask = auxMsg[0] & 0b00000011;
|
84
|
+
uint8_t address = auxMsg[1] & 0b01111111;
|
85
|
+
uint8_t sendStop = auxMsg[1] >> 7;
|
86
|
+
uint8_t dataLength = auxMsg[2];
|
80
87
|
|
81
|
-
// Limit to
|
88
|
+
// Limit to board's I2C buffer size.
|
82
89
|
if (dataLength > DENKO_I2C_BUFFER_SIZE) dataLength = DENKO_I2C_BUFFER_SIZE;
|
83
90
|
|
91
|
+
// Start and set speed.
|
84
92
|
if (!i2cStarted) i2cBegin();
|
85
|
-
if (i2cSpeed !=
|
93
|
+
if (i2cSpeed != speedMask) i2cSetSpeed(speedMask);
|
86
94
|
|
87
95
|
Wire.beginTransmission(address);
|
88
|
-
Wire.write(&auxMsg[
|
96
|
+
Wire.write(&auxMsg[3], dataLength);
|
89
97
|
|
90
98
|
// No repeated start on ESP32.
|
91
99
|
#if defined(ESP32)
|
92
100
|
Wire.endTransmission();
|
93
101
|
#else
|
94
|
-
|
102
|
+
|
95
103
|
Wire.endTransmission(sendStop);
|
96
104
|
#endif
|
97
105
|
}
|
98
106
|
|
99
|
-
// CMD = 35
|
100
|
-
// Read from an I2C device over a harwdare I2C interface.
|
101
107
|
//
|
102
|
-
//
|
103
|
-
// bits 0..6 = Device address
|
104
|
-
// bit 7 = Send stop condition. 0 = no, repeated start. 1 = yes.
|
105
|
-
//
|
106
|
-
// val
|
107
|
-
// bits 0..4 = Data length. NOTE: maximum of 32. Anything more is ignored.
|
108
|
-
//
|
109
|
-
// auxMsg[0] = I2C settings. Just speed selection for now.
|
108
|
+
// Read from an I2C device over a harwdare I2C interface.
|
110
109
|
//
|
111
|
-
//
|
112
|
-
//
|
110
|
+
// cmd = 35
|
111
|
+
// pin = <reseverd>
|
112
|
+
// val = <reserved>
|
113
|
+
// auxMsg[0] = I2C settings
|
114
|
+
// Bits[7..2] = <reserved>
|
115
|
+
// Bits[1..0] = Bitmask for I2C speed
|
116
|
+
// auxMsg[1] = Device address in bits [6..0] + repeated start in bit 7
|
117
|
+
// auxMsg[2] = Data length to read
|
118
|
+
// auxMsg[3] = Register address length
|
119
|
+
// auxMsg[4]+ = Register address bytes if length > 0
|
113
120
|
//
|
114
121
|
void Denko::i2cRead() {
|
115
122
|
// Get parameters from message.
|
116
|
-
uint8_t
|
117
|
-
uint8_t
|
118
|
-
uint8_t
|
123
|
+
uint8_t speedMask = auxMsg[0] & 0b00000011;
|
124
|
+
uint8_t address = auxMsg[1] & 0b01111111;
|
125
|
+
uint8_t sendStop = auxMsg[1] >> 7;
|
126
|
+
uint8_t dataLength = auxMsg[2];
|
119
127
|
|
120
|
-
// Limit to
|
128
|
+
// Limit to board's I2C buffer size.
|
121
129
|
if (dataLength > DENKO_I2C_BUFFER_SIZE) dataLength = DENKO_I2C_BUFFER_SIZE;
|
122
130
|
|
131
|
+
// Start and set speed.
|
123
132
|
if (!i2cStarted) i2cBegin();
|
124
|
-
if (i2cSpeed !=
|
125
|
-
|
133
|
+
if (i2cSpeed != speedMask) i2cSetSpeed(speedMask);
|
134
|
+
|
126
135
|
// Optionally write up to a 4 byte register address before reading.
|
127
|
-
if ((auxMsg[
|
136
|
+
if ((auxMsg[3] > 0) && (auxMsg[3] < 5)) {
|
128
137
|
Wire.beginTransmission(address);
|
129
|
-
Wire.write(&auxMsg[
|
138
|
+
Wire.write(&auxMsg[4], auxMsg[3]);
|
130
139
|
Wire.endTransmission(sendStop);
|
131
140
|
}
|
132
|
-
|
141
|
+
|
133
142
|
// ESP32 crashes if requestFrom gets the 3rd arg.
|
134
|
-
#if defined(ESP32)
|
143
|
+
#if defined(ESP32)
|
135
144
|
Wire.requestFrom(address, dataLength);
|
136
145
|
#else
|
137
146
|
Wire.requestFrom(address, dataLength, sendStop);
|
138
147
|
#endif
|
139
|
-
|
140
|
-
// Send data as if coming from
|
148
|
+
|
149
|
+
// Send data as if coming from a pin called "I2C0". Prefix with device adddress.
|
141
150
|
// Fail silently if no bytes read / invalid device address.
|
142
|
-
stream->print(
|
143
|
-
stream->print(address); stream->print('-');
|
151
|
+
stream->print("I2C0:");
|
152
|
+
stream->print(address); stream->print('-');
|
144
153
|
while(Wire.available()){
|
145
154
|
stream->print(Wire.read());
|
146
155
|
stream->print(',');
|