目次

制御動作検討

 GBCから画像データを取得するための動作を考えます。

 シーケンスは、以下としました。
  1. カメラをリセット
  2. モード指定用パラメータ送信
  3. 撮影
 カメラの動作をテストするので、1〜3の処理を1文字のコマンドに  割り当てます。  パーソナルコンピュータからコマンドを受信し、動作を決める  インタプリタを定義します。 モード指定用パラメータを送信する場合、デフォルトの内容を決めた  方が簡単なので、対応する関数を定義します。 void send_default(void) { send_cam((0 << 8) | 0x80); /* exposure */ send_cam((1 << 8) | 0x03); /* exposure time change this to adjust picture light */ send_cam((2 << 8) | 0x00); send_cam((3 << 8) | 0x30); send_cam((4 << 8) | 0x01); send_cam((5 << 8) | 0x00); send_cam((6 << 8) | 0x01); send_cam((7 << 8) | 0x21); }  細かくモードを指定したい場合には、コマンド'R'を使います。  ヘルプで、コマンド'?'を用意します。 void uart_interpreter(void) { UBYTE cmd ; UBYTE chx ; UBYTE dir ; UBYTE val[2] ; /* get command character */ cmd = *(sbuf+0) ; /* reset camera */ if ( cmd == 'C' ) { reset_cam() ; } /* set register value */ if ( cmd == 'R' ) { /* get channel */ chx = get_hex( *(sbuf+3) ); /* get code */ *(val+0) = get_hex( *(sbuf+1) ); *(val+1) = get_hex( *(sbuf+2) ); /* send this value to camera */ send_cam( (chx << 8) | ((val[0] << 4)+ val[1]) ); } /* set default value */ if ( cmd == 'S' ) { send_default() ; } /* get picture */ if ( cmd == 'G' ) { crlf(); get_img() ; } /* help */ if ( cmd == '?' ) { show_help() ; } /* new line */ crlf(); } void show_help(void) { send_uart_msg(MSG_HELP); send_uart_msg(MSG_RESET); send_uart_msg(MSG_REGISTER); send_uart_msg(MSG_IMAGE); send_uart_msg(MSG_DEFAULT); send_uart_msg(MSG_DEBUG); send_uart_msg(MSG_PULSE); send_uart_msg(MSG_DUTY); }
目次

inserted by FC2 system