Lixie Clock Refresh
For me, the concept of sharing the workload between a two micros, one for NTP Time Sync and sensor reading and one for running the clock in a timely fashion (SWIDT?) has worked really well so I decided that it was time to implement the same in my Lixie Clock.
I re-worked the state-machine code from other projects to suit the Lixie library and implemented the second processor. I also took the opportunity to make a ‘better’ job of the display – by that I mean having the TEMP and PRESSURE readings centrally located within the 6 Lixie digits rather than lurking at the right hand side of the clock. For this to happen I needed to learn a little more about how the Lixie library worked.
The basic lix.write() function takes a number as its argument so to write the time to the display, say half past ten, I need to send 1103045, the first digit is ignored as there are only 6 lixies, it displays the last 6 digits.
If I send 24 for 24 degrees C, then it displays 24 on the right most two digits, not ideal.
There is little documentation available so I looked in to the library and discovered some additional functions that allow the setting and clearing of individual elements of the display. Great I thought, just convert the number to a string, extract each digit in turn and send it’s value using the correct function. Well, this is where I seem to have over complicated things. I make the string just fine, I extract a single character using ‘.charAt()’, also fine. Then the trouble starts, how can I get the numeric value of that single digit? In the old days one might use val(mid$(timestring$,1,1)), no, not now. The process of learning what a char data type is – begins……
Finally, after much research (the posh name for googling) I deduce that the ‘value’ of a char data type is in fact the ascii value of the character concerned (obviously?) so I manage to come up with mystring.charAt(0)-‘0’ as the actual numeric value of the first element of mystring., it works!
Now I have temp and pressure displayed neatly in the centre of the display, hurrah. There is a newer library ‘edgelit’ which promises much more sophistication though again, the lack of examples and documentation makes it difficult for someone of my inexperience to get to grips with it so, for now I will settle with what I have.
Given that the micro sending the time sync at temp/pressure data is also computing and sending the pressure trend I might just have a go at indicating the rising/steady/falling status either by the use of colour alone or perhaps one of the unused digits in a different colour. I’ll just need to see how that looks.