LeeHolmes / watchysim

Simulation framework for Watchy watch faces
MIT License
88 stars 9 forks source link

Add support for internal temp simulation #9

Closed aminch closed 1 year ago

aminch commented 1 year ago

Add support to simulate reading of the internal watch temperature.

This happens on the real hardware when there is no WIFi so instead of getting the weather external temperature it reads the temperature from the internal sensor of the watch.

Sets the "external" flag to false in the currentWeather object, which can be used in watch faces to have different behavior if desired

LeeHolmes commented 1 year ago

This looks helpful! There doesn't appear to be a way to go back to "External", though, so I think we'd want to add that to the PR before merging. MFC menus do have a way to do checkboxes inside of a menu item, so maybe use that approach rather than two menu items for Internal and External.

Also, do any watch faces consume this data? 7SEG is the test case I've found that consumes the most sensor data, but it'd be good to see how this impacts a watch face.

aminch commented 1 year ago

I set the default to put it back to external=true in the setWeatherCode call in the header, so if you select any of the other weather menu items it returns to external.

I did it this way based on how the real watchy code works. External = false is only set when it tries to read weather data and the WiFi connection fails. See here: https://github.com/sqfmi/Watchy/blob/master/src/Watchy.cpp#L671

I didn't see it in use in any of the watch faces. It appears to be implemented with this external flag just to distinguish where the temperature reading came from. I was planning to add it to a watch face I was working on so that I could ignore the internal temperature readings, and continue to display the last reading from the weather API itself.

LeeHolmes commented 1 year ago

Got it. Since this is very literally conditioned on WiFi in the Watchy SDK, should we instead make this API call when you turn WiFi off and revert when you either explicitly set a weather (or temperature?) or turn WiFi back on?

aminch commented 1 year ago

Yes this was along the lines of my first thoughts on how to implement it, to connect it to the WiFi being on or off.

I couldn't think of a nice way to implement it, but I see you point. It could be as you explain, just turning off WiFi could flip the external flag to false, and then it can be flipped back to true when WiFi is turned on or a weather or temp item selected.... I'll try that.

LeeHolmes commented 1 year ago

Looks great! Thanks!