Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API nRF51822 mbed
Fork of KS7 by
Diff: main.cpp
- Branch:
- KS3
- Revision:
- 33:d7b53d548c33
- Parent:
- 31:b5e19d153db4
- Child:
- 36:3cca74c30551
--- a/main.cpp Mon Aug 01 08:58:31 2016 +0000
+++ b/main.cpp Wed Aug 10 06:56:36 2016 +0000
@@ -180,6 +180,9 @@
void BLEConnectionCallback(const Gap::ConnectionCallbackParams_t *params)
{
ble.updateConnectionParams(params->handle, params->connectionParams);
+#ifdef UART_DEBUG
+ pc.printf("BLEConnectionCallback \r\n");
+#endif
}
void BLEDisconnectionCallback(const Gap::DisconnectionCallbackParams_t *params)
@@ -187,6 +190,9 @@
if(led_mode == MODE_ON) {
ble.startAdvertising();
}
+#ifdef UART_DEBUG
+ pc.printf("BLEDisconnectionCallback \r\n");
+#endif
}
void BLERadioNotificationCallback(bool radio_active)
@@ -195,6 +201,9 @@
if(led_mode == MODE_ON) {
}
}
+#ifdef UART_DEBUG
+ pc.printf("BLERadioNotificationCallback \r\n");
+#endif
}
@@ -249,13 +258,18 @@
/*E-----------------------------------------------------------------------*/
ble.addService(HWS);
ble.addService(DIS);
- DFUService dfu(ble);
+// これをコメントにするとライトできた!!
+// DFUService dfu(ble);
}
/*S---------------------------------------------------------------------*/
-//void zTap(void)
-//{
-//}
+/*キー押されて1sec経過すればコールバックされる*/
+int _key1sec = 0;
+bool _analog_skip = false;
+void KeyOn(void)
+{
+ _key1sec = 1;
+}
void AccelInit(void)
{
/*加速度センサー初期化*/
@@ -270,6 +284,8 @@
//p_MMA845x->enableMotionMode();
//p_MMA845x->registerDump();
p_MMA845x->enableDataReadyMode();
+
+ io.attach(&KeyOn);
}
/*モード決定*/
void GetMode(void)
@@ -399,6 +415,8 @@
sw = io.get_switch();
io.switch_reset();
if(sw != exio::None) {/*通常押しもしくは長押し*/
+ _key1sec = 0;
+ io.CallFlagClear();
GetMode(); /*傾きからモード決定*/
if(_mode == M_WATCHTIMER){
GetState(sw); //WATCH or TIMER ?
@@ -409,16 +427,39 @@
/*E--------------------------------------------------------------------*/
led_mode = MODE_START;
}
+/*S---------------------------------------------------------------------------*/
+ else {
+ // キー押された状態で1sec経過した場合表示のみ開始、Timerモード開始は後ほど
+ if(_key1sec == 1){
+ _mode = M_WATCHTIMER;
+ _state = S_TIMER;
+ io.analog_pow(1);
+ io.power_save_mode(0);
+ _analog_skip = true;
+ io.displaySeconds(0);
+ //io.display_unitT();
+ _key1sec = 2;
+ } else if(_key1sec == 2){
+ led_brightness += BRIGHTNESS_ADDVALUE; // 徐々に明るく
+ io.display(led_brightness);
+ if(led_brightness >= BRIGHTNESS_MAXVALUE) _key1sec = 3;
+ } else {
+ io.display(led_brightness);
+ }
+ }
+/*E---------------------------------------------------------------------------*/
break;
case MODE_START:
+ //if(_analog_skip) {_analog_skip=false; goto L090;}
io.analog_pow(1);
io.power_save_mode(0);
/*S----------------------------------------------------------------*/
+//L090:
// タイマー時はここで毎回更新
- if(_mode == M_WATCHTIMER && _state == S_TIMER){
- p_CurrentTimeService->setCounter(0); // タイマーカウンタリセット
- io.displaySeconds(0);
- } else if(_mode == M_SCALE){
+ //if(_mode == M_WATCHTIMER && _state == S_TIMER){
+ // p_CurrentTimeService->setCounter(0); // タイマーカウンタリセット
+ // io.displaySeconds(0);
+ /*} else*/ if(_mode == M_SCALE){
io.display_value = 0;
}
/*E----------------------------------------------------------------*/
