Skip to content

johanwheeler/arduino-uno-q-vs-code-workspace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VS Code workspace template for Ardunio Uno Q

This repository provides a Visual Studio Code workspace template for developing projects with the Arduino Uno Q microcontroller (without needing Arduino App Lab). It includes configurations and tasks to streamline the development process. Note that this is in early stages and mainly something I have put together for my own use, but can be useful for others as well. It might require some adjustments based on your specific setup (has been used on Linux).

Main Features and Benefits

Enables writing the Arduino sketch and Python code for Uno Q apps in VS Code. This enables:

  • Faster compile and upload cycles by compiling sketches locally and only flashing when changes are detected.
  • IntelliSense for Arduino C++ code using Arduino CLI installed libraries.
  • Local linting of Python code using a virtual environment with necessary dependencies.
  • Predefined tasks for common actions like starting/stopping the app, viewing logs, and more.
  • Usage of VS Code extensions.

Usage

  1. Clone or download this repository to get the .vscode folder. This contains the scripts for the different tasks.
  2. Place this folder in a directory where you want to create your Arduino Uno Q project.
  3. Open the directory in Visual Studio Code.
  4. Run the task Initialize New Arduino App Project which will set up multiple things:
    • Create an app folder for your App (arduino sketch and Python code).
    • Creates a python virtual environment with base dependencies for Uno Q development to enable local linting.
    • .vscode/c_cpp_properties.json is configured to use the Arduino CLI installed libraries for IntelliSense (arduino-cli has to be installed separately).
    • Tip: You might have to reload the VS Code window after this step for IntelliSense to work properly (Ctrl+Shift+P, then "Reload Window").
    • Note: If you already have an app folder (or copied the whole repo), you can skip this step and just configure the python virtual environment with the task Setup local Python environment.
  5. Start coding your Arduino sketch in app/sketch and your Python code in app/python.
  6. Code can be uploaded to the Uno Q with the task Fast deploy and run (Ctrl+Shift+B). This task performs multiple actions to enable fast development cycles:
    • It checks if the Arduino sketch has changed since the last upload using a hash comparison. If it has changed, it locally compiles and uploads the sketch to the Uno Q.
    • It pushes the Python code to the Uno Q.
    • It restarts the app on the Uno Q to run the updated code.
  7. Additional tasks are available for individual actions like viewing the Serial Monitor (Monitor output from the microcontroller), viewing Python logs, starting/stopping the app and more.

Requirements

  • Visual Studio Code
  • Arduino CLI installed and configured
  • ADB (Android Debug Bridge) installed for communication with the Uno Q
  • uv python package manager to create the virtual environment
  • Bash shell for running the provided scripts

Recommended VS Code Extensions

  • C/C++ Extension pack
  • Python

Limitations and future work

  • Currently tested on Linux only.
  • In order to avoid the Uno Q compiling the sketch again after the local compile and flashing has been performed, the sketch folder is not copied to the device like normal (it is copied under /hidden/ as reference). This is a workaround for how arduino-app-cli app start works currently (it wont find the sketch and therefore not compile and flash it) but also means that the Uno Q won't flash the sketch again on its own (if the app is started again later with another app running inbetween). It would be nicer to have a more elegant solution for this in the future.
  • If another app is started on the Uno Q, the script wont be able to stop or start a new app. This can be worked around by manually stopping the app first using adb shell arduino-app-cli app stop PATH_TO_RUNNING_APP before running the tasks again (or stopping from Arduino App Lab).
  • Uses ADB for now which is fast, further setup can enable wireless deployment (Modification of scripts to use SSH should be fairly straightforward).
  • More robust error handling.
  • Automatic setup of local Arduino CLI environment.
  • Further testing.

Further reading

About

Workspace and tasks for Arduino Uno Q development in VS Code without Arduino App Lab.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors