Saturday, March 30, 2013

Time for a Change

I've been rolling out new iz2jffs5 updates at a fairly rapid pace for two weeks now, so I figured maybe it was time for a change of pace.

So I checked the todo list, double checked it, and decided to finally do something about that flipclock app that's been languishing there for quite a while now.  The first thing I had to do was track down the problem with the display.  It was way too flickery to leave on all night.  I tried it once and it drove me nuts.  So I reorganized the code a bit to give the SDL software double buffering a chance to do it's thing.  Now I can leave it running without fearing for my sanity.

After spending all that quality time in the code I finally felt more confident adding some command line options to do various messaging functions in the blank space below the actual clock.
It's now got 4 lines of text using the png font file that I borrowed from slug's gmenu2x a while back.  I could've fit 5 lines, but it seemed kinda tight.  So far I've got code to put up simple static messages, strftime formatted time and date messages, and messages that can be updated on the fly by polling a file.  I'm planning to use that one someday to feed it a real live weather report.  It integrates pretty well with the iz2jffs alarm script so I included a sample implementation of that too.  Here's the usage message to give you some idea how I intend to use it.


Usage:  fc [-1|-2|-3|-4][D|f][w|d] [message|file|timeformat]

Displays a flipclock and up to 4 lines of text messages underneath.

  f = Display message from a file.  Updates whenever the file does.
  D = Display the date/time by passing timeformat through strftime().
      Line 3 defaults to a date using "%b %d, %Y  -  %l:%M %p".
  w = white text (default = grey)
  d = darker grey text.

eg:  fc -1d "Nice weather." -2D "%b %d, %Y" -3 "" -4 "Wake at 7 AM"


This should work on either IZ2S or the iz2jffs, although I haven't yet tested the alarm script in the bash shell on IZ2S.
fc-iz2jffs.zip

Source code:
fc-iz2s-src.zip

I'd still like to see if I can get it to use the gmu font files in addition to sfont files and the modified gmenu2x sfont file.  I suspect gmu uses only fixed width fonts because the fonts lack the "magic pink" spacers on the top image line.

Update:

I added a -t option for 24hr time in the main clock display, and -p for padding the upper hour digit with a zero for folks who need to see 4 digits all the time.  I also experimented with various options for the  date string to see what could be done with that.  Here I tried it with a bigger message font and this command for an ISO 8601 date with 24 Hour time.

   fc -tp -3w "%F - %R %p"

I forgot sfont files can come in colors, so I think I probably need to change the w option to b for bold and remove all mention of grey from the usage message.  I'll package up a new executable and the code real soon now, depending on how far I get with the gmu font file.  Here's what that looks like so far.  I added a -w<size> option just in case it can't figure out the font width from the png image size.


I have to say, I definitely prefer the layout of the GMU font file to the gmenu2x "sfontplus" file.  The GMU font files are quite small because they use fixed width characters.  The magic pink spacers don't seem to compress so well in the sfont files.  But what I really like about the GMU file is that it's a simple 256 character latin1 font, which works quite well with the latin15 setup of the iz2jffs.  The gmenu2x sfontplus file has the glyph order scrambled all willy-nilly.  Who came up with that?  If I ever do get back to working with the openwrt-zipit version of the gmenu2x code, the first thing I'm gonna do is re-order the glyphs in the font file.  It's unicode so I'll just put them in unicode standard order with the gaps for missing characters compressed.

Now if only I could convince gimp or mtpaint to generate a decent png font file, I'd be all set with the flipclock app.

Maybe this microfontmaker thing will do it for me?  I just gotta find me a PC that still has java on it.

Or maybe I can hack the code from that tiny sdl font previewer to save a png file.

Or use one of the many Windows texture font makers like bmfont.  Something's gotta work.

Or maybe I should just come to terms with the fact that libfreetype and libSDL_ttf actually fit on the jffs with plenty of room to spare.  I really should be using ttf fonts for everything.  In fact, the best change I could make to the jffs would be to chop the huge png font outta links and replace it with some nice ttf fonts that all the apps can use.  I really need to take another look at that plan9 ttf version of links...

Update 2:

I managed to modify the dingux gmenu2x font generator program gen_sfont_image.py to create a latin1 png font instead with gen_sfont_latin.py.  I used it to create an sfont file with the same latin1 glyph order as the gmu font file, except this one uses a proportional spaced 15 point DejaVuSansCondensed font. The file is a bit larger than I'd like so maybe the gmu font makes more sense for the jffs.  I might do some more experiments generating fonts, but more likely I'll start converting the flipclock to use a ttf font.  Heck, even the tiny imgv program uses the ttf font.

I did a quick latin test on puppy linux and it seems to work, maybe.
Here's the new flipclock release.
fc3-iz2jffs.zip

Source code:
fc3-iz2jffs-src.zip


Meanwhile, since I'm still waffling over then benefits and drawbacks of libfreetype I should probably mention stb_truetype.h over at http://nothings.org.  It replaces libfreetype with a small C header file.  You give up some quality (hinting) and performance for the tiny size but you also lose the dependency on the huge shared lib.  I probably can't use it on the zipit because I really want the hints for the smaller fonts.  But I'm gonna have to try it.  And some of the other code there too.

3 comments:

  1. Bonjour,
    It will be uneasy to frencheese this clock !
    Is there a way to make it display time with 0-24 ?
    Do you know the old BSD calendar ?
    http://sourceforge.net/projects/bsdcalendar/files/
    If you roll a new iz2jffs5, can you add this small
    http://prototypeur.free.fr/cosmetic.zip ?

    ReplyDelete
  2. I knew I forgot something. I'll add a 24 hour clock option, and if possible I'll try to make the command line setting for that match the one from the ttyclock. I'll also add the Black Gloss gmenu2x skin and take a look at the BSD calendar.

    ReplyDelete
  3. I compiled the bsd calendar program, but haven't yet had a chance to see if it runs on the zipit.
    I put it here (otherwise I might lose track of it).
    http://www.datafilehost.com/download-057be4ab.html

    ReplyDelete