LoginSignup
23
16

More than 5 years have passed since last update.

PlatformIO でライブラリを使う & 普通のライブラリを直接使う

Posted at

Arduino/mbed 等を CUI から抽象化して操作できるツール、PlatformIO は大変便利です。

参考: コマンドラインでArduino開発 : vim + platformio

ライブラリのインストールには、

# 良い感じの Timer ライブラリ無いかな〜
$ platformio lib search Timer
Found 7 libraries:

[ ID  ] Name             Compatibility         "Authors": Description
----------------------------------------------------------------------------------------------------------------------------------------
[ 75  ] Timer            arduino, atmelavr     "Jack Christensen, Simon Monk, Damian Philipp": Timer Library
[ 138 ] FlexiTimer2      arduino, atmelavr, teensy "Wim Leers, Paul Stoffregen": Arduino library to use timer 2 with a configurable resolution. Based on MsTimer2 by Javier Valencia. Written for the project associated with the "Mobile & Pervasive Computing" course at Hasselt University in Belgium.
[ 442 ] DueTimer         arduino, atmelsam     "Ivan Seidel": Timer Library fully implemented for Arduino DUE
[ 131 ] TimerOne         arduino, atmelavr, teensy "Paul Stoffregen": Allow to use the built-in 16 bit Timer1
[ 132 ] TimerThree       arduino, atmelavr, teensy "Paul Stoffregen": Allow to use the built-in 16 bit Timer3
[ 137 ] MsTimer2         arduino, atmelavr, teensy "Javier Valencia, Paul Stoffregen": MsTimer2 is a small and very easy to use library to interface Timer2 with humans. It's called MsTimer2 because it "hardcodes" a resolution of 1 millisecond on timer2.
[ 419 ] SimpleTimer      arduino, atmelavr     "Jean-Francois Turcot": SimpleTimer Library for Arduino
$ platformio lib install 137

のように CUI から行うことができます(ライブラリ名で入れたいけど…)。また追加したいライブラリがあったら、library.json をつくって

$ platformio lib install https://raw.githubusercontent.com/hotchpotch/arduino_ST7032/library-json/library.json

とすることで、PlatformIO 側に申請が行って、申請が通り次第利用できるようになります。

しかし、俺はライブラリをすぐ使いたいんじゃ!!!という場合は、~/.platformio/lib にライブラリを直接置けば利用できます。

cd ~/.platformio/lib
git clone https://github.com/tomozh/arduino_ST7032

簡単ですね!

Arduino の世界では、いちおうライブラリのエコシステムはあるのですが、CUI から使いやすい形にはなっていませんでした。PlatformIO がもっと流行って、開発がやりやすくなることを期待してます。

こんな感じ で PlatformIO の開発者たちがエコシステムを広げるため、地味に努力してるのも良いですね!

23
16
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
23
16