Browse Source

fix brigtness addition in exponential mode on low brightness

Alexander Lutsai 4 years ago
parent
commit
2caeecc1fd
1 changed files with 9 additions and 5 deletions
  1. 9
    5
      src/light.c

+ 9
- 5
src/light.c View File

185
     else
185
     else
186
         target_value_d = max_value_d * (light_percent_clamp(inpercent) / 100.0);
186
         target_value_d = max_value_d * (light_percent_clamp(inpercent) / 100.0);
187
     uint64_t target_value = LIGHT_CLAMP((uint64_t)target_value_d, 0, max_value);
187
     uint64_t target_value = LIGHT_CLAMP((uint64_t)target_value_d, 0, max_value);
188
-    *outraw = target_value;
188
+    *outraw = round(target_value);
189
     
189
     
190
     return true;
190
     return true;
191
 }
191
 }
880
         return false;
880
         return false;
881
     }
881
     }
882
     
882
     
883
-    uint64_t value = 0;
883
+    uint64_t value = 0, new_value = 0;
884
     if(!target->get_value(target, &value))
884
     if(!target->get_value(target, &value))
885
     {
885
     {
886
         LIGHT_ERR("failed to read from target");
886
         LIGHT_ERR("failed to read from target");
909
             return false;
909
             return false;
910
         }
910
         }
911
         percent += ctx->run_params.float_value;
911
         percent += ctx->run_params.float_value;
912
-        if(!_light_percent_to_raw(ctx, percent, &value))
912
+        if(!_light_percent_to_raw(ctx, percent, &new_value))
913
         {
913
         {
914
             LIGHT_ERR("failed to convert value from percent to raw for device target");
914
             LIGHT_ERR("failed to convert value from percent to raw for device target");
915
             return false;
915
             return false;
916
-        }        
916
+        }
917
+        if(new_value <= value)
918
+            value += 1;
919
+        else
920
+            value = new_value;
917
         break;
921
         break;
918
     }
922
     }
919
     
923
     
976
         {
980
         {
977
             LIGHT_ERR("failed to convert value from percent to raw for device target");
981
             LIGHT_ERR("failed to convert value from percent to raw for device target");
978
             return false;
982
             return false;
979
-        }        
983
+        }
980
         break;
984
         break;
981
     }
985
     }
982
     
986