denko 0.13.4 → 0.13.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -1
- data/DEPS_IDE.md +3 -2
- data/HARDWARE.md +41 -30
- data/README.md +2 -2
- data/benchmarks/i2c_ssd1306_refresh.rb +5 -0
- data/denko.gemspec +4 -4
- data/examples/i2c/search.rb +2 -0
- data/examples/sensor/hcsr04.rb +14 -0
- data/lib/denko/board/pulse.rb +4 -0
- data/lib/denko/board.rb +1 -0
- data/lib/denko/sensor/hcsr04.rb +33 -0
- data/lib/denko/sensor.rb +1 -0
- data/lib/denko/version.rb +1 -1
- data/src/denko_wifi.ino +39 -14
- data/src/lib/Denko.cpp +6 -2
- data/src/lib/Denko.h +4 -2
- data/src/lib/DenkoDefines.h +16 -1
- data/src/lib/DenkoLEDArray.cpp +1 -1
- data/src/lib/DenkoPulseInput.cpp +32 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db3ab91a78e9e78ce4f973237f2de09e93561d8dae7cd239708ab9ab85bff3c7
|
4
|
+
data.tar.gz: bb904d187be4fbeaa238ee8d259d7f24abecc900b2244c9d01599752141c019f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f943f022e9058de0cc22ff88ea35588c78f35ea6282a72f5607e5059f73b5975fbd3c05ca5fa06448aff19e90227e67d9b38e0359a9168a13d08ed70dfa38028
|
7
|
+
data.tar.gz: 3fc9bca5801515fc7f1ba01aefd13888b9e9acb84e434335e571c75d383afbcccef066c285b749f12a0a9ab470dfb87b3a39c7aa16193b9e250785e6c55313a0
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.13.5
|
4
|
+
|
5
|
+
### New Components
|
6
|
+
|
7
|
+
- HC-SR04 Ultrasonic Distance Sensor:
|
8
|
+
- Class: `Denko::Sensor::HCSRO4`
|
9
|
+
- Custom function on the board to handle ping and response.
|
10
|
+
- Simple interface. `#read` returns a distance in mm.
|
11
|
+
|
12
|
+
### Bug Fixes
|
13
|
+
|
14
|
+
- OTA updating now works on ESP32.
|
15
|
+
- Adjust ESP32 expected serial buffer sizes and acknowledge intervals to to be more reliable.
|
16
|
+
- Fixed a bug on Windows where submodules weren't being included in load path.
|
17
|
+
- Fixed a bug where the board could incorrectly report EEPROM_LENGTH as 0.
|
18
|
+
|
3
19
|
## 0.13.4
|
4
20
|
|
5
21
|
### New Components
|
@@ -37,7 +53,7 @@
|
|
37
53
|
|
38
54
|
### Bug Fixes
|
39
55
|
|
40
|
-
- Fixed bug where `BMP280
|
56
|
+
- Fixed bug where `BMP280` sensor class would not autoload.
|
41
57
|
|
42
58
|
## 0.13.3
|
43
59
|
|
data/DEPS_IDE.md
CHANGED
@@ -33,7 +33,8 @@ All platforms will require libraries to be installed. To install a library do th
|
|
33
33
|
Arduino SAMD Boards (32-bits ARM Cortex-M0+)
|
34
34
|
Arduino UNO R4 Boards
|
35
35
|
ESP8266 Boards
|
36
|
-
ESP32 Boards
|
36
|
+
ESP32 Boards
|
37
|
+
Raspberry Pi Pico/RP2040
|
37
38
|
````
|
38
39
|
* Libraries:
|
39
40
|
````
|
@@ -119,7 +120,7 @@ All platforms will require libraries to be installed. To install a library do th
|
|
119
120
|
````
|
120
121
|
* Boards:
|
121
122
|
````
|
122
|
-
Raspberry Pi Pico/RP2040
|
123
|
+
Raspberry Pi Pico/RP2040
|
123
124
|
````
|
124
125
|
* Libraries:
|
125
126
|
````
|
data/HARDWARE.md
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
| Chip | Status | Products | Notes |
|
10
10
|
| :-------- | :------: | :--------------- |------ |
|
11
|
-
| ATmega168 | :green_heart: | Duemilanove, Diecimila, Pro |
|
11
|
+
| ATmega168 | :green_heart: | Duemilanove, Diecimila, Pro | Omits features. `denko targets` for info.
|
12
12
|
| ATmega328 | :green_heart: | Uno R3, Uno WiFi, Nano, Fio, Pro |
|
13
13
|
| ATmega32u4 | :green_heart: | Leonardo, Micro, Leonardo ETH, Esplora, LilyPad USB |
|
14
14
|
| ATmega1280 | :green_heart: | Mega |
|
@@ -24,7 +24,7 @@
|
|
24
24
|
|
25
25
|
| Chip | Status | Products | Notes |
|
26
26
|
| :-------- | :------: | :--------------- |------ |
|
27
|
-
| ATSAM3X8E | :yellow_heart: | Due | Native USB
|
27
|
+
| ATSAM3X8E | :yellow_heart: | Due | Uses Native USB. Tone and IR Out don't work.
|
28
28
|
| ATSAMD21 | :green_heart: | Zero, M0 Series, Nano 33 IOT, MKR WiFi 1010 | Native USB
|
29
29
|
| RA4M1 | :yellow_heart: | Uno R4 Minima, Uno R4 WiFi | IR and WS2812 libraries don't support this yet
|
30
30
|
|
@@ -55,6 +55,8 @@
|
|
55
55
|
| ESP32-S2 | :green_heart: | LOLIN S2 Pico | Native USB
|
56
56
|
| ESP32-S3 | :green_heart: | LOLIN S3 V1.0.0 | Native USB
|
57
57
|
| ESP32-C3 | :green_heart: | LOLIN C3 Mini V2.1.0 | Native USB
|
58
|
+
| ESP32-H2 | :heart: | - | Support in Arduino ESP32 core beta
|
59
|
+
| ESP32-C6 | :heart: | - | Support in Arduino ESP32 core beta
|
58
60
|
|
59
61
|
**Note:** For ESP32 chips using native USB, make sure `USB CDC On Boot` is `Enabled` in the IDE's `Tools` menu. Flashing from the CLI doesn't automatically enable this, so the IDE is recommended for now.
|
60
62
|
|
@@ -155,12 +157,13 @@ Polling and reading follow a call and response pattern.
|
|
155
157
|
| :--------------- | :------: | :-------- | :--------------- |------ |
|
156
158
|
| Generic Hobby Servo | :green_heart: | Servo/ESC PWM | `Motor::Servo` | Max depends on PWM channel count
|
157
159
|
| Generic ESC | :yellow_heart: | Servo/ESC PWM | `Motor::Servo` | Works. Needs its own class.
|
158
|
-
| PCA9685 | :heart: | I2C | `PulseIO::PCA9685` |
|
160
|
+
| PCA9685 | :heart: | I2C | `PulseIO::PCA9685` | 16-ch, 12-bit PWM for servo or LED
|
159
161
|
| L298N | :green_heart: | Digi + PWM Out | `Motor::L298` | H-Bridge DC motor driver
|
160
162
|
| DRV8833 | :heart: | Digi + PWM Out | `Motor::DRV8833` | H-Bridge DC motor driver
|
161
|
-
|
|
163
|
+
| TB6612 | :heart: | Digi + PWM Out | `Motor::TB6612` | H-Bridge DC motor driver
|
164
|
+
| A3967 | :green_heart: | Digital Out | `Motor::Stepper` | 1-ch microstepper (EasyDriver)
|
162
165
|
| A4988 | :yellow_heart: | DigitalOut | `Motor::Stepper` | 1-ch microstepper
|
163
|
-
| TMC2209 | :heart: | - | - |
|
166
|
+
| TMC2209 | :heart: | - | - | 1-ch silent stepper driver
|
164
167
|
|
165
168
|
### I/O Expansion
|
166
169
|
|
@@ -168,33 +171,38 @@ Polling and reading follow a call and response pattern.
|
|
168
171
|
| :--------------- | :------: | :-------- | :--------------- |------ |
|
169
172
|
| Input Register | :green_heart: | SPI | `SPI::InputRegister` | Tested on CD4021B
|
170
173
|
| Output Register | :green_heart: | SPI | `SPI::OutputRegister`| Tested on 74HC595
|
171
|
-
| PCF8574 Expander | :heart: | I2C | `DigitalIO::PCF8574` |
|
172
|
-
| ADS1100 ADC | :heart: | I2C | `AnalogIO::ADS1100` |
|
173
|
-
| ADS1115 ADC | :green_heart: | I2C | `AnalogIO::ADS1115` |
|
174
|
-
| ADS1118 ADC | :green_heart: | SPI | `AnalogIO::ADS1118` |
|
175
|
-
|
|
176
|
-
|
|
174
|
+
| PCF8574 Expander | :heart: | I2C | `DigitalIO::PCF8574` | 8-ch bi-directional digital I/O
|
175
|
+
| ADS1100 ADC | :heart: | I2C | `AnalogIO::ADS1100` | 1-ch, 16-bit ADC
|
176
|
+
| ADS1115 ADC | :green_heart: | I2C | `AnalogIO::ADS1115` | 4-ch, 16-bit ADC. Comparator not implemented.
|
177
|
+
| ADS1118 ADC | :green_heart: | SPI | `AnalogIO::ADS1118` | 4-ch, 16-bit ADC + temperature
|
178
|
+
| ADS1232 ADC | :heart: | SPI | `AnalogIO::ADS1232` | 2-ch, 24-bit ADC + temperature
|
179
|
+
| PCF8591 ADC/DAC | :heart: | I2C | `AnalogIO::PCF8591` | 4-ch, 8-bit ADC + 1-chm 8-bit DAC
|
180
|
+
| MCP4725 DAC | :heart: | I2C | `AnalogIO::MCP4275` | 1-ch, 12-bit DAC
|
181
|
+
| PCA9548 I2C Mux | :heart: | I2C | `I2C::PCA9548` | 8-way I2C multiplexer
|
177
182
|
|
178
183
|
### Environmental Sensors
|
179
184
|
|
180
|
-
| Name | Status | Interface | Component Class | Type
|
181
|
-
| :--------------- | :------: | :-------- | :--------------- |---------------
|
182
|
-
| MAX31850 | :heart: | OneWire | `Sensor::MAX31850` | Thermocouple
|
183
|
-
| MAX6675 | :heart: | SPI | `Sensor::MAX6675` | Thermocouple
|
184
|
-
| DS18B20 | :green_heart: | OneWire | `Sensor::DS18B20` | Temp
|
185
|
-
| DHT11/21/22 | :green_heart: | Digi In/Out | `Sensor::DHT` | Temp / RH
|
186
|
-
| SHT30/31/35 | :green_heart: | I2C | `Sensor::SHT3X` | Temp / RH
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
185
|
+
| Name | Status | Interface | Component Class | Type | Notes |
|
186
|
+
| :--------------- | :------: | :-------- | :--------------- |--------------- | ---------------------- |
|
187
|
+
| MAX31850 | :heart: | OneWire | `Sensor::MAX31850` | Thermocouple |
|
188
|
+
| MAX6675 | :heart: | SPI | `Sensor::MAX6675` | Thermocouple |
|
189
|
+
| DS18B20 | :green_heart: | OneWire | `Sensor::DS18B20` | Temp |
|
190
|
+
| DHT11/21/22 | :green_heart: | Digi In/Out | `Sensor::DHT` | Temp / RH |
|
191
|
+
| SHT30/31/35 | :green_heart: | I2C | `Sensor::SHT3X` | Temp / RH | M5Stack ENV III, one-shot only
|
192
|
+
| SHT40/41 | :heart: | I2C | `Sensor::SHT4X` | Temp / RH |
|
193
|
+
| QMP6988 | :green_heart: | I2C | `Sensor::QMP6988` | Temp / Press | M5Stack ENV III
|
194
|
+
| BMP180 | :green_heart: | I2C | `Sensor::BMP180` | Temp / Press |
|
195
|
+
| BMP280 | :green_heart: | I2C | `Sensor::BMP280` | Temp / Press |
|
196
|
+
| BME280 | :green_heart: | I2C | `Sensor::BME280` | Temp / Press / RH |
|
197
|
+
| BME680 | :heart: | I2C | `Sensor::BME680` | Temp / Press / RH / TVOC |
|
198
|
+
| HTU21D | :green_heart: | I2C | `Sensor::HTU21D` | Temp / RH | No user register read
|
199
|
+
| HTU31D | :green_heart: | I2C | `Sensor::HTU31D` | Temp / RH | No diagnostic read
|
200
|
+
| AHT10/15 | :green_heart: | I2C | `Sensor::AHT10` | Temp / RH |
|
201
|
+
| AHT20/21/25 | :green_heart: | I2C | `Sensor::AHT20` | Temp / RH |
|
202
|
+
| ENS160 | :heart: | I2C | `Sensor::ENS160` | eCO2 / TVOC / AQI |
|
203
|
+
| AGS02MA | :heart: | I2C | `Sensor::AGS02MA` | TVOC |
|
204
|
+
| SCD40 | :heart: | I2C | `Sensor::SDC40` | Temp / Press / CO2 |
|
205
|
+
| CCS811 | :heart: | I2C | `Sensor::CCS811` | eCO2 |
|
198
206
|
|
199
207
|
### Light Sensors
|
200
208
|
|
@@ -208,13 +216,15 @@ Polling and reading follow a call and response pattern.
|
|
208
216
|
| Name | Status | Interface | Component Class | Notes |
|
209
217
|
| :--------------- | :------: | :-------- | :--------------- |------ |
|
210
218
|
| HC-SR501 | :green_heart: | Digital In | `Sensor::GenericPIR` |
|
219
|
+
| HC-SR505 | :yellow_heart: | Digital In | `Sensor::GenericPIR` |
|
211
220
|
| AS312 | :green_heart: | Digital In | `Sensor::GenericPIR` |
|
221
|
+
| AM312 | :yellow_heart: | Digital In | `Sensor::GenericPIR` |
|
212
222
|
|
213
223
|
### Distance Sensors
|
214
224
|
|
215
225
|
| Name | Status | Interface | Component Class | Notes |
|
216
226
|
| :--------------- | :------: | :-------- | :--------------- |------ |
|
217
|
-
| HC-SR04 | :
|
227
|
+
| HC-SR04 | :green_heart: | Digi In/Out | `Sensor::HCSR04` | Ultrasonic, 20-4000mm
|
218
228
|
| RCWL-9620 | :green_heart: | I2C | `Sensor::RCWL9260` | Ultrasonic, 20-4500mm
|
219
229
|
| VL53L0X | :heart: | I2C | `Sensor::VL53L0X` | Laser, 30 - 1000mm
|
220
230
|
| GP2Y0E03 | :heart: | I2C | `Sensor::GP2Y0E03` | Infrared, 40 - 500mm
|
@@ -226,6 +236,7 @@ Polling and reading follow a call and response pattern.
|
|
226
236
|
| ADXL345 | :heart: | I2C | `Sensor::ADXL345` | Accelerometer
|
227
237
|
| IT3205 | :heart: | I2C | `Sensor::IT3205` | Gyroscope
|
228
238
|
| HMC5883L | :heart: | I2C | `Sensor::HMC5883L` | Compass
|
239
|
+
| MPU6050 | :heart: | I2C | `Sensor::MPU6050` | Gyro + Accelerometer
|
229
240
|
| MPU6886 | :heart: | I2C | `Sensor::MPU6886` | Gyro + Accelerometer
|
230
241
|
| BMI160 | :heart: | I2C | `Sensor::BMI160` | Gyro + Accelerometer
|
231
242
|
| LSM6DS3 | :heart: | I2C | `Sensor:LSM6DS3` | Gyro + Accelerometer
|
data/README.md
CHANGED
@@ -23,10 +23,10 @@ High-level abstraction in Ruby makes hardware classes easy to implement, with in
|
|
23
23
|
Full list of supported mircocontroller platforms, interfaces, and peripherals is located [here](HARDWARE.md).
|
24
24
|
|
25
25
|
##### denko-piboard
|
26
|
-
The
|
26
|
+
The [denko-piboard](https://github.com/denko-rb/denko-piboard) add-on gem, uses a Raspberry Pi's built in GPIO header instead of an attached microcontroller. Connect things directly to the Pi, and use the peripheral classes from this gem.
|
27
27
|
|
28
28
|
##### mruby-denko
|
29
|
-
A solo Raspberry Pi (or other
|
29
|
+
A solo Raspberry Pi (or other SBC + microcontroller) is great if you need the compute power anyway, but what if you don't? Why not run Ruby on the microcontroller itself?
|
30
30
|
|
31
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.
|
32
32
|
|
@@ -30,6 +30,11 @@
|
|
30
30
|
# Arduino Nano Every : 9.2 fps (USB through ATSAMD11 @ 115200, 128-byte I2C limit, no I2C level shifter)
|
31
31
|
# Arduino Nano Every : 13.0 fps (USB through ATSAMD11 @ 230400, 128-byte I2C limit, no I2C level shifter)
|
32
32
|
#
|
33
|
+
# February 25 2024 | i7 8700k CPU | CRuby 3.2.1 | 100 frames | 1 Mhz I2C frequency | Average of 3 runs
|
34
|
+
#
|
35
|
+
# ESP32-S3 : 51.8 fps (native USB) - Changed from 64 to 128 serial ACK interval
|
36
|
+
# ESP32-C3 : 51.7 fps (native USB) - Changed from 64 to 128 serial ACK interval
|
37
|
+
#
|
33
38
|
require 'bundler/setup'
|
34
39
|
require 'denko'
|
35
40
|
|
data/denko.gemspec
CHANGED
@@ -17,10 +17,10 @@ Gem::Specification.new do |gem|
|
|
17
17
|
# get an array of submodule dirs by executing 'pwd' inside each submodule
|
18
18
|
gem_dir = File.expand_path(File.dirname(__FILE__)) + "/"
|
19
19
|
`git submodule --quiet foreach pwd`.split($\).each do |submodule_path|
|
20
|
-
# Fix submodule paths on Windows.
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
# Fix submodule paths on Windows, by removing prepended / and drive letter.
|
21
|
+
if RUBY_PLATFORM.match(/mswin|mingw/i)
|
22
|
+
submodule_path = submodule_path[2..-1]
|
23
|
+
end
|
24
24
|
|
25
25
|
Dir.chdir(submodule_path) do
|
26
26
|
submodule_relative_path = submodule_path.sub gem_dir, ""
|
data/examples/i2c/search.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
#
|
2
|
+
# Example of reading an HC-SR04 ultrasonic sensor.
|
3
|
+
#
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'denko'
|
6
|
+
|
7
|
+
board = Denko::Board.new(Denko::Connection::Serial.new)
|
8
|
+
hcsr04 = Denko::Sensor::HCSR04.new(board: board, pins: {trigger: 6, echo: 7})
|
9
|
+
|
10
|
+
hcsr04.poll(0.05) do |distance|
|
11
|
+
puts "Distance: #{distance} mm"
|
12
|
+
end
|
13
|
+
|
14
|
+
sleep
|
data/lib/denko/board/pulse.rb
CHANGED
data/lib/denko/board.rb
CHANGED
@@ -110,6 +110,7 @@ module Denko
|
|
110
110
|
# Component generating convenience methods. TODO: add more!
|
111
111
|
#
|
112
112
|
def eeprom
|
113
|
+
raise StandardError, 'board has no built-in EEPROM, or EEPROM disabled in sketch' if @eeprom_length == 0
|
113
114
|
@eeprom ||= EEPROM::BuiltIn.new(board: self)
|
114
115
|
end
|
115
116
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Denko
|
2
|
+
module Sensor
|
3
|
+
class HCSR04
|
4
|
+
# Speed of sound in meters per second.
|
5
|
+
SPEED_OF_SOUND = 343.0
|
6
|
+
|
7
|
+
include Behaviors::MultiPin
|
8
|
+
include Behaviors::Poller
|
9
|
+
|
10
|
+
def initialize_pins(options={})
|
11
|
+
proxy_pin :trigger, DigitalIO::Output
|
12
|
+
proxy_pin :echo, DigitalIO::Input
|
13
|
+
end
|
14
|
+
|
15
|
+
def after_initialize(options={})
|
16
|
+
super(options)
|
17
|
+
|
18
|
+
# Receive values from echo pin.
|
19
|
+
echo.add_callback { |data| self.update(data) }
|
20
|
+
end
|
21
|
+
|
22
|
+
def _read
|
23
|
+
board.hcsr04_read(echo.pin, trigger.pin)
|
24
|
+
end
|
25
|
+
|
26
|
+
def pre_callback_filter(us)
|
27
|
+
# Data is microseconds roundtrip time. Convert to mm.
|
28
|
+
um = (us/2) * SPEED_OF_SOUND
|
29
|
+
mm = um / 1000.0
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/denko/sensor.rb
CHANGED
@@ -14,6 +14,7 @@ module Denko
|
|
14
14
|
autoload :SHT3X, "#{__dir__}/sensor/sht3x"
|
15
15
|
autoload :QMP6988, "#{__dir__}/sensor/qmp6988"
|
16
16
|
autoload :RCWL9620, "#{__dir__}/sensor/rcwl9620"
|
17
|
+
autoload :HCSR04, "#{__dir__}/sensor/hcsr04"
|
17
18
|
autoload :GenericPIR, "#{__dir__}/sensor/generic_pir"
|
18
19
|
end
|
19
20
|
end
|
data/lib/denko/version.rb
CHANGED
data/src/denko_wifi.ino
CHANGED
@@ -30,8 +30,8 @@
|
|
30
30
|
#elif defined(ESP32)
|
31
31
|
#include <WiFi.h>
|
32
32
|
#include <ESPmDNS.h>
|
33
|
-
|
34
|
-
|
33
|
+
#include <WiFiUdp.h>
|
34
|
+
#include <ArduinoOTA.h>
|
35
35
|
#define WIFI_STATUS_LED 2
|
36
36
|
#else
|
37
37
|
#define WIFI_STATUS_LED 13
|
@@ -48,13 +48,13 @@
|
|
48
48
|
#endif
|
49
49
|
|
50
50
|
// Configure your WiFi options here. IP address is not configurable. Uses DHCP.
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
#define DENKO_TCP_PORT 3466
|
52
|
+
#define WIFI_SSID "yourNetwork"
|
53
|
+
#define WIFI_PASSWORD "yourPassword"
|
54
54
|
boolean connected = false;
|
55
55
|
|
56
56
|
Denko denko;
|
57
|
-
WiFiServer server(
|
57
|
+
WiFiServer server(DENKO_TCP_PORT);
|
58
58
|
WiFiClient client;
|
59
59
|
|
60
60
|
// Use the built in LED to indicate WiFi status.
|
@@ -82,7 +82,7 @@ void printWifiStatus() {
|
|
82
82
|
DENKO_SERIAL_IF.println(WiFi.localIP());
|
83
83
|
#endif
|
84
84
|
DENKO_SERIAL_IF.print("Denko TCP Port: ");
|
85
|
-
DENKO_SERIAL_IF.println(
|
85
|
+
DENKO_SERIAL_IF.println(DENKO_TCP_PORT);
|
86
86
|
indicateWiFi(true);
|
87
87
|
}
|
88
88
|
|
@@ -94,7 +94,7 @@ void connect(){
|
|
94
94
|
|
95
95
|
// Try to connect.
|
96
96
|
DENKO_SERIAL_IF.print("Connecting to WiFi ");
|
97
|
-
WiFi.begin(
|
97
|
+
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
|
98
98
|
|
99
99
|
// Delay until connected.
|
100
100
|
while (WiFi.status() != WL_CONNECTED) {
|
@@ -117,14 +117,39 @@ void setup() {
|
|
117
117
|
DENKO_SERIAL_IF.begin(115200);
|
118
118
|
while(!DENKO_SERIAL_IF);
|
119
119
|
|
120
|
-
//
|
121
|
-
|
120
|
+
// Attempt initial WiFi connection.
|
121
|
+
connect();
|
122
|
+
|
123
|
+
// Enable over the air updates on the ESP8266 and ESP32.
|
124
|
+
// Taken from standard ESP8266/ESP32 OTA examples.
|
125
|
+
#if defined(ESP8266) || (ESP32)
|
126
|
+
ArduinoOTA.onStart([]() {
|
127
|
+
String type;
|
128
|
+
if (ArduinoOTA.getCommand() == U_FLASH) {
|
129
|
+
type = "sketch";
|
130
|
+
} else { // U_FS (ESP8266) or U_SPIFFS (ESP32)
|
131
|
+
type = "filesystem";
|
132
|
+
}
|
133
|
+
// NOTE: if updating FS or SPIFFS, this would be the place to unmount using FS.end() or SPIFFS.end()
|
134
|
+
Serial.println("Arduino OTA: Start updating " + type);
|
135
|
+
});
|
136
|
+
ArduinoOTA.onEnd([]() {
|
137
|
+
Serial.println("\nArduino OTA: End\n");
|
138
|
+
});
|
139
|
+
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
|
140
|
+
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
|
141
|
+
});
|
142
|
+
ArduinoOTA.onError([](ota_error_t error) {
|
143
|
+
Serial.printf("Error[%u]: ", error);
|
144
|
+
if (error == OTA_AUTH_ERROR) Serial.println("Arduino OTA: Auth Failed");
|
145
|
+
else if (error == OTA_BEGIN_ERROR) Serial.println("Arduino OTA: Begin Failed");
|
146
|
+
else if (error == OTA_CONNECT_ERROR) Serial.println("Arduino OTA: Connect Failed");
|
147
|
+
else if (error == OTA_RECEIVE_ERROR) Serial.println("Arduino OTA: Receive Failed");
|
148
|
+
else if (error == OTA_END_ERROR) Serial.println("Arduino OTA: End Failed");
|
149
|
+
});
|
122
150
|
ArduinoOTA.begin();
|
123
151
|
#endif
|
124
152
|
|
125
|
-
// Attempt initial WiFi connection.
|
126
|
-
connect();
|
127
|
-
|
128
153
|
// Start the denko TCP server.
|
129
154
|
server.begin();
|
130
155
|
|
@@ -141,7 +166,7 @@ void loop() {
|
|
141
166
|
maintainWiFi();
|
142
167
|
|
143
168
|
// Handle OTA updates.
|
144
|
-
#if defined(ESP8266)
|
169
|
+
#if defined(ESP8266) || (ESP32)
|
145
170
|
ArduinoOTA.handle();
|
146
171
|
#endif
|
147
172
|
|
data/src/lib/Denko.cpp
CHANGED
@@ -3,6 +3,9 @@
|
|
3
3
|
*/
|
4
4
|
#include "Denko.h"
|
5
5
|
#include "BoardMap.h"
|
6
|
+
#ifdef DENKO_EEPROM
|
7
|
+
#include "EEPROM.h"
|
8
|
+
#endif
|
6
9
|
|
7
10
|
Denko::Denko(){
|
8
11
|
messageFragments[0] = cmdStr;
|
@@ -119,7 +122,8 @@ void Denko::process() {
|
|
119
122
|
#endif
|
120
123
|
|
121
124
|
// Implemented in DenkoPulseInput.cpp
|
122
|
-
case 9:
|
125
|
+
case 9: pulseRead (); break;
|
126
|
+
case 20: hcsr04Read (); break;
|
123
127
|
|
124
128
|
// Implemented in DenkoServo.cpp
|
125
129
|
#ifdef DENKO_SERVO
|
@@ -275,7 +279,7 @@ void Denko::handshake() {
|
|
275
279
|
stream->print(',');
|
276
280
|
#if defined(EEPROM_EMULATED)
|
277
281
|
stream->print(EMULATED_EEPROM_LENGTH);
|
278
|
-
#elif defined(
|
282
|
+
#elif defined(DENKO_EEPROM)
|
279
283
|
stream->print(EEPROM.length());
|
280
284
|
#endif
|
281
285
|
|
data/src/lib/Denko.h
CHANGED
@@ -95,11 +95,13 @@ class Denko {
|
|
95
95
|
void eepromRead (); //cmd = 7
|
96
96
|
void eepromWrite (); //cmd = 8
|
97
97
|
|
98
|
-
//
|
98
|
+
// Pulse inputs (DHT and HC-SR04)
|
99
99
|
void pulseRead (); //cmd = 9
|
100
|
+
void hcsr04Read (); //cmd = 20
|
101
|
+
|
102
|
+
// Servos
|
100
103
|
void servoToggle (); //cmd = 10
|
101
104
|
void servoWrite (); //cmd = 11
|
102
|
-
void handleSerial (); //cmd = 12
|
103
105
|
|
104
106
|
// Single Bit Bang UART
|
105
107
|
#ifdef DENKO_UART_BB
|
data/src/lib/DenkoDefines.h
CHANGED
@@ -134,9 +134,24 @@
|
|
134
134
|
// Best performance acknowledging at 64 bytes, or 32 if buffer is only 64.
|
135
135
|
//
|
136
136
|
// These are 256/64 regardless of whether native USB CDC or UART bridge.
|
137
|
-
#if defined(ARDUINO_ARCH_RP2040) ||
|
137
|
+
#if defined(ARDUINO_ARCH_RP2040) || defined(ESP8266) || defined(__SAM3X8E__)
|
138
138
|
#define DENKO_SERIAL_BUFFER_SIZE 256
|
139
139
|
#define DENKO_RX_ACK_INTERVAL 64
|
140
|
+
// ESP32 defaults to 256 buffer. Stay one under.
|
141
|
+
#elif defined(ESP32)
|
142
|
+
#define DENKO_SERIAL_BUFFER_SIZE 255
|
143
|
+
#ifdef ARDUINO_USB_CDC_ON_BOOT
|
144
|
+
// S2 unreliable with acknowledgement before buffer is full.
|
145
|
+
#ifdef CONFIG_IDF_TARGET_ESP32S2
|
146
|
+
#define DENKO_RX_ACK_INTERVAL 255
|
147
|
+
// S3 and C3 are fine acknowledging at half buffer filled.
|
148
|
+
#else
|
149
|
+
#define DENKO_RX_ACK_INTERVAL 128
|
150
|
+
#endif
|
151
|
+
// Default to 64 if using a UART bridge.
|
152
|
+
#else
|
153
|
+
#define DENKO_RX_ACK_INTERVAL 64
|
154
|
+
#endif
|
140
155
|
// RA4M1 has a 512 Serial buffer.
|
141
156
|
#elif defined(_RENESAS_RA_)
|
142
157
|
#define DENKO_SERIAL_BUFFER_SIZE 512
|
data/src/lib/DenkoLEDArray.cpp
CHANGED
data/src/lib/DenkoPulseInput.cpp
CHANGED
@@ -27,7 +27,7 @@ void Denko::pulseRead(){
|
|
27
27
|
uint16_t resetTime = (auxMsg[1] << 8) | auxMsg[0];
|
28
28
|
pinMode(pin, OUTPUT);
|
29
29
|
digitalWrite(pin, bitRead(val, 1));
|
30
|
-
|
30
|
+
microDelay(resetTime);
|
31
31
|
}
|
32
32
|
pinMode(pin, INPUT);
|
33
33
|
byte state = digitalRead(pin);
|
@@ -55,3 +55,34 @@ void Denko::pulseRead(){
|
|
55
55
|
}
|
56
56
|
if (pulseCount == 0) stream->print('\n');
|
57
57
|
}
|
58
|
+
|
59
|
+
// CMD = 20
|
60
|
+
//
|
61
|
+
// pin : echo pin
|
62
|
+
// val (lower 8 bits) : trigger pin
|
63
|
+
//
|
64
|
+
void Denko::hcsr04Read(){
|
65
|
+
// Store number of microseconds to return.
|
66
|
+
uint32_t us;
|
67
|
+
|
68
|
+
// Ensure pins are correct direction.
|
69
|
+
// This is handled by modeling the sensor as a multipin component instead.
|
70
|
+
// pinMode(pin, INPUT);
|
71
|
+
// pinMode(val, OUTPUT);
|
72
|
+
|
73
|
+
// Initial pulse on the triger pin.
|
74
|
+
digitalWrite(val, LOW);
|
75
|
+
microDelay(2);
|
76
|
+
digitalWrite(val,HIGH);
|
77
|
+
microDelay(10);
|
78
|
+
digitalWrite(val,LOW);
|
79
|
+
|
80
|
+
// Wait for the echo, up to 25,000 microseconds.
|
81
|
+
us = pulseIn(pin, HIGH, 25000);
|
82
|
+
|
83
|
+
// Send value.
|
84
|
+
stream->print(pin);
|
85
|
+
stream->print(':');
|
86
|
+
stream->print(us);
|
87
|
+
stream->print('\n');
|
88
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: denko
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vickash, Austinbv
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyserial
|
@@ -149,6 +149,7 @@ files:
|
|
149
149
|
- examples/sensor/dht.rb
|
150
150
|
- examples/sensor/ds18b20.rb
|
151
151
|
- examples/sensor/generic_pir.rb
|
152
|
+
- examples/sensor/hcsr04.rb
|
152
153
|
- examples/sensor/htu21d.rb
|
153
154
|
- examples/sensor/htu31d.rb
|
154
155
|
- examples/sensor/neat_tph_readings.rb
|
@@ -259,6 +260,7 @@ files:
|
|
259
260
|
- lib/denko/sensor/dht.rb
|
260
261
|
- lib/denko/sensor/ds18b20.rb
|
261
262
|
- lib/denko/sensor/generic_pir.rb
|
263
|
+
- lib/denko/sensor/hcsr04.rb
|
262
264
|
- lib/denko/sensor/htu21d.rb
|
263
265
|
- lib/denko/sensor/htu31d.rb
|
264
266
|
- lib/denko/sensor/qmp6988.rb
|