Skip to content

Instantly share code, notes, and snippets.

@TakehikoShimojima
Last active May 28, 2018 02:06
Show Gist options
  • Select an option

  • Save TakehikoShimojima/c19e70d3bba5192670cc4bef626c6881 to your computer and use it in GitHub Desktop.

Select an option

Save TakehikoShimojima/c19e70d3bba5192670cc4bef626c6881 to your computer and use it in GitHub Desktop.
void loop() {
delay(REDRAW); // REDRAW時間(20ミリ秒)待つ
int y = pulseSensor.getLatestSample(); // 最新の心拍センサーの値を取得
if (x > 0) {
M5.Lcd.drawLine(x - 1, lastY, x, y, WHITE); // LCDに描画
lastY = y;
}
if (++x > LCD_WIDTH) { // LCD画面の最後まで描いたら
x = 0; // x軸を0に戻して
M5.Lcd.fillScreen(BLACK); // 画面を消去して
M5.Lcd.printf("BPM: %d", pulseSensor.getBeatsPerMinute()); // 心拍数を表示
}
if (++loopcount > PERIOD * 1000 / REDRAW) { // 送信間隔経過したら
loopcount = 0; // loopcountを0に戻して
while (!gps.location.isUpdated()) { // 位置情報が更新されるまで
while (GPS_s.available() > 0) {
if (gps.encode(GPS_s.read())) { // GPSデーターを読み、解析
break;
}
}
}
ambient.set(1, pulseSensor.getBeatsPerMinute()); // d1に心拍数
dtostrf(gps.location.lat(), 12, 8, buf);
ambient.set(9, buf); // d9に緯度
dtostrf(gps.location.lng(), 12, 8, buf);
ambient.set(10, buf); // d10に経度をセット
ambient.send(); // Ambientに送信
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment