Skip to content

Commit

Permalink
Bug fix adding the upload_speed flag (issue: #183)
Browse files Browse the repository at this point in the history
  • Loading branch information
gepd committed Sep 28, 2017
1 parent f3d9b1e commit 72091cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions libraries/preferences_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class PreferencesBridge(PioBridge):

def __init__(self):
super(PreferencesBridge, self).__init__()
self.init_option = None

def save_selected_board(self, board_id):
"""Store Board
Expand Down Expand Up @@ -227,7 +228,7 @@ def programmer(self, wipe=False):
with open(ini_path, 'w') as configfile:
config.write(configfile)

def add_option(self, option_name, wipe=False):
def add_option(self, option_name, wipe=False, append=False):
"""Add option
Adds the option `option_name` into platformio.ini. The value
Expand All @@ -239,6 +240,8 @@ def add_option(self, option_name, wipe=False):
Keyword Arguments:
wipe {bool} -- when is true remove the option
from platformio.ini (default: {False})
append {bool} -- when is true, when is true it appends
the given data
"""
option = get_setting(option_name, None)
ini_path = self.get_ini_path()
Expand All @@ -260,7 +263,7 @@ def add_option(self, option_name, wipe=False):

# add option
if(not wipe and option and option not in current):
if(self.init_option):
if(self.init_option and append):
option = self.init_option + ', ' + option

config.set(environment, option_name, option)
Expand All @@ -274,7 +277,6 @@ def add_option(self, option_name, wipe=False):
else:
config.remove_option(environment, option_name)
write_file = True
self.init_option = None

# save in file
if(write_file):
Expand Down
2 changes: 1 addition & 1 deletion platformio/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def start_upload(self):
self.add_board()

# add extra library board
self.add_option('lib_extra_dirs')
self.add_option('lib_extra_dirs', append=True)

# check if there is a new speed to overwrite
self.add_option('upload_speed')
Expand Down

0 comments on commit 72091cf

Please sign in to comment.