printf消した
Dependencies: RemoteIR TextLCD
main.cpp@5:3fffb364744b, 2020-07-29 (annotated)
- Committer:
- yangtzuli
- Date:
- Wed Jul 29 06:52:39 2020 +0000
- Revision:
- 5:3fffb364744b
- Parent:
- 4:3f80c0180e2f
- Child:
- 6:800a745c7f2e
aaa
Who changed what in which revision?
User | Revision | Line number | New 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 | 2:38825726cb1b | 11 | #include "TextLCD.h" |
yangtzuli | 0:0d0037aabe41 | 12 | |
yangtzuli | 0:0d0037aabe41 | 13 | Serial pc(USBTX, USBRX); |
yangtzuli | 0:0d0037aabe41 | 14 | |
yangtzuli | 3:2ae6218973be | 15 | /* マクロ定義、列挙型定義 */ |
yangtzuli | 3:2ae6218973be | 16 | #define MIN_V 2.0 |
yangtzuli | 3:2ae6218973be | 17 | #define MAX_V 2.67 |
yangtzuli | 3:2ae6218973be | 18 | #define LOW 0 // |
yangtzuli | 3:2ae6218973be | 19 | #define HIGH 1 // |
yangtzuli | 3:2ae6218973be | 20 | #define NORMAL 0 // フラグ値 |
yangtzuli | 3:2ae6218973be | 21 | #define FAST 1 // フラグ値 |
yangtzuli | 3:2ae6218973be | 22 | #define VERYFAST 2 // フラグ値 |
yangtzuli | 2:38825726cb1b | 23 | |
yangtzuli | 3:2ae6218973be | 24 | enum MODE{ |
yangtzuli | 3:2ae6218973be | 25 | READY = -1, |
yangtzuli | 3:2ae6218973be | 26 | ADVANCE = 1, |
yangtzuli | 2:38825726cb1b | 27 | RIGHT, |
yangtzuli | 2:38825726cb1b | 28 | LEFT, |
yangtzuli | 2:38825726cb1b | 29 | BACK, |
yangtzuli | 2:38825726cb1b | 30 | STOP, |
yangtzuli | 2:38825726cb1b | 31 | LINE_TRACE, |
yangtzuli | 2:38825726cb1b | 32 | AVOIDANCE, |
yangtzuli | 3:2ae6218973be | 33 | SPEED, |
yangtzuli | 2:38825726cb1b | 34 | }; |
yangtzuli | 2:38825726cb1b | 35 | |
yangtzuli | 3:2ae6218973be | 36 | /* ピン配置 */ |
yangtzuli | 3:2ae6218973be | 37 | ReceiverIR ir(p5); // リモコン操作 |
yangtzuli | 3:2ae6218973be | 38 | DigitalOut trig(p6); // 超音波センサtrigger |
yangtzuli | 5:3fffb364744b | 39 | DigitalIn echo(p7); // 超音波センサecho |
yangtzuli | 3:2ae6218973be | 40 | DigitalIn ss1(p8); // ライントレースセンサ(左) |
yangtzuli | 3:2ae6218973be | 41 | DigitalIn ss2(p9); // ライントレースセンサ |
yangtzuli | 3:2ae6218973be | 42 | DigitalIn ss3(p10); // ライントレースセンサ |
yangtzuli | 3:2ae6218973be | 43 | DigitalIn ss4(p11); // ライントレースセンサ |
yangtzuli | 3:2ae6218973be | 44 | DigitalIn ss5(p12); // ライントレースセンサ(右) |
yangtzuli | 3:2ae6218973be | 45 | Serial esp(p13, p14); // Wi-Fiモジュール(tx, rx) |
yangtzuli | 3:2ae6218973be | 46 | AnalogIn battery(p15); // 電池残量読み取り(Max 3.3V) |
yangtzuli | 3:2ae6218973be | 47 | PwmOut motorR2(p21); // 右モーター後退 |
yangtzuli | 3:2ae6218973be | 48 | PwmOut motorR1(p22); // 右モーター前進 |
yangtzuli | 3:2ae6218973be | 49 | PwmOut motorL2(p23); // 左モーター後退 |
yangtzuli | 3:2ae6218973be | 50 | PwmOut motorL1(p24); // 左モーター前進 |
yangtzuli | 3:2ae6218973be | 51 | PwmOut servo(p25); // サーボ |
yangtzuli | 3:2ae6218973be | 52 | I2C i2c_lcd(p28,p27); // LCD(tx, rx) |
yangtzuli | 2:38825726cb1b | 53 | |
yangtzuli | 3:2ae6218973be | 54 | /* 変数宣言 */ |
yangtzuli | 3:2ae6218973be | 55 | int mode; // 操作モード |
yangtzuli | 3:2ae6218973be | 56 | int run; // 走行状態 |
yangtzuli | 3:2ae6218973be | 57 | int beforeMode; // 前のモード |
yangtzuli | 3:2ae6218973be | 58 | int flag_sp = 0; // スピード変化フラグ |
yangtzuli | 3:2ae6218973be | 59 | Timer viewTimer; // スピ―ド変更時に3秒計測 |
yangtzuli | 3:2ae6218973be | 60 | float motorSpeed[6] = {0.7, 0.8, 0.9, 0.8, 0.9, 1.0}; |
yangtzuli | 3:2ae6218973be | 61 | // モーター速度設定(後半はライントレース用) |
yangtzuli | 3:2ae6218973be | 62 | Mutex mutex; |
yangtzuli | 3:2ae6218973be | 63 | // ポートp15を赤外線受信モジュールの接続先に指定 |
yangtzuli | 3:2ae6218973be | 64 | RemoteIR::Format format; |
yangtzuli | 3:2ae6218973be | 65 | uint8_t buf[32]; |
yangtzuli | 3:2ae6218973be | 66 | uint32_t bitcount; |
yangtzuli | 3:2ae6218973be | 67 | uint32_t code; |
yangtzuli | 3:2ae6218973be | 68 | |
yangtzuli | 3:2ae6218973be | 69 | //bChangeのいろいろ |
yangtzuli | 3:2ae6218973be | 70 | TextLCD_I2C lcd(&i2c_lcd, (0x27 << 1), TextLCD::LCD16x2, TextLCD::HD44780); |
yangtzuli | 3:2ae6218973be | 71 | int b = 0; |
yangtzuli | 3:2ae6218973be | 72 | double test; |
yangtzuli | 3:2ae6218973be | 73 | int flag_b = 0; |
yangtzuli | 3:2ae6218973be | 74 | int flag_t = 0; |
yangtzuli | 3:2ae6218973be | 75 | |
yangtzuli | 3:2ae6218973be | 76 | // ライントレース |
yangtzuli | 3:2ae6218973be | 77 | int sensArray[32] = {0,0,0,0,0,0,0,0, // ライントレースセンサパターン |
yangtzuli | 3:2ae6218973be | 78 | 0,0,0,0,0,0,0,0, |
yangtzuli | 3:2ae6218973be | 79 | 0,0,0,0,0,0,0,0, |
yangtzuli | 3:2ae6218973be | 80 | 0,0,0,0,0,0,0,0}; |
yangtzuli | 0:0d0037aabe41 | 81 | |
yangtzuli | 2:38825726cb1b | 82 | /* 障害物検知用の変数設定 */ |
yangtzuli | 3:2ae6218973be | 83 | Timer timer; // 距離計測用タイマ |
yangtzuli | 3:2ae6218973be | 84 | int DT; // 距離 |
yangtzuli | 2:38825726cb1b | 85 | int SC; // 正面 |
yangtzuli | 2:38825726cb1b | 86 | int SL; // 左 |
yangtzuli | 2:38825726cb1b | 87 | int SR; // 右 |
yangtzuli | 2:38825726cb1b | 88 | int SLD; // 左前 |
yangtzuli | 2:38825726cb1b | 89 | int SRD; // 右前 |
yangtzuli | 5:3fffb364744b | 90 | int flag_a = 0; // 障害物有無のフラグ |
yangtzuli | 2:38825726cb1b | 91 | const int limit = 20; // 障害物の距離のリミット(単位:cm) |
yangtzuli | 3:2ae6218973be | 92 | int far; // 最も遠い距離 |
yangtzuli | 2:38825726cb1b | 93 | int houkou; // 進行方向(1:前 2:左 3:右) |
yangtzuli | 2:38825726cb1b | 94 | int i; // ループ変数 |
yangtzuli | 2:38825726cb1b | 95 | |
yangtzuli | 3:2ae6218973be | 96 | |
yangtzuli | 3:2ae6218973be | 97 | |
yangtzuli | 3:2ae6218973be | 98 | /* プロトタイプ宣言 */ |
yangtzuli | 3:2ae6218973be | 99 | void decodeIR(void const *argument); |
yangtzuli | 3:2ae6218973be | 100 | void motor(void const *argument); |
yangtzuli | 3:2ae6218973be | 101 | void changeSpeed(); |
yangtzuli | 2:38825726cb1b | 102 | void avoidance(void const *argument); |
yangtzuli | 3:2ae6218973be | 103 | void trace(void const *argument); |
yangtzuli | 2:38825726cb1b | 104 | void watchsurrounding(); |
yangtzuli | 2:38825726cb1b | 105 | int watch(); |
yangtzuli | 5:3fffb364744b | 106 | void bChange(); |
yangtzuli | 3:2ae6218973be | 107 | void display(); |
yangtzuli | 3:2ae6218973be | 108 | void lcdBacklight(void const *argument); |
yangtzuli | 4:3f80c0180e2f | 109 | Thread thread1(decodeIR, NULL, osPriorityRealtime);//+3 |
yangtzuli | 4:3f80c0180e2f | 110 | Thread thread2(motor, NULL, osPriorityHigh);//+2 |
yangtzuli | 4:3f80c0180e2f | 111 | Thread thread3(avoidance, NULL, osPriorityHigh);//+2 |
yangtzuli | 4:3f80c0180e2f | 112 | Thread thread4(trace, NULL, osPriorityHigh);//+2 |
yangtzuli | 3:2ae6218973be | 113 | RtosTimer bTimer(lcdBacklight, osTimerPeriodic); |
yangtzuli | 2:38825726cb1b | 114 | |
yangtzuli | 5:3fffb364744b | 115 | DigitalOut led1(LED1); |
yangtzuli | 3:2ae6218973be | 116 | |
yangtzuli | 5:3fffb364744b | 117 | |
yangtzuli | 5:3fffb364744b | 118 | void decodeIR(void const *argument){ |
yangtzuli | 5:3fffb364744b | 119 | while(1){ |
yangtzuli | 0:0d0037aabe41 | 120 | // 受信待ち |
yangtzuli | 4:3f80c0180e2f | 121 | pc.printf("decodeIR\r\n"); |
yangtzuli | 3:2ae6218973be | 122 | if (ir.getState() == ReceiverIR::Received) { |
yangtzuli | 0:0d0037aabe41 | 123 | // コード受信 |
yangtzuli | 3:2ae6218973be | 124 | bitcount = ir.getData(&format, buf, sizeof(buf) * 8); |
yangtzuli | 0:0d0037aabe41 | 125 | if(bitcount > 1){ |
yangtzuli | 0:0d0037aabe41 | 126 | // 受信成功 |
yangtzuli | 1:5bb497a38344 | 127 | code=0; |
yangtzuli | 1:5bb497a38344 | 128 | for(int j=0;j<4;j++){ |
yangtzuli | 1:5bb497a38344 | 129 | code+=(buf[j]<<(8*(3-j))); |
yangtzuli | 1:5bb497a38344 | 130 | } |
yangtzuli | 3:2ae6218973be | 131 | if(mode!=SPEED){ |
yangtzuli | 3:2ae6218973be | 132 | beforeMode=mode; |
yangtzuli | 3:2ae6218973be | 133 | } |
yangtzuli | 3:2ae6218973be | 134 | |
yangtzuli | 3:2ae6218973be | 135 | //pc.printf("%0x\r\n",code); |
yangtzuli | 0:0d0037aabe41 | 136 | switch(code){ |
yangtzuli | 1:5bb497a38344 | 137 | case 0x40bf27d8://クイック |
yangtzuli | 3:2ae6218973be | 138 | pc.printf("mode = SPEED\r\n"); |
yangtzuli | 3:2ae6218973be | 139 | mode = SPEED; |
yangtzuli | 4:3f80c0180e2f | 140 | changeSpeed(); |
yangtzuli | 4:3f80c0180e2f | 141 | display(); |
yangtzuli | 4:3f80c0180e2f | 142 | mode = beforeMode; |
yangtzuli | 1:5bb497a38344 | 143 | break; |
yangtzuli | 1:5bb497a38344 | 144 | case 0x40be34cb://レグザリンク |
yangtzuli | 3:2ae6218973be | 145 | pc.printf("mode = INE_TRACE\r\n"); |
yangtzuli | 3:2ae6218973be | 146 | mode=LINE_TRACE; |
yangtzuli | 3:2ae6218973be | 147 | display(); |
yangtzuli | 1:5bb497a38344 | 148 | break; |
yangtzuli | 1:5bb497a38344 | 149 | case 0x40bf6e91://番組表 |
yangtzuli | 3:2ae6218973be | 150 | pc.printf("mode = AVOIDANCE\r\n"); |
yangtzuli | 3:2ae6218973be | 151 | mode=AVOIDANCE; |
yangtzuli | 3:2ae6218973be | 152 | display(); |
yangtzuli | 1:5bb497a38344 | 153 | break; |
yangtzuli | 1:5bb497a38344 | 154 | case 0x40bf3ec1://↑ |
yangtzuli | 3:2ae6218973be | 155 | pc.printf("mode = ADVANCE\r\n"); |
yangtzuli | 3:2ae6218973be | 156 | mode = ADVANCE; |
yangtzuli | 3:2ae6218973be | 157 | run = ADVANCE; |
yangtzuli | 3:2ae6218973be | 158 | display(); |
yangtzuli | 1:5bb497a38344 | 159 | break; |
yangtzuli | 1:5bb497a38344 | 160 | case 0x40bf3fc0://↓ |
yangtzuli | 3:2ae6218973be | 161 | pc.printf("mode = BACK\r\n"); |
yangtzuli | 3:2ae6218973be | 162 | mode = BACK; |
yangtzuli | 3:2ae6218973be | 163 | run = BACK; |
yangtzuli | 3:2ae6218973be | 164 | display(); |
yangtzuli | 0:0d0037aabe41 | 165 | break; |
yangtzuli | 1:5bb497a38344 | 166 | case 0x40bf5fa0://← |
yangtzuli | 3:2ae6218973be | 167 | pc.printf("mode = LEFT\r\n"); |
yangtzuli | 3:2ae6218973be | 168 | mode = LEFT; |
yangtzuli | 3:2ae6218973be | 169 | run = LEFT; |
yangtzuli | 3:2ae6218973be | 170 | display(); |
yangtzuli | 1:5bb497a38344 | 171 | break; |
yangtzuli | 1:5bb497a38344 | 172 | case 0x40bf5ba4://→ |
yangtzuli | 3:2ae6218973be | 173 | pc.printf("mode = RIGHT\r\n"); |
yangtzuli | 3:2ae6218973be | 174 | mode = RIGHT; |
yangtzuli | 3:2ae6218973be | 175 | run = RIGHT; |
yangtzuli | 3:2ae6218973be | 176 | display(); |
yangtzuli | 1:5bb497a38344 | 177 | break; |
yangtzuli | 1:5bb497a38344 | 178 | case 0x40bf3dc2://決定 |
yangtzuli | 3:2ae6218973be | 179 | pc.printf("mode = STOP\r\n"); |
yangtzuli | 3:2ae6218973be | 180 | mode = STOP; |
yangtzuli | 3:2ae6218973be | 181 | run = STOP; |
yangtzuli | 3:2ae6218973be | 182 | display(); |
yangtzuli | 1:5bb497a38344 | 183 | break; |
yangtzuli | 0:0d0037aabe41 | 184 | default: |
yangtzuli | 0:0d0037aabe41 | 185 | ; |
yangtzuli | 0:0d0037aabe41 | 186 | } |
yangtzuli | 0:0d0037aabe41 | 187 | } |
yangtzuli | 0:0d0037aabe41 | 188 | } |
yangtzuli | 4:3f80c0180e2f | 189 | if(viewTimer.read_ms()>=3000){ |
yangtzuli | 4:3f80c0180e2f | 190 | viewTimer.stop(); |
yangtzuli | 4:3f80c0180e2f | 191 | viewTimer.reset(); |
yangtzuli | 4:3f80c0180e2f | 192 | display(); |
yangtzuli | 4:3f80c0180e2f | 193 | } |
yangtzuli | 4:3f80c0180e2f | 194 | ThisThread::sleep_for(90); |
yangtzuli | 4:3f80c0180e2f | 195 | } |
yangtzuli | 2:38825726cb1b | 196 | } |
yangtzuli | 2:38825726cb1b | 197 | void motor(void const *argument){ |
yangtzuli | 3:2ae6218973be | 198 | while(true){ |
yangtzuli | 3:2ae6218973be | 199 | pc.printf("motor\r\n"); |
yangtzuli | 3:2ae6218973be | 200 | if(flag_sp >VERYFAST){ |
yangtzuli | 3:2ae6218973be | 201 | flag_sp -= 3; |
yangtzuli | 3:2ae6218973be | 202 | } |
yangtzuli | 3:2ae6218973be | 203 | switch(run){ |
yangtzuli | 3:2ae6218973be | 204 | case ADVANCE: |
yangtzuli | 3:2ae6218973be | 205 | motorR1 = motorSpeed[flag_sp]; |
yangtzuli | 3:2ae6218973be | 206 | motorR2 = LOW; |
yangtzuli | 3:2ae6218973be | 207 | motorL1 = motorSpeed[flag_sp]; |
yangtzuli | 3:2ae6218973be | 208 | motorL2 = LOW; |
yangtzuli | 3:2ae6218973be | 209 | break; |
yangtzuli | 3:2ae6218973be | 210 | case RIGHT: |
yangtzuli | 3:2ae6218973be | 211 | motorR1 = LOW; |
yangtzuli | 3:2ae6218973be | 212 | motorR2 = motorSpeed[flag_sp]; |
yangtzuli | 3:2ae6218973be | 213 | motorL1 = motorSpeed[flag_sp]; |
yangtzuli | 3:2ae6218973be | 214 | motorL2 = LOW; |
yangtzuli | 3:2ae6218973be | 215 | break; |
yangtzuli | 3:2ae6218973be | 216 | case LEFT: |
yangtzuli | 3:2ae6218973be | 217 | motorR1 = motorSpeed[flag_sp]; |
yangtzuli | 3:2ae6218973be | 218 | motorR2 = LOW; |
yangtzuli | 3:2ae6218973be | 219 | motorL1 = LOW; |
yangtzuli | 3:2ae6218973be | 220 | motorL2 = motorSpeed[flag_sp]; |
yangtzuli | 3:2ae6218973be | 221 | break; |
yangtzuli | 3:2ae6218973be | 222 | case BACK: |
yangtzuli | 3:2ae6218973be | 223 | motorR1 = LOW; |
yangtzuli | 3:2ae6218973be | 224 | motorR2 = motorSpeed[flag_sp]; |
yangtzuli | 3:2ae6218973be | 225 | motorL1 = LOW; |
yangtzuli | 3:2ae6218973be | 226 | motorL2 = motorSpeed[flag_sp]; |
yangtzuli | 3:2ae6218973be | 227 | break; |
yangtzuli | 3:2ae6218973be | 228 | case STOP: |
yangtzuli | 3:2ae6218973be | 229 | motorR1 = LOW; |
yangtzuli | 3:2ae6218973be | 230 | motorR2 = LOW; |
yangtzuli | 3:2ae6218973be | 231 | motorL1 = LOW; |
yangtzuli | 3:2ae6218973be | 232 | motorL2 = LOW; |
yangtzuli | 3:2ae6218973be | 233 | break; |
yangtzuli | 3:2ae6218973be | 234 | } |
yangtzuli | 3:2ae6218973be | 235 | pc.printf(" motor\r\n"); |
yangtzuli | 4:3f80c0180e2f | 236 | ThisThread::sleep_for(30); |
yangtzuli | 2:38825726cb1b | 237 | } |
yangtzuli | 2:38825726cb1b | 238 | } |
yangtzuli | 3:2ae6218973be | 239 | void changeSpeed(){ |
yangtzuli | 3:2ae6218973be | 240 | if(flag_sp == VERYFAST){ |
yangtzuli | 3:2ae6218973be | 241 | flag_sp = NORMAL; |
yangtzuli | 3:2ae6218973be | 242 | |
yangtzuli | 3:2ae6218973be | 243 | }else{ |
yangtzuli | 3:2ae6218973be | 244 | flag_sp = flag_sp + 1; |
yangtzuli | 3:2ae6218973be | 245 | } |
yangtzuli | 3:2ae6218973be | 246 | } |
yangtzuli | 3:2ae6218973be | 247 | void trace(void const *argument){ |
yangtzuli | 3:2ae6218973be | 248 | while(true){ |
yangtzuli | 3:2ae6218973be | 249 | if(mode==LINE_TRACE){ |
yangtzuli | 3:2ae6218973be | 250 | pc.printf("line trace\r\n"); |
yangtzuli | 3:2ae6218973be | 251 | // センサー値読み取り |
yangtzuli | 3:2ae6218973be | 252 | int sensor1 = ss1; |
yangtzuli | 3:2ae6218973be | 253 | int sensor2 = ss2; |
yangtzuli | 3:2ae6218973be | 254 | int sensor3 = ss3; |
yangtzuli | 3:2ae6218973be | 255 | int sensor4 = ss4; |
yangtzuli | 3:2ae6218973be | 256 | int sensor5 = ss5; |
yangtzuli | 3:2ae6218973be | 257 | |
yangtzuli | 3:2ae6218973be | 258 | int sensD = 0; |
yangtzuli | 3:2ae6218973be | 259 | int sensorNum; |
yangtzuli | 3:2ae6218973be | 260 | |
yangtzuli | 3:2ae6218973be | 261 | if(sensor1 > 0) sensD |= 0x10; |
yangtzuli | 3:2ae6218973be | 262 | if(sensor2 > 0) sensD |= 0x08; |
yangtzuli | 3:2ae6218973be | 263 | if(sensor3 > 0) sensD |= 0x04; |
yangtzuli | 3:2ae6218973be | 264 | if(sensor4 > 0) sensD |= 0x02; |
yangtzuli | 3:2ae6218973be | 265 | if(sensor5 > 0) sensD |= 0x01; |
yangtzuli | 3:2ae6218973be | 266 | |
yangtzuli | 3:2ae6218973be | 267 | sensorNum = sensArray[sensD]; |
yangtzuli | 3:2ae6218973be | 268 | |
yangtzuli | 3:2ae6218973be | 269 | switch(sensorNum){ |
yangtzuli | 3:2ae6218973be | 270 | case 1: |
yangtzuli | 3:2ae6218973be | 271 | run = ADVANCE; |
yangtzuli | 3:2ae6218973be | 272 | break; |
yangtzuli | 3:2ae6218973be | 273 | case 2: |
yangtzuli | 3:2ae6218973be | 274 | run = RIGHT; |
yangtzuli | 3:2ae6218973be | 275 | break; |
yangtzuli | 3:2ae6218973be | 276 | case 3: |
yangtzuli | 3:2ae6218973be | 277 | run = LEFT; |
yangtzuli | 3:2ae6218973be | 278 | break; |
yangtzuli | 3:2ae6218973be | 279 | case 4: |
yangtzuli | 3:2ae6218973be | 280 | flag_sp += 3; |
yangtzuli | 3:2ae6218973be | 281 | run = RIGHT; |
yangtzuli | 3:2ae6218973be | 282 | break; |
yangtzuli | 3:2ae6218973be | 283 | case 5: |
yangtzuli | 3:2ae6218973be | 284 | flag_sp += 3; |
yangtzuli | 3:2ae6218973be | 285 | run = LEFT; |
yangtzuli | 3:2ae6218973be | 286 | break; |
yangtzuli | 3:2ae6218973be | 287 | } |
yangtzuli | 3:2ae6218973be | 288 | pc.printf(" line trace\r\n"); |
yangtzuli | 4:3f80c0180e2f | 289 | ThisThread::sleep_for(30); |
yangtzuli | 3:2ae6218973be | 290 | }else{ |
yangtzuli | 4:3f80c0180e2f | 291 | ThisThread::sleep_for(1); |
yangtzuli | 3:2ae6218973be | 292 | } |
yangtzuli | 3:2ae6218973be | 293 | } |
yangtzuli | 3:2ae6218973be | 294 | } |
yangtzuli | 3:2ae6218973be | 295 | |
yangtzuli | 2:38825726cb1b | 296 | /* 障害物回避走行 */ |
yangtzuli | 2:38825726cb1b | 297 | void avoidance(void const *argument){ |
yangtzuli | 3:2ae6218973be | 298 | while(1){ |
yangtzuli | 3:2ae6218973be | 299 | if(mode==AVOIDANCE){ |
yangtzuli | 5:3fffb364744b | 300 | pc.printf("avoidance\r\n"); |
yangtzuli | 5:3fffb364744b | 301 | pc.printf("%d %d %d %d %d \r\n",SL,SLD,SC,SRD,SR); |
yangtzuli | 5:3fffb364744b | 302 | |
yangtzuli | 5:3fffb364744b | 303 | if(flag_a == 0){ // 障害物がない場合 |
yangtzuli | 3:2ae6218973be | 304 | run = ADVANCE; // 前進 |
yangtzuli | 3:2ae6218973be | 305 | } |
yangtzuli | 5:3fffb364744b | 306 | else{ // 障害物がある場合 |
yangtzuli | 3:2ae6218973be | 307 | i = 0; |
yangtzuli | 3:2ae6218973be | 308 | if(SC < 15){ // 正面15cm以内に障害物が現れた場合 |
yangtzuli | 3:2ae6218973be | 309 | run = BACK; // 後退 |
yangtzuli | 3:2ae6218973be | 310 | while(watch() < limit){ // 正面20cm以内に障害物がある間 |
yangtzuli | 5:3fffb364744b | 311 | if(mode!=AVOIDANCE){ |
yangtzuli | 5:3fffb364744b | 312 | break; |
yangtzuli | 5:3fffb364744b | 313 | } |
yangtzuli | 3:2ae6218973be | 314 | } |
yangtzuli | 3:2ae6218973be | 315 | run = STOP; // 停止 |
yangtzuli | 2:38825726cb1b | 316 | } |
yangtzuli | 3:2ae6218973be | 317 | if(SC < limit && SLD < limit && SL < limit && SRD < limit && SR < limit){ // 全方向に障害物がある場合 |
yangtzuli | 3:2ae6218973be | 318 | run = LEFT; // 左折 |
yangtzuli | 5:3fffb364744b | 319 | while(i < 10){ // 進行方向確認 |
yangtzuli | 5:3fffb364744b | 320 | if(mode!=AVOIDANCE){ |
yangtzuli | 5:3fffb364744b | 321 | break; |
yangtzuli | 5:3fffb364744b | 322 | } |
yangtzuli | 3:2ae6218973be | 323 | if(watch() > limit){ |
yangtzuli | 5:3fffb364744b | 324 | i++; |
yangtzuli | 5:3fffb364744b | 325 | |
yangtzuli | 3:2ae6218973be | 326 | } |
yangtzuli | 3:2ae6218973be | 327 | else{ |
yangtzuli | 3:2ae6218973be | 328 | i = 0; |
yangtzuli | 3:2ae6218973be | 329 | } |
yangtzuli | 3:2ae6218973be | 330 | } |
yangtzuli | 3:2ae6218973be | 331 | run = STOP; // 停止 |
yangtzuli | 3:2ae6218973be | 332 | } |
yangtzuli | 3:2ae6218973be | 333 | else { // 全方向以外 |
yangtzuli | 3:2ae6218973be | 334 | far = SC; // 正面を最も遠い距離に設定 |
yangtzuli | 3:2ae6218973be | 335 | houkou = 1; // 進行方向を前に設定 |
yangtzuli | 3:2ae6218973be | 336 | if(far < SLD || far < SL){ // 左または左前がより遠い場合 |
yangtzuli | 3:2ae6218973be | 337 | if(SL < SLD){ // 左前が左より遠い場合 |
yangtzuli | 3:2ae6218973be | 338 | far = SLD; // 左前を最も遠い距離に設定 |
yangtzuli | 3:2ae6218973be | 339 | } |
yangtzuli | 3:2ae6218973be | 340 | else{ // 左が左前より遠い場合 |
yangtzuli | 3:2ae6218973be | 341 | far = SL; // 左を最も遠い距離に設定 |
yangtzuli | 3:2ae6218973be | 342 | } |
yangtzuli | 3:2ae6218973be | 343 | houkou = 2; // 進行方向を左に設定 |
yangtzuli | 2:38825726cb1b | 344 | } |
yangtzuli | 3:2ae6218973be | 345 | if(far < SRD || far < SR){ // 右または右前がより遠い場合 |
yangtzuli | 3:2ae6218973be | 346 | if(SR < SRD){ // 右前が右より遠い場合 |
yangtzuli | 3:2ae6218973be | 347 | far = SRD; // 右前を最も遠い距離に設定 |
yangtzuli | 3:2ae6218973be | 348 | } |
yangtzuli | 3:2ae6218973be | 349 | else{ // 右が右前よりも遠い場合 |
yangtzuli | 3:2ae6218973be | 350 | far = SR; // 右を最も遠い距離に設定 |
yangtzuli | 3:2ae6218973be | 351 | } |
yangtzuli | 3:2ae6218973be | 352 | houkou = 3; // 進行方向を右に設定 |
yangtzuli | 3:2ae6218973be | 353 | } |
yangtzuli | 3:2ae6218973be | 354 | switch(houkou){ // 進行方向の場合分け |
yangtzuli | 3:2ae6218973be | 355 | case 1: // 前の場合 |
yangtzuli | 3:2ae6218973be | 356 | run = ADVANCE; // 前進 |
yangtzuli | 5:3fffb364744b | 357 | pc.printf("Advance\r\n"); |
yangtzuli | 3:2ae6218973be | 358 | thread_sleep_for(100); // 1秒待つ |
yangtzuli | 3:2ae6218973be | 359 | break; |
yangtzuli | 3:2ae6218973be | 360 | case 2: // 左の場合 |
yangtzuli | 3:2ae6218973be | 361 | run = LEFT; // 左折 |
yangtzuli | 5:3fffb364744b | 362 | while(i < 10){ // 進行方向確認 |
yangtzuli | 5:3fffb364744b | 363 | pc.printf("left\r\n"); |
yangtzuli | 5:3fffb364744b | 364 | if(mode!=AVOIDANCE){ |
yangtzuli | 5:3fffb364744b | 365 | break; |
yangtzuli | 5:3fffb364744b | 366 | } |
yangtzuli | 3:2ae6218973be | 367 | if(watch() > (far - 2)){ |
yangtzuli | 3:2ae6218973be | 368 | i++; |
yangtzuli | 5:3fffb364744b | 369 | |
yangtzuli | 3:2ae6218973be | 370 | } |
yangtzuli | 3:2ae6218973be | 371 | else{ |
yangtzuli | 3:2ae6218973be | 372 | i = 0; |
yangtzuli | 3:2ae6218973be | 373 | } |
yangtzuli | 3:2ae6218973be | 374 | } |
yangtzuli | 3:2ae6218973be | 375 | run = STOP; // 停止 |
yangtzuli | 3:2ae6218973be | 376 | break; |
yangtzuli | 3:2ae6218973be | 377 | case 3: // 右の場合 |
yangtzuli | 3:2ae6218973be | 378 | run = RIGHT; // 右折 |
yangtzuli | 5:3fffb364744b | 379 | while(i < 10){ // 進行方向確認 |
yangtzuli | 5:3fffb364744b | 380 | pc.printf("right\r\n"); |
yangtzuli | 5:3fffb364744b | 381 | if(mode!=AVOIDANCE){ |
yangtzuli | 5:3fffb364744b | 382 | break; |
yangtzuli | 5:3fffb364744b | 383 | } |
yangtzuli | 3:2ae6218973be | 384 | if(watch() > (far - 2)){ |
yangtzuli | 3:2ae6218973be | 385 | i++; |
yangtzuli | 5:3fffb364744b | 386 | |
yangtzuli | 3:2ae6218973be | 387 | } |
yangtzuli | 3:2ae6218973be | 388 | else{ |
yangtzuli | 3:2ae6218973be | 389 | i = 0; |
yangtzuli | 3:2ae6218973be | 390 | } |
yangtzuli | 3:2ae6218973be | 391 | } |
yangtzuli | 3:2ae6218973be | 392 | run = STOP; // 停止 |
yangtzuli | 3:2ae6218973be | 393 | break; |
yangtzuli | 2:38825726cb1b | 394 | } |
yangtzuli | 2:38825726cb1b | 395 | } |
yangtzuli | 5:3fffb364744b | 396 | } |
yangtzuli | 5:3fffb364744b | 397 | pc.printf("こんにちは!\r\n"); |
yangtzuli | 5:3fffb364744b | 398 | flag_a = 0; // フラグを0にセット |
yangtzuli | 3:2ae6218973be | 399 | watchsurrounding(); |
yangtzuli | 3:2ae6218973be | 400 | pc.printf(" avoidance\r\n"); |
yangtzuli | 3:2ae6218973be | 401 | }else{ |
yangtzuli | 4:3f80c0180e2f | 402 | ThisThread::sleep_for(1); |
yangtzuli | 3:2ae6218973be | 403 | } |
yangtzuli | 2:38825726cb1b | 404 | } |
yangtzuli | 2:38825726cb1b | 405 | } |
yangtzuli | 2:38825726cb1b | 406 | int watch(){ |
yangtzuli | 5:3fffb364744b | 407 | led1=0; |
yangtzuli | 2:38825726cb1b | 408 | pc.printf("watch\r\n"); |
yangtzuli | 2:38825726cb1b | 409 | trig = 0; |
yangtzuli | 2:38825726cb1b | 410 | ThisThread::sleep_for(5); // 5ms待つ |
yangtzuli | 2:38825726cb1b | 411 | trig = 1; |
yangtzuli | 2:38825726cb1b | 412 | ThisThread::sleep_for(15); // 15ms待つ |
yangtzuli | 2:38825726cb1b | 413 | trig = 0; |
yangtzuli | 5:3fffb364744b | 414 | while(echo.read() == 0){ |
yangtzuli | 5:3fffb364744b | 415 | led1=1; |
yangtzuli | 5:3fffb364744b | 416 | if(mode!=AVOIDANCE){ |
yangtzuli | 5:3fffb364744b | 417 | break; |
yangtzuli | 5:3fffb364744b | 418 | } |
yangtzuli | 5:3fffb364744b | 419 | } |
yangtzuli | 2:38825726cb1b | 420 | timer.start(); // 距離計測タイマースタート |
yangtzuli | 2:38825726cb1b | 421 | while(echo.read() == 1){ |
yangtzuli | 2:38825726cb1b | 422 | } |
yangtzuli | 2:38825726cb1b | 423 | timer.stop(); // 距離計測タイマーストップ |
yangtzuli | 5:3fffb364744b | 424 | DT = (int)(timer.read_us()*0.01657); // 距離計算 |
yangtzuli | 5:3fffb364744b | 425 | if(DT > 100){ // 検知範囲外なら400cmに設定 |
yangtzuli | 5:3fffb364744b | 426 | DT = 100; |
yangtzuli | 2:38825726cb1b | 427 | } |
yangtzuli | 5:3fffb364744b | 428 | |
yangtzuli | 2:38825726cb1b | 429 | timer.reset(); // 距離計測タイマーリセット |
yangtzuli | 3:2ae6218973be | 430 | //ThisThread::sleep_for(30); // 30ms待つ |
yangtzuli | 5:3fffb364744b | 431 | pc.printf("私はDTである。%d\r\n",DT); |
yangtzuli | 2:38825726cb1b | 432 | return DT; |
yangtzuli | 0:0d0037aabe41 | 433 | } |
yangtzuli | 0:0d0037aabe41 | 434 | |
yangtzuli | 2:38825726cb1b | 435 | void watchsurrounding(){ |
yangtzuli | 2:38825726cb1b | 436 | pc.printf("watchsurrounding\r\n"); |
yangtzuli | 2:38825726cb1b | 437 | SC = watch(); |
yangtzuli | 2:38825726cb1b | 438 | if(SC < limit){ // 正面20cm以内に障害物がある場合 |
yangtzuli | 2:38825726cb1b | 439 | run = STOP; // 停止 |
yangtzuli | 2:38825726cb1b | 440 | } |
yangtzuli | 2:38825726cb1b | 441 | servo.pulsewidth_us(1925); // サーボを左に40度回転 |
yangtzuli | 2:38825726cb1b | 442 | ThisThread::sleep_for(250); // 250ms待つ |
yangtzuli | 2:38825726cb1b | 443 | SLD = watch(); |
yangtzuli | 2:38825726cb1b | 444 | if(SLD < limit){ // 左前20cm以内に障害物がある場合 |
yangtzuli | 2:38825726cb1b | 445 | run = STOP; // 停止 |
yangtzuli | 2:38825726cb1b | 446 | } |
yangtzuli | 2:38825726cb1b | 447 | servo.pulsewidth_us(2400); // サーボを左に90度回転 |
yangtzuli | 2:38825726cb1b | 448 | ThisThread::sleep_for(250); // 250ms待つ |
yangtzuli | 2:38825726cb1b | 449 | SL = watch(); |
yangtzuli | 2:38825726cb1b | 450 | if(SL < limit){ // 左20cm以内に障害物がある場合 |
yangtzuli | 2:38825726cb1b | 451 | run = STOP; // 停止 |
yangtzuli | 2:38825726cb1b | 452 | } |
yangtzuli | 2:38825726cb1b | 453 | servo.pulsewidth_us(1450); |
yangtzuli | 2:38825726cb1b | 454 | ThisThread::sleep_for(100); |
yangtzuli | 2:38825726cb1b | 455 | servo.pulsewidth_us(925); // サーボを右に40度回転 |
yangtzuli | 2:38825726cb1b | 456 | ThisThread::sleep_for(250); // 250ms待つ |
yangtzuli | 2:38825726cb1b | 457 | SRD = watch(); |
yangtzuli | 2:38825726cb1b | 458 | if(SRD < limit){ // 右前20cm以内に障害物がある場合 |
yangtzuli | 2:38825726cb1b | 459 | run = STOP; // 停止 |
yangtzuli | 2:38825726cb1b | 460 | } |
yangtzuli | 2:38825726cb1b | 461 | servo.pulsewidth_us(500); // サーボを右に90度回転 |
yangtzuli | 2:38825726cb1b | 462 | ThisThread::sleep_for(250); // 250ms待つ |
yangtzuli | 2:38825726cb1b | 463 | SR = watch(); |
yangtzuli | 2:38825726cb1b | 464 | if(SR < limit){ // 右20cm以内に障害物がある場合 |
yangtzuli | 2:38825726cb1b | 465 | run = STOP; // 停止 |
yangtzuli | 2:38825726cb1b | 466 | } |
yangtzuli | 2:38825726cb1b | 467 | servo.pulsewidth_us(1450); // サーボを中央位置に戻す |
yangtzuli | 2:38825726cb1b | 468 | ThisThread::sleep_for(100); // 100ms待つ |
yangtzuli | 2:38825726cb1b | 469 | if(SC < limit || SLD < limit || SL < limit || SRD < limit || SR < limit){ // 20cm以内に障害物を検知した場合 |
yangtzuli | 5:3fffb364744b | 470 | flag_a = 1; // フラグに1をセット |
yangtzuli | 2:38825726cb1b | 471 | } |
yangtzuli | 3:2ae6218973be | 472 | pc.printf(" watchsurrounding\r\n"); |
yangtzuli | 3:2ae6218973be | 473 | } |
yangtzuli | 3:2ae6218973be | 474 | |
yangtzuli | 3:2ae6218973be | 475 | void defaultView(){ |
yangtzuli | 3:2ae6218973be | 476 | lcd.setAddress(0,0); |
yangtzuli | 3:2ae6218973be | 477 | lcd.printf("Battery:"); |
yangtzuli | 3:2ae6218973be | 478 | lcd.setAddress(0,1); |
yangtzuli | 3:2ae6218973be | 479 | lcd.printf("Mode:"); |
yangtzuli | 2:38825726cb1b | 480 | } |
yangtzuli | 2:38825726cb1b | 481 | |
yangtzuli | 3:2ae6218973be | 482 | void display(){ |
yangtzuli | 3:2ae6218973be | 483 | mutex.lock(); |
yangtzuli | 3:2ae6218973be | 484 | lcd.setAddress(0,1); |
yangtzuli | 3:2ae6218973be | 485 | switch(mode){ |
yangtzuli | 3:2ae6218973be | 486 | case ADVANCE: |
yangtzuli | 3:2ae6218973be | 487 | //strcpy(DispMode,"Mode:Advance"); |
yangtzuli | 3:2ae6218973be | 488 | lcd.printf("Mode:Advance "); |
yangtzuli | 3:2ae6218973be | 489 | break; |
yangtzuli | 3:2ae6218973be | 490 | case RIGHT: |
yangtzuli | 3:2ae6218973be | 491 | //strcpy(DispMode,"Mode:Right"); |
yangtzuli | 5:3fffb364744b | 492 | lcd.printf("Mode:TurnRight "); |
yangtzuli | 3:2ae6218973be | 493 | break; |
yangtzuli | 3:2ae6218973be | 494 | case LEFT: |
yangtzuli | 3:2ae6218973be | 495 | //strcpy(DispMode,"Mode:Left"); |
yangtzuli | 5:3fffb364744b | 496 | lcd.printf("Mode:TurnLeft "); |
yangtzuli | 3:2ae6218973be | 497 | break; |
yangtzuli | 3:2ae6218973be | 498 | case BACK: |
yangtzuli | 3:2ae6218973be | 499 | //strcpy(DispMode,"Mode:Back"); |
yangtzuli | 3:2ae6218973be | 500 | lcd.printf("Mode:Back "); |
yangtzuli | 3:2ae6218973be | 501 | break; |
yangtzuli | 3:2ae6218973be | 502 | case STOP: |
yangtzuli | 3:2ae6218973be | 503 | //strcpy(DispMode,"Mode:Stop"); |
yangtzuli | 3:2ae6218973be | 504 | lcd.printf("Mode:Stop "); |
yangtzuli | 3:2ae6218973be | 505 | break; |
yangtzuli | 3:2ae6218973be | 506 | case READY: |
yangtzuli | 3:2ae6218973be | 507 | //strcpy(DispMode,"Mode:Stop"); |
yangtzuli | 3:2ae6218973be | 508 | lcd.printf("Mode:Ready "); |
yangtzuli | 3:2ae6218973be | 509 | break; |
yangtzuli | 3:2ae6218973be | 510 | case LINE_TRACE: |
yangtzuli | 3:2ae6218973be | 511 | //strcpy(DispMode,"Mode:LineTrace"); |
yangtzuli | 3:2ae6218973be | 512 | lcd.printf("Mode:LineTrace "); |
yangtzuli | 3:2ae6218973be | 513 | break; |
yangtzuli | 3:2ae6218973be | 514 | case AVOIDANCE: |
yangtzuli | 3:2ae6218973be | 515 | //strcpy(DispMode,"Mode:Avoidance"); |
yangtzuli | 3:2ae6218973be | 516 | lcd.setAddress(0,1); |
yangtzuli | 3:2ae6218973be | 517 | lcd.printf("Mode:Avoidance "); |
yangtzuli | 3:2ae6218973be | 518 | break; |
yangtzuli | 3:2ae6218973be | 519 | case SPEED: |
yangtzuli | 3:2ae6218973be | 520 | switch(flag_sp){ |
yangtzuli | 3:2ae6218973be | 521 | case(NORMAL): |
yangtzuli | 3:2ae6218973be | 522 | lcd.printf("Speed:Normal "); |
yangtzuli | 3:2ae6218973be | 523 | break; |
yangtzuli | 3:2ae6218973be | 524 | case(FAST): |
yangtzuli | 3:2ae6218973be | 525 | lcd.printf("Speed:Fast "); |
yangtzuli | 3:2ae6218973be | 526 | break; |
yangtzuli | 3:2ae6218973be | 527 | case(VERYFAST): |
yangtzuli | 3:2ae6218973be | 528 | lcd.printf("Speed:VeryFast "); |
yangtzuli | 3:2ae6218973be | 529 | break; |
yangtzuli | 3:2ae6218973be | 530 | } |
yangtzuli | 3:2ae6218973be | 531 | viewTimer.reset(); |
yangtzuli | 3:2ae6218973be | 532 | viewTimer.start(); |
yangtzuli | 3:2ae6218973be | 533 | break; |
yangtzuli | 3:2ae6218973be | 534 | } |
yangtzuli | 3:2ae6218973be | 535 | mutex.unlock(); |
yangtzuli | 3:2ae6218973be | 536 | } |
yangtzuli | 3:2ae6218973be | 537 | |
yangtzuli | 3:2ae6218973be | 538 | void lcdBacklight(void const *argument){ |
yangtzuli | 3:2ae6218973be | 539 | if(flag_b == 1){ |
yangtzuli | 3:2ae6218973be | 540 | lcd.setBacklight(TextLCD::LightOn); |
yangtzuli | 3:2ae6218973be | 541 | }else{ |
yangtzuli | 3:2ae6218973be | 542 | lcd.setBacklight(TextLCD::LightOff); |
yangtzuli | 3:2ae6218973be | 543 | } |
yangtzuli | 3:2ae6218973be | 544 | flag_b = !flag_b; |
yangtzuli | 3:2ae6218973be | 545 | } |
yangtzuli | 2:38825726cb1b | 546 | |
yangtzuli | 5:3fffb364744b | 547 | void bChange(){ |
yangtzuli | 3:2ae6218973be | 548 | lcd.setBacklight(TextLCD::LightOn); |
yangtzuli | 3:2ae6218973be | 549 | while(1){ |
yangtzuli | 3:2ae6218973be | 550 | pc.printf(" bChange1\r\n"); |
yangtzuli | 4:3f80c0180e2f | 551 | b = (int)(((battery.read() * 3.3 - MIN_V)/0.67)*10+0.5)*10; |
yangtzuli | 5:3fffb364744b | 552 | //pc.printf("%f",battery.read()); |
yangtzuli | 4:3f80c0180e2f | 553 | if(b < 0){//すべての機能停止(今はなし) |
yangtzuli | 4:3f80c0180e2f | 554 | b = 0; |
yangtzuli | 5:3fffb364744b | 555 | }else if(b > 50){ |
yangtzuli | 5:3fffb364744b | 556 | b = 50; |
yangtzuli | 3:2ae6218973be | 557 | } |
yangtzuli | 3:2ae6218973be | 558 | mutex.lock(); |
yangtzuli | 3:2ae6218973be | 559 | lcd.setAddress(0,0); |
yangtzuli | 2:38825726cb1b | 560 | lcd.printf("Battery:%3d%%",b); |
yangtzuli | 3:2ae6218973be | 561 | pc.printf(" bChange2\r\n"); |
yangtzuli | 3:2ae6218973be | 562 | mutex.unlock(); |
yangtzuli | 3:2ae6218973be | 563 | if(b <= 30){ |
yangtzuli | 3:2ae6218973be | 564 | if(flag_t == 0){ |
yangtzuli | 3:2ae6218973be | 565 | bTimer.start(500); |
yangtzuli | 3:2ae6218973be | 566 | flag_t = 1; |
yangtzuli | 3:2ae6218973be | 567 | } |
yangtzuli | 3:2ae6218973be | 568 | }else{ |
yangtzuli | 3:2ae6218973be | 569 | if(flag_t == 1){ |
yangtzuli | 3:2ae6218973be | 570 | bTimer.stop(); |
yangtzuli | 3:2ae6218973be | 571 | lcd.setBacklight(TextLCD::LightOn); |
yangtzuli | 3:2ae6218973be | 572 | flag_t = 0; |
yangtzuli | 3:2ae6218973be | 573 | } |
yangtzuli | 3:2ae6218973be | 574 | } |
yangtzuli | 2:38825726cb1b | 575 | } |
yangtzuli | 4:3f80c0180e2f | 576 | ThisThread::sleep_for(500); |
yangtzuli | 2:38825726cb1b | 577 | } |
yangtzuli | 0:0d0037aabe41 | 578 | int main() { |
yangtzuli | 3:2ae6218973be | 579 | mode = READY; |
yangtzuli | 3:2ae6218973be | 580 | beforeMode = READY; |
yangtzuli | 3:2ae6218973be | 581 | run = STOP; |
yangtzuli | 3:2ae6218973be | 582 | flag_sp = NORMAL; |
yangtzuli | 4:3f80c0180e2f | 583 | display(); |
yangtzuli | 2:38825726cb1b | 584 | |
yangtzuli | 0:0d0037aabe41 | 585 | while(1){ |
yangtzuli | 3:2ae6218973be | 586 | pc.printf(" main1\r\n"); |
yangtzuli | 5:3fffb364744b | 587 | bChange(); |
yangtzuli | 3:2ae6218973be | 588 | pc.printf(" main2\r\n"); |
yangtzuli | 4:3f80c0180e2f | 589 | ThisThread::sleep_for(1); |
yangtzuli | 0:0d0037aabe41 | 590 | } |
yangtzuli | 0:0d0037aabe41 | 591 | } |