pastebin - collaborative debugging tool
eckelmann.kpaste.net RSS


Quantron Linux gpio key poller, try 0.0.1
Posted by Anonymous on Thu 2nd Jan 2020 14:07
raw | new post

  1. # horrible abuse of bash to poll the Quantron imx keypad for key presses
  2. a=0
  3. b=0
  4. c=0
  5.  
  6. while true ; do
  7.         (( i=$(printf "2#"; printf "%d" $(cat /sys/class/gpio/gpio{61..68}/value) ) ))
  8.  
  9.         case $i in
  10.                 240) # no key pressed
  11.                         ;;
  12.                 176) # "C/100%" key
  13.                         (( a++, b=0, c=0 ))
  14.                         ;;
  15.                 224) # "enter" key
  16.                         (( a=0, b++, c=0 ))
  17.                         ;;
  18.                 208) # "ESC" key
  19.                         (( a=0, b=0, c++ ))
  20.                         ;;
  21.                 *)
  22.                         (( a=0, b=0, c=0 ))
  23.                         ;;
  24.         esac
  25.  
  26.         if (( (a+b+c) > 4 )) ; then
  27.                 printf "a=%d, b=%d, c=%d\n" $a $b $c
  28.                 exit 0
  29.         fi
  30.  
  31.         msleep 10
  32. done

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}





All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at