void jogglerTask::run() { if ((m_timer++ % m_timeout) != 0) return; while(1) { if (ioctl(m_i2c, I2C_SMBUS, &smbus_ioctl_data)) { perror("Read result\n"); exit(1); } if (smbus_data.block[1] == 0x87) break; usleep(1000); } if (smbus_data.block[1] != 0x87) { fprintf(stderr, "Failed to get response\n"); exit(1); } int result = (smbus_data.block[3] << 8) | smbus_data.block[2]; if (result < 3) { backlightOff(); } else { backlightOn(); } }
void getSerial() { if (Serial.available() > 0) { keyIn = Serial.read(); Serial.print(keyIn, BYTE); if (keyIn == 'L') { backlightOn(); Serial.println("backlight on"); } else if (keyIn == 'l') { backlightOff(); Serial.println("backlight off"); } else { Serial.println("options: L - Led On; l - Led Off;"); } } }
void setup() // run once, when the sketch starts { Serial.begin(9600); backlightOff(); }