8.1 Android Lighting System _ Overall Framework

Source: Internet
Author: User

1. Framework

APP (Java language Implementation)

-------------------------------

JNI (c + + language implementation) provides an interface for Java to perform C functions down-access HAL

-------------------------------

HAL (c or C + + language implementation) encapsulates hardware operation details

-------------------------------

Driver (C language Implementation) operating hardware

If JNI is written by itself, then its interface only knows that the application can only write itself, so it must use the existing JNI of Android, but Hal and the driver can write their own, as long as the HAL can meet the requirements of JNI, then the application can be written by other people to access the driver through Universal JNI.

2. Android Lighting System Frame

App: Battery light app, notification light app, backlight app

---------------------

JNI:com_android_server_lights_LightsService.cpp

---------------------

HAL: Write Yourself: HAL_LIGHTS.C

---------------------

Drive: Write yourself: leds_4412.c

How to write:

(1): See function

Battery lights and notification lights: On the hardware is the same, color, flashing

Backlight: Adjust LCD brightness

(2): Write driver

Battery lamp and notification light: Three LEDs (red, green and blue respectively) together, drive operator 3 LEDs

Backlight: Control the duty ratio of the output PWM

(3): Write Hal

Dividing the hardware LEDs into different logic lights

JNI Requirements Analysis:

(1) Obtaining hw_modult_t structure

(2) Call Get_device, call Module->methods->open according to different name, get different light_device_t struct

See the source of JNI, you can see a lot of name, we wrote the HAL will only implement "light_id_backlight (backlight)", "Light_id_battery", "Light_id_notifications"

HAL provides analysis:

(1) Realizing hw_module_t

(2) Implement the Open function, according to different name return different light_device_t structure, which has hw_device_t structure and set_light function, so for different lights need to implement different set_light functions, in set_ Action Driver inside light function

Drive Analysis:

(1) operation of Red Green and blue three LEDs, to achieve light, off, flashing three functions;

(2) for backlight, set the PWM duty ratio

8.1 Android Lighting System _ Overall Framework

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.