FanSpeedProfile.java 435 B

12345678910111213141516171819202122
  1. package eu.tankernn.grid;
  2. public class FanSpeedProfile {
  3. public static final int MAX_TEMP = 80, MIN_TEMP = 30, STEPS = 5;
  4. private int[] percentages = new int[STEPS];
  5. public int getSpeedPercentage(double temp) {
  6. int stepSize = (MAX_TEMP - MIN_TEMP) / STEPS;
  7. int currentTemp = MIN_TEMP;
  8. for (int i : percentages) {
  9. if (temp < currentTemp) {
  10. return i;
  11. }
  12. currentTemp += stepSize;
  13. }
  14. return 100;
  15. }
  16. }