Skip to content

Instantly share code, notes, and snippets.

@blippy
blippy / elang.p6
Created Jul 2, 2020
Creating a templating system in raku
View elang.p6
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 Jun 16, 2020
Crude demo of using wifi on ESP8266 Lua
View mywifi.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 Jan 20, 2020
Execute a block of code n times
View times.4th
: 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 Sep 9, 2019
Crude oscilloscope
View oscillo.py
%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 Jun 26, 2019
Streaming audio on an ESP32 with a blinkt
View voicer.ino
#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 Aug 20, 2019
Playing hard-coded audio on an ESP32 via DAC
View play.c
#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 Jun 25, 2019
ESP32 RTOS "does not compute"
View computer.c
/* 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
LCD DOG clock with ESP8266 with fancy LCD commands
View lcd-clock-esp.py
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
Test wifi connectivity
View twc.py
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()
@blippy
blippy / chain.scm
Created May 6, 2019
Chain procures together
View chain.scm
#lang racket
(define (chain arg0 . lambdas)
(let loop ((arg arg0) (lambdas lambdas))
(if (empty? lambdas)
arg
(loop ((car lambdas) arg) (cdr lambdas)))))
; example usage
(define (add1 n) (+ 1 n))
You can’t perform that action at this time.