diff --git a/src/main.cpp b/src/main.cpp index 675ae15..256e5ce 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -288,8 +288,11 @@ void dataMode(){ uint8_t calibW=135; //one of calibR,calibG or calibB should be 255. - int minval=min(r-calibR,min(g-calibG,b-calibB)); //0 if rgb contains full white. <0 if not full white. -1*(max(calibR,calibG,calibB)) if no white content - float whitecontent=1.0 + (minval/255.0); //scale to: 0=no white, 1=full white content + //int minval=min(r-calibR,min(g-calibG,b-calibB)); //0 if rgb contains full white. <0 if not full white. -1*(max(calibR,calibG,calibB)) if no white content + //float whitecontent=1.0 + (minval/255.0); //scale to: 0=no white, 1=full white content + + float whitecontent=min(float(r)/calibR, min(float(g)/calibG, float(b)/calibB)); + //subtract white contents from rgb r-=calibR*whitecontent; g-=calibG*whitecontent;