Wednesday, 21 November 2018

A clock, for my desk, revisited…

So, back when I was a wee kid, I wanted to make the obligatory LED clock — back then, it wasn't ųC's, it was decade counters and 7400 series logic gates.  Never did actually make it, though…  So when I got my first Arduino, the desk clock (with a few extras) was the first thing I made after the obligatory learn-to-Arduino style Blinky.  But as I mentioned in an earlier post, it died a sad, sad, death.

I've done my non-Arduino Blinky, too, nice little (7)555 on a board, got me a taste of KiCad and SMT.  Now it's time to resurrect my DeskClock project; this time, I'm planning to make it an Arduino shield, much the same as before, but with an actual real time clock module thrown in for bonus points.  (Next version, I think, will be an all-in-one, maybe I'll add a buzzer there for an alarm option, maybe the external temperature sensor I was considering adding also, so many things…)

Now, onto the project.  So I've got me that nice blue 4-digit 7-segment clock display, and a simple MAX7219 display driver.  The driver's not really what I want, I want (at least) per-digit brightness, the 7219 only does global brightness, but it's what I've got, so I'm going to see if I can make it do what I want, see if I can flip the digits on and off quick enough to pretend.  Though from an initial poke, I gotta say I'm a little dubious…  Still, current step is to get the display running, then try it and see.  But there appears to be a small problem, it seems my common-cathode display, mayhaps isn't.  Started with a simple library and demo program on the Arduino, with just the MAX7219 and the display wired up, and nada.  Well, not exactly nada, all the digits were on, all the time.  Seems kind of obvious now, but after poking at it for a bit, and verifying that the program is spitting out the data it's supposed to be, I think my common-cathode display might actually be a common-anode one, or if I'm lucky, perhaps the documentation I found just has the anodes and cathodes backwards — I would have noticed that when I was building my clock the first time around, but I was just experimenting and playing with it at the time, and wasn't particularly keeping notes.  (This is why project diaries are good — they save you from wasting time later on.)

(… later …)

Well, it turns out the display is indeed common-anode.  Still, that wasn't going to stop me.  A little confusing wiring, and some tricky coding to transpose the bits, and it's displaying digits just fine — little annoying I can't use the display trim to render just the four digits, but it works just fine.  Added an RTC module (so it doesn't slip a minute a day like it used to), and stepped it up to two buttons this time, and it's been running quite happily on my shelf for the past couple months.

(… much later …)

Its RTC module is still holding time just fine, though it's hard to read the digits through the tangle of breadboard wires, so it's been sitting there running, but mostly neglected — the interface connected to those buttons is still mostly undone.  Well, I've finally decided to push it along again.  I've got a spare EtherTen board, and that clock has a temperature sensor stranded on the device and not available to my growing room automation system … I'm sure you know where that's leading.

However, that does change the plan a bit.  I'm not quite to the point of designing PCB's with Ethernet just yet, so I've designed a PCB version of the circuit as an Arduino shield, parts and board (finally) ordered, just waiting for it all to arrive.  It also raises a fresh problem; my prior little project, very quickly exhausted the ATmega328P's (the chip at the heard of the Arduino Uno) rather meagre code and data resources — so I'm not at all confident that after dropping in the Ethernet library, there'll be enough room left for everything else, and I'm certain it won't fit an NTP client on top.  I'm fully expecting it'll fit the basic clock and temperature functions, but I may need to off-load the menu's with their settings — on the upside, since I never designed a buzzer into the PCB, I'll just have to implement the alarm by having a Raspberry Pi play an audio clip.

(… to be continued …)

Sunday, 4 February 2018

Bootstrapping another sojourn in web-design land…

It happens that the government of Australia decided to enforce plain packaging on smoking products, and even more frustratingly, to in some cases, also hide the prices of said products from the consumer (or maybe that's just the individual shop)…  And while I'm not a smoker, I rather frequently found myself purchasing smoking products, and keeping track of the current cheapest pack was a constant nightmare, especially with it often being cheaper to buy two half-sized packs, and such.

So what did I do?  I built myself a web application in Google App Engine to make the job easier.  It lets me track the prices of various sized packets in my favourite store, prompting me to enquire about the current price of packets I haven't checked in a while, and offering the ability to quickly discern how best to obtain either the most smokes for a given sum of money, or spend the least money for a given number of smokes.  And it worked very well indeed…

… but it was so hideous!!!  It was built around a fairly basic HTML and CSS template I'd put together myself for an earlier project, and my CSS skills, well, they're not the best.  And viewing it on a phone — as I typically was while at the shop counter where I needed it — was, interesting; zooming out to see the page, then zooming in to select a field or press a button, back and forth a couple times.  It was still fantastically useful; though you still needed to ask at the counter, just to make sure there wasn't a new option you didn't yet know about, particularly when faced with someone who wasn't familiar with the various smoking products on offer (which was rather often in my favourite supermarket), it would often beat their suggestion.

In any case, that was what spurred me into investigating responsive web design.  At first, I wanted to learn to do it myself — of course — but, well, it's nasty.  (Even nastier than my still-in-the-1990's web page designs.)  So I started looking at toolkits instead, and ran across Bootstrap — I'd heard of it before, and it was coming up in my searches as seemingly fairly popular (they certainly think so, too…!), so I decided to take a look.  Unfortunately for the smoking app that started this, I was no longer needing to purchase smokes by this point, so though I'll probably have to dig into it again when I start Bootstrap-ifying the template it's built from — it's going to need some fairly radical changes to it's UI, and I can't see that happening — so I'll probably just be giving it a flattened copy of its present template and leave it on ice, while everything else on that branch of the site moves on into the 2010's, finally.

So, I wanted to learn Bootstrap, but the smoking app wasn't the place — in fact, it's not even a particularly pleasant memory, those damn cancer sticks are getting horribly expensive, and at an increasingly alarming rate — so what to do…  Ah huh!  Light bulb moment!  Time to breath some new life into my old 1990's style homepage…!  (It's also on a branch of the GAE site which holds a couple "learn to GAE" tutorial examples, and doesn't have any existing templates.)  And so it was reborn (and probably isn't yet finished being reborn), with a fancy new Bootstrap interface — presently in the guise of something kind of sort of resembling part of a resume … with a link to this blog … do I really want this blog on my resume … ?  (On the other hand, if you've been following the various links in this post, you may have noticed my "homepage" has some minor variations, depending on exactly what name you reach it by…)

Now at the end of all this, what do I think…?  Bootstrap is rather nice.  It's not too invasive, and the great majority of it works just fine without any scripting at all — though I did finally give in and add the JavaScript components, so I could add a couple little tooltips in one section, and if it ever gets long enough to need a navigation bar, I'll be employing the "you're here" marker script too (which I did briefly test out, of course).  I haven't gone down the path of compiling my own style sheet yet (though it is referencing a mildly themed version rather than the default), but that's mostly only because my site presently doesn't have any build mechanics — it just gets deployed as written.  (And something I plan on fixing, when time and sanity permit.)  But I have to say I rather like Bootstrap, and it wasn't at all difficult to use.