{"id":7645,"date":"2015-12-27T10:55:35","date_gmt":"2015-12-27T01:55:35","guid":{"rendered":"http:\/\/www.moonmile.net\/blog\/?p=7645"},"modified":"2015-12-27T11:06:22","modified_gmt":"2015-12-27T02:06:22","slug":"windows-iot-core-%e3%81%a8-mvvm-%e3%81%ae%e9%96%a2%e4%bf%82","status":"publish","type":"post","link":"http:\/\/www.moonmile.net\/blog\/archives\/7645","title":{"rendered":"Windows IoT Core \u3068 MVVM \u306e\u95a2\u4fc2"},"content":{"rendered":"<p>\u5148\u6708\u306e .NET\u30e9\u30dc\u3067 Windows IoT Core \u306e\u30c7\u30e2\u3092\u3084\u308a\u307e\u3057\u305f\u304c\u3001\u305d\u3053\u3067\u4f7f\u3063\u305f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u516c\u958b\u3057\u307e\u3059\u3002<\/p>\n<p>moonmile\/WinIoT<br \/>\n<a href=\"https:\/\/github.com\/moonmile\/WinIoT\/tree\/master\/HelloSample\">https:\/\/github.com\/moonmile\/WinIoT\/tree\/master\/HelloSample<\/a><\/p>\n<p>HelloServo \u306e\u30b5\u30f3\u30d7\u30eb\u306f Raspberry Pi \u3067\u306f\u52d5\u4f5c\u3057\u306a\u3044\uff08\u4ed6\u3067\u306f\u52d5\u4f5c\u3057\u3066\u3044\u308b\uff1f\uff09\u306e\u3067\u306a\u3093\u3068\u3082\u8a00\u3048\u307e\u305b\u3093\u304c\u3001\u4ed6\u306e\u30b3\u30fc\u30c9\u306f\u307b\u3069\u3088\u304f Hello \u7684\u306b\u4f7f\u3048\u308b\u3082\u306e\u3067\u3059\u3002\u5f53\u65e5\u306f\u30b3\u30fc\u30c9\u306e\u89e3\u8aac\u306f\u305b\u305a\u3001\u6982\u8981\u3068\u52d5\u4f5c\u3060\u3051\u3060\u3063\u305f\u306e\u3067\u3001\u3061\u3087\u3063\u3068\u30b3\u30fc\u30c9\u306e\u307b\u3046\u3082\u89e3\u8aac\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<h2>\u74b0\u5883\u3092\u6574\u3048\u308b<\/h2>\n<p>\u6728\u6fa4\u3055\u3093\u306e I\/O \u30cd\u30bf\u306b\u3082\u7a81\u3063\u8fbc\u307f\u3092\u5165\u308c\u305f\u306e\u3067\u3059\u304c\u3001\u73fe\u5728 Winodws IoT \u306e\u958b\u767a\u74b0\u5883\u3065\u304f\u308a\u306f\u7d50\u69cb\u306a\u56f0\u96e3\u3092\u4f34\u3044\u307e\u3059\u3002\u6709\u511f\uff08\u3068\u3055\u308c\u308b\uff09Enterprize \u7248\u306e\u5834\u5408\u3082\u3053\u306e\u3088\u3046\u306a\u72b6\u6cc1\u306a\u306e\u304b\u306f\u308f\u304b\u308a\u307e\u305b\u3093\u304c\u3001\u5c11\u306a\u304f\u3068\u3082\u958b\u767a\u8005\u304c\u81ea\u7531\u306b\u4f7f\u3048\u308b\u7121\u511f\u7248\u306f\u3001\u73fe\u72b6\u3053\u3093\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n<ul>\n<li>\u6700\u65b0\u306e Windows IoT Core 10.0.10585 \u3092 micro SD \u30ab\u30fc\u30c9\u306b\u713c\u304d\u3053\u3093\u3060\u6642\u306f\u3001Windows 10.0.10585 + Visual Studio 2015 Update 1 \u306e\u74b0\u5883\u304c\u5fc5\u8981\u306b\u306a\u308b\u3002<\/li>\n<li>\u6700\u65b0\u306e Windows IoT Core 10.0.10585 \u306b\u306f\u3001\u30ea\u30e2\u30fc\u30c8\u74b0\u5883\u304c\u542b\u307e\u308c\u3066\u304a\u3089\u305a\u3001\u76f4\u524d\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u304b\u3089 RDBG \u30d5\u30a9\u30eb\u30c0\u3092\u30b3\u30d4\u30fc\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002<\/li>\n<\/ul>\n<p>Windows IoT Core \u306e\u6700\u65b0\u30d0\u30fc\u30b8\u30e7\u30f3\u306f <a href=\"https:\/\/ms-iot.github.io\/content\/en-US\/GetStarted.htm\">Get Started with Windows IoT<\/a> \u304b\u3089 Windows IoT Core Dashboard \u3092\u4f7f\u3063\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002\u6700\u521d\u306e\u9803\u306f\u30d5\u30a1\u30a4\u30eb\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u304b\u3089\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3001\u3068\u3044\u3046\u3084\u3084\u3053\u3057\u3044\u624b\u9806\u3060\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u6700\u8fd1\u306e\u3082\u306e\u306f\u3048\u3089\u3044\u5909\u308f\u308a\u307e\u3057\u305f\u3002\u3064\u3044\u3067\u306b\u8a00\u3046\u3068\u3001\u5148\u65e5\u306e\u767a\u8868\u3092\u3057\u305f\u9803\u3088\u308a\u3082\u5909\u308f\u3063\u3066\u3044\u3066\u3001\u81ea\u52d5\u7684\u306b micro SD \u30ab\u30fc\u30c9\u306b\u713c\u304d\u3053\u3080\u30d5\u30a1\u30a4\u30eb\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u3088\u3046\u3067\u3059\u3002<br \/>\n<a href=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2015\/12\/image34.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2015\/12\/image_thumb34.png\" border=\"0\" alt=\"image\" title=\"image\" width=\"640\" height=\"395\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-width: 0px;\" \/><\/a><\/p>\n<p>\u3061\u3087\u3063\u3068\u524d\u306e\u5f93\u6765\u306e\u3082\u306e\u306f <a href=\"http:\/\/ms-iot.github.io\/content\/en-US\/Downloads.htm\">Download Windows 10 IoT Core<\/a> \u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u30c8\u30c3\u30d7\u30da\u30fc\u30b8\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u81ea\u4f53\u304c Windows 10 (version 10.0.10240) or better. \u3068\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u3001Windows 10 \u306e\u7d30\u304b\u3044\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u602a\u3057\u3044\u306e\u3067\u3059\u304c\u3001\u30c7\u30d0\u30c3\u30b0\u306e\u95a2\u4fc2\u4e0a Visual Studio \u3067\u4f5c\u6210\u3059\u308b\u30e6\u30cb\u30d0\u30fc\u30b5\u30eb\u30a2\u30d7\u30ea\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3068 Raspberry Pi \u4e0a\u3067\u52d5\u304f Windows IoT Core \u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306f\u63c3\u3048\u306a\u3044\u3068\u3044\u3051\u307e\u305b\u3093\u3002<\/p>\n<p>Visual Studio 2015 \u304b\u3089 Raspberry Pi \u3078\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u9001\u308a\u8fbc\u3080\u306b\u306f\u30ea\u30e2\u30fc\u30c8\u30c7\u30d0\u30c3\u30b0\u304c\u4fbf\u5229\u306a\u306e\u3067\u3059\u304c\u3001\u4f55\u6545\u304b10585 \u7248\u306e\u74b0\u5883\u306b\u306f\u809d\u5fc3\u306a\u30ea\u30e2\u30fc\u30c8\u30c7\u30d0\u30c3\u30b0\u306e\u74b0\u5883\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u305b\u3093\u3002\u5165\u308c\u5fd8\u308c\u305f\u306e\u304b\u3001\u6709\u511f\u7248\u306b\u306f\u5165\u3063\u3066\u3044\u3066\u7121\u511f\u7248\u306b\u306f\u306a\u3044\u306e\u304b\u3001\u306f\u5b9a\u304b\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u304c 10585 \u7248\u306f\u305d\u306e\u307e\u307e\u3067\u306f\u30ea\u30e2\u30fc\u30c8\u30c7\u30d0\u30c3\u30b0\u304c\u3067\u304d\u307e\u305b\u3093\u3002\u3053\u306e\u3042\u305f\u308a\u306f <a href=\"http:\/\/www.moonmile.net\/blog\/archives\/7625\">Windows IoT Core ver.10.0.10586 \u306e\u30c7\u30d0\u30c3\u30b0\u3092\u6709\u52b9\u306b\u3059\u308b | Moonmile Solutions Blog<\/a> \u3092\u53c2\u8003\u306b\u3057\u3066\u3001RDBG \u30d5\u30a9\u30eb\u30c0\u3092\u30b3\u30d4\u30fc\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u76f4\u524d\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306e RDBG \u30d5\u30a9\u30eb\u30c0\u306f <a href=\"http:\/\/1drv.ms\/1QqAKz4\">http:\/\/1drv.ms\/1QqAKz4<\/a> \u306b\u3042\u308a\u307e\u3059\u3002<\/p>\n<h2>\u6642\u8a08\u3092\u52d5\u304b\u3059<\/h2>\n<p>Windows IoT Core \u306f\u30e6\u30cb\u30d0\u30fc\u30b5\u30eb\u30a2\u30d7\u30ea\uff08UWP\uff09\u3067\u4f5c\u308a\u307e\u3059\u304c\u3001\u3053\u308c\u306e\u6700\u5927\u306e\u30e1\u30ea\u30c3\u30c8\u306f\u30e6\u30fc\u30b6\u30fc\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306e\u30c6\u30b9\u30c8\u3092\u666e\u901a\u306e PC \u3067\u884c\u3048\u308b\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>HelloSample \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306f\u3001\u753b\u9762\u306b\u6642\u523b\u3092\u8868\u793a\u3059\u308b\u30a2\u30d7\u30ea\u3067\u3059\u304c\u7279\u306b Raspberry Pi \u306e GPIO \u306a\u3069\u3092\u30a2\u30af\u30bb\u30b9\u3057\u3066\u3044\u308b\u8a33\u3067\u306f\u306a\u3044\u306e\u3067\u3001PC \u4e0a\u3067\u52d5\u304d\u307e\u3059\u3002\u3082\u3061\u308d\u3093\u3001Windows Phone \u4e0a\u3067\u3082\u52d5\u304d\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2015\/12\/image35.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2015\/12\/image_thumb35.png\" border=\"0\" alt=\"image\" title=\"image\" width=\"640\" height=\"418\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-width: 0px;\" \/><\/a><\/p>\n<p>\u307e\u305f\u3001\u753b\u9762\u306f XAML \u3067\u4f5c\u6210\u3059\u308b\u306e\u3067 MVVM \u30d1\u30bf\u30fc\u30f3\u3092\u4f7f\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002HelloSample \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u306f\u3001\u6642\u8a08\u306e\u8868\u793a\u90e8\u5206\u30921\u79d2\u3054\u3068\u306b\u66f4\u65b0\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u3053\u308c\u306f TextBlock \u3092\u76f4\u63a5\u66f4\u65b0\u3057\u3066\u3044\u308b\u308f\u3051\u3067\u306f\u306a\u304f\u3066\u3001\u308f\u3056\u308f\u3056 Binding \u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u7a0b\u5ea6\u3060\u3068\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u3092\u4f7f\u308f\u306a\u304f\u3066\u3044\u3044\u306e\u3067\u3059\u304c\u3001\u307e\u3042\u3001\u5148\u306e Xamarin + MVVM \u306e\u6d41\u308c\u3067\u3053\u3046\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\"> \r\npublic sealed partial class MainPage : Page\r\n{\r\n    public MainPage()\r\n    {\r\n        this.InitializeComponent();\r\n        this.Loaded += (s, e) =&gt;\r\n        {\r\n            this.DataContext = _vm = new ViewModel(this.Dispatcher);\r\n            _vm.TimeStart();\r\n        };\r\n        this.Unloaded += (s, e) =&gt; { _vm.TimeStop(); };\r\n    }\r\n    ViewModel _vm;\r\n}\r\n\r\npublic class ViewModel : INotifyPropertyChanged\r\n{\r\n    public event PropertyChangedEventHandler PropertyChanged;\r\n\r\n    Windows.UI.Core.CoreDispatcher _disp;\r\n\r\n    public ViewModel(Windows.UI.Core.CoreDispatcher disp )\r\n    {\r\n        _disp = disp;\r\n    }\r\n\r\n    private DateTime _time = DateTime.Now;\r\n    public DateTime Time\r\n    {\r\n        get { return _time; }\r\n        set { this.SetProperty(ref _time, value); }\r\n    }\r\n\r\n    Task _task;\r\n    bool _loop = false;\r\n    public void TimeStart()\r\n    {\r\n        _loop = true;\r\n        _task = new Task(async () =&gt; {\r\n            while( _loop )\r\n            {\r\n                await _disp.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =&gt;\r\n                {\r\n                    this.Time = DateTime.Now;\r\n                });\r\n                await Task.Delay(1000);\r\n            }\r\n        });\r\n        _task.Start();\r\n    }\r\n    public void TimeStop()\r\n    {\r\n        _loop = false;\r\n    }\r\n\r\n\r\n    protected bool SetProperty&lt;T&gt;(ref T storage, T value, &#x5B;CallerMemberName] String propertyName = null)\r\n    {\r\n        if (object.Equals(storage, value)) return false;\r\n\r\n        storage = value;\r\n        this.OnPropertyChanged(propertyName);\r\n        return true;\r\n    }\r\n    protected void OnPropertyChanged(&#x5B;CallerMemberName] string propertyName = null)\r\n    {\r\n        var eventHandler = this.PropertyChanged;\r\n        if (eventHandler != null)\r\n        {\r\n            eventHandler(this, new PropertyChangedEventArgs(propertyName));\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p>\u30bf\u30a4\u30de\u30fc\u306f Task \u30af\u30e9\u30b9\u3067\u5225\u30b9\u30ec\u30c3\u30c9\u306b\u3057\u3066\u3044\u308b\u306e\u3067\u3001RunAsync \u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3063\u3066\u30b9\u30ec\u30c3\u30c9\u8d8a\u3048\u3092\u3057\u3066 UI \u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u306e\u3042\u305f\u308a\u3001\u30d7\u30ed\u30d1\u30c6\u30a3\u30a2\u30af\u30bb\u30b9\u3068 UI \u30a2\u30af\u30bb\u30b9\u304c\u6df7\u5728\u3057\u3066\u3044\u308b VM \u306e\u5f31\u70b9\u3067\u3082\u3042\u308a\u307e\u3059\u304c\u3001\u9006\u306b\u8a00\u3048\u3070\u3001Model \u306b\u30b9\u30ec\u30c3\u30c9\u7d61\u307f\u3092\u3044\u308c\u3066\u3057\u307e\u3046\u3068 View \u306e\u7d50\u5408\u304c\u5f37\u304f\u306a\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u672c\u672b\u8ee2\u5012\u3001\u305d\u3046\u306a\u308b\u3068 ViewModel \u306b\u62bc\u3057\u8fbc\u3080\u306e\u304c\u30d9\u30bf\u30fc\u304b\u3001\u3068\u3044\u3063\u305f\u3068\u3053\u308d\u3067\u3059\u3002<\/p>\n<h2>L\u30c1\u30ab\u3068\u30bf\u30af\u30c8\u30b9\u30a4\u30c3\u30c1<\/h2>\n<p>HelloLED \u3067\u306f\u3001GPIO \u3067 L\u30c1\u30ab \u3092\u3059\u308b\u306e\u3068\u3001\u30bf\u30af\u30c8\u30b9\u30a4\u30c3\u30c1\u3068\u3044\u3046\u7269\u7406\u30dc\u30bf\u30f3\u3092\u30d6\u30ec\u30c3\u30c9\u30dc\u30fc\u30c9\u306b\u4e57\u305b\u3066\u30b9\u30a4\u30c3\u30c1\u306b\u53cd\u5fdc\u3059\u308b\u30d1\u30bf\u30fc\u30f3\u3067\u3059\u3002\u3044\u308f\u3070\u3001\u30a2\u30a6\u30c8\u30d7\u30c3\u30c8\u304c L\u30c1\u30ab\u3067\u3001\u30a4\u30f3\u30d7\u30c3\u30c8\u304c\u30bf\u30af\u30c8\u30b9\u30a4\u30c3\u30c1\u3067\u3059\u3002<\/p>\n<p><a href=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2015\/12\/image36.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2015\/12\/image_thumb36.png\" border=\"0\" alt=\"image\" title=\"image\" width=\"571\" height=\"437\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-width: 0px;\" \/><\/a><\/p>\n<p>\u30a2\u30a6\u30c8\u30d7\u30c3\u30c8\u306e\u307b\u3046\u306f\u3001LED \u3060\u3051\u3067\u306a\u304f\u3001\u6db2\u6676\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u3068\u304b\u3001\u30e2\u30fc\u30bf\u30fc\u3078\u306e\u51fa\u529b\u3068\u304b\u3001\u51fa\u529b\u5168\u822c\u3092\u6271\u3046\u305f\u3081\u306e\u57fa\u790e\u306b\u306a\u308a\u307e\u3059\u3002\u30a4\u30f3\u30d7\u30c3\u30c8\u306f\u3001\u6e29\u5ea6\u30bb\u30f3\u30b5\u30fc\u3084\u3001\u30de\u30a6\u30b9\u3084\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u3001\u89d2\u901f\u5ea6\u30bb\u30f3\u30b5\u30fc\u306e\u691c\u51fa\u306a\u3069\u306e\u57fa\u790e\u3067\u3059\u3002\u30a4\u30f3\u30d7\u30c3\u30c8\u306f\u3001OS \u306e\u5272\u308a\u8fbc\u307f\u306e\u3088\u3046\u306a\u3082\u306e\u3067\u3059\u304c\u3001Windows IoT Core \u3067\u306f\u9069\u5f53\u306a\u30a4\u30d9\u30f3\u30c8\u306b\u3057\u3066\u623b\u3057\u3066\u304f\u308c\u307e\u3059\u3002\u3053\u306e\u30a4\u30d9\u30f3\u30c8\u306e\u5185\u90e8\u52d5\u4f5c\u306f\u3001\u5f8c\u3005\u8a73\u3057\u304f\u8aac\u660e\u3057\u305f\u3044\u3068\u601d\u3046\u306e\u3067\u3059\u304c\uff08\u7d50\u5c40\u306e\u3068\u3053\u308d Windows \u306e\u30a4\u30d9\u30f3\u30c8\u99c6\u52d5\u3068\u540c\u3058\u306a\u306e\u3067\uff09\u3001\u3053\u3053\u3067\u306f\u300c\u4fbf\u5229\u306b\u300d\u30a4\u30d9\u30f3\u30c8\u3068\u3057\u3066\u8fd4\u3057\u3066\u304f\u308c\u308b\u3068\u3053\u308d\u306b\u6ce8\u76ee\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u3061\u306a\u307f\u306b\u3001Arduino IDE \u3067\u30bf\u30af\u30c8\u30b9\u30a4\u30c3\u30c1\u3092\u6271\u3046\u3068\u304d\u306f\u610f\u5916\u3068\u9762\u5012\u3067\u3059\u3002<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\npublic MainPage()\r\n{\r\n    this.InitializeComponent();\r\n\r\n    var gpio = GpioController.GetDefault();\r\n    this.ledPin = gpio.OpenPin(LED_PIN);\r\n    this.buttonPin = gpio.OpenPin(BUTTON_PIN);\r\n\r\n    ledPin.SetDriveMode(GpioPinDriveMode.Output);\r\n    buttonPin.SetDriveMode(GpioPinDriveMode.InputPullUp);\r\n\r\n    ledPin.Write(GpioPinValue.Low);\r\n    _isLED = false;\r\n\r\n    buttonPin.ValueChanged += ButtonPin_ValueChanged;\r\n\r\n}\r\n\r\nprivate async void  ButtonPin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)\r\n{\r\n    await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =&gt; {\r\n        \/\/ if (buttonPin.Read() == GpioPinValue.High )\r\n        if ( args.Edge == GpioPinEdge.FallingEdge)\r\n        {\r\n            ellipse1.Fill = new SolidColorBrush(Colors.Red);\r\n        }\r\n        else\r\n        {\r\n            ellipse1.Fill = new SolidColorBrush(Colors.Gray);\r\n        }\r\n    });\r\n}\r\n<\/pre>\n<p>\u30bf\u30af\u30c8\u30b9\u30a4\u30c3\u30c1\u306e\u30dc\u30bf\u30f3\u30a4\u30d9\u30f3\u30c8\u306f\u3001ValueChanged \u3068\u3057\u3066\u6271\u3044\u307e\u3059\u3002\u3053\u308c\u306f Read \u3060\u3051\u3067\u8aad\u307f\u53d6\u308b\u3068\u3001\u62bc\u3057\u3066\u3044\u308b\u77ac\u9593\u306f\u96fb\u6c17\u4fe1\u53f7\u3068\u3057\u3066 +\/- \u3092\u3046\u308d\u3046\u308d\u3059\u308b\u3053\u3068\u304c\u3042\u308b\u304b\u3089\u3067\u3059\u3002\u30bf\u30af\u30c8\u30b9\u30a4\u30c3\u30c1\u3068\u306f\u3044\u3048\u3001\u96fb\u7559\u304c\u6d41\u308c\u308b\u90e8\u5206\u306f\u30a2\u30ca\u30ed\u30b0\u7684\u306a\u96fb\u6c17\u63a5\u70b9\u3067\u3059\u304b\u3089\u3001\u7269\u7406\u7684\u306b\u63a5\u70b9\u304c\u3061\u3087\u3063\u3068\u96e2\u308c\u305f\u308a\u62bc\u3055\u308c\u305f\u308a\u3059\u308b\u308f\u3051\u3067\u3059\u3002\u3067\u3059\u304c\u3001\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u306e\u307b\u3046\u3067\u306f 0\/1 \u306e\u30c7\u30b8\u30bf\u30eb\u3067\u5224\u65ad\u3057\u305f\u3044\u306e\u3067\u3001\u9014\u4e2d\u306e\u63fa\u308c\u306e\u90e8\u5206\u306f\u5fc5\u8981\u3042\u308a\u307e\u305b\u3093\u3002\u3080\u3057\u308d\u30010\/1 \u306e\u3042\u305f\u308a\u3092\u3046\u308d\u3046\u308d\u3057\u3066\u3044\u308b\u306e\u306f\u90aa\u9b54\u3067\u3059\u3088\u306d\u3002\u3068\u3044\u3046\u308f\u3051\u3067\u3001ValueChanged \u30a4\u30d9\u30f3\u30c8\u306f\u3001\u4e00\u5b9a\u306e\u3067\u96fb\u5727\u4ee5\u4e0b\u304b\u3089\u4ee5\u4e0a\u306b\u306a\u308b\u30bf\u30a4\u30df\u30f3\u30b0\u3001\u3042\u308b\u3044\u306f\u4e00\u5b9a\u306e\u96fb\u5727\u4ee5\u4e0a\u304b\u3089\u4ee5\u4e0b\u306b\u306a\u308b\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u30a4\u30d9\u30f3\u30c8\u3092\u767a\u751f\u3057\u3066\u3044\u307e\u3059\u2026\u3063\u3066\u306f\u305a\u306a\u306e\u3067\u3059\u304c\u3001\u5185\u90e8\u306f\u3042\u3068\u3067\u8abf\u3079\u3066\u307f\u307e\u3059\u3002\u5c11\u306a\u304f\u3068\u3082\u3001\u5fae\u5999\u306a\u63a5\u70b9\u306b\u3088\u308b\u3046\u308d\u3044\u308d\u3057\u305f\u3068\u3053\u308d\u3092\u524a\u3063\u3066\u30010\/1 \u3067\u53cd\u5fdc\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u4e00\u898b\u3001UI \u306e\u30dc\u30bf\u30f3\u30a4\u30d9\u30f3\u30c8\u306e\u3088\u3046\u306b\u898b\u3048\u307e\u3059\u304c\u3001\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u304b\u3089\u30a4\u30d9\u30f3\u30c8\u306a\u306e\u3067\u30b9\u30ec\u30c3\u30c9\u8d8a\u3048\u306e\u3068\u304d\u3068\u540c\u3058\u3088\u3046\u306b Dispatcher.RunAsync \u3092\u4f7f\u3046\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u306e\u3042\u305f\u308a\u306e\u30b9\u30ec\u30c3\u30c9\u3092\u610f\u8b58\u3057\u306a\u3051\u308c\u3070\u3044\u3051\u306a\u3044\u306e\u306f\u3001Windows IoT Core \u306e\u96e3\u3057\u3044\u3068\u3053\u308d\u306a\u306e\u304b\u3001\u4e0d\u5099\u306a\u306e\u304b\u306f\u8b0e\u3067\u3059\u2026\u304c\u3001\u30ef\u30bf\u30af\u30b7\u7684\u306b\u306f\u300c\u4e0d\u5099\u300d\u3067\u3059\u306d\u3002\u3082\u3046\u3061\u3087\u3063\u3068 MVVM \u30d1\u30bf\u30fc\u30f3\u3082\u542b\u3081\u3066\u30b9\u30ec\u30c3\u30c9\u8d8a\u3048\u3092\u610f\u8b58\u3057\u306a\u3044\u3088\u3046\u306a\u30b3\u30fc\u30c9\u306b\u3057\u305f\u3044\u3068\u3053\u308d\u3067\u3059\u3002<\/p>\n<h2>\u30e2\u30fc\u30bf\u30fc\u3092\u52d5\u304b\u3059<\/h2>\n<p>\u672c\u5f53\u306f\u30b5\u30fc\u30dc\u30e2\u30fc\u30bf\u30fc\u306e\u5236\u5fa1\u3092\u8a66\u3057\u305f\u304b\u3063\u305f\u306e\u3067\u3059\u304c\u3001Windows.Devices.Pwm \u306e\u4e2d\u8eab\u304c\u304b\u3089\u3063\u307d\u3063\u307d\u3044\u306e\u3067\u3001\u6025\u907d\u30d6\u30e9\u30b7\u30e2\u30fc\u30bf\u306b\u5909\u66f4\u3057\u307e\u3057\u305f\u3002Windows.Devices.Pwm \u306e\u307b\u3046\u306f\u3044\u305a\u308c\u4e2d\u8eab\u3092\u4f5c\u3063\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\npublic sealed partial class MainPage : Page\r\n{\r\n    public MainPage()\r\n    {\r\n        this.InitializeComponent();\r\n        this.Loaded += MainPage_Loaded;\r\n        this.Unloaded += (s, e) =&gt; _motor.Stop();\r\n    }\r\n\r\n    private void MainPage_Loaded(object sender, RoutedEventArgs e)\r\n    {\r\n        var gpio = GpioController.GetDefault();\r\n        _motor = new Motor(gpio.OpenPin(22), gpio.OpenPin(27));\r\n    }\r\n\r\n    Motor _motor;\r\n\r\n    private void clickFront(object sender, RoutedEventArgs e)\r\n    {\r\n        _motor.GoFront();\r\n    }\r\n    private void clickBack(object sender, RoutedEventArgs e)\r\n    {\r\n        _motor.GoBack();\r\n    }\r\n    private void clickStop(object sender, RoutedEventArgs e)\r\n    {\r\n        _motor.Stop();\r\n    }\r\n}\r\n\r\npublic class Motor\r\n{\r\n    GpioPin _front, _back;\r\n    public Motor( GpioPin front, GpioPin back )\r\n    {\r\n        _front = front;\r\n        _back = back;\r\n\r\n        _front.SetDriveMode(GpioPinDriveMode.Output);\r\n        _front.Write(GpioPinValue.Low);\r\n        _back.SetDriveMode(GpioPinDriveMode.Output);\r\n        _back.Write(GpioPinValue.Low);\r\n    }\r\n\r\n    public void GoFront()\r\n    {\r\n        _front.Write(GpioPinValue.High);\r\n        _back.Write(GpioPinValue.Low);\r\n    }\r\n    public void GoBack()\r\n    {\r\n        _front.Write(GpioPinValue.Low);\r\n        _back.Write(GpioPinValue.High);\r\n    }\r\n    public void Stop()\r\n    {\r\n        _front.Write(GpioPinValue.Low);\r\n        _back.Write(GpioPinValue.Low);\r\n    }\r\n}\r\n<\/pre>\n<p>\u30e2\u30fc\u30bf\u30fc\u3092\u524d\u5f8c\u306b\u52d5\u304b\u3059\u305f\u3081\u306b\u306f\u3001+ \u3068 &#8211; \u3092\u4ea4\u63db\u3059\u308c\u3070\u3088\u3044\u3060\u3051\u3067\u3059\u3002\u305f\u3060\u3057\u3001\u3075\u3064\u3046\u306e\u30e2\u30fc\u30bf\u30fc\u3092\u52d5\u304b\u3059\u305f\u3081\u306b\u306f\u3042\u308b\u7a0b\u5ea6\u306e\u96fb\u6d41\u304c\u5fc5\u8981\u306b\u306a\u308b\u306e\u3067\u3001Raspberry Pi \u306e GPIO \u306b\u76f4\u63a5\u3055\u3057\u3066\u52d5\u304b\u3059\u308f\u3051\u306b\u306f\u3044\u304d\u307e\u305b\u3093\u3002\u5225\u9014\u30e2\u30fc\u30bf\u30fc\u30c9\u30e9\u30a4\u30d0\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002\u3061\u306a\u307f\u306b\u3001\u5c0f\u3055\u306a\u30e2\u30fc\u30bf\u30fc\uff08\u643a\u5e2f\u7528\u306e\u632f\u52d5\u30e2\u30fc\u30bf\u30fc\u306a\u3069\uff09\u306f\u76f4\u63a5\u3055\u3057\u3066\u3082\u52d5\u304d\u307e\u3059\u3002<\/p>\n<p>+\/- \u3092\u9006\u8ee2\u3055\u305b\u308b\u305f\u3081\u306b\u30012\u672c\u306eGPIO\u3092\u4f7f\u3044\u307e\u3059\u3002\u305d\u308c\u305e\u308c\u306e GPIO \u306b\u5bfe\u3057\u3066 HIGH\/LOW \u3092\u9006\u8ee2\u3055\u305b\u3066\u3082\u3088\u3044\u306e\u3067\u3059\u304c\u3001\u81ea\u524d\u3067 Motor \u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u306e Motor \u30af\u30e9\u30b9\u3092\u4f7f\u3063\u3066\u5236\u5fa1\u304c\u3067\u304d\u308b\u306e\u304c\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u306e\u3088\u3044\u3068\u3053\u308d\u3067\u3059\u3088\u306d\u3002\u3053\u3053\u306b\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u5236\u5fa1\u3060\u3051\u3067\u306a\u304f\u3001\u6db2\u6676\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u306b\u72b6\u614b\u3092\u3042\u3089\u308f\u3059\u3088\u3046\u306a VM \u3092\u8ffd\u52a0\u3057\u3066\u3044\u3051\u3070\u3001\u3046\u307e\u304f V-VM-M \u304c\u5206\u96e2\u3067\u304d\u308b\u3066\u30b7\u30df\u30e5\u30ec\u30fc\u30bf\u3067\u52d5\u304b\u3057\u305f\u308a\u3001\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u7d4c\u7531\u3067\u52d5\u304b\u3057\u305f\u308a\u3068\u3044\u3046\u30a2\u30b9\u30da\u30af\u30c8\u6307\u5411\u7684\u306a\u5b9f\u88c5\u3082\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5148\u6708\u306e .NET\u30e9\u30dc\u3067 Windows IoT Core \u306e\u30c7\u30e2\u3092\u3084\u308a\u307e\u3057\u305f\u304c\u3001\u305d\u3053\u3067\u4f7f\u3063\u305f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u516c\u958b\u3057\u307e\u3059\u3002 moonmile\/WinIoT https:\/\/github.com\/moonmile\/WinIoT &hellip; <a href=\"http:\/\/www.moonmile.net\/blog\/archives\/7645\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[23,67],"tags":[],"class_list":["post-7645","post","type-post","status-publish","format-standard","hentry","category-csharp","category-raspberrypi"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/7645","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/comments?post=7645"}],"version-history":[{"count":2,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/7645\/revisions"}],"predecessor-version":[{"id":7647,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/7645\/revisions\/7647"}],"wp:attachment":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/media?parent=7645"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/categories?post=7645"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/tags?post=7645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}