![](/media/cache/group/sakura-logo.png.50x50_q85.png)
sakura.io Evalution Board's sample program of power management.
Dependencies: AQM0802A SakuraIO mbed
Diff: main.cpp
- Revision:
- 1:c92bbea0eec1
- Parent:
- 0:4387b9fc4c58
--- a/main.cpp Tue May 15 02:30:39 2018 +0000 +++ b/main.cpp Thu May 31 07:06:53 2018 +0000 @@ -17,7 +17,7 @@ DigitalOut led_3(LED3); DigitalOut led_4(LED4); -DigitalOut leds[] = {led_1, led_2, led_3}; +DigitalOut leds[] = {led_1, led_2}; // LCD backlight DigitalOut lcd_led(LED_LCD); @@ -30,7 +30,7 @@ DigitalIn sw_5(SW5); DigitalIn sw_6(SW6); -DigitalIn sws[] = {sw_1, sw_2, sw_3}; +DigitalIn sws[] = {sw_1, sw_2}; // Internal I2C I2C internal_i2c(I2C_INTERNAL_SDA, I2C_INTERNAL_SCL); @@ -70,12 +70,29 @@ static void loop() { uint8_t mode = 0xff; - static uint8_t prev_sw[3] = {1, 1, 1}; + static uint8_t prev_sw[3] = {1, 1}; uint8_t send_sw; static uint8_t prev_send_sw = 1; uint8_t cnstat; static uint8_t prev_cnstat = 0xff; + // WAKE_INを設定 + if (wake_in != sw_5) { + lcd.cls(); + if (sw_5 == 1) { + lcd.printf("Running"); + } else { + lcd.printf("DeepSleep"); + cnstat = 0xff; + led_4 = 0; + } + } + wake_in = sw_5; + if (wake_in == 0) { + wait(0.1); + return; + } + // 動作中LEDを点滅させる led_4 = !led_4; @@ -96,7 +113,6 @@ uint8_t stat = sakuraio.getPowerSaveMode(); led_1 = (stat == 0) ? 1 : 0; led_2 = (stat == 1) ? 1 : 0; - led_3 = (stat == 2) ? 1 : 0; // 接続状態を表示 cnstat = sakuraio.getConnectionStatus(); @@ -120,9 +136,6 @@ } prev_send_sw = send_sw; - // WAKE_INを設定 - wake_in = sw_5; - uint8_t available, queued; if (sakuraio.getRxQueueLength(&available, &queued) == CMD_ERROR_NONE) { for (int i = 0; i < queued; i++) {