Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> 怎樣添加一個自定義的LED燈?

怎樣添加一個自定義的LED燈?

編輯:關於Android編程

1. 修改如下兩個文件:
    alps/mediatek/custom/common/kernel/leds/inc/cust_leds.h
    -----------------------------------------------------------
    enum mt65xx_led_type
    {
        MT65XX_LED_TYPE_RED = 0,
        ... ...
        MT65XX_LED_TYPE_LCD,
        MT65XX_LED_TYPE_ABC,        // Add a new LED type
        MT65XX_LED_TYPE_TOTAL,
    };
 
 
   alps/mediatek/custom/YOUR_PRJ/kernel/leds/mt65xx/cust_leds.c
    ----------------------------------------------------------------
    static struct cust_mt65xx_led cust_led_list[MT65XX_LED_TYPE_TOTAL] = {
        {"red",               MT65XX_LED_MODE_NONE, -1,{0}},
        ... ...
        {"lcd-backlight",     MT65XX_LED_MODE_CUST, (int)Cust_SetBacklight,{0}},
 
        // Set LED params, Please refer to <Driver all in One>
        {"abc-backlight", MT65XX_LED_MODE_CUST, (int)Cust_SetBacklight_abc,{0}},
    };
  www.2cto.com
 
2. 重新編譯後,在Kernel log 裡可以看到如下信息:
--------------------------------------------------------------------
    <7>[    1.021967] (0)Registered led device: button-backlight
    <7>[    1.022013] (0)Registered led device: lcd-backlight
    <7>[    1.022072] (0)Registered led device: abc-backlight   // <------- !
 
3. 用如下命令查看新LED的 sysfs節點
adb shell ls /sys/devices/platform/leds-mt65xx/leds/
------------------------------------------------------------------------
    abc-backlight
    button-backlight
    lcd-backlight
  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved