From 3f8d6869b98f7a62c1360a96c7edfc0e6e160bbd Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 10 Sep 2016 18:00:15 +0300 Subject: [PATCH] Cleanup code --- builder/frameworks/arduino.py | 32 ++++++++++++++++++++------------ builder/main.py | 11 +++++++---- platform.json | 2 +- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/builder/frameworks/arduino.py b/builder/frameworks/arduino.py index 42cbabc..8b23811 100644 --- a/builder/frameworks/arduino.py +++ b/builder/frameworks/arduino.py @@ -1,4 +1,4 @@ -# Copyright 2014-present Ivan Kravets +# Copyright 2014-present PlatformIO # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,8 +22,7 @@ kinds of creative coding, interactive objects, spaces or physical experiences. http://www.stm32duino.com """ -from os import walk -from os.path import isdir, isfile, join +from os.path import isdir, join from SCons.Script import DefaultEnvironment @@ -31,7 +30,8 @@ env = DefaultEnvironment() platform = env.PioPlatform() if "stm32f103" in env.BoardConfig().get("build.mcu", ""): - FRAMEWORK_DIR = join(platform.get_package_dir("framework-arduinoststm32"), "STM32F1") + FRAMEWORK_DIR = join(platform.get_package_dir( + "framework-arduinoststm32"), "STM32F1") env.Append( CPPDEFINES=[ "ERROR_LED_PORT=GPIOB", @@ -39,12 +39,17 @@ if "stm32f103" in env.BoardConfig().get("build.mcu", ""): "ARDUINO_ARCH_STM32F1" ] ) - if "stm32f103r8" or "stm32f103rb" in env.BoardConfig().get("build.mcu", ""): - env.Append(CPPDEFINES=["BOARD_generic_stm32f103r8", "ARDUINO_GENERIC_STM32F103R"]) - elif "stm32f103rc" or "stm32f103re" in env.BoardConfig().get("build.mcu", ""): - env.Append(CPPDEFINES=["BOARD_generic_stm32f103r", "ARDUINO_GENERIC_STM32F103R"]) + if "stm32f103r8" or "stm32f103rb" in env.BoardConfig().get( + "build.mcu", ""): + env.Append(CPPDEFINES=[ + "BOARD_generic_stm32f103r8", "ARDUINO_GENERIC_STM32F103R"]) + elif "stm32f103rc" or "stm32f103re" in env.BoardConfig().get( + "build.mcu", ""): + env.Append(CPPDEFINES=[ + "BOARD_generic_stm32f103r", "ARDUINO_GENERIC_STM32F103R"]) elif "stm32f103c" in env.BoardConfig().get("build.mcu", ""): - env.Append(CPPDEFINES=["BOARD_generic_stm32f103c", "ARDUINO_GENERIC_STM32F103C"]) + env.Append(CPPDEFINES=[ + "BOARD_generic_stm32f103c", "ARDUINO_GENERIC_STM32F103C"]) elif "stm32f103rb_maple" in env.BoardConfig().get("build.mcu", ""): env.Append(CPPDEFINES=["BOARD_maple", "ARDUINO_MAPLE_REV3"]) @@ -67,7 +72,8 @@ env.Append( ], LIBPATH=[ - join(FRAMEWORK_DIR, "variants", env.BoardConfig().get("build.variant"), "ld") + join(FRAMEWORK_DIR, "variants", + env.BoardConfig().get("build.variant"), "ld") ] ) @@ -85,7 +91,8 @@ if env.subst("$UPLOAD_PROTOCOL") == "dfu": if "stm32f103rb_maple" in env.BoardConfig().get("build.mcu", ""): env.Append(CPPDEFINES=["VECT_TAB_ADDR=0x8005000", "SERIAL_USB"]) else: - env.Append(CPPDEFINES=["VECT_TAB_ADDR=0x8002000", "SERIAL_USB", "GENERIC_BOOTLOADER"]) + env.Append(CPPDEFINES=[ + "VECT_TAB_ADDR=0x8002000", "SERIAL_USB", "GENERIC_BOOTLOADER"]) env.Replace(LDSCRIPT_PATH=ld) else: env.Append(CPPDEFINES=["VECT_TAB_ADDR=0x8000000"]) @@ -110,7 +117,8 @@ libs = [] if "build.variant" in env.BoardConfig(): env.Append( CPPPATH=[ - join(FRAMEWORK_DIR, "variants", env.BoardConfig().get("build.variant")) + join(FRAMEWORK_DIR, "variants", + env.BoardConfig().get("build.variant")) ] ) libs.append(env.BuildLibrary( diff --git a/builder/main.py b/builder/main.py index 9040d3e..2de4f4f 100644 --- a/builder/main.py +++ b/builder/main.py @@ -156,16 +156,19 @@ if "arduino" in env.subst("$PIOFRAMEWORK"): uploadParams = "{upload.altID} {upload.usbID} $PROJECT_DIR/$SOURCES" elif env.subst("$UPLOAD_PROTOCOL") == "dfu": uploadProtocol = "maple_upload" - usbids = env.BoardConfig().get("build.hwids", "") + usbids = env.BoardConfig().get("build.hwids") usbid = '2 %s:%s' % (usbids[0][0], usbids[0][1]) env.Replace(UPLOADERFLAGS=usbid) uploadParams = usbid env.Replace( - UPLOADER=join(env.PioPlatform().get_package_dir("framework-arduinoststm32") or "", "tools", uploadPlatform, uploadProtocol), + UPLOADER=join( + env.PioPlatform().get_package_dir( + "framework-arduinoststm32") or "", + "tools", uploadPlatform, uploadProtocol), UPLOADERFLAGS=["$UPLOAD_PORT"], UPLOADERPARAMS=uploadParams, - UPLOADCMD='$UPLOADER $UPLOADERFLAGS $UPLOADERPARAMS $PROJECT_DIR/$SOURCES' - ) + UPLOADCMD=( + '$UPLOADER $UPLOADERFLAGS $UPLOADERPARAMS $PROJECT_DIR/$SOURCES')) # # Target: Build executable and linkable firmware diff --git a/platform.json b/platform.json index 4a4fe88..288bfe6 100644 --- a/platform.json +++ b/platform.json @@ -22,7 +22,7 @@ "framework-arduinoststm32": [ { "url": "https://github.com/ubis/Arduino_STM32/archive/v1.0.0.tar.gz", - "sha1": "36F26069B70EF6B7CEAE2A91E3C23BE74CC79337", + "sha1": "36f26069b70ef6b7ceae2a91e3c23be74cc79337", "version": "1.0.0", "system": "*" }