A simple reminder program that can store up to 5 reminders, and has the ability to navigate between different pages through different functions.

Dependencies:   Hexi_KW40Z Hexi_OLED_SSD1351 PWM_Tone_Library

Committer:
fusop
Date:
Wed Apr 19 14:57:15 2017 +0000
Revision:
0:63db1c7ee975
Final Version of the Reminder Program;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
fusop 0:63db1c7ee975 1
fusop 0:63db1c7ee975 2 //------------------------------------------------------------------------------
fusop 0:63db1c7ee975 3 // MAIN PROGRAM
fusop 0:63db1c7ee975 4 //------------------------------------------------------------------------------
fusop 0:63db1c7ee975 5 //Main program controls the navigation of menus
fusop 0:63db1c7ee975 6 //------------------------------------------------------------------------------
fusop 0:63db1c7ee975 7
fusop 0:63db1c7ee975 8 int main (void)
fusop 0:63db1c7ee975 9 {
fusop 0:63db1c7ee975 10 //Miscellanous Variables used for this function
fusop 0:63db1c7ee975 11 int n;
fusop 0:63db1c7ee975 12
fusop 0:63db1c7ee975 13 //--------------------------------------------------------------------------
fusop 0:63db1c7ee975 14 // INITIALIZATIONS
fusop 0:63db1c7ee975 15 //--------------------------------------------------------------------------
fusop 0:63db1c7ee975 16
fusop 0:63db1c7ee975 17 //Attach Buttons Callback Functions
fusop 0:63db1c7ee975 18 B_attach();
fusop 0:63db1c7ee975 19
fusop 0:63db1c7ee975 20 //Text Formatting in OLED
fusop 0:63db1c7ee975 21 oled.GetTextProperties(&tProp);
fusop 0:63db1c7ee975 22 oled.DimScreenOFF();
fusop 0:63db1c7ee975 23 oled.FillScreen(COLOR_BLACK);
fusop 0:63db1c7ee975 24 tProp.fontColor = COLOR_WHITE;
fusop 0:63db1c7ee975 25 tProp.alignParam = OLED_TEXT_ALIGN_CENTER;
fusop 0:63db1c7ee975 26 oled.SetTextProperties(&tProp);
fusop 0:63db1c7ee975 27
fusop 0:63db1c7ee975 28 //Flush all the reminder data for now.
fusop 0:63db1c7ee975 29 for (n = 0; n < 5; n++)
fusop 0:63db1c7ee975 30 {
fusop 0:63db1c7ee975 31 remData[n].rExist = 0;
fusop 0:63db1c7ee975 32 remData[n].rMins = 0;
fusop 0:63db1c7ee975 33 remData[n].rHours = 0;
fusop 0:63db1c7ee975 34 }
fusop 0:63db1c7ee975 35
fusop 0:63db1c7ee975 36 //Initializations of Strings
fusop 0:63db1c7ee975 37 TextInit();
fusop 0:63db1c7ee975 38
fusop 0:63db1c7ee975 39 //INTERRUPT STARTS HERE
fusop 0:63db1c7ee975 40 masa.start(1); //In miliseconds
fusop 0:63db1c7ee975 41
fusop 0:63db1c7ee975 42
fusop 0:63db1c7ee975 43 //--------------------------------------------------------------------------
fusop 0:63db1c7ee975 44 // MENU SELECTION
fusop 0:63db1c7ee975 45 //--------------------------------------------------------------------------
fusop 0:63db1c7ee975 46
fusop 0:63db1c7ee975 47 TimeSetup();
fusop 0:63db1c7ee975 48 oled.FillScreen(COLOR_BLACK);
fusop 0:63db1c7ee975 49
fusop 0:63db1c7ee975 50 TimeDisplay(); //Just display time for now
fusop 0:63db1c7ee975 51 MainDisp(); //Setup the home screen for the first time
fusop 0:63db1c7ee975 52
fusop 0:63db1c7ee975 53 ReminderList(); //Setup the data list display for the first time
fusop 0:63db1c7ee975 54
fusop 0:63db1c7ee975 55 //Program Loop in here
fusop 0:63db1c7ee975 56 while(1)
fusop 0:63db1c7ee975 57 {
fusop 0:63db1c7ee975 58 //Go into AddReminder() if the user enters Right
fusop 0:63db1c7ee975 59 if (butflg == 1)
fusop 0:63db1c7ee975 60 {
fusop 0:63db1c7ee975 61 if (butmem == BUT_RIGHT) AddReminder();
fusop 0:63db1c7ee975 62 else if (butmem == BUT_LEFT) DelReminder();
fusop 0:63db1c7ee975 63
fusop 0:63db1c7ee975 64 //At the end of either functions, reset the screen to home screen, with first available
fusop 0:63db1c7ee975 65 //data to display
fusop 0:63db1c7ee975 66 if (fReCalc == 1 || fAlarm == 2)
fusop 0:63db1c7ee975 67 {
fusop 0:63db1c7ee975 68 for (nDisp = 0; nDisp < 5; nDisp++)
fusop 0:63db1c7ee975 69 {
fusop 0:63db1c7ee975 70 if (remData[nDisp].rExist == 1) break;
fusop 0:63db1c7ee975 71 }
fusop 0:63db1c7ee975 72 fReCalc = 0; //This solved the mystery
fusop 0:63db1c7ee975 73 }
fusop 0:63db1c7ee975 74
fusop 0:63db1c7ee975 75 //Update the list in the display
fusop 0:63db1c7ee975 76 ReminderList();
fusop 0:63db1c7ee975 77
fusop 0:63db1c7ee975 78 //Prevent loop reentry
fusop 0:63db1c7ee975 79 butflg = 0;
fusop 0:63db1c7ee975 80 }
fusop 0:63db1c7ee975 81 }
fusop 0:63db1c7ee975 82 }