Skip to content

Commit

Permalink
Add project files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Sapundzhiev committed Mar 4, 2018
1 parent da4c912 commit aff664a
Show file tree
Hide file tree
Showing 24 changed files with 530 additions and 0 deletions.
43 changes: 43 additions & 0 deletions PiPiano.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2036
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PiPiano", "PiPiano\PiPiano.csproj", "{34106E64-4347-425F-B96B-1ECC3E649328}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|ARM = Release|ARM
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{34106E64-4347-425F-B96B-1ECC3E649328}.Debug|ARM.ActiveCfg = Debug|ARM
{34106E64-4347-425F-B96B-1ECC3E649328}.Debug|ARM.Build.0 = Debug|ARM
{34106E64-4347-425F-B96B-1ECC3E649328}.Debug|ARM.Deploy.0 = Debug|ARM
{34106E64-4347-425F-B96B-1ECC3E649328}.Debug|x64.ActiveCfg = Debug|x64
{34106E64-4347-425F-B96B-1ECC3E649328}.Debug|x64.Build.0 = Debug|x64
{34106E64-4347-425F-B96B-1ECC3E649328}.Debug|x64.Deploy.0 = Debug|x64
{34106E64-4347-425F-B96B-1ECC3E649328}.Debug|x86.ActiveCfg = Debug|x86
{34106E64-4347-425F-B96B-1ECC3E649328}.Debug|x86.Build.0 = Debug|x86
{34106E64-4347-425F-B96B-1ECC3E649328}.Debug|x86.Deploy.0 = Debug|x86
{34106E64-4347-425F-B96B-1ECC3E649328}.Release|ARM.ActiveCfg = Release|ARM
{34106E64-4347-425F-B96B-1ECC3E649328}.Release|ARM.Build.0 = Release|ARM
{34106E64-4347-425F-B96B-1ECC3E649328}.Release|ARM.Deploy.0 = Release|ARM
{34106E64-4347-425F-B96B-1ECC3E649328}.Release|x64.ActiveCfg = Release|x64
{34106E64-4347-425F-B96B-1ECC3E649328}.Release|x64.Build.0 = Release|x64
{34106E64-4347-425F-B96B-1ECC3E649328}.Release|x64.Deploy.0 = Release|x64
{34106E64-4347-425F-B96B-1ECC3E649328}.Release|x86.ActiveCfg = Release|x86
{34106E64-4347-425F-B96B-1ECC3E649328}.Release|x86.Build.0 = Release|x86
{34106E64-4347-425F-B96B-1ECC3E649328}.Release|x86.Deploy.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8F6E9781-B406-4875-B524-39B02C751DC8}
EndGlobalSection
EndGlobal
8 changes: 8 additions & 0 deletions PiPiano/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Application
x:Class="PiPiano.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:PiPiano"
RequestedTheme="Light">

</Application>
100 changes: 100 additions & 0 deletions PiPiano/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

namespace PiPiano
{
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
sealed partial class App : Application
{
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
}

/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
Frame rootFrame = Window.Current.Content as Frame;

// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();

rootFrame.NavigationFailed += OnNavigationFailed;

if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
}

// Place the frame in the current Window
Window.Current.Content = rootFrame;
}

if (e.PrelaunchActivated == false)
{
if (rootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
rootFrame.Navigate(typeof(MainPage), e.Arguments);
}
// Ensure the current window is active
Window.Current.Activate();
}
}

/// <summary>
/// Invoked when Navigation to a certain page fails
/// </summary>
/// <param name="sender">The Frame which failed navigation</param>
/// <param name="e">Details about the navigation failure</param>
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
}

/// <summary>
/// Invoked when application execution is being suspended. Application state is saved
/// without knowing whether the application will be terminated or resumed with the contents
/// of memory still intact.
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param>
private void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
//TODO: Save application state and stop any background activity
deferral.Complete();
}
}
}
Binary file added PiPiano/Assets/LockScreenLogo.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PiPiano/Assets/SplashScreen.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PiPiano/Assets/Square150x150Logo.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PiPiano/Assets/Square44x44Logo.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PiPiano/Assets/StoreLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PiPiano/Assets/Wide310x150Logo.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PiPiano/Assets/sound0.wav
Binary file not shown.
Binary file added PiPiano/Assets/sound1.wav
Binary file not shown.
Binary file added PiPiano/Assets/sound2.wav
Binary file not shown.
Binary file added PiPiano/Assets/sound3.wav
Binary file not shown.
Binary file added PiPiano/Assets/sound4.wav
Binary file not shown.
Binary file added PiPiano/Assets/sound5.wav
Binary file not shown.
Binary file added PiPiano/Assets/sound6.wav
Binary file not shown.
Binary file added PiPiano/Assets/sound7.wav
Binary file not shown.
22 changes: 22 additions & 0 deletions PiPiano/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Page
x:Class="PiPiano.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:PiPiano"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel Orientation="Horizontal" Spacing="20" HorizontalAlignment="Center">
<Button Tag="0" Height="200" Width="40" Click="Button_Click"></Button>
<Button Tag="1" Height="200" Width="40" Click="Button_Click"></Button>
<Button Tag="2" Height="200" Width="40" Click="Button_Click"></Button>
<Button Tag="3" Height="200" Width="40" Click="Button_Click"></Button>
<Button Tag="4" Height="200" Width="40" Click="Button_Click"></Button>
<Button Tag="5" Height="200" Width="40" Click="Button_Click"></Button>
<Button Tag="6" Height="200" Width="40" Click="Button_Click"></Button>
<Button Tag="7" Height="200" Width="40" Click="Button_Click"></Button>
</StackPanel>
</Grid>
</Page>
90 changes: 90 additions & 0 deletions PiPiano/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Devices.Gpio;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Media.Core;
using Windows.Media.Playback;
using Windows.Storage;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409

namespace PiPiano
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
private const int PB_PIN_START = 5;
private GpioPin[] pushButtons = new GpioPin[8];
private bool[] downStates = new bool[8];
private DispatcherTimer timer;
private MediaPlayer player = new MediaPlayer();



public MainPage()
{
this.InitializeComponent();

var gpio = GpioController.GetDefault();
if (gpio != null)
{
InitGPIO(gpio);
timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromMilliseconds(500);
timer.Tick += Timer_Tick;
timer.Start();
}
}

private void InitGPIO(GpioController gpio)
{
for (int i = 0; i < pushButtons.Length; i++)
{
pushButtons[i] = gpio.OpenPin(i + PB_PIN_START);
pushButtons[i].SetDriveMode(GpioPinDriveMode.Input);
downStates[i] = false;
}
}

private void Timer_Tick(object sender, object e)
{
CheckButtonState();
}

private void CheckButtonState()
{
for (int i = 0; i < pushButtons.Length; i++)
{
bool isPinOn = pushButtons[i].Read() == GpioPinValue.High;
if (downStates[i] != isPinOn && isPinOn)
playNote(i);
downStates[i] = isPinOn;
}
}

private void playNote(int i)
{
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.Source = MediaSource.CreateFromUri(new Uri($"ms-appx:///Assets/sound{i}.wav"));
mediaPlayer.Play();
}

private void Button_Click(object sender, RoutedEventArgs e)
{
playNote(int.Parse((e.OriginalSource as Button).Tag.ToString()));
}
}
}
49 changes: 49 additions & 0 deletions PiPiano/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>

<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
IgnorableNamespaces="uap mp">

<Identity
Name="6fc4e9b4-320f-4bba-a48f-cf8bce9a95b7"
Publisher="CN=julia"
Version="1.0.0.0" />

<mp:PhoneIdentity PhoneProductId="6fc4e9b4-320f-4bba-a48f-cf8bce9a95b7" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

<Properties>
<DisplayName>PiPiano</DisplayName>
<PublisherDisplayName>julia</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>

<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
</Dependencies>

<Resources>
<Resource Language="x-generate"/>
</Resources>

<Applications>
<Application Id="App"
Executable="$targetnametoken$.exe"
EntryPoint="PiPiano.App">
<uap:VisualElements
DisplayName="PiPiano"
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png"
Description="PiPiano"
BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>

<Capabilities>
<Capability Name="internetClient" />
</Capabilities>
</Package>
Loading

0 comments on commit aff664a

Please sign in to comment.