These are last weeks findings, I will add to this page when I discover other useful things.
Platformio
always include “Arduino.h”
Order of functions matter! (Not with Arduino IDE)
setup serial monitor speed in platformio.ini monitor_speed = 115200
Arduino IDE
Build error “panic: runtime error: index out of range [3] with length 3” or length 4. Code probably correct, build with another board and build+upload with correct board as workaround.
Generic
Using a SSD1306 with other pins? For example with Adafruit_SSD1306.h in setup(){ place Wire.begin(5,4);
I’ve build a IR Blaster in the past and tested IR with EspEasy Dev. I’m not happy with my Harmony Hub. Not so much control as i like to have.
So now OpenMqttGateway with IR.
Wemos D1 with IR shieldIR Signal (visible using mobile phone)
I’ve installed platformio in the past. Not really a fan of visual-code i’m showing you the process on CLI
We can’t use the webinstaller or a precompiled binary because we need to change GPIO ports
wget https://github.com/1technophile/OpenMQTTGateway/releases/download/v1.5.0/nodemcuv2-ir-libraries.zip
wget https://github.com/1technophile/OpenMQTTGateway/archive/refs/tags/v1.5.0.tar.gz
tar xzvf v1.5.0.tar.gz
cd v1.5.0/libs
unzip ../../nodemcuv2-ir-libraries.zip
cd ..
edit platformio.ini
remove ; from
default_envs = nodemcuv2-ir
vi main/config_IR.h
search for LOLIN, edit and change into 0 (GPIO 0 = D3)
build and upload
pio run --target upload --upload-port /dev/ttyUSB0
build and upload with flash erase
pio run --target erase --target upload --upload-port /dev/ttyUSB0
clean the environment when needed
pio run -t clean
Now you will get a Access Point, connect and enter your Wifi network information and mqtt server.
When connected you will see the IR codes and if you installed mqtt support in home assistant it will see the mqtt topics.
I’ve copied a json output as was send by my IR remote. Below an example using mosquitto_pub to send codes.
Why use platformio? I know Arduino IDE is easier for starters. Platformio is far more flexible, you can make projects with their own versions of libraries. I like CLI, easier to do version control (git)
I was needing ALL GPIO pins, even RX/TX ( see trick below) When doing so, you can’t use serialprint. Do NOT enable, your sketch won’t work!
Don’t use pullup on D8, you can’t upload to the wemos if you do that
Due to library conflicts in keypad.h, DON’T change the order in the source. You will end up with compile errors!
The keypad has a weird pinout, but there are similar keypads with alternative layouts. Measure this using a multimeter.
The pull-up resistors will help fighting ghost key presses!
I2C needs D1/D2
To use RX/TX as GPIO pins you need to do the following:
//Define pins
int led = 1; //tx
int col = 3; //rx
// Change to function mode 3
// see https://www.esp8266.com/wiki/doku.php?id=esp8266_gpio_pin_allocations
pinMode(1, FUNCTION_3);
pinMode(3, FUNCTION_3);
// Revert to normal mode
// pinMode(1, FUNCTION0);
// Define mode input/output
// i'm using led to control the led so thats an output
// I'm using col for the keypad column scanner, that's an input
pinMode(led, OUTPUT);
pinMode(col, INPUT);
Complete code
The (*) clears input The (#) sends the pin code using MQTT
Sending a 0 or 1 to escape/keypadin topic will toggle the led
I never look in the mirror, so why do i need one? The mirror foil was already ugly in the corners. There were bumps. Never finished a proper interface
This one was made using a touch screen, so there are always fingerprints you could see
I’m going to use the display for an in-house small Escape Room idea i have.
Only the time part still worked, but i could not find the right cables for the touch part. The buttons displayed are meaningless anyway 🙂 Just a mockup
Mirror part was done using a Safety/One way mirror foil. Cut a part as large as you screen, spray a little water and stick it on.
At some point i displayed Dashticz on there. Apparently i started playing with a magic mirror setup in 2015, according some timestamps of code on my fileserver.
I have several ip cameras which monitor movement in and around our home.
I’m using Zoneminder and other home automation systems but i want to scan through a bunch of files uploaded by the security cameras to my secondary fileserver.
So what is interesting?
Major movement compared to a base image
Movement compared to a previous uploaded image
Setting a threshold when to output information (note the 65% mark)
Looking at the output we see: At 76% of the captured images (image 1438) the threshold was above 3000 and the minus gives us the information of the difference between this image and the previous, the X marks the difference between current image and the baseline. | percent | image number | filename | difference | graphbar
Bash script:
#!/bin/bash
threshold=3000
baseline=$( ls SDAlarm*jpg | head -1)
previous=$( ls SDAlarm*jpg | head -1)
total=$( ls *.jpg |wc -l)
echo "Number of files : $total"
nr=1
ls *jpg | while read; do
graph="....................................................................................................."
diff=$(compare -verbose -metric MAE $baseline $REPLY /dev/null 2>&1 | grep all | awk '{ print $2 }' | cut -f1 -d. )
prevdiff=$(compare -verbose -metric MAE $previous $REPLY /dev/null 2>&1 | grep all | awk '{ print $2 }' | cut -f1 -d. )
line=$( echo "100 / $total * $nr" | bc -l | cut -f1 -d.)
line=$(( $line + 1))
#echo -n "$line | $nr | $REPLY | "
#echo $diff
draw1=$(( $diff / 100 + 1))
draw2=$(( $prevdiff / 100 + 1))
graph=$(echo $graph | sed "s/./X/$draw1")
graph=$(echo $graph | sed "s/./-/$draw2")
if [ $diff -gt $threshold ] ; then
printf "| %4s %% | %3s | %30s | %5s | %102s \n" $line $nr $REPLY $diff $graph
fi
nr=$(( $nr +1 ))
previous=$REPLY
done
Want to see only difference with previous image?
change:
if [ $diff -gt $threshold ] ; then into if [ $prevdiff -gt $threshold ] ; then
I’m using below scripts to generate tunebooks. These books I can print OR view on a tablet using my DIY bluetooth page turner. ( see other post )
I often work on tunes, add notes, text or write other versions. So i needed a fast and simple way to re-generate a tunebook. ( hence the date on the title page and in the name, so i know whats the most recent version ) Now i have a separate tunebook for each instrument, with the same looks
What does this script?
Generates a title page using Latex
Generates a tune index, with page numbers ( works with multipage tunes )
Adds bookmarks to the tunes, so you can use the bookmark link in your reader.
000 title 001 index 002 – 099 xyz (extra pages, not in index) 100 – 999 Tunes (sorting)
000 title.pdf
001aIndex.pdf
002 tuneinfo.pdf
100 The Battle of Aughrim.pdf
101 I was born for sports.pdf
105 Cerlew Jig.pdf
110 Chanters Song.pdf
115 Gander at the Pratie Hole.pdf
120 honeymoon.pdf
125 Kitty Goes a-Milking.pdf
130 Terribus.pdf
./generatebook
Tune PDFs in directory : 8
Needed index pages : 1
Extra pages : 1
Total pages for tunes : 3
create column page as text
Create Index pdf
Create title page pdf
Add bookmarks : ........
download the package with used files and compilers from here: https://media.henriaanstoot.nl/assembly.tgz
extract with tar xzvf /tmp/assembly.tgz to a directory
start dosbox and mount the directory as C
mount c /path/assembly
Run “a line”, this a batchfile which starts the editor (qedit) When closing the file (esc – q menu) It will compile the assembly and write out a executable
This is the batchfile
@echo off
q %1.asm
cls
masm %1.asm;
link %1.obj;
exe2bin %1.exe %1.com
echo READY!
line assemblycode
NAME lijnentrekroutine
.286
Code SEGMENT
ASSUME CS:Code,DS:Code
org 100h
Start:
mov ax,13h ;set video mode
int 10h
mov bx,100
mov cx,100
hiero:
mov dx,0a000h
mov es,dx
mov ax,320
mul cx
add ax,bx
mov di,ax
mov al,2
stosb
inc bx
inc bx
inc cx
cmp bx,150
jnz hiero
mov ah,8
int 21h
mov ax,3
int 10h
MOV AX,4C00h
INT 21h
code ends
end start
While playing with MuseScore…. (Typesetting some scores for Pipes and Flute)
This came in: WOOOT
Trident 8900C (1024 x768 max 512Kb)
This is a Trident VGA card. While having a 16bit ISA connector, it can work in a 8bits ISA slot.
A while ago i bought a Laser XT/3, that’s the one my parents had. This is where i did a lot of assembly programming on. It’s a 8086 cpu, 640K and has a Hercules/CGA graphics card.
I found loads of assembly files and i want to see if i can get it running again. While some code was written for hercules, ( That’s the monochrome image you see in the example above ) and a few for EGA (4 colors).
Most of it was written for VGA. Probably on a later machine like a 80386?
But i know there are vga cards for 8 bit msdos computers, and i found one. ( This one is even autodetect, so no jumpers to figure out)
So i’ve put this card in the machine, turned it on, and it works! I’ve got only 2 examples living on the harddisk of the machine, both black and white … 🙂 I have to search for interesting code in hundreds of files.
Some friends of mine, picture was taken from an amiga genlock digitizerThe intro pages of a “amiga emulator” WHERE is the rest??? (end is a cga starfield demo)
And a boot demo, which was able to start from a bootsector, went into a graphic mode and ran a demo with sound. Edk wrote a sector loader for this. I have some 5.25 inch floppy disks, labelled boot demo. So i wanted to try this today … I needed to change the boot order, so i went online to search for jumper settings.
I see a led when it tries to boot, but my disks are probably formatted 720Kb instead of 360Kb, which this drive is.
So …. TODO!
Find a 720Kb floppy drive (5.25 inch), and sort through my code! There is a 8bit soundblaster compatible soundcard that i bidding on online, hopefully i’ll get it
Assembly and modes
I wasn’t sure how to sort the assembly code into Hercules and VGA compatible, but i used this table (There are also extended modes for higher resolutions)
mode 0x00
text 40×25 gray
mode 0x01
text 40×25 16 colors
mode 0x02
text 80×25
mode 0x03
text 80×25 16 color
mode 0x04
graphics mode (CGA) 320×200
mode 0x05
graphics mode (CGA) 320×200
mode 0x06
graphics mode (CGA) 640×200 (B/W)
mode 0x07
text 80×25 Hercules
mode 0x0F
graphics mode 640×350? gray
mode 0x10
graphics mode 640×350?
mode 0x11
graphics vga 2 colors
mode 0x12
graphics vga 16 colors
mode 0x13
graphics 320×200 256 colors
# Set VGA mode
mov ax,13h
int 10h ;screen 320x200 256 colours
# Exit VGA mode
mov ax,3
int 10h ;screen 80x25 text
mov ax,4c00h
int 21h ;back to DOS
"If something is worth doing, it's worth overdoing."