maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   All about SleepAnalyser (https://talk.maemo.org/showthread.php?t=57419)

mirakels 2010-08-25 18:45

Re: [ANNOUNCE]: SleepAnalyser
 
Hi caco3

sleepanalyser takes a noticable ammount of cpu/battery. To improve on this I changed the duration value during recording to only show hour:minute. E.g. remove the seconds. This apperantly save lots of screenupdates.
In my case it gets me 2 to 3% less battery drain during the night.

jaguilar 2010-08-25 19:25

Re: [ANNOUNCE]: SleepAnalyser
 
Quote:

Originally Posted by mirakels (Post 798187)
sleepanalyser takes a noticable ammount of cpu/battery. To improve on this I changed the duration value during recording to only show hour:minute. E.g. remove the seconds. This apperantly save lots of screenupdates.
In my case it gets me 2 to 3% less battery drain during the night.

Why update the screen while you are sleeping?
It would be better only update the screen if the display is on?

caco3 2010-08-25 20:37

Re: [ANNOUNCE]: SleepAnalyser
 
Hi Mirakels and Jaguilar

My original idea was only to update the screen (incl. graph) when the display is on.
How ever i have not yet figured out how to detect if the display is on.
I expect I can get that information with dbus, but how?

jaguilar 2010-08-25 20:52

Re: [ANNOUNCE]: SleepAnalyser
 
Caco3,

Using "dbus-monitor --system" in the terminal, received these signals:

1- signal sender=:1.9 -> dest=(null destination) serial=1553 path=/com/nokia/mce/signal; interface=com.nokia.mce.signal; member=display_status_ind
string "off"

2- signal sender=:1.9 -> dest=(null destination) serial=1556 path=/com/nokia/mce/signal; interface=com.nokia.mce.signal; member=display_status_ind
string "on"

Signal 1 when display off, and signal 2 when on!
Register in dbus listening these signals and be happy! :)

caco3 2010-08-25 21:00

Re: [ANNOUNCE]: SleepAnalyser
 
Thank you a lot!

What do you mean with "register at the bus?"
Do I then have to listen all the time? Isn't that also power sucking?
Or can I get a trigger when a certain event occures?

I guess I could somehow use dbus-scripts, but as it is only in Extras-Devel, most people could not use it.

jaguilar 2010-08-25 21:27

Re: [ANNOUNCE]: SleepAnalyser
 
When you register in dbus listening for a signal you provide a callback function. When the signal is emited the function is called. There is no power sucking!

This code works for you:
Code:

#!/usr/bin/env python2.5
# -*- coding: utf-8 -*-
import sys
import dbus
from dbus.mainloop.qt import DBusQtMainLoop

from PyQt4.QtGui import *
from PyQt4.QtCore import *


class Daemon:
    def __init__(self):
        print "Daemon"
        loop = DBusQtMainLoop(set_as_default=True)
        system_bus = dbus.SystemBus()
        system_bus.add_signal_receiver(self.test_signal,
                                      path='/com/nokia/mce/signal',
                                    signal_name='display_status_ind',
                                    dbus_interface='com.nokia.mce.signal')
        print "Daemon ok"


    def test_signal(self, *params):
        print "1", len(params)
        print params


class test:
    def __init__(self):
        app = QApplication(sys.argv)
        Daemon()
        app.exec_()


if __name__ == "__main__":
    test()


caco3 2010-08-25 21:40

Re: [ANNOUNCE]: SleepAnalyser
 
Hi jaguilar

Thank you sooo much for your help!
Now I can make SleepAnalyser even more power saving.

Now I just have to figure out how to make big buttons without repeating theme (http://talk.maemo.org/showthread.php?p=798347)

zimon 2010-08-26 13:43

Re: [ANNOUNCE]: SleepAnalyser
 
Nice program!
I used to use Sleepy before, but this is nicer looking. (more candy)

What I am missing from Sleepy, is to able to see several sleeping times (nights) top of eachothers to visually compare.
Also Sleepy will tell how much "deep" sleep was there.
Similarly SleeyAnalyzer could tell total cumulative time of those Green, Dark Green, Red, Light Red zones....and maybe also max length of those.
In example: Your "max deep sleep" (light green) was 20 minutes long, total 2h 10m.

Horizontal scrolling of diagram with finger and not just with arrow-buttons would be nice.

BTW, not really about sleep, but this same program could have an option to alarm when just some treshold of movement in some selectable time period have occured. Maybe alarm could be a slient phone call and/or SMS message also. Could be usefull as a burglary alarm inside of luggage or attached to a hotel door.

Could be a separate program, but the internal logic would be so much similar to SleepAnalyser this could be included also IMO.
Besides, the name "SleepAnalyzer" would then also mean it analyzes if N900 is not disturbed by shaking, moving or tilting. Let N900 "sleep" or it acts. Some optional delay, so SMS is not send if owner STOPs the delayed alarm.

jaguilar 2010-08-26 18:04

Re: [ANNOUNCE]: SleepAnalyser
 
Quote:

Originally Posted by caco3 (Post 798389)
Now I just have to figure out how to make big buttons without repeating theme (http://talk.maemo.org/showthread.php?p=798347)

Well....with that unfortunally I can't help! My expertise in Python is not so good, and with Qt even less! :)

But keep going with the excelent job in SleepAnalyser!

caco3 2010-08-26 18:28

Re: [ANNOUNCE]: SleepAnalyser
 
Hi Guys
In the newest devel version I changed a lot in the ui. It now more gets into how it should be for daily usage.
I still have to figure out how to make big buttons (with QT Designer or in python).
I was told to do it with stylesheets, but how?
If you know how to do it, please let me know.

Also please still test and vote for the version 1.6-28 in testing.
It is quite stable ond has only very minor bugs. I want to get it into extras, so others also can profit from the alarm function.


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

vBulletin® Version 3.8.8