Corrected 1Mhz operating frequency

This commit is contained in:
Thomas Mørch
2015-05-12 22:14:28 +02:00
parent bf7372eeac
commit d5becd5ca1
@@ -58,6 +58,7 @@ MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
int measureCount = 0; int measureCount = 0;
int sendBattery = 0; int sendBattery = 0;
boolean isMetric = true; boolean isMetric = true;
boolean highfreq = true;
// Storage of old measurements // Storage of old measurements
float lastTemperature = -100; float lastTemperature = -100;
@@ -73,12 +74,11 @@ RunningAverage raTemp(AVERAGES);
* *
****************************************************/ ****************************************************/
void setup() { void setup() {
// clock_prescale_set(clock_div_8); // Switch to 1Mhz right after powerup.
pinMode(LED_PIN, OUTPUT); pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, LOW); digitalWrite(LED_PIN, LOW);
Serial.begin(19200); Serial.begin(115200);
Serial.print(F("Sensebender Micro FW ")); Serial.print(F("Sensebender Micro FW "));
Serial.print(RELEASE); Serial.print(RELEASE);
Serial.flush(); Serial.flush();
@@ -131,6 +131,12 @@ void loop() {
sendBattery ++; sendBattery ++;
bool forceTransmit = false; bool forceTransmit = false;
if ((measureCount == 5) && highfreq)
{
clock_prescale_set(clock_div_8); // Switch to 1Mhz for the reminder of the sketch, save power.
highfreq = false;
}
if (measureCount > FORCE_TRANSMIT_INTERVAL) { // force a transmission if (measureCount > FORCE_TRANSMIT_INTERVAL) { // force a transmission
forceTransmit = true; forceTransmit = true;
measureCount = 0; measureCount = 0;