After converting all the IF statements like I suggested above, it did fit in RAM,
and it compiled to 313 WORDS.
mister_e,
Yours fit in RAM too, and compiled to 295 WORDS. (unexpected for Select Case)
You know what that means RIGHT?
Yup, this ain't over yet!
172 WORDS
However, omid_juve,Code:@ DEVICE WDT_OFF DEFINE NO_CLRWDT 1 ' Don't kick the Dog lowinput VAR GPIO.0 overtemprature VAR GPIO.1 overload VAR GPIO.2 outputpin VAR GPIO.3 green VAR GPIO.4 red VAR GPIO.5 FlashCount var byte FlashPattern var byte TRISIO = %000111 Start: If (lowinput=0) then IF (overload=0) then ; lowinput, overload, overtemprature if (overtemprature=0) then ; 000 outputpin = 0 FlashCount = 1 FlashPattern = %0001 ; ModeOK GOSUB FlashLEDs else ; 001 FlashCount = 5 FlashPattern = %0011 ; overtempraturemode gosub FlashLEDs outputpin = 1 endif else ; 010 if (overtemprature=0) then FlashCount = 2 FlashPattern = %1001 ; overloadmode gosub FlashLEDs outputpin =1 FlashCount = 7 gosub FlashLEDs outputpin =0 else ; 011 ; --- Action undefined --- endif endif else if (overload=0) then if (overtemprature=0) then ; 100 FlashCount = 5 FlashPattern = %1001 ; lowinputmode gosub FlashLEDs outputpin =1 else ; 101 ; --- Action undefined --- endif else ; 110 if (overtemprature=0) then FlashCount = 5 FlashPattern = %0011 ; overtempraturemode gosub FlashLEDs outputpin =1 else ; 111 ; --- Action undefined --- endif endif endif GOTO Start FlashLEDs: REPEAT green = FlashPattern.0 red = FlashPattern.1 Pause 500 green = FlashPattern.2 red = FlashPattern.3 Pause 500 FlashCount = FlashCount - 1 UNTIL (FlashCount = 0) return
There are 3 states that are not accounted for
lowinput=0 overload=1 overtemprature=1
lowinput=1 overload=0 overtemprature=0
lowinput=1 overload=1 overtemprature=1
It may be intentional. Maybe they aren't needed. But normally, unchecked states will cause havoc in your program.
If we knew what was supposed to happen in those states, I think mister_e ..., uh I mean, I could probably reduce it further.







Bookmarks