ボタンを押すと、 バッテリ更新を停止し、 他のボタンもロックさせる

Dependencies:   RemoteIR TextLCD

Revision:
0:0d0037aabe41
Child:
1:5bb497a38344
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Jul 14 01:20:09 2020 +0000
@@ -0,0 +1,68 @@
+/* mbed Microcontroller Library
+ * Copyright (c) 2019 ARM Limited
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include "mbed.h"
+#include "ReceiverIR.h"
+#include "rtos.h"
+#include <stdint.h>
+#include "platform/mbed_thread.h"
+
+Serial pc(USBTX, USBRX);
+
+
+DigitalIn button(p15);
+// ポートp15を赤外線受信モジュールの接続先に指定
+ReceiverIR ir_rx(p15);
+RemoteIR::Format format;
+uint8_t buf[32];
+uint32_t bitcount;
+uint8_t code;
+char mode[20]; 
+
+void rimokon();
+
+void rimokon(/*void const *argument*/){  
+        
+       
+        // 受信待ち
+        if (ir_rx.getState() == ReceiverIR::Received) {
+            // コード受信
+            bitcount = ir_rx.getData(&format, buf, sizeof(buf) * 8);
+            if(bitcount > 1){
+                // 受信成功
+                code = buf[2];
+                pc.printf("%x\r\n",code);
+                switch(code){
+                    case 0x40://ok
+                        strcpy(mode,"Default");
+                        pc.printf("%s\r\n",mode);
+                        break;
+                    case 0x42://*
+                        strcpy(mode,"Avoidance");
+                        pc.printf("%s\r\n",mode);
+                        break;
+                    case 0x4a://#
+                        strcpy(mode,"Line_Trace");
+                        pc.printf("%s\r\n",mode);
+                        break;
+                    default:
+                        ;
+                }
+            }
+        }
+        
+}
+
+int main() {
+    
+    //RtosTimer rimokon_timer(rimokon, osTimerPeriodic, (void *)0); // set RTOS timer for sensor
+    //rimokon_timer.start(10);
+    //Thread thread1(rimokon , NULL , osPriorityHigh);
+    while(1){
+        if(button.read()==0){
+            rimokon();
+        }    
+    }
+}
\ No newline at end of file