uint16_t battery_read_raw() { setBit(PF1, DDRF); // Powers Sensor // clrBit(PF1, PORTF); _delay_ms(10); uint16_t battery = hardware_analogRead(2); clrBit(PF1, DDRF); // Shuts down Sensor // return battery; }
unsigned int hardware_readLight(uint8_t r) { // Need to power off lights // hardware_flashlight(0); char backlightVal = lcd.getBacklight(); lcd.backlight(0); if(backlightVal > 0) _delay_ms(50); if(r > 2) r = 2; DDRA &= ~0b00000111; // clear all // PORTA &= ~0b00000111; // clear all // setBit(r, DDRA); // Powers Sensor // clrBit(r, PORTA); _delay_ms(50); uint16_t light = hardware_analogRead(0); clrBit(r, DDRA); // Shuts down Sensor // if(backlightVal > lcd.getBacklight()) lcd.backlight(backlightVal); return light; }
void hardware_lightning_enable() { // Need to power off lights // backlightVal = lcd.getBacklight(); lcd.backlight(0); if(backlightVal > 0) _delay_ms(50); setIn(LIGHT_SENSE_PIN); // set to input setLow(LIGHT_SENSE_PIN); // no pull-up uint8_t i = 3; while(i--) { hardware_light_enable(i); _delay_ms(50); uint16_t reading = hardware_analogRead(0); //DEBUG('('); //DEBUG(reading); //DEBUG(')'); //DEBUG(':'); //DEBUG(' '); //DEBUG_NL(); if(reading < 256) break; } //DEBUG(i); //if(getPin(LIGHT_SENSE_PIN)) { // DEBUG(STR("+")); //} //else //{ // DEBUG(STR("-")); //} shutter_half(); EIMSK &= ~_BV(INT6); // Interrupt disable EICRB |= (1<<ISC61)|(1<<ISC60); // Rising edge EIMSK |= _BV(INT6); // Interrupt enable }
unsigned int hardware_readLight(uint8_t r) { // Need to power off lights // backlightVal = lcd.getBacklight(); lcd.backlight(0); if(backlightVal > 0) _delay_ms(50); hardware_light_enable(r); _delay_ms(50); uint16_t light = hardware_analogRead(0); hardware_light_disable(); if(backlightVal > lcd.getBacklight()) lcd.backlight(backlightVal); return light; }