denko 0.13.1 → 0.13.2

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