Reorganize drivers and utility modules into lib/ subdirectory and update server and upload scripts
This commit is contained in:
@@ -43,17 +43,21 @@ To bypass the memory and protocol constraints of the microcontroller, we use a h
|
||||
* **[boot.py](boot.py)**: Automatically connects to Wi-Fi using credentials in `wifi_config.py` and renders connection logs on the screen.
|
||||
* **[main.py](main.py)**: Background execution loop. Handlers for buttons (manual dashboard refresh, LED state cycle), NeoPixel animation loop, and non-blocking MCP server requests.
|
||||
* **[mcp_server.py](mcp_server.py)**: The lightweight JSON-RPC server implementing the MCP tools list and call handlers.
|
||||
* **[audio_util.py](audio_util.py)**: Audio drivers for the ES7210 microphone array and the ES8311 speaker DAC. Implements sine-wave tone generation (`play_tone`), voice recording (`record_audio`), and file-based audio playing (`play_wav`).
|
||||
* **[rlcd.py](rlcd.py)**: Low-level FrameBuffer driver for the 4.2" Reflective LCD, including PBM loaders and screenshot exporters.
|
||||
* **[sd_util.py](sd_util.py)**: Mounting and filesystem management utility for the onboard microSD card slot.
|
||||
* **Hardware Drivers**:
|
||||
* [shtc3_util.py](shtc3_util.py) (Temperature & Humidity)
|
||||
* [rtc_util.py](rtc_util.py) (Hardware Real-Time Clock)
|
||||
* [battery_util.py](battery_util.py) (Voltage & Capacity reader)
|
||||
* [rgb_led_util.py](rgb_led_util.py) (WS2812 NeoPixel animations)
|
||||
* [button_util.py](button_util.py) (Key & Boot button debouncer)
|
||||
* [ble_util.py](ble_util.py) (Passive BLE scanning & UART)
|
||||
* **[wifi_config.py](wifi_config.py)**: Wi-Fi credentials. **(Do not commit real credentials to Git)**.
|
||||
* **`lib/`**: Hardware drivers and utility modules automatically searched by MicroPython:
|
||||
* **[audio_util.py](lib/audio_util.py)**: Audio drivers for the ES7210 microphone array and the ES8311 speaker DAC. Implements sine-wave tone generation (`play_tone`), voice recording (`record_audio`), and file-based audio playing (`play_wav`).
|
||||
* **[rlcd.py](lib/rlcd.py)**: Low-level FrameBuffer driver for the 4.2" Reflective LCD, including PBM loaders and screenshot exporters.
|
||||
* **[sd_util.py](lib/sd_util.py)**: Mounting and filesystem management utility for the onboard microSD card slot.
|
||||
* **[shtc3_util.py](lib/shtc3_util.py)**: Temperature & Humidity sensor utility.
|
||||
* **[rtc_util.py](lib/rtc_util.py)**: PCF85063 Hardware Real-Time Clock driver.
|
||||
* **[battery_util.py](lib/battery_util.py)**: Battery voltage and capacity reader.
|
||||
* **[rgb_led_util.py](lib/rgb_led_util.py)**: WS2812 NeoPixel animation manager.
|
||||
* **[button_util.py](lib/button_util.py)**: Boot/Key button debouncer utility.
|
||||
* **[ble_util.py](lib/ble_util.py)**: Passive BLE scanning and BLE UART interface.
|
||||
* **[ft6336u.py](lib/ft6336u.py)**: I2C Capacitive touchscreen controller driver.
|
||||
* **[ili9341.py](lib/ili9341.py)**: ILI9341 LCD driver.
|
||||
* **[st7796.py](lib/st7796.py)**: ST7796 LCD driver.
|
||||
* **[download_util.py](lib/download_util.py)**: Helper for streaming downloads to the local filesystem.
|
||||
|
||||
### Host-Side files
|
||||
* **[mcp_bridge.py](mcp_bridge.py)**: The stdio-to-HTTP LAN bridge connecting the LLM client to the board. Handles image resizing, dithering, and formatting.
|
||||
|
||||
@@ -510,6 +510,18 @@ class MCPServer:
|
||||
elif name == "write_file":
|
||||
path = str(args.get("path"))
|
||||
content = str(args.get("content"))
|
||||
# Auto-create parent directories on the device if present in the path
|
||||
import os
|
||||
parts = path.split('/')
|
||||
if len(parts) > 1:
|
||||
dir_path = ""
|
||||
for part in parts[:-1]:
|
||||
if part:
|
||||
dir_path = dir_path + "/" + part if dir_path else part
|
||||
try:
|
||||
os.mkdir(dir_path)
|
||||
except OSError:
|
||||
pass # Directory likely already exists
|
||||
with open(path, 'w') as f:
|
||||
f.write(content)
|
||||
return f"Successfully wrote {len(content)} characters to '{path}'."
|
||||
|
||||
+5
-4
@@ -54,10 +54,11 @@ def main():
|
||||
|
||||
# Upload new drivers, utilities, and updated scripts
|
||||
files_to_upload = [
|
||||
("st7796.py", "st7796.py"),
|
||||
("ft6336u.py", "ft6336u.py"),
|
||||
("battery_util.py", "battery_util.py"),
|
||||
("rgb_led_util.py", "rgb_led_util.py"),
|
||||
("lib/st7796.py", "lib/st7796.py"),
|
||||
("lib/ft6336u.py", "lib/ft6336u.py"),
|
||||
("lib/battery_util.py", "lib/battery_util.py"),
|
||||
("lib/rgb_led_util.py", "lib/rgb_led_util.py"),
|
||||
("lib/audio_util.py", "lib/audio_util.py"),
|
||||
("video_stream.py", "video_stream.py"),
|
||||
("mcp_server.py", "mcp_server.py"),
|
||||
("boot.py", "boot.py"),
|
||||
|
||||
Reference in New Issue
Block a user