Browse Source

poweroff on pek long press

Vincent-FK 4 years ago
parent
commit
32a6c31d2f
3 changed files with 12 additions and 2 deletions
  1. 7 1
      driver_axp209.c
  2. 1 0
      driver_axp209.h
  3. 4 1
      gpio_mapping.c

+ 7 - 1
driver_axp209.c

@@ -60,7 +60,13 @@ bool axp209_init(void) {
         }
     }	
 
-    /* Set N_OE Shutdown delay to 3S*/
+    /* Set PEK Long press delay to 2.5s*/
+    err = i2c_smbus_write_byte_data(fd_axp209 , AXP209_REG_PEK_PARAMS, 0x9F);
+    if(err < 0){
+        printf("ERROR Setting AXP209 PEK Long press delay to 2.5s\n");
+    }
+
+    /* Set N_OE Shutdown delay to 3s*/
     err = i2c_smbus_write_byte_data(fd_axp209 , AXP209_REG_32H, 0x47);
     if(err < 0){
         printf("ERROR Setting AXP209 N_OE Shutdown delay to 3S\n");

+ 1 - 0
driver_axp209.h

@@ -15,6 +15,7 @@
 
 // Chip registers adresses
 #define AXP209_REG_32H						0x32 
+#define AXP209_REG_PEK_PARAMS				0x36 
 #define AXP209_INTERRUPT_BANK_1_ENABLE		0x40 
 #define AXP209_INTERRUPT_BANK_1_STATUS		0x48 
 #define AXP209_INTERRUPT_BANK_2_ENABLE		0x41

+ 4 - 1
gpio_mapping.c

@@ -54,6 +54,7 @@
 
 #define KEY_IDX_MAPPED_FOR_SHORT_PEK_PRESS	16 	//KEY_Q
 #define KEY_IDX_MAPPED_FOR_LONG_PEK_PRESS	28 	//KEY_ENTER
+#define SHELL_CMD_LONG_PEK_PRESS			"poweroff"
 
 
 /****************************************************************
@@ -410,7 +411,9 @@ int listen_gpios_interrupts(void)
 		}
 		if(val_int_bank_3 & AXP209_INTERRUPT_PEK_LONG_PRESS){
 			GPIO_PRINTF("	AXP209 long PEK key press detected\n");
-			sendKeyAndStopKey(KEY_IDX_MAPPED_FOR_LONG_PEK_PRESS);
+			//sendKeyAndStopKey(KEY_IDX_MAPPED_FOR_LONG_PEK_PRESS); SHELL_CMD_LONG_PEK_PRESS
+			GPIO_PRINTF("Apply mapping activation fct: shell command \"%s\"\n", SHELL_CMD_LONG_PEK_PRESS);
+			system(SHELL_CMD_LONG_PEK_PRESS);
 		}
 	}
 #endif //ENABLE_AXP209_INTERRUPTS