Notices


Reply
Thread Tools
ciroip's Avatar
Posts: 334 | Thanked: 366 times | Joined on Nov 2008 @ Italy
#91
Originally Posted by jolouis View Post
Did you manage to get the power-management code tied into your "Rebuilt" version of the app?
-Rob
Yes, I always keep in mind a minimal version that act as much clever as I can manage. Im trying to keep the think modular and configurable moving all the variables in one place (ci_init) at the point that the app could recognize it the tablet is connected or not to the power and downgrade the functionality (update the clock each 10 seconds instead of every 1, and stop completely the video update when the screen go dark). I just need to look around for the os call to check the battery/charning status. Since the application is mean to run everytime I was thinking to keep some stats so advanced users could keep track of charging (and discharging) time (and how it degrade during the device history...) mh, maybe nokia will not be too excited about that....
Anyway yes, number 1 priority is to make the thing ringin
__________________
I can't do it. No one can help.
[SIGPIC][/SIGPIC]

Flip Alarm Clock - 3DMania Theme - Synesthesia - Deluxepain
http://ciroip.blogspot.com/
http://twitter.com/ciroippolito
 

The Following 2 Users Say Thank You to ciroip For This Useful Post:
ciroip's Avatar
Posts: 334 | Thanked: 366 times | Joined on Nov 2008 @ Italy
#92
Originally Posted by lcuk View Post
ciroip,
how difficult is it to make all the top row buttons respond to the alarm ringing - like a real alarm clock.
In the form you have it now I can see myself poking blearily and making n810 slide off the bedside and smash on the floor.
when the alarmclock is ringing, think of your users as cavemen
Yes, I was thinking to use the real buttons on top for the "another5minutesinbed" and prolong the ringing until someone really want to switch off (or close the app). I pondered to use the slide keyboard to arm and disarm the alarm but that 1. too risky (too easy to change the status) and 2. that would cut out the n800/770 whatever.I still didnt check how access the hardware buttons but the thing should be ridicolously easy to make it. Anyway Im still not sure if the application can run 8 hours straight without a glitch. Im keeping calling pygame screens without caring too much about release resources, I have no idea how clever are the python+pygame solution.
__________________
I can't do it. No one can help.
[SIGPIC][/SIGPIC]

Flip Alarm Clock - 3DMania Theme - Synesthesia - Deluxepain
http://ciroip.blogspot.com/
http://twitter.com/ciroippolito
 

The Following User Says Thank You to ciroip For This Useful Post:
Jaffa's Avatar
Posts: 2,535 | Thanked: 6,681 times | Joined on Mar 2008 @ UK
#93
Originally Posted by ciroip View Post
Yes, I always keep in mind a minimal version that act as much clever as I can manage. Im trying to keep the think modular and configurable moving all the variables in one place (ci_init) at the point that the app could recognize it the tablet is connected or not to the power and downgrade the functionality (update the clock each 10 seconds instead of every 1[...]
Ah, so even the updated version doesn't do anything clever to avoid pegging the CPU?

0.0.4 sat constantly eating 12% CPU when not even in the foreground. It's a lovely looking app, but it needs some smarts (and not even the variety you're talking about ;-)):
  • Don't update the clock every second. The display only changes every minute. If you want to ensure that the clock flips at the instant the minute rollsover, identify the number of seconds until the next minute change, and sleep the main thread until that time. Only check the alarm when necessary.
  • As you say, stop completely any updating or counting or anything the moment your app isn't in the foreground, or when its minimised, or when the screen blanks.
  • You can test this by opening up X Terminal (under the Utilities menu) and running top. When you can see X Terminal (i.e. Flip Clock's in the background) the CPU usage of your process should be 0.0%. When it is in the foreground (and you'll have to SSH in to your tablet to see this), it should be as low as possible to make it practicable to actually use as a clock without a mains adapter.

If you've started on a rewrite, get this structure in first, and then add features. IMNSHO, this'll help you keep things sane in your head.

HTH,

Andrew
__________________
Andrew Flegg -- mailto:andrew@bleb.org | http://www.bleb.org
 

The Following 8 Users Say Thank You to Jaffa For This Useful Post:
ciroip's Avatar
Posts: 334 | Thanked: 366 times | Joined on Nov 2008 @ Italy
#94
@jaffa, i love this kind of comments . Really help me to keep' the focus on the right things. I have no idea how balance the things... ill try to rebalance the app as much as i can

Last edited by ciroip; 2009-01-04 at 05:18.
 

The Following User Says Thank You to ciroip For This Useful Post:
TrueJournals's Avatar
Posts: 480 | Thanked: 378 times | Joined on Apr 2008 @ Chicago-ish
#95
Well, I took a bit of time to see if I could modify ciroip's code to at least implement Jaffa's first suggestion, and this improved CPU usage DRAMATICALLY. The changes are actually pretty simple...
In fk007.py, find the line:
Code:
pygame.time.set_timer(DRAW_CLOCK_EVENT, 5000)
And replace it with:
Code:
ctime = time.ctime()
pygame.time.set_timer(DRAW_CLOCK_EVENT, (60-int(str(ctime[17])+str(ctime[18])))*1000)
timesixty=False
Find the line:
Code:
elif event.type == DRAW_CLOCK_EVENT:
And add AFTER (inside the if):
Code:
    if timesixty == False:
      pygame.time.set_timer(DRAW_CLOCK_EVENT, 60000)
      timesixty = True
Tah-dah! This adds a small extra if statement for the program to check when updating the clock, but it only happens once a minute, and it's just boolean checking, so there really shouldn't be any extra strain on the CPU for updating. I checked top in xterm, and even in the foreground, this now runs at 0% CPU (except for the update once a minute). Before this change, top would never show the CPU below ~1.5%
__________________
Disclaimer: If a program I wrote doesn't work/breaks your tablet... It's not my fault
mcedit | Utility Calculators (WIP) | PyRDesktop
My Blog | Twitter
 

The Following 7 Users Say Thank You to TrueJournals For This Useful Post:
Jaffa's Avatar
Posts: 2,535 | Thanked: 6,681 times | Joined on Mar 2008 @ UK
#96
Originally Posted by TrueJournals View Post
Well, I took a bit of time to see if I could modify ciroip's code to at least implement Jaffa's first suggestion[...]
There is a possibility of clock drift with this approach. Consider, time is 11:54:36
  1. Timer is correctly calculated to go off in 24 seconds.
  2. Device gets busy or app stumbles or some other circumstance occurs which means timer doesn't go off for 25 seconds.
  3. Clock doesn't change until 11:55:01. Timer is set to go off in 60 seconds.
  4. Repeat whatever caused step 2, timer doesn't go off for 61 seconds.
  5. Clock doesn't change until 11:56:02.
  6. ...

So, although it's an extra call I'd suggest not committing the cardinal sin of premature optimisation until the extra step is a significant part of refreshing the screen/checking the alarm/doing nothing (if screen blank and no alarm set).
__________________
Andrew Flegg -- mailto:andrew@bleb.org | http://www.bleb.org
 

The Following 5 Users Say Thank You to Jaffa For This Useful Post:
Posts: 1,097 | Thanked: 650 times | Joined on Nov 2007
#97
Any .deb's available for install for the all new noParty version with Alarams ?
 
danramos's Avatar
Posts: 4,672 | Thanked: 5,455 times | Joined on Jul 2008 @ Springfield, MA, USA
#98
Rather than sleeping as a way of freeing up CPU cycles and checking every minute (I'd also immediately considered drifting and imprecision as issues if this is implemented), is there a way to use a system interrupt based library to run the update code every time the system's clock has incremented the minute? I'm not familiar with programming in python, but I would assume this would mean using a library that deals with the HAL (Hardware Abstraction Layer) interface? This would offload the work from the app and leave it up to the operating system to run the routine as an event.
 

The Following 2 Users Say Thank You to danramos For This Useful Post:
danramos's Avatar
Posts: 4,672 | Thanked: 5,455 times | Joined on Jul 2008 @ Springfield, MA, USA
#99
Actually, this seems to make great reference to the technique I'm trying to express:
http://maemo.org/maemo_release_docum...1.x/node6.html

The relevant portion is "5.3.1.12 Maemo Alarm Framework" and in a more general way "5.3.4 Application Framework". If the OS can execute the routine to update, rather than having the app running busy the entire time, then it can just simply sit there in memory and just exist to execute on a hardware timer to update the screen and another routine, again called by hardware timer event, to run the alarm routine.

Maybe I'm just thinking this way because I did too much assembly programming as a kid. Seems like this would be a really easy thing to write in assembly but I've never looked at anything on writing assembly in ARM and I'd assume this type of functionality had probably already been written into the maemo python libraries somewhere.
 

The Following User Says Thank You to danramos For This Useful Post:
Jaffa's Avatar
Posts: 2,535 | Thanked: 6,681 times | Joined on Mar 2008 @ UK
#100
Originally Posted by danramos View Post
Actually, this seems to make great reference to the technique I'm trying to express:
http://maemo.org/maemo_release_docum...1.x/node6.html
Indeed, alarmd immediately sprung to mind when you described what you wanted.

The relevant portion is "5.3.1.12 Maemo Alarm Framework" and in a more general way "5.3.4 Application Framework". If the OS can execute the routine to update, rather than having the app running busy the entire time, then it can just simply sit there in memory and just exist to execute on a hardware timer to update the screen and another routine, again called by hardware timer event, to run the alarm routine.
IMHO, alarmd isn't designed for frequent updates within a single running app, but it is designed to handle the case where the alarm set in flip-clock should go off whether the app is running or not.

I think the overhead of context switching and DBUS signals make alarmd unsuitable for the task of updating the clock, every minute, when the app is running. It may be suitable, however, if the alarm should be integrated into the existing alarm system (including the built-in Clock). In that circumstance, it can even "do" the alarm sound and popup, not requiring flip-clock to even be (re-)started.
__________________
Andrew Flegg -- mailto:andrew@bleb.org | http://www.bleb.org
 

The Following 2 Users Say Thank You to Jaffa For This Useful Post:
Reply

Tags
clock, flip clock


 
Forum Jump


All times are GMT. The time now is 13:55.