Project

General

Profile

Statistics
| Branch: | Revision:

pse-2015-16-grupo-3 / tpf / display.c @ 65489db4

History | View | Annotate | Download (2.06 KB)

1
#include <stdlib.h>
2
#include <stdint.h>
3
#include <stdio.h>
4
#include <lcd.h>
5
#include "display.h"
6
#include "tempo.h"
7
#include "config.h"
8

    
9
uint8_t setDisplay(pse_time_t clock, uint16_t power, char* message)
10
{
11
    int lcdHandler;
12
    uint8_t result;
13
    
14
    if(getLCDHandler(&lcdHandler)!=0)
15
    {
16
        result=1;
17
    }
18
    else
19
    {
20
        
21
        lcdPosition (lcdHandler, 0, 0) ; lcdPuts (lcdHandler,"                ");
22
        lcdPosition (lcdHandler, 0, 1) ; lcdPuts (lcdHandler,"                ");
23
    
24
        char horas[2];
25
        char minutos[2];
26
        char segundos[2];
27
        char powerChar[3];
28
                
29
        sprintf(horas, "%02d", clock.horas);
30
        sprintf(minutos, "%02d", clock.minutos);
31
        sprintf(segundos, "%02d", clock.segundos);
32
        
33
        //printf("%02hho", clock.minutos);
34
        //printf("%02d", clock.segundos);
35
        //printf(minutos);
36
        //printf(segundos);
37
        
38
        sprintf(powerChar, "%03d", power);
39
        result=0;    
40
        if(message)
41
        {
42

    
43
            lcdPosition (lcdHandler, 0, 0); 
44
            lcdPuts (lcdHandler, horas);
45
            //lcdPosition (lcdHandler, 2, 0) ; 
46
            lcdPutchar (lcdHandler, ':');
47
            //lcdPosition (lcdHandler, 3, 0) ; 
48
            lcdPuts (lcdHandler, minutos);
49
            //lcdPosition (lcdHandler, 5, 0) ; 
50
            lcdPutchar (lcdHandler, ':');
51
            //lcdPosition (lcdHandler, 6, 0) ; 
52
            lcdPuts (lcdHandler, segundos);
53
            
54
            lcdPosition (lcdHandler, 12, 0) ; 
55
            lcdPuts (lcdHandler, powerChar);
56
            lcdPosition (lcdHandler, 15, 0) ; 
57
            lcdPutchar (lcdHandler, 'W');
58
            
59
            
60
            lcdPosition (lcdHandler, 0, 1) ; lcdPuts (lcdHandler,message) ;
61

    
62

    
63
        }
64
        else
65
        {
66

    
67
            lcdPosition (lcdHandler, 0, 0) ; lcdPuts (lcdHandler, horas);// + ':' + minutos + ':' + segundos + ' ' + Power +  'W') ;
68

    
69

    
70

    
71
        }
72
    }
73
    
74
    
75
    
76
    //power
77
            
78
            
79
    //Message
80
            
81
    
82
    return result;
83
}
84

    
85
uint8_t clearDisplay()
86
{
87
    return 0;
88
}