Category: Creative
Blacksmith Day 2023
Had a great day on my blacksmith course making a Ram’s head fire poker at Adrian Wood’s Forge, I would highly recommend it.
I went back for a second course after making a dragon coat hook last year, course which was part of my 50th birthday presents.
Flickr album Short Code
Short code for embedding Flickr albums easily. Here demonstrated with my Inkotober 2020 album.
Short code defined like this
<a data-flickr-embed="true" data-header="true" data-footer="true"
href="{{ index .Params 1 }}"
title="{{ index .Params 0 }}">
<img src="{{ index .Params 2 }}"
width="800" height="600"
alt="{{ index .Params 0 }}">
</a><script async src="//embedr.flickr.com/assets/client-code.js" charset="utf-8"></script>
First parameter is the album title. Second parameter is the album URL. Third parameter is a URL to an image to use for the album.
Shapes
Code can be found at Shapes
Further modification produce different results for Shapes Colours
Flickr shortcode
Testing a Flickr shortcode I found here flickr-hugo-embed and tweaked for my own needs.
Category: Code
Advent of Code 2024
Nearing the time for Advent of Code 2024 thinking of using Node NPM again this year.
Hopefully will complete more this year than before.
Category: Geek
Advent of Code 2024
Nearing the time for Advent of Code 2024 thinking of using Node NPM again this year.
Hopefully will complete more this year than before.
Node JS Jokebot
Learning Node JS
I’ve started playing about with Node JS to learn it enough to modify some legacy Lambda code.
One of the tasks I set myself was to write a Joke bot for Mastodon, which work out to be fairly easy with a couple of packages got and masto.
Dad Joke Bot the code is only 32 lines long, looking to expand it to be able to post images as well.
Python icecream debug
Icecream Debug
Do you ever use print() or log() to debug your code? Of course you do. IceCream, or ic for short, makes print debugging a little sweeter.
ic() is like print(), but better.
TFT Display ST7735 MicroPython
I got a cheap SPI TFT ST7735 Display module with SD Card reader off ebay, it had an unusual number of pins on the back.
It took a while searching about on the internet and some head scratching to find a library and work out what connected to what on the Pico.
This is what I found, and worked out.
TFT Board | Raspberry Pi Pin |
---|---|
LED | 3v3(Out) |
SCK | GP10 |
SDA | GP11 |
AO/DC | GP16 |
Reset | GP17 |
CS | GP18 |
GND | GND |
VCC | VBUS 5V |
Using that information I was able to put together this library based on a few others I found and a few test programs.
Small LED Matrix Numbers
Something I did a few (8) years ago on the Arduino to display two-digit numbers on a 8x8 LED matrix, this is an update to do the same in Micropthon.
Numbers have been defined to 3x5 pixels, so for a two-digit number it fits into 8x5 LED grid with spacing, saving some LED Matrix space.
The code for this can be found here numbers.py
DHT11 Sensor in Micropython
Just a short bit of code to test a DHT11 temperature and humidity sensor module.
This version has just three pins VCC, GND and data, so easy to connect and use with the DHT library.
Raspberry Pi Pico W LED Matrix
Found a LED Matrix with a Max7219 in my parts bin (box of random electronics in the garage) so looked into getting it working with the Pico and MicroPython.
This is an example why I love open source. The original library I found was functional but sparse, last committed to 4 years ago. There were a few forks, most not much activity. One had been active recently and had some major improvements in functionality so switched over to that fork. https://github.com/enchant97/micropython-max7219
Raspberry Pi Pico W Mandelbrot Set
Stumbled across a Python script to run a Mandelbrot set in ASCII in Python so I thought I would see how it ran on the RaspberryPi Pico.
After tweaking it slightly from the source it ended up like this mandelbrot.py
This results in the following;
...................................................................................................
.....................................................................................................
.......................................................................................................
.........................................................................................................
...................................,,,,,,,,,,,,,,,,,.......................................................
..........................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.............................................
.....................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,......................................
.................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----------,,,,,,,,,,,,.................................
...............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---------:i;;::::-------,,,,,,,,,.............................
.............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----------:::;ih$+;;::::-------,,,,,,,,,..........................
...........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,------------::::;;+# hiiii :---------,,,,,,,,,.......................
.........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-------------:::::;;i+hM MM #+;;:---------,,,,,,,,,,....................
.........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,--------------::::::;;ii+hH* $H+ii;:::---------,,,,,,,,,,..................
........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---------------::::::;i+HhH *h++;;::::---------,,,,,,,,,,................
.......,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---------------::::::;;;+ *@ +i;::::::-------,,,,,,,,,,,..............
.....,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---------------::::;;;;;ii+hM@ $hii;;:::::::------,,,,,,,,,,,............
.....,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,--------------:::;;;;;;iiii++h *h+ii;;;;:::::::----,,,,,,,,,,,...........
....,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-------------::::;ii++ ++++++hhHH$@ @MHhh++ii;;;;;ihi;:---,,,,,,,,,,,,.........
....,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----------:::::::;;+H @MHhH$ # $@ h++ii++M$i;:---,,,,,,,,,,,,........
...,,,,,,,,,,,,,,,,,,,,,,,,,,,,--------::::::::::;;;ii@ #@ $HH* $# #;:---,,,,,,,,,,,,.......
..,,,,,,,,,,,,,,,,,,,,,,,,,,,------:::::::::::::;;;;ii+hM * i;::---,,,,,,,,,,,,,.....
..,,,,,,,,,,,,,,,,,,,,,,,,,-----:::::::::::::::;;;;;i++HHM# *+;;:::---,,,,,,,,,,,,,....
..,,,,,,,,,,,,,,,,,,,,,-----::::::::::::::::;;;;;;iiM #Mhii;;::---,,,,,,,,,,,,,....
..,,,,,,,,,,,,,,,,,------::;iH+;;;;;;;;;;;;;;;iiiii++H$ Mh++;::----,,,,,,,,,,,,,...
.,,,,,,,,,,,,---------::::;;iH#++iiii++H*++iiiiii+++H$ $ H;::----,,,,,,,,,,,,,..
,,,,,,,,------------:::::;;;+h **M HhhM $HHMhhhhhhHM@ H;::----,,,,,,,,,,,,,,.
.,,,,,------------::::::::;;ii+hM# @@ #$HHHHM H+i;::-----,,,,,,,,,,,,,.
,,,,------------:::::::::;iiiihh$ $$* @ i;::-----,,,,,,,,,,,,,,
,,-------------::::::::;;iii+H * @ M+;:::-----,,,,,,,,,,,,,,
,------------:::::;;;;i+#HhhhM$@ Mi;:::------,,,,,,,,,,,,,
----------::;;;;;;;iii+hH* * @ hi;::::------,,,,,,,,,,,,,
::::;;;iiMiiiiii+++++MHM $+i;;::::------,,,,,,,,,,,,,
*Hh+i;;::::------,,,,,,,,,,,,,
::::;;;iiMiiiiii+++++MHM $+i;;::::------,,,,,,,,,,,,,
----------::;;;;;;;iii+hH* * @ hi;::::------,,,,,,,,,,,,,
,------------:::::;;;;i+#HhhhM$@ Mi;:::------,,,,,,,,,,,,,
,,-------------::::::::;;iii+H * @ M+;:::-----,,,,,,,,,,,,,,
,,,,------------:::::::::;iiiihh$ $$* @ i;::-----,,,,,,,,,,,,,,
.,,,,,------------::::::::;;ii+hM# @@ #$HHHHM H+i;::-----,,,,,,,,,,,,,.
,,,,,,,,------------:::::;;;+h **M HhhM $HHMhhhhhhHM@ H;::----,,,,,,,,,,,,,,.
.,,,,,,,,,,,,---------::::;;iH#++iiii++H*++iiiiii+++H$ $ H;::----,,,,,,,,,,,,,..
..,,,,,,,,,,,,,,,,,------::;iH+;;;;;;;;;;;;;;;iiiii++H$ Mh++;::----,,,,,,,,,,,,,...
..,,,,,,,,,,,,,,,,,,,,,-----::::::::::::::::;;;;;;iiM #Mhii;;::---,,,,,,,,,,,,,....
..,,,,,,,,,,,,,,,,,,,,,,,,,-----:::::::::::::::;;;;;i++HHM# *+;;:::---,,,,,,,,,,,,,....
..,,,,,,,,,,,,,,,,,,,,,,,,,,,------:::::::::::::;;;;ii+hM * i;::---,,,,,,,,,,,,,.....
...,,,,,,,,,,,,,,,,,,,,,,,,,,,,--------::::::::::;;;ii@ #@ $HH* $# #;:---,,,,,,,,,,,,.......
....,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----------:::::::;;+H @MHhH$ # $@ h++ii++M$i;:---,,,,,,,,,,,,........
....,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-------------::::;ii++ ++++++hhHH$@ @MHhh++ii;;;;;ihi;:---,,,,,,,,,,,,.........
.....,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,--------------:::;;;;;;iiii++h *h+ii;;;;:::::::----,,,,,,,,,,,...........
.....,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---------------::::;;;;;ii+hM@ $hii;;:::::::------,,,,,,,,,,,............
.......,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---------------::::::;;;+ *@ +i;::::::-------,,,,,,,,,,,..............
........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---------------::::::;i+HhH *h++;;::::---------,,,,,,,,,,................
.........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,--------------::::::;;ii+hH* $H+ii;:::---------,,,,,,,,,,..................
.........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-------------:::::;;i+hM MM #+;;:---------,,,,,,,,,,....................
...........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,------------::::;;+# hiiii :---------,,,,,,,,,.......................
.............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----------:::;ih$+;;::::-------,,,,,,,,,..........................
...............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---------:i;;::::-------,,,,,,,,,.............................
.................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----------,,,,,,,,,,,,.................................
.....................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,......................................
..........................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.............................................
...................................,,,,,,,,,,,,,,,,,.......................................................
.........................................................................................................
.......................................................................................................
.....................................................................................................
I amended the code to update the OLED I was using in the temperature sensor tests mand_oled.
Raspberry Pi Pico W Temperature
Have been tinkering with temperature measurement using the Raspberry Pi Pico.
First with the internal temperature sensor and then using a TMP36 temperature sensor externally.
I wrote two classes to access these and return the reading.
Here is an example using the two sensors together temps.py
You will need to upload the two classes to the Pico first in a library
sub-directory.
Here is how you would wire it up on a breadboard tmp36.fzz
Rasberry Pi Pico W OLED
Some components arrived from AliExpress recently so been able to play with an I2C OLED display with my Pico W.
Hello World Test
Code of this is here https://github.com/alastairhm/pico_w/blob/main/i2c_scan.py
And also used here to display the IP address after connected to the wifi https://github.com/alastairhm/pico_w/blob/main/wifi_oled.py
Next thing I’ve been playing with is internal and external temperature sensors, I will post about that soon.
Raspberry Pi Pico W
Just before Christmas I got a Raspberry Pi Pico W to have a play with.
Looking forward to using MicroPython to do some LED flashing and other things.
Started a repo on Github for it Pico W Repo
Search from the command line
A simple Python script to allow you to quickly search from the command line that I’ve been playing with on and off for a while.
https://github.com/alastairhm/searchit
It uses the Python Library Fire to automatically generate the command line interface which is something I stumbled across recently.
You either pass it a paramater for the search term or if one it not passed it used whatever is in your clipboard buffet.
Updating the parameter file you can add other search engines and pick which one to use as your default.
Learn C on Linux
Came across this article of ways to Learn C on Linux which took me back to my 3rd real programming job.
It was with a software house mainly working with C/C++ on Linux/ Unix and embedded systems.
My first real experience use C/C++ in a professional environment, happy days with a good bunch of geeks.
If you’ve never tried it before it would be a good change from more recent languages to learn C for a challenge.
6502 Assembly Language
Been trying to relearn 6502 assembly language for fun, its a lot faster and easier than the first time on actual hardware when I was a teenager.
Been using a book I picked up from eBay Discovering BBC Micro Machine Code by A.P. Stephenson
Using BeebAsm assembler on my Mac with a BBC Micro emulator, rather than build in BBC BASIC one.
You can find my code at Github https://github.com/alastairhm/beebasm
This example draws a line of zeros to Mode 7, see screenshot below.
Category: NodeJS
Advent of Code 2024
Nearing the time for Advent of Code 2024 thinking of using Node NPM again this year.
Hopefully will complete more this year than before.
Node JS Jokebot
Learning Node JS
I’ve started playing about with Node JS to learn it enough to modify some legacy Lambda code.
One of the tasks I set myself was to write a Joke bot for Mastodon, which work out to be fairly easy with a couple of packages got and masto.
Dad Joke Bot the code is only 32 lines long, looking to expand it to be able to post images as well.
Category: Technical
Cascading Updates
Having been a bit lazy in not updating my Hugo version since I started which was recently breaking one of my Github actions, I decided do do that.
This lead to an cascading update cycle.
- Updating Hugo version broke the theme I was using.
- Updating the theme broke the Tweet shortcode, no longer on Twitter so edited those post which referenced my old Twitter account.
- Updating the Hugo version, broke the Github Action which was building and uploaded to S3. This was due to newer versions of Hugo now having an “extended” and “with_deploy” versions.
- Raised a PR against the Github action to update to use the “with_deploy” version.
Still a couple of deprecated warning and fixing background and social icon links to sort out but at least now running against the latest version of Hugo.
Clipboard History
I wrote a simple Python script to monitor the clipboard and write any unique text content out to a YAML file for a history. It might turn into something better eventually.
Update
Updated to use a settings file for file location and size.
#!/usr/bin/env python3
import pyperclip
import time
import yaml
import toml
import os
from yaml.loader import SafeLoader
script_path = os.path.dirname(os.path.abspath(__file__))
settings = toml.load(os.path.join(script_path, "clippy.toml"))
history = settings["history"]
max_size = settings["size"]
cliptext = ""
clip_array = []
with open(history, "r") as f:
clip_array = list(yaml.load_all(f, Loader=SafeLoader))
clip_array = sum(clip_array, [])
while True:
tmptext = pyperclip.paste()
if tmptext != cliptext:
cliptext = tmptext
if cliptext not in clip_array:
clip_array.insert(0,tmptext)
if len(clip_array) > max_size:
clip_array.pop()
with open(history, "w") as f:
f.write(yaml.dump(clip_array))
time.sleep(1)
Script on GitHub https://github.com/alastairhm/automate_python/blob/main/clippy.py
CA Thumbprint from Python
Recently had a need to get the CA Thumbprint from the Root certificate of a domain. This was for creating OIDC provider for an AWS EKS cluster.
This is the solution I came up with.
Puppy linux 9.5
One of my favorite low foot print Linux installs is Puppy Linux been using it on and off for years.
It has saved my bacon on a few times used to boot and restore or save data from a dead OS install.
New version looks good so far.
Processing
Make learning programming fun
It is funny how things come around again, when I started learning to programming back in the 1980s on my 8 bit machines (ZX81, Acorn Electron, BBC Micro) I used to play with graphics a lot. It gave instant feedback and visually showed the results of things like recursion. I had great fun playing with Fractals and other procedural generated images.
Recently I discovered a YouTube channel and programming platform which took me right back to those days.
Which Shell?
I made the switch from Bash shell to the FISH shell a couple of years ago now and never looked back.
Customization and auto-complete features was the killer features for me.
Jump to the 20 minute mark for the shell discussion if you want.
Video Source Destination Linux
Links
Hugo Lbry Shortcode
One thing I like about Hugo is how easy it is to expand its functionality with your own code.
For example was able to create a shortcode to embed Lbry.tv videos into a post in around five minutes.
First I created an empty file layouts/shortcodes/lbry.html
which I pasted the basic embed code take from the share button on one of their videos.
<iframe id="lbry-iframe" width="560" height="315" src="https://lbry.tv/$/embed/this-new-fedora-powered-thinkpad-p53-is/097106eb68aebc90b33d83bb053467af942a8e20" allowfullscreen></iframe>
Then parameterized this so that the src url can be changed.
Markor Android App
Found this useful Android Mark down application.
Markor it has a Hugo template to use for blank documents which is useful.
It’s on FDroid so it’s easy to install o on my kindle as well.
Then use Github website to upload the new file to my Hugo blog repo.
Posting from Android 2
Testing github Web upload.
Update
Edited on mark down app, uploaded again via github web page.
Mgit
Found mGit App which looks like it would do the job of repo management on Android.
First trial not so good.
Wondering if its an issue with having MFA enabled on my Github account, although using my personal access token instead of the password should work I would have thought.
I’ve submitted an issue on their Github page, so wait and see what they say about it.
Posting from Android
Trying to think of a way to be able to post content from my Android devices (phone/ Fire Tablet).
Basically would need just the following;
- Text editor for creating markdown for the post.
- Git to checkout, commit and push updates to GitHub.
My Travis CI pipeline would then handle the publishing.
Finding a text editor app isn’t a problem there are any number of them on both Google Play and Amazon Kindle stores which could be used.
Automation
Automate publishing
To make the publishing of new content easily I am using Travis CI to publish changes.
I did try installing Hugo from source but this took longer and was producing errors so it was easier to download the binary.
Using this as the Travis CI pipline yaml.
Travis CI Pipeline
# Auto deploy repo from Github to Amazon S3 bucket via Travis CI
# * Set env vars for ACCESS_KEY_ID, BUCKET_NAME and SECRET_ACCESS_KEY on Travis
# * Update `bucket.name` in `sync` command
# * Assumes your `publishDir` is the default (`public`) - if not update `sync` command
language: go
before_install:
addons:
apt:
packages:
- libcurl4-openssl-dev # required to avoid SSL errors
install:
- curl -LO https://github.com/gohugoio/hugo/releases/download/v0.74.3/hugo_0.74.3_Linux-64bit.deb
- sudo dpkg -i hugo_0.74.3_Linux-64bit.deb
before_script:
- python --version
- sudo pip install s3cmd
script:
- hugo
after_success:
- s3cmd sync -v --delete-removed --no-preserve --access_key=$ACCESS_KEY_ID --secret_key=$SECRET_ACCESS_KEY -r public/ s3://$BUCKET_NAME
notifications:
email: true
Category: Python
Python icecream debug
Icecream Debug
Do you ever use print() or log() to debug your code? Of course you do. IceCream, or ic for short, makes print debugging a little sweeter.
ic() is like print(), but better.
TFT Display ST7735 MicroPython
I got a cheap SPI TFT ST7735 Display module with SD Card reader off ebay, it had an unusual number of pins on the back.
It took a while searching about on the internet and some head scratching to find a library and work out what connected to what on the Pico.
This is what I found, and worked out.
TFT Board | Raspberry Pi Pin |
---|---|
LED | 3v3(Out) |
SCK | GP10 |
SDA | GP11 |
AO/DC | GP16 |
Reset | GP17 |
CS | GP18 |
GND | GND |
VCC | VBUS 5V |
Using that information I was able to put together this library based on a few others I found and a few test programs.
Small LED Matrix Numbers
Something I did a few (8) years ago on the Arduino to display two-digit numbers on a 8x8 LED matrix, this is an update to do the same in Micropthon.
Numbers have been defined to 3x5 pixels, so for a two-digit number it fits into 8x5 LED grid with spacing, saving some LED Matrix space.
The code for this can be found here numbers.py
DHT11 Sensor in Micropython
Just a short bit of code to test a DHT11 temperature and humidity sensor module.
This version has just three pins VCC, GND and data, so easy to connect and use with the DHT library.
Raspberry Pi Pico W LED Matrix
Found a LED Matrix with a Max7219 in my parts bin (box of random electronics in the garage) so looked into getting it working with the Pico and MicroPython.
This is an example why I love open source. The original library I found was functional but sparse, last committed to 4 years ago. There were a few forks, most not much activity. One had been active recently and had some major improvements in functionality so switched over to that fork. https://github.com/enchant97/micropython-max7219
Raspberry Pi Pico W Mandelbrot Set
Stumbled across a Python script to run a Mandelbrot set in ASCII in Python so I thought I would see how it ran on the RaspberryPi Pico.
After tweaking it slightly from the source it ended up like this mandelbrot.py
This results in the following;
...................................................................................................
.....................................................................................................
.......................................................................................................
.........................................................................................................
...................................,,,,,,,,,,,,,,,,,.......................................................
..........................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.............................................
.....................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,......................................
.................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----------,,,,,,,,,,,,.................................
...............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---------:i;;::::-------,,,,,,,,,.............................
.............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----------:::;ih$+;;::::-------,,,,,,,,,..........................
...........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,------------::::;;+# hiiii :---------,,,,,,,,,.......................
.........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-------------:::::;;i+hM MM #+;;:---------,,,,,,,,,,....................
.........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,--------------::::::;;ii+hH* $H+ii;:::---------,,,,,,,,,,..................
........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---------------::::::;i+HhH *h++;;::::---------,,,,,,,,,,................
.......,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---------------::::::;;;+ *@ +i;::::::-------,,,,,,,,,,,..............
.....,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---------------::::;;;;;ii+hM@ $hii;;:::::::------,,,,,,,,,,,............
.....,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,--------------:::;;;;;;iiii++h *h+ii;;;;:::::::----,,,,,,,,,,,...........
....,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-------------::::;ii++ ++++++hhHH$@ @MHhh++ii;;;;;ihi;:---,,,,,,,,,,,,.........
....,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----------:::::::;;+H @MHhH$ # $@ h++ii++M$i;:---,,,,,,,,,,,,........
...,,,,,,,,,,,,,,,,,,,,,,,,,,,,--------::::::::::;;;ii@ #@ $HH* $# #;:---,,,,,,,,,,,,.......
..,,,,,,,,,,,,,,,,,,,,,,,,,,,------:::::::::::::;;;;ii+hM * i;::---,,,,,,,,,,,,,.....
..,,,,,,,,,,,,,,,,,,,,,,,,,-----:::::::::::::::;;;;;i++HHM# *+;;:::---,,,,,,,,,,,,,....
..,,,,,,,,,,,,,,,,,,,,,-----::::::::::::::::;;;;;;iiM #Mhii;;::---,,,,,,,,,,,,,....
..,,,,,,,,,,,,,,,,,------::;iH+;;;;;;;;;;;;;;;iiiii++H$ Mh++;::----,,,,,,,,,,,,,...
.,,,,,,,,,,,,---------::::;;iH#++iiii++H*++iiiiii+++H$ $ H;::----,,,,,,,,,,,,,..
,,,,,,,,------------:::::;;;+h **M HhhM $HHMhhhhhhHM@ H;::----,,,,,,,,,,,,,,.
.,,,,,------------::::::::;;ii+hM# @@ #$HHHHM H+i;::-----,,,,,,,,,,,,,.
,,,,------------:::::::::;iiiihh$ $$* @ i;::-----,,,,,,,,,,,,,,
,,-------------::::::::;;iii+H * @ M+;:::-----,,,,,,,,,,,,,,
,------------:::::;;;;i+#HhhhM$@ Mi;:::------,,,,,,,,,,,,,
----------::;;;;;;;iii+hH* * @ hi;::::------,,,,,,,,,,,,,
::::;;;iiMiiiiii+++++MHM $+i;;::::------,,,,,,,,,,,,,
*Hh+i;;::::------,,,,,,,,,,,,,
::::;;;iiMiiiiii+++++MHM $+i;;::::------,,,,,,,,,,,,,
----------::;;;;;;;iii+hH* * @ hi;::::------,,,,,,,,,,,,,
,------------:::::;;;;i+#HhhhM$@ Mi;:::------,,,,,,,,,,,,,
,,-------------::::::::;;iii+H * @ M+;:::-----,,,,,,,,,,,,,,
,,,,------------:::::::::;iiiihh$ $$* @ i;::-----,,,,,,,,,,,,,,
.,,,,,------------::::::::;;ii+hM# @@ #$HHHHM H+i;::-----,,,,,,,,,,,,,.
,,,,,,,,------------:::::;;;+h **M HhhM $HHMhhhhhhHM@ H;::----,,,,,,,,,,,,,,.
.,,,,,,,,,,,,---------::::;;iH#++iiii++H*++iiiiii+++H$ $ H;::----,,,,,,,,,,,,,..
..,,,,,,,,,,,,,,,,,------::;iH+;;;;;;;;;;;;;;;iiiii++H$ Mh++;::----,,,,,,,,,,,,,...
..,,,,,,,,,,,,,,,,,,,,,-----::::::::::::::::;;;;;;iiM #Mhii;;::---,,,,,,,,,,,,,....
..,,,,,,,,,,,,,,,,,,,,,,,,,-----:::::::::::::::;;;;;i++HHM# *+;;:::---,,,,,,,,,,,,,....
..,,,,,,,,,,,,,,,,,,,,,,,,,,,------:::::::::::::;;;;ii+hM * i;::---,,,,,,,,,,,,,.....
...,,,,,,,,,,,,,,,,,,,,,,,,,,,,--------::::::::::;;;ii@ #@ $HH* $# #;:---,,,,,,,,,,,,.......
....,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----------:::::::;;+H @MHhH$ # $@ h++ii++M$i;:---,,,,,,,,,,,,........
....,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-------------::::;ii++ ++++++hhHH$@ @MHhh++ii;;;;;ihi;:---,,,,,,,,,,,,.........
.....,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,--------------:::;;;;;;iiii++h *h+ii;;;;:::::::----,,,,,,,,,,,...........
.....,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---------------::::;;;;;ii+hM@ $hii;;:::::::------,,,,,,,,,,,............
.......,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---------------::::::;;;+ *@ +i;::::::-------,,,,,,,,,,,..............
........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---------------::::::;i+HhH *h++;;::::---------,,,,,,,,,,................
.........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,--------------::::::;;ii+hH* $H+ii;:::---------,,,,,,,,,,..................
.........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-------------:::::;;i+hM MM #+;;:---------,,,,,,,,,,....................
...........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,------------::::;;+# hiiii :---------,,,,,,,,,.......................
.............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----------:::;ih$+;;::::-------,,,,,,,,,..........................
...............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---------:i;;::::-------,,,,,,,,,.............................
.................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----------,,,,,,,,,,,,.................................
.....................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,......................................
..........................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.............................................
...................................,,,,,,,,,,,,,,,,,.......................................................
.........................................................................................................
.......................................................................................................
.....................................................................................................
I amended the code to update the OLED I was using in the temperature sensor tests mand_oled.
Raspberry Pi Pico W Temperature
Have been tinkering with temperature measurement using the Raspberry Pi Pico.
First with the internal temperature sensor and then using a TMP36 temperature sensor externally.
I wrote two classes to access these and return the reading.
Here is an example using the two sensors together temps.py
You will need to upload the two classes to the Pico first in a library
sub-directory.
Here is how you would wire it up on a breadboard tmp36.fzz
Rasberry Pi Pico W OLED
Some components arrived from AliExpress recently so been able to play with an I2C OLED display with my Pico W.
Hello World Test
Code of this is here https://github.com/alastairhm/pico_w/blob/main/i2c_scan.py
And also used here to display the IP address after connected to the wifi https://github.com/alastairhm/pico_w/blob/main/wifi_oled.py
Next thing I’ve been playing with is internal and external temperature sensors, I will post about that soon.
Raspberry Pi Pico W
Just before Christmas I got a Raspberry Pi Pico W to have a play with.
Looking forward to using MicroPython to do some LED flashing and other things.
Started a repo on Github for it Pico W Repo
Clipboard History
I wrote a simple Python script to monitor the clipboard and write any unique text content out to a YAML file for a history. It might turn into something better eventually.
Update
Updated to use a settings file for file location and size.
#!/usr/bin/env python3
import pyperclip
import time
import yaml
import toml
import os
from yaml.loader import SafeLoader
script_path = os.path.dirname(os.path.abspath(__file__))
settings = toml.load(os.path.join(script_path, "clippy.toml"))
history = settings["history"]
max_size = settings["size"]
cliptext = ""
clip_array = []
with open(history, "r") as f:
clip_array = list(yaml.load_all(f, Loader=SafeLoader))
clip_array = sum(clip_array, [])
while True:
tmptext = pyperclip.paste()
if tmptext != cliptext:
cliptext = tmptext
if cliptext not in clip_array:
clip_array.insert(0,tmptext)
if len(clip_array) > max_size:
clip_array.pop()
with open(history, "w") as f:
f.write(yaml.dump(clip_array))
time.sleep(1)
Script on GitHub https://github.com/alastairhm/automate_python/blob/main/clippy.py
Category: Blacksmith
Blacksmith Day 2023
Had a great day on my blacksmith course making a Ram’s head fire poker at Adrian Wood’s Forge, I would highly recommend it.
I went back for a second course after making a dragon coat hook last year, course which was part of my 50th birthday presents.
Category: RaspberryPi
TFT Display ST7735 MicroPython
I got a cheap SPI TFT ST7735 Display module with SD Card reader off ebay, it had an unusual number of pins on the back.
It took a while searching about on the internet and some head scratching to find a library and work out what connected to what on the Pico.
This is what I found, and worked out.
TFT Board | Raspberry Pi Pin |
---|---|
LED | 3v3(Out) |
SCK | GP10 |
SDA | GP11 |
AO/DC | GP16 |
Reset | GP17 |
CS | GP18 |
GND | GND |
VCC | VBUS 5V |
Using that information I was able to put together this library based on a few others I found and a few test programs.
Small LED Matrix Numbers
Something I did a few (8) years ago on the Arduino to display two-digit numbers on a 8x8 LED matrix, this is an update to do the same in Micropthon.
Numbers have been defined to 3x5 pixels, so for a two-digit number it fits into 8x5 LED grid with spacing, saving some LED Matrix space.
The code for this can be found here numbers.py
DHT11 Sensor in Micropython
Just a short bit of code to test a DHT11 temperature and humidity sensor module.
This version has just three pins VCC, GND and data, so easy to connect and use with the DHT library.
Raspberry Pi Pico W LED Matrix
Found a LED Matrix with a Max7219 in my parts bin (box of random electronics in the garage) so looked into getting it working with the Pico and MicroPython.
This is an example why I love open source. The original library I found was functional but sparse, last committed to 4 years ago. There were a few forks, most not much activity. One had been active recently and had some major improvements in functionality so switched over to that fork. https://github.com/enchant97/micropython-max7219
Raspberry Pi Pico W Mandelbrot Set
Stumbled across a Python script to run a Mandelbrot set in ASCII in Python so I thought I would see how it ran on the RaspberryPi Pico.
After tweaking it slightly from the source it ended up like this mandelbrot.py
This results in the following;
...................................................................................................
.....................................................................................................
.......................................................................................................
.........................................................................................................
...................................,,,,,,,,,,,,,,,,,.......................................................
..........................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.............................................
.....................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,......................................
.................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----------,,,,,,,,,,,,.................................
...............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---------:i;;::::-------,,,,,,,,,.............................
.............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----------:::;ih$+;;::::-------,,,,,,,,,..........................
...........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,------------::::;;+# hiiii :---------,,,,,,,,,.......................
.........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-------------:::::;;i+hM MM #+;;:---------,,,,,,,,,,....................
.........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,--------------::::::;;ii+hH* $H+ii;:::---------,,,,,,,,,,..................
........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---------------::::::;i+HhH *h++;;::::---------,,,,,,,,,,................
.......,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---------------::::::;;;+ *@ +i;::::::-------,,,,,,,,,,,..............
.....,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---------------::::;;;;;ii+hM@ $hii;;:::::::------,,,,,,,,,,,............
.....,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,--------------:::;;;;;;iiii++h *h+ii;;;;:::::::----,,,,,,,,,,,...........
....,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-------------::::;ii++ ++++++hhHH$@ @MHhh++ii;;;;;ihi;:---,,,,,,,,,,,,.........
....,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----------:::::::;;+H @MHhH$ # $@ h++ii++M$i;:---,,,,,,,,,,,,........
...,,,,,,,,,,,,,,,,,,,,,,,,,,,,--------::::::::::;;;ii@ #@ $HH* $# #;:---,,,,,,,,,,,,.......
..,,,,,,,,,,,,,,,,,,,,,,,,,,,------:::::::::::::;;;;ii+hM * i;::---,,,,,,,,,,,,,.....
..,,,,,,,,,,,,,,,,,,,,,,,,,-----:::::::::::::::;;;;;i++HHM# *+;;:::---,,,,,,,,,,,,,....
..,,,,,,,,,,,,,,,,,,,,,-----::::::::::::::::;;;;;;iiM #Mhii;;::---,,,,,,,,,,,,,....
..,,,,,,,,,,,,,,,,,------::;iH+;;;;;;;;;;;;;;;iiiii++H$ Mh++;::----,,,,,,,,,,,,,...
.,,,,,,,,,,,,---------::::;;iH#++iiii++H*++iiiiii+++H$ $ H;::----,,,,,,,,,,,,,..
,,,,,,,,------------:::::;;;+h **M HhhM $HHMhhhhhhHM@ H;::----,,,,,,,,,,,,,,.
.,,,,,------------::::::::;;ii+hM# @@ #$HHHHM H+i;::-----,,,,,,,,,,,,,.
,,,,------------:::::::::;iiiihh$ $$* @ i;::-----,,,,,,,,,,,,,,
,,-------------::::::::;;iii+H * @ M+;:::-----,,,,,,,,,,,,,,
,------------:::::;;;;i+#HhhhM$@ Mi;:::------,,,,,,,,,,,,,
----------::;;;;;;;iii+hH* * @ hi;::::------,,,,,,,,,,,,,
::::;;;iiMiiiiii+++++MHM $+i;;::::------,,,,,,,,,,,,,
*Hh+i;;::::------,,,,,,,,,,,,,
::::;;;iiMiiiiii+++++MHM $+i;;::::------,,,,,,,,,,,,,
----------::;;;;;;;iii+hH* * @ hi;::::------,,,,,,,,,,,,,
,------------:::::;;;;i+#HhhhM$@ Mi;:::------,,,,,,,,,,,,,
,,-------------::::::::;;iii+H * @ M+;:::-----,,,,,,,,,,,,,,
,,,,------------:::::::::;iiiihh$ $$* @ i;::-----,,,,,,,,,,,,,,
.,,,,,------------::::::::;;ii+hM# @@ #$HHHHM H+i;::-----,,,,,,,,,,,,,.
,,,,,,,,------------:::::;;;+h **M HhhM $HHMhhhhhhHM@ H;::----,,,,,,,,,,,,,,.
.,,,,,,,,,,,,---------::::;;iH#++iiii++H*++iiiiii+++H$ $ H;::----,,,,,,,,,,,,,..
..,,,,,,,,,,,,,,,,,------::;iH+;;;;;;;;;;;;;;;iiiii++H$ Mh++;::----,,,,,,,,,,,,,...
..,,,,,,,,,,,,,,,,,,,,,-----::::::::::::::::;;;;;;iiM #Mhii;;::---,,,,,,,,,,,,,....
..,,,,,,,,,,,,,,,,,,,,,,,,,-----:::::::::::::::;;;;;i++HHM# *+;;:::---,,,,,,,,,,,,,....
..,,,,,,,,,,,,,,,,,,,,,,,,,,,------:::::::::::::;;;;ii+hM * i;::---,,,,,,,,,,,,,.....
...,,,,,,,,,,,,,,,,,,,,,,,,,,,,--------::::::::::;;;ii@ #@ $HH* $# #;:---,,,,,,,,,,,,.......
....,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----------:::::::;;+H @MHhH$ # $@ h++ii++M$i;:---,,,,,,,,,,,,........
....,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-------------::::;ii++ ++++++hhHH$@ @MHhh++ii;;;;;ihi;:---,,,,,,,,,,,,.........
.....,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,--------------:::;;;;;;iiii++h *h+ii;;;;:::::::----,,,,,,,,,,,...........
.....,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---------------::::;;;;;ii+hM@ $hii;;:::::::------,,,,,,,,,,,............
.......,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---------------::::::;;;+ *@ +i;::::::-------,,,,,,,,,,,..............
........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---------------::::::;i+HhH *h++;;::::---------,,,,,,,,,,................
.........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,--------------::::::;;ii+hH* $H+ii;:::---------,,,,,,,,,,..................
.........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-------------:::::;;i+hM MM #+;;:---------,,,,,,,,,,....................
...........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,------------::::;;+# hiiii :---------,,,,,,,,,.......................
.............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----------:::;ih$+;;::::-------,,,,,,,,,..........................
...............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---------:i;;::::-------,,,,,,,,,.............................
.................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----------,,,,,,,,,,,,.................................
.....................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,......................................
..........................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.............................................
...................................,,,,,,,,,,,,,,,,,.......................................................
.........................................................................................................
.......................................................................................................
.....................................................................................................
I amended the code to update the OLED I was using in the temperature sensor tests mand_oled.
Raspberry Pi Pico W Temperature
Have been tinkering with temperature measurement using the Raspberry Pi Pico.
First with the internal temperature sensor and then using a TMP36 temperature sensor externally.
I wrote two classes to access these and return the reading.
Here is an example using the two sensors together temps.py
You will need to upload the two classes to the Pico first in a library
sub-directory.
Here is how you would wire it up on a breadboard tmp36.fzz
Rasberry Pi Pico W OLED
Some components arrived from AliExpress recently so been able to play with an I2C OLED display with my Pico W.
Hello World Test
Code of this is here https://github.com/alastairhm/pico_w/blob/main/i2c_scan.py
And also used here to display the IP address after connected to the wifi https://github.com/alastairhm/pico_w/blob/main/wifi_oled.py
Next thing I’ve been playing with is internal and external temperature sensors, I will post about that soon.
Raspberry Pi Pico W
Just before Christmas I got a Raspberry Pi Pico W to have a play with.
Looking forward to using MicroPython to do some LED flashing and other things.
Started a repo on Github for it Pico W Repo
Category: Photo
Category: Photography
Category: Programming
Search from the command line
A simple Python script to allow you to quickly search from the command line that I’ve been playing with on and off for a while.
https://github.com/alastairhm/searchit
It uses the Python Library Fire to automatically generate the command line interface which is something I stumbled across recently.
You either pass it a paramater for the search term or if one it not passed it used whatever is in your clipboard buffet.
Updating the parameter file you can add other search engines and pick which one to use as your default.
Processing
Make learning programming fun
It is funny how things come around again, when I started learning to programming back in the 1980s on my 8 bit machines (ZX81, Acorn Electron, BBC Micro) I used to play with graphics a lot. It gave instant feedback and visually showed the results of things like recursion. I had great fun playing with Fractals and other procedural generated images.
Recently I discovered a YouTube channel and programming platform which took me right back to those days.
Category: Gaming
Steam World Dig
Picked this indie retro style platform game for my Playstation 5 cheap recently.
It was released in 2013, so old now but still a good play.
Links
Category: Retro
BBC Twitter Bot Fun
More fun playing with BBC Twitter Bot.
https://tco/ks0jhudxdM
https://tco/jVpUMLBa8D
https://tco/Rt3DOf1FOh
Beebasm Mac Catalina
Got a new Mac with Catalina pre-installed, so had to compile my own version of Beebasm for the 64 bit OS.
10 PRINT6502
BBC Micro machine code take on C64 10 Print one line random pattern generator.
Code at Github 10print.asm
\ 10 PRINT
\ Using BeebASM assembler
\ (c) Alastair Montgomery
INCLUDE "../lib/constants.asm"
seed = &70
ORG &2000
.start
LDA #23
STA seed
LDA #63
STA seed+1
LDX #0
.char
LDA chartable, X
JSR oswrch
INX
CPX #23
BNE char
.loop
JSR random
BMI two
.one
LDA #224
JMP print
.two
LDA #225
.print
JSR oswrch
JMP loop
.finish
RTS
.random
INCLUDE "../lib/random.asm"
.chartable
EQUB 22,0
EQUB 23,224,8,8,12,7,224,48,16,16
EQUB 23,225,16,16,48,224,7,12,8,8
.end
SAVE "MyCode", start, end
10 PRINT
BBC Micro take on C64 10 Print one line random pattern generator.
10 MODE 0
20 N=RND(1):IF N > 0.5 THEN PRINT "/"; ELSE PRINT "\";
30 GOTO 20
RUN
Golden Tail and Kitsune's Curse New Retro Game
New retro game, looks worth getting a Amstrad CPC emulator setup to play it.
Juan’s games: (https://www.usebox.net/jjm/)
Buy physical copies of these games:
The Pit New Retro Game
New retro game, looks worth getting a Commodore emulator setup to play it.
This style of game is one of my favorites, loved Boulder Dash and Repton.
Retro Gaming Commando
One of the games I loved playing in my youth on my BBC Micro, I’m still rubbish at it to this day.
Links
Category: Work
Six months
Six Months
Doesn’t time fly, been at my new job with the DWP six months now.
Still enjoying it, learning new tools (Nomad, Pact, etc) and techinques as they say everyday is a school day.
I a major part of it is the team I joined, most welcoming and helpful bunch, looking forward to the next six months.
New Job
New Job
After nine years and nine months at William Hill I will be starting a new job next Monday.
Looking forward to the new challenge but also sad to say goodbye to my co-workers who have been on the journey with me since I started at William Hill back in November 2011.
I have certainly grown and learned a lot at my time at William Hill and am grateful for all the opportunities they provided with me to improve.
Category: General
Reading
One positive thing that’s come out of the COVID-19 situation is that I’ve had more time to read than before.
So much so I’ve already smashed my GoodReads reading challenge for this year.
0x32 years old
0x32 (50) years old
So it’s happened, 50 years, where did they go.
I don’t feel any different (mentally) that when I was younger, maybe a bit more grumpy and opinionated, but that’s the benefit of getting old surely?
My First Post
My First Post
Welcome to my new blog 0x32 started as I reach the age of 50.