Skip to content

Commit

Permalink
Optionally clone teensyduino core files into project
Browse files Browse the repository at this point in the history
  • Loading branch information
luni64 committed Aug 23, 2021
1 parent bdcf465 commit 0a2a5c1
Show file tree
Hide file tree
Showing 29 changed files with 390 additions and 411 deletions.
21 changes: 11 additions & 10 deletions VisualTeensy/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ SetupData loadSetup()
setupData.mru.load(Settings.Default.mruString);
Helpers.arduinoPath = setupData.arduinoBase;

using (var reader = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("VisualTeensy.Embedded.makefile_make")))
{
setupData.makefile_fixed = reader.ReadToEnd();
}
using (var reader = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("VisualTeensy.Embedded.makefile_builder")))
{
setupData.makefile_builder = reader.ReadToEnd();
}
//using (var reader = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("VisualTeensy.Embedded.makefile_make")))
//{
// setupData.makefile_fixed = reader.ReadToEnd();
//}
//using (var reader = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("VisualTeensy.Embedded.makefile_builder")))
//{
// setupData.makefile_builder = reader.ReadToEnd();
//}



Expand Down Expand Up @@ -135,10 +135,11 @@ void saveSetup(SetupData setupData)


protected override void OnStartup(StartupEventArgs e)
{
{
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.GetCultureInfo("en-US");

this.ShutdownMode = ShutdownMode.OnExplicitShutdown;

CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.GetCultureInfo("en-US");

// create applicaton folder <user>\AppData\Local\VisualTeensy (if not yet existing)
Directory.CreateDirectory(SetupData.vtAppFolder);
Expand Down
4 changes: 2 additions & 2 deletions VisualTeensy/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0")]
[assembly: AssemblyFileVersion("1.1.0")]
[assembly: AssemblyVersion("1.2.0")]
[assembly: AssemblyFileVersion("1.2.0")]
[assembly: NeutralResourcesLanguage("en")]

12 changes: 8 additions & 4 deletions VisualTeensy/ViewModel/MainWin/MainVM.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Collections.ObjectModel;
using log4net;
using System.Collections.ObjectModel;
using System.IO;
using System.Reflection;
using System.Windows;
using vtCore;
using vtCore.Interfaces;
Expand Down Expand Up @@ -110,17 +112,19 @@ public MainVM(IProject project, LibManager libManager, SetupData setup)
projecTabVM.OnPropertyChanged("");
};

mruList = new ObservableCollection<MruItemVM>();
mruList = new ObservableCollection<MruItemVM>();
foreach (var prj in setup.mru.projects)
{
mruList.Add(new MruItemVM(prj, this));
}
//var mruList = setup.mru.projects?.Select(p => new MruItemVM(p, this));
//if(mruList != null) mruList = new ObservableCollection<MruItemVM>(mruList);
log.Info($"MRU list loaded ({mruList.Count} entries)");
log.Info("constructed");
}

public LibManager libManager { get; }
public SetupData setup { get; }
public IProject project { get; }

private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
}
}
103 changes: 31 additions & 72 deletions VisualTeensy/ViewModel/ProjectTab/ProjectTabVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
using System.Linq;
using vtCore.Interfaces;
using vtCore;

using log4net;
using System.Reflection;

namespace ViewModel
{
Expand Down Expand Up @@ -76,14 +77,6 @@ void doClose(object o)
{
// model.saveSettings();
}

public RelayCommand cmdCoreSelected { get; private set; }
void doCoreSelected(object o)
{
project.coreStrategy = (CoreStrategies)o;
}


#endregion

#region Properties ----------------------------------------------------
Expand All @@ -102,28 +95,16 @@ public BoardVM selectedBoard
}
}


public bool isMakefileBuild => project.buildSystem == BuildSystem.makefile;
// set
// {
// if (value != project.isMakefileBuild)
// {
// project.isMakefileBuild = value;
// OnPropertyChanged();
// }
// }
//}


public bool quickSetup

public SetupTypes setupType
{
get => project.selectedConfiguration.setupType == SetupTypes.quick ? true : false;
get => project.selectedConfiguration.setupType;
set
{
SetupTypes newType = value == true ? SetupTypes.quick : SetupTypes.expert; // hack, valueConverter would be better
if (project.selectedConfiguration.setupType != newType)
if (project.selectedConfiguration.setupType != value)
{
project.selectedConfiguration.setupType = newType;
project.selectedConfiguration.setupType = value;
updateAll();
OnPropertyChanged("");
}
Expand All @@ -140,7 +121,21 @@ public bool hasDebugSupport
OnPropertyChanged("");
}
}


public LibStrategy coreStragegy
{
get => project.selectedConfiguration.coreStrategy;
set
{
if (value != project.selectedConfiguration.coreStrategy)
{
project.selectedConfiguration.coreStrategy = value;
updateFiles();
OnPropertyChanged("");
}
}
}

public string makefileExtension
{
get => project.selectedConfiguration.makefileExtension;
Expand Down Expand Up @@ -210,46 +205,7 @@ public String arduinoBase
}
}
}
//public String boardTxtPath
//{
// get => project.selectedConfiguration.boardTxtPath;
// set
// {
// if (value != project.selectedConfiguration.boardTxtPath)
// {
// project.selectedConfiguration.boardTxtPath = value.Trim();
// updateAll();
// OnPropertyChanged("");
// }
// }
//}
//public bool copyBoardTxt
//{
// get => project.selectedConfiguration.copyBoardTxt;
// set
// {
// if (value != project.selectedConfiguration.copyBoardTxt)
// {
// project.selectedConfiguration.copyBoardTxt = value;
// OnPropertyChanged();
// updateFiles();
// }
// }
//}

public bool copyCore
{
get => project.selectedConfiguration.copyCore;
set
{
if (value != project.selectedConfiguration.copyCore)
{
project.selectedConfiguration.copyCore = value;
OnPropertyChanged();
updateFiles();
}
}
}

public String corePath
{
get => project.selectedConfiguration.coreBase.path;
Expand Down Expand Up @@ -303,13 +259,13 @@ public ProjectTabVM(IProject project, LibManager libManager, SetupData setup)
settFile = ProjectSettings.generate(project);
debugFile = DebugFile.generate(project, setup);



cmdGenerate = new RelayCommand(doGenerate);//, o => project.pathError == null && !String.IsNullOrWhiteSpace(project.selectedConfiguration.makefile) && !String.IsNullOrWhiteSpace(project.tasks_json) && !String.IsNullOrWhiteSpace(project.props_json));
cmdClose = new RelayCommand(doClose);
cmdCoreSelected = new RelayCommand(doCoreSelected);


updateBoards();
OnPropertyChanged("");

log.Info("constructed");
}

internal void updateAll()
Expand All @@ -320,7 +276,7 @@ internal void updateAll()
}
internal void updateFiles()
{


makefile = Makefile.generate(project, libManager, setup);
taskFile = TaskFile.generate(project, setup);
Expand Down Expand Up @@ -365,6 +321,9 @@ protected void Message(string message)
public IProject project;
LibManager libManager;
SetupData setup;


private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
}
}

Expand Down
4 changes: 2 additions & 2 deletions VisualTeensy/ViewModel/SaveWin/SaveWinVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ async Task doSave()
while (!taskVMs.IsCurrentAfterLast)
{
var taskVM = (TaskVM)taskVMs.CurrentItem;
log.Info(taskVM.title);
log.Info(taskVM.title + " started...");

await taskVM.action();
await Task.Delay(50);
await Task.Delay(150);
log.Info($"{taskVM.title} done");

taskVMs.MoveCurrentToNext();
Expand Down
12 changes: 10 additions & 2 deletions VisualTeensy/ViewModel/SetupTab/SetupTabVM.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System;
using log4net;
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Drawing;
using System.Reflection;
using System.Windows.Data;
using vtCore;
using vtCore.Interfaces;
Expand Down Expand Up @@ -277,12 +279,13 @@ public int selectedFile
get => _selectedFile;
set => SetProperty(ref _selectedFile, value);
}
int _selectedFile=0;
int _selectedFile = 0;

public RelayCommand cmdAddFile { get; private set; }
void doAddFile(object f)
{
string filename = f as String;
log.Info($"add additional file {filename}");
setup.additionalFiles.Add(filename);
additionalFilesView.Refresh();
}
Expand All @@ -292,6 +295,7 @@ void doDelFile(object o)
{
if (selectedFile >= 0)
{
log.Info($"delete additional file {setup.additionalFiles[selectedFile]}");
setup.additionalFiles.RemoveAt(selectedFile);
additionalFilesView.Refresh();
}
Expand All @@ -309,10 +313,14 @@ public SetupTabVM(IProject project, SetupData setup)
// additionalFiles = new ObservableCollection<string>(setup.additionalFiles);

additionalFilesView = CollectionViewSource.GetDefaultView(setup.additionalFiles);

log.Info("constructed");
}

private readonly SetupData setup;
private readonly IProject project;

private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
}
}

23 changes: 23 additions & 0 deletions VisualTeensy/Views/Converters/EnumBooleanConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace VisualTeensy
{
public class EnumBooleanConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value.Equals(parameter);
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return ((bool)value) ? parameter : Binding.DoNothing;
}
}
}
36 changes: 26 additions & 10 deletions VisualTeensy/Views/ProjectTab.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ d:DataContext="{d:DesignInstance vm:ProjectTabVM, IsDesignTimeCreatable=False}"
d:DesignHeight="800" d:DesignWidth="1000">

<UserControl.Resources>
<!--<local:EnumBooleanConverter x:Key="EnumBooleanConverter"/>-->
<local:EnumBooleanConverter x:Key="EnumBooleanConverter"/>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
</UserControl.Resources>

Expand Down Expand Up @@ -55,12 +57,18 @@ d:DesignHeight="800" d:DesignWidth="1000">

<TextBlock Grid.Row="0" Grid.Column="0" FontSize="18" Text="Configuration" Margin="0,0,0,0" HorizontalAlignment="Left" Foreground="{DynamicResource PrimaryHueDarkBrush}" />
<StackPanel Grid.Row="1" Grid.ColumnSpan="2" Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,10,0,28" >
<RadioButton x:Name="radioButton" Content="Quick Setup" IsChecked="{Binding quickSetup}" Visibility="{Binding isMakefileBuild, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}" >
<RadioButton x:Name="radioButton" Content="Quick Setup"
IsChecked="{Binding setupType, ConverterParameter={x:Static if:SetupTypes.quick}, Converter={StaticResource EnumBooleanConverter}}"
Visibility="{Binding isMakefileBuild, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}" >
<RadioButton.ToolTip>
Quick Setup uses your Arduino installation to generate the project.
</RadioButton.ToolTip>
</RadioButton>
<RadioButton x:Name="radioButton1" Content="Expert Setup" IsChecked="True" Margin="10,0,40,0" Visibility="{Binding isMakefileBuild, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}" >
<RadioButton
x:Name="radioButton1" Content="Expert Setup"
IsChecked="{Binding setupType, ConverterParameter={x:Static if:SetupTypes.expert}, Converter={StaticResource EnumBooleanConverter}}"
Margin="10,0,40,0"
Visibility="{Binding isMakefileBuild, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}" >
<RadioButton.ToolTip>
Expert Setup allows to choose the compiler and used core libraries independently of your Arduino installation.
</RadioButton.ToolTip>
Expand Down Expand Up @@ -102,21 +110,29 @@ d:DesignHeight="800" d:DesignWidth="1000">
<Label Content="Compiler (gcc-arm-none-eabi):" FontWeight="SemiBold" FontSize="12" Foreground="{DynamicResource PrimaryHueDarkBrush}" Padding="0" Margin="0,25,0,0" />
<local:PSelector SelectedPath="{Binding compilerPath, ValidatesOnDataErrors=True}" Style="{DynamicResource ValidatingControl}" isFolderDialog="True" />

<Label Content="Teensyduino Core" FontSize="12" FontWeight="SemiBold" Foreground="{DynamicResource PrimaryHueDarkBrush}" Padding="0" Margin="0,20,0,5" />
<RadioButton x:Name="rbLinkCore" GroupName="core" Content="Link to local core" Command="{Binding cmdCoreSelected, Mode=OneWay}" CommandParameter="{x:Static if:CoreStrategies.link}" Margin="10,5,0,0" IsChecked="True"/>
<Label Content="Teensyduino core" FontSize="12" FontWeight="SemiBold" Foreground="{DynamicResource PrimaryHueDarkBrush}" Padding="0" Margin="0,20,0,5" />
<RadioButton
x:Name="rbLinkCore" GroupName="core"
Content="Link to local core" Margin="10,5,0,0"
IsChecked="{Binding coreStragegy, ConverterParameter={x:Static if:LibStrategy.link}, Converter={StaticResource EnumBooleanConverter}}"/>
<local:PSelector SelectedPath="{Binding corePath, ValidatesOnDataErrors=True}" Style="{DynamicResource ValidatingControl}" isFolderDialog="True" Margin="35,0,0,0" Visibility="{Binding IsChecked, Converter={StaticResource BooleanToVisibilityConverter}, ElementName=rbLinkCore}" >
<local:PSelector.ToolTip>
Folder to copy the core library from. &#x0a;
Typically this folder has boards.txt, platform.txt and board specific folders for the corresponding core libraries
</local:PSelector.ToolTip>
</local:PSelector>
<RadioButton x:Name="rbCopyCore" Content="Copy local core to project" Command="{Binding cmdCoreSelected, Mode=OneWay}" CommandParameter="{x:Static if:CoreStrategies.copy}" GroupName="core" Margin="10,5,0,0" />
<RadioButton
x:Name="rbCopyCore" GroupName="core" Margin="10,5,0,0"
Content="Copy local core into project"
IsChecked="{Binding coreStragegy, ConverterParameter={x:Static if:LibStrategy.copy}, Converter={StaticResource EnumBooleanConverter}}"/>
<local:PSelector SelectedPath="{Binding corePath, ValidatesOnDataErrors=True}" Style="{DynamicResource ValidatingControl}" isFolderDialog="True" Margin="35,0,0,0" Visibility="{Binding IsChecked, Converter={StaticResource BooleanToVisibilityConverter}, ElementName=rbCopyCore}" />
<RadioButton x:Name="rbCloneCore" Content="Clone core from gitHub into project" Command="{Binding cmdCoreSelected, Mode=OneWay}" CommandParameter="{x:Static if:CoreStrategies.clone}" GroupName="core" Margin="10,5,0.4,0" />

<CheckBox Content="Embedd in project (recommended)" FontSize="10" IsChecked="{Binding copyCore}" Visibility="Collapsed"/>


<RadioButton
x:Name="rbCloneCore"
Content="Clone core from gitHub into project"
GroupName="core"
Margin="10,5,0.4,0"
IsChecked="{Binding coreStragegy, ConverterParameter={x:Static if:LibStrategy.clone}, Converter={StaticResource EnumBooleanConverter}}"/>

<Label Content="Additional entries to makefile:" FontWeight="SemiBold" FontSize="12" Foreground="{DynamicResource PrimaryHueDarkBrush}" Padding="0" Margin="0,25,0,0" />
</StackPanel>
<TextBox Grid.Row="5" Grid.ColumnSpan="2" VerticalContentAlignment="Stretch" BorderThickness="1" AcceptsReturn="True" AcceptsTab="True" TextWrapping="NoWrap" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="Auto" FontFamily="Courier New" FontSize="13" Visibility="{Binding IsChecked, Converter={StaticResource BooleanToVisibilityConverter}, ElementName=radioButton1}" Text="{Binding makefileExtension, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Delay=100}"/>
Expand Down
Loading

0 comments on commit 0a2a5c1

Please sign in to comment.