Code Monkey home page Code Monkey logo

arduino-cli-mode's Introduction

arduino-cli-mode

arduino-cli-mode is an Emacs minor mode for using the excellent new arduino command line interface in an Emacs-native fashion. The mode covers the full range of arduino-cli features in an Emacs native fashion. It even leverages the infinite power the GNU to provide fussy-finding of libraries and much improved support for handling multiple boards. The commands that originally require multiple steps (such as first searching for a library and then separately installing it) have been folded into one.

Installation

The recommended way to install arduino-cli-mode is through melpa. Depending on if you use arduino-mode or not, you might want to load arduino-cli-mode either as a hook or as a mode. A sample configuration with use-package could look like this:

(use-package arduino-cli-mode
  :ensure t
  ;; :hook arduino-mode
  ;; :mode "\\.ino\\'"
  :custom
  (arduino-cli-warnings 'all)
  (arduino-cli-verify t))

Default boards

By default arduino-cli-mode uses the board list command from arduino-cli to determine which board to target. This works well most of the time, but sometimes fails due to connectivity issues. It also requires the target board to be connected, which might not always be possible. To cover these use cases you are able to set a default board (fqbn) and port via arduino-cli-default-fqbn and arduino-cli-default-port respectively. These can of course be set global via your init, but have found them to be an excellent fit for dir and file local variables. To get the fqbn/port information for a currently connected board, use arduino-cli-board-list.

Using default board variables should be a bit faster, as it eliminates the need to shelling out and then parse JSON from arduino-cli.

Customization

You can enable the major flags from arduino-cli using similar enumerations.

Flag Values
arduino-cli-verify nil (default), t
arduino-cli-warnings nil (default), 'default, 'more, 'all
arduino-cli-verbosity nil (default), 'quiet, 'verbose
arduino-cli-compile-only-verbosity nil, t (default)

If you want to automatically enable arduino-cli-mode on .ino files, you have to get auto-minor-mode. Once that is installed, add the following to your init:

(add-to-list 'auto-minor-mode-alist '("\\.ino\\'" . arduino-cli-mode))

Keymap

The default keymap prefix is C-c C-a and can be customized with arduino-cli-mode-keymap-prefix.

The following keybindings are provided out of the box.

Function Keymap
Compile C-c C-a c
Upload C-c C-a u
Compile and Upload C-c C-a b
List Connected Boards C-c C-a l
Create new sketch C-c C-a n
Install a Library C-c C-a i
Uninstall a Library C-c C-a u
Kill Arduino Connection C-c C-a k

Limitations

  • Does not support board attach commands
  • Only tested on macOS (but will probably work on other Unices)
  • Not called elduino-mode

What it is not

This mode is not an Arduino major mode, it only provides convenient access to arduino-cli. If you are looking for something like that, check out arduino-mode. In fact, I think they would complement each other rather well, as arduino-mode lacks support for arduino-cli, simply due to pre-dating it with a decade.

If you want auto-completion for Arduino development, see company-arduino.

Depending on your board, you might also enjoy platform-io-mode, an excellent wrapper that I took a lot of inspiration from while writing this one.

Contribute

This is my first real elisp project, so everything from code review to feature implementations are welcome! The plan is to support (more or less) the entire feature set of arduino-cli, and then go into maintenance mode.

arduino-cli-mode's People

Contributors

ahihi avatar motform avatar syohex avatar zck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

arduino-cli-mode's Issues

Symbol's function definition is void: mapcar*

Hi,
I managed to install arduino-cli and installed all core stuff, was able to compile in comandline with --fqbn arduino:avr:nano.
I managed to install your arduino-cli.el by copying to ~/.emacs.d/lisp/ and making request and I run some commands from emacs.
However - when trying to arduino-cli-compile it crashes. I dont know how to convince emacs to pass --fqbn parameter, which possibly makes the problem.

thank you
Jaro

Edit: I see I dont get my board recognized, one nano is connected via USB:

$ arduino-cli board list      
Port         Type              Board Name FQBN Core
/dev/ttyS4   Serial Port       Unknown             
/dev/ttyUSB0 Serial Port (USB) Unknown             

After some playing around, I found I cannot get the expected output fromarduino-cli board list. Can I somehow convince the arduino-cli-mode.el file about getting --fqbn and probably also the PORT from e.g. json file in the directory?

Issues

I am currently trying this out on Fedora 31 with Emacs 26.3 and found an issue with the following menu item in arduino-cli-mode.el.

Was:
["Compile Project" arduino-cli-build]

Should be:
["Compile Project" arduino-cli-compile]

This from version arduino-cli-mode-20200812.935 from elpa.

So far everything else seems to be working fine.

Improve doc

Hi:

Just a suggestion. In the use-package snippet you propose in the readme it is simpler to use this:

(use-package arduino-cli-mode
  :ensure t
  :mode "\\.ino\\'"
  :custom
  (arduino-cli-warnings 'all)
  (arduino-cli-verify t))

BTW: Does this mode conflicts with the arduino-mode?

https://github.com/stardiviner/arduino-mode

If not, maybe it is better to use a hook instead of the mode to have both.

Compile and upload absolute path

When I compile and upload, it seems to run the command "arduino-cli compile --fqbn arduino:avr:uno [absolute path]," with the absolute path to the file. I believe the proper command would be like this: "arduino-cli compile --fqbn arduino:avr:uno" without the path at the end.
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.