Use only 8 bytes

This commit is contained in:
2012-10-28 13:58:10 +01:00
parent d21f38f24b
commit dd03575d1b
2 changed files with 20 additions and 28 deletions

View File

@ -45,6 +45,10 @@ inline Print &operator >>(Print &obj, T arg)
return obj;
}
template<class T>
inline Print &operator +(Print &obj, T arg)
{ obj.print(arg, HEX); return obj; }
void setup() {
Serial.begin(9600);
@ -56,10 +60,10 @@ void setup() {
Wire.write((byte)0);
Wire.endTransmission();
Wire.requestFrom(CHRONODOT_ADDRESS, 19);
byte blah[20];
Wire.requestFrom(CHRONODOT_ADDRESS, 7);
byte blah[8];
int i;
for(i=0; i<20; i++) {
for(i=0; i<8; i++) {
blah[i] = Wire.read();
}
@ -71,14 +75,6 @@ void setup() {
uint8_t d = bcd2bin(blah[4]);
uint8_t m = bcd2bin(blah[5]);
uint16_t y = bcd2bin(blah[6]) + 2000;
float ttc = (float)(int)blah[17];
byte portion = blah[18];
if(portion == 0b01000000) ttc += 0.25;
if(portion == 0b10000000) ttc += 0.5;
if(portion == 0b11000000) ttc += 0.75;
float degF = (((ttc * 9.0) / 5.0) + 32.5);
int ttf = (int)degF;
//return DateTime (y, m, d, hh, mm, ss, ttf, ttc);
Serial.println();
Serial.println("What\tByte\tCorrespondance");
@ -90,9 +86,17 @@ void setup() {
<< "hours\t" << blah[2] << "\t" << hh << "\r\n"
<< "days\t" << blah[4] << "\t" << d << "\r\n"
<< "months\t" << blah[5] << "\t" << m << "\r\n"
<< "years\t" << blah[6] << "\t" << y << "\r\n"
<< "temp\t" << blah[17] << "\t" << ttc << "\r\n"
<< "temp\t" << blah[18] << "\t" << portion << "\r\n";
<< "years\t" << blah[6] << "\t" << y << "\r\n";
Serial.println();
Serial
<< y << "-" << m << "-" << d << " "
<< hh << ":" << mm << ":" << ss << "\r\n";
Serial.println();
Serial.println("Address\tDecimal\tBinary");
Serial.println("----------------------");
Serial + CHRONODOT_ADDRESS << "\t" << CHRONODOT_ADDRESS << "\t" >> CHRONODOT_ADDRESS << "\r\n";
Serial.println();
Serial.println("Byte\tDecimal\tBinary");
@ -106,19 +110,7 @@ void setup() {
<< "4\t" << blah[4] << "\t" >> blah[4] << "\r\n"
<< "5\t" << blah[5] << "\t" >> blah[5] << "\r\n"
<< "6\t" << blah[6] << "\t" >> blah[6] << "\r\n"
<< "7\t" << blah[7] << "\t" >> blah[7] << "\r\n"
<< "8\t" << blah[8] << "\t" >> blah[8] << "\r\n"
<< "9\t" << blah[9] << "\t" >> blah[9] << "\r\n"
<< "10\t" << blah[10] << "\t" >> blah[10] << "\r\n"
<< "11\t" << blah[11] << "\t" >> blah[11] << "\r\n"
<< "12\t" << blah[12] << "\t" >> blah[12] << "\r\n"
<< "13\t" << blah[13] << "\t" >> blah[13] << "\r\n"
<< "14\t" << blah[14] << "\t" >> blah[14] << "\r\n"
<< "15\t" << blah[15] << "\t" >> blah[15] << "\r\n"
<< "16\t" << blah[16] << "\t" >> blah[16] << "\r\n"
<< "17\t" << blah[17] << "\t" >> blah[17] << "\r\n"
<< "18\t" << blah[18] << "\t" >> blah[18] << "\r\n"
<< "19\t" << blah[19] << "\t" >> blah[19] << "\r\n";
<< "7\t" << blah[7] << "\t" >> blah[7] << "\r\n";
}
void loop() {