Browse Source

Added BSD-Licence.tyt Readme.md for Release 1.00

master 1.00
Olli Graf 5 months ago
parent
commit
145f3a4034
  1. 11
      BSD-Licence.txt
  2. 5
      Readme.md
  3. 8
      SourceGenerator.py
  4. 6
      field.py
  5. 17
      r4matrixed.py
  6. 1
      requirements.txt

11
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.

5
Readme.md

@ -0,0 +1,5 @@
Tiny Editor for the Arduino Uno R4 Wifi LED Matrix
Published under BSD licence (see BSD-Licence.txt)

8
SourceGenerator.py

@ -6,18 +6,12 @@ class SourceGenerator:
def generate_source(self,field): def generate_source(self,field):
source = 'byte frame[8][12] ={\n' source = 'byte frame[8][12] ={\n'
logging.debug(f'frame= {field.frame}')
for line in range(0,len(field.frame)): for line in range(0,len(field.frame)):
logging.debug(f'proccessing line {line}')
curline = field.frame[line] curline = field.frame[line]
sourceline = '{ ' sourceline = '{ '
logging.debug(f'initialized sourceline= {sourceline}')
for col in range(0,len(curline)): for col in range(0,len(curline)):
logging.debug(f'processing column {col},adding {curline[col]}')
sourceline += '1, ' if curline[col] == 1 else '0, ' sourceline += '1, ' if curline[col] == 1 else '0, '
logging.debug(f'sourceline for ({line},{col})={sourceline}') sourceline += '},\n'
sourceline += '},\n' #if col < len(curline) else '}\n'
logging.debug(f'appending sourceline {sourceline}')
source = source + sourceline source = source + sourceline
source = source + '\n};' source = source + '\n};'
return source return source

6
field.py

@ -20,6 +20,12 @@ class Field:
self.changed = False 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): def togglePixel(self):
curline = self.frame[self.cursor[0]] curline = self.frame[self.cursor[0]]
curline[self.cursor[1]] = 0 if curline[self.cursor[1]] == 1 else 1 curline[self.cursor[1]] = 0 if curline[self.cursor[1]] == 1 else 1

17
r4matrixed.py

@ -6,6 +6,7 @@ import logging
from curses import wrapper from curses import wrapper
from SourceGenerator import SourceGenerator from SourceGenerator import SourceGenerator
__VERSION__ = '1.00'
logging.basicConfig( format='%(asctime)s [%(levelname)s] %(funcName)s: %(message)s', logging.basicConfig( format='%(asctime)s [%(levelname)s] %(funcName)s: %(message)s',
filename='r4.log', filename='r4.log',
@ -20,6 +21,15 @@ def display_source(stdscr,source):
stdscr.addstr(0,0,source) stdscr.addstr(0,0,source)
key = stdscr.getch() 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,'<<Press any key to return>>',curses.color_pair(3))
stdscr.getch()
def inputLoop(stdscr): def inputLoop(stdscr):
exitPrg = False exitPrg = False
curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK) curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK)
@ -33,7 +43,7 @@ def inputLoop(stdscr):
field.print_field(stdscr) field.print_field(stdscr)
key = stdscr.getkey() key = stdscr.getkey()
field.message = str(key) # field.message = str(key)
match key: match key:
case 'q': case 'q':
exitPrg = True exitPrg = True
@ -41,11 +51,14 @@ def inputLoop(stdscr):
generator = SourceGenerator() generator = SourceGenerator()
source = generator.generate_source(field) source = generator.generate_source(field)
display_source(stdscr,source) display_source(stdscr,source)
logging.debug(f'source={source}') case 'h':
display_help(stdscr)
case ' ': case ' ':
field.togglePixel() field.togglePixel()
case '^L': case '^L':
field.print_field(stdscr) field.print_field(stdscr)
case '0':
field.clear()
case 'KEY_DOWN': case 'KEY_DOWN':
if field.cursor[0] < len(field.frame)-1: if field.cursor[0] < len(field.frame)-1:
newcursor = (field.cursor[0] +1,field.cursor[1]) newcursor = (field.cursor[0] +1,field.cursor[1])

1
requirements.txt

@ -0,0 +1 @@
colorama==0.4.6
Loading…
Cancel
Save