Skip to content

Instantly share code, notes, and snippets.

@rahji
rahji / text_with_p5play.js
Created November 13, 2023 15:46
A way to show text in p5play
// how to show text and not have it appear
// underneath the game's sprites
let spriteToClick;
let textSpriteToShow;
function setup() {
let canvas = new Canvas("fullscreen");
spriteToClick = new Sprite(width/2,height/2,128,128,'s');
@rahji
rahji / in class demo part 2 with gravity.js
Created October 18, 2023 15:42
2023 Fall p5play in-class demo part 2
let kitty;
let block;
let beep;
let showText = false;
function preload() {
// don't forget to uncomment the line in the HTML that loads
// the p5.sound library if you want to play sounds!
beep = loadSound('assets/beep.wav');
@rahji
rahji / in class demo part 1 top view with text.js
Created October 18, 2023 15:41
2023 Fall p5play in-class demo part 1
let kitty;
let block;
let beep;
let showText = false;
function preload() {
// don't forget to uncomment the line in the HTML that loads
// the p5.sound library if you want to play sounds!
beep = loadSound('assets/beep.wav');
@rahji
rahji / resetuser.bat
Last active August 17, 2023 16:06
Windows batch script to reset vscode, git, chrome, and firefox
Rem --- Close vscode, since we are going to clear its settings and sync credentials
TSKILL code
Rem --- clear git global settings
git config --global --unset-all user.email
git config --global --unset-all user.username
Rem -- clear all vscode sync credentials, whether it's microsoft or github
setlocal enableextensions disabledelayedexpansion
for /f "delims=" %%a in ('cmdkey /list ^| findstr vscode') do (
@rahji
rahji / jing2movie.md
Last active July 3, 2023 15:16
Turn SWF Screen Recordings from Jing into mp4s

Turning Jing SWF Screen Recordings into Video Files

Create a Folder Structure

This command will create an export folder that contains a separate subfolder for each SWF file's exported data. In the next step, JPEXS will be used create sounds and frames folders for each video and extract sound and frame files into their respective folders.

$ for f in `basename --suffix=.swf *swf`; do \
mkdir export/$f; \
done
@rahji
rahji / main.cpp
Created May 28, 2023 18:46
Left shift bits within 6 bits of a byte, wrapping at the end
#include <stdio.h>
#include <stdlib.h>
// shift bits to the left, while wrapping
// but only wrap within the 6 LSBs (ignore the 2 MSBs)
unsigned char shift_bit(unsigned char theByte);
int main(int argc, char **argv) {
if (argc != 2) {
@rahji
rahji / platformio.ini
Created May 26, 2023 20:29
Example of a platformio.ini with f_cpu and fuses, set up for Atmel ICE
[env:ATmega328P]
platform = atmelavr
board = ATmega328P
board_build.f_cpu = 8000000L
upload_protocol = atmelice_isp
upload_flags = -e
upload_port = usb
board_fuses.hfuse = 0xD9 ; defaults, flash 2K
@rahji
rahji / my favorite debouncers.md
Last active May 25, 2023 21:16
This is a cleaned up version of the article at <https://www.embedded.com/my-favorite-software-debouncers>. Unfortunately, that page has some HTML problems that mangle the code examples. I reformatted it here so they're readable.

My favorite software debouncers

Jack breaks out the real code for taming the recalcitrant but ubiquitous mechanical switch.

After last month's look at the Embedded Systems Conference we're back to the surprisingly deep subject of debouncing switch inputs. But first, a mea culpa for mixing up formulas in May's column ("Solving Switch Bounce Problems," May 2004, on pages 46 and 48). The first and second formulas were accidentally swapped. To see the corrected version, go to https://www.embedded.com/solving-switch-bounce-problems/.

Software debounce routines range from some quite simple approaches to sophisticated algorithms that handle multiple switches in parallel. Many developers create solutions without completely understanding the problem. Sure, contacts rebound against each other. But the environment itself can induce all sorts of short transients that mask themselves as switch transitions. Called EMI (electromagnetic interference), these bits of nastiness come from energy coupled into our circu

@rahji
rahji / main.cpp
Last active May 18, 2023 20:07
debounce test
#ifdef F_CPU
#undef F_CPU
#define F_CPU 8000000UL
#endif
#include "buttonDebouncer.h"
#include "millis.h"
#define NR_OF_BUTTONS 5
#include <Arduino.h>
#define EnablePin 3
#define PhasePin 4
#define CSPin A0
unsigned long lastTime = 0;
int highestCurrent = 0;
int direction = HIGH;