carrotIndustries / pluto-fw

Pluto is a programmable digital watch that re-uses case and LCD panel of the Casio® F-91W. (Software)
GNU General Public License v3.0
100 stars 17 forks source link

Changing update frequency of LCD in time app #9

Open cculpepper opened 7 years ago

cculpepper commented 7 years ago

I am trying to add a hundredths display. Basically instead of using seconds, it would use hundredths of minutes. It is used in motorsports timing.

My issue is with the sim, the display is still updating every second, instead of updating every hundredth. Is this a limitation of the sim, or am I missing a timing element somewhere?

The time app: display.c The hundredths service itself: hundredths.c, note that simulation testing boilerplate was added as aux_timer wasn't available.

carrotIndustries commented 7 years ago

Seems like a perfect application for pluto, do you have any references for the use of "hundredths of a minute"? Overall, this sounds like a feature I'm willing to eventually merge, but there are some implementation details that will need to be sorted out / I'd like to make you aware of:

Using the aux timer significantly increases power consumption since the MCU now has to wake up 128 a second instead of 4 times, so I'm not sure whether it's wise to integrate this feature into the time display since all other display modes have been optimized for lowest power consumption i.e. hal_lcd_set_mode(HAL_LCD_MODE_IMMEDIATE); I'd be more happy with this feature being implemented in a distinct app.

Don't use floating point math, since this will increase code size significantly.

To make the display update on every aux timer tick, svc_aux_timer_set_call_main as in https://github.com/carrotIndustries/pluto-fw/blob/master/common/svc/chro.c#L41

cculpepper commented 7 years ago

I'm trying to find references, its a thing that is more just understand than really explained. An app for the iphone that measures hundredths (They call them cents) https://itunes.apple.com/us/app/centwatch/id424471807?mt=8

Was afraid of the power consumption, so the way I have it coded now, is that the aux timer is only activated when the time app is in hundredths mode. When the app is in decimal or hex time, the aux timer is not requested for the hundredths service. For HAL_LCD_MODE_IMMEDIATE, does this mode (Like I believe the name implies) have the LCD controller set the segments asynchronously of a clock pulse? IE whenever an update is issued? I would be more than happy to write this as a separate app, I'm just trying to get a handle on the architecture.

Floating point math was added just for testing on the sim. I wanted to see the updates, but the sim does not implement the aux timer. I figured my laptop would have a few more floating point cycles to spare. The actual service only does integer math.

Instead of updating on every aux timer tick, could I just call the main loop? Or issue a fake event just to make the display update? Although, if the aux timer is going to be used anyway, it shouldn't be wasting too many cycles just calling main, its a pretty tight loop in there.

cculpepper commented 7 years ago

Okay, so looking at my code, I actually do have it call svc_aux_timer_set_call_main in the aux timer handler. However, I am guessing that this is actually a sim issue. I lent my programming jig to a friend before vacation so have yet to try on real people hardware. I will probably be trying to build another jig within the next couple weeks. I suspect that the LCD update rate will be fine on the real hardware.

carrotIndustries commented 7 years ago

Take a look at the chronograph - the display updates just fine in in the simulator since it implements the aux timer (otherwise beeping won't work).

HAL_LCD_MODE_IMMEDIATE is there for reducing power consumption. In buffered mode lcd_putc and friends render to a back buffer, when calling hal_lcd_update it gets copied to the LCD memory. To do away with the useless copying, lcd_putc directly writes to lcd memory in immediate mode.

Still, enabling the aux timer in the time app seems like a bad idea since it's non-obvious to the user that a particular base causes increased power consumption. That's why I'd like to see that feature as a separate app.

cculpepper commented 7 years ago

Gotcha with HAL_LCD_MODE_IMMEDIATE. I think I have a better handle on it.

My chronograph does not work in sim, I had assumed it was a limitation of the simulator, I'll see what dependencies I am missing for that.

I'll throw it into a separate app. That makes a lot of sense.