Skip to content

Instantly share code, notes, and snippets.

View bdaniel7's full-sized avatar

Daniel Blendea bdaniel7

  • Bucharest, Romania
View GitHub Profile
@bdaniel7
bdaniel7 / README.md
Created July 6, 2023 07:13 — forked from savetheclocktower/README.md
Using a rotary encoder as a volume control for the Raspberry Pi

Using a rotary encoder as a volume control

On my RetroPie machine I wanted a hardware volume knob — the games I play use a handful of emulators, and there's no unified software interface for controlling the volume. The speakers I got for my cabinet are great, but don't have their own hardware volume knob. So with a bunch of googling and trial and error, I figured out what I need to pull this off: a rotary encoder and a daemon that listens for the signals it sends.

Rotary encoder

A rotary encoder is like the standard potentiometer (i.e., analog volume knob) we all know, except (a) you can keep turning it in either direction for as long as you want, and thus (b) it talks to the RPi differently than a potentiometer would.

I picked up this one from Adafruit, but there are plenty others available. This rotary encoder also lets you push the knob in and treats that like a button press, so I figured that would be useful for toggling mute on and off.

@bdaniel7
bdaniel7 / StateMachine.fs
Created May 23, 2023 19:48 — forked from MiloszKrajewski/StateMachine.fs
State Machine Construction Kit in F#
module StateMachine =
type State<'Event> =
| Next of ('Event -> State<'Event>)
| Stop
let feed state event =
match state with
| Stop -> failwith "Terminal state reached"
| Next handler -> event |> handler
internal class DockerMsSqlServerDatabase : IAsyncDisposable
{
private const string Password = "!Passw0rd";
private const string Image = "mcr.microsoft.com/mssql/server";
private const string Tag = "2019-GA-ubuntu-16.04";
private static IContainer _sqlServerContainer;
private SemaphoreSlim semaphore = new(1, 1);
private readonly string DatabaseName;
@bdaniel7
bdaniel7 / setup.nsi
Created February 22, 2022 11:29 — forked from zmilojko/setup.nsi
NSIS package for a C# application - a package file I used in Zaws, with comments on how to use it for your own application
; Full script for making an NSIS installation package for .NET programs,
; Allows installing and uninstalling programs on Windows environment, and unlike the package system
; integrated with Visual Studio, this one does not suck.
;To use this script:
; 1. Download NSIS (http://nsis.sourceforge.net/Download) and install
; 2. Save this script to your project and edit it to include files you want - and display text you want
; 3. Add something like the following into your post-build script (maybe only for Release configuration)
; "$(DevEnvDir)..\..\..\NSIS\makensis.exe" "$(ProjectDir)Setup\setup.nsi"
; 4. Build your project.
@bdaniel7
bdaniel7 / Install.ps1
Created February 9, 2017 15:10 — forked from lkaczanowski/Install.ps1
Nuget install script - copy folder from package to other directory
param($installPath, $toolsPath, $package, $project)
$projectFullName = $project.FullName
Write-Host "Copying Docs folder to the root of the solution: $projectFullName"
$fileInfo = new-object -typename System.IO.FileInfo -ArgumentList $projectFullName
$projectDirectory = $fileInfo.DirectoryName
$sourceDirectory = "$installPath\docs"
Write-Host $sourceDirectory