Torch/Flash

From WebOS Internals

Jump to: navigation, search

Contents

The Camera Flash LED - Background

This is a pretty cool device. I just did some research and concluded that Palm is using the Luxeon Flash LED after looking at available products. There is a PDF application note available [*http://www.philipslumileds.com/pdfs/DR01.PDF HERE] from the manufacturer.

According to the application note, the maximum steady state you can safely run the LED at with typical thermal treatment is 150ma. The Pre's hardware will let you drive it at 200ma steady-state, and 400ma or 500ma for a quarter of a second. (flash mode) Maybe Palm did a better thermal treatment and tested the LED to be steady-state capable at 200ma? This is an assumption, so it's probably best to keep it at 150ma or below. 100ma will be completely safe.

The Pre's battery contains almost 4 watt-hours of usable energy, but the battery protection system probably prevents you from using that last 1/2 watt-hour or so.

The current levels the hardware makes available for steady-state (flashlight) usage are: 50ma, 75ma, 100ma, 150ma, and maybe even 200ma if we limit on time.

Engineering calculations applied to the various current levels result in: 50ma: 20 hours of runtime, or 5% for 1 hour. 75ma: 14 hours of runtime, or 7% for 1 hour. 100ma: 10 hours of runtime, or 10% for 1 hour. 150ma: 6 hours of runtime, or 16% for 1 hour. 200ma: 4 hours of runtime, or 25% for 1 hour. (//but probably a BAD idea!//)

It's also possible to make a "strobe mode" that is 250ms on every second. Would be useful for dazzling a potential attacker or spontaneous sickening fun at parties!

Pretty cool stuff!

How to make your Pre a flashlight using the LED camera flash!

Turn the torch on

cd /sys/class/i2c-adapter/i2c-2/2-0033
echo -n 1 >avin
echo -n 100mA >torch_current
echo -n torch >mode

Turn the torch off

cd /sys/class/i2c-adapter/i2c-2/2-0033
echo -n shutdown >mode
echo -n 0mA >torch_current
echo -n 0 >avin

mode options

shutdown torch torch/flash

torch_current options

0mA 50mA 75mA 100mA 150mA 200mA* 250/400mA 250/500mA

Script the actions for later reuse

One for turning it on

nano -wc /opt/bin/torch-on  # or whatever you'd like to call it

#!/bin/sh
echo -n 1 >/sys/class/i2c-adapter/i2c-2/2-0033/avin
echo -n 100mA >/sys/class/i2c-adapter/i2c-2/2-0033/torch_current
echo -n torch >/sys/class/i2c-adapter/i2c-2/2-0033/mode

..and one for turning it off

nano -wc /opt/bin/torch-off  # or whatever you'd like to call it

#!/bin/sh
echo -n shutdown >/sys/class/i2c-adapter/i2c-2/2-0033/mode
echo -n 0mA >/sys/class/i2c-adapter/i2c-2/2-0033/torch_current
echo -n 0 >/sys/class/i2c-adapter/i2c-2/2-0033/avin

Here's a shell script that will accept a parameter to turn on or off the light.

cat > /opt/bin/flashlight.sh
#/bin/sh
# Written by firestorm_v1
case "$1" in
  on)
    echo -n 1 >/sys/class/i2c-adapter/i2c-2/2-0033/avin
    echo -n 50mA >/sys/class/i2c-adapter/i2c-2/2-0033/torch_current
    echo -n torch >/sys/class/i2c-adapter/i2c-2/2-0033/mode
    echo Flashlight is on
    ;;

  off)
    echo -n shutdown >/sys/class/i2c-adapter/i2c-2/2-0033/mode
    echo -n 0mA >/sys/class/i2c-adapter/i2c-2/2-0033/torch_current
    echo -n 0 >/sys/class/i2c-adapter/i2c-2/2-0033/avin
    echo Flashlight is off
    ;;
  *)
    echo flashlight \(on\|off\|help\)
    echo Turns on or off the "Flash"light on the Pre
    ;;
esac
# Ctrl-D

Usage:

$ flashlight on - Turns the flashlight on
$ flashlight off - Turns the flashlight off
$ flashlight help (or any other parameter not "on" or "off") - Displays flashlight usage.

In this implementation, I wanted to play it safe so I only have mine set to 50mA, but you can change the line to whatever you want. I would suggest keeping inline with the original warnings about running the flashlight too hot.

Concerns

We don't know the impact both electrically and thermally of running the torch over 100mA for extended periods of time, be careful or you may damage your Pre.

These instructions only apply to the Pre. Does anyone know how to interface with the torch on a Pixi?

Contributors

Thanks to scm6079 from Precentral for finding the device nodes, rennerik and dreadchicken for lighting it up and this page, Robi for the scripts to call directly, and pEEf for doing the LED research and runtime calculations.

Personal tools
Google AdSense