616b3d7ce00f91b04cc74b07a37facf4f60e867e
Stefan Schuermans begin of config file parsing

Stefan Schuermans authored 7 years ago

pyetherpix/examples/blink.py  1) #! /usr/bin/env python
pyetherpix/examples/blink.py  2) 
Stefan Schuermans copyright headers

Stefan Schuermans authored 7 years ago

pyetherpix/examples/blink.py  3) # python EtherPix library
pyetherpix/examples/blink.py  4) #
pyetherpix/examples/blink.py  5) # Copyright 2017 Stefan Schuermans <stefan schuermans info>
pyetherpix/examples/blink.py  6) #
pyetherpix/examples/blink.py  7) # This program is free software: you can redistribute it and/or modify
pyetherpix/examples/blink.py  8) # it under the terms of the GNU General Public License as published by
pyetherpix/examples/blink.py  9) # the Free Software Foundation, version 3 of the License.
pyetherpix/examples/blink.py 10) #
pyetherpix/examples/blink.py 11) #
pyetherpix/examples/blink.py 12) # This program is distributed in the hope that it will be useful,
pyetherpix/examples/blink.py 13) # but WITHOUT ANY WARRANTY; without even the implied warranty of
pyetherpix/examples/blink.py 14) # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
pyetherpix/examples/blink.py 15) # GNU General Public License for more details.
pyetherpix/examples/blink.py 16) #
pyetherpix/examples/blink.py 17) # You should have received a copy of the GNU Lesser General Public License
pyetherpix/examples/blink.py 18) # along with this program. If not, see <http://www.gnu.org/licenses/>.
pyetherpix/examples/blink.py 19) 
Stefan Schuermans begin of config file parsing

Stefan Schuermans authored 7 years ago

pyetherpix/examples/blink.py 20) import sys
Stefan Schuermans implement UDP packet output

Stefan Schuermans authored 7 years ago

pyetherpix/examples/blink.py 21) import time
pyetherpix/examples/blink.py 22) 
Stefan Schuermans implement reading image data

Stefan Schuermans authored 7 years ago

pyetherpix/examples/blink.py 23) from PIL import Image
pyetherpix/examples/blink.py 24) 
Stefan Schuermans begin of config file parsing

Stefan Schuermans authored 7 years ago

pyetherpix/examples/blink.py 25) import pyetherpix
pyetherpix/examples/blink.py 26) 
pyetherpix/examples/blink.py 27) 
pyetherpix/examples/blink.py 28) def main(argv):
pyetherpix/examples/blink.py 29)     if len(argv) < 2:
Stefan Schuermans parsing config file complete

Stefan Schuermans authored 7 years ago

pyetherpix/examples/blink.py 30)         print >>sys.stderr, "usage: %s <config.etp>" % argv[0]
pyetherpix/examples/blink.py 31)         return 2
Stefan Schuermans begin of config file parsing

Stefan Schuermans authored 7 years ago

pyetherpix/examples/blink.py 32)     config_file = argv[1]
Stefan Schuermans implement reading image data

Stefan Schuermans authored 7 years ago

pyetherpix/examples/blink.py 33)     # create display
Stefan Schuermans parsing config file complete

Stefan Schuermans authored 7 years ago

pyetherpix/examples/blink.py 34)     display = pyetherpix.Display(config_file)
Stefan Schuermans implement UDP packet output

Stefan Schuermans authored 7 years ago

pyetherpix/examples/blink.py 35)     (width, height) = display.get_size()
Stefan Schuermans python 3 compatibility

Stefan Schuermans authored 7 years ago

pyetherpix/examples/blink.py 36)     print("width %u, height %u" % (width, height))
Stefan Schuermans implement reading image data

Stefan Schuermans authored 7 years ago

pyetherpix/examples/blink.py 37)     # prepare "on" image (all white)
pyetherpix/examples/blink.py 38)     on = Image.new("RGB", (width, height), "white")
pyetherpix/examples/blink.py 39)     # blink
Stefan Schuermans python 3 compatibility

Stefan Schuermans authored 7 years ago

pyetherpix/examples/blink.py 40)     print("blink")
Stefan Schuermans implement UDP packet output

Stefan Schuermans authored 7 years ago

pyetherpix/examples/blink.py 41)     for i in range(5):
Stefan Schuermans python 3 compatibility

Stefan Schuermans authored 7 years ago

pyetherpix/examples/blink.py 42)         print("on")
Stefan Schuermans implement reading image data

Stefan Schuermans authored 7 years ago

pyetherpix/examples/blink.py 43)         display.data_image(on)
Stefan Schuermans implement UDP packet output

Stefan Schuermans authored 7 years ago

pyetherpix/examples/blink.py 44)         display.send()
pyetherpix/examples/blink.py 45)         time.sleep(0.5)
Stefan Schuermans python 3 compatibility

Stefan Schuermans authored 7 years ago

pyetherpix/examples/blink.py 46)         print("off")
Stefan Schuermans implement UDP packet output

Stefan Schuermans authored 7 years ago

pyetherpix/examples/blink.py 47)         display.data_clear()
pyetherpix/examples/blink.py 48)         display.send()
pyetherpix/examples/blink.py 49)         time.sleep(0.5)
Stefan Schuermans python 3 compatibility

Stefan Schuermans authored 7 years ago

pyetherpix/examples/blink.py 50)     print("done")
Stefan Schuermans implement reading image data

Stefan Schuermans authored 7 years ago

pyetherpix/examples/blink.py 51)     # close display
Stefan Schuermans implement UDP packet output

Stefan Schuermans authored 7 years ago

pyetherpix/examples/blink.py 52)     display.close()