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: RemoteIR TextLCD
Diff: main.cpp
- Revision:
- 10:d193030ce672
- Parent:
- 9:266198aae6c2
- Child:
- 11:b5ceaef70827
--- a/main.cpp Thu Jul 30 07:41:52 2020 +0000
+++ b/main.cpp Thu Jul 30 07:57:42 2020 +0000
@@ -608,37 +608,33 @@
/* バッテリー残量更新関数 */
void bChange(){
- lcd.setBacklight(TextLCD::LightOn); // バックライトON
- while(1){
- pc.printf(" bChange1\r\n");
- b = (int)(((battery.read() * 3.3 - MIN_V)/0.67)*10+0.5)*10;
- if(b <= 0){ // バッテリー残量0%なら全ての機能停止
- b = 0;
- //lcd.setBacklight(TextLCD::LightOff);
- //run = STOP;
- //exit(1); // 電池残量が5%未満の時、LCDを消灯し、モーターを停止し、プログラムを終了する。
- }else if(b >= 100){ // バッテリー残量100%以上なら
- b = 100; // 100%
+ pc.printf(" bChange1\r\n");
+ b = (int)(((battery.read() * 3.3 - MIN_V)/0.67)*10+0.5)*10;
+ if(b <= 0){ // バッテリー残量0%なら全ての機能停止
+ b = 0;
+ //lcd.setBacklight(TextLCD::LightOff);
+ //run = STOP;
+ //exit(1); // 電池残量が5%未満の時、LCDを消灯し、モーターを停止し、プログラムを終了する。
+ }else if(b >= 100){ // バッテリー残量100%以上なら
+ b = 100; // 100%
+ }
+ mutex.lock(); // ミューテックスロック
+ lcd.setAddress(0,0);
+ lcd.printf("Battery:%3d%%",b); // バッテリー残量表示
+ pc.printf(" bChange2\r\n");
+ mutex.unlock(); // ミューテックスアンロック
+ if(b <= 30){ // バッテリー残量30%以下なら
+ if(flag_t == 0){ // バックライトタイマーフラグが0なら
+ bTimer.start(500); // 0.5秒周期でバックライトタイマー割り込み
+ flag_t = 1; // バックライトタイマーフラグを1に切り替え
}
- mutex.lock(); // ミューテックスロック
- lcd.setAddress(0,0);
- lcd.printf("Battery:%3d%%",b); // バッテリー残量表示
- pc.printf(" bChange2\r\n");
- mutex.unlock(); // ミューテックスアンロック
- if(b <= 30){ // バッテリー残量30%以下なら
- if(flag_t == 0){ // バックライトタイマーフラグが0なら
- bTimer.start(500); // 0.5秒周期でバックライトタイマー割り込み
- flag_t = 1; // バックライトタイマーフラグを1に切り替え
- }
- }else{
- if(flag_t == 1){ // バックライトタイマーフラグが1なら
- bTimer.stop(); // バックライトタイマーストップ
- lcd.setBacklight(TextLCD::LightOn); // バックライトON
- flag_t = 0; // バックライトタイマーフラグを0に切り替え
- }
+ }else{
+ if(flag_t == 1){ // バックライトタイマーフラグが1なら
+ bTimer.stop(); // バックライトタイマーストップ
+ lcd.setBacklight(TextLCD::LightOn); // バックライトON
+ flag_t = 0; // バックライトタイマーフラグを0に切り替え
}
- }
- ThisThread::sleep_for(500); // 500ms待つ
+ }
}
/* mainスレッド */
@@ -648,6 +644,7 @@
beforeMode = READY; // 前回待ちモード
run = STOP; // 停止
flag_sp = NORMAL; // スピード(普通)
+ lcd.setBacklight(TextLCD::LightOn); // バックライトON
display(); // ディスプレイ表示
while(1){