/*
edison_google_calendar.ino
Part of "Intel IoT Edison Google Calendar reminder"
Copyright 2014 Pavlos Iliopoulos, techprolet.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
#include
#include "rgb_lcd.h"
#include "text_reader.c"
#define BUZZER_PIN 6
// const char * delimiter = " ,.-";
const char * delimiter = "\n";
char * str;
char * pch;
rgb_lcd lcd;
String lastEventSummary = " ";
String eventSummary = " ";
String eventLocation = " ";
bool stringIsOk = false;
bool buzzing = false;
void setup() {
//Initialize serial and wait for port to open:
Serial.begin(9600);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.setRGB(0,255,0);
lcd.print("Hello Google");
lcd.setCursor(0, 1);
lcd.print("Calendar!!!");
delay (2000);
lcd.setRGB(0,0,0);
lcd.setCursor(0, 0);
lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print(" ");
}
void loop() {
if (buzzing){
noTone(BUZZER_PIN);
buzzing = false;
}
// put your setup code here, to run once:
str = readFile();
pch = strtok (str, delimiter);
if (pch != NULL){
eventSummary = String(pch);
pch = strtok (NULL, delimiter);
eventLocation = String (pch);
pch = strtok (NULL, delimiter);
stringIsOk = String (pch) == "OK";
//read the rest of the string, you can omit this
while ((pch != NULL))
{
pch = strtok (NULL, delimiter);
}
}
if (stringIsOk && (eventSummary!=lastEventSummary)){
//first, empty the screen from the old message
lcd.setCursor(0, 0);
lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.setRGB(0,0,eventSummary==" "?0:255);
lcd.setCursor(0, 1);
if (eventSummary!=" "){
tone(BUZZER_PIN, 440); //play a La
buzzing = true;
lcd.setCursor(0, 0);
lcd.print(eventSummary);
lcd.setCursor(0, 1);
lcd.print(eventLocation);
}
lastEventSummary = eventSummary;
}
delay(2000);
}