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

Micropython support for Raspberry Pi Simulator #76

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
38a0010
Micropython starts on raspberry simulator load
silbogdan Jul 5, 2021
ea60fb3
Program MicroPython from Monaco Editor
silbogdan Jul 6, 2021
080ba07
Merge branch 'wyliodrinstudio:master' into micropython-dev
silbogdan Jul 6, 2021
dab3a7c
Fixed wrong path
silbogdan Jul 7, 2021
1bb6a40
Added more GPIO pins
silbogdan Jul 7, 2021
495e7f1
Function to read file names
silbogdan Jul 8, 2021
c13d541
Merge branch 'micropython-dev' of https://github.com/silbogdan/Wyliod…
silbogdan Jul 8, 2021
9cf502d
Cleaning libraries from python code
silbogdan Jul 8, 2021
ca3a10f
Mocking RPi.GPIO library
silbogdan Jul 12, 2021
a01bb2e
Python can be runned for Raspberry simulator
silbogdan Jul 12, 2021
fd5f486
More comments
silbogdan Jul 12, 2021
411b6a4
Visual run button fix
silbogdan Jul 13, 2021
b7e17c9
Comma fix
silbogdan Jul 13, 2021
1f32c2e
More checks and todo update
silbogdan Jul 20, 2021
3cd9612
Support for input pins
silbogdan Jul 22, 2021
e694c8b
Micropython runs on separate thread (WEB ONLY)
silbogdan Jul 23, 2021
ffb07a1
Fixed filenames
silbogdan Jul 26, 2021
e2f022d
Fixed workers for electron
silbogdan Jul 27, 2021
23ce1de
Removed extra file
silbogdan Jul 27, 2021
68f1e15
Merge branch 'master' into micropython-dev
silbogdan Jul 27, 2021
6307579
Worker thread terminates on simulator disconnect
silbogdan Jul 27, 2021
ac7c957
Merge branch 'micropython-dev' of https://github.com/silbogdan/Wyliod…
silbogdan Jul 27, 2021
58301a6
Tweaks: stop button and worker reload
silbogdan Jul 28, 2021
0837feb
LCD Print
silbogdan Aug 11, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12",
"webpack-node-externals": "^1.7.2",
"worker-plugin": "^5.0.1",
"xml-js": "^1.6.11",
"xterm": "^4.8.1"
},
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import machine

# Mapping BCM to Board
# ! generic_raspberrypi has Board - 1
BoardToBCM = {
"3": 2,
"5": 3,
"7": 4,
"29": 5,
"31": 6,
"26": 7,
"24": 8,
"21": 9,
"19": 10,
"23": 11,
"32": 12,
"33": 13,
"8": 14,
"10": 15,
"36": 16,
"11": 17,
"12": 18,
"35": 19,
"38": 20,
"40": 21,
"15": 22,
"16": 23,
"18": 24,
"22": 25,
"37": 26
}

def convertToBCM(pin, isBoard):
if isBoard == 100:
return int(BoardToBCM[str(pin)])
else:
return pin

class GPIO:
HIGH = 1
LOW = 0
BOARD = 100
BCM = 0
IN = -5
OUT = 5

def setmode(mode):
if mode == GPIO.BOARD:
GPIO.BOARD = 100
elif mode == GPIO.BCM:
GPIO.BOARD = -100

# To do: create logic
def setup(givenPin, mode, pull_up_down='pull_up_down=GPIO.PUD_DOWN'):
return True

def output(givenPin, mode):
givenPin = convertToBCM(givenPin, GPIO.BOARD)
pin = machine.Pin(str(givenPin))
if mode == GPIO.HIGH or mode == True or mode == 1:
pin(1)
elif mode == GPIO.LOW or mode == False or mode == 0:
pin(0)

def input(givenPin):
givenPin = convertToBCM(givenPin, GPIO.BOARD)
pin = machine.Pin(str(givenPin))
return pin()
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
scl = machine.Pin('X9')
sda = machine.Pin('X10')
i2c = machine.I2C(scl=scl, sda=sda)

class CharLCD:
def __init__(self, cols, rows, pin_rs, pin_e, pins_data):
self.cols = cols
self.rows = rows
self.pin_rs = pin_rs
self.pin_e = pin_e
self.pins_data = pins_data

cursor_pos = ()
def write_string(self, buffer):
i2c.writeto(8, buffer)