FORUMS
Remove All Ads from XDA

Screen off with timed prox sensor

859 posts
Thanks Meter: 209
 
By Spookymyo, Senior Member on 17th August 2016, 08:55 PM
Post Reply Email Thread
I've looked for a solution but none of them work.

I'm looking for a simple Profile to turn the screen off when the proximity sensor is covered, which is simple.

But I don't want the profile to trigger if the sensor is just briefly covered so I want to add a task to only trigger the profile if the sensor is covered for 5 seconds.

I've tried adding a Wait task but that doesn't work. According to the tutorials I've seen, a Wait task should work. When I pass my hand over the sensor instead of turning off immediately, it waits 5 seconds then turns off.

I'm looking for similar functionality to the F-Droid app F2L.

Thanks.
17th August 2016, 11:18 PM |#2  
Member
Thanks Meter: 1
 
More
i'm in the same, what i do is when the sensor and no light switch time of screen to 15s. I set time of screen to 2m.
Using your way you have to make 2 profiles 1 with sensor on off variable, the second with a entry task with wait 5 seconds and screen off and exit task to stop the first one. the second profile must be activate when the variable of the first one is set to true (or what ever you want)

Enviado desde mi SM-G900M mediante Tapatalk
The Following User Says Thank You to potter3390 For This Useful Post: [ View ] Gift potter3390 Ad-Free
17th August 2016, 11:46 PM |#3  
#Henkate's Avatar
Senior Member
Flag フェアリーテイル
Thanks Meter: 3,135
 
Donate to Me
More
Quote:
Originally Posted by Spookymyo

I've looked for a solution but none of them work.

I'm looking for a simple Profile to turn the screen off when the proximity sensor is covered, which is simple.

But I don't want the profile to trigger if the sensor is just briefly covered so I want to add a task to only trigger the profile if the sensor is covered for 5 seconds.

I've tried adding a Wait task but that doesn't work. According to the tutorials I've seen, a Wait task should work. When I pass my hand over the sensor instead of turning off immediately, it waits 5 seconds then turns off.

I'm looking for similar functionality to the F-Droid app F2L.

Thanks.


Proximity Sensor.prj.xml

Download the project and import it.
A code shell is used to power off the screen, so root is needed. If you don't have root, then use System Lock tasker action.

I hope it's working as you want.

EDIT: Ops, someone already replied. I was writing this post.
The Following User Says Thank You to #Henkate For This Useful Post: [ View ] Gift #Henkate Ad-Free
18th August 2016, 05:49 AM |#4  
Spookymyo's Avatar
OP Senior Member
Flag Morristown, TN
Thanks Meter: 209
 
More
Quote:
Originally Posted by #Henkate

Proximity Sensor.prj.xml

Download the project and import it.
A code shell is used to power off the screen, so root is needed. If you don't have root, then use System Lock tasker action.

I hope it's working as you want.

EDIT: Ops, someone already replied. I was writing this post.

Thanks for the reply. I downloaded your XML project from media fire but when I tried to import it I got an error saying it failed to import data. I checked the XML in a text editor and noticed a lot of text strings with "media fire" and "Google". I don't think that should be the case.

Edit: Nevermind. I opened it in a different browser and it downloaded the proper file. I'll test it and see if it's what I was taking about.

Edit 2: That's money dude! That's so much easier than I thought. I had 4 different tasks and a few different variables. Thanks a ton!

Edit 3: I added a notification sound when the screen actually turns off. That way I'm not wondering if it did or not.

I noticed that when I turn the screen back on the flash text (Please wait 5 seconds) always displays. Does this mean that your project is always polling the proximity sensor even when the screen is off? In Tasker preferences, under the monitor tab, I have the proximity setting at No.
The Following User Says Thank You to Spookymyo For This Useful Post: [ View ] Gift Spookymyo Ad-Free
18th August 2016, 09:19 AM |#5  
#Henkate's Avatar
Senior Member
Flag フェアリーテイル
Thanks Meter: 3,135
 
Donate to Me
More
Quote:
Originally Posted by Spookymyo

Thanks for the reply. I downloaded your XML project from media fire but when I tried to import it I got an error saying it failed to import data. I checked the XML in a text editor and noticed a lot of text strings with "media fire" and "Google". I don't think that should be the case.

Edit: Nevermind. I opened it in a different browser and it downloaded the proper file. I'll test it and see if it's what I was taking about.

Edit 2: That's money dude! That's so much easier than I thought. I had 4 different tasks and a few different variables. Thanks a ton!

Edit 3: I added a notification sound when the screen actually turns off. That way I'm not wondering if it did or not.

I noticed that when I turn the screen back on the flash text (Please wait 5 seconds) always displays. Does this mean that your project is always polling the proximity sensor even when the screen is off? In Tasker preferences, under the monitor tab, I have the proximity setting at No.

I'm glad I helped you. I'm still a noob
I've tried again and it seems that you're right about the flash text. And I've figured out why: because when screen was going on after it was off, the variable %PROX still had value 1 (so it was triggering the profile), but then it was going to 0. I think that's it. In any case, I've made some changed and now that problem is gone.

I've made following changes:

- added two profiles to know if the screen is locked or unlocked. When it's unlocked, it also means that the screen is on

- added a state not call any, so the screen won't turn off when you're in a call (because when you have the phone at ear, the proximity sensor stays on, so we don't want our profile gets triggered that time)

- added a state display on at proximity profile which play with the %PROX variable, so the proximity sensor won't get triggered when you have the phone in pocket for example. It will trigger only if the screen is on

NEW version here


PS: let me know how it goes with the battery drain , if is minor or major. I'm just curious because i didn't use a profile with proximity sensor and I don't need this one.
The Following 2 Users Say Thank You to #Henkate For This Useful Post: [ View ] Gift #Henkate Ad-Free
18th August 2016, 11:14 PM |#6  
Spookymyo's Avatar
OP Senior Member
Flag Morristown, TN
Thanks Meter: 209
 
More
Quote:
Originally Posted by #Henkate

I'm glad I helped you. I'm still a noob
I've tried again and it seems that you're right about the flash text. And I've figured out why: because when screen was going on after it was off, the variable %PROX still had value 1 (so it was triggering the profile), but then it was going to 0. I think that's it. In any case, I've made some changed and now that problem is gone.

I've made following changes:

- added two profiles to know if the screen is locked or unlocked. When it's unlocked, it also means that the screen is on

- added a state not call any, so the screen won't turn off when you're in a call (because when you have the phone at ear, the proximity sensor stays on, so we don't want our profile gets triggered that time)

- added a state display on at proximity profile which play with the %PROX variable, so the proximity sensor won't get triggered when you have the phone in pocket for example. It will trigger only if the screen is on

NEW version here


PS: let me know how it goes with the battery drain , if is minor or major. I'm just curious because i didn't use a profile with proximity sensor and I don't need this one.

This version didn't work at all. It won't display the flash text. And it won't turn off the screen, it only dims. I'll just modify the first one with some of your new code.
19th August 2016, 07:49 AM |#7  
#Henkate's Avatar
Senior Member
Flag フェアリーテイル
Thanks Meter: 3,135
 
Donate to Me
More
Quote:
Originally Posted by Spookymyo

This version didn't work at all. It won't display the flash text. And it won't turn off the screen, it only dims. I'll just modify the first one with some of your new code.

Huh, it worked for me.
Do like you said.
2nd December 2019, 05:31 AM |#8  
Junior Member
Flag Tucson
Thanks Meter: 0
 
Donate to Me
More
I tried something a little different with the exception of using two profiles.
Profile one: Cover Closed
State-Proximity Sensor -> Task: Screen Off(Wait; one sec.,Turn Off; Dim off, Lock on)
Profile two: Cover open
State-Not Proximity Sensor -> Task: Screen On(Stop; Task Screen Off, Turn On; Block Time five hundred)
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes