北海道情報専門学校 ライフハック研究所のエンベデッドUSBチーム松葉和仁により開発されたUSBSecのmbedに使用するソースコード by 和仁

Dependencies:   SDFileSystem MusicEngine

Fork of mbed-os-example-ble-LED by mbed-os-examples

北海道情報専門学校 ライフハック研究所 エンベデッドUSB USBSec用mbedプログラム

松葉和仁

Revision:
23:64df5e4f1c0c
Parent:
22:ad986f13599d
Child:
24:c0cc460aadef
--- a/source/main.cpp	Fri Feb 03 00:33:55 2017 +0000
+++ b/source/main.cpp	Fri Feb 03 00:38:32 2017 +0000
@@ -17,21 +17,12 @@
 #define DEBUG(...) /* nothing */
 #endif /* #if NEED_CONSOLE_OUTPUT */
 
-#define mC 261.626
-#define mD 293.665
-#define mE 329.628
-#define mF 349.228
-#define mG 391.995
-#define mA 440.000
-#define mB 493.883
-
 DigitalOut alivenessLED(LED1, 0);//システム生存確認LED
 DigitalOut actuatedLED(LED2, 0);//USB用リレーピン
 
 InterruptIn powerSwitch(p17);//パワー検出コード
 InterruptIn resetSwitch(p18);//リセットボタン
 
-//PwmOut speakerP(LED4);//スピーカPWM
 DigitalOut speakerD(LED3, 0);//スピーカ省電力化デジタル
 MusicEngine Speaker(LED4);
 
@@ -55,29 +46,17 @@
 
 char password[] = {0x00,0x00,0x00,0x00,0x00,0x00};//デバッグパスワード
 
-int connectAlertCount = 0;
-int disconnectAlertCount = 0;
-float connectAlert[]={mC,mE,mG,mB,mB};
-float disconnectAlert[]={mB,mG,mE,mC,mB};
-
+//http://mag.switch-science.com/2015/06/17/fathersday2015/
 void connectAlertOff();
 
-//http://mag.switch-science.com/2015/06/17/fathersday2015/
-
 /**
  *接続時発音
  *接続時に発音されるためのキュー
  */
 void connectAlertOn() {
     DEBUG("connectAlertOn\r\n");
-    /*
-    speakerP.period(1.0/connectAlert[connectAlertCount]);
-    speakerP.write(0.5f);
-    eventQueue.call_in(1.0f, &connectAlertOff);
-    */
-    //Speaker.play("T120L4CDEFEDCREFGAGFER");//非同期だった//7秒?
-    Speaker.play("T120L4CDEFEDC");//非同期だった//7秒?
-    eventQueue.call_in(5000.0f, &connectAlertOff);
+    Speaker.play("T160L4CDEFEDC");//非同期だった//7秒?
+    eventQueue.call_in(3000.0f, &connectAlertOff);
 }
 
 /**
@@ -86,19 +65,6 @@
  */
 void connectAlertOff() {
     DEBUG("connectAlertOff\r\n");
-    /*
-    speakerP.write(0.0f);
-    if(connectAlertCount<4){
-        connectAlertCount += 1;
-        eventQueue.call_in(2.0f, &connectAlertOn);
-    }else{
-        if(disconnectAlertCount<=0){
-            speakerD = 0;
-        }
-        connectAlertCount = 0;
-        DEBUG("connectAlertStop\r\n");
-    }
-    */
     speakerD = 0;
 }
 
@@ -109,7 +75,6 @@
 void connectAlertStart() {
     DEBUG("connectAlertStart\r\n");
     speakerD = 1;
-    connectAlertCount = 0;
     eventQueue.call(&connectAlertOn);
 }
 
@@ -121,14 +86,8 @@
  */
 void disconnectAlertOn() {
     DEBUG("disconnectAlertOn\r\n");
-    /*
-    speakerP.period(1.0/disconnectAlert[disconnectAlertCount]);
-    speakerP.write(0.5f);
-    eventQueue.call_in(1.0f, &disconnectAlertOff);
-    */
-    
-    Speaker.play("T120L4CR4CR4CR4CR4");//非同期だった//非同期じゃないとすべての処理が止まるから当たり前か
-    eventQueue.call_in(5000.0f, &disconnectAlertOff);
+    Speaker.play("T160L4CR4CR4CR4CR4");//非同期だった//非同期じゃないとすべての処理が止まるから当たり前か
+    eventQueue.call_in(3000.0f, &disconnectAlertOff);
 }
 
 /**
@@ -137,17 +96,6 @@
  */
 void disconnectAlertOff() {
     DEBUG("disconnectAlertOff\r\n");
-    /*speakerP.write(0.0f);
-    if(disconnectAlertCount<4){
-        disconnectAlertCount += 1;
-        eventQueue.call_in(2.0f, &disconnectAlertOn);
-    }else{
-        if(connectAlertCount<=0){
-            speakerD = 0;
-        }
-        disconnectAlertCount = 0;
-        DEBUG("disconnectAlertStop\r\n");
-    }*/
     speakerD = 0;
 }
 
@@ -158,7 +106,6 @@
 void disconnectAlertStart() {
     DEBUG("disconnectAlertStart\r\n");
     speakerD = 1;
-    disconnectAlertCount = 0;
     eventQueue.call(&disconnectAlertOn);
 }