Repository navigation
MicroCS Studio
A browser IDE for boards running MicroCS: file manager, C# editor and REPL over USB (Web Serial). Visual Studio 2022 Dark look.
- Online: https://amir1387aht.github.io/MicroCS/
-
Offline: open
index.htmlin Chrome or Edge on a desktop (double-click works, no server or install). Keep the files together.
Click Connect, pick the board's serial port, done. Firefox and Safari have no Web Serial: the editor works there, but it can't connect to a board.
| File | What it holds |
|---|---|
index.html |
page layout |
studio.css |
look: Visual Studio 2022 Dark / Light, C# colours (--t-* variables) |
studio.js |
the app: serial link and shell protocol, editor, file manager, console |
templates/ |
the templates and examples: one folder per category, plain .cs files + a templates.txt describing them (how to add one) |
templates.js |
generated from templates/ by python3 gen_templates.py (the page loads it; CI checks it is current) |
snippets.js |
completion snippets (label, detail, text with $0 for the caret) |
api.js |
class and member names known to the runtime (completion fallback) |
docs.js |
signatures and one-line docs of every library member (completion details, parameter info, hover) |
lang.js |
C# language service: symbols of the open file, type inference, call context |
No build step for the app: edit a file and reload the page. After changing a template run
python3 tools/studio/gen_templates.py (or make studio-templates).
| Keys | Action |
|---|---|
| Ctrl+Space · Ctrl+Shift+Space | completion (with docs) · parameter info (↑/↓ switch overloads) |
| Ctrl+F · Ctrl+H · F3 / Shift+F3 | find · replace · next / previous match |
| Ctrl+G · Ctrl+] | go to line · jump to the matching bracket |
| Shift+Alt+F | format document |
| Alt+↑/↓ · Shift+Alt+↑/↓ · Ctrl+D · Ctrl+Shift+K | move line · copy line · duplicate · delete line |
| Ctrl+/ · Tab / Shift+Tab | toggle comment · indent / outdent |
| F5 / Ctrl+Enter · Ctrl+Shift+Enter · Ctrl+S | save and run · run the selection · save |
docs.js holds one line per member, e.g.
@GPIO | Digital pins (modules/hal)
Write(pin pin, bool value): void | Drives the pin: true / 1 = high, false / 0 = low
.Value: bool | (a leading "." = instance member) const Rising: int | constant
Repeat a line for each overload; new(...) lines are constructors.
Alt+T (or Templates) opens it: categories on the left (Recent holds the last ones you
used), search across names, descriptions and code (every word must match; name hits come
first and are highlighted), a preview with tags, line count, a copy button and a link to the
source file. ↑/↓, PgUp/PgDn, Home/End move, Enter adds the template as a new file
(named so it doesn't clash with an open tab), Ctrl+Enter inserts it at the cursor, Esc
clears the search, then closes. Saving a new file over an existing one on the device asks
first.
Studio leaves DTR/RTS as the browser opens the port (both asserted), which does not reset ESP32 boards with the usual auto-reset circuit or the native USB-Serial-JTAG. Reset board pulses EN like esptool. A board that sits in the ROM download mode is reset once automatically. If a board needs the lines low, enable ⋯ → Release DTR/RTS on connect.
Scheduler.Every / Scheduler.After jobs keep running after their script returns (and after
its file is deleted). So that re-running a script does not stack copies, Run first sends
cancel scripts (⋯ → Stop script jobs before each Run, on by default); jobs.cfg jobs are
left alone. ⋯ → Show running jobs lists them, ⋯ → Stop all jobs cancels every job until
the next reset.
Append to templates.js:
T("GPIO", "My blinker", "myblink.cs",
"One line shown in the list.", String.raw`
var led = new Pin(2, GPIO.Output);
led.Toggle();
`);String.raw keeps \n and other escapes as they are, so you can paste C# straight in.
node tests/studio/test_templates.js ./mcs compiles and runs every C# template on the
simulated board. Templates that use U8g2 / U8x8 start with an
if (!Drivers.Has("u8g2")) { ...; return; } hint and are run against the simulated OLED with a
u8g2 build: make fetch-u8g2 mcs-u8g2 && node tests/studio/test_templates.js build/mcs_u8g2 --only=u8g2.
tests/studio/test_studio.js tests the page in a headless browser.
Protocol and features: docs/STANDALONE.md.
Generated from the MicroCS repository - edit the files there, not in the wiki.
Start here
Step-by-step guides
- Guides
- Guide PC Simulator
- Guide ESP32
- Guide ESP32 C3 OLED
- Guide Raspberry Pi Pico
- Guide STM32
- Guide Arduino
- Guide Zephyr
- Guide Peripheral Settings
- Guide DMA
Hardware
- Hardware API
- Power Management
- Bluetooth LE
- Peripheral Configuration
- DMA
- Device Drivers
- Wi Fi and Networking
- U8g2 Displays
- Filesystem
- Threads
- Scheduler
Ports
- Porting and Build Systems
- Port ESP32
- Port RP2040 RP2350
- Port STM32
- Port STM32 Firmware
- Port Zephyr
- Port Arduino
C# and the runtime
Embedding and tuning
Internals
Project