I’ve spent a while trying to improve the code and the way in which the swim watch can be used. I’m sure things can be improved more, but the current updates are below

Buttons

I’m trying to keep the number of buttons to 4, but at the same time, I’m trying to add a few more features to the device. Therefore I’ve edited the program so that it now stores how long each button is pressed for (and has been pressed for if the button is classed as “justReleased”).

This has allowed me to make two important additions:

  • The “Off” button now has two functions: Switch the device off when it’s long-pressed; Go back if it’s short-pressed.
  • The “Select” button has a few different functions:
    • Moves forward in menus, etc. when it’s short-pressed;
    • When the “recordSwim” screen first comes on, a long-press starts a new swimming session
    • When currently recording a swim, a short-press records a new length;
    • When currently recording a swim, a long-press finishes the current swim session

Updated FSM

In order to implement the above button and menu changes, it was necessary to update the FSM model. I’ve finally got round to implementing a function pointer based FSM, which has allowed me to get rid of the large – and growing – switch case statement.

RTC – Date and Time

Time Stamping

One thing that was really important for having multiple swim sessions recorded on one device was the ability to time-stamp the date and time of the start of each training session.

In the current version – 5.0 – the device still only records one training session, with each new record over-writing the previous one. However, in the next version of the swim watch, I hope to include the ability to record multiple sessions, to then view – and delete – each one separately, but in order to do that, the date and time of the session needs to be stored along with the length details.

Therefore, I used the date and time of the RTC – using I2C – and stored that when the training session starts (i.e. when “Record Swim” has been selected and then the “Select” button has been long-pressed).

Below you can see the date and time as it’s recalled from the “View History” option.

DSC_000001

Changing Current Data / Time

When the RTC first starts up, the date and time are all set to zero, which is fine for testing, but of zero practical use. Therefore I created a “System” option on the main menu, to change the time and date, and also to show the current version number.

DSC_000001 (1)

To change the current time and date, the following steps are used (assuming starting at the main menu):

  • Press Up / Down to get to the “System” option and press Select;
  • Choose “Time / Date” and press Select
  • Go through each of the highlighted numbers (first date [DD-MM-YY] then time [HH-mm-SS]), pressing Up / Down to choose the correct one, then press Select to go to the next one.
  • When the time and date have been set, the RTC is updated via I2C.
  • Keep pressing Back (i.e. short-press the Off button) to get back to the main menu

Hopefully this will be pretty clear to anyone who’s updated the time / date on a sports watch.

Power usage

At this point, I was pretty curious what current the device was storing at various stages. Although I don’t have a current logger, my hand-held multi-meter can supposedly measure down to 0.01mA (10uA), so I decided to do some measurements

I tested the device in 3 different settings, with the following results:

System State Current (mA)
Main menu 13
Record swim 14
Sleep 0.3

From the above measurements, with the 300mA battery, the device should last for about 21 hours in use, or about 41 days in sleep.

Although I’m not convinced that my cheap battery will last that long, even half those values will be pretty good.

Next Step

I’m getting close to designing and getting some prototype PCB’s built, but before that, I want to improve the device a bit more.

Before I actually design the prototype PCBs (which will use SMD components to get it as small as possible), I want to add the following features over the next few versions:

  • Add the ability to record and view multiple swimming sessions;
  • Add the ability to record sets as well as individual lengths;
  • Figure out a method of setting pre-recorded training sessions;
  • Find a way to communicate between the watch and a computer (while keeping the device water-tight);

As always, the latest version of the code and circuit diagram can be found at the project site: https://code.google.com/p/avr-swim-watch/

 

Advertisements