Commit 2c81ce37 by Hideaki Tai

LED indicator

parent 0f5b5594
......@@ -33,4 +33,6 @@ struct XBeeSettings
};
XBeeSettings xb_settings[6];
static constexpr uint32_t INDICATOR_INTERVAL_MS = 1000;
#endif // WHILL_GLOBAL_H
......@@ -289,6 +289,7 @@ void sendStatus()
{
if (b_streaming)
{
Serial.println("streaming enabled");
if (b_motor_active)
packer.pack(HARDWARE_ID, whill.battery(WhillOmni::LR::L), whill.battery(WhillOmni::LR::R), whill.errorCode(WhillOmni::LR::L), whill.errorCode(WhillOmni::LR::R));
else
......@@ -296,6 +297,10 @@ void sendStatus()
XBEE_SERIAL.write(packer.data(), packer.size());
}
else
{
Serial.println("streaming disabled");
}
}
void waitReply(uint16_t wait_ms = 0)
......
......@@ -41,6 +41,7 @@ void setup()
pinMode(PIN_IRLED_OE, OUTPUT);
digitalWrite(PIN_IRLED_OE, LOW); // Output Enable
pinMode(LED_BUILTIN, OUTPUT);
WHILL_SERIAL_L.begin(WHILL_SERIAL_BAUD, SERIAL_8N2); // L
WHILL_SERIAL_R.begin(WHILL_SERIAL_BAUD, SERIAL_8N2); // R
......@@ -94,7 +95,17 @@ void loop()
static uint32_t prev_ms = millis();
if ((millis() - prev_ms) > streaming_interval)
{
Serial.println("send status");
sendStatus();
prev_ms = millis();
}
static uint32_t prev_indicate = millis();
static bool led_state = false;
if ((millis() - prev_indicate) > INDICATOR_INTERVAL_MS)
{
digitalWrite(LED_BUILTIN, led_state);
led_state = !led_state;
prev_indicate = millis();
}
}
  • Markdown is supported
    0% or
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or sign in to comment