Project

General

Profile

Revision 65489db4

ID65489db409f7333c821402ce224de0db244a2010
Parent ca430a12
Child 6c30c8f9

Added by RicardoSilva91 almost 7 years ago

setdisplay tested, working

View differences:

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

  
8
uint8_t setDisplay(pse_time_t clock, int uint8_t power ,char[] Message)
9
uint8_t setDisplay(pse_time_t clock, uint16_t power, char* message)
9 10
{
10 11
    int lcdHandler;
11 12
    uint8_t result;
13
    
12 14
    if(getLCDHandler(&lcdHandler)!=0)
13 15
    {
14
         result=1;
15
    }else{
16
    
17
    char horas[3];
18
    char minutos[3];
19
    char segundos[3];
20
    char Power[5];
21
    sprintf(horas, "%d", tempo.horas);
22
    sprintf(minutos, "%d", tempo.minutos);
23
    sprintf(segundos, "%d", tempo.segundos);
24
    sprintf(Power, "%d", power);
25
    result=0;    
26
    if(Message)
16
        result=1;
17
    }
18
    else
27 19
    {
28
       
29
        lcdPosition (lcdHandler, 0, 0) ; lcdPuts (lcdHandler,horas+":"+minutos+":"+segundos+"  "+Power+" W") ;
30
        lcdPosition (lcdHandler, 0, 1) ; lcdPuts (lcdHandler,Message) ;
31
        
32
        
33
    }else{
34
        
35
        lcdPosition (lcdHandler, 0, 0) ; lcdPuts (lcdHandler,horas+":"+minutos+":"+segundos+"  "+Power+" W") ;
36 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);
37 32
        
33
        //printf("%02hho", clock.minutos);
34
        //printf("%02d", clock.segundos);
35
        //printf(minutos);
36
        //printf(segundos);
38 37
        
39
    }}
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
    }
40 73
    
41 74
    
42 75
    
tpf/display.h
4 4
#include <stdint.h>
5 5
#include <stdlib.h>
6 6
#include <stdio.h>
7
#include "tempo.h"
7 8

  
8 9
/**
9 10
*	\brief Displays the values received, in this case, the time,power and if needed a message 
10 11
*	
11 12
*	\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
12 13
*/
13
uint8_t setDisplay(pse_time_t clock, int uint8_t power,char[] Message);
14

  
14
uint8_t setDisplay(pse_time_t clock, uint16_t power, char* message);
15 15

  
16 16
/**
17 17
*	\brief Limpa o display
tpf/mainTest.c
6 6
#include <stdlib.h>
7 7

  
8 8
#define testing
9
#define testing_display
9 10

  
10 11
#ifdef testing
11 12

  
......
19 20
int powerSet = 0;	//estiverem a 1 é que se pode dar Start
20 21

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

  
25 26
//1 enquanto estiver a funcionar(start), 0 se estiver parado(stop);
26 27
int isRunning = 0;
......
185 186
        }
186 187
        */
187 188
        
189
#ifndef testing_display
190
        
188 191
        int lcdHandler;
189 192
        uint8_t btnPressed=0;
190 193
        
......
344 347
        lcdPosition (lcdHandler, 0, 1) ; lcdPuts (lcdHandler, "       YOU      ") ;
345 348
        
346 349
#endif
350
        
351
#ifdef testing_display
352
        
353
        pse_time_t tempo;
354
        tempo.horas=0;
355
        tempo.minutos=20;
356
        tempo.segundos=20;
357
        char abc[16] = "jogos";
358
        
359
        setDisplay(tempo, 750, abc);
360
        
361
        
362
#endif
363
        
364
#endif
347 365

  
348 366
}
tpf/make_and_run.sh
1
make clean
2
make
3
sudo ./microwave
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>
14
            <file>file:/home/rofler/D/Google%20Drive/ua/PSE/git_code_ua/pse-2015-16-grupo-3/tpf/config.c</file>
15
            <file>file:/home/rofler/D/Google%20Drive/ua/PSE/git_code_ua/pse-2015-16-grupo-3/tpf/io.h</file>
16 13
            <file>file:/home/rofler/D/Google%20Drive/ua/PSE/git_code_ua/pse-2015-16-grupo-3/tpf/mainTest.c</file>
17
            <file>file:/home/rofler/D/Google%20Drive/ua/PSE/git_code_ua/pse-2015-16-grupo-3/tpf/config.h</file>
18 14
        </group>
19 15
    </open-files>
20 16
</project-private>

Also available in: Unified diff