denko 0.13.1 → 0.13.2
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 +2 -4
- 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 +60 -0
- data/DEPS_CLI.md +8 -6
- data/DEPS_IDE.md +9 -7
- data/HARDWARE.md +90 -74
- data/README.md +19 -28
- data/benchmarks/i2c_ssd1306_refresh.rb +74 -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/examples/pulse_io/buzzer.rb +40 -0
- 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/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 +6 -14
- 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 +35 -50
- data/src/lib/Denko.cpp +23 -6
- data/src/lib/Denko.h +6 -16
- data/src/lib/DenkoCoreIO.cpp +3 -3
- data/src/lib/DenkoDefines.h +62 -16
- data/src/lib/DenkoEEPROM.cpp +9 -1
- data/src/lib/DenkoI2C.cpp +11 -9
- data/src/lib/DenkoLEDArray.cpp +1 -1
- data/target.yml +35 -1
- data/test/behaviors/reader_test.rb +8 -1
- data/test/board/helper_test.rb +0 -4
- data/test/display/hd44780_test.rb +10 -0
- data/test/led/seven_segment_test.rb +30 -8
- data/test/test_helper.rb +17 -2
- data/vendor/board-maps/.gitmodules +3 -0
- data/vendor/board-maps/BoardMap.h +40 -12
- data/vendor/board-maps/README.md +1 -0
- data/vendor/board-maps/lib/header_parser.rb +30 -5
- data/vendor/board-maps/run.rb +11 -1
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32S3.yml +6 -1
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32S3_NOPSRAM.yml +6 -1
- data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32_V2.yml +5 -1
- data/vendor/board-maps/yaml/ADAFRUIT_QTPY_ESP32S3_N4R2.yml +20 -0
- data/vendor/board-maps/yaml/ADAFRUIT_QTPY_ESP32_PICO.yml +2 -1
- data/vendor/board-maps/yaml/ARTRONSHOP_RP2_NANO.yml +32 -0
- data/vendor/board-maps/yaml/AVR_CIRCUITPLAY.yml +1 -1
- data/vendor/board-maps/yaml/AVR_ESPLORA.yml +1 -1
- data/vendor/board-maps/yaml/AVR_INDUSTRIAL101.yml +1 -1
- data/vendor/board-maps/yaml/AVR_LEONARDO.yml +1 -1
- data/vendor/board-maps/yaml/AVR_LEONARDO_ETH.yml +1 -1
- data/vendor/board-maps/yaml/AVR_LILYPAD_USB.yml +1 -1
- data/vendor/board-maps/yaml/AVR_LININO_ONE.yml +1 -1
- data/vendor/board-maps/yaml/AVR_MICRO.yml +1 -1
- data/vendor/board-maps/yaml/AVR_ROBOT_CONTROL.yml +1 -1
- data/vendor/board-maps/yaml/AVR_ROBOT_MOTOR.yml +1 -1
- data/vendor/board-maps/yaml/AVR_YUN.yml +1 -1
- data/vendor/board-maps/yaml/AVR_YUNMINI.yml +1 -1
- data/vendor/board-maps/yaml/BPI_LEAF_S3.yml +11 -1
- data/vendor/board-maps/yaml/BeeMotionS3.yml +6 -1
- data/vendor/board-maps/yaml/Bee_Motion.yml +3 -0
- data/vendor/board-maps/yaml/Bee_S3.yml +1 -1
- data/vendor/board-maps/yaml/CHALLENGER_2040_WIFI6_BLE_RP2040.yml +42 -0
- data/vendor/board-maps/yaml/CYTRON_MAKER_FEATHER_AIOT_S3.yml +4 -1
- data/vendor/board-maps/yaml/CoreESP32.yml +5 -1
- data/vendor/board-maps/yaml/D1_MINI32.yml +10 -1
- data/vendor/board-maps/yaml/DENKY.yml +10 -1
- data/vendor/board-maps/yaml/DENKY_PICOV3.yml +10 -1
- data/vendor/board-maps/yaml/DENKY_WROOM32.yml +10 -1
- data/vendor/board-maps/yaml/DFROBOT_FIREBEETLE_2_ESP32E.yml +6 -1
- data/vendor/board-maps/yaml/DPU_ESP32.yml +10 -1
- data/vendor/board-maps/yaml/D_Duino_32.yml +9 -1
- data/vendor/board-maps/yaml/ESP32S2_DEV.yml +11 -1
- data/vendor/board-maps/yaml/ESP32S2_THING_PLUS.yml +11 -1
- data/vendor/board-maps/yaml/ESP32S2_USB.yml +11 -1
- data/vendor/board-maps/yaml/ESP32_DEV.yml +10 -1
- data/vendor/board-maps/yaml/ESP32_DEVKIT_LIPO.yml +10 -1
- data/vendor/board-maps/yaml/ESP32_IOT_REDBOARD.yml +10 -1
- data/vendor/board-maps/yaml/ESP32_PICO.yml +10 -1
- data/vendor/board-maps/yaml/ESP32_S3_BOX.yml +4 -1
- data/vendor/board-maps/yaml/ESP32_THING.yml +10 -1
- data/vendor/board-maps/yaml/ESP32_THING_PLUS.yml +4 -1
- data/vendor/board-maps/yaml/ESP32_THING_PLUS_C.yml +4 -1
- data/vendor/board-maps/yaml/ESP32_WROOM_DA.yml +10 -1
- data/vendor/board-maps/yaml/ESP32_WROVER_KIT.yml +10 -1
- data/vendor/board-maps/yaml/ESPECTRO32.yml +10 -1
- data/vendor/board-maps/yaml/ESPea32.yml +10 -1
- data/vendor/board-maps/yaml/ESPino32.yml +10 -1
- data/vendor/board-maps/yaml/FEATHERS2.yml +11 -1
- data/vendor/board-maps/yaml/FEATHERS2NEO.yml +2 -1
- data/vendor/board-maps/yaml/FEATHERS3.yml +3 -0
- data/vendor/board-maps/yaml/FEATHER_ESP32.yml +5 -1
- data/vendor/board-maps/yaml/FRANZININHO_WIFI.yml +11 -1
- data/vendor/board-maps/yaml/FRANZININHO_WIFI_MSC.yml +11 -1
- data/vendor/board-maps/yaml/FROG_ESP32.yml +10 -1
- data/vendor/board-maps/yaml/HEALTHYPI_4.yml +10 -1
- data/vendor/board-maps/yaml/HONEYLEMON.yml +10 -1
- data/vendor/board-maps/yaml/HORNBILL_ESP32_DEV.yml +10 -1
- data/vendor/board-maps/yaml/HORNBILL_ESP32_MINIMA.yml +4 -1
- data/vendor/board-maps/yaml/IMBRIOS_LOGSENS_V1P1.yml +5 -1
- data/vendor/board-maps/yaml/LILYGO_T_DISPLAY_S3.yml +7 -1
- data/vendor/board-maps/yaml/LOLIN32.yml +10 -1
- data/vendor/board-maps/yaml/LOLIN32_LITE.yml +10 -1
- data/vendor/board-maps/yaml/LOLIN_D32.yml +10 -1
- data/vendor/board-maps/yaml/LOLIN_D32_PRO.yml +10 -1
- data/vendor/board-maps/yaml/LOLIN_S2_MINI.yml +11 -1
- data/vendor/board-maps/yaml/LOLIN_S2_PICO.yml +11 -1
- data/vendor/board-maps/yaml/LOLIN_S3.yml +9 -1
- data/vendor/board-maps/yaml/LOLIN_S3_MINI.yml +9 -1
- data/vendor/board-maps/yaml/LOLIN_S3_PRO.yml +9 -1
- data/vendor/board-maps/yaml/LoPy.yml +11 -1
- data/vendor/board-maps/yaml/LoPy4.yml +11 -1
- data/vendor/board-maps/yaml/MAGTAG29_ESP32S2.yml +11 -1
- data/vendor/board-maps/yaml/METRO_ESP32S2.yml +11 -1
- data/vendor/board-maps/yaml/MGBOT_IOTIK32A.yml +10 -1
- data/vendor/board-maps/yaml/MGBOT_IOTIK32B.yml +10 -1
- data/vendor/board-maps/yaml/MH_ET_LIVE_ESP32DEVKIT.yml +10 -1
- data/vendor/board-maps/yaml/MH_ET_LIVE_ESP32MINIKIT.yml +10 -1
- data/vendor/board-maps/yaml/MICROS2.yml +11 -1
- data/vendor/board-maps/yaml/MINIMA.yml +15 -0
- data/vendor/board-maps/yaml/NANO32.yml +10 -1
- data/vendor/board-maps/yaml/Node32s.yml +10 -1
- data/vendor/board-maps/yaml/NodeMCU_32S.yml +10 -1
- data/vendor/board-maps/yaml/ONEHORSE_ESP32_DEV.yml +11 -1
- data/vendor/board-maps/yaml/PIMORONI_PLASMA2040.yml +29 -0
- data/vendor/board-maps/yaml/PORTENTA_C33.yml +28 -0
- data/vendor/board-maps/yaml/PROS3.yml +6 -1
- data/vendor/board-maps/yaml/PYCOM_GPY.yml +11 -1
- data/vendor/board-maps/yaml/Piranha.yml +7 -1
- data/vendor/board-maps/yaml/Pocket32.yml +10 -1
- data/vendor/board-maps/yaml/QUANTUM.yml +10 -1
- data/vendor/board-maps/yaml/REDPILL_ESP32S3.yml +11 -1
- data/vendor/board-maps/yaml/RMP.yml +11 -1
- data/vendor/board-maps/yaml/SAMD_CIRCUITPLAYGROUND_EXPRESS.yml +0 -1
- data/vendor/board-maps/yaml/SAM_DUE.yml +3 -1
- data/vendor/board-maps/yaml/SONOFF_DUALR3.yml +10 -1
- data/vendor/board-maps/yaml/TAMC_TERMOD_S3.yml +11 -1
- data/vendor/board-maps/yaml/TBEAM_USE_RADIO_SX1262.yml +6 -1
- data/vendor/board-maps/yaml/TBEAM_USE_RADIO_SX1268.yml +6 -1
- data/vendor/board-maps/yaml/TBEAM_USE_RADIO_SX1276.yml +6 -1
- data/vendor/board-maps/yaml/TBEAM_USE_RADIO_SX1278.yml +6 -1
- data/vendor/board-maps/yaml/TBEAM_USE_RADIO_SX1280.yml +6 -1
- data/vendor/board-maps/yaml/TBeam.yml +6 -1
- data/vendor/board-maps/yaml/TINYPICO.yml +10 -1
- data/vendor/board-maps/yaml/TINYS2.yml +11 -1
- data/vendor/board-maps/yaml/TTGO_LoRa32_V1.yml +11 -1
- data/vendor/board-maps/yaml/TTGO_LoRa32_V2.yml +11 -1
- data/vendor/board-maps/yaml/TTGO_LoRa32_v21new.yml +11 -1
- data/vendor/board-maps/yaml/TTGO_T1.yml +10 -1
- data/vendor/board-maps/yaml/TTGO_T7_V13_Mini32.yml +10 -1
- data/vendor/board-maps/yaml/TTGO_T7_V14_Mini32.yml +10 -1
- data/vendor/board-maps/yaml/TWATCH_2020_V1.yml +0 -1
- data/vendor/board-maps/yaml/TWATCH_2020_V2.yml +0 -1
- data/vendor/board-maps/yaml/TWATCH_2020_V3.yml +0 -1
- data/vendor/board-maps/yaml/TWATCH_BASE.yml +0 -1
- data/vendor/board-maps/yaml/TWatch.yml +0 -1
- data/vendor/board-maps/yaml/UBLOX_NINA_W10.yml +10 -1
- data/vendor/board-maps/yaml/UNOWIFIR4.yml +17 -0
- data/vendor/board-maps/yaml/WIPY3.yml +11 -1
- data/vendor/board-maps/yaml/XIAO_ESP32S3.yml +2 -1
- data/vendor/board-maps/yaml/connaxio_espoir.yml +7 -1
- data/vendor/board-maps/yaml/esp32vn_iot_uno.yml +10 -1
- data/vendor/board-maps/yaml/heltec_wifi_32_lora_V3.yml +11 -1
- data/vendor/board-maps/yaml/heltec_wifi_kit_32.yml +11 -1
- data/vendor/board-maps/yaml/heltec_wifi_kit_32_V3.yml +11 -1
- data/vendor/board-maps/yaml/heltec_wifi_lora_32.yml +10 -1
- data/vendor/board-maps/yaml/heltec_wifi_lora_32_V2.yml +10 -1
- data/vendor/board-maps/yaml/heltec_wireless_stick.yml +10 -1
- data/vendor/board-maps/yaml/heltec_wireless_stick_LITE.yml +10 -1
- data/vendor/board-maps/yaml/openkb.yml +11 -1
- data/vendor/board-maps/yaml/roboheart_hercules.yml +10 -1
- data/vendor/board-maps/yaml/sensesiot_weizen.yml +10 -1
- data/vendor/board-maps/yaml/uPesy_WROOM.yml +10 -1
- data/vendor/board-maps/yaml/uPesy_WROVER.yml +10 -1
- data/vendor/board-maps/yaml/unphone8.yml +11 -1
- data/vendor/board-maps/yaml/unphone9.yml +11 -1
- metadata +14 -2
data/HARDWARE.md
CHANGED
@@ -3,7 +3,8 @@
|
|
3
3
|
:green_heart: Full support :yellow_heart: Partial support :heart: Planned. No support yet :question: Works in theory. Untested in real hardware.
|
4
4
|
|
5
5
|
### AVR/MegaAVR Based in Arduino Products (and Clones)
|
6
|
-
[![AVR Build Status](https://github.com/denko-rb/denko/actions/workflows/build_avr.yml/badge.svg)](https://github.com/denko-rb/denko/actions/workflows/build_avr.yml)
|
6
|
+
[![AVR Build Status](https://github.com/denko-rb/denko/actions/workflows/build_avr.yml/badge.svg)](https://github.com/denko-rb/denko/actions/workflows/build_avr.yml)
|
7
|
+
[![MegaAVR Build Status](https://github.com/denko-rb/denko/actions/workflows/build_megaavr.yml/badge.svg)](https://github.com/denko-rb/denko/actions/workflows/build_megaavr.yml)
|
7
8
|
|
8
9
|
| Chip | Status | Products | Notes |
|
9
10
|
| :-------- | :------: | :--------------- |------ |
|
@@ -17,13 +18,15 @@
|
|
17
18
|
**Note:** Only USB boards listed. Any board with a supported chip should work, once you can flash it and connect to serial.
|
18
19
|
|
19
20
|
### ARM Based Arduino Products (and Clones)
|
20
|
-
[![SAM3X Build Satus](https://github.com/denko-rb/denko/actions/workflows/build_sam3x.yml/badge.svg)](https://github.com/denko-rb/denko/actions/workflows/build_sam3x.yml)
|
21
|
+
[![SAM3X Build Satus](https://github.com/denko-rb/denko/actions/workflows/build_sam3x.yml/badge.svg)](https://github.com/denko-rb/denko/actions/workflows/build_sam3x.yml)
|
22
|
+
[![SAMD Build Satus](https://github.com/denko-rb/denko/actions/workflows/build_samd.yml/badge.svg)](https://github.com/denko-rb/denko/actions/workflows/build_samd.yml)
|
23
|
+
[![RA4M1 Build Satus](https://github.com/denko-rb/denko/actions/workflows/build_ra4m1.yml/badge.svg)](https://github.com/denko-rb/denko/actions/workflows/build_ra4m1.yml)
|
21
24
|
|
22
25
|
| Chip | Status | Products | Notes |
|
23
26
|
| :-------- | :------: | :--------------- |------ |
|
24
27
|
| ATSAM3X8E | :yellow_heart: | Due | Native USB port. Tone, and IR Out don't work.
|
25
|
-
| ATSAMD21 | :green_heart: | Zero, M0, M0 Pro | Native USB port
|
26
|
-
| RA4M1 | :
|
28
|
+
| ATSAMD21 | :green_heart: | Zero, M0, M0 Pro | Native USB port
|
29
|
+
| RA4M1 | :yellow_heart: | Uno R4 Minima, Uno R4 WiFi | IR Out and WS2812 unsupported. UART & Wi-Fi untested
|
27
30
|
|
28
31
|
### Arduino Accessories
|
29
32
|
|
@@ -33,8 +36,9 @@
|
|
33
36
|
| HDG204 + AT32UC3 | :question: | WiFi Shield | WiFi for Uno. No hardware to test, but compiles
|
34
37
|
| ATWINC1500 | :question: | WiFi Shield 101 | Same as above, high memory use, Mega only
|
35
38
|
|
36
|
-
### Espressif Chips with Built-In
|
37
|
-
[![ESP8266 Build Status](https://github.com/denko-rb/denko/actions/workflows/build_esp8266.yml/badge.svg)](https://github.com/denko-rb/denko/actions/workflows/build_esp8266.yml)
|
39
|
+
### Espressif Chips with Built-In Wi-Fi
|
40
|
+
[![ESP8266 Build Status](https://github.com/denko-rb/denko/actions/workflows/build_esp8266.yml/badge.svg)](https://github.com/denko-rb/denko/actions/workflows/build_esp8266.yml)
|
41
|
+
[![ESP32 Build Status](https://github.com/denko-rb/denko/actions/workflows/build_esp32.yml/badge.svg)](https://github.com/denko-rb/denko/actions/workflows/build_esp32.yml)
|
38
42
|
|
39
43
|
| Chip | Status | Board Tested | Notes |
|
40
44
|
| :-------- | :------: | :--------------- |------ |
|
@@ -52,12 +56,12 @@
|
|
52
56
|
|
53
57
|
| Chip | Status | Board Tested | Notes |
|
54
58
|
| :-------- | :------: | :--------------- |------ |
|
55
|
-
|
|
59
|
+
| RP2040 | :green_heart: | Raspberry Pi Pico (W) | WiFi only on W version. No WS1812 LED support.
|
56
60
|
|
57
61
|
# Single Board Computers
|
58
62
|
|
59
63
|
### Raspberry Pi Single Board Computers
|
60
|
-
**Note:** See the [denko-piboard](https://github.com/denko-rb/denko-piboard) extension to this gem. It uses the peripheral classes from this gem, but swaps out `Board` for `PiBoard`, which uses the Raspberry Pi's built-in
|
64
|
+
**Note:** See the [denko-piboard](https://github.com/denko-rb/denko-piboard) extension to this gem. It uses the peripheral classes from this gem, but swaps out `Board` for `PiBoard`, which uses the Raspberry Pi's built-in GPIO interface. This is still a work-in-progress.
|
61
65
|
|
62
66
|
| Chip | Status | Products | Notes |
|
63
67
|
| :-------- | :------: | :--------------- |------ |
|
@@ -71,114 +75,124 @@
|
|
71
75
|
|
72
76
|
:green_heart: Full support :yellow_heart: Partial support :heart: Planned. No support yet
|
73
77
|
|
74
|
-
###
|
75
|
-
|
76
|
-
| Name | Status | Component Class
|
77
|
-
| :--------------- | :------: |
|
78
|
-
| Digital
|
79
|
-
|
|
80
|
-
|
|
81
|
-
| Analog Out (DAC) | :green_heart: | `AnalogIO::Output`
|
82
|
-
|
|
83
|
-
|
|
78
|
+
### Interfaces
|
79
|
+
|
80
|
+
| Name | Status | HW/SW | Component Class | Notes |
|
81
|
+
| :--------------- | :------: | :--- | :-------------- | :---- |
|
82
|
+
| Digital In | :green_heart: | H | `DigitalIO::Input` | 1ms - 128ms (4ms default) listen, poll, or read
|
83
|
+
| Analog In (ADC) | :green_heart: | H | `AnalogIO::Input` | 1ms - 128ms (16ms default) listen, poll, or read
|
84
|
+
| Digital Out | :green_heart: | H | `DigitalIO::Output` |
|
85
|
+
| Analog Out (DAC) | :green_heart: | H | `AnalogIO::Output` | Only SAM3X, SAMD21, RA4M1, ESP32, ESP32-S2
|
86
|
+
| PWM Out | :green_heart: | H | `PulseIO::PWMOutput` |
|
87
|
+
| Servo/ESC PWM | :green_heart: | H | See Motor table | Uses PWM
|
88
|
+
| Tone Out (Square Wave)| :green_heart: | H | `PulseIO::Buzzer` | Except SAM3X. Uses PWM
|
89
|
+
| I2C | :green_heart: | H | `I2C::Bus` | Predetermined pins from IDE
|
90
|
+
| I2C Bit Bang | :heart: | S | `I2C::BitBang` | Any pins
|
91
|
+
| SPI | :green_heart: | H | `SPI::Bus` | Predetermined pins from IDE
|
92
|
+
| SPI Bit Bang | :green_heart: | S | `SPI::BitBang` | Any pins
|
93
|
+
| UART | :green_heart: | H | `UART::Hardware` | Except Atmega328, ATmega168, RA4M1
|
94
|
+
| UART Bit Bang | :green_heart: | S | `UART::BitBang` | Only ATmega328, ATmega168
|
95
|
+
| Maxim OneWire | :green_heart: | S | `OneWire::Bus` | No overdrive
|
96
|
+
| Infrared Emitter | :green_heart: | S | `PulseIO::IRTransmitter` | Except RA4M1
|
97
|
+
| Infrared Receiver | :heart: | S | `PulseIO::IRReceiver` | Doable with existing library
|
98
|
+
| WS2812 | :green_heart: | S | See LED table | Except RP2040
|
99
|
+
| ESP32-PCNT | :heart: | H | - | Only ESP32. Pulse counter (for encoders)
|
100
|
+
| ESP32-MCPWM | :heart: | H | - | Only ESP32. Motor control PWM
|
84
101
|
|
85
102
|
**Note:** When listening, the board checks the pin's value every **_2^n_** milliseconds (**_n_** from **_0_** to **_7_**), without further commands.
|
86
103
|
Polling and reading follow a call and response pattern.
|
87
104
|
|
88
|
-
###
|
89
|
-
|
90
|
-
| Name | Status | SW/HW | Component Class | Notes |
|
91
|
-
| :--------------- | :------: | :-------- | :--------------- |------ |
|
92
|
-
| I2C | :green_heart: | Hardware | `I2C::Bus` | Hardware I2C on predefined pins
|
93
|
-
| SPI | :green_heart: | Hardware | `SPI::Bus` | Hardware SPI on prefedined pins
|
94
|
-
| SPI Bit Bang | :green_heart: | Software | `SPI::BitBang` | Bit Bang SPI on any pins
|
95
|
-
| UART | :green_heart: | Hardware | `UART::Hardware` | R/W support for UART1..3 when available
|
96
|
-
| UART Bit Bang | :green_heart: | Software | `UART::BitBang` | R/W support for a single UART. Only ATmega chips
|
97
|
-
| Maxim OneWire | :green_heart: | Software | `OneWire::Bus` | No overdrive support
|
98
|
-
| Infrared Emitter | :green_heart: | Software | `PulseIO::IRTransmitter` | Library on Board
|
99
|
-
| Infrared Receiver| :heart: | Software | `PulseIO::IRReceiver` | Doable with existing library
|
100
|
-
|
101
|
-
### Generic Peripherals
|
105
|
+
### Basic Input/Output
|
102
106
|
|
103
107
|
| Name | Status | Interface | Component Class | Notes |
|
104
108
|
| :--------------- | :------: | :-------- | :--------------- |------ |
|
105
|
-
| Board EEPROM | :green_heart: | Built-In | `EEPROM::BuiltIn` | Not all boards have EEPROM
|
106
|
-
| Led | :green_heart: | Digi/Ana Out | `LED::Base` |
|
107
|
-
| RGBLed | :green_heart: | Digi/Ana Out | `LED::RGB` |
|
108
|
-
| Relay | :green_heart: | Digital Out | `DigitalIO::Relay` |
|
109
|
-
| 7 Segment Display| :yellow_heart: | Digital Out | `LED::SevenSegment` | No decimal point
|
110
109
|
| Button | :green_heart: | Digital In | `DigitalIO::Button` |
|
111
110
|
| Rotary Encoder | :green_heart: | Digital In | `DigitalIO::RotaryEncoder` | Listens every 1ms
|
112
|
-
| PIR Sensor | :yellow_heart: | Digital In | `DigitalIO::Input` | Needs class. HC-SR501
|
113
|
-
| Analog Sensor | :green_heart: | Analog In | `AnalogIO::Sensor` |
|
114
111
|
| Potentiometer | :green_heart: | Analog In | `AnalogIO::Potentiometer` | Smoothing on by default
|
115
|
-
|
|
116
|
-
| Input Register | :green_heart: | SPI | `SPI::InputRegister` | Tested on CD4021B
|
117
|
-
| Output Register | :green_heart: | SPI | `SPI::OutputRegister` | Tested on 74HC595
|
118
|
-
|
119
|
-
**Note:** Most Digital In and Out peripherals can be used seamlessley through Input and Output Registers respectively.
|
112
|
+
| Relay | :green_heart: | Digital Out | `DigitalIO::Relay` |
|
120
113
|
|
121
|
-
###
|
114
|
+
### LEDs
|
122
115
|
|
123
|
-
| Name
|
124
|
-
| :---------------
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
116
|
+
| Name | Status | Interface | Component Class | Notes |
|
117
|
+
| :--------------- | :------: | :-------- | :--------------- |------ |
|
118
|
+
| LED | :green_heart: | Digi/Ana Out | `LED::Base` |
|
119
|
+
| RGB LED | :green_heart: | Digi/Ana Out | `LED::RGB` |
|
120
|
+
| 7 Segment Display | :yellow_heart: | Digital Out | `LED::SevenSegment` | No decimal point
|
121
|
+
| TM1637 | :heart: | BitBang SPI | `LED::TM1637` | 4x 7 Segment + Colon
|
122
|
+
| Neopixel / WS2812B | :yellow_heart: | Adafruit Library | `LED::WS2812` | Not working on RP2040
|
123
|
+
| Dotstar / APA102 | :green_heart: | SPI | `LED::APA102` |
|
129
124
|
|
130
125
|
### Displays
|
131
126
|
|
132
127
|
| Name | Status | Interface | Component Class | Notes |
|
133
128
|
| :--------------- | :------: | :-------- | :--------------- |------ |
|
134
|
-
| HD44780 LCD | :green_heart: | Digital Out, Output Register | `Display::HD44780` |
|
129
|
+
| HD44780 LCD | :green_heart: | Digital Out, Output Register | `Display::HD44780` |
|
135
130
|
| SSD1306 OLED | :yellow_heart: | I2C | `Display::SSD1306` | 1 font, some graphics
|
136
131
|
|
137
|
-
###
|
132
|
+
### Sound
|
133
|
+
|
134
|
+
| Name | Status | Interface | Component Class | Notes |
|
135
|
+
| :--------------- | :------: | :-------- | :--------------- |------ |
|
136
|
+
| Piezo Buzzer | :green_heart: | Tone Out | `PulseIO::Buzzer` | Frequency > 30Hz
|
137
|
+
|
138
|
+
### Motors / Motor Drivers
|
138
139
|
|
139
|
-
| Name
|
140
|
-
| :---------------
|
141
|
-
|
|
142
|
-
|
|
140
|
+
| Name | Status | Interface | Component Class | Notes |
|
141
|
+
| :--------------- | :------: | :-------- | :--------------- |------ |
|
142
|
+
| Generic Hobby Servo | :green_heart: | Servo/ESC PWM | `Motor::Servo` | Max depends on PWM channel count
|
143
|
+
| Generic ESC | :yellow_heart: | Servo/ESC PWM | `Motor::Servo` | Works. Needs its own class.
|
144
|
+
| L298N | :green_heart: | Digi + PWM Out | `Motor::L298` | H-Bridge DC motor driver
|
145
|
+
| A3967 | :green_heart: | Digital Out | `Motor::Stepper` | 1ch microstepper (EasyDriver)
|
146
|
+
| PCA9685 | :heart: | I2C | `PulseIO::PCA9685` | 16ch 12-bit PWM for servo or LED
|
143
147
|
|
144
148
|
### I/O Expansion
|
145
149
|
|
146
150
|
| Name | Status | Interface | Component Class | Notes |
|
147
151
|
| :--------------- | :------: | :-------- | :--------------- |------ |
|
152
|
+
| Input Register | :green_heart: | SPI | `SPI::InputRegister` | Tested on CD4021B
|
153
|
+
| Output Register | :green_heart: | SPI | `SPI::OutputRegister`| Tested on 74HC595
|
148
154
|
| PCF8574 Expander | :heart: | I2C | `DigitalIO::PCF8574` | 8ch bi-directional digital I/O
|
149
|
-
|
|
150
|
-
|
|
155
|
+
| ADS1100 ADC | :heart: | I2C | `AnalogIO::ADS1100` | 15-bit +/- 1ch ADC
|
156
|
+
| ADS1115 ADC | :green_heart: | I2C | `AnalogIO::ADS1115` | 15-bit +/- 4ch ADC. Comparator not implemented.
|
157
|
+
| ADS1118 ADC | :green_heart: | SPI | `AnalogIO::ADS1118` | 15-bit +/- 4ch ADC + temperature
|
151
158
|
| PCF8591 ADC/DAC | :heart: | I2C | `AnalogIO::PCF8591` | 4ch ADC + 1ch DAC, 8-bit resolution
|
159
|
+
| MCP4725 DAC | :heart: | I2C | `AnalogIO::MCP4275` | 1ch 12-bit DAC
|
152
160
|
|
153
161
|
### Environmental Sensors
|
154
162
|
|
155
163
|
| Name | Status | Interface | Component Class | Notes |
|
156
164
|
| :--------------- | :------: | :-------- | :--------------- |------ |
|
157
|
-
| DHT 11/21/22 | :green_heart: | Digi In/Out | `Sensor::DHT` | Temp/RH
|
158
165
|
| DS18B20 | :green_heart: | OneWire | `Sensor::DS18B20` | Temp
|
166
|
+
| DHT 11/21/22 | :green_heart: | Digi In/Out | `Sensor::DHT` | Temp/RH
|
167
|
+
| SHT30 | :heart: | I2C | `Sensor::SHT30` | Temp/RH
|
168
|
+
| QMP6988 | :heart: | I2C | `Sensor::QMP6988` | Pressure
|
159
169
|
| BME280 | :green_heart: | I2C | `Sensor::BME280` | Temp/RH/Press
|
160
170
|
| BMP280 | :green_heart: | I2C | `Sensor::BMP280` | Temp/Press
|
161
|
-
| HTU21D | :green_heart: | I2C | `Sensor::HTU21D` | Temp/RH.
|
162
|
-
| HTU31D | :
|
171
|
+
| HTU21D | :green_heart: | I2C | `Sensor::HTU21D` | Temp/RH. User register read not implemented.
|
172
|
+
| HTU31D | :green_heart: | I2C | `Sensor::HTU31D` | Temp/RH. Diagnostic read not implemented.
|
163
173
|
| AHT10/15 | :green_heart: | I2C | `Sensor::AHT10` | Temp/RH. Always uses calibrated mode.
|
164
|
-
| AHT20/21/25 | :green_heart: | I2C | `Sensor::AHT20` | Temp/RH. Always uses calibrated mode
|
165
|
-
| MAX31850 | :heart: | OneWire | `Sensor::MAX31850` | Thermocouple Amplifier
|
174
|
+
| AHT20/21/25 | :green_heart: | I2C | `Sensor::AHT20` | Temp/RH. Always uses calibrated mode + CRC.
|
166
175
|
| ENS160 | :heart: | I2C | `Sensor::ENS160` | CO2e/TVOC/AQI
|
167
176
|
| AGS02MA | :heart: | I2C | `Sensor::AGS02MA` | TVOC
|
177
|
+
| MAX31850 | :heart: | OneWire | `Sensor::MAX31850` | Thermocouple Amplifier
|
168
178
|
|
169
179
|
### Light Sensors
|
170
180
|
|
171
|
-
| Name | Status | Interface
|
172
|
-
| :--------------- | :------: | :--------
|
173
|
-
|
|
181
|
+
| Name | Status | Interface | Component Class | Notes |
|
182
|
+
| :--------------- | :------: | :-------- | :--------------- |------ |
|
183
|
+
| BH1750 | :heart: | Digital In | `Sensor::BH1750` | Ambient Light
|
184
|
+
| HC-SR501 | :yellow_heart: | Digital In | `DigitalIO::Input` | PIR. Needs class: `Sensor::HC-SR501`
|
185
|
+
| AS312 | :heart: | I2C | `Sensor::AS312` | PIR
|
186
|
+
| APDS9960 | :heart: | I2C | `Sensor::APDS9960` | Proximity, RGB, Gesture
|
174
187
|
|
175
188
|
### Distance Sensors
|
176
189
|
|
177
|
-
| Name | Status | Interface
|
178
|
-
| :--------------- | :------: | :--------
|
179
|
-
| HC-SR04 | :heart: |
|
180
|
-
|
|
181
|
-
|
|
190
|
+
| Name | Status | Interface | Component Class | Notes |
|
191
|
+
| :--------------- | :------: | :-------- | :--------------- |------ |
|
192
|
+
| HC-SR04 | :heart: | Digi In/Out | `Sensor::HCSR04` | Ultrasonic, 20-4000mm
|
193
|
+
| RCWL-9620 | :heart: | I2C | `Sensor::RCWL9260` | Ultrasonic, 20-4500mm
|
194
|
+
| VL53L0X | :heart: | I2C | `Sensor::VL53L0X` | Laser, 30 - 1000mm
|
195
|
+
| GP2Y0E03 | :heart: | I2C | `Sensor::GP2Y0E03` | Infrared, 40 - 500mm
|
182
196
|
|
183
197
|
### Motion Sensors
|
184
198
|
|
@@ -187,16 +201,18 @@ Polling and reading follow a call and response pattern.
|
|
187
201
|
| ADXL345 | :heart: | I2C | `Sensor::ADXL345` | 3-axis Accelerometer
|
188
202
|
| IT3205 | :heart: | I2C | `Sensor::IT3205` | 3-axis Gyroscope
|
189
203
|
| HMC5883L | :heart: | I2C | `Sensor::HMC5883L` | 3-axis Compass
|
204
|
+
| MPU6886 | :heart: | I2C | `Sensor::MPU6886` | 3-axis Gyro + Accel
|
190
205
|
|
191
|
-
### Real Time
|
206
|
+
### Real Time Clocks
|
192
207
|
|
193
208
|
| Name | Status | Interface | Component Class | Notes |
|
194
209
|
| :--------------- | :------: | :-------- | :--------------- |------ |
|
195
210
|
| DS1302 | :heart: | I2C | `RTC::DS1302` |
|
196
|
-
|
|
211
|
+
| DS3231 | :green_heart: | I2C | `RTC::DS3231` | Alarms not implemented
|
197
212
|
|
198
213
|
### Miscellaneous
|
199
214
|
|
200
215
|
| Name | Status | Interface | Component Class | Notes |
|
201
216
|
| :--------------- | :------: | :-------- | :--------------- |------ |
|
217
|
+
| Board EEPROM | :green_heart: | Built-In | `EEPROM::BuiltIn` | Arduino ARM boards have no EEPROM
|
202
218
|
| MFRC522 | :heart: | SPI/I2C | `DigitalIO::MFRC522` | RFID tag reader / writer
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Denko 0.13.
|
1
|
+
# Denko 0.13.1 [![Test Status](https://github.com/denko-rb/denko/actions/workflows/ruby.yml/badge.svg)](https://github.com/denko-rb/denko/actions/workflows/ruby.yml)
|
2
2
|
### Ruby Meets Microcontrollers
|
3
3
|
Denko gives you a high-level Ruby interface to low-level hardware, without writing microcontroller code. Use LEDs, buttons, sensors and more, just as easily as any Ruby object:
|
4
4
|
|
@@ -14,35 +14,31 @@ button.down do
|
|
14
14
|
end
|
15
15
|
```
|
16
16
|
|
17
|
-
Denko doesn't run Ruby on the microcontroller (see [mruby-denko](#mruby-denko)
|
17
|
+
Denko doesn't run Ruby on the microcontroller (see [mruby-denko](#mruby-denko)). It runs custom Arduino firmware to expose its I/O interfaces over a socket. You run Ruby on your computer and talk to it. The microcontroller, and anything connected to it, map directly to Ruby objects. You get to think about your hardware and appplication logic, not everything in between.
|
18
18
|
|
19
|
-
High-level abstraction in Ruby makes hardware classes easy to implement, with intuitive interfaces. They multitask a single core microcontroller, with thread-safe state, and callbacks for inputs
|
20
|
-
|
21
|
-
Each peripheral connected to your microcontroller(s) maps to a Ruby object you can use directly. You get to think about your hardware and appplication logic, not everything in between.
|
19
|
+
High-level abstraction in Ruby makes hardware classes easy to implement, with intuitive interfaces. They multitask a single core microcontroller, with thread-safe state, and callbacks for inputs. If you need more I/O, integration is seamless; connect another board and instantiate it in Ruby.
|
22
20
|
|
23
21
|
### Supported Hardware
|
24
22
|
|
25
23
|
Full list of supported mircocontroller platforms, interfaces, and peripherals is located [here](HARDWARE.md).
|
26
24
|
|
27
25
|
##### denko-piboard
|
28
|
-
There's an add-on
|
26
|
+
There's an add-on in development, [denko-piboard](https://github.com/denko-rb/denko-piboard), which supports the Raspberry Pi's built in GPIO pins, as `Denko::PiBoard`, class-compatible with `Denko::Board`. Connect peripherals directly to the Pi, with no microcontroller between, then use the peripheral classes from this gem.
|
29
27
|
|
30
28
|
##### mruby-denko
|
31
29
|
A solo Raspberry Pi (or other small SBC + microcontroller) is a great standalone setup if your project needs the compute power anyway, but what if you don't? Why not run Ruby on the microcontroller itself?
|
32
30
|
|
33
|
-
That's the goal of [mruby-denko](https://github.com/denko-rb/mruby-denko)
|
31
|
+
That's the goal of [mruby-denko](https://github.com/denko-rb/mruby-denko): write mruby on the ESP32, using peripheral classes as close to this gem as possible. Still early in development, so limited features, but already usable.
|
34
32
|
|
35
33
|
## Getting Started
|
36
34
|
|
37
|
-
**Note:** If using
|
35
|
+
**Note:** If using Windows, you can follow the Mac/Linux instructions in WSL, but it is not recommended. Serial (COM port) forwarding isn't working on WSL2, which means you can't communicate with the board. There are workarounds, and it might work on WSL1, but the [RubyInstaller for Windows](https://rubyinstaller.org/) and Arduino IDE are recommended instead. A Linux virtual machine with USB passthrough works too.
|
38
36
|
|
39
37
|
#### 1. Install the Gem
|
40
38
|
```shell
|
41
39
|
gem install denko
|
42
40
|
```
|
43
41
|
|
44
|
-
Before using the microcontroller in Ruby, we need to flash it with the denko firmware (or "sketch" in Arduino lingo). This is needed **once** for each board, but future versions may need reflashing to add functionality.
|
45
|
-
|
46
42
|
#### 2. Install the Arduino IDE OR CLI
|
47
43
|
|
48
44
|
Get the Arduino IDE [here](http://arduino.cc/en/Main/Software) for a graphical interface (recommended for Windows), or use the command line interface from [here](https://github.com/arduino/arduino-cli/releases), or Homebrew.
|
@@ -54,30 +50,22 @@ brew install arduino-cli
|
|
54
50
|
```
|
55
51
|
|
56
52
|
#### 3. Install Arduino Dependencies
|
57
|
-
Denko uses Arduino cores, which
|
53
|
+
Denko uses Arduino cores, which support different microcontrollers, and a few libraries. Install only the ones for your microcontroller, or install everything. There are no conflcits. Instructions:
|
58
54
|
* [Install Dependencies in IDE](DEPS_IDE.md)
|
59
55
|
* [Install Dependencies in CLI](DEPS_CLI.md)
|
60
56
|
|
61
57
|
#### 4. Generate the Arduino Sketch
|
62
58
|
The `denko` command is included with the gem. It will make the Arduino sketch folder for you, and configure it.
|
63
59
|
|
64
|
-
**
|
65
|
-
```shell
|
66
|
-
denko sketch serial
|
67
|
-
```
|
68
|
-
|
69
|
-
**For ESP8266, Serial over USB:**
|
60
|
+
**Example for ESP32 target on both serial and Wi-Fi:**
|
70
61
|
```shell
|
71
|
-
denko sketch serial --target
|
72
|
-
```
|
73
|
-
|
74
|
-
**For ESP8266 or ESP32 over WiFi (2.4Ghz and DHCP Only):**
|
75
|
-
```shell
|
76
|
-
denko sketch wifi --target esp8266 --ssid YOUR_SSID --password YOUR_PASSWORD
|
62
|
+
denko sketch serial --target esp32
|
77
63
|
denko sketch wifi --target esp32 --ssid YOUR_SSID --password YOUR_PASSWORD
|
78
|
-
```
|
79
64
|
|
80
|
-
|
65
|
+
# For more options
|
66
|
+
denko targets
|
67
|
+
```
|
68
|
+
**Note:** Boards flashed with a Wi-Fi or Ethernet sketch will [listen for a TCP connection](examples/connection/tcp.rb), but fall back to Serial when there is none active.
|
81
69
|
|
82
70
|
#### 5a. IDE Flashing
|
83
71
|
|
@@ -89,6 +77,7 @@ denko sketch wifi --target esp32 --ssid YOUR_SSID --password YOUR_PASSWORD
|
|
89
77
|
**Troubleshooting:**
|
90
78
|
* If your serial port is in the list, but the board is wrong, select the serial port anyway, then you will be asked to manually select a board.
|
91
79
|
* If your board doesn't show up at all, make sure it is connected properly. Try disconnecting and reconnecting, use a different USB port or cable, or press the reset button after plugging it in.
|
80
|
+
* Some boards may be in a state where you have to hold their "boot" button while cycling power (reconnect or reset) for them to enter firmware update mode. Eg. Raspberry Pi Pico, ESP32-S2/S3.
|
92
81
|
|
93
82
|
#### 5b. CLI Flashing
|
94
83
|
|
@@ -139,9 +128,11 @@ Most boards have a regular LED on-board. Test it with the [blink](examples/led/b
|
|
139
128
|
|
140
129
|
#### More Examples
|
141
130
|
|
142
|
-
|
143
|
-
|
144
|
-
-
|
131
|
+
**Note:** This gem was renamed from `dino` to `denko`. Some of these examples use the old name.
|
132
|
+
|
133
|
+
- Try [Getting Started with Arduino and Dino](http://tutorials.jumpstartlab.com/projects/arduino/introducing_arduino.html) from [Jumpstart Lab](http://jumpstartlab.com) (_ignore old install instructions_).
|
134
|
+
- An example [rails app](https://github.com/austinbv/dino_rails_example) using Dino and Pusher.
|
135
|
+
- For a Sinatra example, look at the [site](https://github.com/austinbv/dino_cannon) used to shoot the cannon at RubyConf2012.
|
145
136
|
|
146
137
|
## Explanatory Talks
|
147
138
|
|
@@ -0,0 +1,74 @@
|
|
1
|
+
#
|
2
|
+
# Repeatedly writes filled and empty frames to the OLED
|
3
|
+
# Calculates frames per second. Higher is better.
|
4
|
+
#
|
5
|
+
# RESULTS:
|
6
|
+
# July 6 2023 | i7 8700k CPU | CRuby 3.2.1 | 100 frames | 1 Mhz I2C frequency | Average of 3 runs
|
7
|
+
#
|
8
|
+
# Arduino Uno R3 : 5.3 fps (ATmega16u2 UART bridge @ 115200, no I2C level shifter)
|
9
|
+
# Arduino Uno R3 : 7.1 fps (ATmega16u2 UART bridge @ 230400, no I2C level shifter)
|
10
|
+
# Arduino Leonardo : 12.9 fps (native USB, no I2C level shifter)
|
11
|
+
# Arduino Due : 43.0 fps (native USB)
|
12
|
+
# Arduino Due : 7.9 fps (programming USB @ 115200)
|
13
|
+
# Arduino Zero : 28.6 fps (native USB)
|
14
|
+
# Arduino Zero : 9.4 fps (programming USB @ 115200)
|
15
|
+
# Arduino Zero : 13.6 fps (programming USB @ 230400)
|
16
|
+
# ESP8266 (Node MCU) : 9.9 fps (Silicon Labs UART bridge @ 115200)
|
17
|
+
# ESP8266 (Node MCU) : 19.7 fps (Silicon Labs UART bridge @ 230400)
|
18
|
+
# ESP32 V1 : 9.8 fps (Silicon Labs UART bridge @ 115200)
|
19
|
+
# ESP32 V1 : 19.4 fps (Silicon Labs UART bridge @ 230400)
|
20
|
+
# ESP32-S3 : 58.8 fps (native USB)
|
21
|
+
# Raspberry Pi Pico W : 36.4 fps (native USB)
|
22
|
+
#
|
23
|
+
# July 15 2023 | i7 8700k CPU | CRuby 3.2.1 | 100 frames | 1 Mhz I2C frequency | Average of 3 runs
|
24
|
+
#
|
25
|
+
# Arduino Uno R4 : 7.5 fps (native USB @ 115200, 32-byte I2C limit, no I2C level shifter)
|
26
|
+
# Arduino Uno R4 : 7.8 fps (native USB @ 230400, 32-byte I2C limit, no I2C level shifter)
|
27
|
+
#
|
28
|
+
require 'bundler/setup'
|
29
|
+
require 'denko'
|
30
|
+
|
31
|
+
# Settings
|
32
|
+
# Must match speed in the sketch for UART briges. Doesn't matter for native USB.
|
33
|
+
BAUD_RATE = 115_200
|
34
|
+
FRAME_COUNT = 100
|
35
|
+
# Request 1 Mhz I2C frequency. Wire libraries will fall back to fastest available speed.
|
36
|
+
I2C_FREQUENCY = 1_000_000
|
37
|
+
# Use :SDA0 for RP2040
|
38
|
+
I2C_PIN = :SDA
|
39
|
+
|
40
|
+
# Setup
|
41
|
+
board = Denko::Board.new(Denko::Connection::Serial.new(baud: BAUD_RATE))
|
42
|
+
bus = Denko::I2C::Bus.new(board: board, pin: I2C_PIN)
|
43
|
+
oled = Denko::Display::SSD1306.new(bus: bus, rotate: true, i2c_frequency: I2C_FREQUENCY)
|
44
|
+
canvas = oled.canvas
|
45
|
+
|
46
|
+
# Intro
|
47
|
+
canvas.print "SSD1306 Benchmark"
|
48
|
+
oled.draw
|
49
|
+
sleep 1
|
50
|
+
|
51
|
+
# Run
|
52
|
+
start = Time.now
|
53
|
+
(FRAME_COUNT / 2).times do
|
54
|
+
canvas.fill
|
55
|
+
oled.draw
|
56
|
+
canvas.clear
|
57
|
+
oled.draw
|
58
|
+
end
|
59
|
+
board.finish_write
|
60
|
+
finish = Time.now
|
61
|
+
|
62
|
+
# Calculate results
|
63
|
+
fps = FRAME_COUNT / (finish - start)
|
64
|
+
|
65
|
+
# Print to terminal
|
66
|
+
puts "SSD1306 benchmark result: #{fps.round(2)} fps"
|
67
|
+
puts
|
68
|
+
|
69
|
+
# Print to screen
|
70
|
+
canvas.clear
|
71
|
+
canvas.text_cursor = [0,0]
|
72
|
+
canvas.print "#{fps.round(2)} fps"
|
73
|
+
oled.draw
|
74
|
+
board.finish_write
|
@@ -0,0 +1,57 @@
|
|
1
|
+
#
|
2
|
+
# Example using an ADS1115 ADC over the I2C bus.
|
3
|
+
#
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'denko'
|
6
|
+
|
7
|
+
board = Denko::Board.new(Denko::Connection::Serial.new)
|
8
|
+
bus = Denko::I2C::Bus.new(board: board, pin: :SDA)
|
9
|
+
ads = Denko::AnalogIO::ADS1115.new(bus: bus)
|
10
|
+
|
11
|
+
# Helper method so readings look nice.
|
12
|
+
def print_reading(name, raw, voltage)
|
13
|
+
print "#{Time.now.strftime '%Y-%m-%d %H:%M:%S'} - "
|
14
|
+
print "#{name.rjust(18, " ")} | "
|
15
|
+
print "Raw: #{raw.to_s.rjust(6, " ")} | "
|
16
|
+
print "Voltage: "
|
17
|
+
print ("%.10f" % voltage).rjust(13, " ")
|
18
|
+
puts " V"
|
19
|
+
end
|
20
|
+
|
21
|
+
#
|
22
|
+
# Use the ADS1115 directly by writing values to its config registers.
|
23
|
+
# ADS1115#read automatically waits for conversion time and gets the 16-bit reading.
|
24
|
+
# See datasheet for register bitmaps.
|
25
|
+
#
|
26
|
+
# Note: This is the only way to use continuous mode. Subcomponents always use one-shot.
|
27
|
+
#
|
28
|
+
ads.read([0b11000001, 0b10001011]) do |reading|
|
29
|
+
voltage = reading * 0.0001875
|
30
|
+
print_reading("Direct", reading, voltage)
|
31
|
+
end
|
32
|
+
|
33
|
+
#
|
34
|
+
# Or use its BoardProxy interface, adding subcomponents as if it were a Board.
|
35
|
+
# The key adc: can substitute for board: when intializing AnalogIO::Input.
|
36
|
+
# Gain and sample rate bitmasks can be found in the datasheet.
|
37
|
+
#
|
38
|
+
# Input on pin 0, with pin 1 as differential negative input, and 6.144 V full range.
|
39
|
+
diff_input = Denko::AnalogIO::Input.new(adc: ads, pin: 0, negative_pin: 1, gain: 0b000)
|
40
|
+
|
41
|
+
# Input on pin 2 with no negative input (single ended), and 1.024V full range.
|
42
|
+
# Ths one uses a 8 SPS rate, essentially 16x oversampling compared to the default 128.
|
43
|
+
single_input = Denko::AnalogIO::Input.new(adc: ads, pin: 2, gain: 0b011, sample_rate: 0b000)
|
44
|
+
|
45
|
+
# Poll the differential input every second.
|
46
|
+
diff_input.poll(1) do |reading|
|
47
|
+
voltage = reading * diff_input.volts_per_bit
|
48
|
+
print_reading("Differential A1-A0", reading, voltage)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Poll the single ended input every 2 seconds.
|
52
|
+
single_input.poll(2) do |reading|
|
53
|
+
voltage = reading * single_input.volts_per_bit
|
54
|
+
print_reading("Single A2-GN", reading, voltage)
|
55
|
+
end
|
56
|
+
|
57
|
+
sleep
|
@@ -14,12 +14,12 @@ bus = Denko::SPI::Bus.new(board: board)
|
|
14
14
|
# bus = Denko::SPI::BitBang.new(board: board, pins: SPI_BIT_BANG_PINS)
|
15
15
|
|
16
16
|
# Connect chip select/enable pin of the ADS1118 to pin 9.
|
17
|
-
|
17
|
+
ads = Denko::AnalogIO::ADS1118.new(bus: bus, pin: 9)
|
18
18
|
|
19
19
|
# Helper method so readings look nice.
|
20
20
|
def print_reading(name, raw, voltage)
|
21
21
|
print "#{Time.now.strftime '%Y-%m-%d %H:%M:%S'} - "
|
22
|
-
print "#{name.rjust(
|
22
|
+
print "#{name.rjust(18, " ")} | "
|
23
23
|
print "Raw: #{raw.to_s.rjust(6, " ")} | "
|
24
24
|
print "Voltage: "
|
25
25
|
print ("%.10f" % voltage).rjust(13, " ")
|
@@ -30,7 +30,7 @@ end
|
|
30
30
|
# Read the ADS1118 internal temperature sensor.
|
31
31
|
# This always uses the 128 SPS mode, and there is no polling method for it.
|
32
32
|
#
|
33
|
-
temperature =
|
33
|
+
temperature = ads.temperature_read
|
34
34
|
puts "ADS1118 Temperature: #{temperature} \xC2\xB0C"
|
35
35
|
puts
|
36
36
|
|
@@ -41,7 +41,7 @@ puts
|
|
41
41
|
#
|
42
42
|
# Note: This is the only way to use continuous mode. Subcomponents always use one-shot.
|
43
43
|
#
|
44
|
-
|
44
|
+
ads.read([0b10000001, 0b10001011]) do |reading|
|
45
45
|
voltage = reading * 0.0001875
|
46
46
|
print_reading("Direct", reading, voltage)
|
47
47
|
end
|
@@ -49,26 +49,25 @@ end
|
|
49
49
|
#
|
50
50
|
# Or use its BoardProxy interface, adding subcomponents as if it were a Board.
|
51
51
|
# The key adc: can substitute for board: when intializing AnalogIO::Input.
|
52
|
-
#
|
53
52
|
# Gain and sample rate bitmasks can be found in the datasheet.
|
54
53
|
#
|
55
54
|
# Input on pin 0, with pin 1 as differential negative input, and 6.144 V full range.
|
56
|
-
diff_input = Denko::AnalogIO::Input.new(adc:
|
55
|
+
diff_input = Denko::AnalogIO::Input.new(adc: ads, pin: 0, negative_pin: 1, gain: 0b000)
|
57
56
|
|
58
57
|
# Input on pin 2 with no negative input (single ended), and 1.024V full range.
|
59
58
|
# Ths one uses a 8 SPS rate, essentially 16x oversampling compared to the default 128.
|
60
|
-
single_input = Denko::AnalogIO::Input.new(adc:
|
59
|
+
single_input = Denko::AnalogIO::Input.new(adc: ads, pin: 2, gain: 0b011, sample_rate: 0b000)
|
61
60
|
|
62
61
|
# Poll the differential input every second.
|
63
62
|
diff_input.poll(1) do |reading|
|
64
63
|
voltage = reading * diff_input.volts_per_bit
|
65
|
-
print_reading("Differential", reading, voltage)
|
64
|
+
print_reading("Differential A1-A0", reading, voltage)
|
66
65
|
end
|
67
66
|
|
68
67
|
# Poll the single ended input every 2 seconds.
|
69
68
|
single_input.poll(2) do |reading|
|
70
69
|
voltage = reading * single_input.volts_per_bit
|
71
|
-
print_reading("Single", reading, voltage)
|
70
|
+
print_reading("Single A2-GN", reading, voltage)
|
72
71
|
end
|
73
72
|
|
74
73
|
sleep
|
@@ -5,13 +5,15 @@ require 'bundler/setup'
|
|
5
5
|
require 'denko'
|
6
6
|
|
7
7
|
#
|
8
|
-
#
|
9
|
-
#
|
8
|
+
# Arduino Zero: :DAC0 is :A0 is GPIO14
|
9
|
+
# Arduino UNO R4: :DAC is :A0 is GPIO14
|
10
|
+
# ESP32 V1: :DAC0 is GPIO25, :DAC1 is GPIO26, :A4 is GPIO32
|
11
|
+
# ESP32-S2: :DAC0 is GPIO17, :DAC1 is GPIO18, :A4 is GPIO5
|
10
12
|
#
|
11
13
|
# Connect DAC_PIN TO ADC_PIN with a jumper to test.
|
12
14
|
#
|
13
|
-
DAC_PIN =
|
14
|
-
ADC_PIN =
|
15
|
+
DAC_PIN = :DAC0
|
16
|
+
ADC_PIN = :A4
|
15
17
|
|
16
18
|
board = Denko::Board.new(Denko::Connection::Serial.new)
|
17
19
|
dac = Denko::AnalogIO::Output.new(pin: DAC_PIN, board: board)
|