C,
pasted
on Nov 4:
|
#include <M5Stack.h>
#include <TimeLib.h>
#include <TinyGPSPlus.h>
static const uint32_t GPSBaud = 9600;
TinyGPSPlus gps;
HardwareSerial ss(2);
#define LGFX_M5STACK
#include <LovyanGFX.hpp>
static LGFX lcd;
static LGFX_Sprite sprite(&lcd);
const int offset = 9;
int now_year, now_mon, now_day, now_hour, now_minute, now_second;
unsigned long clock_start_time;
int preview_second = 0;
boolean colon_view = true;
void setup(void) {
M5.begin();
ss.begin(GPSBaud);
pinMode(2, OUTPUT); // 1ppsの入力
pinMode(35, INPUT); // 1ppsの確認用
lcd.init();
lcd.setBrightness(4);
sprite.setColorDepth(16);
}
void loop() {
// 1ppsの確認
if (analogRead(35) != 0) {
digitalWrite(2, HIGH);
} else {
digitalWrite(2, LOW);
}
while (ss.available()) {
if (gps.encode(ss.read())) {
if (gps.date.age() < 500) {
setTime((gps.time.hour()), (gps.time.minute()), (gps.time.second()), (gps.date.day()), (gps.date.month()), (gps.date.year()));
adjustTime(offset * SECS_PER_HOUR);
}
}
}
now_year = year(now());
now_mon = month(now());
now_day = day(now());
now_hour = hour(now());
now_minute = minute(now());
now_second = second(now());
// 時刻とコロンの表示
if (now_second != preview_second && colon_view == true) {
clock_start_time = millis();
sprite.createSprite(320, 90);
sprite.clear(TFT_BLACK);
sprite.setFont(&fonts::Font7);
sprite.setTextDatum(top_left);
char clock_hh_mm[5];
sprintf(clock_hh_mm, "%02d:%02d", now_hour, now_minute);
sprite.setTextColor(TFT_WHITE);
sprite.setTextSize(1.9);
sprite.drawString(String(clock_hh_mm), 3, 0); // 時:分
char clock_ss[2];
sprintf(clock_ss, "%02d", now_second);
sprite.setTextSize(0.8);
sprite.drawString(String(clock_ss), 268, 52); // 秒
sprite.pushSprite(0, 30);
preview_second = now_second;
colon_view = false;
delay(1);
}
// コロンを消す
if ((millis() >= (clock_start_time + 500)) && colon_view == false) {
sprite.createSprite(15, 90);
sprite.clear(TFT_BLACK);
sprite.pushSprite(123, 30);
colon_view = true;
delay(1);
}
}
|
Output:
|
Line 20: error: M5Stack.h: No such file or directory
Line 20: error: TimeLib.h: No such file or directory
Line 24: error: TinyGPSPlus.h: No such file or directory
Line 5: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'GPSBaud'
Line 6: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'gps'
Line 7: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'ss'
Line 24: error: LovyanGFX.hpp: No such file or directory
Line 10: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'lcd'
Line 11: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'sprite'
Line 18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'colon_view'
In function 'setup':
Line 21: error: 'M5' undeclared (first use in this function)
Line 21: error: (Each undeclared identifier is reported only once
Line 21: error: for each function it appears in.)
Line 22: error: 'ss' undeclared (first use in this function)
Line 22: error: 'GPSBaud' undeclared (first use in this function)
Line 23: error: 'OUTPUT' undeclared (first use in this function)
Line 24: error: 'INPUT' undeclared (first use in this function)
Line 25: error: 'lcd' undeclared (first use in this function)
Line 27: error: 'sprite' undeclared (first use in this function)
In function 'loop':
Line 33: error: 'HIGH' undeclared (first use in this function)
Line 35: error: 'LOW' undeclared (first use in this function)
Line 38: error: 'ss' undeclared (first use in this function)
Line 39: error: 'gps' undeclared (first use in this function)
Line 42: error: 'SECS_PER_HOUR' undeclared (first use in this function)
Line 55: error: 'colon_view' undeclared (first use in this function)
Line 55: error: 'true' undeclared (first use in this function)
Line 57: error: 'sprite' undeclared (first use in this function)
Line 58: error: 'TFT_BLACK' undeclared (first use in this function)
Line 59: error: 'fonts' undeclared (first use in this function)
Line 59: error: expected ')' before ':' token
Line 60: error: 'top_left' undeclared (first use in this function)
Line 64: error: 'TFT_WHITE' undeclared (first use in this function)
Line 74: error: 'false' undeclared (first use in this function)
|
|