//#include <IRremoteESP8266.h>
//#include <IRrecv.h>
#include "max7219func.h"
#include <SPI.h>
#include <LiquidCrystal_PCF8574.h>
#define PIN_RECEIVER 4 // Signal Pin of IR receiver
#define MAX_MESG 20
//void translateIR();
//IRrecv receiver(PIN_RECEIVER);
LiquidCrystal_PCF8574 lcd;
unsigned char szMesg[MAX_MESG + 1] = "";
void getTime(unsigned char *psz)
{
tm tim = DSRTCgetTime();
if (tim.tm_hour < 10)
sprintf((char*)psz, "%s%01d%c%02d", " ", tim.tm_hour, ' ', tim.tm_min);
else
sprintf((char*)psz, "%02d%c%02d", tim.tm_hour, ' ', tim.tm_min);
}
void setup()
{
Wire.begin();
Wire1.begin(33,32,100000);
lcd.begin(16,2,Wire1);
lcd.print("<press a button>");
mx.begin();
mx.setFont(numeric7Seg);
mx.setShiftDataInCallback(&dataInCB);
Serial.begin(115200);
//receiver.enableIRIn(); // Start the receiver
while (!Serial) // Wait for the serial connection to be establised.
delay(50);
Serial.println();
Serial.print("IRrecvDemo is now running and waiting for IR message on Pin ");
Serial.println(PIN_RECEIVER);
}
//decode_results results;
unsigned char str[] = "Várpalota:";
unsigned char str1[] = "53.6\x90\x43";
unsigned char str2[] = "Pára:";
unsigned char str3[] = "25%";
void loop()
{
// Checks received an IR signal
/* if (receiver.decode(&results)) {
translateIR();
receiver.resume(); // Receive the next value
} */
static uint8_t lastMinTime = 100;
//static uint32_t showTime = 0;
static uint32_t lastDSUpdate = 0; // Memory (ms)
static uint8_t lastSec = 5;
static bool flasher = false; // Seconds passing flasher
tm tim;
if (!lastDSUpdate || (millis() - lastDSUpdate) > 500) {
lastDSUpdate = millis();
tim = DSRTCgetTime();
//setTime(hours, minutes, seconds, mday, monthL, yearL);
}
//else hours = hour(), minutes = minute(), seconds = second();
if (lastSec == tim.tm_sec)return;
lastSec = tim.tm_sec;
if (flasher)mx.setColumn(22, 34); // Show colon
else mx.setColumn(22, 0);
flasher = !flasher;
getTime(szMesg);
showTime(false, 2, 6, 12, 16, 23, 27);
if (lastMinTime != tim.tm_min) {
printText(0, 3, szMesg, 1);
showTime(false, 2, 6, 12, 16, 23, 27);
lastMinTime = tim.tm_min;
}
if (tim.tm_sec % 5 != 0 || tim.tm_sec == 0) return;
TSUD(str, 0, 20, 2, false);
delay(1000);
TSLR(str1, 15, 20, 5);
//TSUD(str1, 4, 20, 2, false);
delay(2000);
TSLR(str2, 15, 10, 12);
TSLR(str3, 15, 0, 7);
delay(2000);
mx.clear();
getTime(szMesg);
TSLR(szMesg, 15, 0, 1, false);
//printText(0, 3, szMesg, 1);
flasher = !flasher;
}
/* void lcdPrint(const char* text)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("button pressed:");
lcd.setCursor(0, 1);
lcd.print(text);
lcd.print(" code: ");
lcd.print(results.command);
}
void translateIR()
{
// Takes command based on IR code received
switch (results.command) {
case 162:
char time[2];
//lcdPrint("POWER");
DS1307getTime();
lcdPrint(itoa(seconds, time, 10));
break;
case 226:
lcdPrint("MENU");
break;
case 34:
lcdPrint("TEST");
break;
case 2:
lcdPrint("PLUS");
break;
case 194:
lcdPrint("BACK");
break;
case 224:
lcdPrint("PREV.");
break;
case 168:
lcdPrint("PLAY");
break;
case 144:
lcdPrint("NEXT");
break;
case 104:
lcdPrint("num: 0");
break;
case 152:
lcdPrint("MINUS");
break;
case 176:
lcdPrint("key: C");
break;
case 48:
lcdPrint("num: 1");
break;
case 24:
lcdPrint("num: 2");
break;
case 122:
lcdPrint("num: 3");
break;
case 16:
lcdPrint("num: 4");
break;
case 56:
lcdPrint("num: 5");
break;
case 90:
lcdPrint("num: 6");
break;
case 66:
lcdPrint("num: 7");
break;
case 74:
lcdPrint("num: 8");
break;
case 82:
lcdPrint("num: 9");
break;
default:
lcd.clear();
lcd.print(results.command);
lcd.print(" other button");
}
}
*/