Skip to content

Instantly share code, notes, and snippets.

@blippy
blippy / pd.pl6
Created November 25, 2020 15:20
Partition dump MBR
#!/usr/bin/env perl6
# Reference:
# https://wiki.osdev.org/Partition_Table
my %ids = 0x00 => "Empty", 0x0b => "W95 FAT32", 0x0c => "W95 FAT32 (LBA)",
0x82 => "Linux swap", 0x83 => "Linux", 0x93 => "Amoeba";
sub MAIN($filename) {
say "Disk: $filename";
@blippy
blippy / elang.p6
Created July 2, 2020 10:26
Creating a templating system in raku
grammar G {
token TOP { <atom>* }
token atom { IFX { print "\n.. GOT IFX..\n"; }
| IF {print "\n--GOT IF--\n"; }
| . { print $/; }
}
}
my $str = "heIFllIFXo\n";
@blippy
blippy / mywifi.lua
Created June 16, 2020 14:15
Crude demo of using wifi on ESP8266 Lua
-----------------------------------------------
--- Set Variables ---
-----------------------------------------------
--- WIFI CONFIGURATION ---
WIFI_SSID = ""
WIFI_PASSWORD = ""
WIFI_SIGNAL_MODE = wifi.PHYMODE_N
--- IP CONFIG (Leave blank to use DHCP) ---
ESP8266_IP="192.168.0.30"
@blippy
blippy / times.4th
Created January 20, 2020 14:33
Execute a block of code n times
: nneg 0 >= ;
: <times postpone >r postpone begin postpone r> postpone 1- postpone dup
postpone >r postpone nneg postpone while ; immediate
: times> postpone repeat postpone rdrop ; immediate
\ Simple usage:
: eg1 5 <times '. emit times> cr ;
eg1
\ You can even embed blocks:
@blippy
blippy / oscillo.py
Last active September 9, 2019 17:29
Crude oscilloscope
%serialconnect to --port=/dev/ttyUSB1 # for Jupyter
import machine, ssd1306
i2c = machine.I2C(-1, scl=machine.Pin(22), sda=machine.Pin(21))
oled = ssd1306.SSD1306_I2C(128, 64, i2c)
oled.fill(0)
oled.text('MicroPython on', 0, 0)
oled.text('attached SSD1306', 0, 20)
oled.text('OLED display', 0, 30)
@blippy
blippy / voicer.ino
Created June 26, 2019 20:39
Streaming audio on an ESP32 with a blinkt
#include <Arduino.h>
#include <WiFi.h>
#include <driver/dac.h>
const int dataPin = 4; // Blinkt pin 16
const int clockPin = 5; // blinkt pin 18
const int numLEDs = 8;
uint8_t pixels[numLEDs * 3];
void spi_out(uint8_t n) {
@blippy
blippy / play.c
Last active December 13, 2023 22:37
Playing hard-coded audio on an ESP32 via DAC
#include <stdio.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "sdkconfig.h"
#include <driver/dac.h>
// The 8-bit values in our sound sample
#include "track.h"
@blippy
blippy / computer.c
Created June 25, 2019 07:58
ESP32 RTOS "does not compute"
/* Blink Example
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 <stdio.h>
#include <string.h>
@blippy
blippy / lcd-clock-esp.py
Created May 29, 2019 10:36
LCD DOG clock with ESP8266 with fancy LCD commands
from machine import Pin, SPI
import ntptime
from utime import sleep_ms
import utime
import mel
rs_pin = Pin(2, Pin.OUT) # Pin D4. Do NOT use the regular MISO pin (D6)
cs_pin = Pin(15, Pin.OUT) # aka SS slave select
cs_pin.on()
@blippy
blippy / twc.py
Created May 9, 2019 19:16
Test wifi connectivity
import machine
import network
import time
# because we use onbaord GPIO, we invert the meaning of the pin
# so 0 turns it on, 1 turn it off
pin = machine.Pin(16, machine.Pin.OUT)
def poff(): pin.value(1)
def pon(): pin.value(0)
poff()