Make more tweaks

Best commit message. Ever.
master
LEdoian 3 years ago
parent 4fca06fcdf
commit 2ee3fd0ba0

@ -13,17 +13,28 @@ colors = {
BORDERCOLOR = (64,64,64) BORDERCOLOR = (64,64,64)
W = 1900 W = 1920
H = 1000 H = 1080
CELLSIZE = 7 CELLSIZE = 4
CELLBORDER = 1 CELLBORDER = 0
CELLMARGIN = 1 CELLMARGIN = 2
CELLOFFSET = CELLSIZE + 2*CELLBORDER + CELLMARGIN CELLOFFSET = CELLSIZE + 2*CELLBORDER + CELLMARGIN
COLUMNS = W // CELLOFFSET COLUMNS = W // CELLOFFSET
ROWS = H // CELLOFFSET ROWS = H // CELLOFFSET
CELLS = COLUMNS * ROWS CELLS = COLUMNS * ROWS
def get_symb(hist):
## Majority:
#symb, _count = max(hist.items(), key=lambda x: x[1])
#return symb
# The worst:
order = ['-', '/', '*', '?', '+']
for ch in order:
if ch in hist:
return ch
class Visualisation: class Visualisation:
def __init__(self, fn): def __init__(self, fn):
pygame.init() pygame.init()
@ -40,9 +51,8 @@ class Visualisation:
for cid in range(CELLS): for cid in range(CELLS):
start = cid * sqsz start = cid * sqsz
end = (cid + 1) * sqsz end = (cid + 1) * sqsz
hist = self.mapfile.get_hist(start, end).items() hist = self.mapfile.get_hist(start, end)
# Majority symb = get_symb(hist)
symb, _count = max(hist, key=lambda x: x[1])
color = colors[symb] color = colors[symb]
line = cid // COLUMNS line = cid // COLUMNS
@ -51,6 +61,10 @@ class Visualisation:
rect = pygame.Rect(col * CELLOFFSET + CELLBORDER, line * CELLOFFSET + CELLBORDER, CELLSIZE+2*CELLBORDER, CELLSIZE+2*CELLBORDER) rect = pygame.Rect(col * CELLOFFSET + CELLBORDER, line * CELLOFFSET + CELLBORDER, CELLSIZE+2*CELLBORDER, CELLSIZE+2*CELLBORDER)
pygame.draw.rect(self.disp, color, rect) pygame.draw.rect(self.disp, color, rect)
pygame.draw.rect(self.disp, BORDERCOLOR, rect, width=CELLBORDER) if CELLBORDER != 0: pygame.draw.rect(self.disp, BORDERCOLOR, rect, width=CELLBORDER)
pygame.display.flip() pygame.display.flip()
def reload(self):
self.mapfile.load()
self.draw()

@ -1,9 +1,13 @@
#!/bin/python3 #!/bin/python3
import ddresc_visu.draw as v import ddresc_visu.draw as v
from time import sleep
visu = v.Visualisation('/mnt/TAP9701/2021-08-11_Pm_ddresc_mapfile') FILE = '/mnt/TAP9701/2021-08-11_Pm_ddresc_mapfile'
visu = v.Visualisation(FILE)
visu.draw() def redraw():
visu.reload()
import time while True:
time.sleep(10) redraw()
sleep(5)

Loading…
Cancel
Save