ボタンを押すと、 バッテリ更新を停止し、 他のボタンもロックさせる
Dependencies: RemoteIR TextLCD
main.cpp
- Committer:
- yangtzuli
- Date:
- 2020-07-14
- Revision:
- 0:0d0037aabe41
- Child:
- 1:5bb497a38344
File content as of revision 0:0d0037aabe41:
/* 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(); } } }