Beispiel #1
0
void Commands_init(unsigned long _eVal, byte _gVal){
  cmd.aVal[RA] = EEPROM_readLong(aVal1_Address); //steps/axis
  cmd.aVal[DC] = EEPROM_readLong(aVal2_Address); //steps/axis
  cmd.bVal[RA] = EEPROM_readLong(bVal1_Address); //sidereal rate
  cmd.bVal[DC] = EEPROM_readLong(bVal2_Address); //sidereal rate
  cmd.sVal[RA] = EEPROM_readLong(sVal1_Address); //steps/worm rotation
  cmd.sVal[DC] = EEPROM_readLong(sVal2_Address); //steps/worm rotation
  cmd.siderealIVal[RA] = EEPROM_readInt(IVal1_Address); //steps/worm rotation
  cmd.siderealIVal[DC] = EEPROM_readInt(IVal2_Address); //steps/worm rotation
  cmd.normalGotoSpeed[RA] = EEPROM_readByte(RAGoto_Address); //IVal for normal goto speed
  cmd.normalGotoSpeed[DC] = EEPROM_readByte(DECGoto_Address); //IVal for normal goto speed
  for(byte i = 0;i < 2;i++){
    cmd.dir[i] = 0;
    cmd.stepDir[i] = 1; //1-dir*2
    cmd.stopped[i] = 1;
    cmd.gotoEn[i] = 0;
    cmd.FVal[i] = 0;
    cmd.jVal[i] = 0x800000; //Current position, 0x800000 is the centre
    cmd.IVal[i] = cmd.siderealIVal[i]; //Recieved Speed will be set by :I command.
    cmd.GVal[i] = 0; //Mode recieved from :G command
    cmd.HVal[i] = 0; //Value recieved from :H command
    cmd.eVal[i] = _eVal; //version number
    cmd.gVal[i] = _gVal; //High speed scalar
    cmd.minSpeed[i] = cmd.siderealIVal[i]>>1;//2x sidereal rate. [minspeed is the point at which acceleration curves are enabled]
    cmd.stopSpeed[i] = cmd.minSpeed[i];
    cmd.currentIVal[i] = cmd.stopSpeed[i]+1; //just slower than stop speed as axes are stopped.
    cmd.motorSpeed[i] = cmd.stopSpeed[i]+1; //same as above.
    cmd.stepRepeat[i] = 0;//siderealIVal[i]/75;//((aVal[i] < 5600000UL) ? ((aVal[i] < 2800000UL) ? 16 : 8) : 4);
  }
}
Beispiel #2
0
char getReg(uint16_t reg, int* val) {
	if (reg >= REG_RELAY0 && reg < REG_RELAY0 + REG_RELAY_CNT) {
		*val = getOutput(reg - REG_RELAY0) ? 1 : 0;
	} else if (reg >= REG_PWM0 && reg < REG_PWM0 + REG_RELAY_CNT) {
		*val = getPWM(reg - REG_PWM0);
	} else if (reg == REG_TEMP) {
		*val = w1_temp(0);
		if (*val == TEMPERATURE_INVALID)
			return 0;
	} else if (reg == REG_ADC_CONF) {
		*val = EEPROM_readByte(&eeData.adcconf);
	} else if (reg == REG_RESET_BY_WD) {
		*val = EEPROM_readByte(&eeData.resetByWd);
	} else if (reg == REG_WD_ON_RECEIVE) {
		*val = EEPROM_readByte(&eeData.wdOnReceive);
	} else if (reg == REG_TIME_CORR_EN) {
		*val = EEPROM_readByte(&eeData.timeCorrEn);
	} else if (reg == REG_TIME_CORR) {
		*val = getCorr1();
	} else if (reg == REG_TIME_HI) {
		timeBuffer = getTime();
		*val = timeBuffer >> 16;
	} else if (reg == REG_TIME_LO) {
Beispiel #3
0
static __attribute__ ((noinline)) uint8_t get(uint8_t off) {
	return EEPROM_readByte(eeData.rules + off);
}
Beispiel #4
0
unsigned int EEPROM_readInt(unsigned int address) {
    TwoBytes fetcher;
    fetcher.array[0] = EEPROM_readByte(address);
    fetcher.array[1] = EEPROM_readByte(address+1);
    return fetcher.integer;
}
Beispiel #5
0
void EEPROM_readString(char* string, byte len, unsigned int address) {
    for(byte i = 0; i < len; i++) {
        string[i] = EEPROM_readByte(address++);
    }
}