Skip to content
This repository was archived by the owner on Apr 25, 2021. It is now read-only.

Commit 791e16e

Browse files
committed
blink 구현
1 parent 5407f6c commit 791e16e

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

src/modules/component.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,23 @@ def __init__(self, gpu):
5151
self.widthPos = 1
5252
self.heightPos = 1
5353
self.backCount = 0
54+
self.blinkState = False
5455

5556
def __getattr__(self, item):
5657
return getattr(self.gpu, item)
5758

59+
def clearBlink(self):
60+
if self.blinkState:
61+
self.blink()
62+
63+
def setBlink(self):
64+
if not self.blinkState:
65+
self.blink()
66+
67+
def blink(self):
68+
self.blinkState = not self.blinkState
69+
self.gpu.set(self.widthPos, self.heightPos, "_" if self.blinkState else " ")
70+
5871
def scroll(self):
5972
self.gpu.copy(1, 2, self.widthSize, self.heightSize, 0, - 1)
6073
self.gpu.fill(1, self.heightSize, self.widthSize, 1, " ")
@@ -64,6 +77,9 @@ def put(self, buf: str):
6477
self.putChar(char)
6578

6679
def putChar(self, char):
80+
if self.blinkState:
81+
self.blink()
82+
6783
if char == "\n":
6884
self.widthPos = 1
6985
self.heightPos += 1

src/modules/handler.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616

1717
@machine.hook_input
1818
def input_handler():
19+
monitor.setBlink()
1920
while not buf:
20-
signal_handler()
21+
signal_handler(10)
22+
monitor.blink()
2123

2224
return int(buf.pop(0))
2325

@@ -26,6 +28,7 @@ def input_handler():
2628
def print_handler(buf):
2729
try:
2830
monitor.put(buf)
31+
monitor.blink()
2932
except BaseException as e:
3033
debug("print_handler exc =? %s: %s" % (type(e).__name__, e))
3134

0 commit comments

Comments
 (0)