From eb89bd002c5af7612f2aa24881312711667dcc3e Mon Sep 17 00:00:00 2001 From: Sebastian Muszytowski Date: Sat, 27 Feb 2016 21:16:59 +0100 Subject: add makefile option for mass-programming with "make massprogram" which utilized the flasher.py utility. --- Makefile | 3 ++ utilities/flasher.py | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 utilities/flasher.py diff --git a/Makefile b/Makefile index 5328ab9..a80b709 100644 --- a/Makefile +++ b/Makefile @@ -53,6 +53,9 @@ build/main.elf: ${OBJECTS} @echo @avr-size --format=avr --mcu=${MCU} $@ +massprogram: all + python utilities/flasher.py "${AVRFLASH} -p ${MCU} -c ${AVRDUDE_PROGRAMMER} ${AVRFLAGS}" + flash: program program: build/main.hex #main.eep diff --git a/utilities/flasher.py b/utilities/flasher.py new file mode 100644 index 0000000..67f8c08 --- /dev/null +++ b/utilities/flasher.py @@ -0,0 +1,79 @@ +#!/usr/bin/python + +import sys +import os +from termcolor import colored + +try: + import tty, termios +except ImportError: + try: + import msvcrt + except ImportError: + raise ImportError('getch not available') + else: + getch = msvcrt.getch +else: + def getch(): + """getch() -> key character + + Read a single keypress from stdin and return the resulting character. + Nothing is echoed to the console. This call will block if a keypress + is not already available, but will not wait for Enter to be pressed. + + If the pressed key was a modifier key, nothing will be detected; if + it were a special function key, it may return the first character of + of an escape sequence, leaving additional characters in the buffer. + """ + fd = sys.stdin.fileno() + old_settings = termios.tcgetattr(fd) + try: + tty.setraw(fd) + ch = sys.stdin.read(1) + finally: + termios.tcsetattr(fd, termios.TCSADRAIN, old_settings) + return ch + +code_okay = """ + ####### ## ## ### ## ## +## ## ## ## ## ## ## ## +## ## ## ## ## ## #### +## ## ##### ## ## ## +## ## ## ## ######### ## +## ## ## ## ## ## ## + ####### ## ## ## ## ## +""" + +code_error = """ +######## ######## ######## ####### ######## +## ## ## ## ## ## ## ## ## +## ## ## ## ## ## ## ## ## +###### ######## ######## ## ## ######## +## ## ## ## ## ## ## ## ## +## ## ## ## ## ## ## ## ## +######## ## ## ## ## ####### ## ## +""" + +def printOkay(): + print colored(code_okay, 'green') + +def printError(): + print colored(code_error, 'red') + +flash_command = sys.argv[1] + +print colored("Using the following command to flash: ", "green") +print flash_command + +while True: + print colored("Press any key to continue or 'q' to quit.","yellow") + char = getch() + print char + if ord(char) is ord('q'): + sys.exit(0) + return_code = os.system(flash_command) + if return_code > 0: + printError() + else: + printOkay() + -- cgit v1.2.3