Browse Source

added log messages

tags/v1.0.0
Simon Schmidt 2 years ago
parent
commit
125b39a418
2 changed files with 41 additions and 35 deletions
  1. 5
    0
      lib/httpserver/httpserver.cpp
  2. 36
    35
      src/main.cpp

+ 5
- 0
lib/httpserver/httpserver.cpp View File



if (argName(i).equals("range_act_pwm")) { if (argName(i).equals("range_act_pwm")) {
treppe->set_active_pwm(arg(i).toInt(), VORGABE_PROZENT); treppe->set_active_pwm(arg(i).toInt(), VORGABE_PROZENT);
logt("set_active_pwm = %d %\n", arg(i).toInt());
} }
else if (argName(i).equals("range_idl_pwm")) { else if (argName(i).equals("range_idl_pwm")) {
treppe->set_idle_pwm_max(arg(i).toInt(), VORGABE_PROZENT); treppe->set_idle_pwm_max(arg(i).toInt(), VORGABE_PROZENT);
logt("set_idle_pwm_max = %d %\n", arg(i).toInt());
} }
else if (argName(i).equals("range_tim_sta")) { else if (argName(i).equals("range_tim_sta")) {
treppe->set_time_per_stair(arg(i).toInt()); treppe->set_time_per_stair(arg(i).toInt());
logt("set_time_per_stair = %d\n", arg(i).toInt());
} }
else if (argName(i).equals("range_tim_ldr")) { else if (argName(i).equals("range_tim_ldr")) {
treppe->set_time_ldr(arg(i).toInt()); treppe->set_time_ldr(arg(i).toInt());
logt("set_time_ldr = %d\n", arg(i).toInt());
} }
else if (argName(i).equals("range_ldr_shw")) { else if (argName(i).equals("range_ldr_shw")) {
treppe->set_ldr_schwelle(arg(i).toInt(), VORGABE_PROZENT); treppe->set_ldr_schwelle(arg(i).toInt(), VORGABE_PROZENT);
logt("set_ldr_schwelle = %d %\n", arg(i).toInt());
} }


} }

+ 36
- 35
src/main.cpp View File

#endif #endif


#include "PCA9685.h" #include "PCA9685.h"
extern "C" {
#include "user_interface.h"
extern "C" {
#include "user_interface.h"
} }
// OTA & WEB // OTA & WEB
#include "httpserver.h" #include "httpserver.h"
Treppe stairs(16); Treppe stairs(16);


// WIFI // WIFI
const char* ssid = STASSID;
const char* password = STAPSK;
const char *ssid = STASSID;
const char *password = STAPSK;


// port 80, root directory of server '/' // port 80, root directory of server '/'
HTTPServer httpServer(80, "/", &stairs); HTTPServer httpServer(80, "/", &stairs);


uint32_t _t=0;
#define SP_US(_str,_a) Serial.print(_str); Serial.print(" took: "); Serial.print(_a); Serial.println("us")
#define TIMEIF_US(_f, _l, _str) _t=micros(); _f; _t=micros()-_t; if(_t > (_l)) { SP_US(_str, _t); }

struct { // Struct for wifi-data, 40 Bytes each SSID and PW
char SSID[40] = "";
char PW[40] = "";
} wifi_data;
uint32_t _t = 0;
#define SP_US(_str, _a) \
Serial.print(_str); \
Serial.print(" took: "); \
Serial.print(_a); \
Serial.println("us")
#define TIMEIF_US(_f, _l, _str) \
_t = micros(); \
_f; \
_t = micros() - _t; \
if (_t > (_l)) { \
SP_US(_str, _t); \
}


struct { // Struct for wifi-data, 40 Bytes each SSID and PW
char SSID[40] = "";
char PW[40] = "";
} wifi_data;


void timerCallback(void *pArg)
{
void timerCallback(void *pArg) {
*(static_cast<int *>(pArg)) += 1; *(static_cast<int *>(pArg)) += 1;
stairs.task(); stairs.task();
} }


// =============================================== // ===============================================
uint8_t inter = 0; uint8_t inter = 0;
ICACHE_RAM_ATTR void int_test(){
inter = 1;
}
ICACHE_RAM_ATTR void int_test() { inter = 1; }


void setup() { void setup() {
#ifdef WITH_DEBUGGING_ON #ifdef WITH_DEBUGGING_ON
Serial.println("Booting ...."); Serial.println("Booting ....");
pinMode(ESP12_LED, OUTPUT); pinMode(ESP12_LED, OUTPUT);


EEPROM.begin(512); // init virtual "EEPROM" with size 512 Bytes
EEPROM.begin(512); // init virtual "EEPROM" with size 512 Bytes


//strncpy(wifi_data.SSID, "donotconnect", 40);
//strncpy(wifi_data.PW, "unsafe lol", 40);
// strncpy(wifi_data.SSID, "donotconnect", 40);
// strncpy(wifi_data.PW, "unsafe lol", 40);


EEPROM.get(0, wifi_data); EEPROM.get(0, wifi_data);
//EEPROM.commit();
// EEPROM.commit();


Wire.begin(); // Wire must be started first
Wire.setClock(1000000); // Supported baud rates are 100kHz, 400kHz, and 1000kHz
Wire.begin(); // Wire must be started first
Wire.setClock(
1000000); // Supported baud rates are 100kHz, 400kHz, and 1000kHz
stairs.setup(); stairs.setup();
Serial.println("PCA9685 connected !"); Serial.println("PCA9685 connected !");
//attachInterrupt(digitalPinToInterrupt(2), int_test, RISING);
//attachInterrupt(digitalPinToInterrupt(12), int_test, RISING);
// attachInterrupt(digitalPinToInterrupt(2), int_test, RISING);
// attachInterrupt(digitalPinToInterrupt(12), int_test, RISING);


WiFi.mode(WIFI_STA); WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password); WiFi.begin(ssid, password);
os_timer_setfn(&timer1, timerCallback, &timer_flag); os_timer_setfn(&timer1, timerCallback, &timer_flag);
os_timer_arm(&timer1, 20, true); os_timer_arm(&timer1, 20, true);


Serial.println("SSID: " + String(wifi_data.SSID) + " PW: " + String(wifi_data.PW));
Serial.println("SSID: " + String(wifi_data.SSID) +
" PW: " + String(wifi_data.PW));
} }


uint32_t c = 0;

void loop() { void loop() {
if(inter != 0u){
if (inter != 0u) {
Serial.printf("interrupt\n"); Serial.printf("interrupt\n");
inter = 0; inter = 0;
} }
if(c++%1000000 == 0) { { {
httpServer.logt("[%d] starting :)\n", c);
}
}
}

TIMEIF_US(ArduinoOTA.handle(), 10000, "OTA"); TIMEIF_US(ArduinoOTA.handle(), 10000, "OTA");
TIMEIF_US(httpServer.handleClient(), 10000, "HTTP"); TIMEIF_US(httpServer.handleClient(), 10000, "HTTP");
} }

Loading…
Cancel
Save