Skip to content

Instantly share code, notes, and snippets.

View cskilbeck's full-sized avatar

Charlie Skilbeck cskilbeck

View GitHub Profile
@cskilbeck
cskilbeck / ease.c
Created January 10, 2017 08:17
Ease functions
float easeInOut2(float x) {
float ox = 1.0f - x;
float xp = x * x;
return xp / (xp + ox * ox);
}
float easeOut2(float x) {
return (easeInOut2(x * 0.5f + 0.5f, p) - 0.5f) * 2.0f;
}
@cskilbeck
cskilbeck / gist:a7fba01c0275f1cebf46a619c8987d1f
Last active March 23, 2018 09:41
wait for enter or 5 seconds
#if DEBUG
if (Debugger.IsAttached)
{
int timeout = 3;
Console.Error.Write($"Press enter or wait for {timeout} seconds...");
Task.Factory.StartNew(Console.ReadLine).Wait(TimeSpan.FromSeconds(timeout));
}
#endif
/* RMT example -- RGB LED Strip
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include "sdkconfig.h"
#
# Automatically generated file. DO NOT EDIT.
# Espressif IoT Development Framework (ESP-IDF) Project Configuration
#
CONFIG_IDF_TARGET="esp32"
CONFIG_IDF_TARGET_ESP32=y
CONFIG_IDF_FIRMWARE_CHIP_ID=0x0000
#
# SDK tool configuration
MONITOR
--- idf_monitor on /dev/ttyS26 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ښj%Bets Jun 8 2016 00:22:57
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:4
@cskilbeck
cskilbeck / ch32v003_standby.c
Last active September 4, 2023 22:14
CH32V003 Standby mode
void sleep(uint32 count)
{
__disable_irq();
// switch off the ADC
ADC1->CTLR2 = 0;
// switch off all clocks except what we need
RCC->AHBPCENR = RCC_AHBPeriph_SRAM;
RCC->APB1PCENR = RCC_APB1Periph_PWR;
func SendEmail(server, user, password, from, subject, message, contentType string, recipients ...string) error {
smtpTemplate := []string{
"From: %s",
"To: %s",
"Subject: %s",
"MIME-Version: 1.0",
"Content-Type: %s; charset=\"utf-8\"",
"Content-Transfer-Encoding: quoted-printable",
"Content-Disposition: inline",
@cskilbeck
cskilbeck / gist:5e23a3167d9f0e2e54264512b946aa3e
Created April 4, 2024 22:20
Double dabble - convert 32 bit uint to bcd
// double dabble: convert 32 bit unsigned integer to bcd
// right justified, fills output with leading zeros
// no mods or divs
static void uint32_to_bcd(uint32_t input, uint8_t output[5])
{
for(uint8_t i = 0; i < 5; ++i) {
output[i] = 0;
}
@cskilbeck
cskilbeck / encoder.cpp
Last active April 30, 2024 20:58
Encoder peripheral for esp-adf
//////////////////////////////////////////////////////////////////////
#include "freertos/FreeRTOS.h"
#include "freertos/queue.h"
#include "esp_log.h"
#include "driver/gpio.h"
#include "esp_rom_gpio.h"
#include "audio_mem.h"
#include "encoder.h"