LED (Flashlight) Toggle for Motorla Droid 2 Global

This is the place to post any code that you want to share with the community. Only completed scripts should be posted here.

LED (Flashlight) Toggle for Motorla Droid 2 Global

Postby Guitarman2010 » Sun Apr 21, 2013 1:21 am

Code: Select all
import sys
import android
import os

droid = android.Android()

def cls():
  os.system(['clear','cls'][os.name == 'nt'])
 
def turnon():
  light = open('/sys/class/leds/torch-flash/flash_light', 'w')
  light.write('1')
 
def turnoff():
  light = open('/sys/class/leds/torch-flash/flash_light', 'w')
  light.write('0')
 

title = 'Flashlight Toggle'
message = 'By. Guitarman2010'
droid.dialogCreateAlert(title,message)
droid.dialogSetPositiveButtonText('Ok')
droid.dialogShow()
response = droid.dialogGetResponse().result
yep = response['which'] == 'positive'


title = 'Flashlight Toggle'
droid.dialogCreateAlert(title)
droid.dialogSetPositiveButtonText('Shine')
droid.dialogShow()
response = droid.dialogGetResponse().result
light = response['which'] == 'positive'

if light:
  turnon()

cls()

title = 'Turn off'
droid.dialogCreateAlert(title)
droid.dialogSetPositiveButtonText('OFF')
droid.dialogShow()
response = droid.dialogGetResponse().result
dark = response['which'] == 'positive'

if dark:
  turnoff()

cls()
Guitarman2010
 
Posts: 18
Joined: Thu Mar 07, 2013 4:39 pm

Return to Completed Scripts

Who is online

Users browsing this forum: No registered users and 4 guests