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

Dependencies:   RemoteIR TextLCD

Committer:
yangtzuli
Date:
Wed Jul 22 07:43:56 2020 +0000
Revision:
1:5bb497a38344
Parent:
0:0d0037aabe41
Child:
2:38825726cb1b
123

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yangtzuli 0:0d0037aabe41 1 /* mbed Microcontroller Library
yangtzuli 0:0d0037aabe41 2 * Copyright (c) 2019 ARM Limited
yangtzuli 0:0d0037aabe41 3 * SPDX-License-Identifier: Apache-2.0
yangtzuli 0:0d0037aabe41 4 */
yangtzuli 0:0d0037aabe41 5
yangtzuli 0:0d0037aabe41 6 #include "mbed.h"
yangtzuli 0:0d0037aabe41 7 #include "ReceiverIR.h"
yangtzuli 0:0d0037aabe41 8 #include "rtos.h"
yangtzuli 0:0d0037aabe41 9 #include <stdint.h>
yangtzuli 0:0d0037aabe41 10 #include "platform/mbed_thread.h"
yangtzuli 0:0d0037aabe41 11
yangtzuli 0:0d0037aabe41 12 Serial pc(USBTX, USBRX);
yangtzuli 0:0d0037aabe41 13
yangtzuli 0:0d0037aabe41 14
yangtzuli 0:0d0037aabe41 15 DigitalIn button(p15);
yangtzuli 0:0d0037aabe41 16 // ポートp15を赤外線受信モジュールの接続先に指定
yangtzuli 0:0d0037aabe41 17 ReceiverIR ir_rx(p15);
yangtzuli 0:0d0037aabe41 18 RemoteIR::Format format;
yangtzuli 0:0d0037aabe41 19 uint8_t buf[32];
yangtzuli 0:0d0037aabe41 20 uint32_t bitcount;
yangtzuli 1:5bb497a38344 21 uint32_t code;
yangtzuli 0:0d0037aabe41 22
yangtzuli 0:0d0037aabe41 23 void rimokon();
yangtzuli 0:0d0037aabe41 24
yangtzuli 0:0d0037aabe41 25 void rimokon(/*void const *argument*/){
yangtzuli 0:0d0037aabe41 26
yangtzuli 0:0d0037aabe41 27
yangtzuli 0:0d0037aabe41 28 // 受信待ち
yangtzuli 0:0d0037aabe41 29 if (ir_rx.getState() == ReceiverIR::Received) {
yangtzuli 0:0d0037aabe41 30 // コード受信
yangtzuli 0:0d0037aabe41 31 bitcount = ir_rx.getData(&format, buf, sizeof(buf) * 8);
yangtzuli 0:0d0037aabe41 32 if(bitcount > 1){
yangtzuli 0:0d0037aabe41 33 // 受信成功
yangtzuli 1:5bb497a38344 34 code=0;
yangtzuli 1:5bb497a38344 35 for(int j=0;j<4;j++){
yangtzuli 1:5bb497a38344 36 code+=(buf[j]<<(8*(3-j)));
yangtzuli 1:5bb497a38344 37 }
yangtzuli 1:5bb497a38344 38 pc.printf("%0x\r\n",code);
yangtzuli 0:0d0037aabe41 39 switch(code){
yangtzuli 1:5bb497a38344 40 case 0x40bf0ff0://入力切換
yangtzuli 1:5bb497a38344 41 pc.printf("入力切換\r\n");
yangtzuli 1:5bb497a38344 42 break;
yangtzuli 1:5bb497a38344 43 case 0x40bf12ed://電源
yangtzuli 1:5bb497a38344 44 pc.printf("電源\r\n");
yangtzuli 1:5bb497a38344 45 break;
yangtzuli 1:5bb497a38344 46 case 0x40bf7b84://地アナ
yangtzuli 1:5bb497a38344 47 pc.printf("地アナ\r\n");
yangtzuli 1:5bb497a38344 48 break;
yangtzuli 1:5bb497a38344 49 case 0x40bf7a85://地デジ
yangtzuli 1:5bb497a38344 50 pc.printf("地デジ\r\n");
yangtzuli 1:5bb497a38344 51 break;
yangtzuli 1:5bb497a38344 52 case 0x40bf7c83://BS
yangtzuli 1:5bb497a38344 53 pc.printf("BS\r\n");
yangtzuli 1:5bb497a38344 54 break;
yangtzuli 1:5bb497a38344 55 case 0x40bf7d82://CS
yangtzuli 1:5bb497a38344 56 pc.printf("CS\r\n");
yangtzuli 1:5bb497a38344 57 break;
yangtzuli 1:5bb497a38344 58
yangtzuli 1:5bb497a38344 59 case 0x40bf01fe://1
yangtzuli 1:5bb497a38344 60 pc.printf("1\r\n");
yangtzuli 1:5bb497a38344 61 break;
yangtzuli 1:5bb497a38344 62 case 0x40bf02fd://2
yangtzuli 1:5bb497a38344 63 pc.printf("2\r\n");
yangtzuli 1:5bb497a38344 64 break;
yangtzuli 1:5bb497a38344 65 case 0x40bf03fc://3
yangtzuli 1:5bb497a38344 66 pc.printf("3\r\n");
yangtzuli 1:5bb497a38344 67 break;
yangtzuli 1:5bb497a38344 68 case 0x40bf04fb://4
yangtzuli 1:5bb497a38344 69 pc.printf("4\r\n");
yangtzuli 1:5bb497a38344 70 break;
yangtzuli 1:5bb497a38344 71 case 0x40bf05fa://5
yangtzuli 1:5bb497a38344 72 pc.printf("5\r\n");
yangtzuli 1:5bb497a38344 73 break;
yangtzuli 1:5bb497a38344 74 case 0x40bf06f9://6
yangtzuli 1:5bb497a38344 75 pc.printf("6\r\n");
yangtzuli 1:5bb497a38344 76 break;
yangtzuli 1:5bb497a38344 77 case 0x40bf07f8://7
yangtzuli 1:5bb497a38344 78 pc.printf("7\r\n");
yangtzuli 1:5bb497a38344 79 break;
yangtzuli 1:5bb497a38344 80 case 0x40bf08f7://8
yangtzuli 1:5bb497a38344 81 pc.printf("8\r\n");
yangtzuli 1:5bb497a38344 82 break;
yangtzuli 1:5bb497a38344 83 case 0x40bf09f6://9
yangtzuli 1:5bb497a38344 84 pc.printf("9\r\n");
yangtzuli 1:5bb497a38344 85 break;
yangtzuli 1:5bb497a38344 86 case 0x40bf0af5://10
yangtzuli 1:5bb497a38344 87 pc.printf("10\r\n");
yangtzuli 1:5bb497a38344 88 break;
yangtzuli 1:5bb497a38344 89 case 0x40bf0bf4://11
yangtzuli 1:5bb497a38344 90 pc.printf("11\r\n");
yangtzuli 1:5bb497a38344 91 break;
yangtzuli 1:5bb497a38344 92 case 0x40bf0cf3://12
yangtzuli 1:5bb497a38344 93 pc.printf("12\r\n");
yangtzuli 1:5bb497a38344 94 break;
yangtzuli 1:5bb497a38344 95 case 0x40bf1be4://チャンネル↑
yangtzuli 1:5bb497a38344 96 pc.printf("チャンネル↑\r\n");
yangtzuli 1:5bb497a38344 97 break;
yangtzuli 1:5bb497a38344 98 case 0x40bf1fe0://チャンネル↓
yangtzuli 1:5bb497a38344 99 pc.printf("チャンネル↓\r\n");
yangtzuli 0:0d0037aabe41 100 break;
yangtzuli 1:5bb497a38344 101 case 0x40bf1ce3://画面表示
yangtzuli 1:5bb497a38344 102 pc.printf("画面表示\r\n");
yangtzuli 1:5bb497a38344 103 break;
yangtzuli 1:5bb497a38344 104 case 0x40bf10ef://消音
yangtzuli 1:5bb497a38344 105 pc.printf("消音\r\n");
yangtzuli 1:5bb497a38344 106 break;
yangtzuli 1:5bb497a38344 107 case 0x40bf27d8://クイック
yangtzuli 1:5bb497a38344 108 pc.printf("クイック\r\n");
yangtzuli 1:5bb497a38344 109 break;
yangtzuli 1:5bb497a38344 110 case 0x40bf1ae5://音量↑
yangtzuli 1:5bb497a38344 111 pc.printf("音量↑\r\n");
yangtzuli 1:5bb497a38344 112 break;
yangtzuli 1:5bb497a38344 113 case 0x40bf1ee1://音量↓
yangtzuli 1:5bb497a38344 114 pc.printf("音量↓\r\n");
yangtzuli 1:5bb497a38344 115 break;
yangtzuli 1:5bb497a38344 116 case 0x40be34cb://レグザリンク
yangtzuli 1:5bb497a38344 117 pc.printf("レグザリンク\r\n");
yangtzuli 1:5bb497a38344 118 break;
yangtzuli 1:5bb497a38344 119 case 0x40bf6e91://番組表
yangtzuli 1:5bb497a38344 120 pc.printf("番組表\r\n");
yangtzuli 1:5bb497a38344 121 break;
yangtzuli 1:5bb497a38344 122 case 0x40bf3bc4://戻る
yangtzuli 1:5bb497a38344 123 pc.printf("戻る\r\n");
yangtzuli 1:5bb497a38344 124 break;
yangtzuli 1:5bb497a38344 125 case 0x40bf3cc3://終了
yangtzuli 1:5bb497a38344 126 pc.printf("終了\r\n");
yangtzuli 1:5bb497a38344 127 break;
yangtzuli 1:5bb497a38344 128 case 0x40bf3ec1://↑
yangtzuli 1:5bb497a38344 129 pc.printf("↑\r\n");
yangtzuli 1:5bb497a38344 130 break;
yangtzuli 1:5bb497a38344 131 case 0x40bf3fc0://↓
yangtzuli 1:5bb497a38344 132 pc.printf("↓\r\n");
yangtzuli 0:0d0037aabe41 133 break;
yangtzuli 1:5bb497a38344 134 case 0x40bf5fa0://←
yangtzuli 1:5bb497a38344 135 pc.printf("←\r\n");
yangtzuli 1:5bb497a38344 136 break;
yangtzuli 1:5bb497a38344 137 case 0x40bf5ba4://→
yangtzuli 1:5bb497a38344 138 pc.printf("→\r\n");
yangtzuli 1:5bb497a38344 139 break;
yangtzuli 1:5bb497a38344 140 case 0x40bf3dc2://決定
yangtzuli 1:5bb497a38344 141 pc.printf("決定\r\n");
yangtzuli 1:5bb497a38344 142 break;
yangtzuli 1:5bb497a38344 143 case 0x40bf738c://青
yangtzuli 1:5bb497a38344 144 pc.printf("青\r\n");
yangtzuli 1:5bb497a38344 145 break;
yangtzuli 1:5bb497a38344 146 case 0x40bf748b://赤
yangtzuli 1:5bb497a38344 147 pc.printf("赤\r\n");
yangtzuli 1:5bb497a38344 148 break;
yangtzuli 1:5bb497a38344 149 case 0x40bf758a://緑
yangtzuli 1:5bb497a38344 150 pc.printf("緑\r\n");
yangtzuli 0:0d0037aabe41 151 break;
yangtzuli 1:5bb497a38344 152 case 0x40bf7689://黄
yangtzuli 1:5bb497a38344 153 pc.printf("黄\r\n");
yangtzuli 1:5bb497a38344 154 break;
yangtzuli 1:5bb497a38344 155 case 0x43bc14eb://dデータ
yangtzuli 1:5bb497a38344 156 pc.printf("dデータ\r\n");
yangtzuli 1:5bb497a38344 157 break;
yangtzuli 1:5bb497a38344 158 case 0x40bf50af://静止
yangtzuli 1:5bb497a38344 159 pc.printf("静止\r\n");
yangtzuli 1:5bb497a38344 160 break;
yangtzuli 1:5bb497a38344 161 case 0x40bf59a6://おまかせ映像
yangtzuli 1:5bb497a38344 162 pc.printf("おまかせ映像\r\n");
yangtzuli 1:5bb497a38344 163 break;
yangtzuli 1:5bb497a38344 164 case 0x40bf13ec://音声切換
yangtzuli 1:5bb497a38344 165 pc.printf("音声切換\r\n");
yangtzuli 1:5bb497a38344 166 break;
yangtzuli 1:5bb497a38344 167
yangtzuli 1:5bb497a38344 168
yangtzuli 0:0d0037aabe41 169 default:
yangtzuli 0:0d0037aabe41 170 ;
yangtzuli 0:0d0037aabe41 171 }
yangtzuli 0:0d0037aabe41 172 }
yangtzuli 0:0d0037aabe41 173 }
yangtzuli 0:0d0037aabe41 174
yangtzuli 0:0d0037aabe41 175 }
yangtzuli 0:0d0037aabe41 176
yangtzuli 0:0d0037aabe41 177 int main() {
yangtzuli 0:0d0037aabe41 178
yangtzuli 0:0d0037aabe41 179 //RtosTimer rimokon_timer(rimokon, osTimerPeriodic, (void *)0); // set RTOS timer for sensor
yangtzuli 0:0d0037aabe41 180 //rimokon_timer.start(10);
yangtzuli 0:0d0037aabe41 181 //Thread thread1(rimokon , NULL , osPriorityHigh);
yangtzuli 0:0d0037aabe41 182 while(1){
yangtzuli 0:0d0037aabe41 183 if(button.read()==0){
yangtzuli 0:0d0037aabe41 184 rimokon();
yangtzuli 0:0d0037aabe41 185 }
yangtzuli 0:0d0037aabe41 186 }
yangtzuli 0:0d0037aabe41 187 }