/* if socket is not equipped with metering then calibration should stop automatically after some time */ void metering_calibration_stop(void) { //store calibration in EEPROM eeprom_write_word((uint16_t*) EE_METERING_REF, 0); //lock calibration by setting flag in eeprom eeprom_write_byte((uint8_t*) EE_METERING_CAL_FLAG, 0x00); metering_calibration_state = 0; metering_calibration = false; relay_leds(); ctimer_stop(&metering_stop_timer); }
void relay_off(void) { #if ! METERING_ENERGY_PERSISTENT #if RELAY_POWER_SAVING DISABLE_RELAY_PWM(); SET_RELAY_PWM(0x00); #else PORTB &= ~(1 << PB3); #endif relay_state = 0; relay_leds(); metering_reset(); #endif }
void relay_on(void) { #if ! METERING_ENERGY_PERSISTENT if (!relay_state) { #if RELAY_POWER_SAVING ENABLE_RELAY_PWM(); //set PWM to 100% duty cycle SET_RELAY_PWM(RELAY_PWM_START); //sleep RELAY_OPERATE_TIME _delay_ms(RELAY_OPERATE_TIME); //set PWM to 50% duty cycle SET_RELAY_PWM(RELAY_PWM_HOLD); #else PORTB |= (1 << PB3); #endif relay_state = 1; relay_leds(); metering_reset(); } #endif }