denko 0.13.0 → 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 +98 -75
- data/README.md +48 -59
- 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/examples/sensor/aht20.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/bus_peripheral_addressed.rb +1 -1
- data/lib/denko/behaviors/component.rb +1 -1
- data/lib/denko/behaviors/input_pin.rb +3 -0
- data/lib/denko/behaviors/reader.rb +14 -13
- data/lib/denko/behaviors/single_pin.rb +1 -3
- data/lib/denko/behaviors/state.rb +1 -0
- 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/one_wire/bus.rb +1 -1
- data/lib/denko/one_wire/{bus_enumeration.rb → bus_enumerator.rb} +16 -8
- data/lib/denko/one_wire/helper.rb +1 -1
- data/lib/denko/one_wire.rb +1 -1
- data/lib/denko/pulse_io/ir_transmitter.rb +1 -2
- data/lib/denko/sensor/ds18b20.rb +1 -1
- 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/one_wire/bus_enumerator_test.rb +4 -0
- data/test/one_wire/helper_test.rb +5 -5
- data/test/sensor/ds18b20_test.rb +10 -0
- 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 +15 -3
data/HARDWARE.md
CHANGED
@@ -2,22 +2,32 @@
|
|
2
2
|
|
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
|
-
###
|
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)
|
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)
|
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
|
| :-------- | :------: | :--------------- |------ |
|
10
11
|
| ATmega168 | :green_heart: | Duemilanove, Diecimila, Pro | Features omitted to save memory. `denko targets` for more info.
|
11
|
-
| ATmega328 | :green_heart: | Uno, Nano, Fio, Pro |
|
12
|
+
| ATmega328 | :green_heart: | Uno R3, Uno WiFi, Nano, Fio, Pro |
|
12
13
|
| ATmega32u4 | :green_heart: | Leonardo, Micro, Leonardo ETH, Esplora, LilyPad USB |
|
13
14
|
| ATmega1280 | :green_heart: | Mega |
|
14
15
|
| ATmega2560 | :green_heart: | Mega2560, Arduino Mega ADK |
|
15
16
|
| ATmega4809 | :question: | Nano Every, Uno WiFi Rev2 | No hardware to test, but should work
|
16
|
-
| ATSAM3X8E | :yellow_heart: | Due | Native USB port. Tone, and IR Out don't work.
|
17
|
-
| ATSAMD21 | :green_heart: | Zero, M0, M0 Pro | Native USB port. I2C seems stuck on 100 kHz.
|
18
17
|
|
19
18
|
**Note:** Only USB boards listed. Any board with a supported chip should work, once you can flash it and connect to serial.
|
20
19
|
|
20
|
+
### ARM Based Arduino Products (and Clones)
|
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)
|
24
|
+
|
25
|
+
| Chip | Status | Products | Notes |
|
26
|
+
| :-------- | :------: | :--------------- |------ |
|
27
|
+
| ATSAM3X8E | :yellow_heart: | Due | Native USB port. Tone, and IR Out don't work.
|
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
|
30
|
+
|
21
31
|
### Arduino Accessories
|
22
32
|
|
23
33
|
| Chip | Status | Product | Notes |
|
@@ -26,8 +36,9 @@
|
|
26
36
|
| HDG204 + AT32UC3 | :question: | WiFi Shield | WiFi for Uno. No hardware to test, but compiles
|
27
37
|
| ATWINC1500 | :question: | WiFi Shield 101 | Same as above, high memory use, Mega only
|
28
38
|
|
29
|
-
### Espressif Chips with Built-In
|
30
|
-
[![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)
|
31
42
|
|
32
43
|
| Chip | Status | Board Tested | Notes |
|
33
44
|
| :-------- | :------: | :--------------- |------ |
|
@@ -45,12 +56,12 @@
|
|
45
56
|
|
46
57
|
| Chip | Status | Board Tested | Notes |
|
47
58
|
| :-------- | :------: | :--------------- |------ |
|
48
|
-
|
|
59
|
+
| RP2040 | :green_heart: | Raspberry Pi Pico (W) | WiFi only on W version. No WS1812 LED support.
|
49
60
|
|
50
61
|
# Single Board Computers
|
51
62
|
|
52
63
|
### Raspberry Pi Single Board Computers
|
53
|
-
**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.
|
54
65
|
|
55
66
|
| Chip | Status | Products | Notes |
|
56
67
|
| :-------- | :------: | :--------------- |------ |
|
@@ -64,114 +75,124 @@
|
|
64
75
|
|
65
76
|
:green_heart: Full support :yellow_heart: Partial support :heart: Planned. No support yet
|
66
77
|
|
67
|
-
###
|
68
|
-
|
69
|
-
| Name | Status | Component Class
|
70
|
-
| :--------------- | :------: |
|
71
|
-
| Digital
|
72
|
-
|
|
73
|
-
|
|
74
|
-
| Analog Out (DAC) | :green_heart: | `AnalogIO::Output`
|
75
|
-
|
|
76
|
-
|
|
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
|
77
101
|
|
78
102
|
**Note:** When listening, the board checks the pin's value every **_2^n_** milliseconds (**_n_** from **_0_** to **_7_**), without further commands.
|
79
103
|
Polling and reading follow a call and response pattern.
|
80
104
|
|
81
|
-
###
|
82
|
-
|
83
|
-
| Name | Status | SW/HW | Component Class | Notes |
|
84
|
-
| :--------------- | :------: | :-------- | :--------------- |------ |
|
85
|
-
| I2C | :green_heart: | Hardware | `I2C::Bus` | Hardware I2C on predefined pins
|
86
|
-
| SPI | :green_heart: | Hardware | `SPI::Bus` | Hardware SPI on prefedined pins
|
87
|
-
| SPI Bit Bang | :green_heart: | Software | `SPI::BitBang` | Bit Bang SPI on any pins
|
88
|
-
| UART | :green_heart: | Hardware | `UART::Hardware` | R/W support for UART1..3 when available
|
89
|
-
| UART Bit Bang | :green_heart: | Software | `UART::BitBang` | R/W support for a single UART. Only ATmega chips
|
90
|
-
| Maxim OneWire | :green_heart: | Software | `OneWire::Bus` | No overdrive support
|
91
|
-
| Infrared Emitter | :green_heart: | Software | `PulseIO::IRTransmitter` | Library on Board
|
92
|
-
| Infrared Receiver| :heart: | Software | `PulseIO::IRReceiver` | Doable with existing library
|
93
|
-
|
94
|
-
### Generic Peripherals
|
105
|
+
### Basic Input/Output
|
95
106
|
|
96
107
|
| Name | Status | Interface | Component Class | Notes |
|
97
108
|
| :--------------- | :------: | :-------- | :--------------- |------ |
|
98
|
-
| Board EEPROM | :green_heart: | Built-In | `EEPROM::BuiltIn` | Not all boards have EEPROM
|
99
|
-
| Led | :green_heart: | Digi/Ana Out | `LED::Base` |
|
100
|
-
| RGBLed | :green_heart: | Digi/Ana Out | `LED::RGB` |
|
101
|
-
| Relay | :green_heart: | Digital Out | `DigitalIO::Relay` |
|
102
|
-
| 7 Segment Display| :yellow_heart: | Digital Out | `LED::SevenSegment` | No decimal point
|
103
109
|
| Button | :green_heart: | Digital In | `DigitalIO::Button` |
|
104
110
|
| Rotary Encoder | :green_heart: | Digital In | `DigitalIO::RotaryEncoder` | Listens every 1ms
|
105
|
-
| PIR Sensor | :yellow_heart: | Digital In | `DigitalIO::Input` | Needs class. HC-SR501
|
106
|
-
| Analog Sensor | :green_heart: | Analog In | `AnalogIO::Sensor` |
|
107
111
|
| Potentiometer | :green_heart: | Analog In | `AnalogIO::Potentiometer` | Smoothing on by default
|
108
|
-
|
|
109
|
-
| Input Register | :green_heart: | SPI | `SPI::InputRegister` | Tested on CD4021B
|
110
|
-
| Output Register | :green_heart: | SPI | `SPI::OutputRegister` | Tested on 74HC595
|
112
|
+
| Relay | :green_heart: | Digital Out | `DigitalIO::Relay` |
|
111
113
|
|
112
|
-
|
114
|
+
### LEDs
|
113
115
|
|
114
|
-
|
115
|
-
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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` |
|
122
124
|
|
123
125
|
### Displays
|
124
126
|
|
125
127
|
| Name | Status | Interface | Component Class | Notes |
|
126
128
|
| :--------------- | :------: | :-------- | :--------------- |------ |
|
127
|
-
| HD44780 LCD | :green_heart: | Digital Out, Output Register | `Display::HD44780` |
|
129
|
+
| HD44780 LCD | :green_heart: | Digital Out, Output Register | `Display::HD44780` |
|
128
130
|
| SSD1306 OLED | :yellow_heart: | I2C | `Display::SSD1306` | 1 font, some graphics
|
129
131
|
|
130
|
-
###
|
132
|
+
### Sound
|
131
133
|
|
132
|
-
| Name
|
133
|
-
| :---------------
|
134
|
-
|
|
135
|
-
|
134
|
+
| Name | Status | Interface | Component Class | Notes |
|
135
|
+
| :--------------- | :------: | :-------- | :--------------- |------ |
|
136
|
+
| Piezo Buzzer | :green_heart: | Tone Out | `PulseIO::Buzzer` | Frequency > 30Hz
|
137
|
+
|
138
|
+
### Motors / Motor Drivers
|
139
|
+
|
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
|
136
147
|
|
137
148
|
### I/O Expansion
|
138
149
|
|
139
150
|
| Name | Status | Interface | Component Class | Notes |
|
140
151
|
| :--------------- | :------: | :-------- | :--------------- |------ |
|
152
|
+
| Input Register | :green_heart: | SPI | `SPI::InputRegister` | Tested on CD4021B
|
153
|
+
| Output Register | :green_heart: | SPI | `SPI::OutputRegister`| Tested on 74HC595
|
141
154
|
| PCF8574 Expander | :heart: | I2C | `DigitalIO::PCF8574` | 8ch bi-directional digital I/O
|
142
|
-
|
|
143
|
-
|
|
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
|
144
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
|
145
160
|
|
146
161
|
### Environmental Sensors
|
147
162
|
|
148
163
|
| Name | Status | Interface | Component Class | Notes |
|
149
164
|
| :--------------- | :------: | :-------- | :--------------- |------ |
|
150
|
-
| DHT 11/21/22 | :green_heart: | Digi In/Out | `Sensor::DHT` | Temp/RH
|
151
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
|
152
169
|
| BME280 | :green_heart: | I2C | `Sensor::BME280` | Temp/RH/Press
|
153
170
|
| BMP280 | :green_heart: | I2C | `Sensor::BMP280` | Temp/Press
|
154
|
-
| HTU21D | :green_heart: | I2C | `Sensor::HTU21D` | Temp/RH.
|
155
|
-
| 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.
|
156
173
|
| AHT10/15 | :green_heart: | I2C | `Sensor::AHT10` | Temp/RH. Always uses calibrated mode.
|
157
|
-
| AHT20/21/25 | :green_heart: | I2C | `Sensor::AHT20` | Temp/RH. Always uses calibrated mode
|
158
|
-
| MAX31850 | :heart: | OneWire | `Sensor::MAX31850` | Thermocouple Amplifier
|
174
|
+
| AHT20/21/25 | :green_heart: | I2C | `Sensor::AHT20` | Temp/RH. Always uses calibrated mode + CRC.
|
159
175
|
| ENS160 | :heart: | I2C | `Sensor::ENS160` | CO2e/TVOC/AQI
|
160
176
|
| AGS02MA | :heart: | I2C | `Sensor::AGS02MA` | TVOC
|
177
|
+
| MAX31850 | :heart: | OneWire | `Sensor::MAX31850` | Thermocouple Amplifier
|
161
178
|
|
162
179
|
### Light Sensors
|
163
180
|
|
164
|
-
| Name | Status | Interface
|
165
|
-
| :--------------- | :------: | :--------
|
166
|
-
|
|
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
|
167
187
|
|
168
188
|
### Distance Sensors
|
169
189
|
|
170
|
-
| Name | Status | Interface
|
171
|
-
| :--------------- | :------: | :--------
|
172
|
-
| HC-SR04 | :heart: |
|
173
|
-
|
|
174
|
-
|
|
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
|
175
196
|
|
176
197
|
### Motion Sensors
|
177
198
|
|
@@ -180,16 +201,18 @@ Polling and reading follow a call and response pattern.
|
|
180
201
|
| ADXL345 | :heart: | I2C | `Sensor::ADXL345` | 3-axis Accelerometer
|
181
202
|
| IT3205 | :heart: | I2C | `Sensor::IT3205` | 3-axis Gyroscope
|
182
203
|
| HMC5883L | :heart: | I2C | `Sensor::HMC5883L` | 3-axis Compass
|
204
|
+
| MPU6886 | :heart: | I2C | `Sensor::MPU6886` | 3-axis Gyro + Accel
|
183
205
|
|
184
|
-
### Real Time
|
206
|
+
### Real Time Clocks
|
185
207
|
|
186
208
|
| Name | Status | Interface | Component Class | Notes |
|
187
209
|
| :--------------- | :------: | :-------- | :--------------- |------ |
|
188
210
|
| DS1302 | :heart: | I2C | `RTC::DS1302` |
|
189
|
-
|
|
211
|
+
| DS3231 | :green_heart: | I2C | `RTC::DS3231` | Alarms not implemented
|
190
212
|
|
191
213
|
### Miscellaneous
|
192
214
|
|
193
215
|
| Name | Status | Interface | Component Class | Notes |
|
194
216
|
| :--------------- | :------: | :-------- | :--------------- |------ |
|
217
|
+
| Board EEPROM | :green_heart: | Built-In | `EEPROM::BuiltIn` | Arduino ARM boards have no EEPROM
|
195
218
|
| MFRC522 | :heart: | SPI/I2C | `DigitalIO::MFRC522` | RFID tag reader / writer
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
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
|
|
5
|
-
|
5
|
+
```ruby
|
6
6
|
led.blink 0.5
|
7
7
|
|
8
8
|
lcd.print "Hello World!"
|
@@ -12,66 +12,62 @@ reading = sensor.read
|
|
12
12
|
button.down do
|
13
13
|
puts "Button pressed!"
|
14
14
|
end
|
15
|
-
|
16
|
-
|
17
|
-
Denko doesn't run Ruby on the microcontroller (see the [mruby-dino](#mruby) project). It runs a C++ firmware that exposes as much low-level I/O as possible, so we can use it in Ruby. It becomes a peripheral for your computer.
|
15
|
+
```
|
18
16
|
|
19
|
-
|
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.
|
20
18
|
|
21
|
-
|
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).
|
24
|
+
|
25
|
+
##### denko-piboard
|
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.
|
27
|
+
|
28
|
+
##### mruby-denko
|
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?
|
30
|
+
|
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.
|
26
32
|
|
27
33
|
## Getting Started
|
28
34
|
|
29
|
-
**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.
|
30
36
|
|
31
37
|
#### 1. Install the Gem
|
32
38
|
```shell
|
33
39
|
gem install denko
|
34
40
|
```
|
35
41
|
|
36
|
-
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 denko versions may need reflashing to add functionality.
|
37
|
-
|
38
42
|
#### 2. Install the Arduino IDE OR CLI
|
39
43
|
|
40
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.
|
41
45
|
|
42
46
|
**CLI Installation with Homebrew on Mac or Linux:**
|
43
|
-
|
47
|
+
```shell
|
44
48
|
brew update
|
45
49
|
brew install arduino-cli
|
46
|
-
|
50
|
+
```
|
47
51
|
|
48
52
|
#### 3. Install Arduino Dependencies
|
49
|
-
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:
|
50
54
|
* [Install Dependencies in IDE](DEPS_IDE.md)
|
51
55
|
* [Install Dependencies in CLI](DEPS_CLI.md)
|
52
56
|
|
53
57
|
#### 4. Generate the Arduino Sketch
|
54
58
|
The `denko` command is included with the gem. It will make the Arduino sketch folder for you, and configure it.
|
55
59
|
|
56
|
-
**
|
57
|
-
```shell
|
58
|
-
denko sketch serial
|
59
|
-
````
|
60
|
-
|
61
|
-
**For ESP8266, Serial over USB:**
|
60
|
+
**Example for ESP32 target on both serial and Wi-Fi:**
|
62
61
|
```shell
|
63
|
-
denko sketch serial --target
|
64
|
-
````
|
65
|
-
|
66
|
-
**For ESP8266 or ESP32 over WiFi (2.4Ghz and DHCP Only):**
|
67
|
-
```shell
|
68
|
-
denko sketch wifi --target esp8266 --ssid YOUR_SSID --password YOUR_PASSWORD
|
62
|
+
denko sketch serial --target esp32
|
69
63
|
denko sketch wifi --target esp32 --ssid YOUR_SSID --password YOUR_PASSWORD
|
70
|
-
````
|
71
64
|
|
72
|
-
|
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.
|
73
69
|
|
74
|
-
#### 5a
|
70
|
+
#### 5a. IDE Flashing
|
75
71
|
|
76
72
|
* Connect the board to your computer with a USB cable.
|
77
73
|
* Open the .ino file inside your sketch folder with the IDE.
|
@@ -81,46 +77,47 @@ denko sketch wifi --target esp32 --ssid YOUR_SSID --password YOUR_PASSWORD
|
|
81
77
|
**Troubleshooting:**
|
82
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.
|
83
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.
|
84
81
|
|
85
|
-
#### 5b
|
82
|
+
#### 5b. CLI Flashing
|
86
83
|
|
87
84
|
* The path output by `denko sketch` earlier is your sketch folder. Keep it handy.
|
88
85
|
* Connect the board to your computer with a USB cable.
|
89
86
|
* Check if the CLI recognizes it:
|
90
87
|
|
91
|
-
|
88
|
+
```shell
|
92
89
|
arduino-cli board list
|
93
|
-
|
90
|
+
```
|
94
91
|
|
95
92
|
* Using the Port and FQBN (Fully Qualified Board Name) shown, compile and upload the sketch:
|
96
|
-
|
93
|
+
```shell
|
97
94
|
arduino-cli compile -b YOUR_FQBN YOUR_SKETCH_FOLDER
|
98
95
|
arduino-cli upload -v -p YOUR_PORT -b YOUR_FQBN YOUR_SKETCH_FOLDER
|
99
|
-
|
96
|
+
```
|
100
97
|
|
101
98
|
**Troubleshooting:**
|
102
99
|
* Follow the same steps as the IDE method above. List all FQBNs using:
|
103
|
-
|
100
|
+
```shell
|
104
101
|
arduino-cli board listall
|
105
|
-
|
102
|
+
```
|
106
103
|
|
107
|
-
#### 6
|
104
|
+
#### 6. Test It
|
108
105
|
|
109
|
-
Most boards have a regular LED on-board. Test it with the [blink](examples/led/builtin_blink.rb) example. If you have an on-board WS2812 LED, use the [WS2812 blink](examples/led/ws2812_builtin_blink.rb) example instead. If it starts blinking, you're ready for Ruby!
|
106
|
+
Most boards have a regular LED on-board. Test it with the [blink](examples/led/builtin_blink.rb) example. If you have an on-board WS2812 LED (Neopixel), use the [WS2812 blink](examples/led/ws2812_builtin_blink.rb) example instead. If it starts blinking, you're ready for Ruby!
|
110
107
|
|
111
108
|
## Examples and Tutorials
|
112
109
|
|
113
110
|
#### Tutorial
|
114
111
|
|
115
112
|
- [Here](tutorial) you will find a beginner-friendly tutorial, that goes through the basics, using commented examples and diagrams. Read the comments and try modifying the code. You will need the following:
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
113
|
+
- 1 compatible microcontroller (see [supported hardware](HARDWARE.md))
|
114
|
+
- 1 button or momentary switch
|
115
|
+
- 1 potentiometer (any value)
|
116
|
+
- 1 external RGB LED (4 legs common cathode, not a Neopixel or individually addressable)
|
117
|
+
- 1 external LED (any color, or use one color from the RGB LED)
|
118
|
+
- Current limiting resistors for LEDs
|
119
|
+
- Breadboard
|
120
|
+
- Jumper wires
|
124
121
|
|
125
122
|
**Tip:** Kits are a cost-effective way to get started. They will almost certainly include these parts, plus more, getting you well beyond the tutorial.
|
126
123
|
|
@@ -131,22 +128,14 @@ Most boards have a regular LED on-board. Test it with the [blink](examples/led/b
|
|
131
128
|
|
132
129
|
#### More Examples
|
133
130
|
|
134
|
-
|
135
|
-
|
136
|
-
-
|
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.
|
137
136
|
|
138
137
|
## Explanatory Talks
|
139
138
|
|
140
139
|
- "Arduino the Ruby Way" at RubyConf 2012
|
141
140
|
- [Video by ConFreaks](https://www.youtube.com/watch?v=oUIor6GK-qA)
|
142
141
|
- [Slides on SpeakerDeck](https://speakerdeck.com/austinbv/arduino-the-ruby-way)
|
143
|
-
|
144
|
-
## mruby Port
|
145
|
-
|
146
|
-
A single-board computer plus microcontroller can be a great standalone solution, especially if your project needs the computer anyway. For example, a Raspberry Pi Zero and Arduino Nano combo, running CRuby, Denko and other software.
|
147
|
-
|
148
|
-
But what if you want to be _really_ small? Building on the [mruby-esp32](https://github.com/mruby-esp32/mruby-esp32) project, Denko is being ported to run directly on the ESP32 here: [mruby-dino-template](https://github.com/denko-rb/mruby-dino-template).
|
149
|
-
|
150
|
-
## denko-piboard
|
151
|
-
|
152
|
-
There's an add-on for this gem, [denko-piboard](https://github.com/denko-rb/denko-piboard), in early development, which adds support for the Raspberry Pi's built in GPIO interface as a class-compatible "board". This allows you to connect peripherals directly to the Pi, without a microcontroller, and use the denko peripherals classes as-is.
|
@@ -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
|