]> www.fi.muni.cz Git - bike-lights.git/blobdiff - firmware/pwmled.c
delete pwm_off(), use pwm_set instead
[bike-lights.git] / firmware / pwmled.c
index 2640dba05bfc05edcd0c1d0f5e02f5c907919922..798546737d358f303889fd7490f97644f2ff91b1 100644 (file)
@@ -9,7 +9,7 @@ static unsigned char adc_vals[N_PWMLEDS*N_PWMLED_MODES] = {
        /* pwmled1 */
        0x04, 0x14, 0x24, 0x38,
        /* pwmled2 */
-       0x04, 0x14, 0x24, 0x38,
+       0x0c, 0x24, 0x48, 0x90,
 };
 
 // TODO: maybe convert this to bitmask to simplify pwmled_needs_adc() ?
@@ -28,7 +28,6 @@ static void start_probing(unsigned char n)
 {
        pwmled_state[n] = ST_PROBING;
        pwm_set(n, 0);
-       pwm_on(n);
        pwm_probes[n] = 0;
 }
 
@@ -87,7 +86,6 @@ void pwmled_set_mode(unsigned char n, unsigned char mode)
                mode--;
                pwmval = pwm_vals[n*N_PWMLED_MODES+mode];
                pwm_set(n, pwmval);
-               pwm_on(n);
 #if 0
                log_byte(pwmval);
 #endif
@@ -148,7 +146,7 @@ static void inline probing_adc(unsigned char n, uint16_t adcval)
                return;
        }
 
-       if (pwm >= 0x70) { // over the maximum!
+       if (pwm >= 0xE0) { // over the maximum!
                pwm_off(n);
                pwmled_state[n] = ST_DISABLED;
                log_byte(0xF2);
@@ -193,8 +191,8 @@ static void inline on_adc(unsigned char n, uint16_t adcval)
        }
 
        // FIXME: better disconnect detection
-       if (new_pwm > 0x60) { // disconnected?
-               new_pwm = 0x60;
+       if (new_pwm > 0xE0) { // disconnected?
+               new_pwm = 0xE0;
        }
        if (new_pwm < 2) { // short-circuit?
                new_pwm = 2;