private void HandleSpectrumDataHistory(List <List <byte> > history) { int startInterestZone = 0; int endInterestZone = 16; List <byte> spectrumdata = history[history.Count - 1]; int lowest = 254; int highest = 1; for (int i = 1; i < history.Count - 1; i++) { int volume = GetVolume(history[i], startInterestZone, endInterestZone); if (volume < lowest) { lowest = volume; } if (volume > highest) { highest = volume; } } /* * byte b = (byte)(highest * 5); * byte g = 0; * byte r = (byte)(255 - (highest * 10)); * Color color = new Color(r, g, b); */ int volumeRange = highest - lowest; if (volumeRange < 1) { volumeRange = 1; } double volumeFactor = (254 / volumeRange); int InterestVolume = GetVolume(spectrumdata, startInterestZone, endInterestZone); InterestVolume -= lowest; InterestVolume = (int)((double)InterestVolume * volumeFactor); if (InterestVolume < 0) { InterestVolume = 0; } if (InterestVolume > 254) { InterestVolume = 254; } sc.SendColor(ColorChannel.Red, (int)(InterestVolume * ((double)color.Red / 255))); sc.SendColor(ColorChannel.Green, (int)(InterestVolume * ((double)color.Green / 255))); sc.SendColor(ColorChannel.Blue, (int)(InterestVolume * ((double)color.Blue / 255))); }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { sc.SendColor(ColorChannel.Red, 0); sc.SendColor(ColorChannel.Green, 0); sc.SendColor(ColorChannel.Blue, 0); }