Some months ago, my 6 year old son discovered Minecraft. His sister and I soon followed. It’s a great game and there’s a ton of good content out there about it. Reddit and forums are active. it has an excellent wiki, and lots of YouTube stuff. Not surprising given how popular the game is.
One topic that is covered a bunch is how to best mine for diamonds. The thing is that beyond a graph of diamonds by layer, I don’t really see any data involved.
In this post, I talk about how I parsed a Minecraft Bedrock world database to get some more numbers. Topics include:
Pictures of some fun situations and overall distributions.
Some numbers concerning the densities/distributions diamond, other uncommon ores and spawners.
How to parse the data yourself.
Mojang/Microsoft has released their variant of Google’s leveldb, but it doesn’t compile out of the box and it doesn’t come with a reference parser.
The wiki is very helpful but I find that actual code samples tell me more.
A big caveat…
This post mentions data from only one Bedrock world which hasn’t been traveled much. The seed is “-1337710146”. I don’t remember where I got it but it was from a YouTube video.
I’ve recently spent a bunch of time organizing a pile of picture files in various directories. This post is about some of the utilities I’ve found more useful.
I want this structure:
│ └── 31
│ ├── 2012-01-30_17-26-35_65.jpg
│ └── 2012-01-30_17-26-39_533.jpg
│ └── 13
│ └── 2012-02-13_15-37-29_814.jpg
I often have this structure:
if you files have create date stamps in the picture files, this command is the best option:
# Create Date : 2018:04:22 16:05:54
exiftool ‘-Directory<CreateDate’ -d %Y/%m/%d -r
This will set a file’s directory to reflect the CreateDate property. If there’s no such property, exiftool will do nothing.
Remove empty directories
After the “best option”, you may end up with empty directories.
find . -type d -empty -delete
fdupes -rdN <dir>+
This will keep the “first” of a set of copies and remove the rest. I’ve found it difficult to predict which will be first. I understand it’s by name but it often seems not to. Be careful for the situation where one copy is in a directory that tells you the date and another that perhaps isn’t.…
regview is a gdb based utility for viewing control register state. ADC, DMA, RCC,… I use it to view STM32 registers
I am not the original author, but I needed some additional features. In particular, the ability to save and compare states from two sessions. I had a reference prototype that worked and some code of my own that didn’t. Compare register states between the two helped me move forward.
I’ve found the shapely library to be a very helpful way to manipulate polygon data.
Here’s a pair of short video tutorials with some of the basics of using the package.
The code that I walk through can be found here.
In this blog, I focus on programming stuff, but I also have an interest in CNC machines.
I’ve tried a lot of different kinda of linear motion systems and I thought I’d share some of the things I’ve learned.
I recently had the need to parse vector paths from an svg file generated by inkscape. I wanted to convert some graphics into kicad zones and/or boundaries. So I drew some stuff in inkscape and looked at the resulting svg file. Didn’t look so hard to parse.
Turns out there are a fair number of details to consider:
The path format itself. relative and absolute coordinates, closing polygons…
Transformation matrices embedded in the svg.
Global coordinate space. I want the graphics to be a specific size on my PCB.
Polygons can have holes. Inkscape doesn’t associate them for you. It doesn’t tell you which polys are boundaries and which are holes
You can find the python code I came up with here. It implements the svg parsing functions that I needed to turn this in inkscape:
Into this in kicad
This post only talks about the svg stuff. For the kicad side of things, go to my kicad.mmccoo.com blog
The basic path
There are lots of online descriptions of svg paths. Like this one. The basics:
<path d="m 280.53386,834.58414 0,91.42158 z m 18.65215,23.8483 31.17691,0 z" />
A path is stored in the ‘d’ attribute of a path node
In this post, I talk mostly about displaying to graphics devices. One of those devices uses I2C interface, which I haven’t talked about in previous posts, so using I2C is an important topic I cover as well. I2C is a common communications protocol for talking to peripheral devices. Temperature sensors, memories,… anything.
As always, working code can be found in my github. I use the u8g2 library and most of the other code is STMCube generated. The interesting stuff I wrote to put it together is in main.c.
What parts will I be using?
stm32f103c8t6 board (<$2)
I2C OLED display based on SSD1306 (~$2.50)
SPI OLED display ($2.50). If buying on aliexpress, make sure the picture shows 7 pin connections. If you see only 4, it’s the I2C variant. They put SPI in the title, since the underlying hardware supports SPI.
Nokia 5110 display ($2). Bigger display, not as bright, lower resolution, but still very nice.
MAX7219 based 8 digit seven segment display ($1.25)
A logic analyzer module is helpful for getting things to work (~$5). I used this in my previous post.
Edit Jan 30, 2018: fix udev permissions commands. updated firmware commands
In my previous posts of this series, I’ve gone from nothing to programming the stm32f103c8t6 to blink and interact with a terminal window. I’ve covered: