is it possible to work with 2 setup() functions and 2 loop() within the ESP32-Arduino enviroment
Posted: Fri May 25, 2018 11:35 am
Hi all,
maybe a very,very silly question, but anyway here i go ...
Does anyone have a idea on using 1x ESP32 but using both cores with 2 separate programs in each one running arduino code
so one would need 2 void setup() and 2 void loop() functions... at first there is no need of data to travel between both loop() functions
For example declaring void setup1() to run once and void loop1() to continously loop, and then again with void setup2() and void loop2()???
something like this i mean :
That would make a big difference in the arduino/esp32 world... and be more than welcome, since at this moment we only use one core at a time within the ESP-Arduino, and if both cores are used, it is not dedicated witch one would be used for what part of the code, not?
So in that case, we are only using half of the power we have in hands with the ESP32 platform...
Grtz,
Yves
maybe a very,very silly question, but anyway here i go ...
Does anyone have a idea on using 1x ESP32 but using both cores with 2 separate programs in each one running arduino code
so one would need 2 void setup() and 2 void loop() functions... at first there is no need of data to travel between both loop() functions
For example declaring void setup1() to run once and void loop1() to continously loop, and then again with void setup2() and void loop2()???
something like this i mean :
Code: Select all
static uint32_t var1 = 0;
static uint32_t var2 = 0;
static uint32_t var3 = 1000;
void setup1(){ //should run only once
//code for this setup1() function on core 1
var1 = 1000000;
}
void setup2(){ //should also run only once on core 2
//code for this setup1() function
var2 = 250;
var3 = 0;
}
void loop()1{
// code to be checked over and over again for this loop()1 on core 1
dosomethingwithvar1();
}
void loop()2{
// code to be checked over and over again for this loop()2 on core 2
dosomethingwithvar2();
dosomethingwithvar3();
}
So in that case, we are only using half of the power we have in hands with the ESP32 platform...
Grtz,
Yves