finished p2-2

Dependencies:   mbed wave_player 4DGL-uLCD-SE MMA8452

Committer:
levelsnake3
Date:
Sat Apr 17 02:34:03 2021 +0000
Revision:
1:05e3f86df6d5
Parent:
0:95264f964374
Child:
2:7abebe259d59
finished;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DCchico 0:95264f964374 1 //=================================================================
DCchico 0:95264f964374 2 // The header file for general settings for the project
DCchico 0:95264f964374 3 //
DCchico 0:95264f964374 4 // Copyright 2020 Georgia Tech. All rights reserved.
DCchico 0:95264f964374 5 // The materials provided by the instructor in this course are for
DCchico 0:95264f964374 6 // the use of the students currently enrolled in the course.
DCchico 0:95264f964374 7 // Copyrighted course materials may not be further disseminated.
DCchico 0:95264f964374 8 // This file must not be made publicly available anywhere.
DCchico 0:95264f964374 9 //=================================================================
DCchico 0:95264f964374 10
DCchico 0:95264f964374 11 #ifndef GLOBAL_H
DCchico 0:95264f964374 12 #define GLOBAL_H
DCchico 0:95264f964374 13 #include "mbed.h"
DCchico 0:95264f964374 14 #include "wave_player.h"
DCchico 0:95264f964374 15 #include "uLCD_4DGL.h"
DCchico 0:95264f964374 16 #include "MMA8452.h"
DCchico 0:95264f964374 17 #include <math.h>
DCchico 0:95264f964374 18
DCchico 0:95264f964374 19 // === [global object] ===
DCchico 0:95264f964374 20 extern uLCD_4DGL uLCD;
DCchico 0:95264f964374 21 extern Serial pc; // USB Console output
DCchico 0:95264f964374 22 extern wave_player waver;
DCchico 0:95264f964374 23 extern PwmOut speaker;
DCchico 0:95264f964374 24
DCchico 0:95264f964374 25 typedef struct {
DCchico 0:95264f964374 26 int x;
DCchico 0:95264f964374 27 int y;
DCchico 0:95264f964374 28 } point;
DCchico 0:95264f964374 29 typedef struct {
levelsnake3 1:05e3f86df6d5 30 point bottomRight;
DCchico 0:95264f964374 31 point topLeft;
DCchico 0:95264f964374 32 } boundingBox;
DCchico 0:95264f964374 33
DCchico 0:95264f964374 34 // === [global settings] ===
DCchico 0:95264f964374 35 #define BACKGROUND_COLOR 0x000000 //black
DCchico 0:95264f964374 36
DCchico 0:95264f964374 37 // === [define the macro of error handle function] ===
DCchico 0:95264f964374 38 // when the condition (c) is not true, assert the program and show error code
DCchico 0:95264f964374 39 #define ASSERT_P(c,e) do { \
DCchico 0:95264f964374 40 if(!(c)){ \
DCchico 0:95264f964374 41 uLCD.printf("\nERROR:%d\n",e); \
DCchico 0:95264f964374 42 pc.printf("\nERROR:%d\n",e); \
DCchico 0:95264f964374 43 while(1); \
DCchico 0:95264f964374 44 } \
DCchico 0:95264f964374 45 } while (0)
DCchico 0:95264f964374 46
DCchico 0:95264f964374 47 // === [error code] ===
DCchico 0:95264f964374 48 #define ERROR_NONE 0 // All good in the hood
DCchico 0:95264f964374 49 #define ERROR_FRUIT_INDEX_GET_INFO -1 // make sure your code gives the valid index for fruit_get_info()
DCchico 0:95264f964374 50 #define ERROR_FRUIT_INDEX_UPDATE_STATUS -2 // make sure your code gives the valid index for fruit_update_status()
DCchico 0:95264f964374 51 #define ERROR_FRUIT_SPEED -3 // fruit speed has to be between 1 and 8
DCchico 0:95264f964374 52 #define ERROR_FRUIT_INTERVAL -4 // fruit interval has to be between 1 and 100
DCchico 0:95264f964374 53 // other fruit error code ...
DCchico 0:95264f964374 54 #define ERROR_COMPOST_NUMBER -11 // number of fruits is larger than MAX_NUM_COMPOST
DCchico 0:95264f964374 55 #define ERROR_COMPOST_INDEX_GET_INFO -12 // make sure your code gives the valid index for compost_get_info()
DCchico 0:95264f964374 56 // DLL
DCchico 0:95264f964374 57 #define ERROR_DLL_INSERT_HEAD -14 // inserting into doubly linked list at head failed
DCchico 0:95264f964374 58 #define ERROR_DLL_DELETE -15 // deleting node from doubly linked list failed
DCchico 0:95264f964374 59 // other anti-fruit error code ...
DCchico 0:95264f964374 60
DCchico 0:95264f964374 61 #endif //GLOBAL_H