DisplayApp-Base

Dependencies:   mbed-os-lychee DisplayApp_Base

Revision:
4:b75d4cd51099
Parent:
3:6289f0adb6c9
--- a/main.cpp	Fri Nov 16 08:16:08 2018 +0000
+++ b/main.cpp	Wed Nov 21 02:29:46 2018 +0000
@@ -42,18 +42,6 @@
 static DisplayApp  display_app;
 static int Vfield_Int_Cnt = 0;
 
-Ticker flipper;
-static int interCnt = 0;    //割り込み発生回数
-static int sendCnt = 0;     //画像データを送信した回数
-DigitalOut led1(LED1);
-DigitalOut led2(LED2);
-
-
-static void incrementInterCnt()
-{
-    interCnt++;
-}
-
 static void JcuEncodeCallBackFunc(JPEG_Converter::jpeg_conv_error_t err_code)
 {
     if (err_code == JPEG_Converter::JPEG_CONV_OK) {
@@ -65,22 +53,26 @@
 
 static void snapshot(void)
 {
-    //JPEGにエンコード中 or エンコード未完了
+
     while ((jcu_encoding == 1) || (image_change == 0)) {
         Thread::wait(1);
     }
     jcu_buf_index_read = jcu_buf_index_write_done;
-    //画像データをコピー(JpegBufferは他から書き換えられる可能性があるため)
     memcpy(JpegBuffer_Send, JpegBuffer[jcu_buf_index_read],1024 * 64);
     image_change = 0;
 
-    if(interCnt != sendCnt) {
-        led2 = !led2;
-        sendCnt = interCnt;
-        //撮影した画像データ(JPEG)をPCにUSBシリアル通信で転送
-        display_app.SendJpeg(JpegBuffer_Send, (uint32_t)jcu_encode_size[jcu_buf_index_read]);
-        led2 = !led2;
+    display_app.SendJpeg(JpegBuffer_Send, (uint32_t)jcu_encode_size[jcu_buf_index_read]);
+}
+
+static void WaitGetCommand(void)
+{
+    char command;    
+    command = display_app.Getgetc();
+           
+    if(command=='c'){
+        snapshot();
     }
+
 }
 
 static void IntCallbackFunc_Vfield(DisplayBase::int_type_t int_type)
@@ -146,18 +138,12 @@
 
 int main(void)
 {
-    led1 = !led1;
-    //JPEGのエンコード設定
     Jcu.SetQuality(JPEG_ENCODE_QUALITY);
 
-    //カメラの初期化処理
     EasyAttach_Init(Display);
-    //カメラ画像 取得開始
     Start_Video_Camera();
-    //割り込み処理※デバッグの為、5秒
-    flipper.attach(&incrementInterCnt, 5.0);
 
     while (1) {
-        snapshot();
+        WaitGetCommand();  
     }
 }