Permalink
Browse files

Photoresistor

  • Loading branch information...
1 parent 0d320a0 commit c9cade7e5a8b8e6868c47723f46580dea05a560a @jsikorski committed Sep 23, 2012
View
5 Source/EmbeddedMelodyPlayer.Tests/EmbeddedMelodyPlayer.Tests.csproj
@@ -98,6 +98,9 @@
<Compile Include="..\EmbeddedMelodyPlayer\Playing\PlayingMelodyFragmentPipe.cs">
<Link>References\Playing\PlayingMelodyFragmentPipe.cs</Link>
</Compile>
+ <Compile Include="..\EmbeddedMelodyPlayer\Playing\TempoMultiplierProvider.cs">
+ <Link>Playing\TempoMultiplierProvider.cs</Link>
+ </Compile>
<Compile Include="..\EmbeddedMelodyPlayer\Reading\MelodyFileReader.cs">
<Link>Reading\MelodyFileReader.cs</Link>
</Compile>
@@ -120,7 +123,7 @@
<Compile Include="Playing\NoteTests.cs" />
<Compile Include="Playing\PauseTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="References\Supplements.cs" />
+ <Compile Include="References\Replacements.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
View
21 ...odyPlayer.Tests/References/Supplements.cs → ...dyPlayer.Tests/References/Replacements.cs
@@ -120,6 +120,27 @@ internal virtual void Set(bool value)
{
}
}
+
+ internal class AnalogIn
+ {
+ public enum Pin
+ {
+ Ain0
+ }
+
+ public AnalogIn(Pin pin)
+ {
+ }
+
+ public void SetLinearScale(int min, int max)
+ {
+ }
+
+ public int Read()
+ {
+ return 0;
+ }
+ }
}
namespace GHIElectronics.NETMF.FEZ
View
1 Source/EmbeddedMelodyPlayer/EmbeddedMelodyPlayer.csproj
@@ -47,6 +47,7 @@
<Compile Include="Playing\Pause.cs" />
<Compile Include="Playing\PlayingContext.cs" />
<Compile Include="Playing\PlayingMelodyFragmentPipe.cs" />
+ <Compile Include="Playing\TempoMultiplierProvider.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Program.cs" />
<Compile Include="Reading\MelodyFileReader.cs" />
View
3 Source/EmbeddedMelodyPlayer/Playing/Note.cs
@@ -9,7 +9,6 @@ namespace EmbeddedMelodyPlayer.Playing
public class Note : MelodyElement
{
private const int BuzzerPwmDutyCycle = 50;
- private const int TempoMultiplier = 100;
private static readonly PWM BuzzerPwm = new PWM((PWM.Pin)FEZ_Pin.PWM.Di5);
@@ -52,7 +51,7 @@ public override void Play()
BuzzerPwm.Set(frequency, BuzzerPwmDutyCycle);
TurnNoteLedsOn();
- Thread.Sleep(Duration * TempoMultiplier);
+ Thread.Sleep(Duration * TempoMultiplierProvider.GetMultiplier());
TurnAllNoteLedsOff();
BuzzerPwm.Set(false);
View
22 Source/EmbeddedMelodyPlayer/Playing/TempoMultiplierProvider.cs
@@ -0,0 +1,22 @@
+using GHIElectronics.NETMF.Hardware;
+
+namespace EmbeddedMelodyPlayer.Playing
+{
+ public static class TempoMultiplierProvider
+ {
+ private const int MultiplierBase = 250;
+ private const int MultiplierFactor = 2;
+
+ private static readonly AnalogIn AnalogIn = new AnalogIn(AnalogIn.Pin.Ain0);
+
+ static TempoMultiplierProvider()
+ {
+ AnalogIn.SetLinearScale(0, 100);
+ }
+
+ public static int GetMultiplier()
+ {
+ return MultiplierBase - MultiplierFactor * AnalogIn.Read();
+ }
+ }
+}
View
4 Source/EmbeddedMelodyPlayer/Program.cs
@@ -1,9 +1,5 @@
using System.Threading;
using EmbeddedMelodyPlayer.Core;
-using EmbeddedMelodyPlayer.Infrastructure;
-using GHIElectronics.NETMF.FEZ;
-using GHIElectronics.NETMF.Hardware;
-using I2C.Expander;
using Microsoft.SPOT;
namespace EmbeddedMelodyPlayer

0 comments on commit c9cade7

Please sign in to comment.