Skip to content

Instantly share code, notes, and snippets.

View CelliesProjects's full-sized avatar
🖥️
Busy coding...

Cellie CelliesProjects

🖥️
Busy coding...
View GitHub Profile
@CelliesProjects
CelliesProjects / ScopedMutex.h
Created February 19, 2025 19:27
A scoped mutex for a FreeRTOS semaphore handle that prevents deadlocks by ensuring that the mutex is always released, even if exceptions are thrown or the code exits early
#ifndef SCOPEDMUTEX_H
#define SCOPEDMUTEX_H
#include <Arduino.h>
#include <freertos/semphr.h>
/**
* @brief Constructs a ScopedMutex object from `SemaphoreHandle_t` `m` and attempts to acquire the mutex.
*
* Guarantees mutex release when the `ScopedMutex` object goes out of scope.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Aquacontrol index</title>
<!-- Include minified reconnecting-websocket library from https://github.com/joewalnes/reconnecting-websocket -->
<script>!function (a, b) { "function" == typeof define && define.amd ? define([], b) : "undefined" != typeof module && module.exports ? module.exports = b() : a.ReconnectingWebSocket = b() }(this, function () { function a(b, c, d) { function l(a, b) { var c = document.createEvent("CustomEvent"); return c.initCustomEvent(a, !1, !1, b), c } var e = { debug: !1, automaticOpen: !0, reconnectInterval: 1e3, maxReconnectInterval: 3e4, reconnectDecay: 1.5, timeoutInterval: 2e3 }; d || (d = {}); for (var f in e) this[f] = "undefined" != typeof d[f] ? d[f] : e[f]; this.url = b, this.reconnectAttempts = 0, this.readyState = WebSocket.CONNECTING, this.protocol = null; var h, g = this, i = !1, j = !1, k = document.createEleme
@CelliesProjects
CelliesProjects / lv_conf.h
Created September 26, 2024 17:30
Guition 480x480 panel LVGL boilerplate
/**
* @file lv_conf.h
* Configuration file for v8.3.0-dev
*/
/*
* Copy this file as `lv_conf.h`
* 1. simply next to the `lvgl` folder
* 2. or any other places and
* - define `LV_CONF_INCLUDE_SIMPLE`
@CelliesProjects
CelliesProjects / TTGO-TM-Lovyan.ino
Last active September 17, 2023 17:11
LovyanGFX working on TTGO-TM-ESP32
#include <Arduino.h>
// #define LGFX_USE_V1
#include <LovyanGFX.hpp>
// This is the hardware:
// https://github.com/LilyGO/TTGO-TM-ESP32
// LGFX for TTGO T-Display
class LGFX : public lgfx::LGFX_Device
@CelliesProjects
CelliesProjects / isr_in_class.ino
Last active May 15, 2021 12:56
esp32 - simple poc demonstrating a timer interupt driven ISR living in a class
/* simple poc demonstrating a timer interupt driven ISR living in a class */
class foo {
public:
bool start_isr();
private:
static void _timer_isr();
hw_timer_t * exampleTimer;
@CelliesProjects
CelliesProjects / esp32_netif_isup.ino
Created April 18, 2021 14:41
A esp32 check to see if any network interface up.
#include <tcpip_adapter.h>
static bool netif_isup() {
for (int i = TCPIP_ADAPTER_IF_STA; i < TCPIP_ADAPTER_IF_MAX; i++)
if (tcpip_adapter_is_netif_up((tcpip_adapter_if_t)i)) return true;
return false;
}
#include <WiFi.h>
// https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/system_time.html#
// https://github.com/espressif/esp-idf/blob/master/examples/protocols/sntp/main/sntp_example_main.c
const char* WIFI_NETWORK = "xxx";
const char* WIFI_PASSWORD = "xxx";
const char* NTP_POOL = "nl.pool.ntp.org";
@CelliesProjects
CelliesProjects / reboot_through_asyncwebserver.ino
Created January 15, 2021 13:30
poc code to show how to reboot your esp over http with me-no-dev ASyncWebserver.
server.on("/hw-reset", HTTP_GET, [](AsyncWebServerRequest *request){
request->onDisconnect([](){
#ifdef ESP32
ESP.restart();
#elif defined(ESP8266)
ESP.reset();
#endif
});
request->send(200, "text/plain","Restarting ...");
});
@CelliesProjects
CelliesProjects / serial2ws.ino
Last active November 7, 2020 14:16
A simple Serial to WebSocket bridge - poc for reading DSMR conforming smart meters.
/*
This is a serial to websocket server for application with a DSMR 5.x. conform 'Dutch Smart Meter'.
This sketch reads messages (terminated by a newline) from a smart meter connected on Serial
and echos these messages to clients connected on websocket '/ws'.
All non utf8 chararacters in the messages are dropped.
*/
@CelliesProjects
CelliesProjects / static_ip_setup.ino
Created March 10, 2020 14:18
Static IP on ESP32 Arduino
// Load Wi-Fi library
#include <WiFi.h>
// Replace with your network credentials
const char* ssid = "";
const char* password = "";
void setup(){
IPAddress local_IP(192, 168, 0, 60); /* THIS SHOULD BE OUTSIDE YOUR ROUTERS DHCP RANGE! */