Rev 275 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 275 | Rev 276 | ||
|---|---|---|---|
| Line 2... | Line 2... | ||
| 2 | * |
2 | * |
| 3 | * Functions for controlling blinds |
3 | * Functions for controlling blinds |
| 4 | * |
4 | * |
| 5 | ********************************************************************* |
5 | ********************************************************************* |
| 6 | * FileName: $HeadURL: https://svn.auml.se/svn/HomeAutomation/trunk/EmbeddedSoftware/PIC/canTemp/Source/blinds.c $ |
6 | * FileName: $HeadURL: https://svn.auml.se/svn/HomeAutomation/trunk/EmbeddedSoftware/PIC/canTemp/Source/blinds.c $ |
| 7 | * Last changed: $LastChangedDate: 2007-01-30 12: |
7 | * Last changed: $LastChangedDate: 2007-01-30 12:53:25 +0100 (Tue, 30 Jan 2007) $ |
| 8 | * By: $LastChangedBy: johboh $ |
8 | * By: $LastChangedBy: johboh $ |
| 9 | * Revision: $Revision: |
9 | * Revision: $Revision: 276 $ |
| 10 | ********************************************************************/ |
10 | ********************************************************************/ |
| 11 | #include <blinds.h> |
11 | #include <blinds.h> |
| 12 | 12 | ||
| 13 | #ifdef USE_BLINDS |
13 | #ifdef USE_BLINDS |
| 14 | 14 | ||
| 15 | typedef enum {OPEN=2,CLOSE=4} MODE; |
- | |
| 16 | - | ||
| 17 |
|
15 | BLINDS_DIR mode = MIDDLE; |
| 18 | WORD numSteps = 0; |
16 | WORD numSteps = 0; |
| 19 | 17 | ||
| 20 | BYTE minCounter = 0; |
18 | BYTE minCounter = 0; |
| 21 | 19 | ||
| 22 | /* |
20 | /* |
| 23 | * Function: blindsInit |
21 | * Function: blindsInit |
| 24 | * |
22 | * |
| 25 | * Input: none. |
23 | * Input: none. |
| 26 | * Output: none. |
24 | * Output: none. |
| 27 | * Pre-conditions: none |
25 | * Pre-conditions: none |
| 28 | * Affects: none. |
26 | * Affects: none. |
| 29 | * Depends: none. |
27 | * Depends: none. |
| Line 36... | Line 34... | ||
| 36 | TMR1H=((TMR1_VAL&0xFF00)>>8); |
34 | TMR1H=((TMR1_VAL&0xFF00)>>8); |
| 37 | TMR1L=(TMR1_VAL&0xFF); |
35 | TMR1L=(TMR1_VAL&0xFF); |
| 38 | PIR1bits.TMR1IF = 0; |
36 | PIR1bits.TMR1IF = 0; |
| 39 | PIE1bits.TMR1IE = 1; |
37 | PIE1bits.TMR1IE = 1; |
| 40 | IPR1bits.TMR1IP = 1; // high prior? |
38 | IPR1bits.TMR1IP = 1; // high prior? |
| 41 | } |
39 | } |
| 42 | - | ||
| 43 | /* |
- | |
| 44 | * Function: blindsClose |
- | |
| 45 | * |
- | |
| 46 | * Input: Number of steps to perform. 255 equals full close. |
- | |
| 47 | * Output: none. |
- | |
| 48 | * Pre-conditions: none |
- | |
| 49 | * Affects: none. |
- | |
| 50 | * Depends: none. |
- | |
| 51 | */ |
- | |
| 52 | void blindsClose(WORD steps) |
- | |
| 53 | { |
- | |
| 54 | mode = CLOSE; |
- | |
| 55 | minCounter = 0; |
- | |
| 56 | numSteps = steps; |
- | |
| 57 | } |
- | |
| 58 | 40 | ||
| 59 | /* |
41 | /* |
| 60 | * Function: |
42 | * Function: blindsTurn |
| 61 | * |
43 | * |
| 62 | * Input: |
44 | * Input: Direction and number of steps to perform. |
| 63 | * Output: none. |
45 | * Output: none. |
| 64 | * Pre-conditions: none |
46 | * Pre-conditions: none |
| 65 | * Affects: none. |
47 | * Affects: none. |
| 66 | * Depends: none. |
48 | * Depends: none. |
| 67 | */ |
49 | */ |
| 68 | void |
50 | void blindsTurn(BLINDS_DIR dir, WORD steps) |
| 69 | { |
51 | { |
| 70 | mode = |
52 | mode = dir; |
| 71 | minCounter = 0; |
53 | minCounter = 0; |
| 72 | numSteps = steps; |
54 | numSteps = steps; |
| 73 | } |
55 | } |
| 74 | 56 | ||
| - | 57 | ||
| 75 | /* |
58 | /* |
| 76 | * Function: blindsStop |
59 | * Function: blindsStop |
| 77 | * |
60 | * |
| 78 | * Input: Stop blind at current position. |
61 | * Input: Stop blind at current position. |
| 79 | * Output: none. |
62 | * Output: none. |
| 80 | * Pre-conditions: none |
63 | * Pre-conditions: none |
| 81 | * Affects: none. |
64 | * Affects: none. |
| 82 | * Depends: none. |
65 | * Depends: none. |
| 83 | */ |
66 | */ |
| 84 | void blindsStop() |
67 | void blindsStop() |
| 85 | { |
68 | { |
| 86 | numSteps = 0; |
69 | numSteps = 0; |
| 87 | } |
70 | } |
| - | 71 | ||
| 88 | 72 | ||
| 89 | /* |
73 | /* |
| 90 | * Function: |
74 | * Function: blindsISR |
| 91 | * |
75 | * |
| 92 | * Input: |
76 | * Input: none. |
| 93 | * Output: none. |
77 | * Output: none. |
| 94 | * Pre-conditions: none |
78 | * Pre-conditions: none |
| 95 | * Affects: none. |
79 | * Affects: none. |
| 96 | * Depends: none. |
80 | * Depends: none. |
| 97 | */ |
81 | */ |