]> www.fi.muni.cz Git - bike-lights.git/commitdiff
pwmled: more logging
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Thu, 22 Nov 2012 22:00:00 +0000 (23:00 +0100)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Thu, 22 Nov 2012 22:00:00 +0000 (23:00 +0100)
firmware/pwmled.c

index 8c6196481bfc64c4d60b1be62d15011d2cfe647b..d5d947be2d011a396353b11cc7f88f93824a5ae9 100644 (file)
@@ -4,9 +4,9 @@
 
 static uint16_t pwm_vals[N_PWMLEDS*N_PWMLED_MODES];
 static uint16_t pwm_max[N_PWMLEDS] = {
-       PWM_MAX/2,
+       2*PWM_MAX/3,
        PWM_MAX - (PWM_MAX >> 4), // step-up
-       PWM_MAX/2
+       2*PWM_MAX/3
 };
 
 #define PWMLED2_TESTING_WITH_350MA_LED
@@ -137,7 +137,7 @@ static void inline probing_adc(unsigned char n, uint16_t adcval)
 #endif
 
        if (adcval > adc_max[n] // Too high
-               || (pwm == 0 && adcval > 0) // non-zero voltage with zero PWM
+               || (pwm == 0 && adcval > 2) // non-zero voltage with zero PWM
                ) {
                pwm_off(n);
                pwmled_state[n] = ST_DISABLED;
@@ -230,7 +230,14 @@ static void inline on_adc(unsigned char n, uint16_t adcval)
 
        if (new_pwm > (int16_t)pwm_max[n]) {
                // FIXME: disconnected?
-               new_pwm = pwm_max[n];
+               log_byte(0xE1);
+               log_byte(n);
+               log_word(new_pwm);
+               log_word(adcval);
+               log_word(jiffies);
+               pwmled_state[n] = ST_DISABLED;
+               pwm_off(n);
+               return;
        }
 
        if (new_pwm < 1) {
@@ -261,6 +268,8 @@ void pwmled_adc(unsigned char n, uint16_t adcval)
                                probing = 1;
 
                if (!probing) {
+                       log_word(0x5555);
+                       log_word(jiffies);
                        for (i = 0; i < N_PWMLEDS; i++)
                                log_byte(pwmled_state[i]);
                                
@@ -268,6 +277,8 @@ void pwmled_adc(unsigned char n, uint16_t adcval)
                                log_word(pwm_vals[i]);
                        log_flush();
                        log_set_state(4);
+                       for (i = 0; i < N_PWMLEDS; i++)
+                               led_set_pattern(i, mode1_pattern);
                }
 #endif