maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   [ANNOUNCE] Phone Speakers Switcher - turns speakers on/off during call (https://talk.maemo.org/showthread.php?t=46914)

jaeezzy 2010-03-20 03:09

Re: [ANNOUNCE] Phone Speaker Switcher - turns speakers on/off during call
 
Quote:

Originally Posted by hawaii (Post 573322)
Interested in implementing tapping the power button, to disconnect the call instead of the camera button (which works brilliantly, by the way).

If not, I can localize and make a personal patch.

Ya, that would be fine but the thing is when pressing power button it pops up a menu and I don't know how I can cancel that and only do what I want. If you can tell me how, I can implement that and also I'm working on proximity sensor coz the one I'm using at the moment isn't giving stable result - meaning in the day time, night and night time with the room lights on. Maybe because I chose the shorthand (easy way) :D Can anyone plz check this one and report me back?. Coz all I'm doing now is reading the files from /sys/class/hwmon/hwmon1/device/ namely adc0 and adc1 every 1 second and as they return numeric values, I'm just using that to turn speakers on/off. Can someone plz tell what they are actually, coz they are giving random results in different scenarios like I mentioned above and from what I found in the web, it is suppose to give proximity value.

qwerty12 2010-03-20 08:11

Re: [ANNOUNCE] Phone Speaker Switcher - turns speakers on/off during call
 
Quote:

Originally Posted by jaeezzy (Post 574280)
Coz all I'm doing now is reading the files from /sys/class/hwmon/hwmon1/device/ namely adc0 and adc1 every 1 second and as they return numeric values, I'm just using that to turn speakers on/off. Can someone plz tell what they are actually, coz they are giving random results in different scenarios like I mentioned above and from what I found in the web, it is suppose to give proximity value.

That would be due to those being the values for the light sensor... You want the file "/sys/bus/platform/devices/proximity/state" which can have a state of "open" or "closed".

P.S. GIOChannels provide a nicer alternative to watching files.

pillar 2010-03-20 09:05

Re: [ANNOUNCE] Phone Speaker Switcher - turns speakers on/off during call
 
Shortcutd uses proximityd which I think could be used for easy proximity reading. Maybe it could be useful here as well?

jaeezzy 2010-03-21 02:01

Re: [ANNOUNCE] Phone Speaker Switcher - turns speakers on/off during call
 
Quote:

Originally Posted by qwerty12 (Post 574430)
That would be due to those being the values for the light sensor... You want the file "/sys/bus/platform/devices/proximity/state" which can have a state of "open" or "closed".

P.S. GIOChannels provide a nicer alternative to watching files.

Thanks for the info but I just couldn't make use of GIOChannel. Here's how I did:

Code:

int fd = open("/sys/bus/platform/devices/proximity/state", O_RDONLY, O_NONBLOCK, O_NOCTTY);
GIOChannel *channel = g_io_channel_unix_new(fd);
g_io_add_watch(channel, G_IO_IN | G_IO_PRI, (GIOFunc)readState, NULL);
..........

gboolean readState(GIOChannel *channel, GIOCondition cond, gpointer data){
 gchar *state;
 gsize size;
 GIOStatus ret = g_io_channel_read_line(channel, &state, &size, NULL, NULL);
 if (ret != G_IO_STATUS_ERROR){
  printf("STATE: %s", state);
  if (strcmp(state, "open") == 0){
        ...........
    }
  else if (strcmp(state, "closed") == 0){
        ...........
  }
  g_free(state);
 }else
  return FALSE;

 return TRUE;
}

Any help would be great. Thanks

qwerty12 2010-03-21 07:19

Re: [ANNOUNCE] Phone Speaker Switcher - turns speakers on/off during call
 
Quote:

Originally Posted by jaeezzy (Post 575383)
Thanks for the info but I just couldn't make use of GIOChannel. Here's how I did:

Code:

int fd = open("/sys/bus/platform/devices/proximity/state", O_RDONLY, O_NONBLOCK, O_NOCTTY);
GIOChannel *channel = g_io_channel_unix_new(fd);
g_io_add_watch(channel, G_IO_IN | G_IO_PRI, (GIOFunc)readState, NULL);
..........

gboolean readState(GIOChannel *channel, GIOCondition cond, gpointer data){
 gchar *state;
 gsize size;
 GIOStatus ret = g_io_channel_read_line(channel, &state, &size, NULL, NULL);
 if (ret != G_IO_STATUS_ERROR){
  printf("STATE: %s", state);
  if (strcmp(state, "open") == 0){
        ...........
    }
  else if (strcmp(state, "closed") == 0){
        ...........
  }
  g_free(state);
 }else
  return FALSE;

 return TRUE;
}

Any help would be great. Thanks

I'd be lying if I said I knew, so all I can do is point you to headphoned: http://repo.or.cz/w/headphoned.git/b...dphoned.c#l280

jaeezzy 2010-03-22 01:21

Re: [ANNOUNCE] Phone Speaker Switcher - turns speakers on/off during call
 
I've just uploaded the current version 0.1-5 to both devel and my #1 post. Its more matured now :D As, always all info are in that same post.

jaeezzy 2010-03-22 06:30

Re: [ANNOUNCE] Phone Speaker Switcher - turns speakers on/off during call
 
ok I think I've messed up couple of things in extras-devel repo as it's says dependency missing and I've no idea why and it can't be downloaded (I'm just noticing it). I checked some other packages and in every of them its "libosso1 (>=2.23)" but how come mine has "libosso1 (>=2.26)" and its in this where the problem lies. I'm using scratchbox only nothing else and in control file in Depends its ${shlibs:Depends}. Any help would be great however installing the provided deb file in the #1 post goes well. Thanks

qwerty12 2010-03-22 10:32

Re: [ANNOUNCE] Phone Speaker Switcher - turns speakers on/off during call
 
Quote:

Originally Posted by jaeezzy (Post 576679)
ok I think I've messed up couple of things in extras-devel repo as it's says dependency missing and I've no idea why and it can't be downloaded (I'm just noticing it). I checked some other packages and in every of them its "libosso1 (>=2.23)" but how come mine has "libosso1 (>=2.26)" and its in this where the problem lies. I'm using scratchbox only nothing else and in control file in Depends its ${shlibs:Depends}. Any help would be great however installing the provided deb file in the #1 post goes well. Thanks

https://bugs.maemo.org/show_bug.cgi?id=9070#c3 - the first paragraph there should sum it up.

jaeezzy 2010-03-22 11:18

Re: [ANNOUNCE] Phone Speaker Switcher - turns speakers on/off during call
 
Quote:

Originally Posted by qwerty12 (Post 576876)
https://bugs.maemo.org/show_bug.cgi?id=9070#c3 - the first paragraph there should sum it up.

Thanks for the info and does that mean I've to wait until the release of PR1.2 to be able to upload downloadable package in extras-* repo?

qwerty12 2010-03-22 11:21

Re: [ANNOUNCE] Phone Speaker Switcher - turns speakers on/off during call
 
Quote:

Originally Posted by jaeezzy (Post 576916)
Thanks for the info and does that mean I've to wait until the release of PR1.2 to be able to upload downloadable package in extras-* repo?

Nah, you should be OK -- you don't appear to depend on any components that are new to PR 1.1.


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

vBulletin® Version 3.8.8