Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Apr 25, 2021. It is now read-only.

Commit 627d58f

Browse files
committed
opos 업데이트
1 parent fdbc94d commit 627d58f

File tree

9 files changed

+51
-40
lines changed

9 files changed

+51
-40
lines changed

‎src/main/resources/assets/openpython/opos/boot/01_basic.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def input_handler():
1515

1616

1717
@event.register("key_down")
18-
def handle_key_down(_1, char, *_):
18+
def handle_key_down(_0, _1, char, *_):
1919
buf.append(char)
2020

2121

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import component
2+
3+
component.setup()

‎src/main/resources/assets/openpython/opos/boot/02_screen.py‎ renamed to ‎src/main/resources/assets/openpython/opos/boot/03_screen.py‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
import machine
22

3-
fromcomponentimport get_component, find_components
3+
import component
44
from monitor import Monitor, _set_monitor
55

6-
gpu = get_component("gpu")
6+
gpu = component.get_primary("gpu")
77

88
screen = None
9-
for screen in find_components("screen"):
9+
for screen in component.list("screen"):
1010
if screen.getKeyboards():
11+
component.set_primary("screen", screen.address)
1112
break
1213

1314
if gpu and screen:
14-
monitor = Monitor(gpu.address, gpu.type)
15-
monitor.bind(screen.address)
16-
w, h = monitor.maxResolution()
15+
monitor = Monitor(gpu)
16+
gpu.bind(screen.address)
17+
w, h = gpu.maxResolution()
1718
monitor.w, monitor.h = w, h
18-
monitor.setResolution(w, h)
19-
monitor.setBackground(0x000000)
20-
monitor.setForeground(0xFFFFFF)
21-
monitor.fill(1, 1, w, h, " ")
19+
gpu.setResolution(w, h)
20+
gpu.setBackground(0x000000)
21+
gpu.setForeground(0xFFFFFF)
22+
gpu.fill(1, 1, w, h, " ")
2223

2324

2425
@machine.hook_stdout

‎src/main/resources/assets/openpython/opos/lib/event.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
__all__ = ["register", "unregister", "setup"]
66

77
event = {}
8-
handlers = {}
98
lastInterrupt = None
109

1110
registered = {}
@@ -23,7 +22,7 @@ def signal_handler(ticks):
2322

2423
for handler in handlers:
2524
try:
26-
handler(*args)
25+
handler(name, *args)
2726
except BaseException as e:
2827
machine.debug("signal_handler exc => %s: %s" % (type(e).__name__, e))
2928

‎src/main/resources/assets/openpython/opos/lib/filesystem.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from uio import FileIO
22

3-
from component import Component, components
3+
from component import Component, list
44

55

66
class FileSystem:
77
def __init__(self, address):
8-
self.fs = Component(address, components()[address])
8+
self.fs = Component(address)
99
self.address = address
1010
self.readonly = self.fs.isReadOnly()
1111
self.cwd = "/"

‎src/main/resources/assets/openpython/opos/lib/monitor.py‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
__all__ = ["Monitor", "monitor", "_set_monitor"]
44

55

6-
class Monitor(Component):
7-
def __init__(self, address, type):
8-
super().__init__(address, type)
6+
class Monitor:
7+
def __init__(self, gpu: Component):
8+
self.gpu=gpu
99
self.w = 80
1010
self.h = 25
1111
self.x = 1
1212
self.y = 1
1313
self.bc = 0
1414

1515
def scroll(self):
16-
self.copy(1, 2, self.w, self.h, 0, - 1)
17-
self.fill(1, self.h, self.w, 1, " ")
16+
self.gpu.copy(1, 2, self.w, self.h, 0, - 1)
17+
self.gpu.fill(1, self.h, self.w, 1, " ")
1818

1919
def put(self, char: str):
2020
assert len(char) == 1
@@ -37,10 +37,10 @@ def put(self, char: str):
3737
self.bc -= 1
3838
elif char == "\b":
3939
self.x -= 1
40-
self.set(self.x, self.y, " ")
40+
self.gpu.set(self.x, self.y, " ")
4141
self.bc = 3
4242
else:
43-
self.set(self.x, self.y, char)
43+
self.gpu.set(self.x, self.y, char)
4444
self.x += 1
4545

4646

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
try:
2+
import usys as sys
3+
except ImportError:
4+
import sys
5+
6+
sys.modules["usys"] = sys
7+
# sys.modules["sys"] = sys
8+
9+
10+
class Process:
11+
def __init__(self, context):
12+
self.context = context
13+
14+
15+
def spawn(path):
16+
context = {'__name__': '__main__', '__path__': path}
17+
18+
try:
19+
# noinspection PyUnresolvedReferences
20+
execfile(path, context)
21+
except SystemExit as e:
22+
return e.code
23+
24+
return 0
Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
try:
2-
import usys as sys
3-
except ImportError:
4-
import sys
1+
from process import spawn
52

6-
sys.modules["usys"] = sys
7-
# sys.modules["sys"] = sys
8-
9-
10-
def spawn(path):
11-
context = {'__name__': '__main__', '__path__': path}
12-
13-
try:
14-
# noinspection PyUnresolvedReferences
15-
execfile(path, context)
16-
except SystemExit as e:
17-
return e.code
18-
19-
return 0
3+
__all__ = ["spawn"]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /