-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalloc.h
62 lines (48 loc) · 2 KB
/
alloc.h
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
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
void setupArduino()
{
tft.begin(); // start the lcd library
tft.setRotation(1); // rotate the screen so that it looks better
drawIcon(vade_icon, 0, 0, vadeWidth, vadeHeight,4); // drawing the splash screen
Serial.begin(9600); // start the arduino serial library
Serial.println("ARDUINO LOADED!"); // print that the arduino loaded
IrReceiver.begin(irPin, ENABLE_LED_FEEDBACK); // start the ir library
//Setting up the pins to be used
pinMode(interruptPinM1,INPUT_PULLUP);
pinMode(interruptPinM2,INPUT_PULLUP);
pinMode(interruptPinM3,INPUT_PULLUP);
pinMode(interruptPinM4,INPUT_PULLUP);
//Setting up the interupt pins to be used
attachInterrupt(digitalPinToInterrupt(interruptPinM1), intPinToMode1, FALLING);
attachInterrupt(digitalPinToInterrupt(interruptPinM2), intPinToMode2, FALLING);
attachInterrupt(digitalPinToInterrupt(interruptPinM3), intPinToMode3, FALLING);
attachInterrupt(digitalPinToInterrupt(interruptPinM4), intPinToMode4, FALLING);
randomSeed(analogRead(0)); // seed the random number function
int padding = tft.textWidth("9", 2); // get the width of the text in pixels
tft.setTextPadding(padding); // fixes full screen redaws
tft.setTextFont(2); // makes the font larger
}
#elif defined(WIN32)
//dummy function so that I can have a cleaner main
void setupArduino(){}
#endif
/* A function which is used to do allocation for global vars */
void setupGame()
{
// allocate memory for the levels to be put into
levels = getMalloc(sizeof(struct level) * numLevels);
//random number generation seeded for windows
#if defined(WIN32)
time_t random_time_generator;
srand((unsigned) time(&random_time_generator));
#endif
}
/* A function that handles a part of memory managment */
void cleanupGame()
{
/* deallocate allocated memory */
free(errorString);
free(gameMap);
free(levels);
free(items);
}