À partir du 27 mars 2025, nous vous recommandons d'utiliser android-latest-release
au lieu de aosp-main
pour créer et contribuer à AOSP. Pour en savoir plus, consultez la section Modifications apportées à AOSP.
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Documentation de référence sur la struct light_state_t
#include <
lights.h
>
Paramètres pouvant être définis pour une lumière donnée.
Toutes les ampoules ne sont pas tenues de prendre en charge tous les paramètres. Si vous pouvez faire quelque chose de rétrocompatible, faites-le.
Définition à la ligne
145
du fichier
lights.h
.
Règle utilisée par le framework pour gérer la luminosité de la lumière. Actuellement, les valeurs sont BRIGHTNESS_MODE_USER et BRIGHTNESS_MODE_SENSOR.
Définition à la ligne
173
du fichier
lights.h
.
Couleur de l'entier sans signature
|
Couleur de la LED au format ARVB.
Faites de votre mieux.
-
Si votre lumière ne peut être que rouge ou verte, et qu'il demande du bleu, vous devez choisir le vert.
-
Si vous ne pouvez créer qu'une rampe de luminosité, utilisez cette formule: unsigned char brightness = ((77*((color>>16)&0x00ff))
-
(150*((color>>8)&0x00ff)) + (29*(color&0x00ff))) >> 8;
-
Si vous ne pouvez activer ou désactiver qu'une seule option, 0 correspond à la désactivation et tout autre nombre à l'activation.
L'octet supérieur doit être ignoré. Les appelants le définiront sur 0xff (ce qui correspond à 255 alpha).
Définition à la ligne
160
du fichier
lights.h
.
Consultez les constantes LIGHT_FLASH_*
Définition à la ligne
165
du fichier
lights.h
.
La documentation de ce struct a été générée à partir du fichier suivant :
-
hardware/libhardware/include/hardware/
lights.h
Le contenu et les exemples de code de cette page sont soumis aux licences décrites dans la Licence de contenu. Java et OpenJDK sont des marques ou des marques déposées d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/07/27 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Il n'y a pas l'information dont j'ai besoin","missingTheInformationINeed","thumb-down"],["Trop compliqué/Trop d'étapes","tooComplicatedTooManySteps","thumb-down"],["Obsolète","outOfDate","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Mauvais exemple/Erreur de code","samplesCodeIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 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)"]]