summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Laboissière <rafael@debian.org>2022-09-14 03:49:44 -0300
committerRafael Laboissière <rafael@debian.org>2022-09-14 03:49:44 -0300
commit9ff57de88b4590ebe32be678884a79e81c2afe7a (patch)
treefd025ff4dddd031feadf2073ff8e108cc51c24f7
parent25b80a36925f445327b23a60b73de25613d5532c (diff)
New upstream version 0.10.0
-rw-r--r--DESCRIPTION4
-rw-r--r--NEWS11
-rw-r--r--README.md2
-rw-r--r--doc/arduino.css15
-rw-r--r--doc/arduino.html19
-rw-r--r--doc/arduino.pdfbin396762 -> 396859 bytes
-rw-r--r--doc/arduino.qchbin155648 -> 155648 bytes
-rw-r--r--doc/arduino.qhcbin131072 -> 131072 bytes
-rw-r--r--doc/arduino.texi16
-rw-r--r--doc/functions.texi3
-rw-r--r--inst/+arduinoio/+config/config_esp32_dev.m101
-rw-r--r--inst/+arduinoio/boardTypeString.m2
-rw-r--r--inst/+arduinoio/lib/LibraryBase.cpp31
-rw-r--r--inst/+arduinoio/lib/LibraryBase.h8
-rw-r--r--inst/+arduinoio/lib/OctaveCoreLibrary.cpp14
-rw-r--r--inst/+arduinoio/lib/OctaveI2CLibrary.cpp13
-rw-r--r--inst/+arduinoio/lib/OctaveServoLibrary.cpp8
-rw-r--r--inst/@arduino/__freeArduino__.m4
-rw-r--r--inst/@arduino/__initArduino__.m10
-rw-r--r--inst/@arduino/arduino.m47
-rw-r--r--inst/@arduino/playTone.m4
21 files changed, 253 insertions, 59 deletions
diff --git a/DESCRIPTION b/DESCRIPTION
index c596d84..4630e8f 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,6 +1,6 @@
Name: arduino
-Version: 0.9.1
-Date: 2022-07-13
+Version: 0.10.0
+Date: 2022-09-13
Author: John Donoghue <john.donoghue@ieee.org>
Maintainer: John Donoghue <john.donoghue@ieee.org>
Title: Octave Arduino Toolkit
diff --git a/NEWS b/NEWS
index 9e93019..8561bf5 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,14 @@
+Summary of important user-visible changes for arduino 0.10.0:
+-------------------------------------------------------------------
+
+ ** New board configurations:
+ - ESP32 Dev
+
+ ** Doc corrections for using addons
+
+ ** @arduino/arduino
+ - added 'forcebuildon' input property
+
Summary of important user-visible changes for arduino 0.9.1:
-------------------------------------------------------------------
diff --git a/README.md b/README.md
index b19fa05..a43b756 100644
--- a/README.md
+++ b/README.md
@@ -66,6 +66,8 @@ Currently the toolkit recognizes these boards:
* due
+* esp32 dev
+
* leonardo
* lilypad
diff --git a/doc/arduino.css b/doc/arduino.css
index de7e0e9..3c116ef 100644
--- a/doc/arduino.css
+++ b/doc/arduino.css
@@ -9,21 +9,6 @@ pre.example {
padding: 0.5em; }
table.cartouche {
- width: 100%;
- background-color: #fdf6e3;
- border: 1px solid #1C6EA4;
-}
-
-table.xcartouche td {
- border: 1px solid #1C6EA4;
- padding: 4px 4px;
-}
-
-table.xcartouche tbody {
- border: none;
-}
-
-table.cartouche {
border: 1px solid #948473;
background-color: #FFE3C6;
width: 100%;
diff --git a/doc/arduino.html b/doc/arduino.html
index 2e2eec8..eb2cf80 100644
--- a/doc/arduino.html
+++ b/doc/arduino.html
@@ -389,7 +389,7 @@ octave-forge using the following command within <acronym>GNU</acronym> Octave:
<acronym>GNU</acronym> Octave, the package can be installed using the following command within <acronym>GNU</acronym> Octave:
</p>
<div class="example">
-<pre class="example">pkg install arduino-0.9.1.tar.gz
+<pre class="example">pkg install arduino-0.10.0.tar.gz
</pre></div>
</div>
@@ -489,6 +489,7 @@ the Arduino. Otherwise, use the &rsquo;arduino&rsquo; binary property.
eliminate conflicts between servos and the tone library
</p></td></tr></table>
</li><li> Raspberry Pi Pico
+</li><li> EPS32 Dev
</li></ul>
<p>Additional boards can be added easily, however require minor code changes.
@@ -882,7 +883,7 @@ the +arduinoioaddons folder. The subdirectory must begin with a &rsquo;+&rsquo;.
as well as provides information about the addon.
</p>
<span id="Class-inheritance-and-required-properties"></span><h4 class="subsubheading">Class inheritance and required properties</h4>
-<p>The interface file must be a subclass pf arduinoio.LibraryBase and must contain some constant properties values that provide the information.
+<p>The interface file must be a subclass of arduinoio.LibraryBase and must contain some constant properties values that provide the information.
</p>
<p>A minimum example of required is below:
</p><div class="example">
@@ -1042,13 +1043,13 @@ public:
{
switch (cmdID)
{
- case MYADDON_INIT:
+ case MYADDON1_INIT:
{
cnt = 0;
sendResponseMsg(cmdID, 0,0);
break;
}
- case MYADDON_FUNC1:
+ case MYADDON1_FUNC1:
{
// func 1 is just returning a uint8 count of number of times called
cnt ++;
@@ -1063,7 +1064,7 @@ public:
}
}
}
-</code>
+</code>;
</pre></div>
<p>The body of functions can be in the CppSourceFile file is it is defined or within the header file as illustrated above.
@@ -1138,7 +1139,7 @@ Next: <a href="#Examples" accesskey="n" rel="next">Examples</a>, Previous: <a hr
<p>There are two types of sensors available:
</p><ol>
-<li> Matlab compatible(ish) sensors for envorinment and IMU.
+<li> Matlab compatible(ish) sensors for environment and IMU.
</li><li> Additional lightweight wrappers for some chips in a arduinosensor namespace.
</li></ol>
@@ -1157,7 +1158,7 @@ Next: <a href="#Examples" accesskey="n" rel="next">Examples</a>, Previous: <a hr
<div class="subsection" id="Overview">
<h4 class="subsection">7.1.1 Overview</h4>
<p>Matlab compatible functions are provided for a number of sensors, using a similar function naming as
-provided by the Maybal arduino package.
+provided by the Matlab arduino package.
</p>
</div>
<div class="subsection" id="Available-Sensors">
@@ -1783,6 +1784,10 @@ Next: <a href="#Arduino-I2C-Functions" accesskey="n" rel="next">Arduino I2C Func
<dt><span>debug</span></dt>
<dd><p>true / false flag for whether debug in turned on
</p></dd>
+<dt><span>forcebuildon</span></dt>
+<dd><p>true / false flag for whether to force show of the arduino IDE to
+ reprogram the arduino
+ </p></dd>
<dt><span>port (read only)</span></dt>
<dd><p>the communications port the board is connected to.
</p></dd>
diff --git a/doc/arduino.pdf b/doc/arduino.pdf
index f1aacfc..f9905e4 100644
--- a/doc/arduino.pdf
+++ b/doc/arduino.pdf
Binary files differ
diff --git a/doc/arduino.qch b/doc/arduino.qch
index b7e13bb..6a509e4 100644
--- a/doc/arduino.qch
+++ b/doc/arduino.qch
Binary files differ
diff --git a/doc/arduino.qhc b/doc/arduino.qhc
index 83402db..7b50515 100644
--- a/doc/arduino.qhc
+++ b/doc/arduino.qhc
Binary files differ
diff --git a/doc/arduino.texi b/doc/arduino.texi
index b022341..f4d1975 100644
--- a/doc/arduino.texi
+++ b/doc/arduino.texi
@@ -11,7 +11,7 @@
@afourpaper
@paragraphindent 0
@finalout
-@set VERSION 0.9.1
+@set VERSION 0.10.0
@set COPYRIGHT_DATE 2018-2022
@c @afourwide
@c %*** End of the HEADER
@@ -220,6 +220,8 @@ Arduino UNO WiFi rev2
eliminate conflicts between servos and the tone library}
@item
Raspberry Pi Pico
+@item
+EPS32 Dev
@end itemize
Additional boards can be added easily, however require minor code changes.
@@ -528,7 +530,7 @@ The Matlab interface file within the addon directory provides the Matlab interfa
as well as provides information about the addon.
@subsubheading Class inheritance and required properties
-The interface file must be a subclass pf arduinoio.LibraryBase and must contain some constant properties values that provide the information.
+The interface file must be a subclass of arduinoio.LibraryBase and must contain some constant properties values that provide the information.
A minimum example of required is below:
@example
@@ -675,13 +677,13 @@ public:
@{
switch (cmdID)
@{
- case MYADDON_INIT:
+ case MYADDON1_INIT:
@{
cnt = 0;
sendResponseMsg(cmdID, 0,0);
break;
@}
- case MYADDON_FUNC1:
+ case MYADDON1_FUNC1:
@{
// func 1 is just returning a uint8 count of number of times called
cnt ++;
@@ -696,7 +698,7 @@ public:
@}
@}
@}
-}
+};
@end example
The body of functions can be in the CppSourceFile file is it is defined or within the header file as illustrated above.
@@ -752,7 +754,7 @@ An object of the addon type can be created using the addon command.
There are two types of sensors available:
@enumerate
@item
-Matlab compatible(ish) sensors for envorinment and IMU.
+Matlab compatible(ish) sensors for environment and IMU.
@item
Additional lightweight wrappers for some chips in a arduinosensor namespace.
@end enumerate
@@ -762,7 +764,7 @@ Additional lightweight wrappers for some chips in a arduinosensor namespace.
@subsection Overview
Matlab compatible functions are provided for a number of sensors, using a similar function naming as
-provided by the Maybal arduino package.
+provided by the Matlab arduino package.
@subsection Available Sensors
@cindex Available Sensors
diff --git a/doc/functions.texi b/doc/functions.texi
index 5f7a2c5..e43fb3c 100644
--- a/doc/functions.texi
+++ b/doc/functions.texi
@@ -164,6 +164,9 @@
name assigned to the arduino object
@item debug
true / false flag for whether debug in turned on
+ @item forcebuildon
+ true / false flag for whether to force show of the arduino IDE to
+ reprogram the arduino
@item port (read only)
the communications port the board is connected to.
@item board (read only)
diff --git a/inst/+arduinoio/+config/config_esp32_dev.m b/inst/+arduinoio/+config/config_esp32_dev.m
new file mode 100644
index 0000000..a6dc0eb
--- /dev/null
+++ b/inst/+arduinoio/+config/config_esp32_dev.m
@@ -0,0 +1,101 @@
+## Copyright (C) 2021 John Donoghue <john.donoghue@ieee.org>
+##
+## This program is free software: you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program. If not, see
+## <https://www.gnu.org/licenses/>.
+
+## -*- texinfo -*-
+## @deftypefn {} {@var{retval} =} config_esp32_dev (@var{initdata})
+## Private function for setting allowed modes of esp board pins
+## @end deftypefn
+
+# configuration generated from esp32/2.0.2/variants/esp32/pins_arduino.h
+function retval = config_esp32_dev (initdata)
+ retval = {};
+
+ # default board info - must be provided
+ # will be filled in on connection.
+ retval.board = '';
+ retval.mcu = 'eps32';
+ retval.voltref = 0;
+ retval.libs = {};
+ retval.port = '';
+
+ # info expected to be provided by config.
+ retval.description = 'ESP32 Dev Module';
+
+ # pin config
+ retval.pins = {};
+ retval.pins{end+1} = arduinoio.config.pin_info('D0', 0, { 'digital', 'pwm', 'interrupt', 'analog' }, {'a11'});
+ retval.pins{end+1} = arduinoio.config.pin_info('D1', 1, { 'digital', 'pwm', 'uart0_tx', 'interrupt' });
+ retval.pins{end+1} = arduinoio.config.pin_info('D2', 2, { 'digital', 'pwm', 'interrupt', 'led', 'analog' }, {'a12'});
+ retval.pins{end+1} = arduinoio.config.pin_info('D3', 3, { 'digital', 'pwm', 'uart0_rx', 'interrupt' });
+ retval.pins{end+1} = arduinoio.config.pin_info('D4', 4, { 'digital', 'pwm', 'interrupt', 'analog' }, {'a4'});
+ retval.pins{end+1} = arduinoio.config.pin_info('D5', 5, { 'digital', 'pwm', 'interrupt', 'spi_ss' });
+ # dont use
+ #retval.pins{end+1} = arduinoio.config.pin_info('D6', 6, { 'digital', 'pwm', 'interrupt' });
+ #retval.pins{end+1} = arduinoio.config.pin_info('D7', 7, { 'digital', 'pwm', 'interrupt' });
+ #retval.pins{end+1} = arduinoio.config.pin_info('D8', 8, { 'digital', 'pwm', 'interrupt' });
+ #retval.pins{end+1} = arduinoio.config.pin_info('D9', 9, { 'digital', 'pwm', 'interrupt' });
+ #retval.pins{end+1} = arduinoio.config.pin_info('D10', 10, { 'digital', 'pwm', 'interrupt' });
+ #retval.pins{end+1} = arduinoio.config.pin_info('D11', 11, { 'digital', 'pwm', 'interrupt' });
+ retval.pins{end+1} = arduinoio.config.pin_info('D12', 12, { 'digital', 'pwm', 'interrupt', 'analog' }, {'a15'});
+ retval.pins{end+1} = arduinoio.config.pin_info('D13', 13, { 'digital', 'pwm', 'interrupt', 'analog' }, {'a14'});
+ retval.pins{end+1} = arduinoio.config.pin_info('D14', 14, { 'digital', 'pwm', 'interrupt', 'analog' }, {'a16'});
+ retval.pins{end+1} = arduinoio.config.pin_info('D15', 15, { 'digital', 'pwm', 'interrupt', 'analog' }, {'a13'});
+ retval.pins{end+1} = arduinoio.config.pin_info('D16', 16, { 'digital', 'pwm', 'interrupt' });
+ retval.pins{end+1} = arduinoio.config.pin_info('D17', 17, { 'digital', 'pwm', 'interrupt' });
+ retval.pins{end+1} = arduinoio.config.pin_info('D18', 18, { 'digital', 'pwm', 'interrupt', 'spi_sck' });
+ retval.pins{end+1} = arduinoio.config.pin_info('D19', 19, { 'digital', 'pwm', 'interrupt', 'spi_miso' });
+
+ #retval.pins{end+1} = arduinoio.config.pin_info('D20', 20, { 'digital', 'pwm', 'interrupt' });
+ retval.pins{end+1} = arduinoio.config.pin_info('D21', 21, { 'digital', 'pwm', 'interrupt', 'i2c_sda' });
+ retval.pins{end+1} = arduinoio.config.pin_info('D22', 22, { 'digital', 'pwm', 'interrupt', 'i2c_scl' });
+ retval.pins{end+1} = arduinoio.config.pin_info('D23', 23, { 'digital', 'pwm', 'interrupt', 'spi_mosi' });
+ #retval.pins{end+1} = arduinoio.config.pin_info('D24', 24, { 'digital', 'pwm', 'interrupt' });
+ retval.pins{end+1} = arduinoio.config.pin_info('D25', 25, { 'digital', 'pwm', 'interrupt', 'analog' }, {'a18'});
+ retval.pins{end+1} = arduinoio.config.pin_info('D26', 26, { 'digital', 'pwm', 'interrupt', 'analog' }, {'a19'});
+ retval.pins{end+1} = arduinoio.config.pin_info('D27', 27, { 'digital', 'pwm', 'interrupt', 'analog' }, {'a17'});
+ #retval.pins{end+1} = arduinoio.config.pin_info('D28', 28, { 'digital', 'pwm', 'interrupt' });
+ #retval.pins{end+1} = arduinoio.config.pin_info('D29', 29, { 'digital', 'pwm', 'interrupt' });
+ #retval.pins{end+1} = arduinoio.config.pin_info('D30', 30, { 'digital', 'pwm', 'interrupt' });
+ #retval.pins{end+1} = arduinoio.config.pin_info('D31', 31, { 'digital', 'pwm', 'interrupt' });
+ retval.pins{end+1} = arduinoio.config.pin_info('D32', 32, { 'digital', 'pwm', 'interrupt', 'analog' }, {'a4'});
+ retval.pins{end+1} = arduinoio.config.pin_info('D33', 33, { 'digital', 'pwm', 'interrupt', 'anolog' }, {'a5'});
+ retval.pins{end+1} = arduinoio.config.pin_info('D34', 34, { 'digital', 'analog' }, {'a6'});
+ retval.pins{end+1} = arduinoio.config.pin_info('D35', 35, { 'digital', 'analog' }, {'a7'});
+ retval.pins{end+1} = arduinoio.config.pin_info('D36', 36, { 'digital', 'analog' }, {'a0'});
+ retval.pins{end+1} = arduinoio.config.pin_info('D37', 37, { 'digital' });
+ retval.pins{end+1} = arduinoio.config.pin_info('D38', 38, { 'digital' });
+ retval.pins{end+1} = arduinoio.config.pin_info('D39', 39, { 'digital', 'analog' }, {'a3'});
+
+%{
+ analog are in the digital pins
+ retval.pins{end+1} = arduinoio.config.pin_info('A0', 40, { 'digital', 'analog' });
+ retval.pins{end+1} = arduinoio.config.pin_info('A1', 41, { 'digital', 'analog' });
+ retval.pins{end+1} = arduinoio.config.pin_info('A2', 42, { 'digital', 'analog' });
+ retval.pins{end+1} = arduinoio.config.pin_info('A3', 43, { 'digital', 'analog' });
+ retval.pins{end+1} = arduinoio.config.pin_info('A4', 44, { 'digital', 'analog' });
+ retval.pins{end+1} = arduinoio.config.pin_info('A5', 45, { 'digital', 'analog' });
+ retval.pins{end+1} = arduinoio.config.pin_info('A6', 46, { 'digital', 'analog' });
+ retval.pins{end+1} = arduinoio.config.pin_info('A7', 47, { 'digital', 'analog' });
+ retval.pins{end+1} = arduinoio.config.pin_info('A8', 48, { 'digital', 'analog' });
+ retval.pins{end+1} = arduinoio.config.pin_info('A9', 49, { 'digital', 'analog' });
+ retval.pins{end+1} = arduinoio.config.pin_info('A10', 50, { 'digital', 'analog' });
+ retval.pins{end+1} = arduinoio.config.pin_info('A11', 51, { 'digital', 'analog' });
+ retval.pins{end+1} = arduinoio.config.pin_info('A12', 52, { 'digital', 'analog' });
+ retval.pins{end+1} = arduinoio.config.pin_info('A13', 53, { 'digital', 'analog' });
+ retval.pins{end+1} = arduinoio.config.pin_info('A14', 54, { 'digital', 'analog' });
+ retval.pins{end+1} = arduinoio.config.pin_info('A15', 55, { 'digital', 'analog' });
+%}
+endfunction
diff --git a/inst/+arduinoio/boardTypeString.m b/inst/+arduinoio/boardTypeString.m
index 798117b..9a46fd9 100644
--- a/inst/+arduinoio/boardTypeString.m
+++ b/inst/+arduinoio/boardTypeString.m
@@ -65,6 +65,8 @@ function retval = boardTypeString (id)
retval = "raspi_pico";
case 101
retval = "nano_rp2040_connect";
+ case 111
+ retval = "esp32_dev";
otherwise
retval = "unknown";
endswitch
diff --git a/inst/+arduinoio/lib/LibraryBase.cpp b/inst/+arduinoio/lib/LibraryBase.cpp
index 399b827..4a65897 100644
--- a/inst/+arduinoio/lib/LibraryBase.cpp
+++ b/inst/+arduinoio/lib/LibraryBase.cpp
@@ -31,7 +31,11 @@
#define STATE_EOM 5
#if defined(OCTAVE_USE_WIFI_COMMS)
+# ifdef ARDUINO_ARCH_ESP32
+ #include <WiFi.h>
+# else
#include <WiFiNINA.h>
+# endif
char wifi_ssid[] = WIFI_SECRET_SSID; // your network SSID (name)
char wifi_pass[] = WIFI_SECRET_PASS;
@@ -234,9 +238,9 @@ OctaveArduinoClass::processMessage (uint8_t libid, uint8_t cmd, uint8_t *data, u
}
#if defined(WIFI_STATIC_IP)
-static IPAddress make_ip_address(const char *str)
+
+static int get_ip_parts(const char *str, uint8_t parts[4])
{
- uint8_t parts[4];
uint8_t i = 0;
uint8_t o = 0;
@@ -255,8 +259,23 @@ static IPAddress make_ip_address(const char *str)
}
i++;
}
+ return o;
+}
+
+static IPAddress make_ip_address(const char *str)
+{
+ uint8_t parts[4];
+ get_ip_parts(str, parts);
return IPAddress(parts[0], parts[1], parts[2], parts[3]);
}
+
+static IPAddress make_gateway_address(const char *str)
+{
+ uint8_t parts[4];
+ get_ip_parts(str, parts);
+ return IPAddress(parts[0], parts[1], parts[2], 1);
+}
+
#endif
void
@@ -264,11 +283,19 @@ OctaveArduinoClass::init ()
{
OCTAVE_COMMS_PORT.begin (9600);
#if defined(OCTAVE_USE_WIFI_COMMS)
+
+#ifdef ARDUINO_ARCH_ESP32
+ WiFi.begin(wifi_ssid, wifi_pass);
+#endif
while(!OCTAVE_COMMS_PORT) {}
#if defined(WIFI_STATIC_IP)
+#ifdef ARDUINO_ARCH_ESP32
+ WiFi.config(make_ip_address(WIFI_STATIC_IP), make_gateway_address(WIFI_STATIC_IP), IPAddress(255, 255, 0, 0));
+#else
WiFi.config(make_ip_address(WIFI_STATIC_IP));
#endif
+#endif
while (wifi_status != WL_CONNECTED) {
OCTAVE_COMMS_PORT.println("Attempting to connect to nework...");
diff --git a/inst/+arduinoio/lib/LibraryBase.h b/inst/+arduinoio/lib/LibraryBase.h
index 2751262..b9d9083 100644
--- a/inst/+arduinoio/lib/LibraryBase.h
+++ b/inst/+arduinoio/lib/LibraryBase.h
@@ -22,16 +22,18 @@
#include <Arduino.h>
#define VERSION_MAJOR 0
-#define VERSION_MINOR 9
-#define VERSION_PATCH 1
+#define VERSION_MINOR 10
+#define VERSION_PATCH 0
#if defined(ARDUINO_SAM_DUE)
# define OCTAVE_COMMS_PORT SERIAL_PORT_MONITOR
#elif defined(SERIAL_PORT_USBVIRTUAL)
// sparkfun samed21 dev/mini
# define OCTAVE_COMMS_PORT SERIAL_PORT_USBVIRTUAL
-#else
+#elif defined(SERIAL_PORT_MONITOR)
# define OCTAVE_COMMS_PORT SERIAL_PORT_MONITOR
+#else
+# define OCTAVE_COMMS_PORT Serial
#endif
class OctaveLibraryBase
diff --git a/inst/+arduinoio/lib/OctaveCoreLibrary.cpp b/inst/+arduinoio/lib/OctaveCoreLibrary.cpp
index 0131d90..fae1182 100644
--- a/inst/+arduinoio/lib/OctaveCoreLibrary.cpp
+++ b/inst/+arduinoio/lib/OctaveCoreLibrary.cpp
@@ -19,6 +19,11 @@
#include "settings.h"
#include "OctaveCoreLibrary.h"
+#ifdef ARDUINO_ARCH_ESP32
+ // contains analogWrite
+ #include <ESP32Servo.h>
+#endif
+
#define ARDUINO_RESET 0
#define ARDUINO_INIT 1
#define ARDUINO_CONFIGPIN 2
@@ -92,6 +97,9 @@
#ifndef ARDUINO_ARCH_MBED
#error "Expected mbed architechture"
#endif
+#elif defined(ARDUINO_ESP32_DEV)
+ #define BOARD_ID 111
+ #define BOARD_VOLTAGE 33
#else
#error "Unknown board type"
#endif
@@ -163,6 +171,12 @@ reset ()
// processor software reset
NVIC_SystemReset ();
}
+#elif defined (ARDUINO_ARCH_ESP32)
+void
+reset ()
+{
+ ESP.restart ();
+}
#else
#error("Unimplemented architecture for reset")
#endif
diff --git a/inst/+arduinoio/lib/OctaveI2CLibrary.cpp b/inst/+arduinoio/lib/OctaveI2CLibrary.cpp
index 36eb5ae..7eeda0f 100644
--- a/inst/+arduinoio/lib/OctaveI2CLibrary.cpp
+++ b/inst/+arduinoio/lib/OctaveI2CLibrary.cpp
@@ -44,6 +44,10 @@ static uint8_t i2c_address = 0;
# endif
#endif
+#if !defined(ARDUINO_ARCH_ESP32)
+ #define I2C_SUPPORTS_ENDCALL 1
+#endif
+
#endif
OctaveI2CLibrary::OctaveI2CLibrary (OctaveArduinoClass &oc)
@@ -289,9 +293,11 @@ OctaveI2CLibrary::commandHandler (uint8_t cmdID, uint8_t* data, uint8_t datasz)
if (!i2c_enabled[data[0]])
{
+#if defined (I2C_SUPPORTS_ENDCALL)
if(data[0] == 0) Wire.end ();
-#if WIRE_INTERFACES_COUNT > 1
+# if WIRE_INTERFACES_COUNT > 1
if(data[0] == 1) Wire1.end ();
+# endif
#endif
}
sendResponseMsg (cmdID, data, 3);
@@ -368,10 +374,11 @@ OctaveI2CLibrary::commandHandler (uint8_t cmdID, uint8_t* data, uint8_t datasz)
else
{
// disable
-
+#if defined (I2C_SUPPORTS_ENDCALL)
if (data[0] == 0) Wire.end ();
-#if WIRE_INTERFACES_COUNT > 1
+# if WIRE_INTERFACES_COUNT > 1
if (data[0] == 1) Wire1.end ();
+# endif
#endif
i2c_enabled[data[0]] = 0;
}
diff --git a/inst/+arduinoio/lib/OctaveServoLibrary.cpp b/inst/+arduinoio/lib/OctaveServoLibrary.cpp
index 6cde862..7261cca 100644
--- a/inst/+arduinoio/lib/OctaveServoLibrary.cpp
+++ b/inst/+arduinoio/lib/OctaveServoLibrary.cpp
@@ -24,7 +24,13 @@
#ifdef USE_SERVO
// NOTE: if cant fint servo.h, you probally dont have the Servo library installed
// go to Sketch -> Include Library -> Manage Libraries, and select 'Servo'
- #include <Servo.h>
+ // For ESP boards, it bwill need to be ESP32Servo
+# ifdef ARDUINO_ARCH_ESP32
+ #include <ESP32Servo.h>
+# else
+ #include <Servo.h>
+# endif
+
Servo servo[NUM_DIGITAL_PINS];
uint16_t servo_pos[NUM_DIGITAL_PINS];
#endif
diff --git a/inst/@arduino/__freeArduino__.m b/inst/@arduino/__freeArduino__.m
index 4a286f4..a59199e 100644
--- a/inst/@arduino/__freeArduino__.m
+++ b/inst/@arduino/__freeArduino__.m
@@ -18,9 +18,9 @@
function retval = __freeArduino__ (obj, port, board)
- if(obj.connected)
+ if isobject (obj.connected)
fclose(obj.connected);
- obj.connected = [];
+ obj.connected = false;
endif
retval = obj;
diff --git a/inst/@arduino/__initArduino__.m b/inst/@arduino/__initArduino__.m
index 56bd854..8edc7be 100644
--- a/inst/@arduino/__initArduino__.m
+++ b/inst/@arduino/__initArduino__.m
@@ -33,6 +33,16 @@ function retval = __initArduino__ (obj, port, board)
endif
# need wait for aduino to potentially startup
pause(2);
+
+ # clear any data in buffers
+ set(obj.connected, "timeout", 1);
+ data = fread(obj.connected,100);
+ while length(data) >= 100
+ data = fread(obj.connected,100);
+ if obj.debug
+ printf("flushing %d bytes of data\n", length(data));
+ endif
+ endwhile
[dataout, status] = __sendCommand__(obj, 0, ARDUINO_INIT);
if status != 0
diff --git a/inst/@arduino/arduino.m b/inst/@arduino/arduino.m
index b94a7be..1632104 100644
--- a/inst/@arduino/arduino.m
+++ b/inst/@arduino/arduino.m
@@ -49,6 +49,9 @@ classdef arduino < handle
## name assigned to the arduino object
## @item debug
## true / false flag for whether debug in turned on
+ ## @item forcebuildon
+ ## true / false flag for whether to force show of the arduino IDE to
+ ## reprogram the arduino
## @item port (read only)
## the communications port the board is connected to.
## @item board (read only)
@@ -144,6 +147,7 @@ classdef arduino < handle
requiredlibs = {};
forcebuild = false;
+ forcebuildon = false;
for i = 3:2:nargin
propname = tolower (varargin{i});
propvalue = varargin{i+1};
@@ -163,6 +167,14 @@ classdef arduino < handle
error ("arduino: expect libraries value to be a libraryname or cellarray of library names");
endif
endif
+ if strcmp (propname,"forcebuildon")
+ if islogical (propvalue) || (isnumeric(propvalue) && (propvalue == 1 || propvalue == 0))
+ forcebuildon = propvalue;
+ else
+ error ("arduino: expect forcebuildon to be true or false");
+ endif
+ endif
+ # older option that probally should remove
if strcmp (propname,"forcebuild")
if islogical (propvalue) || (isnumeric(propvalue) && (propvalue == 1 || propvalue == 0))
forcebuild = propvalue;
@@ -177,22 +189,27 @@ classdef arduino < handle
# check have requested libs
reprogram = false;
- for i = 1:numel (requiredlibs)
- lib = requiredlibs{i};
- id = this.get_lib (lib);
- if id < 0
- availablelibs = listArduinoLibraries ();
- idx = find( cellfun(@(x) strcmpi(x, lib), availablelibs), 1);
- if isempty (idx)
- error ('arduino: unknown library "%s"', lib);
- elseif forcebuild
- warning ('arduino: not configured with library "%s" - will need to reprogram', lib);
- reprogram = true;
- else
- error ('arduino: not configured with library "%s" - please rerun arduinosetup with library, or set forcebuild', lib);
+ if forcebuildon
+ reprogram = true;
+ else
+ availablelibs = listArduinoLibraries ();
+
+ for i = 1:numel (requiredlibs)
+ lib = requiredlibs{i};
+ id = this.get_lib (lib);
+ if id < 0
+ idx = find( cellfun(@(x) strcmpi(x, lib), availablelibs), 1);
+ if isempty (idx)
+ error ('arduino: unknown library "%s"', lib);
+ elseif forcebuild
+ warning ('arduino: not configured with library "%s" - will need to reprogram', lib);
+ reprogram = true;
+ else
+ error ('arduino: not configured with library "%s" - please rerun arduinosetup with library, or set forcebuild', lib);
+ endif
endif
- endif
- endfor
+ endfor
+ endif
if reprogram
printf("starting reprogram process ....\n")
diff --git a/inst/@arduino/playTone.m b/inst/@arduino/playTone.m
index 4b3e35d..112ea7a 100644
--- a/inst/@arduino/playTone.m
+++ b/inst/@arduino/playTone.m
@@ -61,11 +61,11 @@ function playTone (obj, pin, freq, duration)
endif
freq = uint16(freq);
- freqh = bitshift (freq, -8)
+ freqh = bitshift (freq, -8);
freql = bitand(freq, hex2dec('FF'));
duration = uint16(duration*10);
- durh = bitshift (duration, -8)
+ durh = bitshift (duration, -8);
durl = bitand(duration, hex2dec('FF'));
datain = uint8([pininfo.id freqh freql durh durl]);