2018-12-28

Amazing

Around 18 months ago I made a Russian Doll Puzzle Box on thingiverse. This was after initially doing a simple two part box. The idea was pretty simple - the box has a maze on it, so the lid has to be moved around the maze to close or open the box.

It is surprisingly popular, with over 150,000* views on thingiverse and no idea how many from my site that makes the random versions on the fly.


The original code was almost all done in OpenSCAD, with a small bit of C code to create a random maze and set the various parameters used by the OpenSCAD script. It worked, but rendering the OpenSCAD was quite slow.

This Christmas I thought I would have a bit of fun re-doing it. There have been various requests and suggestions since the original design was posted. So I have incorporated a lot of those. The big one was having the maze on the inside of the box so making it way harder to solve! I have also added a helical option, and ability to emboss an initial on the ends of the box.

I decided to take a new approach. Instead of designing in OpenSCAD, I designed it all in C code, making OpenSCAD from scratch from the C. This is only subtly different, and it uses OpenSCAD to carve the maze from a cylinder in much the same way as before - just more of a long list of functions generated by C code rather than iterative OpenSCAD script. This worked, after a lot of tinkering, and after a couple of days I had a whole new set of test mazes. There are loads of tweaks once you print something for real on a 3D printer, and that takes a lot of time, so the test cycle is slow...

Last night I ended up re-writing a whole chunk of it in my sleep! Today I coded the changes, and it works. The change was simple in concept - instead of using OpenSCAD to carve shapes from a cylinder, I would construct a polyhedron from scratch in the C code to make the maze surface.

This was not as easy as it was in my sleep as I learned a bit about manifold polyhedrons, but it works. It makes the OpenSCAD unreadable as it is a huge list of 3D points and faces.

The end result is a much neater maze, and it is away quicker. The most complex test I had was taking OpenSCAD over an hour to convert to STL, but the new version is just over a minute, and most tests are a few seconds.


The other big difference is I have also released the C code on github. Enjoy.

See https://www.me.uk/puzzlebox for a custom maze SCAD.

P.S. Updated many times since I started on Christmas day. Always one extra tweak :-)

*I do not trust the download count - the file download count goes up way faster, so even counting "download all" as one download it is way off, and there are 50 files. It seems someone downloads every minute or two, and just as many access my web site to make custom mazes - amazing!

P.P.S. One more tweak - I added a mode to alternate "inside" and "outside" maze :-


P.P.P.S. One of the things I have done in this case (as you can see from the source) is make use of popt more than usual. Apart from just using as command line arguments, the same structure is then used to parse QUERY_STRING args, generate the comments in the header of the output, and even generate a web form. This means I can add new options in one place and not repeat myself.

P.P.P.P.S. I worked out a way to make the maze more challenging: The maze is drawn by a path from a point, taking random turns (with some bias) and back tracking when no options. I have now made it run multiple paths from the starting point concurrently so that there should be multiple reasonably long paths from that point, all but one of which will ultimately be a dead end.

2018-12-24

Meaning of an Amazon Christmas?

I heard that Coca Cola managed to get the red coat on Santa due to advertising in the 30s - though wikipedia suggests not quite that (here).

It seems odd in many ways quite how quickly "tradition" changes, and when you have a tradition you assume it has been the case for all time. Basically, anything that was the way it is before you were born, and even more so, before your parents were born, has always been so...

The history (assuming this video is correct) is quite crazy, in fact...



So I was pondering where it will end up in another generation or two. Even if Coca Cola did not have as much influence as it seems, I can see how a large company may want to create a change in "tradition" for its own ends.

It probably just takes a book, or more likely a book and a film and maybe a theme park, to change a tradition. So what could come next?

My guess is Amazon do something where Santa's "North Pole" operation is actually an Amazon fulfilment centre. After all, under the brown paper wrapping, almost (not quite) all of the presents I have wrapped are then in Amazon boxes (some even unopened, just wrapped up when they arrived). And some that did not arrive in Amazon boxes have then been put in spare Amazon boxes as easier to wrap.


As I mentioned in an earlier post, unusually, I have ended up buying more presents this year, and a part of that is the ease of buying from Amazon. Several presents have been a result of a passing comment over coffee and I whip out my phone and quietly order the very thing my wife, or someone else, wants, even for delivery Christmas Eve!

P.S. Merry Christmas or other holiday to which you are looking forward, and have a happy Gregorian calendar new year.

2018-12-18

Is my LG TV haunted?

A few days ago my TV announced it had new s/w to download, so I let it do its thing and upgrade.

Maybe that was a mistake. Yesterday I came in to my man-cave and the TV was on, no signal. That is odd for two reasons: (a) I turned it off the night before, and (b) it turns off after a while with no signal (or used to).

I assumed I was being silly. But this morning the same, and I was suspicious.

Later during the day I popped out today for a coffee, and I definitely turned the TV off when leaving. My wife saw me do it - I am not going crazy. When I came back, there it is, on, no signal.

So I did a test - I turned off the TV.

It turns itself back on!

It also turns on the (connected) Apple TV (as I would expect), and after a while the Apple TV goes off leaving the TV on with no signal. It stays on!

I can only assume this is LG's latest "burn up your OLED pixels quickly" software update. I can't think of any other reason they would do this. Very annoying. Not quite sure what to do - the power socket is an option, but annoyingly all hidden behind the cabinet, and rather tedious to say the least.

FYI I went in to menus and it has "turn on by WiFi" and "turn on by bluetooth", both of which I have disabled, but no different.




P.S. Disabling the simlink stuff "fixes" it, but why was it suddenly broken. It was fine before. Arrrg!

Game Over for Stargate playing cards

I am really sorry to have to admit defeat.

After a lot of work on this, and a lot of obstacles, I believe it is impossible to get a licence from MGM. Whilst their contract has a number of issues, by far the most problematic is that in order to purchase a licence from them, they require me to assign all copyright in my product to them. No, they don't pay me for that! If this seems backwards to you, you are not alone.

I made it clear from the start that the designs included some creative commons work - so they knew it would never work all along. Even if that could be solved by a lot of re-design, it would mean rights in my playing cards designs assigned to them - which means all the other playing cards I have made being theirs - so I'd need to buy a licence to use those (even though I designed them!). This is not, in my view, how copyright is meant to work!

Anyway, this is the video I made earlier. I have not had any further reply from the licensing people, which I can only take as confirmation of my understanding. A bit rude to just ignore me, but seems to be typical of all of the interactions I have had on this. Shame.

I went to Cal Mah, and sadly there was not much merchandise using MGM copyright material (apart from "Stargate Command" stuff which I believe is MGM) - now I know why.

Sorry for getting anyone's hopes up. I'll be removing the Alteran Bridge Club pages, etc.

2018-12-15

Another new toy

I have posted before, saying I am trying to lose weight, and things have been going slow and steady. Thanks for all the feedback and advice.

With the weather getting worse the "walking" had somewhat stopped, which was a slight issue.

I now have a treadmill! It means I can walk and walk and walk and still be in front of the TV. It goes quite well with my new watch setting goals for daily activity.

Weight loss is once again happening. Yay!

P.S. The watch is still going


2018-12-12

Ho Ho Ho!

My wife usually manages most of the Christmas presents, but this year I have got a few.

It all started with seeing something and thinking "Oh, Lewis would like that", or "Oh, Bobby would like that". Before I knew it I had a few things stacked up for grandchildren and then something for my children.

Of course, with two more grandchildren, next year is going to get even more complicated.

I hope they like the wrapping paper :-)

2018-12-08

New watch

I got myself an early present. A new watch. To be honest, there was nothing wrong with my old one - it never needed charging (solar) and had radio clock so always accurate.

However, I saw this new watch and thought it was at last a vaguely "smart" watch that does not need charging.

I told myself I was not getting a "smart watch" until there was one that did not need charging. I had a Garmin one once, and it needed charging every night and I hated that.

My son, quite sensibly, berated me for buying anything off a Facebook advert on the basis that they are all scams (and sadly, one other thing I bought was a scam and I am waiting to get £40 back from Amex for that). However, to my surprise the watch does not seem to be a scam!


It's a Matrix Power Watch, waterproof, and to my surprise thermally powered! It links to my phone via bluetooth and does calories, steps, distance (how?), and sleep tracking. It has an e-ink type display. It actually has a choice of watch face display, and I hope they add more choices later as I'd rather see one like the above but with larger date and day of week rather than "REALTIME POWER" which is pointless being on the display. It even has a back light!

Also, the strap was crap (in my view), but it is a standard 24mm fitting, so I was able to get a nice metal black strap from Amazon, which is (in my view) much nicer.

So now I am doing the whole "completing the circles" thing, with a new treadmill (another new toy), and trying to get fit :-)

It will be interesting to see how it goes.

I am, however, of the view that these devices are really crap at even counting steps, let alone distance. But if it is consistent itself that will still help ensure I keep up the exercise.

Update: Yeh, it has odd ideas, like 500 steps already when I got up this morning (I don't sleep walk).

Update: After several weeks using it, very few quirks, it actually works, and it its counting steps sensibly it seems. Later s/w is nicer.

2018-12-04

Scripted font generation using fontforge

This is my first attempt at making fonts using scripts... Well, apart from a digits only font, it is my first attempt to make any font! It seemed like a good use of a Sunday afternoon :-)

The plan was to make some fonts based on classic 5x9 dot matrix characters. Not a huge challenge you may think - but I did not want to spend ages positioning dots in a graphical user interface. So I ended up making some C code, that produces SVG for each character and then Python script to use fontforge to make a font from the SVG.

My 5x9 characters are defined in the C code using hex.

   {"A", {{0x20, 0x50, 0x88, 0x88, 0xF8, 0x88, 0x88}}},

That defines the capital A to look like :-
My C code makes an SVG that looks like :-

<?xml version="1.0" encoding="UTF-8">
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="816" height="1024">
   <g>
      <circle cx="255" cy="51" r="40"/>
      <circle cx="153" cy="153" r="40"/>
      <circle cx="357" cy="153" r="40"/>
      <circle cx="51" cy="255" r="40"/>
      <circle cx="459" cy="255" r="40"/>
      <circle cx="51" cy="357" r="40"/>
      <circle cx="459" cy="357" r="40"/>
      <circle cx="51" cy="459" r="40"/>
      <circle cx="153" cy="459" r="40"/>
      <circle cx="255" cy="459" r="40"/>
      <circle cx="357" cy="459" r="40"/>
      <circle cx="459" cy="459" r="40"/>
      <circle cx="51" cy="561" r="40"/>
      <circle cx="459" cy="561" r="40"/>
      <circle cx="51" cy="663" r="40"/>
      <circle cx="459" cy="663" r="40"/>
   </g>
</svg>

Which, as you can see was simple enough.

I also make a Python script (from the C code) along the lines of :-

#!/usr/bin/python
import psMat
import fontforge
f=fontforge.font()
f.version="1.0"
f.encoding="unicodeFull"
f.copyright="Adrian Kennard"
f.weight="Regular"
f.familyname="FiveByNineLED"
f.fontname="FiveByNineLED-Regular"
f.fullname="FiveByNineLED Regular"
f.em=1024
f.ascent=714
f.descent=310

Which has for that letters :-

g=f.createMappedChar("u0041")
g.width=612
g.importOutlines("u0041.svg")
g.removeOverlap()
g.simplify()
g.autoHint()

And finally saves :-

f.generate("FiveByNineLED-Regular.ttf")

Simple enough :-)

As you might guess, I was not going to just make a font as simple as that. For a start it was sensible to make some different weights and an italic variant.

For different weights, I just changed the size of the dots :-


For italic I simply adjusted the position of the dots, and told the font it was italic. I picked 10 degrees.


But that was not all. A simple dotty font looked nice but I felt I could do me. You will note I called this "LED" on the basis that it looks like a simple array of round LEDs as seen on railway stations and many such signs.

But what of LCD. For this I made squares.


For bold I actually made the squares touch, and the overlap removal in fontforge creates an outline of the joined up squares.

However, to make an italic version I could not simply move the positions as I did for the LED version as that creates a staggered row of squares. Instead I had to skew the whole glyph.

My first thought was to simply put an transform="skew(-10)" in the SVG. That worked, but there are limits to what the SVG import will do on fontforge it seems. Combinations of translations on individual components and a group object with a skew did not quite work as expected. I had to make the SVG very simple. Later, with some overlapping rectangles I actually managed to not just make errors from fontforge but segfault it! So I ended up doing the skew in the python!

g.transform(psMat.skew(0.174528))

That seemed to work well for this...


But I could do more... What about the way these fonts looked on an old fashioned CRT? So I made a CRT version which joined the dots horizontally with rectangles.


But there's more. This is something I did in something like 1981 when making a printer driver for a spark jet printer that could screen print BBC Micro MODE7 but not look like crap. Back then I created 45 degree lines joining octagonal dots. This works well for most letters.


But some needed help, notably where a diagonal joins a horizontal or vertical line, I would create a right angle not a diagonal. The fix was making a second "layer" of the bit map. For LED and LCD and CRT this did not matter, a dot was a dot, but for this JTD (Join The Dots) mode, it was needed to allow for things like the diagonal of an R to work...


This was another case which was a challenge. I originally planned on using an SVG path to join the dots, but that did not work. The import messed up the translations somehow, and then the overlap removal in fontforge just did not work. By simply creating a rectangle to join each circle, that worked, even the 45 degree ones, until I tried to apply a skew at the SVG level and that got very upset. A skew applied at the phython stage worked. Oddly the 45 degree ones are still making warnings but creating clean glyphs, so close enough.

Creating a simple ASCII character set was not hard. But these days we need a bit more, and so I went through the extended latin and did a lot of them (that I could sensibly work in a 5x9 matrix). I am sure there are more I can add. Thanks to Ray for pointing me to the SAA5050 data sheet with additional characters. So far over 400 characters, and more may be added over time.



The accents all look a lot better in the join-the-dots version as I could make the joins allow for the accents and not stick the accent to the letter in an odd way...


P.S. In honour of a previous blog post...



P.P.S. the "TXT" version is an attempt to mimic the Mullard SAA5050 character rounding logic.

So this is the result (may be updated from time to time if I add more characters) :-

FiveByNineCRT-BoldItalic.ttf
FiveByNineCRT-Bold.ttf
FiveByNineCRT-LightItalic.ttf
FiveByNineCRT-Light.ttf
FiveByNineCRT-RegularItalic.ttf
FiveByNineCRT-Regular.ttf
FiveByNineJTD-BoldItalic.ttf
FiveByNineJTD-Bold.ttf
FiveByNineJTD-LightItalic.ttf
FiveByNineJTD-Light.ttf
FiveByNineJTD-RegularItalic.ttf
FiveByNineJTD-Regular.ttf
FiveByNineLCD-BoldItalic.ttf
FiveByNineLCD-Bold.ttf
FiveByNineLCD-LightItalic.ttf
FiveByNineLCD-Light.ttf
FiveByNineLCD-RegularItalic.ttf
FiveByNineLCD-Regular.ttf
FiveByNineLED-BoldItalic.ttf
FiveByNineLED-Bold.ttf
FiveByNineLED-LightItalic.ttf
FiveByNineLED-Light.ttf
FiveByNineLED-RegularItalic.ttf
FiveByNineLED-Regular.ttf
FiveByNineTXT-BoldItalic.ttf
FiveByNineTXT-Bold.ttf
FiveByNineTXT-LightItalic.ttf
FiveByNineTXT-Light.ttf
FiveByNineTXT-RegularItalic.ttf
FiveByNineTXT-Regular.ttf

I²S

I²S is, err, fun. What is I²S Well, first off, it is grammatically like I²C which is an acronym with two Is in it which people then treat an...