Category Archives: Computer

Amiga week

This week (while preparing for a mini retro party) I fixed some Amiga stuff.

I’ve bought a new gadget.

You place this PCB between the CPU IC socket and the CPU (68000) itself.

Now running a special floppy image, which loads a driver, I can use the 512MB sdcard as “harddisk”.

It at first ran into all kinds of hangups.
Checking everything, I found CIAB (8520) the culprit.
Timing errors I’ve never noticed before!

Switching this one with CIAA resolved the problem.
(I don’t use a printer anyway, but I have to remember that anything using the parallel port can have problems now.)

Meanwhile, I wanted to have a better control over the Amiga drives, so I’m planning to use a second switch to reassign drive numbers using a switch.

For switching Internal/External drive (df0/df1) I was using a Gotek boot switch. (Just press 3x ctrl-Amiga-Amiga)

See https://www.henriaanstoot.nl/2022/05/14/gotek-stuff/

But I have TWO external devices.
The Gotek virtual disk device and a real 5.24″ drive.

So I’m going to use a ON-ON double switch to toggle the external devices.

The internal switch toggles internal and external.
The secondary I’m going to build into the 5.25″ drive toggles df2 and the “df1”.
That way the internal drive can be 0 (boot) or 1.
The external drives can be 0,1 or 2.

NOTE: Switch pin 21 and 9 using the cross switch!

SO: Amiga with internal drive -> External 5.24″ which has a passthrough to the Gotek.

Another amiga thing fixed:
I re-installed Aros (on an old Laptop this time)

And third: I’ve bought the Amiga Forever cdrom.

When you get the ISO image from AmigaForever, and want to run it using Linux, do this to get it working

sudo apt install xkbfile1:i386
sudo apt install libxkbfile1:i386
mkdir -p /cdrom
sudo mount -t iso9660 ~/Downloads/AF.iso /cdrom
cd /cdrom/Private/Linux/e-uae/
./kxlight-start.sh

If you install Wine, you can use the windows gui in linux also.


Amiga samplers

Testing the sampler (demo for Tyrone)

Sampling the sound of a C64 on an Amiga.
Started (booted) the sampling program from second external drive using switch setup as above.

Even realtime echo works!

I tried to recreate an optical illusion

My friend Tyrone posted something he recorded from TV.
It was an illusion, using rotated images.

The effect is that it seems that the card is rotating at different speeds, when pressing the s (show/unshow) key, you see the card rotating at the same speed as before.

So I wanted to try to recreate this using python.
The effect is there, but a little less.
What can I improve?

Mine:

Around the 30 seconds mark I disable the background, you’ll see the card rotating as before.

Original:

Better version, larger and using s key to toggle water off, to see the card rotating

import pygame
import math

# 20240409 added s to toggle 

pygame.init()
screen = pygame.display.set_mode((1600, 900))
clock = pygame.time.Clock()

def blitRotate(surf, image, pos, originPos, angle):

    image_rect = image.get_rect(topleft = (pos[0] - originPos[0], pos[1]-originPos[1]))
    offset_center_to_pivot = pygame.math.Vector2(pos) - image_rect.center
    rotated_offset = offset_center_to_pivot.rotate(-angle)
    rotated_image_center = (pos[0] - rotated_offset.x, pos[1] - rotated_offset.y)
    rotated_image = pygame.transform.rotate(image, angle)
    rotated_image_rect = rotated_image.get_rect(center = rotated_image_center)
    surf.blit(rotated_image, rotated_image_rect)

try:
    image = pygame.image.load('cards.png').convert_alpha()
    image2 = pygame.image.load('clear+sea+water-2048x2048.png').convert_alpha()
except:
    text = pygame.font.SysFont('Times New Roman', 50).render('imagemissing', False, (255, 255, 0))
    image = pygame.Surface((text.get_width()+1, text.get_height()+1))
    image2 = image
    image.blit(text, (1, 1))

w, h = image.get_size()
angle = 0
angle2 = 0
done = False
while not done:
    clock.tick(60)
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True

    pos = (screen.get_width()/2, screen.get_height()/2)
    
    screen.fill(0)
    keys = pygame.key.get_pressed()
    if (not keys[pygame.K_s]):
        blitRotate(screen, image2, pos, (900, 900), angle2)
    blitRotate(screen, image, pos, (w/2, h/2), angle)
    angle += 1
    angle2 += math.sin(math.radians(angle))
    pygame.display.flip()
    
pygame.quit()
exit()

Music Cover Art Display using ILI9431

Little Sunday afternoon project.

Two PHP scripts.

Install on your webserver (see previous post)

Resizes images and removes the onkyo header.
(See previous posts)

<?php
// onkyo.php
// write jpeg header
header('Content-type: image/jpg');

$lines = file_get_contents('http://IP-ONKYO-AMPLIFIER/album_art.cgi', false);
$lines = explode("\n", $lines);
// remove weird Onkyo header (3 lines)
$content = implode("\n", array_slice($lines, 3));
print $content;
?>

CoverArt from a squeezeboxserver

<?php    
// squeezebox.php
// leave playerid as is, for the default.
// change to MAC address of player to get coverart specific player
$img = file_get_contents('http://IP-LOGITECH_MEDIA_SERVER:9000/music/current/cover.jpg?player=<playerid>');
$im = imagecreatefromstring($img);
$width = imagesx($im);
$height = imagesy($im);
$newwidth = '240';
$newheight = '240';
$thumb = imagecreatetruecolor($newwidth, $newheight);
imagecopyresized($thumb, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
//imagejpeg($thumb,'small.jpg'); //save image as jpg
header('Content-Type: image/jpeg');
imagejpeg($thumb);
imagedestroy($thumb); 
imagedestroy($im);
?>

Arduino install:

Start IDE
Install TJpg_Decoder library
Open examples>Tjpeg_decoder>SPIFFS>SPIFFS_web_spiffs
change wifi credentials
and the url to your php script.
  bool loaded_ok = getFile("https://myserver/onkyo.php", "/M81.jpg"); // Note name preceded with "/"

replace bottom part with

 // while(1) yield();
 delay(5000);
     SPIFFS.remove("/M81.jpg");

64×64 Matrixrgb plus Conway’s Game of Life

Yesterday I got this nice led matrix I mentioned before.

I wanted to control this display using Circuit Python and a Raspberry Pico.

Pico  Matrix
GP0   R1
GP1   G1
GP2   B1
GP3   R2
GP4   G2
GP5   B2
GP6   A
GP7   B
GP8   C
GP9   D
GP10  Clock
GP11  E
GP12  Latch
GP13  Output Enable

GND   GND ( I did both )

I installed Circuit Python and the following libraries.

adafruit_imageload, adafruit_display_text.label (the rest was already in the uf2 firmware.)
(Check this link : https://circuitpython.org/board/raspberry_pi_pico/ )
I could not install the Wifi uf2 file, then I got a out of storage space when installing the adafruit libraries.

importing libaries and init display

import board, digitalio, busio, time, displayio, rgbmatrix, framebufferio
import adafruit_imageload, terminalio, random
import adafruit_display_text.label

displayio.release_displays()
matrix = rgbmatrix.RGBMatrix(
    width=64, bit_depth=2, height=64,
    rgb_pins=[board.GP0, board.GP1, board.GP2, board.GP3, board.GP4, board.GP5],
    addr_pins=[board.GP6, board.GP7, board.GP8, board.GP9, board.GP11],
    clock_pin=board.GP10, latch_pin=board.GP12, output_enable_pin=board.GP13)
display = framebufferio.FramebufferDisplay(matrix)

I became interested in Conway’s “Game of Life”, in 1983. Reading a article in the Dutch Magazine Kijk.

The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970. It is a zero-player game, meaning that its evolution is determined by its initial state, requiring no further input. One interacts with the Game of Life by creating an initial configuration and observing how it evolves. It is Turing complete and can simulate a universal constructor or any other Turing machine.

https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life

I found these on my server. Bad quality, I know. Scanned these many years ago.

The rules are:

  1. Any live cell with fewer than two live neighbours dies, as if by underpopulation.
  2. Any live cell with two or three live neighbours lives on to the next generation.
  3. Any live cell with more than three live neighbours dies, as if by overpopulation.
  4. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

When playing with the Basic code as a kid, I wanted to try if it was possible to make a 3D version of this.

I came up with the following rules:

  1. Birth : 4 alive neighbours needed
  2. Survive : 5 or 6 neighbours
  3. Dead : below 4 and over 6

I think there should be a BBC Acorn basic version I wrote somewhere.

Back to the display

Greetings to my friends
Game of Life starting with my Logo plus a glider
A single Gosper‘s glider gun creating gliders

Code for the glider gun

    conway_data = [
        b'                        +           ',
        b'                      + +           ',
        b'            ++      ++            ++',
        b'           +   +    ++            ++',
        b'++        +     +   ++              ',
        b'++        +   + ++    + +           ',
        b'          +     +       +           ',
        b'           +   +                    ',
        b'            ++                      ',
    ]

Next todo:

  • Line functions
  • Design a Chip tune hardware add-on
  • Make a Game of Life start situation selector
  • Make a new Maze game!

Home Assistant – Reboot, start,shutdown and switch OS

This is my short log about (re)starting booting machines.

configuration.yaml

#WOL to start a machine
  - platform: wake_on_lan
    name: "wakeserver"
    mac: ec:be:5f:ee:11:78

#SHELL command to remote start reboot2windows script (multiboot machine)
shell_command:
    ssh_reboottowindows: ssh -i /config/ssh/id_ed25519 -o 'StrictHostKeyChecking=no' root@192.168.1.2 '/root/reboot2windows'
shell_command:
    ssh_haltlinux: ssh -i /config/ssh/id_ed25519 -o 'StrictHostKeyChecking=no' root@192.168.1.2 'halt -p'

reboot2windows linux script (on the remote server)

#!/bin/bash
#place in /root/
#chmod +x /root/reboot2windows
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
WINDOWS_TITLE=`grep -i "^menuentry 'Windows" /boot/grub/grub.cfg|head -n 1|cut -d"'" -f2`
grub-reboot "$WINDOWS_TITLE"
reboot

install https://iotlink.gitlab.io/ on your windows instance

scripts.yaml (with a helper button rebootwindows2linux, shutdownwindows)

#Reboot windows, linux is the default
windows2linux:
  alias: rebootwinserver
  sequence:
  - service: mqtt.publish
    metadata: {}
    data:
      qos: 0
      retain: false
      topic: iotlink/workgroup/winserver/commands/reboot
  mode: single
shutdownwindows:
  alias: shutdownwinserver
  sequence:
  - service: mqtt.publish
    metadata: {}
    data:
      qos: 0
      retain: false
      topic: iotlink/workgroup/winserver/commands/shutdown
  mode: single

automation rebootlinux2windows

(using a helper button rebootlinux2windows)

alias: rebootlinux2windows
description: ""
trigger:
  - platform: state
    entity_id:
      - input_button.rebootlinux2windows
condition: []
action:
  - service: shell_command.ssh_reboottowindows
    data: {}
mode: single

Configuring ssh keys

Open HA terminal

cd
ssh-keygen (enter) (enter) (enter) (enter) 
mkdir -p config/ssh
cp ~/.ssh/id* config/ssh/ 

Arduino Tiny Machine Learning Kit

A while ago I bought a little machine learning kit.

I’ve been reading at listening to ML podcasts and websites.

One on Spotify I liked was:

Also, the following Coursera was interesting
https://www.coursera.org/learn/machine-learning

I’ve been testing using Python on my Laptop.
(see other posts)

And a camera with esp32 using face detection.

See here multiple posts about these experiments.

https://www.henriaanstoot.nl/tag/machinelearning/

Today the first experiments using this kit.

  • Arduino Nano 33 BLE Sense board
  • OV7675 Camera
  • Arduino Tiny Machine Learning Shield
  • USB A to Micro USB Cable
  • 9 axis inertial sensor: what makes this board ideal for wearable devices
  • humidity, and temperature sensor: to get highly accurate measurements of the environmental conditions
  • barometric sensor: you could make a simple weather station
  • microphone: to capture and analyse sound in real time
  • gesture, proximity, light color and light intensity sensor : estimate the room’s luminosity, but also whether someone is moving close to the board
  • Microcontroller nRF52840
  • Operating Voltage 3.3V
  • Input Voltage (limit) 21V
  • DC Current per I/O Pin 15 mA
  • Clock Speed 64MHz
  • CPU Flash Memory 1MB (nRF52840)
  • SRAM 256KB (nRF52840)
  • EEPROM none
  • Digital Input / Output Pins 14
  • PWM Pins all digital pins
  • UART 1
  • SPI 1
  • I2C 1
  • Analog Input Pins 8 (ADC 12 bit 200 ksamples)
  • Analog Output Pins Only through PWM (no DAC)
  • External Interrupts all digital pins
  • LED_BUILTIN 13
  • USB Native in the nRF52840 Processor
  • IMU LSM9DS1 (datasheet)
Gesture test ( yes on a windows surface tablet, but Vincent and I installed linux on it!)

I just started and will update this page, with other experiments.

Note: displaying Arduino output without installing the IDE

stty -F /dev/ttyACM0 raw 9600
cat /dev/ttyACM0
................................
................................
................................
................................
................................
................................
................................
................................
................................
................####............
...............##..#............
..............##...##...........
..............#.....#...........
..............###...#...........
..............##.....#..........
..............##.....#..........
...............#....##..........
...............######...........
................................
................................
................................
................................

LCD matrix idea’s

In previous post I was talking about an esp32 with display for demo’s.
But my friend Erik mentioned a cheap LCD matrix from Ali.

What about creating something cool with that!

My Maze project would look amazing on this!
I can draw walls now!

Or I could make a cool audio visualiser, like the posted WLED version

Ehh .. not posted (well I can’t post everything)

What about a game of life display?
Using a web interface for inputting the start situation of the cells

Conway’s Game of Life is a cellular automaton. It consists of a grid of cells, each of which can be alive or dead. The state of each cell evolves based on simple rules: any live cell with fewer than two live neighbours dies (underpopulation), any live cell with two or three live neighbours survives, and any live cell with more than three live neighbours dies (overpopulation). Additionally, any dead cell with exactly three live neighbours becomes alive (reproduction). This simple set of rules can lead to complex patterns and behaviours.

But back to the demo …

What about a 6502 with 64×64 pixel display!

What would be needed?

  • 6502, with rom and ram
  • Some IO chip, don’t know which one yet
  • The 64×64 pixel matrix
  • A sound solution (simple chip tune player)
  • 3D printed enclosure

Using some libraries and a framework setup, maybe there is a way to make a cool and cheap demo machine

Do you have any suggestions ideas?
Comment or email me!

Server scripts notification for Home Assistant

I’m running loads of housekeeping scripts on my servers.

I thought it would be cool to see states in HA.

Steps:

  • Log into your HA instance, and press your profile icon in the bottom left.
    Scroll to Long-lived access tokens, and create a new token.
    (Save the token string in a text file, you need it later)
  • Goto Settings > Devices & services > Helpers
    Create helper: Text and give it a name (bashnotification)
  • Next create a script in a path on your server, or place in an existing script directly.
    (Change SAVEDTOKENSTRING,HA-IP and bashnotification)
curl -s -X POST -H "Authorization: Bearer SAVEDTOKENSTRING" -H "Content-Type: application/json" -d "{\"state\": \"$1\"}" http://HA-IP:8123/api/states/input_text.bashnotification >/dev/null

I use it like this in a script

#!/bin/bash
bashnotify "Starting this script"

bash commands bash commands 
bash commands 
bash commands bash commands bash commands 
bash commands bash commands 

bashnotify "Bash command finished"

Running an adhoc command

tar czvf /tmp/test.tgz /var/www/html ; bashnotify "tarball made of www"

Album player using old CD Cover site.

In the past, I made an overview of CDs I own, and which CDs I was missing from my top artists.

Today I wanted to have a little test using above code and some additional script to get a little website which enables me to quick start playing an album using LMS.

Exporting the album database in Linux:

sqlite3 /var/lib/squeezeboxserver/cache/library.db ".dump albums" > /mnt/www/albums-test.dump

grep -i culture /mnt/private/albums
INSERT INTO "albums" VALUES(16872,'Bothy Culture','BOTHY CULTURE','BOTHY CULTURE',NULL,0,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,18957,NULL);

So, 16872 is the needed album ID.

To start playing this (adhoc), I used the below command.

curl "http://IP-OF-MY-LMS-SERVER:9000/anyurl?p0=playlistcontrol&p1=album_id:16872&p2=cmd:load&player=12:23:34:45:56:67"

Player=12:23:34:45:56:67 is the mac address from a squeezebox player.

I wrote some additional PHP code in my original CD Cover site, and got this working.

I think I will rewrite the code using python to get a more flexible generator.

Left the LMS player, right the cover website. (Clicking 3 covers to change albums)