﻿<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ねっとでいいの for all netduino users &#187; Netduino</title>
	<atom:link href="http://tinyjoker.net/netduino/c/common/feed/" rel="self" type="application/rss+xml" />
	<link>http://tinyjoker.net/netduino</link>
	<description>Netduino と .NET Micro Framework に関する情報、Tips、ライブラリなど</description>
	<lastBuildDate>Thu, 19 Jul 2012 06:28:20 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>ファーストコード</title>
		<link>http://tinyjoker.net/netduino/common/first-code/</link>
		<comments>http://tinyjoker.net/netduino/common/first-code/#comments</comments>
		<pubDate>Thu, 19 Jul 2012 06:28:20 +0000</pubDate>
		<dc:creator>kyamada</dc:creator>
				<category><![CDATA[Netduino]]></category>
		<category><![CDATA[LED]]></category>

		<guid isPermaLink="false">http://tinyjoker.net/netduino/?p=107</guid>
		<description><![CDATA[とりあえず Netduino の動作確認に使えるファーストコード。 オンボードの LED を一生チカチカさせるだけです。 public static void Main&#40;&#41; &#123; &#160; &#160; &#160;OutputPort led = new OutputPort&#40;Pins.ONBOARD_LED, false&#41;; &#160; &#160; &#160;while &#40;true&#41; &#160; &#160; &#160;&#123; &#160; &#160; &#160; &#160; &#160; led.Write&#40;!led.Read&#40;&#41;&#41;; &#160; &#160; &#160; &#160; &#160; Thread.Sleep&#40;1000&#41;; &#160; &#160; &#8230; <a href="http://tinyjoker.net/netduino/common/first-code/">続きを読む <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>とりあえず Netduino の動作確認に使えるファーストコード。</p>
<p>オンボードの LED を一生チカチカさせるだけです。</p>
<p><span id="more-107"></span></p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> Main<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;OutputPort led <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> OutputPort<span style="color: #008000;">&#40;</span>Pins<span style="color: #008000;">.</span><span style="color: #0000FF;">ONBOARD_LED</span>, <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">while</span> <span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; led<span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span>led<span style="color: #008000;">.</span><span style="color: #0000FF;">Read</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Thread<span style="color: #008000;">.</span><span style="color: #0000FF;">Sleep</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">1000</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://tinyjoker.net/netduino/common/first-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Netduinoの仕様</title>
		<link>http://tinyjoker.net/netduino/common/netduino_specs/</link>
		<comments>http://tinyjoker.net/netduino/common/netduino_specs/#comments</comments>
		<pubDate>Thu, 15 Mar 2012 08:15:47 +0000</pubDate>
		<dc:creator>kyamada</dc:creator>
				<category><![CDATA[Netduino]]></category>
		<category><![CDATA[Netduino Plus]]></category>

		<guid isPermaLink="false">http://tinyjoker.net/netduino/?p=96</guid>
		<description><![CDATA[公式ページで仕様は確認できるが、日本語ではまとまったものがないので、ここにまとめておく。 基本仕様 マイコン Atmel 32-bit ARM7 マイコン AT91SAM7X512 48MHz コード領域 128KB RAM 60KB 電源 DC 7.5 &#8211; 12.0V or USB 出力可能電圧 DC5V、DC3.3V アナログ参照電圧 DC2.6 &#8211; 3.3V 各ポート最大電流 8 mA/ピン デジタル 2, 3, 7: 16 mA/ピン アナログ 0-3: 2 mA/ピン マイコン全体の最大電流: &#8230; <a href="http://tinyjoker.net/netduino/common/netduino_specs/">続きを読む <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>公式ページで仕様は確認できるが、日本語ではまとまったものがないので、ここにまとめておく。<br />
<span id="more-96"></span></p>
<h2>基本仕様</h2>
<table>
<tbody>
<tr>
<th>マイコン</th>
<td>Atmel 32-bit ARM7 マイコン<br />
AT91SAM7X512<br />
48MHz</td>
</tr>
<tr>
<th>コード領域</th>
<td>128KB</td>
</tr>
<tr>
<th>RAM</th>
<td>60KB</td>
</tr>
<tr>
<th>電源</th>
<td>DC 7.5 &#8211; 12.0V or USB</td>
</tr>
<tr>
<th>出力可能電圧</th>
<td>DC5V、DC3.3V</td>
</tr>
<tr>
<th>アナログ参照電圧</th>
<td>DC2.6 &#8211; 3.3V</td>
</tr>
<tr>
<th>各ポート最大電流</th>
<td>8 mA/ピン<br />
デジタル 2, 3, 7: 16 mA/ピン<br />
アナログ 0-3: 2 mA/ピン<br />
マイコン全体の最大電流: 200mA</td>
</tr>
<tr>
<th>デジタルIO電圧</th>
<td>3.3V<br />
ただし、入力は5Vまで可</td>
</tr>
<tr>
<th> デジタルIO</th>
<td>最大20ポート</td>
</tr>
<tr>
<th></th>
<td>UART, PWM, SPI MOSI, MISO, SPCK, I2C SDA, SCL</td>
</tr>
<tr>
<th></th>
<td></td>
</tr>
</tbody>
</table>
<h2>ADコンバータの仕様</h2>
<p>これはAT91SAM7X512の内蔵ADCを利用しているので、この仕様に依る。</p>
<table>
<tbody>
<tr>
<th>ポート数</th>
<td>6</td>
</tr>
<tr>
<th>分解能</th>
<td>10bits</td>
</tr>
<tr>
<th>サンプリングレート</th>
<td>384ksps</td>
</tr>
<tr>
<th>リファレンス電圧</th>
<td>DC2.6 &#8211; 3.3V</td>
</tr>
<tr>
<th> 最大電流</th>
<td>2mA/ピン（0-3）<br />
8mA/ピン（4, 5）</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://tinyjoker.net/netduino/common/netduino_specs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>時間関連のユーティリティメソッドまとめ</title>
		<link>http://tinyjoker.net/netduino/common/time-util/</link>
		<comments>http://tinyjoker.net/netduino/common/time-util/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 06:32:39 +0000</pubDate>
		<dc:creator>kyamada</dc:creator>
				<category><![CDATA[Netduino]]></category>
		<category><![CDATA[.NET MF]]></category>
		<category><![CDATA[日付・時間]]></category>

		<guid isPermaLink="false">http://tinyjoker.net/netduino/?p=84</guid>
		<description><![CDATA[Netduinoの場合、マイコンという性質上、普通の.NETプログラムに比べて、時間に関連したコードはかなり多い。が、意外にも時間にまつわるメソッドたちは少ない。ということで、毎回それなりに同じようなユーティリティメソッドを書くわけだが、それも煩雑なので、1つのクラスにまとめた。 ソースコード このクラスは発展途上なので、たぶんメソッドが増えていきます。 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263/// &#60;summary&#62; /// 時間に関するユーティリティクラス /// &#60;/summary&#62; public static class TimeUtil &#123; &#160; &#160; /// &#60;summary&#62; &#160; &#160; /// 1[ms] が何 [Ticks] に相当するかを表します。Netduino では通常 10000[Ticks/ms] です。 &#160; &#160; /// &#60;/summary&#62; &#160; &#160; public const long TICKS_PER_MILLISECOND = System.TimeSpan.TicksPerMillisecond; &#8230; <a href="http://tinyjoker.net/netduino/common/time-util/">続きを読む <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Netduinoの場合、マイコンという性質上、普通の.NETプログラムに比べて、時間に関連したコードはかなり多い。が、意外にも時間にまつわるメソッドたちは少ない。ということで、毎回それなりに同じようなユーティリティメソッドを書くわけだが、それも煩雑なので、1つのクラスにまとめた。<br />
<span id="more-84"></span></p>
<h3>ソースコード</h3>
<p>このクラスは発展途上なので、たぶんメソッドが増えていきます。</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span><br />
<span style="color: #008080; font-style: italic;">/// 時間に関するユーティリティクラス</span><br />
<span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span><br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">class</span> TimeUtil<br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// 1[ms] が何 [Ticks] に相当するかを表します。Netduino では通常 10000[Ticks/ms] です。</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">long</span> TICKS_PER_MILLISECOND <span style="color: #008000;">=</span> <span style="color: #000000;">System</span><span style="color: #008000;">.</span><span style="color: #0000FF;">TimeSpan</span><span style="color: #008000;">.</span><span style="color: #0000FF;">TicksPerMillisecond</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// 現在時刻をティックカウント [ms] で取得します。</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">long</span> TickMS<br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> DateTime<span style="color: #008000;">.</span><span style="color: #0000FF;">Now</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Ticks</span> <span style="color: #008000;">/</span> TICKS_PER_MILLISECOND<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// 指定したティックカウント [ms] からの経過時間をミリ秒で取得します。</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;src&quot;&gt;&lt;/param&gt;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;&lt;/returns&gt;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">long</span> GetElapsedMS<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">long</span> src<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">long</span> current <span style="color: #008000;">=</span> TickMS<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> current <span style="color: #008000;">-</span> src<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
<br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// 機械時刻をティックカウントで取得します。</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;&lt;/returns&gt;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">long</span> GetMachineTimeTicks<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> Microsoft<span style="color: #008000;">.</span><span style="color: #0000FF;">SPOT</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Hardware</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Utility</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetMachineTime</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Ticks</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// 指定した時間 [ms] 待機します。このメソッドは Thread.Sleep より少し正確ですが、精度は環境によります。</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// 10[ms] 以上のタイムアウトには Thread.Sleep を使ってください。</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;timeoutMilliseconds&quot;&gt;&lt;/param&gt;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> SleepMS<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">long</span> timeoutMilliseconds<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">long</span> target <span style="color: #008000;">=</span> DateTime<span style="color: #008000;">.</span><span style="color: #0000FF;">Now</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Ticks</span> <span style="color: #008000;">+</span> timeoutMilliseconds <span style="color: #008000;">*</span> TICKS_PER_MILLISECOND<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">while</span> <span style="color: #008000;">&#40;</span>DateTime<span style="color: #008000;">.</span><span style="color: #0000FF;">Now</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Ticks</span> <span style="color: #008000;">&gt;=</span> target<span style="color: #008000;">&#41;</span> <span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// 指定した時間 [us] 待機します。このメソッドは 500[us] 程度の分解能で、1[ms] 以下の待機時間が必要なときに使用します。</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// 2000[ms] 以上のタイムアウトには SleepMS や Thread.Sleep を使ってください。</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;microseconds&quot;&gt;&lt;/param&gt;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> SleepUS<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">double</span> microseconds<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>microseconds <span style="color: #008000;">&lt;</span> <span style="color: #FF0000;">300</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; var start <span style="color: #008000;">=</span> GetMachineTimeTicks<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">-</span> <span style="color: #FF0000;">3000</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; microseconds <span style="color: #008000;">*=</span> <span style="color: #FF0000;">10</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">while</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>GetMachineTimeTicks<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">-</span> start<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&lt;</span> microseconds<span style="color: #008000;">&#41;</span> <span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://tinyjoker.net/netduino/common/time-util/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>チャタリング対策済みボタン用入力ポート</title>
		<link>http://tinyjoker.net/netduino/common/button-port/</link>
		<comments>http://tinyjoker.net/netduino/common/button-port/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 05:38:15 +0000</pubDate>
		<dc:creator>kyamada</dc:creator>
				<category><![CDATA[Netduino]]></category>
		<category><![CDATA[DIO]]></category>

		<guid isPermaLink="false">http://tinyjoker.net/netduino/?p=79</guid>
		<description><![CDATA[InputPortのグリッチフィルター（たぶんチャタリング軽減フィルター）をオンにしても、チャタリングが起こるので、対策してみた。押しっぱなしにされたときのイベントも実装してある。 動作概要 想定しているボタンはタクトスイッチのようなモーメンタリ（自動復帰型）スイッチ。 「ボタンを押した」とみなす時間をPressTime[ms]で設定する。50[ms]でだいたいうまく動作したので、既定値にしてある。これ以下だとチャタリングが起こることがある。 ボタンを一回押すと、Pressイベントが発生する。 さらにRepeatTimeLag[ms]ボタンを押したままにするとRepeatInterval[ms]ごとに PressRepeatイベントが起こる。 押しっぱなしで早送りなどの機能をつけたいときに役に立つと思う。 使い方 基本的にはピンを指定してインスタンス化し、イベントを設定しておくだけ。 ただ、裏でチェック用のループは動かしていないので、メインループかどこかでCheckメソッドを呼ぶ必要がある。 12345678ButtonPort button = new ButtonPort&#40;Pins.GPIO_PIN_D13&#41;; button.Press += new NativeEventHandler&#40;button_Press&#41;; button.PressRepeat += new NativeEventHandler&#40;button_PressRepeat&#41;; while&#40;true&#41; &#123; &#160; &#160; button.Check&#40;&#41;; // 状態のチェック &#160; &#160; Thread.Sleep&#40;100&#41;; &#125; ソースコード なお、実行には時間のユーティリティクラス TimeUtil（こちら）が必要。 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899/// &#60;summary&#62; &#8230; <a href="http://tinyjoker.net/netduino/common/button-port/">続きを読む <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>InputPortのグリッチフィルター（たぶんチャタリング軽減フィルター）をオンにしても、チャタリングが起こるので、対策してみた。押しっぱなしにされたときのイベントも実装してある。<br />
<span id="more-79"></span></p>
<h3>動作概要</h3>
<p>想定しているボタンはタクトスイッチのようなモーメンタリ（自動復帰型）スイッチ。</p>
<p>「ボタンを押した」とみなす時間をPressTime[ms]で設定する。50[ms]でだいたいうまく動作したので、既定値にしてある。これ以下だとチャタリングが起こることがある。<br />
ボタンを一回押すと、Pressイベントが発生する。</p>
<p>さらにRepeatTimeLag[ms]ボタンを押したままにするとRepeatInterval[ms]ごとに PressRepeatイベントが起こる。<br />
押しっぱなしで早送りなどの機能をつけたいときに役に立つと思う。</p>
<h3>使い方</h3>
<p>基本的にはピンを指定してインスタンス化し、イベントを設定しておくだけ。<br />
ただ、裏でチェック用のループは動かしていないので、メインループかどこかでCheckメソッドを呼ぶ必要がある。</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ButtonPort button <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> ButtonPort<span style="color: #008000;">&#40;</span>Pins<span style="color: #008000;">.</span><span style="color: #0000FF;">GPIO_PIN_D13</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
button<span style="color: #008000;">.</span><span style="color: #0000FF;">Press</span> <span style="color: #008000;">+=</span> <span style="color: #008000;">new</span> NativeEventHandler<span style="color: #008000;">&#40;</span>button_Press<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
button<span style="color: #008000;">.</span><span style="color: #0000FF;">PressRepeat</span> <span style="color: #008000;">+=</span> <span style="color: #008000;">new</span> NativeEventHandler<span style="color: #008000;">&#40;</span>button_PressRepeat<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">while</span><span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; button<span style="color: #008000;">.</span><span style="color: #0000FF;">Check</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// 状態のチェック</span><br />
&nbsp; &nbsp; Thread<span style="color: #008000;">.</span><span style="color: #0000FF;">Sleep</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">100</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<h3>ソースコード</h3>
<p>なお、実行には時間のユーティリティクラス TimeUtil（<a href="http://tinyjoker.net/netduino/common/time-util/" title="時間関連のユーティリティメソッドまとめ">こちら</a>）が必要。</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span><br />
<span style="color: #008080; font-style: italic;">/// ボタンを接続する入力ポートです。</span><br />
<span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span><br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> ButtonPort <span style="color: #008000;">:</span> InputPort<br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// グリッチフィルター有、プルアップ抵抗有でボタン用入力ポートを初期化します。</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;portId&quot;&gt;&lt;/param&gt;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> ButtonPort<span style="color: #008000;">&#40;</span>Cpu<span style="color: #008000;">.</span><span style="color: #0000FF;">Pin</span> portId<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">:</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">&#40;</span>portId, <span style="color: #0600FF; font-weight: bold;">true</span>, ResistorMode<span style="color: #008000;">.</span><span style="color: #0000FF;">PullUp</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span> <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// グリッチフィルター、プルアップ抵抗を指定してボタン用入力ポートを初期化します。</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;portId&quot;&gt;&lt;/param&gt;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;glitchFilter&quot;&gt;&lt;/param&gt;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;registorMode&quot;&gt;&lt;/param&gt;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> ButtonPort<span style="color: #008000;">&#40;</span>Cpu<span style="color: #008000;">.</span><span style="color: #0000FF;">Pin</span> portId, <span style="color: #6666cc; font-weight: bold;">bool</span> glitchFilter, ResistorMode registorMode<span style="color: #008000;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">:</span> <span style="color: #0600FF; font-weight: bold;">base</span><span style="color: #008000;">&#40;</span>portId, glitchFilter, registorMode<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; PressTime <span style="color: #008000;">=</span> <span style="color: #FF0000;">50</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; RepeatTimeLag <span style="color: #008000;">=</span> <span style="color: #FF0000;">800</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; RepeatInterval <span style="color: #008000;">=</span> <span style="color: #FF0000;">500</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Reverse <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// ボタンが押されたとして判定する時間 [ms]（初期値:50[ms]）</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> PressTime <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// ボタンが押しっぱなしにされたとき、最初の PressRepeat イベントが起こるまでの時間 [ms]（初期値:800[ms]）</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> RepeatTimeLag <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// ボタンが押しっぱなしにされたとき、Press イベントを発生させる間隔 [ms]（初期値:500[ms]）</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> RepeatInterval <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// 論理を反転するかどうか（初期値:true）</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> Reverse <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
<br />
<br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">bool</span> _PrevState <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">long</span> _PressStartTick <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">long</span> _RepeatCounter <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">bool</span> _IsPressInvoked <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">event</span> NativeEventHandler Press<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">event</span> NativeEventHandler PressRepeat<span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// メインループから呼び出します。</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Check<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">bool</span> currentState <span style="color: #008000;">=</span> Reverse <span style="color: #008000;">^</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Read</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// 逆論理の場合はひっくり返す</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>currentState <span style="color: #008000;">&amp;&amp;</span> _PrevState<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>_PressStartTick <span style="color: #008000;">==</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> _PressStartTick <span style="color: #008000;">=</span> TimeUtil<span style="color: #008000;">.</span><span style="color: #0000FF;">TickMS</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span>_IsPressInvoked<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>TimeUtil<span style="color: #008000;">.</span><span style="color: #0000FF;">GetElapsedMS</span><span style="color: #008000;">&#40;</span>_PressStartTick<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&gt;=</span> PressTime<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Press イベント</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>Press <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span> Press<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">uint</span><span style="color: #008000;">&#41;</span>TimeUtil<span style="color: #008000;">.</span><span style="color: #0000FF;">TickMS</span>, <span style="color: #FF0000;">0</span>, DateTime<span style="color: #008000;">.</span><span style="color: #0000FF;">Now</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _IsPressInvoked <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>TimeUtil<span style="color: #008000;">.</span><span style="color: #0000FF;">GetElapsedMS</span><span style="color: #008000;">&#40;</span>_PressStartTick<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&gt;=</span> RepeatTimeLag <span style="color: #008000;">&amp;&amp;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TimeUtil<span style="color: #008000;">.</span><span style="color: #0000FF;">GetElapsedMS</span><span style="color: #008000;">&#40;</span>_RepeatCounter<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&gt;=</span> RepeatInterval<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// PressRepeat イベント</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>PressRepeat <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span> PressRepeat<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">uint</span><span style="color: #008000;">&#41;</span>TimeUtil<span style="color: #008000;">.</span><span style="color: #0000FF;">TickMS</span>, <span style="color: #FF0000;">0</span>, DateTime<span style="color: #008000;">.</span><span style="color: #0000FF;">Now</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _RepeatCounter <span style="color: #008000;">=</span> TimeUtil<span style="color: #008000;">.</span><span style="color: #0000FF;">TickMS</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _PrevState <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _PressStartTick <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _RepeatCounter <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _IsPressInvoked <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; _PrevState <span style="color: #008000;">=</span> currentState<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://tinyjoker.net/netduino/common/button-port/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>出力ポートを使う</title>
		<link>http://tinyjoker.net/netduino/common/ouputport/</link>
		<comments>http://tinyjoker.net/netduino/common/ouputport/#comments</comments>
		<pubDate>Fri, 21 Oct 2011 03:29:32 +0000</pubDate>
		<dc:creator>kyamada</dc:creator>
				<category><![CDATA[Netduino]]></category>
		<category><![CDATA[.NET MF]]></category>
		<category><![CDATA[DIO]]></category>
		<category><![CDATA[LED]]></category>

		<guid isPermaLink="false">http://tinyjoker.net/netduino/?p=73</guid>
		<description><![CDATA[NetduinoとPlusはデジタル出力14ポート、アナログの6ポートも合わせると20ポートが利用できる。 OutputPortクラスのインスタンスを作るだけで非常に簡単に利用することができる。 Netduino上にはテスト用？のLEDが1つ実装されていて、デジタル出力ポートに接続されている。 このLEDを光らせるには、下記のようなコードを書けばよい。 OutputPort led = new OutputPort&#40;Pins.ONBOARD_LED, false&#41;; led.Write&#40;true&#41;; // 光る OutputPortの第1引数にはピンの番号を渡す（Cpu.Pinクラス）。NetduinoのポートはPinsに定義されているので、それを利用できる。Pins.ONBOARD_LEDがその名の通りボード上のLEDのポートを表している。 そのほかのピンは同様にGPIO_PIN_D0やGPIO_PIN_A0などの名前で定義されているので、これを利用する。 第2引数は初期値で、trueを指定すると、初期状態でHになる。 インスタンス化したあとはWriteメソッドにbool値を渡せば出力が切り替えられる（true=H, false=L）。]]></description>
			<content:encoded><![CDATA[<p>NetduinoとPlusはデジタル出力14ポート、アナログの6ポートも合わせると20ポートが利用できる。<br />
OutputPortクラスのインスタンスを作るだけで非常に簡単に利用することができる。</p>
<p><span id="more-73"></span></p>
<p>Netduino上にはテスト用？のLEDが1つ実装されていて、デジタル出力ポートに接続されている。<br />
このLEDを光らせるには、下記のようなコードを書けばよい。</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">OutputPort led <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> OutputPort<span style="color: #008000;">&#40;</span>Pins<span style="color: #008000;">.</span><span style="color: #0000FF;">ONBOARD_LED</span>, <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
led<span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// 光る</span></div></div>
<p>OutputPortの第1引数にはピンの番号を渡す（Cpu.Pinクラス）。NetduinoのポートはPinsに定義されているので、それを利用できる。Pins.ONBOARD_LEDがその名の通りボード上のLEDのポートを表している。<br />
そのほかのピンは同様にGPIO_PIN_D0やGPIO_PIN_A0などの名前で定義されているので、これを利用する。</p>
<p>第2引数は初期値で、trueを指定すると、初期状態でHになる。</p>
<p>インスタンス化したあとはWriteメソッドにbool値を渡せば出力が切り替えられる（true=H, false=L）。</p>
]]></content:encoded>
			<wfw:commentRss>http://tinyjoker.net/netduino/common/ouputport/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>システム時刻を設定する</title>
		<link>http://tinyjoker.net/netduino/common/system-time/</link>
		<comments>http://tinyjoker.net/netduino/common/system-time/#comments</comments>
		<pubDate>Tue, 18 Oct 2011 08:50:23 +0000</pubDate>
		<dc:creator>kyamada</dc:creator>
				<category><![CDATA[Netduino]]></category>
		<category><![CDATA[日付・時間]]></category>

		<guid isPermaLink="false">http://tinyjoker.net/netduino/?p=25</guid>
		<description><![CDATA[DateTime.Nowなどで取得できるnetduino自体の時刻は、Utility.SetLocalTimeメソッドで書き換えることができる。 ただ、ネットワークにつながっていない場合は必要がなさそうだ。まぁ、時計ぐらいか。 Utility.SetLocalTime&#40;datetime&#41;;]]></description>
			<content:encoded><![CDATA[<p>DateTime.Nowなどで取得できるnetduino自体の時刻は、Utility.SetLocalTimeメソッドで書き換えることができる。<br />
<span id="more-25"></span><br />
ただ、ネットワークにつながっていない場合は必要がなさそうだ。まぁ、時計ぐらいか。</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Utility<span style="color: #008000;">.</span><span style="color: #0000FF;">SetLocalTime</span><span style="color: #008000;">&#40;</span>datetime<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://tinyjoker.net/netduino/common/system-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
