diff --git a/BSD-Licence.txt b/BSD-Licence.txt new file mode 100644 index 0000000..0906f42 --- /dev/null +++ b/BSD-Licence.txt @@ -0,0 +1,11 @@ +Copyright 2024 Olli Graf + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..52527e1 --- /dev/null +++ b/Readme.md @@ -0,0 +1,5 @@ +Tiny Editor for the Arduino Uno R4 Wifi LED Matrix + +Published under BSD licence (see BSD-Licence.txt) + + diff --git a/SourceGenerator.py b/SourceGenerator.py index 2235d50..3e28577 100644 --- a/SourceGenerator.py +++ b/SourceGenerator.py @@ -6,18 +6,12 @@ class SourceGenerator: def generate_source(self,field): source = 'byte frame[8][12] ={\n' - logging.debug(f'frame= {field.frame}') for line in range(0,len(field.frame)): - logging.debug(f'proccessing line {line}') curline = field.frame[line] sourceline = '{ ' - logging.debug(f'initialized sourceline= {sourceline}') for col in range(0,len(curline)): - logging.debug(f'processing column {col},adding {curline[col]}') sourceline += '1, ' if curline[col] == 1 else '0, ' - logging.debug(f'sourceline for ({line},{col})={sourceline}') - sourceline += '},\n' #if col < len(curline) else '}\n' - logging.debug(f'appending sourceline {sourceline}') + sourceline += '},\n' source = source + sourceline source = source + '\n};' return source diff --git a/field.py b/field.py index 886b0f5..61b1bfd 100644 --- a/field.py +++ b/field.py @@ -20,6 +20,12 @@ class Field: self.changed = False + def clear(self): + for line in range(0,len(self.frame)): + curline = self.frame[line] + for col in range(0,len(curline)): + curline[col] = 0 + def togglePixel(self): curline = self.frame[self.cursor[0]] curline[self.cursor[1]] = 0 if curline[self.cursor[1]] == 1 else 1 diff --git a/r4matrixed.py b/r4matrixed.py index 49e9904..6588b0f 100755 --- a/r4matrixed.py +++ b/r4matrixed.py @@ -6,6 +6,7 @@ import logging from curses import wrapper from SourceGenerator import SourceGenerator +__VERSION__ = '1.00' logging.basicConfig( format='%(asctime)s [%(levelname)s] %(funcName)s: %(message)s', filename='r4.log', @@ -20,6 +21,15 @@ def display_source(stdscr,source): stdscr.addstr(0,0,source) key = stdscr.getch() +def display_help(stdscr): + stdscr.clear() + stdscr.addstr(0,0,f'r4matrixed V {__VERSION__}') + stdscr.addstr(1,0,'h - Help') + stdscr.addstr(2,0,'g - generate Source') + stdscr.addstr(3,0,'q - Quit') + stdscr.addstr(6,0,'<>',curses.color_pair(3)) + stdscr.getch() + def inputLoop(stdscr): exitPrg = False curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK) @@ -33,7 +43,7 @@ def inputLoop(stdscr): field.print_field(stdscr) key = stdscr.getkey() - field.message = str(key) +# field.message = str(key) match key: case 'q': exitPrg = True @@ -41,11 +51,14 @@ def inputLoop(stdscr): generator = SourceGenerator() source = generator.generate_source(field) display_source(stdscr,source) - logging.debug(f'source={source}') - case ' ': + case 'h': + display_help(stdscr) + case ' ': field.togglePixel() case '^L': field.print_field(stdscr) + case '0': + field.clear() case 'KEY_DOWN': if field.cursor[0] < len(field.frame)-1: newcursor = (field.cursor[0] +1,field.cursor[1]) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e9405b3 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +colorama==0.4.6