Front LED/flash

Post your feature requets for new triggers, conditions, actions and other improvements.

Moderator: Martin

Post Reply
Mar
Posts: 49
Joined: 20 May 2015 23:24
Location: Germany

Front LED/flash

Post by Mar » 07 Nov 2015 03:07

Hi,

I think there's a function of the iPhone which flash on the back LED. Maybe this has inspired me.

Anyway, I have searched for a way to something like that. As my phone has got a front LED (flash light for photos), I thought it would be nice to flash it on when something happens. Perhaps when I come home. So, I have found out that the front LED can be flashed on when you use the action to take a photo, choose front camera and the suitable setting of the flash.
But I don't want to take a photo. Especially, because you can't choose the pattern it should flash up. Moreover, I don't need a picture :D.
So what I am looking for: a way to include the front flash which should light up. If possible, the ability to set a pattern (something like that with the vibration; pause, vibrate, pause, vibrate...) because it always takes some time to activate and deactivate the LED. So, you don't need to set actions like pauses and flashs. But that could be a bit hard to implement I think. For now it would be enough just to able to control the front flash. Thanks in advance.

Regards,
Mar

User avatar
Desmanto
Posts: 1873
Joined: 21 Jul 2017 17:50

Re: Front LED/flash

Post by Desmanto » 01 Oct 2018 17:37

Sorry to bump old thread. But I just see the implementation of the dual flash app. A quick search show how to use java to turn on the front flash using Camera2 API : https://stackoverflow.com/questions/419 ... h-of-phone
Don't know if this work on all phone, but I have activated Camera2 API at my RN5 whyred, RR 6.2 Oreo 8.1. Using the script below, I can turn on/off the flash for back and front flash.

Code: Select all

cm = callJavaMethod(getContext(), "android.content.Context", "getSystemService(java.lang.String)", "camera");
callJavaMethod(cm, "android.hardware.camera2.CameraManager", "setTorchMode(java.lang.String, boolean)", 1, true)
Change 1 (front flash) to 0 for back flash. True and false is to turn on and off.

It will be much better if this is implemented directly into current action "Flashlight". Add option to choose back or front camera (if the phone support front flash). Will be nice also if we have the ability to set a pattern. So we can make it blink or act like a morse code.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), Resurrection Remix Official 7.0.2 20190714, Pie 9.0, Rooted.

wfrcrd
Posts: 116
Joined: 27 May 2015 08:57

Re: Front LED/flash

Post by wfrcrd » 18 Jan 2019 13:54

I've tried this script on my new phone wich has a little weak monochromatic led (that seems to be turned on just from pre installed apps),
and it's seems working good as a workaround for those who has the same problem.
It's necessary to build some "cicle" to turn the flash on /off and something else wich stops it automatically.
I hope this will not cause a huge battery drain.
I agree too, the implementation of this function into the "flashlight" action would be great!

Post Reply