mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-06 19:46:54 +03:00
Esp32s3 test (#3836)
* Added ethernet functionality * change smart leds to GPIO47 for now * Make etherenet code specific for the esp32-s3 board * Add 'sleep if idle' option for sleeping between rounds and change IO47 to IO12 for LED * minor fix, remove space * minor fix, add space * remove space
This commit is contained in:
@@ -230,6 +230,10 @@ void ClassFlowControll::setAutoStartInterval(long &_interval)
|
||||
_interval = AutoInterval * 60 * 1000; // AutoInterval: minutes -> ms
|
||||
}
|
||||
|
||||
void ClassFlowControll::setSleepWhileIdle(bool& _sleepwhileidle){
|
||||
_sleepwhileidle = SleepWhileIdle;
|
||||
}
|
||||
|
||||
ClassFlow* ClassFlowControll::CreateClassFlow(std::string _type)
|
||||
{
|
||||
ClassFlow* cfc = NULL;
|
||||
@@ -575,6 +579,10 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)
|
||||
}
|
||||
}
|
||||
|
||||
if ((toUpper(splitted[0]) == "SLEEPWHILEIDLE") && (splitted.size() > 1)) {
|
||||
SleepWhileIdle = alphanumericToBoolean(splitted[1]);
|
||||
}
|
||||
|
||||
if ((toUpper(splitted[0]) == "DATALOGACTIVE") && (splitted.size() > 1)) {
|
||||
LogFile.SetDataLogToSD(alphanumericToBoolean(splitted[1]));
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ protected:
|
||||
|
||||
bool AutoStart;
|
||||
float AutoInterval;
|
||||
bool SleepWhileIdle;
|
||||
void SetInitialParameter(void);
|
||||
std::string aktstatusWithTime;
|
||||
std::string aktstatus;
|
||||
@@ -72,6 +73,7 @@ public:
|
||||
|
||||
bool getIsAutoStart();
|
||||
void setAutoStartInterval(long &_interval);
|
||||
void setSleepWhileIdle(bool& _sleepwhileidle);
|
||||
|
||||
std::string* getActStatusWithTime();
|
||||
std::string* getActStatus();
|
||||
|
||||
@@ -43,6 +43,7 @@ bool bTaskAutoFlowCreated = false;
|
||||
bool flowisrunning = false;
|
||||
|
||||
long auto_interval = 0;
|
||||
bool sleep_while_idle = false;
|
||||
bool autostartIsEnabled = false;
|
||||
|
||||
int countRounds = 0;
|
||||
@@ -1659,6 +1660,7 @@ void task_autodoFlow(void *pvParameter)
|
||||
doInit();
|
||||
|
||||
flowctrl.setAutoStartInterval(auto_interval);
|
||||
flowctrl.setSleepWhileIdle(sleep_while_idle);
|
||||
autostartIsEnabled = flowctrl.getIsAutoStart();
|
||||
|
||||
if (isSetupModusActive())
|
||||
@@ -1739,11 +1741,22 @@ void task_autodoFlow(void *pvParameter)
|
||||
|
||||
if (auto_interval > fr_delta_ms)
|
||||
{
|
||||
if(sleep_while_idle){
|
||||
vTaskDelay(10000 / portTICK_PERIOD_MS);//A little more time so the user can finish config
|
||||
fr_delta_ms = (esp_timer_get_time() - fr_start) / 1000;
|
||||
if (auto_interval > fr_delta_ms){
|
||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Deep sleep for " + std::to_string(auto_interval - fr_delta_ms));
|
||||
|
||||
esp_sleep_enable_timer_wakeup((auto_interval - fr_delta_ms) * 1000); // Time in microseconds
|
||||
esp_deep_sleep_start();
|
||||
}
|
||||
}else{
|
||||
const TickType_t xDelay = (auto_interval - fr_delta_ms) / portTICK_PERIOD_MS;
|
||||
ESP_LOGD(TAG, "Autoflow: sleep for: %ldms", (long)xDelay);
|
||||
vTaskDelay(xDelay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
|
||||
@@ -349,7 +349,7 @@
|
||||
#define CAM_PIN_D7 GPIO_NUM_16
|
||||
#define CAM_PIN_D6 GPIO_NUM_17
|
||||
#define CAM_PIN_D5 GPIO_NUM_18
|
||||
#define CAM_PIN_D4 GPIO_NUM_12
|
||||
#define CAM_PIN_D4 GPIO_NUM_47
|
||||
#define CAM_PIN_D3 GPIO_NUM_10
|
||||
#define CAM_PIN_D2 GPIO_NUM_8
|
||||
#define CAM_PIN_D1 GPIO_NUM_9
|
||||
|
||||
@@ -112,20 +112,20 @@ HomeassistantDiscovery = false
|
||||
;ApiKey = undefined
|
||||
;UploadImg = 0
|
||||
|
||||
;[GPIO]
|
||||
;MainTopicMQTT = wasserzaehler/GPIO
|
||||
[GPIO]
|
||||
;IO0 = input disabled 10 false false
|
||||
;IO1 = input disabled 10 false false
|
||||
;IO3 = input disabled 10 false false
|
||||
;IO4 = built-in-led disabled 10 false false
|
||||
;IO12 = input-pullup disabled 10 false false
|
||||
IO12 = external-flash-ws281x disabled 10 false false
|
||||
;IO13 = input-pullup disabled 10 false false
|
||||
LEDType = WS2812
|
||||
LEDNumbers = 2
|
||||
LEDColor = 150 150 150
|
||||
LEDNumbers = 4
|
||||
LEDColor = 200 200 200
|
||||
|
||||
[AutoTimer]
|
||||
Interval = 5
|
||||
SleepWhileIdle = false
|
||||
|
||||
[DataLogging]
|
||||
DataLogActive = true
|
||||
|
||||
@@ -1974,6 +1974,19 @@
|
||||
<td>$TOOLTIP_AutoTimer_Interval</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="indent1">
|
||||
<class id="AutoTimer_SleepWhileIdle_text" style="color:black;">Sleep While Idle</class>
|
||||
</td>
|
||||
<td>
|
||||
<select id="AutoTimer_SleepWhileIdle_value1">
|
||||
<option value="true">enabled (true)</option>
|
||||
<option value="false" selected>disabled (false)</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>$TOOLTIP_AutoTimer_SleepWhileIdle</td>
|
||||
</tr>
|
||||
|
||||
<!------------- Data Logging ------------------>
|
||||
<tr style="border-bottom: 2px solid lightgray;">
|
||||
<td colspan="3" style="padding-left: 0px; padding-bottom: 3px;"><h4>Data Logging</h4></td>
|
||||
@@ -2402,6 +2415,7 @@ function UpdateInput() {
|
||||
|
||||
//WriteParameter(param, category, "AutoTimer", "AutoStart", false);
|
||||
WriteParameter(param, category, "AutoTimer", "Interval", false);
|
||||
WriteParameter(param, category, "AutoTimer", "SleepWhileIdle", false);
|
||||
|
||||
WriteParameter(param, category, "DataLogging", "DataLogActive", false);
|
||||
WriteParameter(param, category, "DataLogging", "DataFilesRetention", false);
|
||||
@@ -2578,6 +2592,7 @@ function ReadParameterAll() {
|
||||
|
||||
//ReadParameter(param, "AutoTimer", "AutoStart", false);
|
||||
ReadParameter(param, "AutoTimer", "Interval", false);
|
||||
ReadParameter(param, "AutoTimer", "SleepWhileIdle", false);
|
||||
|
||||
ReadParameter(param, "DataLogging", "DataLogActive", false);
|
||||
ReadParameter(param, "DataLogging", "DataFilesRetention", false);
|
||||
|
||||
Reference in New Issue
Block a user