denko 0.13.1 → 0.13.3
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 +2 -4
- data/.github/workflows/build_esp32.yml +2 -3
- data/.github/workflows/build_esp8266.yml +2 -3
- data/.github/workflows/build_megaavr.yml +3 -5
- data/.github/workflows/build_ra4m1.yml +57 -0
- data/.github/workflows/build_rp2040.yml +2 -4
- data/.github/workflows/build_sam3x.yml +1 -3
- data/.github/workflows/build_samd.yml +2 -4
- data/CHANGELOG.md +100 -0
- data/DEPS_CLI.md +13 -6
- data/DEPS_IDE.md +14 -7
- data/HARDWARE.md +104 -80
- data/README.md +19 -28
- data/benchmarks/i2c_ssd1306_refresh.rb +79 -0
- data/examples/analog_io/ads1115.rb +57 -0
- data/examples/analog_io/ads1118.rb +8 -9
- data/examples/analog_io/dac_loopback.rb +6 -4
- data/examples/analog_io/input.rb +39 -36
- data/examples/connection/tcp.rb +1 -1
- data/examples/display/hd44780.rb +3 -3
- data/examples/display/ssd1306.rb +1 -1
- data/lib/denko/analog_io/ads1115.rb +61 -0
- data/lib/denko/analog_io/ads1118.rb +10 -120
- data/lib/denko/analog_io/ads111x.rb +123 -0
- data/lib/denko/analog_io/output.rb +2 -1
- data/lib/denko/analog_io.rb +2 -0
- data/lib/denko/behaviors/reader.rb +14 -13
- data/lib/denko/behaviors/subcomponents.rb +2 -2
- data/lib/denko/board/core.rb +1 -1
- data/lib/denko/board/i2c.rb +1 -4
- data/lib/denko/board/led_array.rb +3 -6
- data/lib/denko/board/map.rb +9 -0
- data/lib/denko/board/servo.rb +2 -6
- data/lib/denko/board.rb +32 -20
- data/lib/denko/connection/board_uart.rb +3 -3
- data/lib/denko/connection/flow_control.rb +10 -2
- data/lib/denko/digital_io/output.rb +1 -1
- data/lib/denko/display/hd44780.rb +18 -18
- data/lib/denko/led/seven_segment.rb +18 -19
- data/lib/denko/message.rb +7 -15
- data/lib/denko/pulse_io/ir_transmitter.rb +1 -2
- data/lib/denko/version.rb +1 -1
- data/lib/denko_cli/packages.rb +7 -1
- data/lib/denko_cli/targets.rb +8 -5
- data/lib/denko_cli/usage.txt +8 -4
- data/src/denko_ethernet.ino +15 -23
- data/src/denko_serial.ino +3 -14
- data/src/denko_wifi.ino +72 -52
- data/src/lib/Denko.cpp +14 -6
- data/src/lib/Denko.h +6 -17
- data/src/lib/DenkoCoreIO.cpp +3 -3
- data/src/lib/DenkoDefines.h +73 -19
- data/src/lib/DenkoEEPROM.cpp +9 -1
- data/src/lib/DenkoI2C.cpp +11 -9
- data/src/lib/DenkoLEDArray.cpp +5 -11
- data/test/analog_io/input_test.rb +3 -3
- data/test/analog_io/output_test.rb +1 -1
- data/test/analog_io/potentiometer_test.rb +2 -2
- data/test/behaviors/bus_peripheral_addressed.rb +1 -1
- data/test/behaviors/bus_peripheral_test.rb +1 -1
- data/test/behaviors/callbacks_test.rb +4 -4
- data/test/behaviors/component_test.rb +2 -2
- data/test/behaviors/listener_test.rb +3 -3
- data/test/behaviors/poller_test.rb +3 -3
- data/test/behaviors/reader_test.rb +11 -4
- data/test/behaviors/subcomponents_test.rb +1 -1
- data/test/behaviors/threaded_test.rb +7 -7
- data/test/board/board_test.rb +8 -8
- data/test/board/core_test.rb +12 -12
- data/test/board/eeprom_test.rb +2 -2
- data/test/board/helper_test.rb +0 -4
- data/test/board/i2c_test.rb +5 -5
- data/test/board/infrared_test.rb +1 -1
- data/test/board/message_test.rb +1 -1
- data/test/board/one_wire_test.rb +4 -4
- data/test/board/pulse_test.rb +2 -2
- data/test/board/servo_test.rb +3 -3
- data/test/board/spi_test.rb +3 -3
- data/test/board/tone_test.rb +2 -2
- data/test/connection/serial_test.rb +13 -13
- data/test/digital_io/input_test.rb +7 -7
- data/test/digital_io/output_test.rb +5 -5
- data/test/digital_io/rotary_encoder_test.rb +4 -4
- data/test/display/hd44780_test.rb +11 -1
- data/test/eeprom/built_in_test.rb +1 -1
- data/test/i2c/bus_test.rb +5 -5
- data/test/i2c/peripheral_test.rb +4 -4
- data/test/led/base_test.rb +2 -2
- data/test/led/rgb_test.rb +6 -6
- data/test/led/seven_segment_test.rb +36 -14
- data/test/motor/servo_test.rb +6 -6
- data/test/motor/stepper_test.rb +5 -5
- data/test/one_wire/bus_test.rb +9 -9
- data/test/one_wire/peripheral_test.rb +17 -17
- data/test/pulse_io/buzzer_test.rb +4 -4
- data/test/pulse_io/ir_transmitter_test.rb +2 -2
- data/test/pulse_io/pwm_output_test.rb +4 -4
- data/test/rtc/ds3231_test.rb +4 -4
- data/test/sensor/dht_test.rb +3 -3
- data/test/sensor/ds18b20_test.rb +9 -9
- data/test/spi/bus_test.rb +4 -4
- data/test/spi/input_register_test.rb +8 -8
- data/test/spi/output_register_test.rb +4 -4
- data/test/test_helper.rb +17 -2
- data/test/uart/bitbang_test.rb +3 -3
- metadata +7 -350
- data/vendor/board-maps/.gitignore +0 -56
- data/vendor/board-maps/.gitmodules +0 -21
- data/vendor/board-maps/BoardMap.h +0 -1364
- data/vendor/board-maps/README.md +0 -51
- data/vendor/board-maps/lib/boards_parser.rb +0 -66
- data/vendor/board-maps/lib/header_parser.rb +0 -164
- data/vendor/board-maps/run.rb +0 -47
- data/vendor/board-maps/yaml/0XCB_HELIOS.yml +0 -48
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32S2.yml +0 -25
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32S2_REVTFT.yml +0 -25
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32S2_TFT.yml +0 -27
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32S3.yml +0 -29
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32S3_NOPSRAM.yml +0 -29
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32S3_REVTFT.yml +0 -25
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32S3_TFT.yml +0 -27
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32_V2.yml +0 -30
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_RP2040.yml +0 -48
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_RP2040_CAN.yml +0 -48
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_RP2040_DVI.yml +0 -48
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_RP2040_PROP_MAKER.yml +0 -48
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_RP2040_RFM.yml +0 -48
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_RP2040_SCORPIO.yml +0 -48
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_RP2040_THINKINK.yml +0 -48
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_RP2040_USB_HOST.yml +0 -48
- data/vendor/board-maps/yaml/ADAFRUIT_ITSYBITSY_ESP32.yml +0 -24
- data/vendor/board-maps/yaml/ADAFRUIT_ITSYBITSY_RP2040.yml +0 -48
- data/vendor/board-maps/yaml/ADAFRUIT_KB2040_RP2040.yml +0 -48
- data/vendor/board-maps/yaml/ADAFRUIT_MACROPAD_RP2040.yml +0 -48
- data/vendor/board-maps/yaml/ADAFRUIT_MATRIXPORTAL_ESP32S3.yml +0 -16
- data/vendor/board-maps/yaml/ADAFRUIT_QTPY_ESP32C3.yml +0 -12
- data/vendor/board-maps/yaml/ADAFRUIT_QTPY_ESP32S2.yml +0 -22
- data/vendor/board-maps/yaml/ADAFRUIT_QTPY_ESP32S3_NOPSRAM.yml +0 -20
- data/vendor/board-maps/yaml/ADAFRUIT_QTPY_ESP32_PICO.yml +0 -27
- data/vendor/board-maps/yaml/ADAFRUIT_QTPY_RP2040.yml +0 -48
- data/vendor/board-maps/yaml/ADAFRUIT_STEMMAFRIEND_RP2040.yml +0 -48
- data/vendor/board-maps/yaml/ADAFRUIT_TRINKEYQT_RP2040.yml +0 -48
- data/vendor/board-maps/yaml/ALKS.yml +0 -34
- data/vendor/board-maps/yaml/AMPERKA_WIFI_SLOT.yml +0 -16
- data/vendor/board-maps/yaml/AVR_ADK.yml +0 -24
- data/vendor/board-maps/yaml/AVR_BT.yml +0 -16
- data/vendor/board-maps/yaml/AVR_CIRCUITPLAY.yml +0 -14
- data/vendor/board-maps/yaml/AVR_DUEMILANOVE.yml +0 -16
- data/vendor/board-maps/yaml/AVR_ESPLORA.yml +0 -20
- data/vendor/board-maps/yaml/AVR_ETHERNET.yml +0 -16
- data/vendor/board-maps/yaml/AVR_FIO.yml +0 -16
- data/vendor/board-maps/yaml/AVR_GEMMA.yml +0 -6
- data/vendor/board-maps/yaml/AVR_INDUSTRIAL101.yml +0 -20
- data/vendor/board-maps/yaml/AVR_LEONARDO.yml +0 -20
- data/vendor/board-maps/yaml/AVR_LEONARDO_ETH.yml +0 -20
- data/vendor/board-maps/yaml/AVR_LILYPAD.yml +0 -16
- data/vendor/board-maps/yaml/AVR_LILYPAD_USB.yml +0 -20
- data/vendor/board-maps/yaml/AVR_LININO_ONE.yml +0 -20
- data/vendor/board-maps/yaml/AVR_MEGA.yml +0 -24
- data/vendor/board-maps/yaml/AVR_MEGA2560.yml +0 -24
- data/vendor/board-maps/yaml/AVR_MICRO.yml +0 -20
- data/vendor/board-maps/yaml/AVR_MINI.yml +0 -16
- data/vendor/board-maps/yaml/AVR_NANO.yml +0 -16
- data/vendor/board-maps/yaml/AVR_NANO_EVERY.yml +0 -22
- data/vendor/board-maps/yaml/AVR_NG.yml +0 -16
- data/vendor/board-maps/yaml/AVR_PRO.yml +0 -16
- data/vendor/board-maps/yaml/AVR_ROBOT_CONTROL.yml +0 -22
- data/vendor/board-maps/yaml/AVR_ROBOT_MOTOR.yml +0 -19
- data/vendor/board-maps/yaml/AVR_UNO.yml +0 -16
- data/vendor/board-maps/yaml/AVR_UNO_WIFI_DEV_ED.yml +0 -16
- data/vendor/board-maps/yaml/AVR_UNO_WIFI_REV2.yml +0 -22
- data/vendor/board-maps/yaml/AVR_YUN.yml +0 -20
- data/vendor/board-maps/yaml/AVR_YUNMINI.yml +0 -20
- data/vendor/board-maps/yaml/AirM2M_CORE_ESP32C3.yml +0 -14
- data/vendor/board-maps/yaml/BEE_DATA_LOGGER.yml +0 -39
- data/vendor/board-maps/yaml/BPI_BIT.yml +0 -9
- data/vendor/board-maps/yaml/BPI_LEAF_S3.yml +0 -31
- data/vendor/board-maps/yaml/BRIDGETEK_IDM2040-7A.yml +0 -48
- data/vendor/board-maps/yaml/BeeMotionS3.yml +0 -40
- data/vendor/board-maps/yaml/Bee_Motion.yml +0 -27
- data/vendor/board-maps/yaml/Bee_Motion_Mini.yml +0 -1
- data/vendor/board-maps/yaml/Bee_S3.yml +0 -38
- data/vendor/board-maps/yaml/CHALLENGER_2040_LORA_RP2040.yml +0 -39
- data/vendor/board-maps/yaml/CHALLENGER_2040_LTE_RP2040.yml +0 -38
- data/vendor/board-maps/yaml/CHALLENGER_2040_NFC_RP2040.yml +0 -32
- data/vendor/board-maps/yaml/CHALLENGER_2040_SDRTC_RP2040.yml +0 -36
- data/vendor/board-maps/yaml/CHALLENGER_2040_SUBGHZ_RP2040.yml +0 -39
- data/vendor/board-maps/yaml/CHALLENGER_2040_UWB_RP2040.yml +0 -39
- data/vendor/board-maps/yaml/CHALLENGER_2040_WIFI_BLE_RP2040.yml +0 -42
- data/vendor/board-maps/yaml/CHALLENGER_2040_WIFI_RP2040.yml +0 -38
- data/vendor/board-maps/yaml/CHALLENGER_NB_2040_WIFI_RP2040.yml +0 -38
- data/vendor/board-maps/yaml/CRABIK_SLOT_ESP32_S3.yml +0 -19
- data/vendor/board-maps/yaml/CYTRON_MAKER_FEATHER_AIOT_S3.yml +0 -26
- data/vendor/board-maps/yaml/CYTRON_MAKER_NANO_RP2040.yml +0 -48
- data/vendor/board-maps/yaml/CYTRON_MAKER_PI_RP2040.yml +0 -48
- data/vendor/board-maps/yaml/CoreESP32.yml +0 -49
- data/vendor/board-maps/yaml/D1_MINI32.yml +0 -36
- data/vendor/board-maps/yaml/D1_UNO32.yml +0 -28
- data/vendor/board-maps/yaml/DATANOISETV_PICOADK.yml +0 -48
- data/vendor/board-maps/yaml/DENKY.yml +0 -26
- data/vendor/board-maps/yaml/DENKY_PICOV3.yml +0 -26
- data/vendor/board-maps/yaml/DENKY_WROOM32.yml +0 -26
- data/vendor/board-maps/yaml/DEPARTMENT_OF_ALCHEMY_MINIMAIN_ESP32S2.yml +0 -26
- data/vendor/board-maps/yaml/DFROBOT_BEETLE_ESP32_C3.yml +0 -14
- data/vendor/board-maps/yaml/DFROBOT_BEETLE_RP2040.yml +0 -48
- data/vendor/board-maps/yaml/DFROBOT_FIREBEETLE_2_ESP32E.yml +0 -44
- data/vendor/board-maps/yaml/DFROBOT_FIREBEETLE_2_ESP32S3.yml +0 -38
- data/vendor/board-maps/yaml/DFROBOT_ROMEO_ESP32S3.yml +0 -7
- data/vendor/board-maps/yaml/DPU_ESP32.yml +0 -26
- data/vendor/board-maps/yaml/DYDK.yml +0 -38
- data/vendor/board-maps/yaml/DYDK1A.yml +0 -37
- data/vendor/board-maps/yaml/DYDK1Av2.yml +0 -45
- data/vendor/board-maps/yaml/DYG.yml +0 -20
- data/vendor/board-maps/yaml/DYM.yml +0 -40
- data/vendor/board-maps/yaml/DYMv2.yml +0 -39
- data/vendor/board-maps/yaml/D_Duino_32.yml +0 -29
- data/vendor/board-maps/yaml/ELECTRONICCATS_HUNTERCAT_NFC.yml +0 -44
- data/vendor/board-maps/yaml/ESP320.yml +0 -8
- data/vendor/board-maps/yaml/ESP32C3_DEV.yml +0 -14
- data/vendor/board-maps/yaml/ESP32C3_M1_I_KIT.yml +0 -13
- data/vendor/board-maps/yaml/ESP32S2_DEV.yml +0 -33
- data/vendor/board-maps/yaml/ESP32S2_THING_PLUS.yml +0 -34
- data/vendor/board-maps/yaml/ESP32S2_USB.yml +0 -33
- data/vendor/board-maps/yaml/ESP32S3_CAM_LCD.yml +0 -7
- data/vendor/board-maps/yaml/ESP32S3_DEV.yml +0 -38
- data/vendor/board-maps/yaml/ESP32_DEV.yml +0 -26
- data/vendor/board-maps/yaml/ESP32_DEVKIT_LIPO.yml +0 -26
- data/vendor/board-maps/yaml/ESP32_EVB.yml +0 -7
- data/vendor/board-maps/yaml/ESP32_GATEWAY.yml +0 -13
- data/vendor/board-maps/yaml/ESP32_GATEWAY_C.yml +0 -13
- data/vendor/board-maps/yaml/ESP32_GATEWAY_E.yml +0 -13
- data/vendor/board-maps/yaml/ESP32_GATEWAY_F.yml +0 -13
- data/vendor/board-maps/yaml/ESP32_IOT_REDBOARD.yml +0 -27
- data/vendor/board-maps/yaml/ESP32_MICROMOD.yml +0 -24
- data/vendor/board-maps/yaml/ESP32_PICO.yml +0 -26
- data/vendor/board-maps/yaml/ESP32_POE.yml +0 -7
- data/vendor/board-maps/yaml/ESP32_POE_ISO.yml +0 -7
- data/vendor/board-maps/yaml/ESP32_S3_BOX.yml +0 -16
- data/vendor/board-maps/yaml/ESP32_S3_USB_OTG.yml +0 -11
- data/vendor/board-maps/yaml/ESP32_THING.yml +0 -27
- data/vendor/board-maps/yaml/ESP32_THING_PLUS.yml +0 -30
- data/vendor/board-maps/yaml/ESP32_THING_PLUS_C.yml +0 -30
- data/vendor/board-maps/yaml/ESP32_WROOM_DA.yml +0 -26
- data/vendor/board-maps/yaml/ESP32_WROVER_KIT.yml +0 -26
- data/vendor/board-maps/yaml/ESP8266_ADAFRUIT_HUZZAH.yml +0 -9
- data/vendor/board-maps/yaml/ESP8266_AGRUMINO_LEMON_V4.yml +0 -8
- data/vendor/board-maps/yaml/ESP8266_ARDUINO_PRIMO.yml +0 -7
- data/vendor/board-maps/yaml/ESP8266_ARDUINO_STAR_OTTO.yml +0 -7
- data/vendor/board-maps/yaml/ESP8266_ARDUINO_UNOWIFI.yml +0 -9
- data/vendor/board-maps/yaml/ESP8266_ESP01.yml +0 -9
- data/vendor/board-maps/yaml/ESP8266_ESP07.yml +0 -20
- data/vendor/board-maps/yaml/ESP8266_ESP12.yml +0 -20
- data/vendor/board-maps/yaml/ESP8266_ESP13.yml +0 -17
- data/vendor/board-maps/yaml/ESP8266_ESP210.yml +0 -9
- data/vendor/board-maps/yaml/ESP8266_ESPECTRO_CORE.yml +0 -9
- data/vendor/board-maps/yaml/ESP8266_ESPINO_ESP12.yml +0 -9
- data/vendor/board-maps/yaml/ESP8266_ESPINO_ESP13.yml +0 -9
- data/vendor/board-maps/yaml/ESP8266_ESPRESSO_LITE_V1.yml +0 -9
- data/vendor/board-maps/yaml/ESP8266_ESPRESSO_LITE_V2.yml +0 -9
- data/vendor/board-maps/yaml/ESP8266_GENERIC.yml +0 -9
- data/vendor/board-maps/yaml/ESP8266_INVENT_ONE.yml +0 -22
- data/vendor/board-maps/yaml/ESP8266_NODEMCU_ESP12.yml +0 -20
- data/vendor/board-maps/yaml/ESP8266_NODEMCU_ESP12E.yml +0 -20
- data/vendor/board-maps/yaml/ESP8266_OAK.yml +0 -9
- data/vendor/board-maps/yaml/ESP8266_PHOENIX_V1.yml +0 -9
- data/vendor/board-maps/yaml/ESP8266_PHOENIX_V2.yml +0 -9
- data/vendor/board-maps/yaml/ESP8266_SCHIRMILABS_EDUINO_WIFI.yml +0 -25
- data/vendor/board-maps/yaml/ESP8266_SONOFF_BASIC.yml +0 -9
- data/vendor/board-maps/yaml/ESP8266_SONOFF_S20.yml +0 -9
- data/vendor/board-maps/yaml/ESP8266_SONOFF_SV.yml +0 -9
- data/vendor/board-maps/yaml/ESP8266_SONOFF_TH.yml +0 -9
- data/vendor/board-maps/yaml/ESP8266_THING.yml +0 -9
- data/vendor/board-maps/yaml/ESP8266_THING_DEV.yml +0 -9
- data/vendor/board-maps/yaml/ESP8266_WEMOS_D1MINI.yml +0 -18
- data/vendor/board-maps/yaml/ESP8266_WEMOS_D1MINILITE.yml +0 -18
- data/vendor/board-maps/yaml/ESP8266_WEMOS_D1MINIPRO.yml +0 -18
- data/vendor/board-maps/yaml/ESP8266_WEMOS_D1R1.yml +0 -25
- data/vendor/board-maps/yaml/ESP8266_WEMOS_D1WROOM02.yml +0 -18
- data/vendor/board-maps/yaml/ESP8266_WIO_LINK.yml +0 -9
- data/vendor/board-maps/yaml/ESP8266_XINABOX_CW01.yml +0 -9
- data/vendor/board-maps/yaml/ESPECTRO32.yml +0 -27
- data/vendor/board-maps/yaml/ESPea32.yml +0 -27
- data/vendor/board-maps/yaml/ESPino32.yml +0 -27
- data/vendor/board-maps/yaml/ET-Board.yml +0 -26
- data/vendor/board-maps/yaml/EXTREMEELEXTRONICS_RC2040.yml +0 -46
- data/vendor/board-maps/yaml/Edgebox-ESP-100.yml +0 -7
- data/vendor/board-maps/yaml/FEATHERS2.yml +0 -33
- data/vendor/board-maps/yaml/FEATHERS2NEO.yml +0 -30
- data/vendor/board-maps/yaml/FEATHERS3.yml +0 -29
- data/vendor/board-maps/yaml/FEATHER_ESP32.yml +0 -28
- data/vendor/board-maps/yaml/FLYBOARD2040_CORE.yml +0 -48
- data/vendor/board-maps/yaml/FRANZININHO_WIFI.yml +0 -33
- data/vendor/board-maps/yaml/FRANZININHO_WIFI_MSC.yml +0 -33
- data/vendor/board-maps/yaml/FROG_ESP32.yml +0 -26
- data/vendor/board-maps/yaml/FUNHOUSE_ESP32S2.yml +0 -22
- data/vendor/board-maps/yaml/GEN4_IOD.yml +0 -9
- data/vendor/board-maps/yaml/GENERIC_RP2040.yml +0 -48
- data/vendor/board-maps/yaml/HEALTHYPI_4.yml +0 -27
- data/vendor/board-maps/yaml/HONEYLEMON.yml +0 -27
- data/vendor/board-maps/yaml/HORNBILL_ESP32_DEV.yml +0 -27
- data/vendor/board-maps/yaml/HORNBILL_ESP32_MINIMA.yml +0 -16
- data/vendor/board-maps/yaml/ILABS_2040_RPICO32_RP2040.yml +0 -47
- data/vendor/board-maps/yaml/IMBRIOS_LOGSENS_V1P1.yml +0 -19
- data/vendor/board-maps/yaml/INTOROBOT_ESP32_DEV.yml +0 -34
- data/vendor/board-maps/yaml/LILYGO_T_DISPLAY_S3.yml +0 -26
- data/vendor/board-maps/yaml/LOLIN32.yml +0 -27
- data/vendor/board-maps/yaml/LOLIN32_LITE.yml +0 -27
- data/vendor/board-maps/yaml/LOLIN_C3_MINI.yml +0 -14
- data/vendor/board-maps/yaml/LOLIN_D32.yml +0 -27
- data/vendor/board-maps/yaml/LOLIN_D32_PRO.yml +0 -27
- data/vendor/board-maps/yaml/LOLIN_S2_MINI.yml +0 -34
- data/vendor/board-maps/yaml/LOLIN_S2_PICO.yml +0 -34
- data/vendor/board-maps/yaml/LOLIN_S3.yml +0 -32
- data/vendor/board-maps/yaml/LOLIN_S3_MINI.yml +0 -32
- data/vendor/board-maps/yaml/LOLIN_S3_PRO.yml +0 -32
- data/vendor/board-maps/yaml/Lion_Bit_Dev_Board.yml +0 -18
- data/vendor/board-maps/yaml/LoPy.yml +0 -27
- data/vendor/board-maps/yaml/LoPy4.yml +0 -27
- data/vendor/board-maps/yaml/M5STACK_CORES3.yml +0 -8
- data/vendor/board-maps/yaml/M5STACK_Core2.yml +0 -9
- data/vendor/board-maps/yaml/M5STACK_FIRE.yml +0 -10
- data/vendor/board-maps/yaml/M5Stack-Timer-CAM.yml +0 -10
- data/vendor/board-maps/yaml/M5Stack_ATOM.yml +0 -10
- data/vendor/board-maps/yaml/M5Stack_ATOMS3.yml +0 -7
- data/vendor/board-maps/yaml/M5Stack_CoreInk.yml +0 -9
- data/vendor/board-maps/yaml/M5Stack_Core_ESP32.yml +0 -10
- data/vendor/board-maps/yaml/M5Stack_Station.yml +0 -10
- data/vendor/board-maps/yaml/M5Stick_C.yml +0 -10
- data/vendor/board-maps/yaml/MAGTAG29_ESP32S2.yml +0 -21
- data/vendor/board-maps/yaml/MELOPERO_COOKIE_RP2040.yml +0 -48
- data/vendor/board-maps/yaml/MELOPERO_SHAKE_RP2040.yml +0 -48
- data/vendor/board-maps/yaml/METRO_ESP32S2.yml +0 -34
- data/vendor/board-maps/yaml/MGBOT_IOTIK32A.yml +0 -27
- data/vendor/board-maps/yaml/MGBOT_IOTIK32B.yml +0 -27
- data/vendor/board-maps/yaml/MH_ET_LIVE_ESP32DEVKIT.yml +0 -27
- data/vendor/board-maps/yaml/MH_ET_LIVE_ESP32MINIKIT.yml +0 -27
- data/vendor/board-maps/yaml/MICROS2.yml +0 -34
- data/vendor/board-maps/yaml/MOD_WIFI_ESP8266.yml +0 -9
- data/vendor/board-maps/yaml/Metro.yml +0 -8
- data/vendor/board-maps/yaml/NANO32.yml +0 -27
- data/vendor/board-maps/yaml/NANO_RP2040_CONNECT.yml +0 -35
- data/vendor/board-maps/yaml/NEBULAS3.yml +0 -33
- data/vendor/board-maps/yaml/NEKOSYSTEMS_BL2040_MINI.yml +0 -48
- data/vendor/board-maps/yaml/NULLBITS_BIT_C_PRO.yml +0 -48
- data/vendor/board-maps/yaml/Node32s.yml +0 -27
- data/vendor/board-maps/yaml/NodeMCU_32S.yml +0 -27
- data/vendor/board-maps/yaml/ODROID_ESP32.yml +0 -10
- data/vendor/board-maps/yaml/ONEHORSE_ESP32_DEV.yml +0 -24
- data/vendor/board-maps/yaml/OROCA_EDUBOT.yml +0 -33
- data/vendor/board-maps/yaml/PIMORONI_PGA2040.yml +0 -48
- data/vendor/board-maps/yaml/PROS3.yml +0 -28
- data/vendor/board-maps/yaml/PYCOM_GPY.yml +0 -27
- data/vendor/board-maps/yaml/Piranha.yml +0 -16
- data/vendor/board-maps/yaml/Pocket32.yml +0 -27
- data/vendor/board-maps/yaml/QUANTUM.yml +0 -26
- data/vendor/board-maps/yaml/RASPBERRY_PI_PICO.yml +0 -48
- data/vendor/board-maps/yaml/RASPBERRY_PI_PICO_W.yml +0 -48
- data/vendor/board-maps/yaml/REDPILL_ESP32S3.yml +0 -32
- data/vendor/board-maps/yaml/RMP.yml +0 -33
- data/vendor/board-maps/yaml/SAMD_CIRCUITPLAYGROUND_EXPRESS.yml +0 -12
- data/vendor/board-maps/yaml/SAMD_MKR1000.yml +0 -20
- data/vendor/board-maps/yaml/SAMD_MKRFox1200.yml +0 -19
- data/vendor/board-maps/yaml/SAMD_MKRGSM1400.yml +0 -15
- data/vendor/board-maps/yaml/SAMD_MKRNB1500.yml +0 -15
- data/vendor/board-maps/yaml/SAMD_MKRVIDOR4000.yml +0 -19
- data/vendor/board-maps/yaml/SAMD_MKRWAN1300.yml +0 -18
- data/vendor/board-maps/yaml/SAMD_MKRWAN1310.yml +0 -18
- data/vendor/board-maps/yaml/SAMD_MKRWIFI1010.yml +0 -19
- data/vendor/board-maps/yaml/SAMD_MKRZERO.yml +0 -19
- data/vendor/board-maps/yaml/SAMD_NANO_33_IOT.yml +0 -13
- data/vendor/board-maps/yaml/SAMD_TIAN.yml +0 -15
- data/vendor/board-maps/yaml/SAMD_ZERO.yml +0 -14
- data/vendor/board-maps/yaml/SAM_DUE.yml +0 -26
- data/vendor/board-maps/yaml/SAM_ZERO.yml +0 -15
- data/vendor/board-maps/yaml/SEEED_INDICATOR_RP2040.yml +0 -47
- data/vendor/board-maps/yaml/SEEED_XIAO_RP2040.yml +0 -29
- data/vendor/board-maps/yaml/SOLDERPARTY_RP2040_STAMP.yml +0 -48
- data/vendor/board-maps/yaml/SONOFF_DUALR3.yml +0 -26
- data/vendor/board-maps/yaml/SPARKFUN_PROMICRO_RP2040.yml +0 -48
- data/vendor/board-maps/yaml/SPARKFUN_THINGPLUS_RP2040.yml +0 -48
- data/vendor/board-maps/yaml/STAMP_S3.yml +0 -4
- data/vendor/board-maps/yaml/TAMC_TERMOD_S3.yml +0 -31
- data/vendor/board-maps/yaml/TBEAM_USE_RADIO_SX1262.yml +0 -23
- data/vendor/board-maps/yaml/TBEAM_USE_RADIO_SX1268.yml +0 -23
- data/vendor/board-maps/yaml/TBEAM_USE_RADIO_SX1276.yml +0 -23
- data/vendor/board-maps/yaml/TBEAM_USE_RADIO_SX1278.yml +0 -23
- data/vendor/board-maps/yaml/TBEAM_USE_RADIO_SX1280.yml +0 -23
- data/vendor/board-maps/yaml/TBeam.yml +0 -23
- data/vendor/board-maps/yaml/TINYPICO.yml +0 -26
- data/vendor/board-maps/yaml/TINYS2.yml +0 -33
- data/vendor/board-maps/yaml/TINYS3.yml +0 -25
- data/vendor/board-maps/yaml/TTGO-T-OI-PLUS_DEV.yml +0 -11
- data/vendor/board-maps/yaml/TTGO_LoRa32_V1.yml +0 -28
- data/vendor/board-maps/yaml/TTGO_LoRa32_V2.yml +0 -28
- data/vendor/board-maps/yaml/TTGO_LoRa32_v21new.yml +0 -28
- data/vendor/board-maps/yaml/TTGO_T1.yml +0 -27
- data/vendor/board-maps/yaml/TTGO_T7_V13_Mini32.yml +0 -27
- data/vendor/board-maps/yaml/TTGO_T7_V14_Mini32.yml +0 -27
- data/vendor/board-maps/yaml/TWATCH_2020_V1.yml +0 -10
- data/vendor/board-maps/yaml/TWATCH_2020_V2.yml +0 -10
- data/vendor/board-maps/yaml/TWATCH_2020_V3.yml +0 -10
- data/vendor/board-maps/yaml/TWATCH_BASE.yml +0 -10
- data/vendor/board-maps/yaml/TWatch.yml +0 -10
- data/vendor/board-maps/yaml/Trueverit_ESP32_Universal_IoT_Driver.yml +0 -18
- data/vendor/board-maps/yaml/Trueverit_ESP32_Universal_IoT_Driver_MK_II.yml +0 -18
- data/vendor/board-maps/yaml/UBLOX_NINA_W10.yml +0 -48
- data/vendor/board-maps/yaml/UBLOX_NORA_W10.yml +0 -43
- data/vendor/board-maps/yaml/UPESY_RP2040_DEVKIT.yml +0 -48
- data/vendor/board-maps/yaml/VALTRACK_V4_MFW_ESP32_C3.yml +0 -23
- data/vendor/board-maps/yaml/VALTRACK_V4_VTS_ESP32_C3.yml +0 -23
- data/vendor/board-maps/yaml/VIYALAB_MIZU_RP2040.yml +0 -48
- data/vendor/board-maps/yaml/WATCHY.yml +0 -7
- data/vendor/board-maps/yaml/WATCHY_V10.yml +0 -7
- data/vendor/board-maps/yaml/WATCHY_V15.yml +0 -7
- data/vendor/board-maps/yaml/WATCHY_V20.yml +0 -7
- data/vendor/board-maps/yaml/WAVESHARE_RP2040_LCD_0_96.yml +0 -47
- data/vendor/board-maps/yaml/WAVESHARE_RP2040_LCD_1_28.yml +0 -47
- data/vendor/board-maps/yaml/WAVESHARE_RP2040_ONE.yml +0 -47
- data/vendor/board-maps/yaml/WAVESHARE_RP2040_PLUS.yml +0 -48
- data/vendor/board-maps/yaml/WAVESHARE_RP2040_ZERO.yml +0 -47
- data/vendor/board-maps/yaml/WESP32.yml +0 -17
- data/vendor/board-maps/yaml/WIDORA_AIR.yml +0 -34
- data/vendor/board-maps/yaml/WIFIDUINO_ESP8266.yml +0 -23
- data/vendor/board-maps/yaml/WIFINFO.yml +0 -20
- data/vendor/board-maps/yaml/WIPY3.yml +0 -27
- data/vendor/board-maps/yaml/WIZNET_5100S_EVB_PICO.yml +0 -48
- data/vendor/board-maps/yaml/WIZNET_5500_EVB_PICO.yml +0 -48
- data/vendor/board-maps/yaml/WIZNET_WIZFI360_EVB_PICO.yml +0 -48
- data/vendor/board-maps/yaml/WT32_ETH01.yml +0 -8
- data/vendor/board-maps/yaml/WiFiduino32S3.yml +0 -27
- data/vendor/board-maps/yaml/WiFiduinoV2.yml +0 -27
- data/vendor/board-maps/yaml/Wifiduino32.yml +0 -40
- data/vendor/board-maps/yaml/XIAO_ESP32C3.yml +0 -22
- data/vendor/board-maps/yaml/XIAO_ESP32S3.yml +0 -36
- data/vendor/board-maps/yaml/YD_RP2040.yml +0 -48
- data/vendor/board-maps/yaml/atmegazero_esp32s2.yml +0 -30
- data/vendor/board-maps/yaml/connaxio_espoir.yml +0 -18
- data/vendor/board-maps/yaml/esp32vn_iot_uno.yml +0 -22
- data/vendor/board-maps/yaml/fm_devkit.yml +0 -15
- data/vendor/board-maps/yaml/heltec_wifi_32_lora_V3.yml +0 -31
- data/vendor/board-maps/yaml/heltec_wifi_kit_32.yml +0 -28
- data/vendor/board-maps/yaml/heltec_wifi_kit_32_V3.yml +0 -32
- data/vendor/board-maps/yaml/heltec_wifi_lora_32.yml +0 -27
- data/vendor/board-maps/yaml/heltec_wifi_lora_32_V2.yml +0 -27
- data/vendor/board-maps/yaml/heltec_wireless_stick.yml +0 -27
- data/vendor/board-maps/yaml/heltec_wireless_stick_LITE.yml +0 -27
- data/vendor/board-maps/yaml/openkb.yml +0 -27
- data/vendor/board-maps/yaml/roboheart_hercules.yml +0 -17
- data/vendor/board-maps/yaml/sensesiot_weizen.yml +0 -26
- data/vendor/board-maps/yaml/uPesy_WROOM.yml +0 -27
- data/vendor/board-maps/yaml/uPesy_WROVER.yml +0 -27
- data/vendor/board-maps/yaml/unphone8.yml +0 -32
- data/vendor/board-maps/yaml/unphone9.yml +0 -32
- data/vendor/board-maps/yaml/wifi_kit_8.yml +0 -15
data/examples/analog_io/input.rb
CHANGED
@@ -1,52 +1,55 @@
|
|
1
1
|
#
|
2
|
-
# This
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
2
|
+
# This example shows how to use your board's analog-to-digital-converter(ADC) pins,
|
3
|
+
# through the AnalogIO::Input class. ADC inputs can be connected to sensors
|
4
|
+
# which produce a variable output voltage, such as light dependent resistors,
|
5
|
+
# or a simple temperature sensor like the TMP36.
|
6
6
|
#
|
7
7
|
require 'bundler/setup'
|
8
8
|
require 'denko'
|
9
9
|
|
10
10
|
board = Denko::Board.new(Denko::Connection::Serial.new)
|
11
|
-
|
12
|
-
|
13
|
-
# Single read
|
14
|
-
#
|
15
|
-
|
16
|
-
|
17
|
-
#
|
18
|
-
#
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
11
|
+
input = Denko::AnalogIO::Input.new(pin: :A0, board: board)
|
12
|
+
|
13
|
+
# Single read that blocks the main thread. When a value is received, the given
|
14
|
+
# code block runs only once, and then the main thread continues.
|
15
|
+
input.read { |value| puts "#{Time.now} Single read #1: #{value}" }
|
16
|
+
|
17
|
+
# Read (poll) the input every half second. This happens in a separate thread,
|
18
|
+
# so sleep the main thread for a while to get some values.
|
19
|
+
# Given code block is added as a callback, and runs every time a value is received.
|
20
|
+
input.poll(0.5) { |value| puts "#{Time.now} Polling: #{value}" }
|
21
|
+
sleep 3
|
22
|
+
|
23
|
+
# Stop polling. Automatically removes the #poll callback.
|
24
|
+
input.stop
|
25
|
+
|
26
|
+
# Listening is similar to polling. The board reads the input and sends the value
|
27
|
+
# every time interval, except it's keeping time. We only send the initial command,
|
28
|
+
# not one for each read. Smaller intervals like 32 milliseconds are possible.
|
29
|
+
# Powers of 2 from 1 to 128 are supported for listener intervals.
|
30
|
+
input.listen(32) { |value| puts "#{Time.now} Listening: #{value}" }
|
27
31
|
sleep 0.5
|
28
32
|
|
29
|
-
# Stop listening. Automatically removes the
|
30
|
-
|
31
|
-
|
32
|
-
# Add a persistent callback.
|
33
|
-
sensor.on_data { |value| puts "#{Time.now} Persistent callback: #{value}" }
|
33
|
+
# Stop listening. Automatically removes the #listen callback.
|
34
|
+
input.stop
|
34
35
|
|
35
|
-
#
|
36
|
-
|
36
|
+
# This adds a persistent callback, which runs no matter how a read happens.
|
37
|
+
# It will not be removed by #stop.
|
38
|
+
input.on_data { |value| puts "#{Time.now} Persistent callback: #{value}" }
|
37
39
|
|
38
|
-
#
|
39
|
-
|
40
|
+
# This is a persistent callback with a custom key.
|
41
|
+
input.on_data(:test) { |value| puts "#{Time.now} Keyed callback: #{value}"}
|
40
42
|
|
41
|
-
#
|
42
|
-
|
43
|
-
sleep 0.5
|
43
|
+
# If we do a single read, the two persistent callbacks, and the block given, should run once each.
|
44
|
+
input.read { |value| puts "#{Time.now} Single read #2: #{value}" }
|
44
45
|
|
45
|
-
#
|
46
|
-
|
46
|
+
# If we listen, the two persistent callbacks, and the block given should run many times.
|
47
|
+
input.listen(8) { |value| puts "#{Time.now } Listening again: #{value}" }
|
48
|
+
sleep 0.125
|
49
|
+
input.stop
|
47
50
|
|
48
51
|
# Remove callbacks keyed with :test.
|
49
|
-
|
52
|
+
input.remove_callbacks(:test)
|
50
53
|
|
51
54
|
# Remove all callbacks.
|
52
|
-
|
55
|
+
input.remove_callbacks
|
data/examples/connection/tcp.rb
CHANGED
@@ -11,7 +11,7 @@ connection = Denko::Connection::TCP.new("192.168.0.77", 3466)
|
|
11
11
|
# connection = Denko::Connection::TCP.new("192.168.1.2", 3466)
|
12
12
|
#
|
13
13
|
board = Denko::Board.new(connection)
|
14
|
-
led = Denko::
|
14
|
+
led = Denko::LED.new(board: board, pin: :LED_BUILTIN)
|
15
15
|
|
16
16
|
[:on, :off].cycle do |switch|
|
17
17
|
led.send(switch)
|
data/examples/display/hd44780.rb
CHANGED
@@ -6,9 +6,9 @@ require 'denko'
|
|
6
6
|
|
7
7
|
board = Denko::Board.new(Denko::Connection::Serial.new)
|
8
8
|
lcd = Denko::Display::HD44780.new board: board,
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
pins: { rs: 8, enable: 9, d4: 4, d5: 5, d6: 6, d7: 7 },
|
10
|
+
cols: 16,
|
11
|
+
rows: 2
|
12
12
|
|
13
13
|
# Bitmap for a custom character. 5 bits wide x 8 high.
|
14
14
|
# Useful for generating these: https://omerk.github.io/lcdchargen/
|
data/examples/display/ssd1306.rb
CHANGED
@@ -21,7 +21,7 @@ board = Denko::Board.new(Denko::Connection::Serial.new)
|
|
21
21
|
# Only give the SDA pin of the I2C bus. SCL (clock) pin must be
|
22
22
|
# connected for it to work, but we don't need to control it.
|
23
23
|
#
|
24
|
-
bus = Denko::I2C::Bus.new(board: board, pin:
|
24
|
+
bus = Denko::I2C::Bus.new(board: board, pin: :SDA)
|
25
25
|
oled = Denko::Display::SSD1306.new(bus: bus, rotate: true)
|
26
26
|
canvas = oled.canvas
|
27
27
|
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Denko
|
2
|
+
module AnalogIO
|
3
|
+
class ADS1115
|
4
|
+
include I2C::Peripheral
|
5
|
+
include ADS111X
|
6
|
+
|
7
|
+
# Config register values on startup. MSB-first.
|
8
|
+
# Matches datasheet, except MSB bit 7 unset to avoid conversion start.
|
9
|
+
# Same as: [0x05, 0x83] or [5, 131]
|
10
|
+
CONFIG_STARTUP = [0b00000101, 0b10000011]
|
11
|
+
|
12
|
+
# Base config bytes to mask settings into. Not same as startup config.
|
13
|
+
# MSB bits 0 and 7 set to enable single-shot mode.
|
14
|
+
# LSB bits 0 and 1 set to disable comparator.
|
15
|
+
BASE_MSB = 0b10000001
|
16
|
+
BASE_LSB = 0b00000011
|
17
|
+
|
18
|
+
# Register addresses.
|
19
|
+
CONFIG_ADDRESS = 0b01
|
20
|
+
CONVERSION_ADDRESS = 0b00
|
21
|
+
|
22
|
+
def before_initialize(options={})
|
23
|
+
@i2c_address = 0x48
|
24
|
+
@i2c_frequency = 400_000
|
25
|
+
super(options)
|
26
|
+
end
|
27
|
+
|
28
|
+
def after_initialize(options={})
|
29
|
+
super(options)
|
30
|
+
|
31
|
+
# Mutex and variables for BoardProxy behavior.
|
32
|
+
@mutex = Mutex.new
|
33
|
+
@active_pin = nil
|
34
|
+
@active_gain = nil
|
35
|
+
|
36
|
+
# Set register bytes to default and write to device.
|
37
|
+
@config_register = CONFIG_STARTUP.dup
|
38
|
+
i2c_write [CONFIG_ADDRESS] + @config_register
|
39
|
+
|
40
|
+
# Enable BoardProxy callbacks.
|
41
|
+
enable_proxy
|
42
|
+
end
|
43
|
+
|
44
|
+
def _read(config)
|
45
|
+
# Write config register to start reading.
|
46
|
+
i2c_write [CONFIG_ADDRESS] + config
|
47
|
+
|
48
|
+
# Sleep the right amount of time for conversion, based on sample rate bits.
|
49
|
+
sleep WAIT_TIMES[config[1] >> 5]
|
50
|
+
|
51
|
+
# Read the result, triggering callbacks.
|
52
|
+
i2c_read(CONVERSION_ADDRESS, 2)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Readings are 2 bytes big-endian.
|
56
|
+
def pre_callback_filter(bytes)
|
57
|
+
bytes.pack("C*").unpack("s>")[0]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -2,55 +2,18 @@ module Denko
|
|
2
2
|
module AnalogIO
|
3
3
|
class ADS1118
|
4
4
|
include SPI::Peripheral
|
5
|
-
include
|
6
|
-
include Behaviors::Threaded
|
5
|
+
include ADS111X
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
0.0000625, # 0b010 2.048 V (default)
|
12
|
-
0.00003125, # 0b011 1.024 V
|
13
|
-
0.000015625, # 0b100 0.512 V
|
14
|
-
0.0000078125, # 0b101 0.256 V
|
15
|
-
0.0000078125, # 0b110 0.256 V
|
16
|
-
0.0000078125, # 0b111 0.256 V
|
17
|
-
]
|
18
|
-
PGA_RANGE = (0..7).to_a
|
19
|
-
|
20
|
-
# Sample rate bitmask maps to sample time in seconds.
|
21
|
-
SAMPLE_TIMES = [ # Bitmask
|
22
|
-
0.125, # 0b000
|
23
|
-
0.0625, # 0b001
|
24
|
-
0.03125, # 0b010
|
25
|
-
0.015625, # 0b011
|
26
|
-
0.0078125, # 0b100 (default)
|
27
|
-
0.004, # 0b101
|
28
|
-
0.002105263, # 0b110
|
29
|
-
0.00116279, # 0b111
|
30
|
-
]
|
31
|
-
SAMPLE_RATE_RANGE = (0..7).to_a
|
32
|
-
|
33
|
-
# Wait times need to be slightly longer than the actual sample times.
|
34
|
-
WAIT_TIMES = SAMPLE_TIMES.map { |time| time + 0.0005 }
|
35
|
-
|
36
|
-
# Mux bits map to array of form [positive input, negative input].
|
37
|
-
MUX_SETTINGS = {
|
38
|
-
0b000 => [0, 1],
|
39
|
-
0b001 => [0, 3],
|
40
|
-
0b010 => [1, 3],
|
41
|
-
0b011 => [2, 3],
|
42
|
-
0b100 => [0, nil],
|
43
|
-
0b101 => [1, nil],
|
44
|
-
0b110 => [2, nil],
|
45
|
-
0b111 => [3, nil],
|
46
|
-
}
|
47
|
-
|
48
|
-
# Config register values on startup.
|
49
|
-
CONFIG_DEFAULT = [0x05, 0x8B]
|
7
|
+
# Config register values on startup. MSB-first.
|
8
|
+
# Matches datasheet. Same as: [0x05, 0x8B] or [5, 139]
|
9
|
+
CONFIG_STARTUP = [0b00000101, 0b10001011]
|
50
10
|
|
51
11
|
# Base config bytes to mask settings into. Not same as default.
|
12
|
+
# MSB bits 0 and 7 set to enable single-shot mode.
|
13
|
+
# LSB bit 3 set to enable pullup resistor on MISO pin.
|
14
|
+
# LSB bit 1 set to flag valid data in the NOP bits.
|
52
15
|
BASE_MSB = 0b10000001
|
53
|
-
BASE_LSB =
|
16
|
+
BASE_LSB = 0b00001010
|
54
17
|
|
55
18
|
def after_initialize(options={})
|
56
19
|
super(options)
|
@@ -64,7 +27,7 @@ module Denko
|
|
64
27
|
@active_gain = nil
|
65
28
|
|
66
29
|
# Set register bytes to default and write to device.
|
67
|
-
@config_register =
|
30
|
+
@config_register = CONFIG_STARTUP.dup
|
68
31
|
spi_write(@config_register)
|
69
32
|
|
70
33
|
# Enable BoardProxy callbacks.
|
@@ -82,7 +45,7 @@ module Denko
|
|
82
45
|
spi_read(2)
|
83
46
|
end
|
84
47
|
|
85
|
-
# Pack the 2 bytes back into a string, then unpack as big-endian int16.
|
48
|
+
# Pack the 2 bytes back into a string, then unpack as big-endian signed int16.
|
86
49
|
def pre_callback_filter(message)
|
87
50
|
bytes = message.split(",").map { |b| b.to_i }
|
88
51
|
bytes.pack("C*").unpack("s>")[0]
|
@@ -104,79 +67,6 @@ module Denko
|
|
104
67
|
block.call(temperature) if block_given?
|
105
68
|
return temperature
|
106
69
|
end
|
107
|
-
|
108
|
-
#
|
109
|
-
# BoardProxy behavior so AnalogIO classes can use this as a Board.
|
110
|
-
#
|
111
|
-
include Behaviors::BoardProxy
|
112
|
-
|
113
|
-
# Mimic Board#update, but inside a callback, wrapped by #update.
|
114
|
-
def enable_proxy
|
115
|
-
self.add_callback(:board_proxy) do |value|
|
116
|
-
components.each do |component|
|
117
|
-
if @active_pin == component.pin
|
118
|
-
component.volts_per_bit = PGA_SETTINGS[@active_gain]
|
119
|
-
component.update(value)
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
def analog_read(pin, negative_pin=nil, gain=nil, sample_rate=nil)
|
126
|
-
# Wrap in mutex so calls and callbacks are atomic.
|
127
|
-
@mutex.synchronize do
|
128
|
-
# Default gain and sample rate.
|
129
|
-
gain ||= 0b010
|
130
|
-
sample_rate ||= 0b100
|
131
|
-
|
132
|
-
# Set these for callbacks.
|
133
|
-
@active_pin = pin
|
134
|
-
@active_gain = gain
|
135
|
-
|
136
|
-
# Set gain in upper config register.
|
137
|
-
raise ArgumentError "wrong gain: #{gain.inspect} given for ADS1118" unless PGA_RANGE.include?(gain)
|
138
|
-
@config_register[0] = BASE_MSB | (gain << 1)
|
139
|
-
|
140
|
-
# Set mux bits in upper config register.
|
141
|
-
mux_bits = pins_to_mux_bits(pin, negative_pin)
|
142
|
-
@config_register[0] = @config_register[0] | (mux_bits << 4)
|
143
|
-
|
144
|
-
# Set sample rate in lower config_register.
|
145
|
-
raise ArgumentError "wrong sample_rate: #{sample_rate.inspect} given for ADS1118" unless SAMPLE_RATE_RANGE.include?(gain)
|
146
|
-
@config_register[1] = BASE_LSB | (sample_rate << 5)
|
147
|
-
|
148
|
-
read(@config_register)
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
def pins_to_mux_bits(pin, negative_pin)
|
153
|
-
# Pin 1 is negative input. Only pin 0 can be read.
|
154
|
-
if negative_pin == 1
|
155
|
-
raise ArgumentError, "given pin: #{pin.inspect} cannot be used when pin 1 is negative input, only 0" unless pin == 0
|
156
|
-
return 0b000
|
157
|
-
end
|
158
|
-
|
159
|
-
# Pin 3 is negative input. Pins 0..2 can be read.
|
160
|
-
if negative_pin == 3
|
161
|
-
raise ArgumentError, "given pin: #{pin.inspect} cannot be used when pin 3 is negative input, only 0..2" unless [0,1,2].include? pin
|
162
|
-
return 0b001 + pin
|
163
|
-
end
|
164
|
-
|
165
|
-
# No negative input. Any pin from 0 to 3 can be read.
|
166
|
-
unless negative_pin
|
167
|
-
raise ArgumentError, "given pin: #{pin.inspect} is out of range 0..3" unless [0,1,2,3].include? pin
|
168
|
-
return (0b100 + pin)
|
169
|
-
end
|
170
|
-
|
171
|
-
raise ArgumentError, "only pins 1 and 3 can be used as negative input"
|
172
|
-
end
|
173
|
-
|
174
|
-
def analog_listen(pin, divider=nil)
|
175
|
-
raise StandardError, "ADS1118 does not implement #listen for subcomponents. Use #read or #poll instead"
|
176
|
-
end
|
177
|
-
|
178
|
-
def stop_listener(pin)
|
179
|
-
end
|
180
70
|
end
|
181
71
|
end
|
182
72
|
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
module Denko
|
2
|
+
module AnalogIO
|
3
|
+
module ADS111X
|
4
|
+
#
|
5
|
+
# Functionality shared among the ADS111X class of ADC converters.
|
6
|
+
#
|
7
|
+
include Behaviors::Reader
|
8
|
+
|
9
|
+
PGA_SETTINGS = [ # Bitmask Full scale voltage
|
10
|
+
0.0001875, # 0b000 6.144 V
|
11
|
+
0.000125, # 0b001 4.095 V
|
12
|
+
0.0000625, # 0b010 2.048 V (default)
|
13
|
+
0.00003125, # 0b011 1.024 V
|
14
|
+
0.000015625, # 0b100 0.512 V
|
15
|
+
0.0000078125, # 0b101 0.256 V
|
16
|
+
0.0000078125, # 0b110 0.256 V
|
17
|
+
0.0000078125, # 0b111 0.256 V
|
18
|
+
]
|
19
|
+
PGA_RANGE = (0..7).to_a
|
20
|
+
|
21
|
+
# Sample rate bitmask maps to sample time in seconds.
|
22
|
+
SAMPLE_TIMES = [ # Bitmask
|
23
|
+
0.125, # 0b000
|
24
|
+
0.0625, # 0b001
|
25
|
+
0.03125, # 0b010
|
26
|
+
0.015625, # 0b011
|
27
|
+
0.0078125, # 0b100 (default)
|
28
|
+
0.004, # 0b101
|
29
|
+
0.002105263, # 0b110
|
30
|
+
0.00116279, # 0b111
|
31
|
+
]
|
32
|
+
SAMPLE_RATE_RANGE = (0..7).to_a
|
33
|
+
|
34
|
+
# Wait times need to be slightly longer than the actual sample times.
|
35
|
+
WAIT_TIMES = SAMPLE_TIMES.map { |time| time + 0.0005 }
|
36
|
+
|
37
|
+
# Mux bits map to array of form [positive input, negative input].
|
38
|
+
MUX_SETTINGS = {
|
39
|
+
0b000 => [0, 1],
|
40
|
+
0b001 => [0, 3],
|
41
|
+
0b010 => [1, 3],
|
42
|
+
0b011 => [2, 3],
|
43
|
+
0b100 => [0, nil],
|
44
|
+
0b101 => [1, nil],
|
45
|
+
0b110 => [2, nil],
|
46
|
+
0b111 => [3, nil],
|
47
|
+
}
|
48
|
+
|
49
|
+
#
|
50
|
+
# BoardProxy behavior so AnalogIO classes can use this as a Board.
|
51
|
+
#
|
52
|
+
include Behaviors::BoardProxy
|
53
|
+
|
54
|
+
# Mimic Board#update, but inside a callback, wrapped by #update.
|
55
|
+
def enable_proxy
|
56
|
+
self.add_callback(:board_proxy) do |value|
|
57
|
+
components.each do |component|
|
58
|
+
if @active_pin == component.pin
|
59
|
+
component.volts_per_bit = PGA_SETTINGS[@active_gain]
|
60
|
+
component.update(value)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def analog_read(pin, negative_pin=nil, gain=nil, sample_rate=nil)
|
67
|
+
# Wrap in mutex so calls and callbacks are atomic.
|
68
|
+
@mutex.synchronize do
|
69
|
+
# Default gain and sample rate.
|
70
|
+
gain ||= 0b010
|
71
|
+
sample_rate ||= 0b100
|
72
|
+
|
73
|
+
# Set these for callbacks.
|
74
|
+
@active_pin = pin
|
75
|
+
@active_gain = gain
|
76
|
+
|
77
|
+
# Set gain in upper config register.
|
78
|
+
raise ArgumentError "wrong gain: #{gain.inspect} given for ADS111X" unless PGA_RANGE.include?(gain)
|
79
|
+
@config_register[0] = self.class::BASE_MSB | (gain << 1)
|
80
|
+
|
81
|
+
# Set mux bits in upper config register.
|
82
|
+
mux_bits = pins_to_mux_bits(pin, negative_pin)
|
83
|
+
@config_register[0] = @config_register[0] | (mux_bits << 4)
|
84
|
+
|
85
|
+
# Set sample rate in lower config_register.
|
86
|
+
raise ArgumentError "wrong sample_rate: #{sample_rate.inspect} given for ADS111X" unless SAMPLE_RATE_RANGE.include?(gain)
|
87
|
+
@config_register[1] = self.class::BASE_LSB | (sample_rate << 5)
|
88
|
+
|
89
|
+
read(@config_register)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def pins_to_mux_bits(pin, negative_pin)
|
94
|
+
# Pin 1 is negative input. Only pin 0 can be read.
|
95
|
+
if negative_pin == 1
|
96
|
+
raise ArgumentError, "given pin: #{pin.inspect} cannot be used when pin 1 is negative input, only 0" unless pin == 0
|
97
|
+
return 0b000
|
98
|
+
end
|
99
|
+
|
100
|
+
# Pin 3 is negative input. Pins 0..2 can be read.
|
101
|
+
if negative_pin == 3
|
102
|
+
raise ArgumentError, "given pin: #{pin.inspect} cannot be used when pin 3 is negative input, only 0..2" unless [0,1,2].include? pin
|
103
|
+
return 0b001 + pin
|
104
|
+
end
|
105
|
+
|
106
|
+
# No negative input. Any pin from 0 to 3 can be read.
|
107
|
+
unless negative_pin
|
108
|
+
raise ArgumentError, "given pin: #{pin.inspect} is out of range 0..3" unless [0,1,2,3].include? pin
|
109
|
+
return (0b100 + pin)
|
110
|
+
end
|
111
|
+
|
112
|
+
raise ArgumentError, "only pins 1 and 3 can be used as negative input"
|
113
|
+
end
|
114
|
+
|
115
|
+
def analog_listen(pin, divider=nil)
|
116
|
+
raise StandardError, "ADS111X does not implement #listen for subcomponents. Use #read or #poll instead"
|
117
|
+
end
|
118
|
+
|
119
|
+
def stop_listener(pin)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
data/lib/denko/analog_io.rb
CHANGED
@@ -4,6 +4,8 @@ module Denko
|
|
4
4
|
autoload :Output, "#{__dir__}/analog_io/output"
|
5
5
|
autoload :Potentiometer, "#{__dir__}/analog_io/potentiometer"
|
6
6
|
autoload :Sensor, "#{__dir__}/analog_io/sensor"
|
7
|
+
autoload :ADS111X, "#{__dir__}/analog_io/ads111x"
|
8
|
+
autoload :ADS1115, "#{__dir__}/analog_io/ads1115"
|
7
9
|
autoload :ADS1118, "#{__dir__}/analog_io/ads1118"
|
8
10
|
end
|
9
11
|
end
|
@@ -12,28 +12,29 @@ module Denko
|
|
12
12
|
end
|
13
13
|
|
14
14
|
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
15
|
+
# Take a proc/lambda/method as the first agrument and use it to read.
|
16
|
+
# Arguments are passed through, allowing dynamic read methods to be defined.
|
17
|
+
# Eg. send commands (in args) to a bus, then wait for data read back.
|
18
|
+
#
|
19
|
+
# Block given is added as a one-time callback in the :read key, and
|
20
|
+
# the curent thread waits until data is received. Returns the result of
|
21
|
+
# calling #pre_callback_filter with the data.
|
19
22
|
#
|
20
|
-
|
21
|
-
#
|
22
|
-
def read_using(method, *args, **kwargs, &block)
|
23
|
+
def read_using(reader, *args, **kwargs, &block)
|
23
24
|
add_callback(:read, &block) if block_given?
|
24
25
|
|
25
|
-
|
26
|
+
return_value = nil
|
26
27
|
add_callback(:read) do |filtered_data|
|
27
|
-
|
28
|
+
return_value = filtered_data
|
28
29
|
end
|
29
30
|
|
30
|
-
|
31
|
-
|
31
|
+
reader.call(*args, **kwargs)
|
32
|
+
wait_for_read
|
32
33
|
|
33
|
-
|
34
|
+
return_value
|
34
35
|
end
|
35
36
|
|
36
|
-
def
|
37
|
+
def wait_for_read
|
37
38
|
loop do
|
38
39
|
break if !callbacks[:read]
|
39
40
|
sleep 0.001
|
@@ -10,8 +10,6 @@ module Denko
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def add_component(component)
|
13
|
-
components << component
|
14
|
-
|
15
13
|
if component.respond_to?(:pin) && component.pin.class == Integer
|
16
14
|
unless single_pin_components[component.pin]
|
17
15
|
single_pin_components[component.pin] = component
|
@@ -20,6 +18,8 @@ module Denko
|
|
20
18
|
"already in use by: #{single_pin_components[component.pin]}"
|
21
19
|
end
|
22
20
|
end
|
21
|
+
|
22
|
+
components << component
|
23
23
|
end
|
24
24
|
|
25
25
|
def remove_component(component)
|
data/lib/denko/board/core.rb
CHANGED
@@ -119,7 +119,7 @@ module Denko
|
|
119
119
|
# CMD = 95
|
120
120
|
def set_register_divider(value)
|
121
121
|
unless DIVIDERS.include?(value)
|
122
|
-
raise ArgumentError, "error in divider: #{
|
122
|
+
raise ArgumentError, "error in divider: #{value}. Should be one of: #{DIVIDERS.inspect}"
|
123
123
|
end
|
124
124
|
write Message.encode(command: 95, value: value)
|
125
125
|
end
|
data/lib/denko/board/i2c.rb
CHANGED
@@ -7,10 +7,7 @@ module Denko
|
|
7
7
|
3400000 => 0x03,
|
8
8
|
}
|
9
9
|
|
10
|
-
|
11
|
-
def i2c_limit
|
12
|
-
32
|
13
|
-
end
|
10
|
+
attr_reader :i2c_limit
|
14
11
|
|
15
12
|
def i2c_convert_frequency(freq)
|
16
13
|
# Default to 100 kHz.
|
@@ -1,17 +1,14 @@
|
|
1
1
|
module Denko
|
2
2
|
class Board
|
3
3
|
def show_ws2812(pin, pixel_buffer)
|
4
|
-
length = pixel_buffer.length
|
5
|
-
|
6
4
|
# Settings are blank for now.
|
7
5
|
settings = pack :uint8, [0, 0, 0, 0]
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
packed_pixels = pack :uint8, pixel_buffer
|
8
|
+
|
12
9
|
write_and_halt Message.encode command: 19,
|
13
10
|
pin: pin,
|
14
|
-
value: length,
|
11
|
+
value: pixel_buffer.length,
|
15
12
|
aux_message: settings + packed_pixels
|
16
13
|
end
|
17
14
|
end
|
data/lib/denko/board/map.rb
CHANGED
@@ -6,10 +6,19 @@ module Denko
|
|
6
6
|
|
7
7
|
attr_reader :map
|
8
8
|
|
9
|
+
def substitute_zero_pins
|
10
|
+
["SDA", "SCL", "MOSI", "MISO", "SCK", "SS"].each do |name|
|
11
|
+
symbol = name.to_sym
|
12
|
+
zero_symbol = (name + "0").to_sym
|
13
|
+
@map[symbol] = @map[zero_symbol] if (@map[zero_symbol] && !@map[symbol])
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
9
17
|
def load_map(board_name)
|
10
18
|
if board_name
|
11
19
|
map_path = File.join(MAPS_FOLDER, "#{board_name}.yml")
|
12
20
|
@map = YAML.load_file(map_path)
|
21
|
+
substitute_zero_pins
|
13
22
|
else
|
14
23
|
@map = nil
|
15
24
|
end
|
data/lib/denko/board/servo.rb
CHANGED
@@ -1,15 +1,11 @@
|
|
1
1
|
module Denko
|
2
2
|
class Board
|
3
3
|
# CMD = 10
|
4
|
-
def servo_toggle(pin, value=:off,
|
5
|
-
options[:min] ||= 544
|
6
|
-
options[:max] ||= 2400
|
7
|
-
aux = pack :uint16, [options[:min], options[:max]]
|
8
|
-
|
4
|
+
def servo_toggle(pin, value=:off, min: 544, max: 2400)
|
9
5
|
write Message.encode command: 10,
|
10
6
|
pin: pin,
|
11
7
|
value: (value == :off) ? 0 : 1,
|
12
|
-
aux_message:
|
8
|
+
aux_message: pack(:uint16, [min, max])
|
13
9
|
end
|
14
10
|
|
15
11
|
# CMD = 11
|