Language support for BCOS .capy application files.
Features
Syntax Highlighting
- Section markers (
[APP_NAME],[APP_ICON],[APP_CODE]) - Python code highlighting within
[APP_CODE]section - SVG content highlighting in
[APP_ICON]section - BCOS namespace highlighting (
bcos.hw.*,bcos.app.*,bcos.sys.*) - Comments, strings, numbers, keywords
Code Completion
- BCOS hardware devices (
bcos.hw.LED,bcos.hw.MPU6050, etc.) - BCOS API methods (
bcos.app.get_name(),bcos.sys.free_mem(), etc.) - Python keywords and built-in functions
- Common MicroPython modules (
machine,time,math)
Hover Documentation
- Section descriptions and usage examples
- BCOS hardware device documentation
- BCOS API method signatures and descriptions
- Python keyword documentation
Code Snippets
Type the following prefixes and press Tab:
| Prefix | Description |
|---|---|
capyapp |
Full .capy app template |
bcosled |
LED control code |
bcossensor |
Sensor reading code |
bcosdisplay |
Display text code |
bcosservo |
Servo control code |
bcosapp |
App info code |
bcossys |
System info code |
importbcos |
Import BCOS modules |
gpioread |
GPIO read setup |
gpiowrite |
GPIO write setup |
i2cinit |
I2C initialization |
spiinit |
SPI initialization |
adcread |
ADC read setup |
pwmout |
PWM output setup |
def |
Function definition |
class |
Class definition |
if |
If statement |
for |
For loop |
while |
While loop |
try |
Try-except block |
Commands
- Capy: Create New App - Create a new .capy file with template
- Capy: Run Current App - Run the current app on device
- Capy: Deploy to Device - Deploy app to BCOS device
Other Features
- Document outline (sections in symbol navigator)
- Code folding for sections
- Bracket matching and auto-closing
.capy File Format
[APP_NAME]=My Application
[APP_ICON]=<svg viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg">...</svg>
[APP_CODE]
import bcos
import time
led = bcos.hw.LED
while True:
led.on()
time.sleep(1)
led.off()
time.sleep(1)
Sections
[APP_NAME]- Application name displayed in LVGL desktop[APP_ICON]- SVG icon string for the application[APP_CODE]- Python code section start marker
BCOS API
Hardware Namespace (bcos.hw.*)
Access hardware devices defined in the topology file:
bcos.hw.LED- LED control (on/off/toggle)bcos.hw.MPU6050- IMU sensor (read/get_temp)bcos.hw.ST7789- LCD display (text/clear/show/fill)bcos.hw.SG90- Servo motor (set_angle)bcos.hw.NEO6M- GPS module (read/get_lat/get_lon)bcos.hw.Potentiometer- ADC input (read)bcos.hw.Relay- Relay module (on/off/toggle)
App Namespace (bcos.app.*)
bcos.app.get_name()- Get current app namebcos.app.get_count()- Get number of discovered apps
System Namespace (bcos.sys.*)
bcos.sys.free_mem()- Get free heap memory in bytesbcos.sys.restart()- Restart the system
Requirements
- VSCode 1.105.0 or later
- BCOS device connected via serial port (for run/deploy commands)
Extension Settings
This extension contributes the following settings:
capy.device.port- Serial port for BCOS device (default:COM3)capy.device.baudRate- Baud rate for serial connection (default:115200)capy.deploy.autoRun- Automatically run app after deployment (default:true)
Known Issues
- Serial communication for run/deploy commands is not yet implemented
- Hardware device list is hardcoded (should be read from topology file)
Release Notes
0.1.0
Initial release:
- Syntax highlighting for .capy files
- Code completion for BCOS API
- Hover documentation
- Code snippets
- Document outline and folding
- Create new app command
About BCOS
BCOS (Bad Capybara OS) is a modular embedded operating system designed for ESP32-based hardware. It uses MicroPython for application development and supports dynamic hardware topology configuration.
For more information, visit the BCOS project repository.