Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
LKosoj committed Jan 2, 2023
1 parent 51a32a1 commit 06dcd00
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 6 deletions.
6 changes: 2 additions & 4 deletions Samovar.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#error This code is designed to run on ESP32 platform, not Arduino nor ESP8266! Please check your Tools->Board setting.
#endif

#define SAMOVAR_VERSION "5.17"
#define SAMOVAR_VERSION "5.18"
//#define __SAMOVAR_DEBUG

#include <OneWire.h>
Expand All @@ -15,7 +15,7 @@

#ifdef __SAMOVAR_DEBUG
#ifndef USE_WEB_SERIAL
#define USE_WEB_SERIAL //использовать библиотеку WebSerial для отладки
//#define USE_WEB_SERIAL //использовать библиотеку WebSerial для отладки
#endif
#endif

Expand Down Expand Up @@ -382,8 +382,6 @@ GStepper< STEPPER2WIRE> stepper(STEPPER_STEPS, STEPPER_STEP, STEPPER_DIR, STEPPE

File fileToAppend;

//AsyncMqttClient mqttClient;

#ifdef SERVO_PIN
Servo servo; // create servo object to control a servo
#endif
Expand Down
34 changes: 34 additions & 0 deletions WebServer.ino
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <asyncHTTPrequest.h>

void web_command(AsyncWebServerRequest *request);
void handleSave(AsyncWebServerRequest *request);
void get_data_log(AsyncWebServerRequest *request);
Expand All @@ -11,6 +13,8 @@ String get_DSAddressList(String Address);
void set_pump_speed(float pumpspeed, bool continue_process);
void start_self_test(void);
void stop_self_test(void);
void get_web_file(String fn);

#ifdef USE_LUA
void start_lua_script();
void load_lua_script();
Expand Down Expand Up @@ -74,6 +78,7 @@ void WebServerInit(void) {
server.serveStatic("/program_grain.txt", SPIFFS, "/program_grain.txt");
server.serveStatic("/program_shugar.txt", SPIFFS, "/program_shugar.txt");
server.serveStatic("/brewxml.htm", SPIFFS, "/brewxml.htm").setTemplateProcessor(indexKeyProcessor);
server.serveStatic("/test.txt", SPIFFS, "/test.txt").setTemplateProcessor(indexKeyProcessor);

#ifdef USE_LUA
server.serveStatic("/btn_button1.lua", SPIFFS, "/btn_button1.lua");
Expand Down Expand Up @@ -149,6 +154,9 @@ void WebServerInit(void) {
#ifdef __SAMOVAR_DEBUG
Serial.println("HTTP server started");
#endif

// get_web_file("http://worldtimeapi.org/api/timezone/Europe/London.txt");

}

String indexKeyProcessor(const String &var) {
Expand Down Expand Up @@ -805,3 +813,29 @@ void get_old_data_log(AsyncWebServerRequest *request) {
response->addHeader("Cache-Control", "no-cache");
request->send(response);
}

void get_web_file(String fn) {
asyncHTTPrequest request;
//request.setDebug(true);
request.setTimeout(10); //Таймаут три секунды
request.open(String("GET").c_str(), fn.c_str()); //URL
while (request.readyState() < 1) {
vTaskDelay(5 / portTICK_PERIOD_MS);
}
vTaskDelay(65 / portTICK_PERIOD_MS);
request.send();
while (request.readyState() != 4) {
vTaskDelay(5 / portTICK_PERIOD_MS);
}
if (request.responseHTTPcode() >= 0) {
//Serial.println(request.responseHTTPcode());
File wf = SPIFFS.open("/test.txt", FILE_WRITE);
wf.print(request.responseText());
wf.close();
Serial.println("Done");
}
else {
Serial.println("error");
Serial.println(request.responseHTTPcode());
}
}
9 changes: 9 additions & 0 deletions libraries/GyverButton/src/GyverButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ void GButton::setTickMode(bool tickMode) {
flags.tickMode = tickMode;
}


// ==================== IS ====================
boolean GButton::isPress() {
if (flags.tickMode) GButton::tick();
Expand Down Expand Up @@ -146,6 +147,14 @@ void GButton::resetStates() {
flags.counter_flag = false;
last_hold_counter = 0;
last_counter = 0;
///////////////////////////////
//!!!!!NOT REMOVE!!!!!!
///////////////////////////////
btn_state = false;
btn_timer = 0;
btn_flag = false;
flags.hold_flag = false;
///////////////////////////////
}

// ==================== TICK ====================
Expand Down
1 change: 1 addition & 0 deletions libraries/asyncHTTPrequest/examples/sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ void requestCB(void* optParm, asyncHTTPrequest* request, int readyState){
request->setDebug(false);
}
}


void setup(){
Serial.begin(115200);
Expand Down
2 changes: 1 addition & 1 deletion libraries/asyncHTTPrequest/src/asyncHTTPrequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class asyncHTTPrequest {
bool open(const char* /*GET/POST*/, const char* URL); // Initiate a request
void onReadyStateChange(readyStateChangeCB, void* arg = 0); // Optional event handler for ready state change
// or you can simply poll readyState()
void setTimeout(int); // overide default timeout (seconds)
void setTimeout(int); // overide default timeout (seconds)
void setReqHeader(const char* name, const char* value); // add a request header
void setReqHeader(const char* name, const __FlashStringHelper* value);
void setReqHeader(const __FlashStringHelper *name, const char* value);
Expand Down
2 changes: 2 additions & 0 deletions logic.h
Original file line number Diff line number Diff line change
Expand Up @@ -558,9 +558,11 @@ void IRAM_ATTR check_alarm() {
if (program[ProgramNum].WType != "C") {
set_buzzer(true);
SendMsg(F("Сработал датчик захлёба!"), ALARM_MSG);
#ifdef SAMOVAR_USE_POWER
alarm_c_min = 0;
alarm_c_low_min = 0;
prev_target_power_volt = 0;
#endif
} else {
#ifdef SAMOVAR_USE_POWER
//запускаем счетчик - TIME_C минут, нужен для возврата заданного напряжения
Expand Down
10 changes: 9 additions & 1 deletion lua.h
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,10 @@ static int lua_wrapper_http_request(lua_State *lua_state) {
if (n == 1) {
RequestType = "GET";
request.open(RequestType.c_str(), Var.c_str()); //URL
while (request.readyState() < 1) {
vTaskDelay(5 / portTICK_PERIOD_MS);
}
vTaskDelay(65 / portTICK_PERIOD_MS);
request.send();
} else {
String ContentType;
Expand Down Expand Up @@ -618,12 +622,16 @@ static int lua_wrapper_http_request(lua_State *lua_state) {
lua_pop(lua_state, 1);

request.open(RequestType.c_str(), Var.c_str()); //URL
while (request.readyState() < 1) {
vTaskDelay(5 / portTICK_PERIOD_MS);
}
vTaskDelay(65 / portTICK_PERIOD_MS);
request.setReqHeader(String("Content-Type").c_str(), getValue(ContentType, ':', 1).c_str());
request.send(Body);
}

while (request.readyState() != 4) {
vTaskDelay(10 / portTICK_PERIOD_MS);
vTaskDelay(5 / portTICK_PERIOD_MS);
}
if (request.responseHTTPcode() >= 0) {
payload = request.responseText();
Expand Down
7 changes: 7 additions & 0 deletions sensorinit.h
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,11 @@ void IRAM_ATTR reset_sensor_counter(void) {
set_capacity(0);
alarm_h_min = 0;
alarm_t_min = 0;
#ifdef SAMOVAR_USE_POWER
alarm_c_min = 0;
alarm_c_low_min = 0;
prev_target_power_volt = 0;
#endif
d_s_time_min = 0;
d_s_temp_finish = 0;

Expand Down Expand Up @@ -409,6 +412,10 @@ void IRAM_ATTR reset_sensor_counter(void) {

boil_started = false;

if (xSemaphore != NULL) xSemaphoreGive(xSemaphore);
#ifdef SAMOVAR_USE_SEM_AVR
if (xSemaphoreAVR != NULL) xSemaphoreGive(xSemaphoreAVR);
#endif

set_power(false);
sam_command_sync = SAMOVAR_NONE;
Expand Down

0 comments on commit 06dcd00

Please sign in to comment.