This commit is contained in:
thecarp 2015-05-29 06:02:47 +00:00
commit 7e6bc7a25b
5 changed files with 55 additions and 6 deletions

View File

@ -1 +0,0 @@
SUBSYSTEM=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c21c", MODE="0666"

2
91-g13.rules.tmpl Normal file
View File

@ -0,0 +1,2 @@
SUBSYSTEM=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c21c", MODE="0660", GROUP="!!GROUP!!"
KERNEL=="uinput", SUBSYSTEM=="misc", MODE="0660", GROUP="!!GROUP!!"

View File

@ -1,4 +1,7 @@
all: g13d pbm2lpbm GROUP = 'usb'
PREFIX = '.'
all: g13d pbm2lpbm 91-g13.rules clock.sh
g13d: g13.h g13.cc g13d: g13.h g13.cc
g++ -o g13d -std=c++0x g13.cc -lusb-1.0 g++ -o g13d -std=c++0x g13.cc -lusb-1.0
@ -6,6 +9,17 @@ g13d: g13.h g13.cc
pbm2lpbm: pbm2lpbm.c pbm2lpbm: pbm2lpbm.c
g++ -o pbm2lpbm pbm2lpbm.c g++ -o pbm2lpbm pbm2lpbm.c
91-g13.rules: 91-g13.rules.tmpl
sed 's/!!GROUP!!/${GROUP}/' 91-g13.rules.tmpl > 91-g13.rules
clock.sh: clock.sh.tmpl
sed 's|\!\!PREFIX\!\!|${PREFIX}|' clock.sh.tmpl > clock.sh
install: all
install -m 755 -D g13d ${PREFIX}/g13d
install -m 755 -D clock.sh ${PREFIX}/g13-clock.sh
install -m 755 -D pbm2lpbm ${PREFIX}/pbm2lpbm
package: package:
rm -Rf g13-userspace rm -Rf g13-userspace
mkdir g13-userspace mkdir g13-userspace
@ -13,4 +27,4 @@ package:
tar cjf g13-userspace.tbz2 g13-userspace tar cjf g13-userspace.tbz2 g13-userspace
rm -Rf g13-userspace rm -Rf g13-userspace
clean: clean:
rm -f g13 pbm2lpbm rm -f g13 pbm2lpbm clock.sh 91-g13.rules

View File

@ -2,11 +2,41 @@
** Installation ** Installation
Make sure you have boost and libusb-1.0 installed. Make sure you have boost and libusb-1.0 installed.
You should also create
Compile by running Compile by running
> make > make
If you want to run the daemon as user, put the file 91-g13.rules into /etc/udev/rules.d/ (or whatever directory your distribution uses). Note that the default prefix is ".". If you would like make install and
the clock shell script to use a different directory (such as /usr/local/bin)
then use the following:
> make PREFIX=/usr/local/bin
** Install for non-root use
In order to run the g13 deamon as a user, file permissions in /dev
need to be fixed. In order to do this you should do the following:
1. Create the group: sudo groupadd --system usb
2. add yourself and any other users who will use g13 to the new group:
sudo usermod -a -G usb USERNAME
3. copy the file 91-g13.rules into /etc/udev/rules.d/:
sudo cp 91-g13.rules /etc/udev/rules.d
4. run udevadm trigger
5. run: sudo make PREFIX='/usr/local/bin' install
If you are logged in as the user, you will need to logout and back in.
If you have problems check that /etc/udev/rules.d is the correct udev rules
location for your distribution.
If you would like to change the name of the group used, then use the following
option with make to change it:
> make clean
> make GROUP='newgroup'
** Running ** Running
Connect your device, then run ./g13, it should automatically find your device. Connect your device, then run ./g13, it should automatically find your device.

View File

@ -1,4 +1,8 @@
#!/bin/bash #!/bin/bash
PATH=$PATH:!!PREFIX!!
export PATH
center_x=30 center_x=30
center_y=20 center_y=20
diameter=18 diameter=18
@ -37,6 +41,6 @@ min_x=$(echo "scale=3;$center_x + $min_orig_y * s($min/60*(2*4*a(1)))" | bc -l)
min_y=$(echo "scale=3;$center_y - $min_orig_y * c($min/60*(2*4*a(1)))" | bc -l) min_y=$(echo "scale=3;$center_y - $min_orig_y * c($min/60*(2*4*a(1)))" | bc -l)
preparams="-size 160x43 xc:white -stroke black -fill white -draw \"circle 30,20 30,2\" -draw \"line 30,20 $sec_x,$sec_y\" -draw \"line 30,20 $min_x,$min_y\" -draw \"line 30,20 $hr_x,$hr_y\" " preparams="-size 160x43 xc:white -stroke black -fill white -draw \"circle 30,20 30,2\" -draw \"line 30,20 $sec_x,$sec_y\" -draw \"line 30,20 $min_x,$min_y\" -draw \"line 30,20 $hr_x,$hr_y\" "
postparams="-pointsize 16 -fill black -font Courier -draw \"text 60,15 '$Date'\" -draw \"text 68,35 '$Time'\" pbm:- " postparams="-pointsize 16 -fill black -font Courier -draw \"text 60,15 '$Date'\" -draw \"text 68,35 '$Time'\" pbm:- "
eval convert $preparams $ticks $postparams | ./pbm2lpbm > /tmp/g13-0 eval convert $preparams $ticks $postparams | pbm2lpbm > /tmp/g13-0
sleep 1 sleep 1
done done