Merge branch 'vedderb:master' into master

This commit is contained in:
JohnSpintend 2023-08-14 18:42:15 +08:00 committed by GitHub
commit ce2fb18167
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 1 deletions

View File

@ -23,6 +23,7 @@
* Added recv-to with a timeout argument.
* Added remote message extensions.
* Added phase-hall extension.
* Added loopwhile-thd.
* Hall sensors improvements:
* Smooth transition to sensorless.
* Bug fix in interpolation.

View File

@ -24,7 +24,7 @@
#define FW_VERSION_MAJOR 6
#define FW_VERSION_MINOR 05
// Set to 0 for building a release and iterate during beta test builds
#define FW_TEST_VERSION_NUMBER 12
#define FW_TEST_VERSION_NUMBER 13
#include "datatypes.h"

View File

@ -3146,6 +3146,38 @@ f
---
#### loopwhile-thd
| Platforms | Firmware |
|---|---|
| ESC, Express | 6.05+ |
```clj
(loopwhile-thd stack cond body)
```
While-loop that starts in a new thread. The argument stack is the stack-size of the thread, cond is the condition that has the be true for the loop to continue running and body is the code to execute each iteration. The difference from the regular loopwhile is that the evaluator will continue running the code after this one before this one finishes, as this loop is evaluated in a new thread.
Example that forever prints "Hello World" every two seconds:
```clj
; Note: This example uses the curly backet for progn for convenience
(loopwhile-thd 100 t {
(print "Hello World")
(sleep 2)
})
; The above is equivalent to the following code
(spawn 100 (fn () (loopwhile t {
(print "Hello World")
(sleep 2)
})))
```
---
#### break
| Platforms | Firmware |

View File

@ -87,6 +87,7 @@ static const char* macros[] = {
"(define loopwhile (macro (cnd body) (me-loopwhile cnd body)))",
"(define looprange (macro (it start end body) (me-looprange it start end body)))",
"(define loopforeach (macro (it lst body) (me-loopforeach it lst body)))",
"(define loopwhile-thd (macro (stk cnd body) `(spawn ,stk (fn () (loopwhile ,cnd ,body)))))",
};
static bool strmatch(const char *str1, const char *str2) {