2013年9月22日日曜日

Google Test 1.7.0 がリリースされました

Google Test 1.7.0 がリリースされました。ダウンロードはこちらから。
1.6.0 から約2年ぶりのリリースになります。

1.7.0 RC の時点での変更点は「Google Test 1.7.0 RC がリリースされました」で書いていますので、
そちらを参照してください。
1.7.0 RC から 1.7.0 で、1つだけ変更があったので書き出しておきます。

新機能
New feature: Google Test now implements a protocol to allow
a test runner to detect that a test program has exited
prematurely and report it as a failure (before it would be
falsely reported as a success if the exit code is 0).
テスト開始時に、環境変数 [TEST_PREMATURE_EXIT_FILE] に指定されたファイルパスにファイルを作成します。
テスト終了時に、このファイルは削除されます。

これにより、テストが最後まで実行されたのか、途中で中断したのかを判断することができます。

まとめ
さて、gtest 1.7.0 がリリースされたことですし、iutest も 1.7.0 をリリースしていこうかと思います。
では。

2013年9月17日火曜日

続々・Arduino はじめました

さて、前回は LED を見事に焦がしてしまいましたが、
今回は、LEDマトリックスが届いたので、シフトレジスタも買って LED 光らせたので、そのご報告でございます。

シフトレジスタ
今回買ったのは 74HC595 です。
74HC595 を選んだ理由は、チュートリアルで使わていたからです。

というわけで、チュートリアルを見ながら制御してみました。
特につまずくところはありませんでした。
チュートリアルの通りに配線して、サンプルのコードをコピペですぐにできました。

(写真は撮り忘れたので割愛)
//Pin connected to ST_CP of 74HC595
int latchPin = 8;
//Pin connected to SH_CP of 74HC595
int clockPin = 12;
////Pin connected to DS of 74HC595
int dataPin = 11;

void setup() {
  //set pins to output so you can control the shift register
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
}

void loop() {
  // count from 0 to 255 and display the number 
  // on the LEDs
  for (int numberToDisplay = 0; numberToDisplay < 256; numberToDisplay++) {
    // take the latchPin low so 
    // the LEDs don't change while you're sending in bits:
    digitalWrite(latchPin, LOW);
    // shift out the bits:
    shiftOut(dataPin, clockPin, MSBFIRST, numberToDisplay);  

    //take the latch pin high so the LEDs will light up:
    digitalWrite(latchPin, HIGH);
    // pause before next value:
    delay(500);
  }
}

LED マトリックス点灯式
マトリックスの資料を見たら 5V って書いてあったので、大丈夫だろとぶっ刺しました。
(前回の反省が活かされていませんね…ゾクゾクしますね…)

アノード側にシフトレジスタからの出力をつなぎます。
とりあえず全部点灯でいいのでカソード側を GND に繋ぎました。


点いた\(^o^)/

ダイナミック点灯
さて、このままでは1行/1列ずつしか LED を制御できません。

一個一個の LED を制御するためにダイナミック点灯制御を行います。
ダイナミック点灯は、1つ(1列)ずつ点灯・消灯の操作をものすごく速いスピードでやることで、
人間の目にはすべての LED が同時に制御されているかのように見せる方法です。

シフトレジスタで 1bit ずつ出力するようにずらしながら、(制御ラインの選択)
もう一方の線で LED の ON/OFF を制御します。

int latchPin = 8;  // 74HC595のST_CPへ
int clockPin = 12; // 74HC595のSH_CPへ
int dataPin = 11;  // 74HC595のDSへ
int ledPin = 13;

void setup() {
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
}
 
void loop() {
  // LED1からLED8までを順に光らせます
  for (int j = 0; j < 16; j++) {
    // 送信中のlatchPinはグランド(LOW)レベル
    digitalWrite(latchPin, LOW);
    // シフト演算を使って点灯するLEDを選択しています
    shiftOut(dataPin, clockPin, LSBFIRST, (1<<j)>>8);
    shiftOut(dataPin, clockPin, LSBFIRST, 1<<j);
    if( j % 2 == 0 ) {
      digitalWrite(ledPin, LOW);
    } else {
      digitalWrite(ledPin, HIGH);
    }
    // 送信終了後latchPinをHIGHにする
    digitalWrite(latchPin, HIGH);
    delay(100);
  }
}

1行だけですが、飛び飛びに LED を光らせることに成功しました~


デイジーチェーン
シフトレジスタ(74HC595) を複数つなげることで、少ないピンでよりたくさんの LED を制御できるようになります。
74HC595 の Serial Out ピンからの出力をつなげるもう1つの 74HC595 の Serial data input ピンにつなげてやります。

詳しくは、チュートリアルの Exsample2 を参照してください。

これにより、3本の制御線で 16個、24個、32個... の LED を制御できるようになります。
すごいですねぇ~

今回の LEDマトリックスは 48ピンですので、シフトレジスタが 6個必要になります。
アノード制御と赤色/緑色LED の制御にそれぞれ 16ピンずつ使い、それぞれ独立して制御しようと思っているので、
シフトレジスタを2個ずつ、デイジーチェーンでつなげました。



これで、単純計算で 6 x 3 の 18本必要だった線が、3 x 3 の 9本で済みました。

次回
次は TLC5940 を使って調光をできるようにしたいなぁと思っていたのですが、
時間があまりないので全部シフトレジスタで制御するようにして、
実コードを書いていきたいと思います。

では。

2013年9月10日火曜日

Google Test 1.7.0 RC がリリースされました

(公開されてから少し経ちましたが…)
Google Test の version 1.7.0 release candidate がリリースされました。
約2年ぶりの更新になります。

変更履歴はこちら。
Changes for 1.7.0:

* New feature: death tests are supported on OpenBSD and in iOS
  simulator now.
* New feature: Test::RecordProperty() can now be used outside of the
  lifespan of a test method, in which case it will be attributed to
  the current test case or the test program in the XML report.
* New feature (potentially breaking): --gtest_list_tests now prints
  the type parameters and value parameters for each test.
* Improvement: char pointers and char arrays are now escaped properly
  in failure messages.
* Improvement: failure summary in XML reports now includes file and
  line information.
* Improvement: the <testsuites> XML element now has a timestamp attribute.
* Improvement: When --gtest_filter is specified, XML report now doesn't
  contain information about tests that are filtered out.
* Fixed the bug where long --gtest_filter flag values are truncated in
  death tests.
* Potentially breaking change: RUN_ALL_TESTS() is now implemented as a
  function instead of a macro in order to work better with Clang.
* Compatibility fixes with C++ 11 and various platforms.
* Bug/warning fixes.
今回の変更点をざっと見ていきたいと思います。

New feature: death tests are supported on OpenBSD and in iOS simulator now.
DEATHテストが OpenBSD と iOS シミュレータでも使えるようになった。

New feature: Test::RecordProperty() can now be used outside of the lifespan of a test method, in which case it will be attributed to the current test case or the test program in the XML report
RecordProperty がテスト期間以外でも呼べるようになります。
例えば、SetUpTestCase で呼ぶと XML の <testsuite> に保存されます。

New feature (potentially breaking): --gtest_list_tests now prints the type parameters and value parameters for each test.
--gtest_list_tests で表示されるテストリストにパラメータの型や値を表示するようになりました。

v1.6.0 の場合

v1.7.0 の場合

Improvement: char pointers and char arrays are now escaped properly in failure messages.
char* や char[] のメッセージ出力が改善されました。

Improvement: failure summary in XML reports now includes file and line information.
XML の失敗メッセージにファイルと行数を含むようになりました。

Improvement: the <testsuites> XML element now has a timestamp attribute.
XML の testsuites ノードに timestamp 属性を書き込むようになりました。

Improvement: When --gtest_filter is specified, XML report now doesn't contain information about tests that are filtered out.
--gtest_filter で除外されたテストは XML に出力しないようになりました。

Fixed the bug where long --gtest_filter flag values are truncated in death tests.
--gtest_filter の文字列が長い場合に、DEATHテストに送られる文字列が切り捨てられる不具合が修正されました。

Potentially breaking change: RUN_ALL_TESTS() is now implemented as a function instead of a macro in order to work better with Clang.
RUN_ALL_TESTS がマクロから関数になりました。

Compatibility fixes with C++ 11 and various platforms.
C++11 やその他のプラットフォームへの対応が入りました。

全くもって説明なっていませんね・・・すみません。。。

おおまかにいうと
「様々なプラットフォームへの対応と XML 出力が便利になりました」って感じでしょうか。
バグ修正や細かいところで使いやすくなっているので、
とりあえず 1.7.0 RC 使って正式版に備えておくといいかもしれません。