#include "heater3.h" #include "saveload.h" #include "potentiometers.h" #include "lcd-twi.h" extern heater_str heater[2]; extern opamp_str opamp[2]; extern preset_str preset[2]; void LoadPrefs() { for(uint8_t addr = 0; addr < 4; addr++) { EEAR = addr; EECR |= (1 << EERE); switch(addr) { case 0: heater[CH0].preset = EEDR; break; case 1: heater[CH1].preset = EEDR; break; case 2: heater[CH0].tset = EEDR; break; case 3: heater[CH1].tset = EEDR; break; } } } void SavePrefs() { cli(); for(uint8_t addr = 0; addr < 4; addr++) { EEAR = addr; switch(addr) { case 0: EEDR = heater[CH0].preset; break; case 1: EEDR = heater[CH1].preset; break; case 2: EEDR = heater[CH0].tset; break; case 3: EEDR = heater[CH1].tset; break; } EECR |= (1 << EEMPE); EECR |= (1 << EEPE); while(EECR & (1 << EEPE)); } sei(); } void LoadPreset(uint8_t ch) { uint8_t offset; for(offset = 0; offset < sizeof(preset_str); offset++) { EEAR = 0x30 + (heater[ch].preset * sizeof(preset_str)) + offset; EECR |= (1 << EERE); ((uint8_t*)&preset[ch])[offset] = EEDR; } SetGainData(ch, preset[ch].gain); SetShiftData(ch, preset[ch].shift); SetDriveData(ch, preset[ch].drive); SwitchDrive(ch, OFF); } void SavePreset(uint8_t ch) { uint8_t offset; static FILE lcd_stdout = FDEV_SETUP_STREAM(lcd_putchar, NULL, _FDEV_SETUP_WRITE); cli(); LCD_SendCmd(LCD_CLR); LCD_SetPos(0, 0); fprintf(&lcd_stdout, "ÑÎÕÐÀÍÅÍÈÅ..."); LCD_SetPos(0, 1); for(offset = 0; offset < sizeof(preset_str); offset++) { EEAR = 0x30 + (preset[ch].number * sizeof(preset_str)) + offset; EEDR = ((uint8_t*)&preset[ch])[offset]; EECR |= (1 << EEMPE); EECR |= (1 << EEPE); while(EECR & (1 << EEPE)); if((offset + 1) % 5 == 0) LCD_SendData(0xFF); } sei(); }