denko 0.13.0 → 0.13.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (218) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build_avr.yml +2 -4
  3. data/.github/workflows/build_esp32.yml +2 -3
  4. data/.github/workflows/build_esp8266.yml +2 -3
  5. data/.github/workflows/build_megaavr.yml +2 -4
  6. data/.github/workflows/build_ra4m1.yml +57 -0
  7. data/.github/workflows/build_rp2040.yml +2 -4
  8. data/.github/workflows/build_sam3x.yml +1 -3
  9. data/.github/workflows/build_samd.yml +2 -4
  10. data/CHANGELOG.md +60 -0
  11. data/DEPS_CLI.md +8 -6
  12. data/DEPS_IDE.md +9 -7
  13. data/HARDWARE.md +98 -75
  14. data/README.md +48 -59
  15. data/benchmarks/i2c_ssd1306_refresh.rb +74 -0
  16. data/examples/analog_io/ads1115.rb +57 -0
  17. data/examples/analog_io/ads1118.rb +8 -9
  18. data/examples/analog_io/dac_loopback.rb +6 -4
  19. data/examples/analog_io/input.rb +39 -36
  20. data/examples/connection/tcp.rb +1 -1
  21. data/examples/display/hd44780.rb +3 -3
  22. data/examples/display/ssd1306.rb +1 -1
  23. data/examples/pulse_io/buzzer.rb +40 -0
  24. data/examples/sensor/aht20.rb +1 -1
  25. data/lib/denko/analog_io/ads1115.rb +61 -0
  26. data/lib/denko/analog_io/ads1118.rb +10 -120
  27. data/lib/denko/analog_io/ads111x.rb +123 -0
  28. data/lib/denko/analog_io/output.rb +2 -1
  29. data/lib/denko/analog_io.rb +2 -0
  30. data/lib/denko/behaviors/bus_peripheral_addressed.rb +1 -1
  31. data/lib/denko/behaviors/component.rb +1 -1
  32. data/lib/denko/behaviors/input_pin.rb +3 -0
  33. data/lib/denko/behaviors/reader.rb +14 -13
  34. data/lib/denko/behaviors/single_pin.rb +1 -3
  35. data/lib/denko/behaviors/state.rb +1 -0
  36. data/lib/denko/behaviors/subcomponents.rb +2 -2
  37. data/lib/denko/board/core.rb +1 -1
  38. data/lib/denko/board/i2c.rb +1 -4
  39. data/lib/denko/board/map.rb +9 -0
  40. data/lib/denko/board/servo.rb +2 -6
  41. data/lib/denko/board.rb +32 -20
  42. data/lib/denko/connection/board_uart.rb +3 -3
  43. data/lib/denko/connection/flow_control.rb +10 -2
  44. data/lib/denko/digital_io/output.rb +1 -1
  45. data/lib/denko/display/hd44780.rb +18 -18
  46. data/lib/denko/led/seven_segment.rb +18 -19
  47. data/lib/denko/message.rb +6 -14
  48. data/lib/denko/one_wire/bus.rb +1 -1
  49. data/lib/denko/one_wire/{bus_enumeration.rb → bus_enumerator.rb} +16 -8
  50. data/lib/denko/one_wire/helper.rb +1 -1
  51. data/lib/denko/one_wire.rb +1 -1
  52. data/lib/denko/pulse_io/ir_transmitter.rb +1 -2
  53. data/lib/denko/sensor/ds18b20.rb +1 -1
  54. data/lib/denko/version.rb +1 -1
  55. data/lib/denko_cli/packages.rb +7 -1
  56. data/lib/denko_cli/targets.rb +8 -5
  57. data/lib/denko_cli/usage.txt +8 -4
  58. data/src/denko_ethernet.ino +15 -23
  59. data/src/denko_serial.ino +3 -14
  60. data/src/denko_wifi.ino +35 -50
  61. data/src/lib/Denko.cpp +23 -6
  62. data/src/lib/Denko.h +6 -16
  63. data/src/lib/DenkoCoreIO.cpp +3 -3
  64. data/src/lib/DenkoDefines.h +62 -16
  65. data/src/lib/DenkoEEPROM.cpp +9 -1
  66. data/src/lib/DenkoI2C.cpp +11 -9
  67. data/src/lib/DenkoLEDArray.cpp +1 -1
  68. data/target.yml +35 -1
  69. data/test/behaviors/reader_test.rb +8 -1
  70. data/test/board/helper_test.rb +0 -4
  71. data/test/display/hd44780_test.rb +10 -0
  72. data/test/led/seven_segment_test.rb +30 -8
  73. data/test/one_wire/bus_enumerator_test.rb +4 -0
  74. data/test/one_wire/helper_test.rb +5 -5
  75. data/test/sensor/ds18b20_test.rb +10 -0
  76. data/test/test_helper.rb +17 -2
  77. data/vendor/board-maps/.gitmodules +3 -0
  78. data/vendor/board-maps/BoardMap.h +40 -12
  79. data/vendor/board-maps/README.md +1 -0
  80. data/vendor/board-maps/lib/header_parser.rb +30 -5
  81. data/vendor/board-maps/run.rb +11 -1
  82. data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32S3.yml +6 -1
  83. data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32S3_NOPSRAM.yml +6 -1
  84. data/vendor/board-maps/yaml/ADAFRUIT_FEATHER_ESP32_V2.yml +5 -1
  85. data/vendor/board-maps/yaml/ADAFRUIT_QTPY_ESP32S3_N4R2.yml +20 -0
  86. data/vendor/board-maps/yaml/ADAFRUIT_QTPY_ESP32_PICO.yml +2 -1
  87. data/vendor/board-maps/yaml/ARTRONSHOP_RP2_NANO.yml +32 -0
  88. data/vendor/board-maps/yaml/AVR_CIRCUITPLAY.yml +1 -1
  89. data/vendor/board-maps/yaml/AVR_ESPLORA.yml +1 -1
  90. data/vendor/board-maps/yaml/AVR_INDUSTRIAL101.yml +1 -1
  91. data/vendor/board-maps/yaml/AVR_LEONARDO.yml +1 -1
  92. data/vendor/board-maps/yaml/AVR_LEONARDO_ETH.yml +1 -1
  93. data/vendor/board-maps/yaml/AVR_LILYPAD_USB.yml +1 -1
  94. data/vendor/board-maps/yaml/AVR_LININO_ONE.yml +1 -1
  95. data/vendor/board-maps/yaml/AVR_MICRO.yml +1 -1
  96. data/vendor/board-maps/yaml/AVR_ROBOT_CONTROL.yml +1 -1
  97. data/vendor/board-maps/yaml/AVR_ROBOT_MOTOR.yml +1 -1
  98. data/vendor/board-maps/yaml/AVR_YUN.yml +1 -1
  99. data/vendor/board-maps/yaml/AVR_YUNMINI.yml +1 -1
  100. data/vendor/board-maps/yaml/BPI_LEAF_S3.yml +11 -1
  101. data/vendor/board-maps/yaml/BeeMotionS3.yml +6 -1
  102. data/vendor/board-maps/yaml/Bee_Motion.yml +3 -0
  103. data/vendor/board-maps/yaml/Bee_S3.yml +1 -1
  104. data/vendor/board-maps/yaml/CHALLENGER_2040_WIFI6_BLE_RP2040.yml +42 -0
  105. data/vendor/board-maps/yaml/CYTRON_MAKER_FEATHER_AIOT_S3.yml +4 -1
  106. data/vendor/board-maps/yaml/CoreESP32.yml +5 -1
  107. data/vendor/board-maps/yaml/D1_MINI32.yml +10 -1
  108. data/vendor/board-maps/yaml/DENKY.yml +10 -1
  109. data/vendor/board-maps/yaml/DENKY_PICOV3.yml +10 -1
  110. data/vendor/board-maps/yaml/DENKY_WROOM32.yml +10 -1
  111. data/vendor/board-maps/yaml/DFROBOT_FIREBEETLE_2_ESP32E.yml +6 -1
  112. data/vendor/board-maps/yaml/DPU_ESP32.yml +10 -1
  113. data/vendor/board-maps/yaml/D_Duino_32.yml +9 -1
  114. data/vendor/board-maps/yaml/ESP32S2_DEV.yml +11 -1
  115. data/vendor/board-maps/yaml/ESP32S2_THING_PLUS.yml +11 -1
  116. data/vendor/board-maps/yaml/ESP32S2_USB.yml +11 -1
  117. data/vendor/board-maps/yaml/ESP32_DEV.yml +10 -1
  118. data/vendor/board-maps/yaml/ESP32_DEVKIT_LIPO.yml +10 -1
  119. data/vendor/board-maps/yaml/ESP32_IOT_REDBOARD.yml +10 -1
  120. data/vendor/board-maps/yaml/ESP32_PICO.yml +10 -1
  121. data/vendor/board-maps/yaml/ESP32_S3_BOX.yml +4 -1
  122. data/vendor/board-maps/yaml/ESP32_THING.yml +10 -1
  123. data/vendor/board-maps/yaml/ESP32_THING_PLUS.yml +4 -1
  124. data/vendor/board-maps/yaml/ESP32_THING_PLUS_C.yml +4 -1
  125. data/vendor/board-maps/yaml/ESP32_WROOM_DA.yml +10 -1
  126. data/vendor/board-maps/yaml/ESP32_WROVER_KIT.yml +10 -1
  127. data/vendor/board-maps/yaml/ESPECTRO32.yml +10 -1
  128. data/vendor/board-maps/yaml/ESPea32.yml +10 -1
  129. data/vendor/board-maps/yaml/ESPino32.yml +10 -1
  130. data/vendor/board-maps/yaml/FEATHERS2.yml +11 -1
  131. data/vendor/board-maps/yaml/FEATHERS2NEO.yml +2 -1
  132. data/vendor/board-maps/yaml/FEATHERS3.yml +3 -0
  133. data/vendor/board-maps/yaml/FEATHER_ESP32.yml +5 -1
  134. data/vendor/board-maps/yaml/FRANZININHO_WIFI.yml +11 -1
  135. data/vendor/board-maps/yaml/FRANZININHO_WIFI_MSC.yml +11 -1
  136. data/vendor/board-maps/yaml/FROG_ESP32.yml +10 -1
  137. data/vendor/board-maps/yaml/HEALTHYPI_4.yml +10 -1
  138. data/vendor/board-maps/yaml/HONEYLEMON.yml +10 -1
  139. data/vendor/board-maps/yaml/HORNBILL_ESP32_DEV.yml +10 -1
  140. data/vendor/board-maps/yaml/HORNBILL_ESP32_MINIMA.yml +4 -1
  141. data/vendor/board-maps/yaml/IMBRIOS_LOGSENS_V1P1.yml +5 -1
  142. data/vendor/board-maps/yaml/LILYGO_T_DISPLAY_S3.yml +7 -1
  143. data/vendor/board-maps/yaml/LOLIN32.yml +10 -1
  144. data/vendor/board-maps/yaml/LOLIN32_LITE.yml +10 -1
  145. data/vendor/board-maps/yaml/LOLIN_D32.yml +10 -1
  146. data/vendor/board-maps/yaml/LOLIN_D32_PRO.yml +10 -1
  147. data/vendor/board-maps/yaml/LOLIN_S2_MINI.yml +11 -1
  148. data/vendor/board-maps/yaml/LOLIN_S2_PICO.yml +11 -1
  149. data/vendor/board-maps/yaml/LOLIN_S3.yml +9 -1
  150. data/vendor/board-maps/yaml/LOLIN_S3_MINI.yml +9 -1
  151. data/vendor/board-maps/yaml/LOLIN_S3_PRO.yml +9 -1
  152. data/vendor/board-maps/yaml/LoPy.yml +11 -1
  153. data/vendor/board-maps/yaml/LoPy4.yml +11 -1
  154. data/vendor/board-maps/yaml/MAGTAG29_ESP32S2.yml +11 -1
  155. data/vendor/board-maps/yaml/METRO_ESP32S2.yml +11 -1
  156. data/vendor/board-maps/yaml/MGBOT_IOTIK32A.yml +10 -1
  157. data/vendor/board-maps/yaml/MGBOT_IOTIK32B.yml +10 -1
  158. data/vendor/board-maps/yaml/MH_ET_LIVE_ESP32DEVKIT.yml +10 -1
  159. data/vendor/board-maps/yaml/MH_ET_LIVE_ESP32MINIKIT.yml +10 -1
  160. data/vendor/board-maps/yaml/MICROS2.yml +11 -1
  161. data/vendor/board-maps/yaml/MINIMA.yml +15 -0
  162. data/vendor/board-maps/yaml/NANO32.yml +10 -1
  163. data/vendor/board-maps/yaml/Node32s.yml +10 -1
  164. data/vendor/board-maps/yaml/NodeMCU_32S.yml +10 -1
  165. data/vendor/board-maps/yaml/ONEHORSE_ESP32_DEV.yml +11 -1
  166. data/vendor/board-maps/yaml/PIMORONI_PLASMA2040.yml +29 -0
  167. data/vendor/board-maps/yaml/PORTENTA_C33.yml +28 -0
  168. data/vendor/board-maps/yaml/PROS3.yml +6 -1
  169. data/vendor/board-maps/yaml/PYCOM_GPY.yml +11 -1
  170. data/vendor/board-maps/yaml/Piranha.yml +7 -1
  171. data/vendor/board-maps/yaml/Pocket32.yml +10 -1
  172. data/vendor/board-maps/yaml/QUANTUM.yml +10 -1
  173. data/vendor/board-maps/yaml/REDPILL_ESP32S3.yml +11 -1
  174. data/vendor/board-maps/yaml/RMP.yml +11 -1
  175. data/vendor/board-maps/yaml/SAMD_CIRCUITPLAYGROUND_EXPRESS.yml +0 -1
  176. data/vendor/board-maps/yaml/SAM_DUE.yml +3 -1
  177. data/vendor/board-maps/yaml/SONOFF_DUALR3.yml +10 -1
  178. data/vendor/board-maps/yaml/TAMC_TERMOD_S3.yml +11 -1
  179. data/vendor/board-maps/yaml/TBEAM_USE_RADIO_SX1262.yml +6 -1
  180. data/vendor/board-maps/yaml/TBEAM_USE_RADIO_SX1268.yml +6 -1
  181. data/vendor/board-maps/yaml/TBEAM_USE_RADIO_SX1276.yml +6 -1
  182. data/vendor/board-maps/yaml/TBEAM_USE_RADIO_SX1278.yml +6 -1
  183. data/vendor/board-maps/yaml/TBEAM_USE_RADIO_SX1280.yml +6 -1
  184. data/vendor/board-maps/yaml/TBeam.yml +6 -1
  185. data/vendor/board-maps/yaml/TINYPICO.yml +10 -1
  186. data/vendor/board-maps/yaml/TINYS2.yml +11 -1
  187. data/vendor/board-maps/yaml/TTGO_LoRa32_V1.yml +11 -1
  188. data/vendor/board-maps/yaml/TTGO_LoRa32_V2.yml +11 -1
  189. data/vendor/board-maps/yaml/TTGO_LoRa32_v21new.yml +11 -1
  190. data/vendor/board-maps/yaml/TTGO_T1.yml +10 -1
  191. data/vendor/board-maps/yaml/TTGO_T7_V13_Mini32.yml +10 -1
  192. data/vendor/board-maps/yaml/TTGO_T7_V14_Mini32.yml +10 -1
  193. data/vendor/board-maps/yaml/TWATCH_2020_V1.yml +0 -1
  194. data/vendor/board-maps/yaml/TWATCH_2020_V2.yml +0 -1
  195. data/vendor/board-maps/yaml/TWATCH_2020_V3.yml +0 -1
  196. data/vendor/board-maps/yaml/TWATCH_BASE.yml +0 -1
  197. data/vendor/board-maps/yaml/TWatch.yml +0 -1
  198. data/vendor/board-maps/yaml/UBLOX_NINA_W10.yml +10 -1
  199. data/vendor/board-maps/yaml/UNOWIFIR4.yml +17 -0
  200. data/vendor/board-maps/yaml/WIPY3.yml +11 -1
  201. data/vendor/board-maps/yaml/XIAO_ESP32S3.yml +2 -1
  202. data/vendor/board-maps/yaml/connaxio_espoir.yml +7 -1
  203. data/vendor/board-maps/yaml/esp32vn_iot_uno.yml +10 -1
  204. data/vendor/board-maps/yaml/heltec_wifi_32_lora_V3.yml +11 -1
  205. data/vendor/board-maps/yaml/heltec_wifi_kit_32.yml +11 -1
  206. data/vendor/board-maps/yaml/heltec_wifi_kit_32_V3.yml +11 -1
  207. data/vendor/board-maps/yaml/heltec_wifi_lora_32.yml +10 -1
  208. data/vendor/board-maps/yaml/heltec_wifi_lora_32_V2.yml +10 -1
  209. data/vendor/board-maps/yaml/heltec_wireless_stick.yml +10 -1
  210. data/vendor/board-maps/yaml/heltec_wireless_stick_LITE.yml +10 -1
  211. data/vendor/board-maps/yaml/openkb.yml +11 -1
  212. data/vendor/board-maps/yaml/roboheart_hercules.yml +10 -1
  213. data/vendor/board-maps/yaml/sensesiot_weizen.yml +10 -1
  214. data/vendor/board-maps/yaml/uPesy_WROOM.yml +10 -1
  215. data/vendor/board-maps/yaml/uPesy_WROVER.yml +10 -1
  216. data/vendor/board-maps/yaml/unphone8.yml +11 -1
  217. data/vendor/board-maps/yaml/unphone9.yml +11 -1
  218. 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
- ### Microchip/Atmel Chips in Arduino Products (and Compatibles)
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) [![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) [![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) [![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)
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 WiFi
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) [![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)
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
- | RO2040 | :green_heart: | Raspberry Pi Pico (W) | WiFi only on W version. No WS1812 LED support.
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 GPIPO interface. This is still a work-in-progress.
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
- ### Basic GPIO Interface
68
-
69
- | Name | Status | Component Class | Notes |
70
- | :--------------- | :------: | :------ | :---- |
71
- | Digital Out | :green_heart: | `DigitalIO::Output` | - |
72
- | Digital In | :green_heart: | `DigitalIO::Input` | 1ms - 128ms (4ms default) listen, poll, or read
73
- | PWM Out | :green_heart: | `PulseIO::PWMOutput` |
74
- | Analog Out (DAC) | :green_heart: | `AnalogIO::Output` | On SAM3X, SAMD21 and some ESP32
75
- | Analog In (ADC) | :green_heart: | `AnalogIO::Input` | 1ms - 128ms (16ms default) listen, poll, or read
76
- | Tone Out (Square Wave)| :green_heart: | `PulseIO::Buzzer` | Doesn't work on Due (SAM3X)
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
- ### Advanced Interfaces
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
- | Piezo Buzzer | :green_heart: | Tone Out | `PulseIO::Buzzer` | Frequency > 30Hz
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
- **Note:** Most Digital In and Out peripherals can be used seamlessley through Input and Output Registers respectively.
114
+ ### LEDs
113
115
 
114
- ### Motors / Motor Drivers
115
-
116
- | Name | Status | Interface | Component Class | Notes |
117
- | :--------------- | :------: | :-------- | :--------------- |------ |
118
- | Servo | :green_heart: | PWM + Library | `Motor::Servo` | Maximum of 6 on ATmega168, 16 on ESP32 and 12 otherwise
119
- | L298N | :green_heart: | Digi + PWM Out | `Motor::L298` | H-Bridge DC motor driver
120
- | A3967 | :green_heart: | Digital Out | `Motor::Stepper` | 1ch microstepper (EasyDriver)
121
- | PCA9685 | :heart: | I2C | `PulseIO::PCA9685` | 16ch 12-bit PWM for servo or LED
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
- ### Addressable LEDs
132
+ ### Sound
131
133
 
132
- | Name | Status | Interface | Component Class | Notes |
133
- | :--------------- | :------: | :-------- | :--------------- |------ |
134
- | Neopixel / WS2812B | :yellow_heart: | Adafruit Library | `LED::WS2812` | Not working on RP2040 |
135
- | Dotstar / APA102 | :green_heart: | SPI | `LED::APA102` |
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
- | ADS1115 ADC | :heart: | I2C | `AnalogIO::ADS1115` | 15-bit +/- 4ch ADC
143
- | ADS1118 ADC | :green_heart: | SPI | `AnalogIO::ADS1118` | 15-bit +/- 4ch ADC, and temperature
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. Locks I2C bus during read. No user register read.
155
- | HTU31D | :yellow_heart: | I2C | `Sensor::HTU31D` | Temp/RH. No diagnostic read yet.
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 and CRC.
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 | Component Class | Notes |
165
- | :--------------- | :------: | :-------- | :--------------- |------ |
166
- | APDS9960 | :heart: | I2C | `Sensor::APDS9960`| Proximity, RGB, Gesture
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 | Component Class | Notes |
171
- | :--------------- | :------: | :-------- | :--------------- |------ |
172
- | HC-SR04 | :heart: | Direct | `Sensor::HCSR04` | Ultrasonic, 20-4000mm
173
- | VL53L0X | :heart: | I2C | `Sensor::VL53L0X` | Laser, 30 - 1000mm
174
- | GP2Y0E03 | :heart: | I2C | `Sensor::GP2Y0E03` | Infrared, 40 - 500mm
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 Clock
206
+ ### Real Time Clocks
185
207
 
186
208
  | Name | Status | Interface | Component Class | Notes |
187
209
  | :--------------- | :------: | :-------- | :--------------- |------ |
188
210
  | DS1302 | :heart: | I2C | `RTC::DS1302` |
189
- | DS3221 | :yellow_heart: | I2C | `RTC::DS3231` | Only set and get time implemented
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.0 [![Test Status](https://github.com/denko-rb/denko/actions/workflows/ruby.yml/badge.svg)](https://github.com/denko-rb/denko/actions/workflows/ruby.yml)
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
- ````ruby
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
- 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, but no "task" priority. If you need more I/O, integration is seamless. Connect another board and instantiate it in Ruby.
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
- 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
- See a full list of supported mircocontroller platforms, interfaces, and peripherals [here](HARDWARE.md).
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 Ruby in WSL on Windows, you can follow the Mac/Linux instructions, but it is not recommended. Serial (COM port) forwarding isn't currently working on WSL2, which would make it impossible to communicate with the microcontroller. There are workarounds, and you might get it working by switching to WSL1, but the [RubyInstaller for Windows](https://rubyinstaller.org/) and Arduino IDE are recommended instead.
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
- ````shell
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 add support for microcontrollers, and a few libraries. Install only the ones for your microcontroller, or install everything. There are no conflcits. Instructions for supported microcontrollers:
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
- **For ATmega boards, Serial over USB:** (Arduino Uno, Nano, Mega, Leonardo, Micro)
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 esp8266
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
- **Note:** [This example](examples/connection/tcp.rb) shows how to connect to a board with a TCP socket, but the WiFi & Ethernet sketches fall back to the serial interface when no TCP client is connected.
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) IDE Flashing
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) CLI Flashing
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
- ````shell
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
- ````shell
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
- ````shell
100
+ ```shell
104
101
  arduino-cli board listall
105
- ````
102
+ ```
106
103
 
107
- #### 6) Test It
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
- * 1 compatible microcontroller (see [supported hardware](HARDWARE.md))
117
- * 1 button or momentary switch
118
- * 1 potentiometer (any value)
119
- * 1 external RGB LED (4 legs common cathode, not a Neopixel or individually addressable)
120
- * 1 external LED (any color, or use one color from the RGB LED)
121
- * Current limiting resistors for LEDs
122
- * Breadboard
123
- * Jumper wires
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
- - Try [Getting Started with Arduino and Denko](http://tutorials.jumpstartlab.com/projects/arduino/introducing_arduino.html) from [Jumpstart Lab](http://jumpstartlab.com) (_ignore old install instructions_).
135
- - An example [rails app](https://github.com/denko-rb/denko_rails_example) using Denko and Pusher.
136
- - For a Sinatra example, look at the [site](https://github.com/denko-rb/denko_cannon) used to shoot the cannon at RubyConf2012.
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