added logging. implemented source generation of frame
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,4 +2,5 @@
|
||||
__pycache__
|
||||
lib
|
||||
bin
|
||||
*.log
|
||||
|
||||
|
24
SourceGenerator.py
Normal file
24
SourceGenerator.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import logging
|
||||
|
||||
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}')
|
||||
source = source + sourceline
|
||||
source = source + '\n};'
|
||||
return source
|
||||
|
@@ -2,31 +2,18 @@
|
||||
|
||||
from field import Field
|
||||
import curses
|
||||
import logging
|
||||
from curses import wrapper
|
||||
from SourceGenerator import SourceGenerator
|
||||
|
||||
|
||||
logging.basicConfig( format='%(asctime)s [%(levelname)s] %(funcName)s: %(message)s',
|
||||
filename='r4.log',
|
||||
level=logging.DEBUG)
|
||||
|
||||
|
||||
field = Field()
|
||||
|
||||
def generate_source():
|
||||
source = []
|
||||
|
||||
source.add('byte frame[8][12] =i {')
|
||||
for line in range(len(0,field.frame)):
|
||||
curline = field.frame[line]
|
||||
sourceline = '{'
|
||||
for col in range(0,len(curline)):
|
||||
pass
|
||||
|
||||
|
||||
def print_field():
|
||||
for line in range(0,len(field)):
|
||||
curline = field[line]
|
||||
|
||||
for col in range(0,len(curline)):
|
||||
if curline[col] == 0:
|
||||
print('o ', end='')
|
||||
else:
|
||||
print('x ', end='')
|
||||
print('\n',end='')
|
||||
|
||||
def inputLoop(stdscr):
|
||||
exitPrg = False
|
||||
curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK)
|
||||
@@ -44,6 +31,10 @@ def inputLoop(stdscr):
|
||||
match key:
|
||||
case 'q':
|
||||
exitPrg = True
|
||||
case 'g':
|
||||
generator = SourceGenerator()
|
||||
source = generator.generate_source(field)
|
||||
logging.debug(f'source={source}')
|
||||
case ' ':
|
||||
field.togglePixel()
|
||||
case '^L':
|
||||
|
Reference in New Issue
Block a user