📄 vibrator.c
字号:
#include <hardware/vibrator.h>#include <stdio.h>#include <unistd.h>#include <fcntl.h>#include <errno.h>#define THE_DEVICE "/sys/class/timed_output/vibrator/enable"static int sendit(int timeout_ms){ int nwr, ret, fd; char value[20]; fd = open(THE_DEVICE, O_RDWR); if(fd < 0) return errno; nwr = sprintf(value, "%d\n", timeout_ms); ret = write(fd, value, nwr); close(fd); return (ret == nwr) ? 0 : -1;}int vibrator_on(){ /* constant on, up to maximum allowed time */ return sendit(-1);}int vibrator_off(){ return sendit(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -