Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
device_xiaomi_onclite
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LMODroid-Devices
device_xiaomi_onclite
Commits
04b3e551
Commit
04b3e551
authored
5 years ago
by
Erfan Abdi
Committed by
Dhina17
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
onclite: light: Rewrite based on our LED driver
Change-Id: Ie09fc98d8a35fc56dc963c9f1a7adf1703698b6e
parent
9f47da16
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
light/Light.cpp
+8
-55
8 additions, 55 deletions
light/Light.cpp
light/android.hardware.light@2.0-service.onclite.rc
+6
-12
6 additions, 12 deletions
light/android.hardware.light@2.0-service.onclite.rc
with
14 additions
and
67 deletions
light/Light.cpp
+
8
−
55
View file @
04b3e551
...
...
@@ -27,27 +27,11 @@
#define LCD_LED LEDS "lcd-backlight/"
#define WHITE_LED LEDS "red/"
#define B
LINK
"b
link
"
#define B
REATH
"b
reath
"
#define BRIGHTNESS "brightness"
#define DELAY_OFF "delay_off"
#define DELAY_ON "delay_on"
#define MAX_BRIGHTNESS "max_brightness"
#define DUTY_PCTS "duty_pcts"
#define PAUSE_HI "pause_hi"
#define PAUSE_LO "pause_lo"
#define RAMP_STEP_MS "ramp_step_ms"
#define START_IDX "start_idx"
/*
* 15 duty percent steps.
*/
#define RAMP_STEPS 15
/*
* Each step will stay on for 150ms by default.
*/
#define RAMP_STEP_DURATION 150
/*
* Each value represents a duty percent (0 - 100) for the led pwm.
*/
static
int32_t
BRIGHTNESS_RAMP
[
RAMP_STEPS
]
=
{
0
,
12
,
25
,
37
,
50
,
72
,
85
,
100
,
85
,
72
,
50
,
37
,
25
,
12
,
0
};
namespace
{
/*
...
...
@@ -123,51 +107,20 @@ static void handleBacklight(const LightState& state) {
set
(
LCD_LED
BRIGHTNESS
,
brightness
);
}
/*
* Scale each value of the brightness ramp according to the
* brightness of the color.
*/
static
std
::
string
getScaledRamp
(
uint32_t
brightness
)
{
std
::
string
ramp
,
pad
;
for
(
auto
const
&
step
:
BRIGHTNESS_RAMP
)
{
ramp
+=
pad
+
std
::
to_string
(
step
*
brightness
/
0xFF
);
pad
=
","
;
}
return
ramp
;
}
static
void
handleNotification
(
const
LightState
&
state
)
{
uint32_t
whiteBrightness
=
getScaledBrightness
(
state
,
getMaxBrightness
(
WHITE_LED
MAX_BRIGHTNESS
));
/* Disable blinking */
set
(
WHITE_LED
B
LINK
,
0
);
set
(
WHITE_LED
B
REATH
,
0
);
if
(
state
.
flashMode
==
Flash
::
TIMED
)
{
/*
* If the flashOnMs duration is not long enough to fit ramping up
* and down at the default step duration, step duration is modified
* to fit.
*/
int32_t
stepDuration
=
RAMP_STEP_DURATION
;
int32_t
pauseHi
=
state
.
flashOnMs
-
(
stepDuration
*
RAMP_STEPS
*
2
);
int32_t
pauseLo
=
state
.
flashOffMs
;
if
(
pauseHi
<
0
)
{
//stepDuration = state.flashOnMs / (RAMP_STEPS * 2);
pauseHi
=
0
;
}
/* White */
set
(
WHITE_LED
START_IDX
,
0
*
RAMP_STEPS
);
set
(
WHITE_LED
DUTY_PCTS
,
getScaledRamp
(
whiteBrightness
));
set
(
WHITE_LED
PAUSE_LO
,
pauseLo
);
set
(
WHITE_LED
PAUSE_HI
,
pauseHi
);
set
(
WHITE_LED
RAMP_STEP_MS
,
stepDuration
);
set
(
WHITE_LED
DELAY_OFF
,
state
.
flashOffMs
);
set
(
WHITE_LED
DELAY_ON
,
state
.
flashOnMs
);
/* Enable blinking */
set
(
WHITE_LED
B
LINK
,
1
);
set
(
WHITE_LED
B
REATH
,
1
);
}
else
{
set
(
WHITE_LED
BRIGHTNESS
,
whiteBrightness
);
}
...
...
@@ -246,4 +199,4 @@ Return<void> Light::getSupportedTypes(getSupportedTypes_cb _hidl_cb) {
}
// namespace V2_0
}
// namespace light
}
// namespace hardware
}
// namespace android
\ No newline at end of file
}
// namespace android
This diff is collapsed.
Click to expand it.
light/android.hardware.light@2.0-service.onclite.rc
+
6
−
12
View file @
04b3e551
on boot
# leds light
chown system system /sys/class/leds/red/brightness
chown system system /sys/class/leds/red/blink
chown system system /sys/class/leds/red/duty_pcts
chown system system /sys/class/leds/red/pause_hi
chown system system /sys/class/leds/red/pause_lo
chown system system /sys/class/leds/red/ramp_step_ms
chown system system /sys/class/leds/red/start_idx
chown system system /sys/class/leds/red/breath
chown system system /sys/class/leds/red/delay_off
chown system system /sys/class/leds/red/delay_on
chmod 660 /sys/class/leds/red/blink
chmod 660 /sys/class/leds/red/duty_pcts
chmod 660 /sys/class/leds/red/pause_hi
chmod 660 /sys/class/leds/red/pause_lo
chmod 660 /sys/class/leds/red/ramp_step_ms
chmod 660 /sys/class/leds/red/start_idx
chmod 660 /sys/class/leds/red/breath
chmod 660 /sys/class/leds/red/delay_off
chmod 660 /sys/class/leds/red/delay_on
service light-hal-2-0 /vendor/bin/hw/android.hardware.light@2.0-service.onclite
class hal
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment