#define PWM_ORDER 10
#define PWM_HALF 5
-#define LIGHT_THRESHOLD 600
-#define TIME_ON 16
+#define LIGHT_THRESHOLD 800
+#define TIME_ON 160
#ifdef ADCSC /* Let us hope that this is a "new" model */
# define BIT_RL BIT0
{
int Duty_Cycle = 0;
int Increment = 1;
- unsigned int Time_Count = 0;
- unsigned int Time_Left = 5;
+ unsigned int Time_Left = 50;
unsigned int Time_Indicate = 2;
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
if (!Time_Indicate)
P1OUT &= ~(BIT_RL|BIT_GL); // LEDs off
}
- if (Time_Count++ > 10) {
- Time_Count = 0;
- if (Time_Left)
- Time_Left--;
- else if (Duty_Cycle > 1)
- Increment = -1;
+ if (Time_Left) {
+ Time_Left--;
+ if (!Time_Left)
+ if (Duty_Cycle)
+ Increment = -1;
}
if (Increment > 0) {
if (++Duty_Cycle >= (PWM_ORDER<<1)) {
Duty_Cycle = 0;
Increment = 0;
}
- } else
+ } else // Increment _was_ zero - no change!
continue;
TA0CCR2 = expon2(Duty_Cycle);