yi-hack-Allwinner icon indicating copy to clipboard operation
yi-hack-Allwinner copied to clipboard

GPIO LED Control

Open ricardojlrufino opened this issue 3 years ago • 4 comments

Just sharing how to control LED directly via GPIO

  int fd;
    if ((fd = open("/dev/cpld_periph", O_RDWR)) < 0){
        printf("Open error on /dev/gpiog\n");
        exit(0);
    }

    printf("LED OFF \n");
    ioctl(fd, _IO(0x70, 0x1b), 0);

    sleep(2);

    printf("LED ON  \n");
    ioctl(fd, _IO(0x70, 0x1c), 0);

Only blue led at this time....

ricardojlrufino avatar Apr 05 '21 14:04 ricardojlrufino

Interesting...

roleoroleo avatar Apr 05 '21 16:04 roleoroleo

After using 0x1c to switch on the led, you can use:

ioctl(fd, _IO(0x70, 0x1), 0);   //blue on
ioctl(fd, _IO(0x70, 0x2), 0);   //blue off
ioctl(fd, _IO(0x70, 0x3), 0);   //blue blink fast
ioctl(fd, _IO(0x70, 0x4), 0);   //blue blink slow

ioctl(fd, _IO(0x70, 0x9), 0);   //orange on
ioctl(fd, _IO(0x70, 0xa), 0);   //orange off
ioctl(fd, _IO(0x70, 0xb), 0);   //orange blink fast
ioctl(fd, _IO(0x70, 0xc), 0);   //orange blink slow

roleoroleo avatar Apr 11 '21 08:04 roleoroleo

Yes, only this algorithm works on CN17, outdoor, etc. with Hi3518ev200. https://github.com/npetrovski/yi-home-led/tree/master/src

Arkady23 avatar Apr 11 '21 12:04 Arkady23

Using GPIOfs

  • Pinos do IR_CUT echo 235 > /sys/class/gpio/export echo 236 > /sys/class/gpio/export

echo out > /sys/class/gpio/gpio235/direction echo out > /sys/class/gpio/gpio236/direction

echo 0 > /sys/class/gpio/gpio235/value echo 1 > /sys/class/gpio/gpio236/value (red wire)

  • blue echo 237 > /sys/class/gpio/export echo out > /sys/class/gpio/gpio237/direction echo 1 > /sys/class/gpio/gpio237/value (active low)

  • Orange echo 145 > /sys/class/gpio/export echo out > /sys/class/gpio/gpio145/direction echo 1 > /sys/class/gpio/gpio145/value (active low)

ricardojlrufino avatar May 04 '22 21:05 ricardojlrufino

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Apr 06 '24 01:04 github-actions[bot]