示例#1
0
// Send control constants as JSON string. Might contain spaces between minus sign and number. Python will have to strip these
void PiLink::sendControlConstants(void){
	char tempString[12];
	print_P(PSTR("C:{"));
	sendJsonPair(jsonKeys.tempFormat, tempControl.cc.tempFormat);
	sendJsonPair(jsonKeys.tempSettingMin, tempToString(tempString, tempControl.cc.tempSettingMin, 1, 12));
	sendJsonPair(jsonKeys.tempSettingMax, tempToString(tempString, tempControl.cc.tempSettingMax, 1, 12));
	sendJsonPair(jsonKeys.KpHeat, fixedPointToString(tempString, tempControl.cc.KpHeat, 3, 12));
	sendJsonPair(jsonKeys.KpCool, fixedPointToString(tempString, tempControl.cc.KpCool, 3, 12));
	sendJsonPair(jsonKeys.Ki, fixedPointToString(tempString, tempControl.cc.Ki, 3, 12));
	sendJsonPair(jsonKeys.KdCool, fixedPointToString(tempString, tempControl.cc.KdCool, 3, 12));
	sendJsonPair(jsonKeys.KdHeat, fixedPointToString(tempString, tempControl.cc.KdHeat, 3, 12));
	sendJsonPair(jsonKeys.iMaxError, tempDiffToString(tempString, tempControl.cc.iMaxError, 3, 12));
	sendJsonPair(jsonKeys.iMaxSlope, tempDiffToString(tempString, tempControl.cc.iMaxSlope, 3, 12));
	sendJsonPair(jsonKeys.iMinSlope, tempDiffToString(tempString, tempControl.cc.iMinSlope, 3, 12));
	sendJsonPair(jsonKeys.idleRangeHigh, tempDiffToString(tempString, tempControl.cc.idleRangeHigh, 3, 12));
	sendJsonPair(jsonKeys.idleRangeLow, tempDiffToString(tempString, tempControl.cc.idleRangeLow, 3, 12));
	sendJsonPair(jsonKeys.heatingTargetUpper, tempDiffToString(tempString, tempControl.cc.heatingTargetUpper, 3, 12));
	sendJsonPair(jsonKeys.heatingTargetLower, tempDiffToString(tempString, tempControl.cc.heatingTargetLower, 3, 12));
	sendJsonPair(jsonKeys.coolingTargetUpper, tempDiffToString(tempString, tempControl.cc.coolingTargetUpper, 3, 12));
	sendJsonPair(jsonKeys.coolingTargetLower, tempDiffToString(tempString, tempControl.cc.coolingTargetLower, 3, 12));
	sendJsonPair(jsonKeys.maxHeatTimeForEstimate, tempControl.cc.maxHeatTimeForEstimate);
	sendJsonPair(jsonKeys.maxCoolTimeForEstimate, tempControl.cc.maxCoolTimeForEstimate);

	sendJsonPair(jsonKeys.fridgeFastFilter, tempControl.cc.fridgeFastFilter);
	sendJsonPair(jsonKeys.fridgeSlowFilter, tempControl.cc.fridgeSlowFilter);
	sendJsonPair(jsonKeys.fridgeSlopeFilter, tempControl.cc.fridgeSlopeFilter);
	sendJsonPair(jsonKeys.beerFastFilter, tempControl.cc.beerFastFilter);
	sendJsonPair(jsonKeys.beerSlowFilter, tempControl.cc.beerSlowFilter);
	// last one 'manually' to have no trailing comma
	print_P(PSTR("\"%s\":%u}\n"), jsonKeys.beerSlopeFilter, tempControl.cc.beerSlopeFilter);
}
示例#2
0
// Send settings as JSON string
void PiLink::sendControlSettings(void){
	char tempString[12];
	print_P(PSTR("S:{"));
	sendJsonPair(jsonKeys.mode, tempControl.cs.mode);
	sendJsonPair(jsonKeys.beerSetting, tempToString(tempString, tempControl.cs.beerSetting, 2, 12));
	sendJsonPair(jsonKeys.fridgeSetting, tempToString(tempString, tempControl.cs.fridgeSetting, 2, 12));
	sendJsonPair(jsonKeys.heatEstimator, fixedPointToString(tempString, tempControl.cs.heatEstimator, 3, 12));
	// last one 'manually' to have no trailing comma
	print_P(PSTR("\"%s\":%s}\n"), jsonKeys.coolEstimator, fixedPointToString(tempString, tempControl.cs.coolEstimator, 3, 12));
}
示例#3
0
// Send all control variables. Useful for debugging and choosing parameters
void PiLink::sendControlVariables(void){
	char tempString[12];
	print_P(PSTR("V:{"));
	sendJsonPair(jsonKeys.beerDiff, tempDiffToString(tempString, tempControl.cv.beerDiff, 3, 12));
	sendJsonPair(jsonKeys.diffIntegral, tempDiffToString(tempString, tempControl.cv.diffIntegral, 3, 12));
	sendJsonPair(jsonKeys.beerSlope, tempDiffToString(tempString, tempControl.cv.beerSlope, 3, 12));
	sendJsonPair(jsonKeys.p, fixedPointToString(tempString, tempControl.cv.p, 3, 12));
	sendJsonPair(jsonKeys.i, fixedPointToString(tempString, tempControl.cv.i, 3, 12));
	sendJsonPair(jsonKeys.d, fixedPointToString(tempString, tempControl.cv.d, 3, 12));
	sendJsonPair(jsonKeys.Kp, fixedPointToString(tempString, tempControl.cv.Kp, 3, 12));
	sendJsonPair(jsonKeys.Kd, fixedPointToString(tempString, tempControl.cv.Kd, 3, 12));
	sendJsonPair(jsonKeys.estimatedPeak, tempToString(tempString, tempControl.cv.estimatedPeak, 3, 12));
	sendJsonPair(jsonKeys.negPeakSetting, tempToString(tempString, tempControl.cv.negPeakSetting, 3, 12));
	sendJsonPair(jsonKeys.posPeakSetting, tempToString(tempString, tempControl.cv.posPeakSetting, 3, 12));
	sendJsonPair(jsonKeys.negPeak, tempToString(tempString, tempControl.cv.negPeak, 3, 12));
	print_P(PSTR("\"%s\":%s}\n"), jsonKeys.posPeak, tempToString(tempString, tempControl.cv.posPeak, 3, 12));
}
示例#4
0
void Display::printTemperature(fixed7_9 temp) {
    char tempString[9];
    tempToString(tempString, temp, 1 , 9);
    for(int i = 0; i<(5-strlen(tempString)); i++) {
        oled.write(' ');
    }
    oled.print(tempString);
}
示例#5
0
void PiLink::printTemperaturesJSON(char * beerAnnotation, char * fridgeAnnotation){
	char tempString[9];
	print_P(PSTR("T:{\"BeerTemp\":%s,"), tempToString(tempString, tempControl.getBeerTemp(), 2, 9));
	print_P(PSTR("\"BeerSet\":%s,"), tempToString(tempString, tempControl.getBeerSetting(), 2, 9));
	if(beerAnnotation == 0){
		print_P(PSTR("\"BeerAnn\":null,"));
	}
	else{
		print_P(PSTR("\"BeerAnn\":\"%s\","), beerAnnotation);
	}
	print_P(PSTR("\"FridgeTemp\":%s,"), tempToString(tempString, tempControl.getFridgeTemp(), 2, 9));
	print_P(PSTR("\"FridgeSet\":%s,"), tempToString(tempString, tempControl.getFridgeSetting(), 2, 9));
	if(fridgeAnnotation == 0){
		print_P(PSTR("\"FridgeAnn\":null}\n"));
	}
	else{
		print_P(PSTR("\"FridgeAnn\":\"%s\"}\n"), fridgeAnnotation);	
	}
}
示例#6
0
void LcdDisplay::printTemperature(temperature temp) {
    if (temp==INVALID_TEMP) {
        lcd.print_P(PSTR(" --.-"));
        return;
    }
    char tempString[9];
    tempToString(tempString, temp, 1 , 9);
    int8_t spacesToWrite = 5 - (int8_t) strlen(tempString);
    for(int8_t i = 0; i < spacesToWrite ; i++) {
        lcd.write(' ');
    }
    lcd.print(tempString);
}
示例#7
0
void pickTempSetting(ReadTemp readTemp, WriteTemp writeTemp, const char* tempName, DisplayUpdate update, PrintAnnotation printAnnoation, int row) {
	
	fixed7_9 oldSetting = readTemp();
	fixed7_9 startVal = oldSetting;
	if(oldSetting == INT_MIN)	 // previous temperature was not defined, start at 20C
		startVal = 20*512;
	
	rotaryEncoder.setRange(fixedToTenths(startVal), fixedToTenths(tempControl.cc.tempSettingMin), fixedToTenths(tempControl.cc.tempSettingMax));

	uint8_t blinkTimer = 0;
	uint16_t lastChangeTime = ticks.seconds();
	while(ticks.timeSince(lastChangeTime) < MENU_TIMEOUT){ // time out at 10 seconds
		if(rotaryEncoder.changed()){
			lastChangeTime = ticks.seconds();
			blinkTimer = 0;

			writeTemp(tenthsToFixed(rotaryEncoder.read()));		
			update();

			if( rotaryEncoder.pushed() ){
				rotaryEncoder.resetPushed();
				char tempString[9];
				printAnnoation(PSTR("%S temp set to %s in Menu."), tempName, tempToString(tempString,readTemp(),1,9));
				return;
			}
		}	
		else{
			if(blinkTimer == 0){
				update();
			}
			if(blinkTimer == 128){
				display.printAt_P(12, row, STR_6SPACES); // only 5 needed, but 6 is okay to and lets us re-use the string
			}
			blinkTimer++;
			wait.millis(3); // delay for blinking
		}
	}
	// Time Out. Restore original setting
	writeTemp(oldSetting);	
}