Skip to content

Instantly share code, notes, and snippets.

View tablatronix's full-sized avatar

Shawn A tablatronix

View GitHub Profile
// lib A
Global Server;
void on(const Uri &uri, HTTPMethod method, THandlerFunction fn, THandlerFunction ufn);
server->on("/", std::bind(&myClass::handler, this, handlerArg));
void myClass::handler(bool arg){
Server->blargh();
}
@tablatronix
tablatronix / gist:1ff3262f8ab9f73af814fbd6a77fad98
Last active June 13, 2021 18:11
tasmota_restart_relay_ON
Jun 13 06:59:53 tasmota_C59B5E-7006 192.168.20.46 ESP-MQT: tele/tasmota_C59B5E/SENSOR = {"Time":"2021-06-13T06:59:52","ANALOG":{"CTEnergy":{"Energy":0.006,"Power":2068,"Voltage":230,"Current":8.992}},"DHT11":{"Temperature":23.0,"Humidity":37.0,"DewPoint":7.5},"TempUnit":"C"}
Jun 13 06:59:53 tasmota_C59B5E-7006 192.168.20.46 ESP-MQT: tele/tasmota_C59B5E/STATE = {"Time":"2021-06-13T06:59:52","Uptime":"0T00:00:11","UptimeSec":11,"Heap":28,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER":"ON","Wifi":{"AP":1,"SSId":"leela","BSSId":"F4:92:BF:7F:35:4B","Channel":3,"RSSI":30,"Signal":-85,"LinkCount":1,"Downtime":"0T00:00:05"}}
Jun 13 06:59:51 tasmota_C59B5E-7006 192.168.20.46 ESP-APP: Boot Count 27
Jun 13 06:59:49 tasmota_C59B5E-7006 192.168.20.46 ESP-QPC: Reset
Jun 13 06:59:49 tasmota_C59B5E-7006 192.168.20.46 ESP-MQT: stat/tasmota_C59B5E/STATUS10 = {"StatusSNS":{"Time":"2021-06-13T06:59:49","ANALOG":{"CTEnergy":{"Energy":0.004,"Power":2088,"Voltage":230,"Current":9.078}},"DHT11":{"Temperature":
@tablatronix
tablatronix / powerMon_VoltageOnly.ino
Created January 30, 2020 01:33 — forked from ItKindaWorks/powerMon_VoltageOnly.ino
A small Arduino program to measure AC voltage using a voltage transformer
// EmonLibrary examples openenergymonitor.org, Licence GNU GPL V3
#include "EmonLib.h" // Include Emon Library
#define VOLT_CAL 148.7
EnergyMonitor emon1; // Create an instance
void setup()
{
/*
* aw9523.c aw9523 martix key
*
* Version: v1.0.1
*
* Copyright (c) 2017 AWINIC Technology CO., LTD
*
* Author: Nick Li <liweilei@awinic.com.cn>
*
* This program is free software; you can redistribute it and/or modify it
@tablatronix
tablatronix / why.h
Last active May 4, 2019 18:30
linkerprobs
//COMPILES
#ifndef SOMEDEF
void initstuff(){
}
#endif
#ifdef SOMEDEF
void initstuff(){
}
#endif
@tablatronix
tablatronix / scrolltext.cpp
Last active May 18, 2023 12:20
dirty scroll text for adafruit gfx
void scrollString(String str) {
int yoff = 1;
display.clearDisplay();
display.setTextWrap(false); // we don't wrap text so it scrolls nicely
display.setTextSize(2);
display.setRotation(0);
int charWidth = 12; // textsize 2 @todo auto calculate charwidth from font
int pxwidth = (str.length()*charWidth)+32; // @todo get actual string pixel length, add support to gfx if needed
for (int32_t x=charWidth; x>=-pxwidth; x--) {
@tablatronix
tablatronix / esp32_wifi_set_country.cpp
Last active July 2, 2018 14:42
esp32_wifi_set_country
// typedef enum {
// WIFI_COUNTRY_POLICY_AUTO, /**< Country policy is auto, use the country info of AP to which the station is connected */
// WIFI_COUNTRY_POLICY_MANUAL, /**< Country policy is manual, always use the configured country info */
// } WIFI_COUNTRY_POLICY;
// typedef struct {
// char cc[3]; /**< country code string */
// uint8_t schan; /**< start channel */
// uint8_t nchan; /**< total channel number */
// uint8_t policy; /**< country policy */
@tablatronix
tablatronix / htmlescape.php
Last active April 5, 2018 14:05
html excape examples
<script>
// https://stackoverflow.com/questions/24816/escaping-html-strings-with-jquery
escaped = new Option(unescaped).innerHTML;
var entityMap = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
@tablatronix
tablatronix / xml.php
Last active April 3, 2018 16:43
cannot print xml sub collection
<?php
// why does print_r($xmlobj->node) only print the first node ?
$string = <<<XML
<breakfast_menu>
<food>
<name>Belgian Waffles</name>
<price>$5.95</price>
<description>
Two of our famous Belgian Waffles with plenty of real maple syrup
@tablatronix
tablatronix / stplugins.md
Last active March 30, 2018 15:35
sublime text plugins

Programming

web

bootstrap snippets

browser referesh

color highlighter(buggy)

indent xml