Skip to content

Instantly share code, notes, and snippets.

@makvoid
makvoid / main.py
Created September 23, 2022 04:40
Internet-controllable LED Strip MicroPython code
from config import config
from machine import SPI, Pin
from micropython_dotstar import DotStar
from network import WLAN, STA_IF
from time import sleep, time
import uwebsockets.client
# Setup the network
...
@makvoid
makvoid / websocket-server.js
Created September 23, 2022 04:38
Internet-controllable LED Strip WebSocket Server
const { readFileSync } = require('fs')
const { createServer } = require('https')
const { WebSocketServer } = require('ws')
// Brightness value the DotStar should use (should be 0.0 - 1.0)
const BRIGHTNESS = 0.1
// Create server for WSS (listen port is set at the end of the file)
const server = createServer({
cert: readFileSync('/etc/ssl/certs/your-domain.dev.crt'),
@makvoid
makvoid / run-camera-util.py
Last active July 10, 2022 20:30
Arducam 64MP running the camera utility
$ python3 -m pip install readchar v4l2-fix
$ python3 control.py
Information:
--------------
Focus: 240
Zoom: 0
Hotkeys:
--------------
@makvoid
makvoid / arducam_64mp_list_cameras.sh
Last active July 8, 2022 05:20
Arducam 64MP list cameras output
$ libcamera-still --list-cameras
[3:04:51.771767236] [17736] INFO Camera camera_manager.cpp:293 libcamera v0.0.0+3572-e13ccdd5
[3:04:51.777781516] [17737] WARN CameraSensorProperties camera_sensor_properties.cpp:163 No static properties available for 'arducam_64mp'
[3:04:51.777826978] [17737] WARN CameraSensorProperties camera_sensor_properties.cpp:165 Please consider updating the camera sensor properties database
[3:04:51.778138122] [17737] ERROR CameraSensor camera_sensor.cpp:591 'arducam_64mp 10-001a': Camera sensor does not support test pattern modes.
[3:04:51.808715087] [17737] WARN RPI raspberrypi.cpp:1263 Mismatch between Unicam and CamHelper for embedded data usage!
[3:04:51.809251321] [17737] ERROR DelayedControls delayed_controls.cpp:87 Delay request for control id 0x009a090a but control is not exposed by device /dev/v4l-subdev0
[3:04:51.809469781] [17737] INFO RPI raspberrypi.cpp:1386 Registered camera /base/soc/i2c0mux/i2c@1/arducam_64mp@1a to Unicam device /dev/media3 and ISP device /de
@makvoid
makvoid / arducam_64mp_install.sh
Created July 8, 2022 04:04
Arducam 64MP Install steps
# Add 'dtoverlay=vc4-kms-v3d,cma-512' to the '[all]' section
$ sudo nano /boot/config.txt
# Reboot to load the change
$ sudo reboot now
# Download the install script
$ wget -O install_pivariety_pkgs.sh https://github.com/ArduCAM/Arducam-Pivariety-V4L2-Driver/releases/download/install_script/install_pivariety_pkgs.sh
# Mark the script as executable
$ chmod +x install_pivariety_pkgs.sh
# Install libcamera-dev
$ ./install_pivariety_pkgs.sh -p libcamera_dev
@makvoid
makvoid / libcamera-vid-to-ffmpeg-examples.sh
Created July 8, 2022 01:07
libcamera-vid to FFMPEG example commands
# h264
$ libcamera-vid -t 0 --width 1920 --height 1080 --autofocus -o - | ffmpeg -i - -f alsa -ac 1 -itsoffset 5 -i hw:1,0 -vcodec copy -acodec aac -strict -2 out.flv
# MJPEG
$ libcamera-vid -t 0 --width 1920 --height 1080 --autofocus --codec mjpeg -o - | ffmpeg -i - -f alsa -ac 1 -itsoffset 5 -i hw:1,0 -vcodec copy -acodec aac -strict -2 out.mp4
# YUV420
$ libcamera-vid -t 0 --width 1920 --height 1080 --autofocus --codec yuv420 -o - | ffmpeg -f rawvideo -pix_fmt yuv420p -s:v 1920x1080 -r 30 -i - -f alsa -ac 1 -itsoffset 5 -i hw:1,0 -vcodec copy -acodec aac -strict -2 out.avi
@makvoid
makvoid / algolia-react-hooks-hit-count.js
Last active July 5, 2022 16:56
App.js example using InstantSearch React hooks with useHits
import algoliasearch from 'algoliasearch/lite';
import {
Configure,
Highlight,
Hits,
useHits, // Add import here
Index,
InstantSearch,
SearchBox,
Pagination,
@makvoid
makvoid / hdb-sign-guide-final-setup-step-2.sh
Created June 16, 2022 02:34
Final setup and configuration (step 2)
# Extract the user-interface package
$ tar zxf ui_package.tgz
# Move the package to its final location
$ sudo mv dist /opt/signs-user-interface && chown -R dietpi. /opt/signs-user-interface
# Install the systemd services
$ sudo mv /opt/signs-user-interface/services/*.service /usr/lib/systemd/system/
# Reload systemd so it can load the new services
$ sudo systemctl daemon-reload
# Ensure your configuration file is present (the configuration can be downloaded via the Frontend on the Device’s page)
$ nano /home/dietpi/.sign_config.json
@makvoid
makvoid / hdb-sign-guide-final-setup-step-1.sh
Created June 16, 2022 02:33
Final setup and configuration for the Device (step 1)
$ cd user-interface
$ yarn && yarn package
$ scp ui_package.tgz [email protected]:/home/dietpi
@makvoid
makvoid / hdb-sign-guide-installing-device-extras.sh
Created June 16, 2022 02:31
Installing extra requirements for the Device
# Download and install NVM
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
# Load NVM
$ export NVM_DIR="$HOME/.nvm"
$ [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
$ [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
# Install Node
$ nvm install 14.19.1
# Finally, install unclutter
$ sudo apt install -y unclutter