Skip to content

Instantly share code, notes, and snippets.

View mcspr's full-sized avatar
⚕️
don't let it steal your eyes

Max Prokhorov mcspr

⚕️
don't let it steal your eyes
View GitHub Profile
#include <ESP8266WiFi.h>
void setup() {
delay(1000);
Serial.begin(115200);
Serial.println();
WiFi.mode(WIFI_OFF);
}
struct Auth {
diff --git a/cores/esp8266/WString.cpp b/cores/esp8266/WString.cpp
index 07ab99b..81175fa 100644
--- a/cores/esp8266/WString.cpp
+++ b/cores/esp8266/WString.cpp
@@ -36,6 +36,7 @@ String::String(const char *cstr) {
}
String::String(const String &value) {
+ Serial.printf("%p copy from %p\n", this, &value);
init();
diff --git a/code/espurna/button.cpp b/code/espurna/button.cpp
index da8acc5b..fc9eb0dd 100644
--- a/code/espurna/button.cpp
+++ b/code/espurna/button.cpp
@@ -715,24 +715,35 @@ void buttonSetup() {
_buttons.reserve(buttons);
- // TODO: allow to change gpio pin type based on config?
- #if (BUTTON_EVENTS_SOURCE == BUTTON_EVENTS_SOURCE_GENERIC)
#include <cstdint>
#include <functional>
#include <iostream>
#include <memory>
#include <queue>
#include <vector>
struct JsonObject {};
@mcspr
mcspr / show_template.cpp
Last active December 25, 2019 21:04
Show tasmota template as text
#include <cstdint>
#include <cstdio>
#include <cassert>
#include <string>
// Arduino-specific defines
#define ARDUINOJSON_ENABLE_PROGMEM 0
#define pgm_read_byte(x) static_cast<uint8_t>(*x)
#define PROGMEM
@mcspr
mcspr / runme.cpp
Last active October 24, 2019 12:53
#include <ArduinoJson.h>
#include <iostream>
int main(int argc, char **argv) {
DynamicJsonBuffer buffer(1024);
JsonObject& shared = buffer.createObject();
JsonObject& a = buffer.createObject();
JsonObject& b = buffer.createObject();
arrays
{"relays":{"gpio":[15,15,15,15,15,15,15,15,15,15],"type":[1,1,1,1,1,1,1,1,1,1],"reset":[153,153,153,153,153,153,153,153,153,153],"boot":[2,2,2,2,2,2,2,2,2,2],"pulse":[1,1,1,1,1,1,1,1,1,1],"pulse_time":[3600,3600,3600,3600,3600,3600,3600,3600,3600,3600],"group":["something/else","something/else","something/else","something/else","something/else","something/else","something/else","something/else","something/else","something/else"],"group_sync":[2,2,2,2,2,2,2,2,2,2],"on_disc":[0,0,0,0,0,0,0,0,0,0]}}
objs
{"relays":[{"gpio":15,"type":1,"reset":153,"boot":2,"pulse":1,"pulse_time":3600,"group":"something/else","group_sync":2,"on_disc":0},{"gpio":15,"type":1,"reset":153,"boot":2,"pulse":1,"pulse_time":3600,"group":"something/else","group_sync":2,"on_disc":0},{"gpio":15,"type":1,"reset":153,"boot":2,"pulse":1,"pulse_time":3600,"group":"something/else","group_sync":2,"on_disc":0},{"gpio":15,"type":1,"reset":153,"boot":2,"pulse":1,"pulse_time":3600,"group":"something/else","group_sync":2,"on_disc":0},{"gpio":15
diff --git a/tools/sdk/lwip2/include/lwipopts.h b/tools/sdk/lwip2/include/lwipopts.h
index 22acb6b4..fcd7ba4e 100644
--- a/tools/sdk/lwip2/include/lwipopts.h
+++ b/tools/sdk/lwip2/include/lwipopts.h
@@ -3571,9 +3571,9 @@ extern "C" {
#define SNTP_SET_SYSTEM_TIME_US(t,us) do { struct timeval tv = { t, us }; settimeofday(&tv, NULL); } while (0)
#define SNTP_UPDATE_DELAY_DEFAULT 3600000
-#define SNTP_SUPPRESS_DELAY_CHECK 1
-#define SNTP_UPDATE_DELAY sntp_update_delay_not_less_than_15000
@mcspr
mcspr / hsv.cpp
Last active August 20, 2019 14:17
HSV test
$ g++ -std=c++17 -o hsv hsv.cpp
$ ./hsv 2,100,59
brightness=0, rgb=0,0,0
input=2,100,59
_setRGBInputValue(255,8,0)
brightness=150, rgb=255,8,0
Import("env")
import os
PROJECT_CFG = env.GetProjectConfig()
STORAGE = os.path.join(env["PROJECT_DIR"], PROJECT_CFG.get("common", "shared_libdeps_dir"))
LIB_DEPS = env.GetProjectOption("lib_deps")
#print("using", STORAGE)