Basic_Watch_v2 in progress

A re-write of basic watch using a text based oled library is well underway. I have spent a few hours this evening making a good start.

So far I have re-created the watchface and hourly tones. I have a minor screen timeout issue to resolve and then I can work on the button logic followed by creating all the menus again.

Once I have reached parity with the existing version I will add in the Bluetooth additions in the other post.

Hopefully after all this there will still be more storage left to add more features.

I have mostly finished the re-write and I think it has saved 15-20% of storage.

I have committed it to GitHub so anyone can give it a try. I havenā€™t tested it much but I know there are some minor bugs with the menu cursor.

Other than that most stuff seems to work including sleep mode. I have added some new menu options too.

There is much tidying up to do and many optimizations I am sure.

Once it is a bit more polished I will try and add the Bluetooth music controls.


IMG_20181129_234357|375x499

1 Like

It looks like we will have more storage :slight_smile: I noticed that while I navigate at the menu I can see the screen refresh as I press the up or down button. Did you see the TapClock watch face? It has two features that I fall in love:

  • Breathing LED while charging
  • Keeping the watch wake while charging so that USB hardware awaileable for uploading new sketch.

I forked your work, I will try another library and letā€™s see which one of us will gain more program space:)

I think I know why that might be.

Thereā€™s a delay after the button press. Thatā€™s what will be causing the flicker. It needs a proper debounce adding.

By the way, the code is much more clear and understandable after you divide them by function into different files.

Yeah, that is why I did it. I was finding it difficult to find places in the code with it being such a long sketch.

It can also be a pain working out what is declared before what though.

Updated: I fixed an issue where the screen was using the longer timeout instead of the short one.

I have also implemented the alarm. It functions, I might look at the logic again though. If the hour and minute match the alarm hour and minute the watch beeps. This is works because an ā€œalarmā€ variable gets set to 1. To silence the alarm every button press sets a second variable ā€œalarmstopā€ to 1 if the alarm variable is currently 1. It sets alarm stop back to 0 when the alarm variable is 0.

This does require that a button be pressed after the alarm minute otherwise the alarm will not be reset. I think itā€™s unlikely that this will happen but I will think on it some more.

Next I want to tidy up the format of the menus and make them more consistent.

Then I want to add proper debounce to the buttons and where possible remove all uses of delay().

I am using bounce 2 from https://github.com/thomasfredericks/Bounce2 in my sketches with 25ms debouncing time.
This lib is really useful as is returns not only debounced inputs, you can also get rising and falling signal changes detected (rose/fell).
I use this quite often in my sketches.

Yeah was going to rob your code but I ran out of time last night.

Previously I have just used my own debounce.

Just take a Millis() when there is a successful button press and store in a variable lastpress. Then on each press take another Millis() and subtract lastpress from this one and if > debounce time itā€™s a press and update lastpress if not pass the if statement.

Itā€™s just one of those things thatā€™s been in my code since day 1 and I have not got around to changing.

Pin change interrupts might be better but I am not sure how they work with the sleepy dog library.

I also want to add your USB detection.

I think you can use PCINT parallel to the sleepy dog.
I have used a PCINT lib in WordClock, using was simple.

I found the USB Detection here:

Iā€™ll have a look at that later maybe.

I have fixed the cursor location behaviour.

I looked at the menu flickering when pressing the buttons and it was not what I thought. I already implemented a proper debounce. The flicker is caused by me calling clear display on each refresh. I need to figure out a way to redraw the screen without calling that function. Almost like only writing changes. I wonder if I can access the screen buffer and detect if it has changed.

Actually it seems I fixed the cursor behaviour in one direction but not the other. Will have to look at that again.

Also does pcint wake the watch if it is in a timed sleep?

I am using ā€œsteps/statesā€.

  1. clear the screen
  2. write static text.
  3. write only parts which needs to be updated

Step/State 3 will be repeat each second only once, the result is no flickering on the OLED.

Greimans SSD lib has no buffer as we write directly to the Display.
Need less space but has some disadvantages.

When I got time I will test this.

I will have to go over your code to see how you are doing it.

Iā€™m using a variable to track which menu is currently displayed.

I have finally fixed all my cursor navigation issues.

:+1: Great news, need to test again.

I am trying to integrate Mustafaā€™s Bluetooth stuff at the moment.

I have included your charging LED but not had chance to test it since my battery was full at the time.

I am having usb detection issues though. Mine shows as connected all the time even when itā€™s not.

I have included mtuluā€™s Bluetooth stuff but I cannot get it to change track on my phone. Do you have to pair it in a special way?

The latest code is in GIT and there is currently 85% usage of program storage.

My IOS Device donā€˜t show WatchX as available Bluetooth Partner but the Adafruit Bluefruit App is able to connect without an passcode.

My android phone shows it as available and pairs ok but it doesnā€™t show as connected.

Iā€™m adding in a factory reset just to make sure I have no funky config going on.

Try the Bluefruit App.
I am planning to use it for setting values instead of programming a menu.