void createRandomBodyColor(double &r, double &g, double &b) { // Use narrow HSI ranges to avoid white (the selection color) // and avoid undesirable colors. double h = randrange(0.0, 6.283); double s = randrange(0.3, 1.0); double i = randrange(0.3, 0.8); hsi2rgb(h, s, i, r, g, b); }
void CLedControl::SetHsvRgb(float H, float S, float V) { int RGB[3]; float RGBf[3]; S /= 100; V /= 100; hsi2rgb(H, S, V, RGB); RGBf[0] = static_cast<float>(RGB[0])/255.0f; RGBf[1] = static_cast<float>(RGB[1])/255.0f; RGBf[2] = static_cast<float>(RGB[2])/255.0f; mRedLed = RGBf[0]; mGreenLed = RGBf[1]; mBlueLed = RGBf[2]; }
void ClydeDev::setEyeHSI(float H, float S, float I) { int rgb[3]; hsi2rgb(H, S, I, rgb); uint8_t new_r = (uint8_t)(rgb[0] * SCALE_CONSTRAINT); uint8_t new_g = (uint8_t)(rgb[1] * SCALE_CONSTRAINT); uint8_t new_b = (uint8_t)(rgb[2] * SCALE_CONSTRAINT); current_colour[0] = new_r; current_colour[1] = new_g; current_colour[2] = new_b; current_hue = H; analogWrite(eye_r_pin, new_r); analogWrite(eye_g_pin, new_g); analogWrite(eye_b_pin, new_b); }