Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions .github/workflows/fix-indent.yml

This file was deleted.

6 changes: 2 additions & 4 deletions examples/FastLED_example/FastLED_example.ino
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@

#define USE_FASTLED
#include "FastLED.h"
#include "ESPLiveScript.h"
#include "FastLED.h"
#define NUM_LEDS 256
#define DATA_PIN 15
CRGB leds[NUM_LEDS];
void show() {
FastLED.show();
}
void show() { FastLED.show(); }
string script = R"EOF(
void main()
{
Expand Down
39 changes: 17 additions & 22 deletions examples/executebinary/executebinary.ino
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
#include "ESPLivescriptRuntime.h"
#include <LittleFS.h>
#include "FS.h"
#include <LittleFS.h>

void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);

Binary bin2;
LittleFS.begin(true);
Binary bin2;
LittleFS.begin(true);

loadBinary("/test.bin", LittleFS, &bin2);
Executable ex;
if (bin2.error.error)
{
Serial.printf("%s\n", bin2.error.error_message.c_str());
}
else
{
ex.createExecutableFromBinary(&bin2);
if (ex.isExeExists())
ex.execute("main");
}
loadBinary("/test.bin", LittleFS, &bin2);
Executable ex;
if (bin2.error.error) {
Serial.printf("%s\n", bin2.error.error_message.c_str());
} else {
ex.createExecutableFromBinary(&bin2);
if (ex.isExeExists())
ex.execute("main");
}
}

void loop()
{
// put your main code here, to run repeatedly:
void loop() {
// put your main code here, to run repeatedly:
}
12 changes: 4 additions & 8 deletions examples/externalvariables/externalvariables.ino
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,15 @@ void main()

int variable = 0;
uint16_t _array[10];
void setup()
{
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);

Parser p;
addExternalVariable("value", "int", "", (void *)&variable);
addExternalVariable("array", "int *", "", (void *)_array);
Executable exec = p.parseScript(&script);
if (exec.isExeExists())
{
if (exec.isExeExists()) {

variable = 5;
exec.execute("main");
Expand All @@ -41,14 +39,12 @@ void setup()
exec.execute("change");
printf("new value:%d\n", variable);
exec.execute("fillArray");
for (int i = 0; i < 10; i++)
{
for (int i = 0; i < 10; i++) {
printf("%d:%d\n", i, _array[i]);
}
}
}

void loop()
{
void loop() {
// put your main code here, to run repeatedly:
}
39 changes: 18 additions & 21 deletions examples/factorial/factorial.ino
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,25 @@ void main(int g)
}
)EOF";

void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);

Parser p;
Executable exec = p.parseScript(&script);
if (exec.isExeExists())
{
Arguments args;
args.add(5);
exec.execute("main", args);
args.clear();
args.add(6);
exec.execute("main", args);
args.clear();
args.add(7);
exec.execute("main", args);
}
Parser p;
Executable exec = p.parseScript(&script);
if (exec.isExeExists()) {
Arguments args;
args.add(5);
exec.execute("main", args);
args.clear();
args.add(6);
exec.execute("main", args);
args.clear();
args.add(7);
exec.execute("main", args);
}
}

void loop()
{
// put your main code here, to run repeatedly:
void loop() {
// put your main code here, to run repeatedly:
}
9 changes: 3 additions & 6 deletions examples/firstlight/firstlight.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,17 @@ for(int i=0;i<20;i++)
}
}
)EOF";
void setup()
{
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);

Parser p;
Executable exec = p.parseScript(&script);
if (exec.isExeExists())
{
if (exec.isExeExists()) {
exec.execute("main");
}
}

void loop()
{
void loop() {
// put your main code here, to run repeatedly:
}
33 changes: 14 additions & 19 deletions examples/jsonexample/jsonexample.ino
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,22 @@ void main()
}
)EOF";

void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);

Parser p;
Executable exec = p.parseScript(&script);
printf("copmùpile done\n");
if (exec.isExeExists())
{
Parser p;
Executable exec = p.parseScript(&script);
printf("copmùpile done\n");
if (exec.isExeExists()) {

exec.execute("main", "{\"dp\":{\"value\":6,\"test\":12},\"dp2\":4.5}");
exec.execute("main", "{\"dp\":{\"value\":10,\"test\":20},\"dp2\":7.5854}");
}
else
{
printf("%s\n", exec.error.error_message.c_str());
}
exec.execute("main", "{\"dp\":{\"value\":6,\"test\":12},\"dp2\":4.5}");
exec.execute("main", "{\"dp\":{\"value\":10,\"test\":20},\"dp2\":7.5854}");
} else {
printf("%s\n", exec.error.error_message.c_str());
}
}

void loop()
{
// put your main code here, to run repeatedly:
void loop() {
// put your main code here, to run repeatedly:
}
24 changes: 11 additions & 13 deletions examples/pininterrupt/pininterrupt.ino
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
#include "ESPLiveScript.h"
#include "driver/gpio.h"

typedef struct
{
typedef struct {
Executable *ptr;
char *name;
uint32_t last;
uint32_t _new;
} call_isr;
call_isr isr_struct;


static void IRAM_ATTR gpio_isr_handler(void *args) {
call_isr *ll = (call_isr *)args;
unsigned long currentTime = millis();

if ((currentTime - ll->last) > 100) {
ll->ptr->executeOnly(string(ll->name));
ll->last = currentTime; // Update the last interrupt time
ll->last = currentTime; // Update the last interrupt time
}
}
void setup_gpio_interrupt(Executable *ptr, char *str, int pin_num) {
printf("Setting up the interrupt\n");
gpio_config_t io_conf = {
.pin_bit_mask = (1ULL << pin_num),
.mode = GPIO_MODE_INPUT,
.pull_up_en = GPIO_PULLUP_ENABLE,
.pull_down_en = GPIO_PULLDOWN_DISABLE, // Disable pull-down
.intr_type = GPIO_INTR_NEGEDGE,
.pin_bit_mask = (1ULL << pin_num),
.mode = GPIO_MODE_INPUT,
.pull_up_en = GPIO_PULLUP_ENABLE,
.pull_down_en = GPIO_PULLDOWN_DISABLE, // Disable pull-down
.intr_type = GPIO_INTR_NEGEDGE,
};

gpio_config(&io_conf);
Expand Down Expand Up @@ -58,14 +56,14 @@ void main()

void setup() {
Serial.begin(115200);
addExternalFunction("pinInterrupt", "void", "uint32_t,char *,int", (void *)setup_gpio_interrupt);
addExternalFunction("pinInterrupt", "void", "uint32_t,char *,int",
(void *)setup_gpio_interrupt);
Parser p;
Executable exec = p.parseScript(&script);
if (exec.isExeExists()) {
exec.execute("main");
}
else {
printf("Error:%s\n",exec.error.error_message.c_str());
} else {
printf("Error:%s\n", exec.error.error_message.c_str());
}
// put your setup code here, to run once:
}
Expand Down
11 changes: 5 additions & 6 deletions examples/savebinary/savebinary.ino
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "ESPLiveScript.h"
#include <LittleFS.h>
#include "FS.h"
#include <LittleFS.h>
string script = R"EOF(
void main()
{
Expand All @@ -20,20 +20,19 @@ void setup() {
Binary bin2;
LittleFS.begin(true);
if (!bin.error.error) {
//display the content of the bin
// displayBinary(&bin);
//save the binary
// display the content of the bin
// displayBinary(&bin);
// save the binary
saveBinary("/test.bin", LittleFS, &bin);
freeBinary(&bin);

loadBinary("/test.bin", LittleFS, &bin2);
Executable ex;

ex.createExecutableFromBinary(&bin2);
if (ex.isExeExists())
ex.execute("main");


} else {
printf("%s\n\r", bin.error.error_message.c_str());
}
Expand Down
9 changes: 3 additions & 6 deletions examples/structure/structure.ino
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,17 @@ void main()
}
)EOF";

void setup()
{
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);

Parser p;
Executable exec = p.parseScript(&script);
if (exec.isExeExists())
{
if (exec.isExeExists()) {
exec.execute("main");
}
}

void loop()
{
void loop() {
// put your main code here, to run repeatedly:
}
Loading