Skip to content
This repository was archived by the owner on Apr 28, 2021. It is now read-only.

Commit 32a6c31

Browse files
committed
poweroff on pek long press
1 parent 1e0a92c commit 32a6c31

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

driver_axp209.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@ bool axp209_init(void) {
6060
}
6161
}
6262

63-
/* Set N_OE Shutdown delay to 3S*/
63+
/* Set PEK Long press delay to 2.5s*/
64+
err = i2c_smbus_write_byte_data(fd_axp209 , AXP209_REG_PEK_PARAMS, 0x9F);
65+
if(err < 0){
66+
printf("ERROR Setting AXP209 PEK Long press delay to 2.5s\n");
67+
}
68+
69+
/* Set N_OE Shutdown delay to 3s*/
6470
err = i2c_smbus_write_byte_data(fd_axp209 , AXP209_REG_32H, 0x47);
6571
if(err < 0){
6672
printf("ERROR Setting AXP209 N_OE Shutdown delay to 3S\n");

driver_axp209.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
// Chip registers adresses
1717
#define AXP209_REG_32H 0x32
18+
#define AXP209_REG_PEK_PARAMS 0x36
1819
#define AXP209_INTERRUPT_BANK_1_ENABLE 0x40
1920
#define AXP209_INTERRUPT_BANK_1_STATUS 0x48
2021
#define AXP209_INTERRUPT_BANK_2_ENABLE 0x41

gpio_mapping.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454

5555
#define KEY_IDX_MAPPED_FOR_SHORT_PEK_PRESS 16 //KEY_Q
5656
#define KEY_IDX_MAPPED_FOR_LONG_PEK_PRESS 28 //KEY_ENTER
57+
#define SHELL_CMD_LONG_PEK_PRESS "poweroff"
5758

5859

5960
/****************************************************************
@@ -410,7 +411,9 @@ int listen_gpios_interrupts(void)
410411
}
411412
if(val_int_bank_3 & AXP209_INTERRUPT_PEK_LONG_PRESS){
412413
GPIO_PRINTF(" AXP209 long PEK key press detected\n");
413-
sendKeyAndStopKey(KEY_IDX_MAPPED_FOR_LONG_PEK_PRESS);
414+
//sendKeyAndStopKey(KEY_IDX_MAPPED_FOR_LONG_PEK_PRESS); SHELL_CMD_LONG_PEK_PRESS
415+
GPIO_PRINTF("Apply mapping activation fct: shell command \"%s\"\n", SHELL_CMD_LONG_PEK_PRESS);
416+
system(SHELL_CMD_LONG_PEK_PRESS);
414417
}
415418
}
416419
#endif //ENABLE_AXP209_INTERRUPTS

0 commit comments

Comments
 (0)