-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
109 lines (99 loc) · 2.46 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include <stdio.h>
#include <string.h>
#include "middleware.h"
#include "graphics.h"
#include "remote.h"
#define VOLUME_STEP 10
static uint8_t volume;
static channel_info_t channelInfo;
static info_data_t infoBarData;
void copyValues(channel_info_t *channelStruct, info_data_t *infoStruct)
{
infoStruct->channelNumber = channelStruct->channelNumber;
infoStruct->teletextExist = channelStruct->teletextExist;
infoStruct->audioPID = channelStruct->audioPID;
infoStruct->videoPID = channelStruct->videoPID;
strcpy(infoStruct->date, channelStruct->date);
}
int32_t channelChanged(uint8_t channel)
{
channelInfo = getChannelInfo();
copyValues(&channelInfo, &infoBarData);
drawInfoBar(infoBarData);
return 0;
}
int32_t callbackFunction(uint16_t keyPressed)
{
switch (keyPressed)
{
case KEYCODE_P_MINUS:
{
channelDown();
break;
}
case KEYCODE_P_PLUS:
{
channelUp();
break;
}
case KEYCODE_V_PLUS:
{
volumeUp(VOLUME_STEP);
volume = getVolume();
drawVolume(volume/VOLUME_STEP);
break;
}
case KEYCODE_V_MINUS:
{
volumeDown(VOLUME_STEP);
volume = getVolume();
drawVolume(volume/VOLUME_STEP);
break;
}
case KEYCODE_MUTE:
{
muteVolume();
volume = getVolume();
drawVolume(volume/VOLUME_STEP);
break;
}
case KEYCODE_EXIT:
{
deinitHardware();
break;
}
case KEYCODE_INFO:
{
channelInfo = getChannelInfo();
copyValues(&channelInfo, &infoBarData);
drawInfoBar(infoBarData);
break;
}
default:
{
goToChannel(keyPressed - 1);
}
}
return 0;
}
int main(int argc, char *argv[])
{
if (argc == 2)
{
savePath(argv[1]);
}
else
{
printf("ERROR: Wrong number of arguments when calling this app.\n");
}
// Initialize.
initGraphic();
initHardware();
registerChannelCallback(channelChanged);
initRemote();
registerRemoteCallback(callbackFunction);
// Deinitialize.
deinitRemote();
deinitGraphic();
return 0;
}