Project

General

Profile

Revision 87a830c5

ID87a830c59f978b8cf0423c76f6a0d8f87b8075f3
Parent d838fe06
Child 87c22974

Added by RicardoSilva91 almost 7 years ago

main tests

View differences:

tpf/display.c
160 160
{
161 161
    uint8_t result = 0;
162 162
    
163
    LCDClock.horas=0;
164
    LCDClock.minutos=0;
165
    LCDClock.segundos=0;
166
    
167
    
163 168
    if(getLCDHandler(&lcdHandler)!=0)
164 169
    {
165 170
        result=1;
tpf/mainTest.c
2 2
#include "display.h"
3 3
#include "config.h"
4 4
#include "io.h"
5
#include"power.h"
5 6
#include <stdio.h>
6 7
#include <stdlib.h>
8
#include <wiringPi.h>
7 9

  
8
#define testing
10
//#define testing
11
#define release
9 12

  
10 13
#ifdef testing
11 14

  
......
15 18

  
16 19
#endif
17 20

  
18

  
19
// Power Settings
20
uint16_t powerSettings[] = {150, 350, 500, 750};
21
uint16_t currentPower; //vai indice do array com o tempo atual de power
22

  
23 21
//switches / plugs / doors
24 22

  
25 23
//state of the on/off plug (switch) (1-> on; 0->off)
......
51 49
uint8_t minusBtnPressedLast=0;
52 50
//start/stop button
53 51
uint8_t startBtnPressed=0;
54
uint8_t ptartBtnPressedLast=0;
52
uint8_t startBtnPressedLast=0;
55 53

  
54
//internal states
56 55

  
57 56
//internal state of the hoven (0-> disabled; 1->running)
58 57
uint8_t runState=0;
58
//internal state to define which value is being configured (0-> power; 1-> time)
59
uint8_t powerOrTime=0;
59 60

  
60 61

  
61 62
//Ciclo de vida do sistema
62 63
int main()
63 64
{
65
#ifndef testing
66
#ifdef release
67
    
68
    pse_time_t temp;
69
    uint8_t flag=0;
64 70
    
71
    initBoard();
72
    initDisplay();
73
    
74
    while(1)
75
    {
76
        (uint8_t) getONOFFSwitch(&onOffState);
77
        
78
        if(onOffState==1)
79
        {
80
            //check pressed buttons
81
            
82
            //if user is already defining power settings, program only listens to pressing of the time button
83
            if(powerOrTime==0)
84
            {
85
                (uint8_t) getTimeButton(&timeBtnPressed);
86

  
87
                if (timeBtnPressed == 1 && timeBtnPressedLast == 0) 
88
                {
89
                    timeBtnPressedLast = 1;
90
                    powerOrTime=1;
91
                } 
92
                else if (timeBtnPressed == 0 && timeBtnPressedLast == 1) 
93
                {
94
                    timeBtnPressedLast = 0;
95
                }
96
                
97
                
98
                //read plus button
99
                (uint8_t) getPlusButton(&plusBtnPressed);
100

  
101
                if (plusBtnPressed == 1 && plusBtnPressedLast == 0) 
102
                {
103
                    plusBtnPressedLast = 1;
104
                    
105
                    nextPowerSetting();
106
                    
107
                } 
108
                else if (plusBtnPressed == 0 && plusBtnPressedLast == 1) 
109
                {
110
                    plusBtnPressedLast = 0;
111
                }
112
                
113
                
114
                //read minus button
115
                (uint8_t) getMinusButton(&minusBtnPressed);
116

  
117
                if (minusBtnPressed == 1 && minusBtnPressedLast == 0) 
118
                {
119
                    minusBtnPressedLast = 1;
120
                    
121
                    previousPowerSetting();
122
                    
123
                } 
124
                else if (minusBtnPressed == 0 && minusBtnPressedLast == 1) 
125
                {
126
                    minusBtnPressedLast = 0;
127
                }
128
                
129
                
130
            }
131
            //if user is already defining time settings, program only listens to pressing of the power button
132
            else
133
            {
134
                (uint8_t) getPowerButton(&powerBtnPressed);
135

  
136
                if (powerBtnPressed == 1 && powerBtnPressedLast == 0) 
137
                {
138
                    timeBtnPressedLast = 1;
139
                    powerOrTime=0;
140
                } 
141
                else if (powerBtnPressed == 0 && powerBtnPressedLast == 1) 
142
                {
143
                    powerBtnPressedLast = 0;
144
                }
145
                
146
                
147
                //read plus button
148
                (uint8_t) getPlusButton(&plusBtnPressed);
149

  
150
                if (plusBtnPressed == 1 && plusBtnPressedLast == 0) 
151
                {
152
                    plusBtnPressedLast = 1;
153
                    
154
                    increase();
155
                    
156
                } 
157
                else if (plusBtnPressed == 0 && plusBtnPressedLast == 1) 
158
                {
159
                    plusBtnPressedLast = 0;
160
                }
161
                
162
                
163
                //read minus button
164
                (uint8_t) getMinusButton(&minusBtnPressed);
165

  
166
                if (minusBtnPressed == 1 && minusBtnPressedLast == 0) 
167
                {
168
                    minusBtnPressedLast = 1;
169
                    
170
                    decrease();
171
                    
172
                } 
173
                else if (minusBtnPressed == 0 && minusBtnPressedLast == 1) 
174
                {
175
                    minusBtnPressedLast = 0;
176
                }
177
                
178
                
179
            }
180
            
181
            
182
            
183
            (uint8_t) IsDoorOpen(&doorState);
184
            
185
            if(doorState==0)
186
            {
187
                //read start/stop button
188
                (uint8_t) getStartStop(&startBtnPressed);
189

  
190
                if (startBtnPressed == 1 && startBtnPressedLast == 0) 
191
                {
192
                    startBtnPressedLast = 1;
193
                    
194
                    if(runState==0)
195
                    {
196
                        runState=1;
197
                    }
198
                    else
199
                    {
200
                        runState=0;
201
                    }
202
                    
203
                } 
204
                else if (startBtnPressed == 0 && startBtnPressedLast == 1) 
205
                {
206
                    startBtnPressedLast = 0;
207
                }
208
                
209
                
210
                //machine is Running
211
                if(runState==1)
212
                {
213
                    while(flag==0)
214
                    {
215
                        delay(1000);
216
                        decrease();
217
                        getTime(&temp);
218
                        if(temp.segundos==0)
219
                        {
220
                            flag=1;
221
                            runState=0;
222
                        }
223
                        showDisplay();
224
                    }
225
                    flag=0;
226
                }
227
                    
228
                
229
                
230
            }
231
            
232
            showDisplay();
233
        }
234
        
235
    }
236
    
237
    
238
    
239
#endif
240
#endif
241
    
242
#ifndef release
65 243
#ifndef testing
66 244
	pse_time_t tempo;
67 245
	tempo.segundos = 0;
......
372 550
#endif
373 551
        
374 552
#endif
553
        
554
#endif
375 555

  
376 556
}
tpf/nbproject/private/private.xml
10 10
    <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
11 11
    <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
12 12
        <group>
13
            <file>file:/home/rofler/D/Google%20Drive/ua/PSE/git_code_ua/pse-2015-16-grupo-3/tpf/io.c</file>
13 14
            <file>file:/home/rofler/D/Google%20Drive/ua/PSE/git_code_ua/pse-2015-16-grupo-3/tpf/mainTest.c</file>
15
            <file>file:/home/rofler/D/Google%20Drive/ua/PSE/git_code_ua/pse-2015-16-grupo-3/tpf/config.h</file>
14 16
        </group>
15 17
    </open-files>
16 18
</project-private>
tpf/power.c
1 1
#include "power.h"
2
#include "display.h"
2 3

  
4
#define antigo
5

  
6
// Power Settings
7
static uint16_t powerSettings[] = {150, 350, 500, 750};
8
static uint8_t powerSettingsIndex=0;
9

  
10

  
11
uint8_t nextPowerSetting()
12
{
13
    powerSettingsIndex++;
14
    if(powerSettingsIndex>3)
15
    {
16
        powerSettingsIndex=0;
17
    }
18
    
19
    setDisplayPower(powerSettings[powerSettingsIndex]);
20
    
21
    return 0;
22
}
23

  
24
uint8_t previousPowerSetting()
25
{
26
    if(powerSettingsIndex == 0)
27
    {
28
        powerSettingsIndex=3;
29
    }
30
    else
31
    {
32
        powerSettingsIndex--;
33
    }
34
    
35
    setDisplayPower(powerSettings[powerSettingsIndex]);
36
    
37
    return 0;
38
}
39

  
40

  
41
#ifndef antigo
3 42
uint8_t setPower(uint8_t powerValue, time_t execTime)
4 43
{
5 44
    return 0;
......
9 48
{
10 49
    return 0;
11 50
}
51

  
52
#endif 
tpf/power.h
7 7
uint8_t powerValue;
8 8
time_t execTime;
9 9

  
10

  
11
uint8_t nextPowerSetting();
12
uint8_t previousPowerSetting();
13

  
14
#ifdef antigo
15

  
10 16
/**
11 17
*	\brief Mostra no display a string recebida como argumento
12 18
*	
......
21 27
*/
22 28
uint8_t clearPower();
23 29

  
30
#endif
24 31

  
25 32
#endif /* DISPLAY_H_ */ 
tpf/tempo.c
1 1
#include "tempo.h"
2
#include "display.h"
2 3

  
3 4
pse_time_t relogio;
4 5

  
......
41 42
		}
42 43
	}
43 44
        
45
        
46
        
44 47
        return 0;
45 48
		
46 49
}
......
83 86
	else if(relogio.minutos > 3)
84 87
		increaseTime(30);
85 88
        
89
        setDisplayTime(relogio);
90
        
86 91
        return 0;
87 92
}
88 93

  
......
100 105
	else if(relogio.minutos > 3)
101 106
		decreaseTime(30);
102 107

  
108
        setDisplayTime(relogio);
109
        
103 110
        return 0;	
104 111
}
105 112

  

Also available in: Unified diff