自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
light_state_t 結構體參考資料
#include <
lights.h
>
可為特定燈具設定的參數。
並非所有燈具都支援所有參數。如果您可以進行回溯相容的操作,請務必這麼做。
定義位於檔案
lights.h
的
145
行。
架構用來管理燈光亮度的政策。目前的值為 BRIGHTNESS_MODE_USER 和 BRIGHTNESS_MODE_SENSOR。
定義位於檔案
lights.h
的
173
行。
ARGB 中的 LED 顏色。
請盡力完成這項作業。
-
如果你的燈具只能顯示紅色或綠色,如果對方要求顯示藍色,你就應該顯示綠色。
-
如果您只能執行亮度漸層,請使用以下公式:unsigned char brightness = ((77*((color>>16)&0x00ff))
-
(150*((color>>8)&0x00ff)) + (29*(color&0x00ff))) >> 8;
-
如果只能開啟或關閉,0 代表關閉,其他值則代表開啟。
系統應忽略高位元組。呼叫端會將其設為 0xff (對應於 255 的 alpha 值)。
定義位於檔案
lights.h
的
160
行。
這個結構體的說明文件是由下列檔案產生:
-
hardware/libhardware/include/hardware/
lights.h
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Android Hardware Abstraction Layer: light_state_t Struct Reference\n\nlight_state_t Struct Reference\n==============================\n\n[Data Fields](#pub-attribs) \nlight_state_t Struct Reference \n\n`\n#include \u003c\n`[lights.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h)`\n\u003e\n`\n\n|--------------|------------------------------------------------------------------------------------------|\n| Data Fields ----------- ||\n| unsigned int | [color](/reference/hal/structlight__state__t#aeedc2afa1e522527db2235d0700a3b0d) |\n| ||\n| int | [flashMode](/reference/hal/structlight__state__t#a1376dc4ef9189c6481681f82162911d5) |\n| ||\n| int | [flashOnMS](/reference/hal/structlight__state__t#a11119999eaf9274b752598740c137eee) |\n| ||\n| int | [flashOffMS](/reference/hal/structlight__state__t#a2a43b5608c96a4ce53d78e11cd718cf3) |\n| ||\n| int | [brightnessMode](/reference/hal/structlight__state__t#a29e93d1b3731de25515a118d9818517f) |\n| ||\n\n\nDetailed Description\n--------------------\n\n\nThe parameters that can be set for a given light.\n\n\nNot all lights must support all parameters. If you can do something backward-compatible, you should.\n\n\nDefinition at line\n[145](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h)\nof file\n[lights.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h)\n.\n\nField Documentation\n-------------------\n\n\n|--------------------|\n| int brightnessMode |\n\n\nPolicy used by the framework to manage the light's brightness. Currently the values are BRIGHTNESS_MODE_USER and BRIGHTNESS_MODE_SENSOR.\n\n\nDefinition at line\n[173](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h)\nof file\n[lights.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h)\n.\n\n|--------------------|\n| unsigned int color |\n\n\nThe color of the LED in ARGB.\n\n\nDo your best here.\n\n- If your light can only do red or green, if they ask for blue, you should do green.\n- If you can only do a brightness ramp, then use this formula: unsigned char brightness = ((77\\*((color\\\u003e\\\u003e16)\\&0x00ff))\n - (150\\*((color\\\u003e\\\u003e8)\\&0x00ff)) + (29\\*(color\\&0x00ff))) \\\u003e\\\u003e 8;\n- If you can only do on or off, 0 is off, anything else is on.\n\n\nThe high byte should be ignored. Callers will set it to 0xff (which would correspond to 255 alpha).\n\n\nDefinition at line\n[160](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h)\nof file\n[lights.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h)\n.\n\n|---------------|\n| int flashMode |\n\n\nSee the LIGHT_FLASH_\\* constants\n\n\nDefinition at line\n[165](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h)\nof file\n[lights.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h)\n.\n\n|----------------|\n| int flashOffMS |\n\n\nDefinition at line\n[167](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h)\nof file\n[lights.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h)\n.\n\n|---------------|\n| int flashOnMS |\n\n\nDefinition at line\n[166](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h)\nof file\n[lights.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h)\n.\n\n*** ** * ** ***\n\nThe documentation for this struct was generated from the following file:\n\n- hardware/libhardware/include/hardware/ [lights.h](https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/lights.h)"]]