~doctormo/doctormo-random/cheerled

« back to all changes in this revision

Viewing changes to cheer-graphic.py

  • Committer: Martin Owens (DoctorMO)
  • Date: 2009-03-17 11:48:48 UTC
  • Revision ID: doctormo@gmail.com-20090317114848-itel0d1cd1enuly2
Add two new programs to control the cheerled

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
#
 
3
# Copyright (C) 2009 Martin Owens
 
4
#
 
5
# This program is free software; you can redistribute it and/or modify
 
6
# it under the terms of the GNU General Public License as published by
 
7
# the Free Software Foundation; either version 3 of the License, or
 
8
# (at your option) any later version.
 
9
#
 
10
# This program is distributed in the hope that it will be useful,
 
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
# GNU General Public License for more details.
 
14
#
 
15
# You should have received a copy of the GNU General Public License
 
16
# along with this program; if not, write to the Free Software
 
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
#
 
19
 
 
20
import sys
 
21
import os
 
22
from cheerled import SlcDevice
 
23
 
 
24
def usage():
 
25
    """Print the usage of the tool"""
 
26
    return """
 
27
Usage:
 
28
 
 
29
  %s [DEVICE] Graphic
 
30
 
 
31
""" % sys.argv[0]
 
32
 
 
33
 
 
34
def set_image_messages(device, inputs):
 
35
    """Sets messages to the device"""
 
36
    set_file = False
 
37
    file = 1
 
38
    for input in inputs:
 
39
        if set_file:
 
40
            file = int(input)
 
41
            continue
 
42
        elif input == '-f':
 
43
            set_file = True
 
44
        else:
 
45
            device.graphic(input)
 
46
    device.send_message(file)
 
47
 
 
48
 
 
49
if len(sys.argv) < 3:
 
50
    print usage()
 
51
else:
 
52
    device = SlcDevice( sys.argv[1] )
 
53
    if device:
 
54
        set_image_messages(device, sys.argv[2:])
 
55
 
 
56