-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.c
More file actions
61 lines (51 loc) · 1.91 KB
/
Copy pathexample.c
File metadata and controls
61 lines (51 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "liblinht-ctrl.h"
#include <unistd.h>
#define TRANSITION_DELAY_US 10000 // Delay between brightness steps (10ms)
// Smooth brightness transition function
void smooth_transition(uint8_t start_brightness, uint8_t end_brightness)
{
if (start_brightness > end_brightness) {
// Fade down
for (int brightness = start_brightness; brightness >= end_brightness; brightness--) {
linht_ctrl_lcd_backlight_set_brightness(brightness);
linht_ctrl_kbd_backlight_set_brightness(brightness);
usleep(TRANSITION_DELAY_US);
}
} else {
// Fade up
for (int brightness = start_brightness; brightness <= end_brightness; brightness++) {
linht_ctrl_lcd_backlight_set_brightness(brightness);
linht_ctrl_kbd_backlight_set_brightness(brightness);
usleep(TRANSITION_DELAY_US);
}
}
}
int main(void)
{
// 1. Test green LED using specific function
linht_ctrl_green_led_set(true);
sleep(1);
linht_ctrl_green_led_set(false);
// 2. Test red LED using generic GPIO function
linht_ctrl_gpio_set(LINHT_CTRL_GPIO2_PATH, LINHT_CTRL_RED_LED_PIN, true);
sleep(1);
linht_ctrl_gpio_set(LINHT_CTRL_GPIO2_PATH, LINHT_CTRL_RED_LED_PIN, false);
// 3. Test backlight control - turn off both backlights
linht_ctrl_lcd_backlight_off();
linht_ctrl_kbd_backlight_off();
sleep(1);
// 4. Test backlight control - turn on both backlights
linht_ctrl_lcd_backlight_on();
linht_ctrl_kbd_backlight_on();
sleep(2);
// 5. Test smooth transition from 255 to 0
smooth_transition(255, 0);
sleep(1);
// 6. Test smooth transition from 0 to 255
smooth_transition(0, 255);
sleep(1);
// 7. Final state - turn everything off
linht_ctrl_green_led_set(false);
linht_ctrl_gpio_set(LINHT_CTRL_GPIO2_PATH, LINHT_CTRL_RED_LED_PIN, false);
return 0;
}