.. vim: set noexpandtab fileencoding=utf-8 nomodified wrap textwidth=200 foldmethod=marker foldcolumn=4 ruler showcmd lcs=tab\:|- list: .. title: Arduino CLI .. slug: Arduino-cli .. date: 2023-07-07 09:33:07 .. tags: AVR,gentoo .. category: AVR .. link: .. description: Zkouším arduino-cli .. type: text .. author: Gilhad .. |logo| image:: /images/logo/gilhad.png Zkouším arduino-cli ======================================= Chci mít možnost kompilovat \*.ino ze skriptu a sdílet knihovny .. TEASER_END .. section-numbering:: .. contents:: Content Nějak jsem nainstaloval arduino a arduino-cli a něco někde oklikal ... * asi jako root `curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=/usr/local/bin sh` * a jako user `arduino-cli core install arduino:avr` * `arduino-cli core update-index` .. code-block:: bash cat ~/bin/ac #!/bin/bash -x # vim: fileencoding=utf-8:nomodified:nowrap:textwidth=0:foldmethod=marker:foldcolumn=4:syntax=sh:filetype=sh:ruler:showcmd:lcs=tab\:|- list arduino-cli --config-file .config.yaml "$@" .. code-block:: text metrics: addr: 999666999 enabled: false directories: user: . * ta @#$% vyžaduje, aby ten soubor končil na .yaml i když ho výslovně uvedu jménem * a v defaultu má metrics povolené * a zkusím, jestli půjde použít i z aktuálního adresáře * ``__ .. code-block:: text $ ac board list + arduino-cli --config-file .config.yaml board list Port Protocol Type Board Name FQBN Core /dev/ttyACM0 serial Serial Port (USB) Arduino Mega or Mega 2560 arduino:avr:mega arduino:avr $ ac compile --fqbn arduino:avr:mega MyFirstSketch $ ac upload -p /dev/ttyACM0 --fqbn arduino:avr:mega MyFirstSketch * vypadá to, že to základně funguje, teď ještě knihovny ... * nový .config.yaml - `user: .` `enable_notification: false` `metrics: enabled: false` .. code-block:: text $ cat .config.yaml board_manager: additional_urls: [] build_cache: compilations_before_purge: 10 ttl: 720h0m0s daemon: port: XXXXXXXXXXX directories: data: /home/gilhad/.arduino15 downloads: /home/gilhad/.arduino15/staging user: . library: enable_unsafe_install: false logging: file: "" format: text level: info metrics: addr: XXXXXXXXX enabled: false output: no_color: false sketch: always_export_binaries: false updater: enable_notification: false * a Makefile (`LIBS = ../libs`) .. code-block:: text #!/bin/bash # vim: fileencoding=utf-8:nomodified:nowrap:textwidth=0:foldmethod=marker:foldcolumn=4:syntax=make:filetype=make:ruler:showcmd:lcs=tab\:|- list # include Make.color LIBS = ../libs BOARD = arduino:avr:mega PORT = /dev/ttyArduinoMega # PORT = /dev/ttyACM0 SPEED = 115200 CONFIG = ./.config.yaml VERBOSE = -v .PHONY: all upload monitor list clean help more_help all: ## Compile arduino-cli --config-file $(CONFIG) --library $(LIBS) compile $(VERBOSE) --fqbn $(BOARD) *.ino upload: ## Upload arduino-cli --config-file $(CONFIG) upload $(VERBOSE) -p $(PORT) --fqbn $(BOARD) . monitor: ## Serial connection screen $(PORT) $(SPEED); killall screen; killall screen; true # make chce uspech list: ## List of boards attached arduino-cli --config-file $(CONFIG) board list clean: ## does nothing now @echo "nothing to do" help: ## Show help about main commands {{{ @egrep -h '(^|[^#])##\s' $(MAKEFILE_LIST) | \ sed "s/^# /# /;s/{{{//;s/}}}//" | \ awk 'BEGIN {FS = ":.*?#[#] "}; {printf "$(shell echo -en $(COLORS))$(BRIGHTGREEN);$(BG_BLUE);$(BOLD)m%-15s$(shell echo -en $(COLORS))$(RESET)m %s\n", $$1, $$2}' @# awk %-15s fits string left, padding with spaces - works better than tabs # }}} more_help: ## Show help about all docummented targets {{{ @egrep -h '###?\s' $(MAKEFILE_LIST) | \ sed "s/^# /# /;s/{{{//;s/}}}//" | \ awk 'BEGIN {FS = ":.*?#[#] "}; {printf "$(shell echo -en $(COLORS))$(BRIGHTGREEN);$(BG_BLUE);$(BOLD)m%-15s$(shell echo -en $(COLORS))$(RESET)m %s\n", $$1, $$2}' # }}}