Project

General

Profile

Revision 6d70682c

ID6d70682cdefdadb756586af26674f343126c9bed
Parent 6c30c8f9
Child d07266e1

Added by RicardoSilva91 almost 7 years ago

setdisplay tested, working

View differences:

tpf/display.c
8 8

  
9 9
#ifdef LCD_NOT_SEG
10 10

  
11
uint8_t setDisplayLCD(pse_time_t clock, uint16_t power, char* message)
11
static int lcdHandler;
12
static pse_time_t LCDClock;
13
static uint16_t LCDppower;
14

  
15
uint8_t setDisplay(pse_time_t clock, uint16_t power, char* message)
12 16
{
13
    int lcdHandler;
14 17
    uint8_t result;
15 18
    
16 19
    if(getLCDHandler(&lcdHandler)!=0)
......
84 87
    return result;
85 88
}
86 89

  
87
uint8_t clearDisplayLCD()
90
uint8_t clearDisplay()
91
{
92
    return 0;
93
}
94

  
95

  
96
uint8_t setDisplayTime(pse_time_t clock)
88 97
{
98
    LCDClock.horas = clock.horas;
99
    LCDClock.minutos = clock.minutos;
100
    LCDClock.segundos = clock.segundos;
101
    
89 102
    return 0;
90 103
}
91 104

  
105
uint8_t setDisplayPower(uint16_t power)
106
{
107
    uint8_t result=0;
108
    
109
    LCDppower = power;
110
    
111
    return result;
112
}
113

  
114
uint8_t showDisplay()
115
{
116
    //returned variable
117
    uint8_t result = 0;
118
    
119
    //clear previous displayed values
120
    lcdPosition (lcdHandler, 0, 0) ; lcdPuts (lcdHandler,"                ");
121
    lcdPosition (lcdHandler, 0, 1) ; lcdPuts (lcdHandler,"                ");
122
    
123
    //char arrays to contain values
124
    char horas[2];
125
    char minutos[2];
126
    char segundos[2];
127
    char powerChar[3];
128

  
129
    //read the values from static variables
130
    sprintf(horas, "%02d", LCDClock.horas);
131
    sprintf(minutos, "%02d", LCDClock.minutos);
132
    sprintf(segundos, "%02d", LCDClock.segundos);
133
    sprintf(powerChar, "%03d", LCDppower);
134
    
135
    //show time values on the left
136
    lcdPosition(lcdHandler, 0, 0);
137
    lcdPuts(lcdHandler, horas);
138
    //lcdPosition (lcdHandler, 2, 0) ; 
139
    lcdPutchar(lcdHandler, ':');
140
    //lcdPosition (lcdHandler, 3, 0) ; 
141
    lcdPuts(lcdHandler, minutos);
142
    //lcdPosition (lcdHandler, 5, 0) ; 
143
    lcdPutchar(lcdHandler, ':');
144
    //lcdPosition (lcdHandler, 6, 0) ; 
145
    lcdPuts(lcdHandler, segundos);
146

  
147
    //show power values on the right
148
    lcdPosition(lcdHandler, 12, 0);
149
    lcdPuts(lcdHandler, powerChar);
150
    lcdPosition(lcdHandler, 15, 0);
151
    lcdPutchar(lcdHandler, 'W');
152
  
153
    
154
    return result;
155
}
156

  
157
uint8_t initDisplay()
158
{
159
    uint8_t result = 0;
160
    
161
    if(getLCDHandler(&lcdHandler)!=0)
162
    {
163
        result=1;
164
    }
165
    
166
    return result;
167
}
168

  
169

  
170

  
171

  
172

  
92 173

  
93 174
#endif
tpf/display.h
8 8
#include "tempo.h"
9 9

  
10 10

  
11
#ifdef LCD_NOT_SEG
12 11

  
13 12
/**
14 13
*	\brief Displays the values received, in this case, the time,power and if needed a message 
15 14
*	
16 15
*	\param send a time as a pse_time_t, a uint8_t power and a message. If there is no need for a message, send a null char[]. The fuction returns 0 if success or !=0 if something failed
17 16
*/
18
uint8_t setDisplayLCD(pse_time_t clock, uint16_t power, char* message);
17
uint8_t setDisplay(pse_time_t clock, uint16_t power, char* message);
19 18

  
20 19
/**
21 20
*	\brief Limpa o display
22 21
*
23 22
 *      \param returns 0 if sucess and !=0 if something failed
24 23
*/
25
uint8_t clearDisplayLCD();
24
uint8_t clearDisplay();
26 25

  
27
#endif
28 26

  
29
#endif /* DISPLAY_H_ */ 
27
/**
28
 * @brief method used by tempo module to set time to show on LCD
29
 * @param clock time(hh:mm:ss) to set
30
 * @return  0 if sucess
31
 *          !0 if fail
32
 */
33
uint8_t setDisplayTime(pse_time_t clock);
34

  
35
/**
36
 * @brief method used by power module to set power(Watts) to show on LCD
37
 * @param power power to show (150, 350, 500, 750)
38
 * @return  0 if sucess
39
 *          !0 if fail
40
 */
41
uint8_t setDisplayPower(uint16_t power);
42

  
43

  
44
/**
45
 * @brief print values on the LCD display
46
 * @return  0 if sucess
47
 *          !0 if fail
48
 */
49
uint8_t showDisplay();
50

  
51
/**
52
 * method used on main module to initiate display activity
53
 * @return  0 if sucess
54
 *          !0 if fail
55
 */
56
uint8_t initDisplay();
57
        
58
        
59
#endif /* DISPLAY_H_ */ 
tpf/mainTest.c
354 354
        tempo.horas=0;
355 355
        tempo.minutos=20;
356 356
        tempo.segundos=20;
357
        char abc[16] = "jogos";
357
        //char abc[16] = "jogos";
358
        uint16_t power = powerSettings[0];
359
        
360
        initDisplay();
361
        setDisplayPower(power);
362
        setDisplayTime(tempo);
363
        showDisplay();
358 364
        
359
        setDisplayLCD(tempo, 750, abc);
360 365
        
361 366
        
362 367
#endif

Also available in: Unified diff