解决了获取时间卡死bug
This commit is contained in:
45
.pio/libdeps/esp32dev/Vector/examples/PlatformIO/README.org
Normal file
45
.pio/libdeps/esp32dev/Vector/examples/PlatformIO/README.org
Normal file
@ -0,0 +1,45 @@
|
||||
#+TITLE: PlatformIO example
|
||||
|
||||
This example can be built using [[https://docs.platformio.org][PlatformIO]],
|
||||
instead of the Arduino IDE.
|
||||
|
||||
** Running the code
|
||||
|
||||
*** Platform: native
|
||||
|
||||
- To run the code in src/ natively:
|
||||
|
||||
#+BEGIN_SRC sh
|
||||
pio run -e native && .pio/build/native/program
|
||||
#+END_SRC
|
||||
|
||||
- To run the code in test/ natively:
|
||||
|
||||
#+BEGIN_SRC sh
|
||||
pio test -e native
|
||||
#+END_SRC
|
||||
|
||||
*** Platform: Arduino
|
||||
|
||||
Before doing any of this, edit =platformio.ini= for your board.
|
||||
|
||||
- To run the code in src/ on a device and then monitor its output:
|
||||
|
||||
#+BEGIN_SRC sh
|
||||
pio run -e uno -t upload && pio device monitor
|
||||
#+END_SRC
|
||||
|
||||
- To run the tests on a device:
|
||||
|
||||
#+BEGIN_SRC sh
|
||||
pio test -e uno
|
||||
#+END_SRC
|
||||
|
||||
*** All platforms at once
|
||||
|
||||
- To run the tests natively on all platforms described in `platformio.ini`:
|
||||
|
||||
#+BEGIN_SRC sh
|
||||
pio test
|
||||
#+END_SRC
|
||||
|
@ -0,0 +1,38 @@
|
||||
This directory is intended for project header files.
|
||||
|
||||
A header file is a file containing C declarations and macro definitions
|
||||
to be shared between several project source files. You request the use of a
|
||||
header file in your project source file (C, C++, etc) located in `src` folder
|
||||
by including it, with the C preprocessing directive `#include'.
|
||||
|
||||
```src/main.c
|
||||
|
||||
#include "header.h"
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Including a header file produces the same results as copying the header file
|
||||
into each source file that needs it. Such copying would be time-consuming
|
||||
and error-prone. With a header file, the related declarations appear
|
||||
in only one place. If they need to be changed, they can be changed in one
|
||||
place, and programs that include the header file will automatically use the
|
||||
new version when next recompiled. The header file eliminates the labor of
|
||||
finding and changing all the copies as well as the risk that a failure to
|
||||
find one copy will result in inconsistencies within a program.
|
||||
|
||||
In C, the usual convention is to give header files names that end with `.h'.
|
||||
It is most portable to use only letters, digits, dashes, and underscores in
|
||||
header file names, and at most one dot.
|
||||
|
||||
Read more about using header files in official GCC documentation:
|
||||
|
||||
* Include Syntax
|
||||
* Include Operation
|
||||
* Once-Only Headers
|
||||
* Computed Includes
|
||||
|
||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
45
.pio/libdeps/esp32dev/Vector/examples/PlatformIO/lib/README
Normal file
45
.pio/libdeps/esp32dev/Vector/examples/PlatformIO/lib/README
Normal file
@ -0,0 +1,45 @@
|
||||
This directory is intended for project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link into executable file.
|
||||
|
||||
The source code of each library should be placed in a an own separate directory
|
||||
("lib/your_library_name/[here are source files]").
|
||||
|
||||
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
||||
|
||||
|--lib
|
||||
| |
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
||||
| |
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |
|
||||
| |- README --> THIS FILE
|
||||
|
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
and a contents of `src/main.c`:
|
||||
```
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
PlatformIO Library Dependency Finder will find automatically dependent
|
||||
libraries scanning project source files.
|
||||
|
||||
More information about PlatformIO Library Dependency Finder
|
||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
@ -0,0 +1,32 @@
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter
|
||||
; Upload options: custom upload port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
; Advanced options: extra scripting
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
; common options for all environments
|
||||
[env]
|
||||
monitor_speed = 115200
|
||||
test_speed = 115200
|
||||
lib_deps =
|
||||
# https://github.com/janelia-arduino/Vector.git#branchname
|
||||
Vector
|
||||
|
||||
[env:uno]
|
||||
platform = atmelavr
|
||||
framework = arduino
|
||||
board = uno
|
||||
|
||||
; Documentation for native platform:
|
||||
; https://docs.platformio.org/en/latest/platforms/native.html
|
||||
[env:native]
|
||||
platform = native
|
||||
#build_flags = -DNATIVE
|
||||
#lib_deps =
|
||||
# ${env.lib_deps}
|
||||
# Dep1
|
||||
# Dep2
|
@ -0,0 +1,45 @@
|
||||
#ifdef ARDUINO
|
||||
# include <Arduino.h>
|
||||
#else
|
||||
# include <cstdio>
|
||||
#endif
|
||||
|
||||
#include <Vector.h>
|
||||
|
||||
char storage[] = { 'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd', '!', '\r', '\n' };
|
||||
Vector<char> vector(storage, sizeof(storage));
|
||||
|
||||
#ifdef ARDUINO
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
Serial.println("Starting up.");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print("Vector size is ");
|
||||
Serial.println(vector.size());
|
||||
|
||||
Serial.print("Vector content: ");
|
||||
for (unsigned int i = 0; i < vector.size(); i++) {
|
||||
Serial.print(vector.at(i));
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
#else /* !defined(ARDUINO) */
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
puts("Starting up.");
|
||||
printf("Vector size is %d\n", vector.size());
|
||||
|
||||
printf("Vector content: ");
|
||||
for (unsigned int i = 0; i < vector.size(); i++) {
|
||||
putchar(vector.at(i));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
10
.pio/libdeps/esp32dev/Vector/examples/PlatformIO/test/README
Normal file
10
.pio/libdeps/esp32dev/Vector/examples/PlatformIO/test/README
Normal file
@ -0,0 +1,10 @@
|
||||
This directory is intended for PlatformIO Unit Testing and project tests.
|
||||
|
||||
Unit Testing is a software testing method by which individual units of
|
||||
source code, sets of one or more MCU program modules together with associated
|
||||
control data, usage procedures, and operating procedures, are tested to
|
||||
determine whether they are fit for use. Unit testing finds problems early
|
||||
in the development cycle.
|
||||
|
||||
More information about PlatformIO Unit Testing:
|
||||
- https://docs.platformio.org/page/plus/unit-testing.html
|
@ -0,0 +1,60 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// test_vector.cpp
|
||||
//
|
||||
//
|
||||
// Authors:
|
||||
// Darsey Litzenberger dlitz@dlitz.net
|
||||
// ----------------------------------------------------------------------------
|
||||
#include <unity.h>
|
||||
#include <Vector.h>
|
||||
|
||||
static void test_vector_size() {
|
||||
int storage[8] = { 21, 42, 84, 0, 0, 0, 0, 0 };
|
||||
Vector<int> v(storage, 3);
|
||||
TEST_ASSERT_EQUAL(8, v.max_size());
|
||||
TEST_ASSERT_EQUAL(3, v.size());
|
||||
v.push_back(10);
|
||||
v.push_back(20);
|
||||
v.push_back(30);
|
||||
TEST_ASSERT_EQUAL(6, v.size());
|
||||
v.pop_back();
|
||||
TEST_ASSERT_EQUAL(5, v.size());
|
||||
}
|
||||
|
||||
static void test_vector_iterator() {
|
||||
int storage[8] = { 21, 42, 84, 0, 0, 0, 0, 0 };
|
||||
Vector<int> v(storage, 3);
|
||||
|
||||
const int expected[3] = { 21, 42, 84 };
|
||||
int i=0;
|
||||
for (auto it = v.begin(); it != v.end(); ++it, ++i) {
|
||||
TEST_ASSERT_EQUAL(expected[i], *it);
|
||||
}
|
||||
TEST_ASSERT_EQUAL(3, i);
|
||||
}
|
||||
|
||||
static void runTests() {
|
||||
UNITY_BEGIN();
|
||||
RUN_TEST(test_vector_size);
|
||||
RUN_TEST(test_vector_iterator);
|
||||
UNITY_END();
|
||||
}
|
||||
|
||||
#ifdef ARDUINO
|
||||
|
||||
void setup() {
|
||||
runTests();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
}
|
||||
|
||||
#else /* !defined(ARDUINO) */
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
runTests();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* !defined(ARDUINO) */
|
@ -0,0 +1,100 @@
|
||||
#include <Arduino.h>
|
||||
#include <Streaming.h>
|
||||
#include <Vector.h>
|
||||
|
||||
|
||||
const long BAUD = 115200;
|
||||
|
||||
const int ELEMENT_COUNT_MAX = 5;
|
||||
typedef Vector<int> Elements;
|
||||
const size_t DELAY = 500;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(BAUD);
|
||||
while (!Serial)
|
||||
{
|
||||
// wait for serial port to connect.
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
int storage_array[ELEMENT_COUNT_MAX];
|
||||
Elements vector;
|
||||
vector.setStorage(storage_array);
|
||||
Serial << "vector.max_size(): " << vector.max_size() << endl;
|
||||
Serial << "vector.size(): " << vector.size() << endl;
|
||||
Serial << "vector:" << endl;
|
||||
Serial << vector << endl;
|
||||
delay(DELAY);
|
||||
|
||||
vector.push_back(10);
|
||||
vector.push_back(8);
|
||||
vector.push_back(7);
|
||||
Serial << "vector.max_size(): " << vector.max_size() << endl;
|
||||
Serial << "vector.size(): " << vector.size() << endl;
|
||||
Serial << "vector:" << endl;
|
||||
Serial << vector << endl;
|
||||
vector.remove(0);
|
||||
Serial << "vector.remove(0):" << endl;
|
||||
Serial << vector << endl;
|
||||
vector.remove(1);
|
||||
Serial << "vector.remove(1):" << endl;
|
||||
Serial << vector << endl;
|
||||
delay(DELAY);
|
||||
|
||||
int storage_array2[ELEMENT_COUNT_MAX];
|
||||
Elements vector2(storage_array2);
|
||||
vector2.push_back(1);
|
||||
vector2.push_back(2);
|
||||
vector2.push_back(4);
|
||||
vector2.pop_back();
|
||||
Serial << "vector2.max_size(): " << vector2.max_size() << endl;
|
||||
Serial << "vector2.size(): " << vector2.size() << endl;
|
||||
Serial << "vector2:" << endl;
|
||||
Serial << vector2 << endl;
|
||||
delay(DELAY);
|
||||
Serial << "Print vector2 elements using iterators: ";
|
||||
for (int element : vector2)
|
||||
{
|
||||
Serial << element << " ";
|
||||
}
|
||||
Serial << endl;
|
||||
delay(DELAY);
|
||||
|
||||
int storage_array3[ELEMENT_COUNT_MAX];
|
||||
storage_array3[0] = 3;
|
||||
storage_array3[1] = 5;
|
||||
Elements vector3(storage_array3);
|
||||
Serial << "vector3.max_size(): " << vector3.max_size() << endl;
|
||||
Serial << "vector3.size(): " << vector3.size() << endl;
|
||||
Serial << "vector3:" << endl;
|
||||
Serial << vector3 << endl;
|
||||
delay(DELAY);
|
||||
|
||||
int storage_array4[ELEMENT_COUNT_MAX];
|
||||
storage_array4[0] = 3;
|
||||
storage_array4[1] = 5;
|
||||
Elements vector4(storage_array4,2);
|
||||
Serial << "vector4.max_size(): " << vector4.max_size() << endl;
|
||||
Serial << "vector4.size(): " << vector4.size() << endl;
|
||||
Serial << "vector4:" << endl;
|
||||
Serial << vector4 << endl;
|
||||
delay(DELAY);
|
||||
|
||||
int storage_array5[1];
|
||||
Elements vector5(storage_array5);
|
||||
Serial << "vector5.max_size(): " << vector5.max_size() << endl;
|
||||
Serial << "vector5.size(): " << vector5.size() << endl;
|
||||
Serial << "vector5:" << endl;
|
||||
Serial << vector5 << endl;
|
||||
delay(DELAY);
|
||||
|
||||
int storage_array6[ELEMENT_COUNT_MAX];
|
||||
Elements vector6(storage_array6);
|
||||
vector6.assign(ELEMENT_COUNT_MAX-1,8);
|
||||
Serial << "vector6:" << endl;
|
||||
Serial << vector6 << endl;
|
||||
delay(DELAY);
|
||||
}
|
Reference in New Issue
Block a user