Friday, June 29, 2012

Animation on Wise Clock 3/4

Mr Ruud did it again :)  He took this video showing a few more features he added.



1. ANIMATIONS
It is now possible to create your own animations which are stored on the SD card.
The APPS menu entry ANIM allows for continously showing one or all animations files.
Animation files are named: anim0.wc3 - anim9.wc3. 
There are also 4 special animation files named: time00.wc3, time15.wc3, time30.wc3 and time45.wc3. 
If ANIM+ is selected in the SETUP menu and the BIG mode is active then every quarter the correponding animation is shown once with a random speed. 
Besides the four time*.wc3 animation file, there are currently 4 sample animations: anim1.wc3 - anim4.wc3.

You may create your own animations (there is NO programming involved) by creating individual screens in Excel and then use a small conversion program to create the *.wc3 file. 
As the animations are stored on the SD card you can make them as big as you like.

2. LOGGING
If the LOG+ menu is selected in the SETUP menu then the following items will be logged in the wc3log.csv file:
  • every hour the current temperature is logged both in Celsius and Fahrenheit (32.5 degrees is stored as 325)
  • all entries created in the time clock (TCLOK) app are now stored in the log file

The wc3log.csv file is an ASCII Comma Separated Values file, which can be opened in Excel for further analysis (or for creating graphs etc).

The average log record is about 25 bytes long. The temperature logging will take 24 x 25 bytes =  600 per day. (So the 2 Megabyte log file will be full after about 9 years.)
A warning message ("log= @ End") will be shown when the log file is almost full, an error message ("log= FULL!") will appear if no more records can be written to the log file.

The SETUP menu entry CLRLG allows for clearing the complete log file, it will take about 10 minutes to clear a 2 megabyte log file.

Mike M. integrated all of the above changes with a previous version that works with FAT32. This code is available here.

Friday, June 1, 2012

Wise Clock 4 with integrated Bluetooth

Wise Clock 4 can now hold a Bluetooth module outside of the XBee socket, as shown in the pictures below.




























The communication with the BT module uses SoftwareSerial on pins D20/PC4 (Tx) and D21/PC5 (Rx).
The module is powered with 3V3 and the Rx line is level-shifted.

I bought a few of these Bluetooth modules from different sources, mostly ebay. Some of them did not work: my PC's Bluetooth could not "discover" them. Once SMD-soldered to the board, it is very difficult to figure out what's wrong and even de-solder and remove them. My advice for anyone using these modules is to check them before soldering them to any board/breakout. An easy way to do this is to solder wires on pins 12 (Vcc) and pin 13 (ground), as shown in the photo below (left), power with 3.3V, then try to pair it with a Bluetooth host (PC, Android; iPhone won't work since it requires an Apple-approved chip).















The module's relevant pins are shown in the diagram below (photo from ebay seller):












I did not test this myself (the experiment may cost about $7), but it seems that these Bluetooth modules only tolerate approx 3.3V and powering with 5V will fry them.

If you already have an Wise Clock 3/4 and want to add Bluetooth functionality (simultaneous to WiFi or XBee), you can add this module to the clock. Connections are through 4 wires: Rx/Tx go to D20/D21 (pins 26 and 27 of the processor), VCC to 5V, GND to ground. Note that this module has on-board power adapter for 3.3V and level-shifter for the logic lines.

Wednesday, May 30, 2012

DWex mod

From Gerard:

Hi Florin,
I had some spare time and moved on with the software mods on the DWex.
The mods are:
- display is always on (means you need to power by NiMH or wall supply)
- small animation after reset (test all the LED's)
- small animation at full 5' (solid) minutes
Feel free to distribute/publish the mods if you feel appropriate.
Best Regards
gerard, DL8SEL


The sketch is available for download here.

Thank you Gerard. Keep up the great work!

Thursday, April 19, 2012

Wise Clock 4 with remote "Alarm stop" button

The Ramos project brought the novel idea of a wireless alarm-stop button: instead of just reaching out to  press on the top of your nightstand alarm clock, you now have to actually get out of the bed and walk to a remote corner of your dwelling to click on a keypad. No chance you will return to sleep afterward :)

This remote alarm-stop feature for Wise Clock 4 can be implemented in several different ways, all of them using of the on-board XBee socket:
  • through a Bluetooth module;
  • through WiFi, using the Roving Networks WiFly module;
  • through XBee radios.
The cheapest and easiest would be the Bluetooth solution, providing that you already have a BT device (e.g. Android phone/tablet) to communicate with. In pseudo-code, it should look like this:

if (alarm is ON)
{
    while (Serial1.available())
    {
       read characters received;
       if (it is the expected string)
       {
            set alarm OFF;
        }
    }
}

The WiFi solution would require a second WiFi device (phone/tablet) to access a web site, or maybe they could talk directly (sockets), using their IP addresses.

The solution based on XBee relies on direct communication between two XBee radios. One would have to build the remote device, probably around an Arduino, with a keypad and an XBee.

Updated Feb 26, 2018: A good XBee remote control would be the SparkFun Wireless joystick.
Another, much cheaper solution, that does not requires software changes, would use the M4 backpack, as detailed here.

Guest post: Wise Clock 3/4 Apr-2012 software release

Updated Apr 20/2012
David M. mentioned an important detail: if you try to compile with Arduino 1.0 on Mac OSX  you will get the error "You can't have a cpp file with the same name as the sketch". The quick fix is to change the name of the file WiseClock4.ino (to TheClock.ino, for example). Interestingly, although it makes sense, this error does not show in Windows.
-------------------------------------------------------------------

Here is the email I received from Mike, who took on the challenge to fix and improve the code for Wise Clock 3/4, available here. Thanks Mike, keep up the great work!

My note: If you don't feel very confident about upgrading the software on Wise Clock 3/4, please do not do it.


I combined WiseClock3/WiseClock4 into one distribution, creating a WiseClockVer.h file with a
   #define _WISE_CLOCK_VER 3
line.  HT1632.cpp and Buttons.h include WiseClockVer.h, and use lines like
  #if _WISE_CLOCK_VER > 3
  #define HT1632_CLK      15      // clock pin (pin 2 of display connector)
  #else
  #define HT1632_CLK      11      // clock pin (pin 2 of display connector)
  #endif
That way the same distribution can be used for Wise Clock 3 or Wise Clock 4, and only one line has to be changed.

I found some places where over 100 bytes of data are copied into msgLine, overflowing the buffer.  Rather than just increasing the size of QUO_MSG_LEN, I changed all references to QUO_MSG_LEN to use MAX_MSG_LEN instead.

When reading a quote line a prefix character of Control-R (^R) will display the quote in red.  A prefix character of Control-O (^O) will display the quote in orange.

I removed all floating-point operations in favor of scaled integers.  For AppPong I scaled by 256, for temperature I scaled by 4 as the DS3231 is only accurate to 0.25 degrees.  I found that when the high and low temperatures were scaled by 10 and displaying farenheit that today's high could be 0.1 degree lower than the current temperature due to round-off errors.  These errors are avoided by saving the temperature scaled by 4 instead of 10.

I added a DST flag to indicate Daylight Savings Time is in affect.  DST+ sets the flag and advances the hour by one, DST- clears the flag and retards the hour by one.  The DST settings in the message file are still honored, setting the flag and incrementing the hour (if the DST flag is clear) or clearing the flag and decrementing the hour (if the DST flag is set) at the appropriate time.
The DST flag is used in the UTC code so the UTC offset is set once.  There is no need to change the UTC offset when Daylight Savings Time starts or ends.

I changed the sign of the UTC offset, so '-5' is now correct for Eastern Standard Time.  UTC + offset = current time.
Negative UTC offsets could not be restored properly, as -5 when retrieved would come back unsigned as 250.  I worked around the problem by adding 24 when saving to EEPROM and subtracting 24 when reading the EEPROM.

I changed the resolution of AppTimeLived's makeTime() from seconds to minutes.  The displayed seconds are calculated by taking the delta of the current second specified birth second, so makeTime() does not need the extra accuracy.  This change allows the offset to be calculated from 1900 instead of 1950.  With a second resolution and base of 1950 makeTime() would wrap in 2018.  With a minute resolution and a base of 1900 makeTime() won't wrap for another ~4000 years.

I changed the DEMO mode so it cycles through several display modes.  The number of minutes to display each mode is selected on the first screen after DEMO is selected, going from 0 minutes to 9 minutes.  Ten seconds is added to the cycle time, so selecting "0" goes to a new display every ten seconds.
The original lines Demo is only displayed for ten seconds, regardless of the selected cycle time.  The LIFE demo is displayed for fifteen seconds.
I was going to have AppWords as one of the demos, but I'd have to in-line most of AppWords' initialization code in the demo code, so I didn't bother.

I changed AppLife so it now wraps over the edges of the display.

I went through AppPong so all display offsets are relative to X_MAX and Y_MAX. As mentioned earlier, floating point math was replaced by scaled integers.  The height of the bat is now a #define and set to 5 instead of the previous version's hard-coded 6.  I settled on a color scheme -- ball and pitch are green, score is red, bats are orange.  I fixed some bugs in the ball prediction code and the 'flip' code (used to put 'english' on the ball).  I changed the 'miss' code to only miss by a few pixels.

The removal of the floating point freed up a lot of space.
It's [the whole sketch] less than 58K bytes.

I'm running the clock now.  The only issue is the year's high temperature needs to be re-initialized.  It was scaled by 10, now we expect it to be scaled by 4.  The nightly comparison won't save a new high temperature because the old one now is 2.5 times higher than it should be.  New clocks won't have the problem, but upgrading an existing one will.  The yearly low temperature isn't a problem because the scaled-by-four temp will be lower than the scaled-by-ten temp (unless your low is less than 0 C).  The work-around is easy, just set the year back by one overnight.  In the morning the yearly high/low temp will be reset.  The yearly high/low is only displayed in the "STATS" app anyway.



I corrected the life neighbor calculations.  The neighbor calculation used to be the sum of the colors for the eight neighbors.  This works when only green (1) is used, but when the colors are randomized the neighbor calculations are wrong, as some neighbors could be red (2) or orange (3).  I changed the color selection to use green for birth, orange for steady-state, red for dead.  The neighbor calculation now looks at the least significant bit of the color.  Green and Orange both have the lsb set, so this works well.

A quote-line can now be any length.  The quote buffer is replenished when processing is within 24 characters from the end of the buffer and the line was truncated.  Additional characters are tacked on to the end of the remaining 24, with no interruption.  This will repeat until the entire line has been processed, no matter how long the line is.  Reminders and Messages are still limited to 100 characters, and the lines in the Words files are still limited to 175 characters.