Just for fun...
This Bash-Script-Add-On uses the MiSTer's i2c Interface on the DE10-Nano
to drive a small SSD1306 OLED Display with 128x64 Pixel showing (currently only) Pictures based on the running core.
Antonio Villena build IOBoards with such small OLED Displays and asked for support, so here we are ๐
This Add-On uses the MiSTer's i2c Bus. Wrong usage can confuse the MiSTer's i2c Bus or worse!
You need to make sure you use the right i2c Bus as the MiSTer has more than one.
Use the command i2cdetect -l
for detecting the correct i2c-Bus
and i2cdetect [I2CBUS]
for detecting the correct i2c Address of your Display, normally 0x3C (Hex).
On my new DE10-Nano (LOT#0521) the correct I2CBUS Number is 2,
on my older DE10-Nano (LOT#0519) the correct I2CBUS Number is 1 also 2 (just checked).
Normally you get an error message if you try to run i2cdetect
on the wrong Bus.
- An DE10-Nano Board
- An i2c breakout (RTC Boards or IOBoards from Antonio Villena with builtin OLED's)
The i2c/SPI Header of the official RTC 1.3 Board has no Power Pin, only Data and GND if I am right.
Means you have to get the 3.3v Power from another Pin on the Board.
I was sponsored by Antonio Villena with (t)his RTC which has solder Pins for i2c and 3.3v power. - An i2c SSD1306 OLED
When the MiSTer boots up the script /etc/init.d/S60i2c2oled
is called.
This script does nothing more than calling the script /usr/bin/i2c2oled.sh
and sent it to the background, but only if /usr/bin/i2c2oled.sh
is found and is executable.
The Script /usr/bin/i2c2oled.sh
uses the Linux source
command to load the Picture Data from file if the core has changed.
The Script uses the i2c command i2cset
to initialize the Display and calculates the needed values
out of the loaded Picture Data and send these values via i2c to the Display.
The used Black&White Pictures are slightly modfied X-PixMap (XPM) Pictures with 128x64 Pixel.
You can create X-PixMap Pictures with Gimp.
After you created the Black&White X-PixMap Picture open it with an Text Editor, I use Notepad++, and...
๐ ๏ธ Use the new XPMtoPIX conversion tool (need .NET Core Framework 3.1+) by MickGyver, many thanks.
or do manually
- Switch to Linux Line Ending (LineFeed only)
- Remove all text lines until the first Data Line which should contain a lot Dot's "." and Spaces like
"... . . . "
- Add
#!/bin/bash
as the new first line - Add
logo=(
before the first " (double quote) so it should look likelogo=("
- Replace all Dot's "." with the Number "0"
- Replace all Spaces " " with the Number "1"
- Replace the ending
};
with)
- The filename must be the same as the name of the core plus
.pix
as extension
Example: Corename = C64, Filename = C64.pix - Upload the File(s) to
/media/fat/i2c2oled_pix/
on MiSTer - Have fun ๐
Double check the files in https://github.com/venice1200/MiSTer_i2c2oled/tree/main/Pictures/Pix for correct modification.
>> Make you PIX available for others uploading them zipped to the forum-thread or use an pull-request here <<
File/Folder | Description |
---|---|
S60i2c2oled [1] | Starter Script, must be placed in folder /etc/init.d/ on MiSTer |
i2c2oled [1] | Communication Script, must be placed in folder /usr/bin/ on MiSTer |
Pictures | Just Pictures |
Pictures/Pix | modded X-PixMap Pictures, must be placed in folder /media/fat/i2c2oled_pix/ on MiSTer |
Notes
[1]
Do not forget to make the two Scripts executable after copying them to the MiSTer.
Use chmod +x [scriptname]
for this.
sorgelig for his MiSTer
https://github.com/MiSTer-devel
Antonio Villena for his RTC Board with i2c connector
https://www.antoniovillena.es
MickGyver for his XPMtoPIX conversion Tool
https://github.com/MickGyver
The following website
https://stackoverflow.com/questions/42980922/which-commands-do-i-have-to-use-ssd1306-over-i%C2%B2c
for pointing me into the right direction.
MiSTer on Github: https://github.com/MiSTer-devel
MiSTer Forum: https://misterfpga.org
Add-On Thread : https://misterfpga.org/viewtopic.php?f=9&t=2476