החל מ-27 במרץ 2025, מומלץ להשתמש ב-android-latest-release
במקום ב-aosp-main
כדי ליצור תרומות ל-AOSP. מידע נוסף זמין במאמר שינויים ב-AOSP.
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
התייחסות ל-Struct light_state_t
#include <
lights.h
>
הפרמטרים שאפשר להגדיר עבור תאורה נתונה.
לא כל הנורות צריכות לתמוך בכל הפרמטרים. אם אפשר לעשות משהו עם תאימות לאחור, כדאי לעשות זאת.
ההגדרה מופיעה בשורה
145
בקובץ
lights.h
.
המדיניות שבה המערכת משתמשת כדי לנהל את הבהירות של התאורה. בשלב זה, הערכים הם BRIGHTNESS_MODE_USER ו-BRIGHTNESS_MODE_SENSOR.
ההגדרה מופיעה בשורה
173
בקובץ
lights.h
.
צבע ה-LED ב-ARGB.
כאן צריך להשתדל כמיטב יכולתכם.
-
אם הנורה יכולה להאיר רק בצבע אדום או ירוק, אם הם מבקשים כחול, צריך להדליק ירוק.
-
אם אפשר ליצור רק שינוי הדרגתי של הבהירות, צריך להשתמש בנוסחה הזו: unsigned char brightness = ((77*((color>>16)&0x00ff))
-
(150*((color>>8)&0x00ff)) + (29*(color&0x00ff))) >> 8;
-
אם אפשר להפעיל או להשבית רק 0, 0 הוא מצב מושבת וכל ערך אחר הוא מצב מופעל.
צריך להתעלם מהבייט הגבוה. גורמים מבחוץ יגדירו אותו כ-0xff (שתואם ל-255 אלפא).
ההגדרה נמצאת בשורה
160
בקובץ
lights.h
.
ראו את הקבועים LIGHT_FLASH_*
ההגדרה מופיעה בשורה
165
בקובץ
lights.h
.
התיעוד של המבנה הזה נוצר מהקובץ הבא:
-
hardware/libhardware/include/hardware/
lights.h
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-27 (שעון UTC).
[[["התוכן קל להבנה","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 (שעון UTC)."],[],[],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)"]]