/** Fix negative slopes by adjusting light output around a level */ private void fixNegativeSlopes(int n_lvl) { int output = table[n_lvl].output; for (int i = 0; i < table.length; i++) { BrightnessLevel lvl = table[i]; if (i < n_lvl && lvl.output > output) lvl.output = output; if (i > n_lvl && lvl.output < output) lvl.output = output; } }
/** Adjust a brightness table with DMS_BRIGHT_LOW feedback */ private void feedbackLow(int photo, int output) { int light = 0; // highest light output so far for (BrightnessLevel lvl : table) { light = Math.max(lvl.output, light); if (lvl.pc_down <= photo && photo <= lvl.pc_up) light = Math.max(light, output + ADJ_OUTPUT); lvl.output = Math.min(light, MAX_OUTPUT); } }
/** Adjust a brightness table with DMS_BRIGHT_HIGH feedback */ private void feedbackHigh(int photo, int output) { int light = MAX_OUTPUT; // lowest light output so far for (int i = table.length - 1; i >= 0; i--) { BrightnessLevel lvl = table[i]; light = Math.min(lvl.output, light); if (lvl.pc_down <= photo && photo <= lvl.pc_up) light = Math.min(light, output - ADJ_OUTPUT); lvl.output = Math.max(light, 0); } }
/** Adjust a brightness table with DMS_BRIGHT_GOOD feedback */ private void feedbackGood(int photo, int output) { final int max_photo = getMaxPhotocell(); for (int i = 0; i < table.length; i++) { BrightnessLevel lvl = table[i]; if (lvl.pc_down <= photo && photo <= lvl.pc_up) { int prev = 0; int next = max_photo; if (i > 0) prev = table[i - 1].pc_up; if (i < table.length - 1) next = table[i + 1].pc_down; if (prev < photo && photo < next) { lvl.output = output; fixNegativeSlopes(i); } } } }