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
6Other_Functions.h
- Committer:
- fusop
- Date:
- 2017-04-19
- Revision:
- 0:63db1c7ee975
File content as of revision 0:63db1c7ee975:
//------------------------------------------------------------------------------ // SUPPLEMENTARY FUNCTION DEFINITIONS //------------------------------------------------------------------------------ int CharInput (int y, int rNum) { //Planned events: //1. Wake Up //2. Close Oven //3. Do laundry //4. OP Garage //5. Meeting //6. Call Mom int txtPt = 0; //Short for Text Pointer int f = 1; //Annoying temp variable for while loop control //Setup the first text to appear oled.Label((uint8_t *) remTxt[txtPt], 0, y); //Clear button memories butmem = 0; //In the condition, alternatively, (butmem != BUT_LEFT & butmem != BUT_RIGHT) //Basically, as long as left and right is not pressed, keep looping. while (f == 1) { if (butflg == 1) { if (butmem == BUT_UP && txtPt != 5) txtPt++; else if (butmem == BUT_DOWN && txtPt != 0) txtPt--; //To exit this loop if (butmem == BUT_LEFT || butmem == BUT_RIGHT) f = 0; //The screen will only be updated for every keypress oled.DrawBox(0, y, 96, 96-y, COLOR_BLACK); oled.Label((uint8_t *) remTxt[txtPt], 0, y); butflg = 0; } } //After an input has been decided if (butmem == BUT_RIGHT) //Acknowledge input and add to database { strcpy(remData[rNum].rText, remTxt[txtPt]); return 1; } else return 0; //Cancel input and go back to home screen } void DelayProg (int del) { //A very sloppy delay program used in parallel with interrupt. //Using interrupt might be a little messy, so it's better to have delay //inside its own world. double delayCount = del*100000; while (delayCount != 0) delayCount--; } void TextInit (void) { strcpy(remTxt[0], "WakeUp"); strcpy(remTxt[1], "CloseOven"); strcpy(remTxt[2], "DoLaundry"); strcpy(remTxt[3], "OpenGarage"); strcpy(remTxt[4], "Meeting"); strcpy(remTxt[5], "CallMom"); } /* OLD CHARINPUT FUNCTION BECAUSE I DON'T WANT TO WASTE TIME ON SINGLE ALPHANUMERIC INPUT void CharInput (int y, int rNum) { //Assumptions for this function: //Text input always begins at the left //y variable is vertical position of the text //This function exits when exit character(ASCII 64 or @)is detected //ASCII is used for this operation char textIn = 65; //A variable to control character input int textPoint = 0; //Index position of string char prevChar = '0'; //Stuff while (prevChar != '@') { if (butflg == 1) { //Character change navigation if (butmem == BUT_UP && textIn != 95) textIn++; else if (butmem == BUT_DOWN && textIn != 64) textIn--; //Position change navigation else if (butmem == BUT_RIGHT && textPoint != 19) { prevChar = textIn; textPoint++; textIn = 65; } else if (butmem == BUT_LEFT && textPoint != 0) { prevChar = textIn; textPoint--; textIn = 65; } butmem = 0; butflg = 0; } remData[rNum].rText[textPoint] = textIn; oled.Label((uint8_t *) remData[rNum].rText, 0, y); } }*/