• Building a Lights Library
  • Audio In this document
  • Android Platform Developer's Guide




    Download 1,28 Mb.
    bet7/95
    Sana22.12.2019
    Hajmi1,28 Mb.
    #4580
    1   2   3   4   5   6   7   8   9   10   ...   95

    Lights

    In this document


    • Building a Lights Library

    • Interface

    Android defines a user space C abstraction interface for LED hardware. The interface header is defined in hardware/libhardware/include/hardware/lights.h. In order to integrate LEDs with Android you need to build a shared library that implements this interface. The types of logical lights currently supported by Android include:

    • Backlight

    • Keyboard

    • Buttons

    • Battery

    • Notifications

    • Attention

    Building a Lights Library


    To implement a Lights driver, create a shared library that implements the interface defined in lights.h. You must name your shared library liblights.so so that it will get loaded from /system/lib at runtime.

    Interface


    Note: This document relies on some Doxygen-generated content that appears in an iFrame below. To return to the Doxygen default content for this page, click here.

    lights.h

    Go to the documentation of this file.

    00001 /*

    00002 * Copyright (C) 2008 The Android Open Source Project

    00003 *

    00004 * Licensed under the Apache License, Version 2.0 (the "License");

    00005 * you may not use this file except in compliance with the License.

    00006 * You may obtain a copy of the License at

    00007 *

    00008 * http://www.apache.org/licenses/LICENSE-2.0

    00009 *

    00010 * Unless required by applicable law or agreed to in writing, software

    00011 * distributed under the License is distributed on an "AS IS" BASIS,

    00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

    00013 * See the License for the specific language governing permissions and

    00014 * limitations under the License.

    00015 */

    00016

    00017 #ifndef ANDROID_LIGHTS_INTERFACE_H

    00018 #define ANDROID_LIGHTS_INTERFACE_H

    00019

    00020 #include

    00021 #include

    00022 #include

    00023

    00024 #include

    00025

    00026 __BEGIN_DECLS

    00027

    00028 /**

    00029 * The id of this module

    00030 */

    00031 #define LIGHTS_HARDWARE_MODULE_ID "lights"

    00032

    00033 /*

    00034 * These light IDs correspond to logical lights, not physical.

    00035 * So for example, if your INDICATOR light is in line with your

    00036 * BUTTONS, it might make sense to also light the INDICATOR

    00037 * light to a reasonable color when the BUTTONS are lit.

    00038 */

    00039 #define LIGHT_ID_BACKLIGHT "backlight"

    00040 #define LIGHT_ID_KEYBOARD "keyboard"

    00041 #define LIGHT_ID_BUTTONS "buttons"

    00042 #define LIGHT_ID_BATTERY "battery"

    00043 #define LIGHT_ID_NOTIFICATIONS "notifications"

    00044 #define LIGHT_ID_ATTENTION "attention"

    00045

    00046 /*

    00047 * These lights aren't currently supported by the higher

    00048 * layers, but could be someday, so we have the constants

    00049 * here now.

    00050 */

    00051 #define LIGHT_ID_BLUETOOTH "bluetooth"

    00052 #define LIGHT_ID_WIFI "wifi"

    00053

    00054 /* ************************************************************************

    00055 * Flash modes for the flashMode field of light_state_t.

    00056 */

    00057

    00058 #define LIGHT_FLASH_NONE 0

    00059

    00060 /**

    00061 * To flash the light at a given rate, set flashMode to LIGHT_FLASH_TIMED,

    00062 * and then flashOnMS should be set to the number of milliseconds to turn

    00063 * the light on, followed by the number of milliseconds to turn the light

    00064 * off.

    00065 */

    00066 #define LIGHT_FLASH_TIMED 1

    00067

    00068

    00069 /**

    00070 * The parameters that can be set for a given light.

    00071 *

    00072 * Not all lights must support all parameters. If you

    00073 * can do something backward-compatible, you should.

    00074 */

    00075 struct light_state_t {

    00076 /**

    00077 * The color of the LED in ARGB.

    00078 *

    00079 * Do your best here.

    00080 * - If your light can only do red or green, if they ask for blue,

    00081 * you should do green.

    00082 * - If you can only do a brightness ramp, then use this formula:

    00083 * unsigned char brightness = ((77*((color>>16)&0x00ff))

    00084 * + (150*((color>>8)&0x00ff)) + (29*(color&0x00ff))) >> 8;

    00085 * - If you can only do on or off, 0 is off, anything else is on.

    00086 *

    00087 * The high byte should be ignored. Callers will set it to 0xff (which

    00088 * would correspond to 255 alpha).

    00089 */

    00090 unsigned int color;

    00091

    00092 /**

    00093 * See the LIGHT_FLASH_* constants

    00094 */

    00095 int flashMode;

    00096 int flashOnMS;

    00097 int flashOffMS;

    00098 };

    00099

    00100 struct light_device_t {

    00101 struct hw_device_t common;

    00102

    00103 /**

    00104 * Set the provided lights to the provided values.

    00105 *

    00106 * Returns: 0 on succes, error code on failure.

    00107 */

    00108 int (*set_light)(struct light_device_t* dev,

    00109 struct light_state_t const* state);

    00110 };

    00111

    00112

    00113 __END_DECLS

    00114

    00115 #endif // ANDROID_LIGHTS_INTERFACE_H

    00116

    light_state_t Struct Reference

    The parameters that can be set for a given light. More...








    Data Fields

    unsigned int 

    color

     

    The color of the LED in ARGB.

    int 

    flashMode

     

    See the LIGHT_FLASH_* constants.

    int 

    flashOffMS

    int 

    flashOnMS

    Detailed Description

    The parameters that can be set for a given light.

    Not all lights must support all parameters. If you can do something backward-compatible, you should.

    Definition at line 75 of file lights.h.

    Field Documentation

    unsigned int light_state_t::color

    The color of the LED in ARGB.

    Do your best here.



    • If your light can only do red or green, if they ask for blue, you should do green.

    • If you can only do a brightness ramp, then use this formula: unsigned char brightness = ((77*((color>>16)&0x00ff)) + (150*((color>>8)&0x00ff)) + (29*(color&0x00ff))) >> 8;

    • If you can only do on or off, 0 is off, anything else is on.

    The high byte should be ignored. Callers will set it to 0xff (which would correspond to 255 alpha).

    Definition at line 90 of file lights.h.



    int light_state_t::flashMode

    See the LIGHT_FLASH_* constants.

    Definition at line 95 of file lights.h.



    int light_state_t::flashOffMS

    Definition at line 97 of file lights.h.

    int light_state_t::flashOnMS

    Definition at line 96 of file lights.h.

    Audio

    In this document


    • Building an Audio Library

    • Interface

    AudioHardwareInterface serves as the glue between proprietary audio drivers and the Android AudioFlinger service, the core audio service that handles all audio-related requests from applications.


    http://pdk.android.com/online-pdk/guide/images/android_audio_architecture.gif

    Solid elements represent Android blocks and dashed elements represent partner-specific blocks.



    Download 1,28 Mb.
    1   2   3   4   5   6   7   8   9   10   ...   95




    Download 1,28 Mb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    Android Platform Developer's Guide

    Download 1,28 Mb.