All posts by fash

BBC Acorn Basic – 3D projection

I found some of my old BBC Acorn basic programs a while ago.
And doing some research into 3D projections I ran some on a emulator.

Cleaned-up code for brandy basic

MODE 1
VDU 5

DIM X(7), Y(7), Z(7)
DIM SX(7), SY(7)

DATA -1,-1,-1, 1,-1,-1, 1,1,-1, -1,1,-1
DATA -1,-1,1,  1,-1,1,  1,1,1,  -1,1,1

FOR I=0 TO 7
READ X(I), Y(I), Z(I)
NEXT

DIM E(11,1)
DATA 0,1, 1,2, 2,3, 3,0
DATA 4,5, 5,6, 6,7, 7,4
DATA 0,4, 1,5, 2,6, 3,7

FOR I=0 TO 11
READ E(I,0), E(I,1)
NEXT

angleX=0
angleY=0
REPEAT
CLS

camera=5
scale=600

FOR I=0 TO 7
y1 = Y(I)*COS(angleX) - Z(I)*SIN(angleX)
z1 = Y(I)*SIN(angleX) + Z(I)*COS(angleX)
x2 = X(I)*COS(angleY) + z1*SIN(angleY)
z2 = -X(I)*SIN(angleY) + z1*COS(angleY)

zc = z2 + camera
IF zc=0 zc=0.01

SX(I) = 640 + (x2 * scale) / zc
SY(I) = 512 - (y1 * scale) / zc

NEXT
FOR I=0 TO 11
MOVE SX(E(I,0)), SY(E(I,0))
DRAW SX(E(I,1)), SY(E(I,1))
NEXT
angleX = angleX + 0.03
angleY = angleY + 0.02

WAIT 2
UNTIL FALSE

Some old notes

DIY VR using two cameras on a Raspberry 5

Above a screenshot of a browser screen (Left and Right in fullscreen)
Colors are a little of (codec Red/Blue problem?)
But the setup works!

I used a android phone in above setup.
I tried a Quest 2 VR set, but I couldn’t get the browser in full screen mode. (YET)

Hardware setup

Two Raspberry Pi Camera Modules, connected via the two 4lane-MIPI DSI/CSI connectors.

Manually focussed and using some 3D printed stands on a piece of wood will do for now.

I build a RTSP NGinx proxy to test, which I previously used for OBS. But there was too much latency.

So I used below webrtc setup, with a latency below 80ms.
(I previously did some test using Janus)

CODE:

wget https://github.com/bluenviron/mediamtx/releases/download/v1.16.1/mediamtx_v1.16.1_linux_arm64.tar.gz
tar xzvf media*
cp mediamtx.yml mediamtx.org

NEW mediamtx.yml

webrtc: yes
webrtcAddress: :8889

rtmp: yes
rtmpAddress: :1935

paths:
  dualcam:
    source: publisher

run it

./mediamtx mediamtx.yml

Next make a streamer.
This Python script takes two square camera inputs, merge them side-by-side to one image and pushed the H264 frame to MediaMTX

import numpy as np
from picamera2 import Picamera2
import subprocess
import time

#WIDTH = 1280
WIDTH = 720
HEIGHT = 720
FPS = 30
BITRATE = "2500k"
RTMP_URL = "rtmp://127.0.0.1:1935/dualcam"  # MediaMTX RTMP

# FFmpeg  raw frames / H.264 
ffmpeg_cmd = [
    "ffmpeg",
    "-y",
    "-f", "rawvideo",
    "-pix_fmt", "bgr24",
    "-s", f"{WIDTH*2}x{HEIGHT}",
    "-r", str(FPS),
    "-i", "-",
    "-c:v", "libx264",
    "-preset", "ultrafast",
    "-tune", "zerolatency",
    "-b:v", BITRATE,
    "-g", str(FPS),  # keyframe every second
    "-x264-params", "keyint=30:min-keyint=30:no-scenecut=1",
    "-pix_fmt", "yuv420p",
    "-f", "flv",
    RTMP_URL
]


ffmpeg = subprocess.Popen(ffmpeg_cmd, stdin=subprocess.PIPE, bufsize=0)

picam0 = Picamera2(0)
picam1 = Picamera2(1)

cfg0 = picam0.create_video_configuration(
    main={"size": (WIDTH, HEIGHT), "format": "BGR888"}, controls={"FrameRate": FPS}
)
cfg1 = picam1.create_video_configuration(
    main={"size": (WIDTH, HEIGHT), "format": "BGR888"}, controls={"FrameRate": FPS}
)

picam0.configure(cfg0)
picam1.configure(cfg1)

picam0.start()
picam1.start()

print("Streaming to MediaMTX via RTMP...")

try:
    while True:
        f0 = picam1.capture_array()
        f1 = picam0.capture_array()
        combined = np.hstack((f0, f1))
        ffmpeg.stdin.write(combined.tobytes())
        time.sleep(1/FPS)
except KeyboardInterrupt:
    print("Stopping...")
finally:
    picam0.stop()
    picam1.stop()
    ffmpeg.stdin.close()
    ffmpeg.wait()

Open using http://REMOTEIP:8889/dualcam

Nintendo Switch controller fix, and Lora measurements

One moment playing with LoRa. Next, a Nintendo Switch controller to fixed.

Side buttons or whatever you call them didn’t work anymore, so I replaced the flex PCB.

LoRa Antenna measurements

Using my NanoVNA and a RF test Kit I learned something about measuring antenna.

Below a measurement of a unknown antenna, ITs off, I need to shorten the metal spring inside.

Immich is amazing

I’m running this Google Photos alternative for a week now, and I am pleasantly suprised.

UPDATE: Installed power-tools, python scripts to manipulate dates and immich-go

  • Face detection : spot on
  • Responsiveness : fast!, even with a large library
  • Android uploads : it just works! (I used Nextcloud before)
  • Movies : plays smoothly (there is a cast button for movies and images)

The face detection had only 1 mismatch in my library.

Negatives?

Well maybe album management, it could be better or more flexible

Some search tests:

  • Food – indeed found food
  • Rum – found drinks
    (I changed search query to OCR, and it gave me images with the word RUM on it) !
  • Dog – First ones are dogs indeed, after that other animals
  • Smiling / Kissing works
  • Hair/red/computer/music/comic

Amazing results!

Features (some)

  • Docker instance for simple upgrades
  • Facial Recognition
  • Hardware Transcoding
  • Hardware-Accelerated Machine Learning
  • Reverse Geocoding (see below)

Lets copy the rest of my photo libary to this server.
(Storage is on a 10Gbit fiberoptic iSCSI device)

Raspberry Pi 5 Projects

Again … out of SBCs
Where are all these things in my home. Someone is stealing Raspberry Pi’s, ESP32 and other sensors.
(Probably me)

So I’ve got multiple projects running on one RPi.

  • Dual Camera’s on top (brown ribbons), these are for VR streaming project.
  • Dual Camera’s on top. these are for a Red Light Green Light game. (Using motion detection on both camera’s for two players.
  • Below a INMP441 Mems microhone. This is a test for BirdNet recording.

All of the above are partially working. Code follows.

INMP441 is a tricky thing. I needed to do some bitbanging to get it working.

Loads of INMP441 info will be posted

Mqtt blinker for topic notifications

Last year I’ve made a led pole with digital fireworks.

Time to replace for something else ..

I’ve made a mqtt 1-D game in december.

I needed to change a lot to the javascript on the website to fix some stuff.

  • Fix IPhone control. (I hate iphone)
  • Fix screenlock timeout
  • Added meta refresh

The XMAS/Fireworks controller was often used, and I got notifications via my TV. (see other posts)

Now I want to see when MQTT movement when I’m in the livingroom.
So I programmed a Wemos controller to blink the internal when MQTT messages are received.

CODE:

#include <ESP8266WiFi.h>
#include <PubSubClient.h>

const char* ssid = "WIFIAP";
const char* password = "WIFIPASS";

const char* mqtt_server = "MQTTBROKER";  // MQTT broker IP
const char* mqtt_topic  = "game/tilt";

WiFiClient espClient;
PubSubClient client(espClient);

String lastPayload = "";

void setup_wifi() {
  delay(10);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
  }
}

void blinkLED() {
    digitalWrite(LED_BUILTIN, LOW);   // LED ON
    delay(200);
    digitalWrite(LED_BUILTIN, HIGH);  // LED OFF
    delay(200);
}

void callback(char* topic, byte* payload, unsigned int length) {
  String message;
  for (unsigned int i = 0; i < length; i++) {
    message += (char)payload[i];
  }

  // Blink only if topic value changed
  if (message != lastPayload) {
    blinkLED();
    lastPayload = message;
  }
}

void reconnect() {
  while (!client.connected()) {
    if (client.connect("WemosClientMqttBlink")) {
      client.subscribe(mqtt_topic);
    } else {
      delay(2000);
    }
  }
}

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH); 

  setup_wifi();

  client.setServer(mqtt_server, 1883);
  client.setCallback(callback);
}

void loop() {
  if (!client.connected()) {
    reconnect();
  }
  client.loop();
}

New own-hosted spotify alternative

I’ve tested many opensource tools to have a personal own hosted spotify.
Now I have migrated to navidrome.

List of alternatives i’ve used:

  • …. to be filled in

I can access this with a browser or an android app named amcfy music.

Why?

  • I like self hosting stuff
  • I’ve got a lot of obscure music, which can’t be found on main streaming services
  • Our folkband stuff is for personal use only (Tapsalteerie/NaeBother)

I don´t have time posting other stuff, I’m balancing almost 10 projects at the same time ….

LoRa and more LoRa

UPDATE : 20260126

I’ve been playing with LoRa for some time now, mostly with two adhoc LilyGO nodes.
After seeing a YT clip from Andreas Spiess I installed a meshtastic node on a Heltec V3.
Wanting more, I bought a Heltec V4 and an 8DBi (60cm) antenna.
Heltec V3 got a new home in Tyrone’s home.

GPS for the Heltec V4 module!

Via meshtastic I communicated with a guy here in the neighbourhood.
I installed Meshcore and my LoRa playground grew!

A Nebra Helium Miner was bought, and repurposed !

There is a Raspberry CM3 in there (Compute module)
Some big antenna’s and a waterproof case.
Using POE to power the thing, the plan is to have this installation at a high point around my house. (LED pole?!? 🙂 )

Meanwhile I got these : Seeed Xiao Lora ESP32 modules

MeshTUI

My mobile Heltec V4, big antenna coming and battery operated, so I can add to https://mapme.sh

Bat detector

I’ve got a DIY Bat detector, today I designed and printed a Case for this PCB.

Below a link to the design files

https://media.henriaanstoot.nl/bat-case.zip

Next todo:

  • Weatherproof case
  • Alternative power
  • Audio Jack
  • Remote access with remote sound