123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- #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();
- }
|