Blame view

main.c 1.29 KB
e583b6a9   henyxia   First version
1
  #include <stdio.h>
cdaa873f   henyxia   Log fixed
2
  #include <pthread.h>
11824cae   Pierre Letousey   Added automatic p...
3
  #include <unistd.h>
ae25085d   henyxia   Output function done
4
  #include "printx.h"
ea1218f1   henyxia   UI finished
5
  #include "ui.h"
3bdc9daf   henyxia   NFC Added
6
  #include "nfc.h"
d4d5bb6d   henyxia   Bus working
7
  #include "bus.h"
9e9f365e   henyxia   Added HVC interface
8
  #include "hvc.h"
bf0cbb04   Pierre Letousey   Automatic regulation
9
  #include "heat.h"
11824cae   Pierre Letousey   Added automatic p...
10
  #include "pump.h"
e583b6a9   henyxia   First version
11
  
e583b6a9   henyxia   First version
12
13
  int main(void)
  {
19082eeb   henyxia   UI design not wor...
14
  	int ret;
c72d79dd   henyxia   Semaphores contro...
15
  	pthread_t tUI;
8ecde263   henyxia   Added main view
16
  	pthread_t tNFC;
c72d79dd   henyxia   Semaphores contro...
17
  	pthread_t tBUS;
bc20374b   henyxia   Low IPS
18
  	pthread_t tHVC;
12ca1331   henyxia   Heat now threaded
19
  	pthread_t tHeat;
717e403d   henyxia   Sperated output
20
  	pthread_t tPump;
ea1218f1   henyxia   UI finished
21
22
23
24
25
26
  	initUILog();
  	if(!initLog())
  	{
  		printf("Log creation failed\n");
  		return 1;
  	}
297a72df   henyxia   Added sender
27
28
  	printx(INFO, MAIN, "Tweekd starting\n");
  	printx(DEBUG, MAIN, "Creating processes\n");
19082eeb   henyxia   UI design not wor...
29
  	ret = pthread_create(&tUI, NULL, drawUI, NULL);
297a72df   henyxia   Added sender
30
  	printx(DEBUG, MAIN, "UI Started ID %08x ret %d\n", tUI, ret);
8ecde263   henyxia   Added main view
31
  	printx(INFO, MAIN, "Initializing NFC\n");
3bdc9daf   henyxia   NFC Added
32
33
34
35
36
  	if(!initNFC())
  	{
  		printx(ERROR, MAIN, "Unable to start the NFC interface\n");
  		return 2;
  	}
8ecde263   henyxia   Added main view
37
  	pthread_create(&tNFC, NULL, processNFC, NULL);
d4d5bb6d   henyxia   Bus working
38
39
40
41
42
  	if(!initBus())
  	{
  		printx(ERROR, MAIN, "Unable to start the BUS interface\n");
  		return 3;
  	}
bc20374b   henyxia   Low IPS
43
  	pthread_create(&tBUS, NULL, processBus, NULL);
9e9f365e   henyxia   Added HVC interface
44
45
46
47
48
  	if(!initHVC())
  	{
  		printx(ERROR, MAIN, "Unable to start the HVC interface\n");
  		return 4;
  	}
bf0cbb04   Pierre Letousey   Automatic regulation
49
50
  	pthread_create(&tHVC, NULL, processHVC, NULL);
  	initProcessHeat();
11824cae   Pierre Letousey   Added automatic p...
51
  	initProcessPump();
12ca1331   henyxia   Heat now threaded
52
  	pthread_create(&tHeat, NULL, processHeat, NULL);
717e403d   henyxia   Sperated output
53
54
  	pthread_create(&tPump, NULL, processPump, NULL);
  
e912f423   henyxia   Urgent fix
55
  	sleep(20);
717e403d   henyxia   Sperated output
56
57
  	setVolWanted(1);
  	setCoffeeWanted();
ac55328a   henyxia   No more UI
58
  
cdaa873f   henyxia   Log fixed
59
  	pthread_join(tUI, NULL);
ae25085d   henyxia   Output function done
60
  	closeLog();
e583b6a9   henyxia   First version
61
62
  	return 0;
  }