Fredrik Haikarainen 10 jaren geleden
bovenliggende
commit
057bb40d04
1 gewijzigde bestanden met toevoegingen van 13 en 2 verwijderingen
  1. 13
    2
      src/light.c

+ 13
- 2
src/light.c Bestand weergeven

@@ -306,11 +306,22 @@ LIGHT_BOOL light_execute()
306 306
 
307 307
   rawSetP     = LIGHT_CLAMP( ((unsigned long) (light_Configuration.specifiedValuePercent * ((double)rawMax) ) / 100) , minCap, rawMax );
308 308
   rawAddP     = LIGHT_CLAMP( ((unsigned long) ( (percentCurr + light_Configuration.specifiedValuePercent) * ((double)rawMax)) / 100) , minCap, rawMax );
309
-  rawSubP     = LIGHT_CLAMP( ((unsigned long) ( (percentCurr - light_Configuration.specifiedValuePercent) * ((double)rawMax)) / 100) , minCap, rawMax );
309
+
310
+  if( light_Configuration.specifiedValuePercent > percentCurr)
311
+  {
312
+    rawSubP   = LIGHT_CLAMP(0, minCap, rawMax);
313
+  }else{
314
+    rawSubP     = LIGHT_CLAMP( ((unsigned long) ( (percentCurr - light_Configuration.specifiedValuePercent) * ((double)rawMax)) / 100) , minCap, rawMax );
315
+  }
310 316
 
311 317
   rawSetR     = LIGHT_CLAMP( light_Configuration.specifiedValueRaw , minCap, rawMax );
312 318
   rawAddR     = LIGHT_CLAMP( rawCurr + light_Configuration.specifiedValueRaw , minCap, rawMax );
313
-  rawSubR     = LIGHT_CLAMP( rawCurr - light_Configuration.specifiedValueRaw , minCap, rawMax );
319
+  
320
+  if(light_Configuration.specifiedValueRaw > rawCurr){
321
+    rawSubR     = LIGHT_CLAMP(0, minCap, rawMax)
322
+  }else{
323
+    rawSubR     = LIGHT_CLAMP( rawCurr - light_Configuration.specifiedValueRaw , minCap, rawMax );
324
+  }
314 325
 
315 326
   minCapP     = LIGHT_CLAMP(((unsigned long) (light_Configuration.specifiedValuePercent * ((double)rawMax) ) / 100), 0, rawMax);
316 327
   minCapR     = LIGHT_CLAMP( light_Configuration.specifiedValueRaw, 0, rawMax );