Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💻 Implemented "is" and sleep command for Micro:bit for level 2 #5587

Merged
merged 28 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a74ab64
Implemented "is" in Micro:bit
rmagedon97 Jun 3, 2024
6a2fa46
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 3, 2024
f32d60a
Adding the sleep command in Micro:bit
rmagedon97 Jun 3, 2024
ff08dec
Merge branch 'Microbit-Level_1' of https://github.com/hedyorg/hedy in…
rmagedon97 Jun 3, 2024
9db42bf
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 3, 2024
23b0c95
Adding a test for "is"
rmagedon97 Jun 3, 2024
4cab818
Merge branch 'Microbit-Level_1' of https://github.com/hedyorg/hedy in…
rmagedon97 Jun 3, 2024
4c2a803
fixed "is" test and added sleep test for Micro:bit
rmagedon97 Jun 3, 2024
e050f1a
Merge branch 'main' into Microbit-Level_1
rmagedon97 Jun 4, 2024
a7abf51
Merge branch 'main' into Microbit-Level_1
rmagedon97 Jun 4, 2024
40472ec
Add microbit transpiler classes with a separate lookup
boryanagoncharenko Jun 5, 2024
bad8416
Refactoring
rmagedon97 Jun 7, 2024
66fe55b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 7, 2024
a53594d
Merge branch 'main' into Microbit-Level_1
rmagedon97 Jun 7, 2024
7818514
Fixed the sleep command for level 2 and added tests
rmagedon97 Jun 9, 2024
1e82607
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 9, 2024
8c34c0f
Fixed assign function for MBit
rmagedon97 Jun 11, 2024
c77adae
Merge branch 'Microbit-Level_1' of https://github.com/hedyorg/hedy in…
rmagedon97 Jun 11, 2024
92c9445
Merge branch 'main' into Microbit-Level_1
rmagedon97 Jun 11, 2024
b576232
Merge branch 'main' into Microbit-Level_1
rmagedon97 Jun 14, 2024
34d6f71
Fixed the tests for sleep
rmagedon97 Jun 14, 2024
b81a2d8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 14, 2024
c178cc2
Fixed the 2 failing tests
rmagedon97 Jun 16, 2024
956cf14
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 16, 2024
a021e34
Merge branch 'main' into Microbit-Level_1
rmagedon97 Jun 16, 2024
9b10444
fix
rmagedon97 Jun 16, 2024
e5062e0
clear implemented
rmagedon97 Jun 16, 2024
2864866
Merge branch 'main' into Microbit-Level_1
mergify[bot] Jun 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,14 +803,26 @@ def save_transpiled_code_for_microbit(transpiled_python_code):
if not os.path.exists(folder):
os.makedirs(folder)
with open(filepath, 'w') as file:
custom_string = "from microbit import *\nwhile True:"
custom_string = "from microbit import *\nimport random"
file.write(custom_string + "\n")

# Add space before every display.scroll call
indented_code = transpiled_python_code.replace("display.scroll(", " display.scroll(")

# Append the indented transpiled code
file.write(indented_code)
# Splitting strings to new line, so it can be properly displayed by Micro:bit
processed_code = ""
lines = transpiled_python_code.split('\n')
for line in lines:
if "display.scroll" in line:
# Extract the content inside display.scroll()
match = re.search(r"display\.scroll\((.*)\)", line)
if match:
content = match.group(1)
parts = re.findall(r"'[^']*'|[^']+", content)
for part in parts:
if part.strip():
processed_code += f"display.scroll({part.strip()})\n"
else:
processed_code += line + "\n"

# Write the processed code
file.write(processed_code)


@app.route('/download_microbit_files/', methods=['GET'])
Expand Down
Loading
Loading