Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release-beta-0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiashuo Li committed Apr 30, 2015
2 parents 782fb21 + ced45e6 commit 44cd296
Show file tree
Hide file tree
Showing 18 changed files with 158 additions and 110 deletions.
4 changes: 4 additions & 0 deletions TestJiashuoConsole/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Program
{
static void Main(string[] args)
{
/*
Instruction ins1 = new Instruction("MOVE 100, 2");
Instruction ins2 = new Instruction("MOVE -100, 2");
Instruction ins3 = new Instruction("MOVE 0, 2");
Expand All @@ -34,6 +35,9 @@ static void Main(string[] args)
string input = File.ReadAllText("demo_forward_until_bump.igp");
HLProgram pro = new HLProgram(input);
File.WriteAllText("demo_forward_until_bump_with_description.igp", pro.ToString(true));
*/

string[] ports = System.IO.Ports.SerialPort.GetPortNames();

}
}
Expand Down
3 changes: 3 additions & 0 deletions UI/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
<setting name="PopupWindowForNewIns" serializeAs="String">
<value>True</value>
</setting>
<setting name="ComPortListIndex" serializeAs="String">
<value>0</value>
</setting>
</iRobotGUI.Properties.Settings>
</userSettings>
</configuration>
2 changes: 1 addition & 1 deletion UI/Controls/ProgramList.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ private void RemoveSelection()
return;

// Just remove the pointer. We don't care the source in HLProgram.
pvm.Remove(index);
pvm.RemoveAt(index);

UpdateContent();
}
Expand Down
13 changes: 6 additions & 7 deletions UI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ void NewCmdExecuted(object target, ExecutedRoutedEventArgs e)
{
igpFile = null;
programList.Program = new HLProgram();
textBlockStatus.Text = Directory.GetCurrentDirectory();
}

/// <summary>
Expand Down Expand Up @@ -513,9 +514,9 @@ private void MenuItemRevealInExplorer_Click(object sender, RoutedEventArgs e)
#region Window callbacks
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (igpFile == "")
{
// No file is open
// No file is open
if (string.IsNullOrEmpty(igpFile))
{
if (programList.Program.ToString() == "") return;
}
else
Expand All @@ -535,15 +536,13 @@ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs
}
#endregion Window callbacks

#region Control Callbacks
private void InstructionPanel_AddNewInstruction(string opcode)
{
programList.AddNewInstruction(opcode);
}


#region ProgramList' Callbacks

// For debugging

private void programList_ProgramChanged()
{
HLProgram program = programList.Program;
Expand Down
12 changes: 12 additions & 0 deletions UI/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions UI/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
<Setting Name="PopupWindowForNewIns" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="ComPortListIndex" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
</Settings>
</SettingsFile>
17 changes: 0 additions & 17 deletions UI/Remarks.txt

This file was deleted.

3 changes: 0 additions & 3 deletions UI/UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,6 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Resource Include="Remarks.txt" />
</ItemGroup>
<ItemGroup>
<Resource Include="pic\backward.png" />
<Resource Include="pic\bump.png" />
Expand Down
2 changes: 1 addition & 1 deletion UI/WinAvr/WinAvrConfiguation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace iRobotGUI.WinAvr
/// </summary>
public class WinAvrConfiguation
{
public string comPort = "COM1"; // com4
public string comPort = "COM1"; // com1
public string firmwareVersion = STK500V1; // stk500v1

public const string STK500 = "stk500";
Expand Down
11 changes: 8 additions & 3 deletions UI/Windows/ConfigurationWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<Window x:Class="iRobotGUI.ConfigurationWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:p="clr-namespace:iRobotGUI.Properties"
xmlns:iRobot="clr-namespace:iRobotGUI"
Title="Configuration" Height="258.359" Width="411.83" ResizeMode="NoResize" WindowStartupLocation="CenterOwner">
<Grid>
<Label Content="COM Port" HorizontalAlignment="Left" Margin="30,37,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="textboxCom" HorizontalAlignment="Left" Height="24" Margin="98,39,0,0" TextWrapping="Wrap" Text="4" VerticalAlignment="Top" Width="120"/>
<Button Content="Auto Detect" HorizontalAlignment="Left" Margin="223,40,0,0" VerticalAlignment="Top" IsEnabled="False"/>
<Button Content="Device Manager" HorizontalAlignment="Left" Margin="296,40,0,0" VerticalAlignment="Top" Click="ButtonDeviceManager_Click"/>
<ComboBox x:Name="comboBoxCom" HorizontalAlignment="Left" Height="24" Margin="98,39,0,0" VerticalAlignment="Top" Width="142"
SelectedIndex="{Binding Source={x:Static p:Settings.Default}, Path=ComPortListIndex, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding Source={x:Static iRobot:ConfigurationWindow.ports}}"/>

<Button Content="Refresh" HorizontalAlignment="Left" Margin="245,39,0,0" VerticalAlignment="Top" Click="ButtonRefresh_Click"/>
<Button Content="Device Manager" HorizontalAlignment="Left" Margin="296,39,0,0" VerticalAlignment="Top" Click="ButtonDeviceManager_Click"/>

<Button x:Name="buttonOk" Content="OK" HorizontalAlignment="Left" Margin="98,183,0,0" VerticalAlignment="Top" Width="75" IsDefault="True" Click="buttonOk_Click"/>
<Button Content="Cancel" HorizontalAlignment="Left" Margin="216,183,0,0" VerticalAlignment="Top" Width="75" IsCancel="True"/>
Expand Down
133 changes: 81 additions & 52 deletions UI/Windows/ConfigurationWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using iRobotGUI.WinAvr;
using iRobotGUI.Properties;
using iRobotGUI.WinAvr;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -15,61 +16,89 @@

namespace iRobotGUI
{
/// <summary>
/// Interaction logic for ComWindow.xaml
/// </summary>
public partial class ConfigurationWindow : Window
{
private WinAvrConfiguation _config;
public WinAvrConfiguation Config
{
set
{
_config = value;
textboxCom.Text = value.comPort;
/// <summary>
/// Interaction logic for ComWindow.xaml
/// </summary>
public partial class ConfigurationWindow : Window
{
private WinAvrConfiguation _config;
public static string[] ports;

switch (value.firmwareVersion)
{
case WinAvrConfiguation.STK500:
radio0.IsChecked = true;
break;
case WinAvrConfiguation.STK500V1:
radio1.IsChecked = true;
break;
case WinAvrConfiguation.STK500V2:
radio2.IsChecked = true;
break;
}
}
get
{
return _config;
}
}
public WinAvrConfiguation Config
{
set
{
_config = value;

public ConfigurationWindow()
{
InitializeComponent();
}
switch (value.firmwareVersion)
{
case WinAvrConfiguation.STK500:
radio0.IsChecked = true;
break;
case WinAvrConfiguation.STK500V1:
radio1.IsChecked = true;
break;
case WinAvrConfiguation.STK500V2:
radio2.IsChecked = true;
break;
}
}
get
{
return _config;
}
}

private void buttonOk_Click(object sender, RoutedEventArgs e)
{
_config.comPort = textboxCom.Text;
public ConfigurationWindow()
{
ports = System.IO.Ports.SerialPort.GetPortNames();

if (radio0.IsChecked ?? false)
_config.firmwareVersion = radio0.Content.ToString();
else if (radio1.IsChecked ?? false)
_config.firmwareVersion = radio1.Content.ToString();
else if (radio2.IsChecked ?? false)
_config.firmwareVersion = radio2.Content.ToString();
InitializeComponent();

WinAvrConnector.CustomizeMakefile();
DialogResult = true;
}
// https://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.selector.selectedindex(v=vs.110).aspx
// If you set SelectedIndex to a value equal or greater than the number of child elements, the value is ignored.
// Try to select the first one.
if (comboBoxCom.SelectedIndex == -1) comboBoxCom.SelectedIndex = 0;

private void ButtonDeviceManager_Click(object sender, RoutedEventArgs e)
{
System.Diagnostics.Process.Start("devmgmt.msc");
}
}
}

private void buttonOk_Click(object sender, RoutedEventArgs e)
{
_config.comPort = comboBoxCom.Text;

if (radio0.IsChecked ?? false)
_config.firmwareVersion = radio0.Content.ToString();
else if (radio1.IsChecked ?? false)
_config.firmwareVersion = radio1.Content.ToString();
else if (radio2.IsChecked ?? false)
_config.firmwareVersion = radio2.Content.ToString();

WinAvrConnector.CustomizeMakefile();
DialogResult = true;
}

private void ButtonDeviceManager_Click(object sender, RoutedEventArgs e)
{
System.Diagnostics.Process.Start("devmgmt.msc");
}

protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
Settings.Default.Save();
base.OnClosing(e);
}

private void ButtonRefresh_Click(object sender, RoutedEventArgs e)
{
ports = System.IO.Ports.SerialPort.GetPortNames();

int previousIndex = comboBoxCom.SelectedIndex;
comboBoxCom.ItemsSource = ports;

// Select the previously selected item again.
if (previousIndex < 0) comboBoxCom.SelectedIndex = 0;
else if (previousIndex < ports.Length) comboBoxCom.SelectedIndex = previousIndex;
else comboBoxCom.SelectedIndex = ports.Length - 1;
}
}
}
8 changes: 8 additions & 0 deletions cprogram/demo_forward-bump-turn.igp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
LOOP 2,0,0 // Loop when the sensor Cliff Left is not detected...
DRIVE 500,32767 // Drive forward at 50cm/s straightly
LOOP 0,0,0 // Loop when the sensor Bump is not detected...
DELAY 100 // Delay for 100ms.
END_LOOP // Description not implemented.
SONG 60,32,62,32,64,32,60,32,60,32,62,32,64,32,60,32,64,32,65,32,67,32 // Play a song.
ROTATE 90 // Turn left by 90 degree(s).
END_LOOP // Description not implemented.
File renamed without changes.
4 changes: 0 additions & 4 deletions cprogram/demo_led_song.igp

This file was deleted.

7 changes: 7 additions & 0 deletions cprogram/demo_song-led.igp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SONG 64,32,64,32,65,32,67,32,67,32,65,32,64,32,62,32,60,32,60,32,62,32,64,32,64,48,62,16,62,64 // Play a song.
LOOP 0,0,0 // Loop when the sensor Bump is not detected...
LED 0,255,255 // Turn off both Play LED and Advance LED.
DELAY 500 // Delay for 500ms.
LED 10,0,255 // Turn on both Play LED and Advance LED.
DELAY 500 // Delay for 500ms.
END_LOOP // Description not implemented.
4 changes: 2 additions & 2 deletions cprogram/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
AVRDUDE_PROGRAMMER = stk500v1

# com1 = serial port. Use lpt1 to connect to parallel port.
AVRDUDE_PORT = COM1 # programmer connected to serial device
AVRDUDE_PORT = 22 # programmer connected to serial device

AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
Expand Down Expand Up @@ -245,7 +245,7 @@ DEBUG_BACKEND = avarice
GDBINIT_FILE = __avr_gdbinit

# When using avarice settings for the JTAG
JTAG_DEV = /dev/COM1
JTAG_DEV = /dev/22

# Debugging port used to communicate between GDB / avarice / simulavr.
DEBUG_PORT = 4242
Expand Down
22 changes: 22 additions & 0 deletions cprogram/mc_t.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ void delay(uint16_t time_ms)
// Delay for the specified time in ms and update sensor values
void delaySensors(uint16_t time_ms)
{
/*
uint8_t temp;
timer_on = 1;
Expand All @@ -184,6 +185,27 @@ void delaySensors(uint16_t time_ms)
sensors_flag = 1;
}
}
*/

uint8_t temp;

delay(time_ms);

// Prepare the sensor.
sensors_index = 0;
sensors_flag = 1;
byteTx(CmdSensors);
byteTx(0);

// Wait for the sensor.
while(!sensors_flag) ;

for(temp = 0; temp < Sen0Size; temp++)
sensors[temp] = sensors_in[temp];

// Update running totals of distance and angle
distance += (int)((sensors[SenDist1] << 8) | sensors[SenDist0]);
angle += (int)((sensors[SenAng1] << 8) | sensors[SenAng0]);
}


Expand Down
Loading

0 comments on commit 44cd296

Please sign in to comment.