From c5b5e80de4928cf91be59e675429b520e31d873a Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 9 Jun 2016 18:50:08 +0300 Subject: [PATCH] Add support for emonPi the OpenEnergyMonitor system // Resolve #687 --- HISTORY.rst | 3 +++ docs/frameworks/arduino.rst | 20 ++++++++++++++++++++ docs/platforms/atmelavr.rst | 20 ++++++++++++++++++++ docs/platforms/embedded_boards.rst | 20 ++++++++++++++++++++ platformio/__init__.py | 2 +- platformio/boards/misc.json | 22 ++++++++++++++++++++++ platformio/builder/scripts/atmelavr.py | 13 +++++++------ 7 files changed, 93 insertions(+), 7 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 313a82cf..7009bae4 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -7,6 +7,9 @@ PlatformIO 2.0 2.9.5 (2016-06-??) ~~~~~~~~~~~~~~~~~~ +* Added support for `emonPi `__, + the OpenEnergyMonitor system + (`issue #687 `_) * Added support for `Arduboy DevKit `__, the game system the size of a credit card diff --git a/docs/frameworks/arduino.rst b/docs/frameworks/arduino.rst index ebb4d499..f7a4877a 100644 --- a/docs/frameworks/arduino.rst +++ b/docs/frameworks/arduino.rst @@ -1197,6 +1197,26 @@ OpenBCI - 128 Kb - 32 Kb +OpenEnergyMonitor +~~~~~~~~~~~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - Type ``board`` + - Name + - Microcontroller + - Frequency + - Flash + - RAM + + * - ``emonpi`` + - `emonPi `_ + - ATMEGA328P + - 16 MHz + - 32 Kb + - 2 Kb + PONTECH ~~~~~~~ diff --git a/docs/platforms/atmelavr.rst b/docs/platforms/atmelavr.rst index 64804ec9..58185e7c 100644 --- a/docs/platforms/atmelavr.rst +++ b/docs/platforms/atmelavr.rst @@ -812,6 +812,26 @@ Microduino - 64 Kb - 4 Kb +OpenEnergyMonitor +~~~~~~~~~~~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - Type ``board`` + - Name + - Microcontroller + - Frequency + - Flash + - RAM + + * - ``emonpi`` + - `emonPi `_ + - ATMEGA328P + - 16 MHz + - 32 Kb + - 2 Kb + PanStamp ~~~~~~~~ diff --git a/docs/platforms/embedded_boards.rst b/docs/platforms/embedded_boards.rst index ad63ea57..7095dd76 100644 --- a/docs/platforms/embedded_boards.rst +++ b/docs/platforms/embedded_boards.rst @@ -1562,6 +1562,26 @@ OpenBCI - 128 Kb - 32 Kb +OpenEnergyMonitor +~~~~~~~~~~~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - Type ``board`` + - Name + - Microcontroller + - Frequency + - Flash + - RAM + + * - ``emonpi`` + - `emonPi `_ + - ATMEGA328P + - 16 MHz + - 32 Kb + - 2 Kb + Outrageous Circuits ~~~~~~~~~~~~~~~~~~~ diff --git a/platformio/__init__.py b/platformio/__init__.py index ea54e00c..d5c24766 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (2, 9, "5.dev0") +VERSION = (2, 9, "5.dev1") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/boards/misc.json b/platformio/boards/misc.json index 92cd0d12..06c13e07 100644 --- a/platformio/boards/misc.json +++ b/platformio/boards/misc.json @@ -43,6 +43,28 @@ "vendor": "BitWizard" }, + "emonpi": { + "build": { + "core": "arduino", + "extra_flags": "-DARDUINO_ARCH_AVR -DAVR_EMONPI", + "f_cpu": "16000000L", + "mcu": "atmega328p", + "variant": "standard" + }, + "frameworks": ["arduino"], + "name": "emonPi", + "platform": "atmelavr", + "upload": { + "maximum_ram_size": 2048, + "maximum_size": 30720, + "protocol": "arduino", + "require_upload_port" : true, + "speed": 57600 + }, + "url": "https://github.com/openenergymonitor/emonpi", + "vendor": "OpenEnergyMonitor" + }, + "sainSmartDue": { "build": { "core": "arduino", diff --git a/platformio/builder/scripts/atmelavr.py b/platformio/builder/scripts/atmelavr.py index ff3ceadf..ae84cf21 100644 --- a/platformio/builder/scripts/atmelavr.py +++ b/platformio/builder/scripts/atmelavr.py @@ -49,18 +49,19 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 env.AutodetectUploadPort() env.Append(UPLOADERFLAGS=["-P", '"$UPLOAD_PORT"']) - if env.subst("$BOARD") == "raspduino": + if env.subst("$BOARD") in ("raspduino", "emonpi"): def _rpi_sysgpio(path, value): with open(path, "w") as f: f.write(str(value)) - _rpi_sysgpio("/sys/class/gpio/export", 18) - _rpi_sysgpio("/sys/class/gpio/gpio18/direction", "out") - _rpi_sysgpio("/sys/class/gpio/gpio18/value", 1) + pin_num = 18 if env.subst("$BOARD") == "raspduino" else 4 + _rpi_sysgpio("/sys/class/gpio/export", pin_num) + _rpi_sysgpio("/sys/class/gpio/gpio%d/direction" % pin_num, "out") + _rpi_sysgpio("/sys/class/gpio/gpio%d/value" % pin_num, 1) sleep(0.1) - _rpi_sysgpio("/sys/class/gpio/gpio18/value", 0) - _rpi_sysgpio("/sys/class/gpio/unexport", 18) + _rpi_sysgpio("/sys/class/gpio/gpio%d/value" % pin_num, 0) + _rpi_sysgpio("/sys/class/gpio/unexport", pin_num) else: if not upload_options.get("disable_flushing", False): env.FlushSerialBuffer("$UPLOAD_PORT")