 }  
 
 void setTemperature() {
-  digits[0] = MINUS_SYMBOL;
-  digits[1] = 2;
-  digits[2] = 3;
-  digits[3] = DEGREE_SYMBOL;
+  const boolean isNegative = temperature < 0 ? true : false;
+  const int absTemperature = isNegative ? -temperature : temperature;
+
+  String textTemperature = String(absTemperature);
+  int textLength = textTemperature.length();
+  if (textLength == 0) {
+    textTemperature = "00";
+    textLength = 2;
+  }
+  else if (textLength == 1) {
+    textTemperature = "0" + textTemperature;
+    textLength = 2;
+  }
+
+Serial.println(textTemperature);
+
+  boolean hasDecimalPoint = true;
+  if ((isNegative && (textLength > 2)) || (!isNegative && (textLength > 3))) {
+    textTemperature.remove(textLength);
+    hasDecimalPoint = false;
+    textLength--;
+  }
+  
+  if (isNegative) {
+    if (textLength == 2) {
+      digits[0] = MINUS_SYMBOL;
+      digits[1] = String(textTemperature.charAt(textLength - 2)).toInt();
+      digits[2] = String(textTemperature.charAt(textLength - 1)).toInt();
+      digits[3] = DEGREE_SYMBOL;
+    } else {
+      digits[0] = E_SYMBOL;
+      digits[1] = R_SYMBOL;
+      digits[2] = R_SYMBOL;
+      digits[3] = DEGREE_SYMBOL; //todo add code for temperature overflow error
+    }
+  } else { // positive
+    if (textLength > 3) {
+      digits[0] = E_SYMBOL;
+      digits[1] = R_SYMBOL;
+      digits[2] = R_SYMBOL;
+      digits[3] = DEGREE_SYMBOL; //todo add code for temperature overflow error
+    } else {
+      if (textLength == 2) digits[0] = NOTHING_SYMBOL;
+      else digits[0] = String(textTemperature.charAt(textLength - 3)).toInt();
+      digits[1] = String(textTemperature.charAt(textLength - 2)).toInt();
+      digits[2] = String(textTemperature.charAt(textLength - 1)).toInt();
+      digits[3] = DEGREE_SYMBOL;
+    }
+  }
   
   decimalPoints[0] = false;
-  decimalPoints[1] = true;
+  decimalPoints[1] = hasDecimalPoint;
   decimalPoints[2] = false;
   decimalPoints[3] = false;
 }

}

int readData() {
  temperature = -23;
  humidity = 463;
  
  return 0;

    else setHumidity();
  }
  
//  delay(1000);
  
  // Draw one current digit on display
  activateDigit(INACTIVE);
  drawDigit(digits[currentDigitIndex], decimalPoints[currentDigitIndex]);
