School project.

Dependencies:   Timezone NTPClient BSP_DISCO_F746NG Grove_temperature

Committer:
tuxx0046
Date:
Thu Jan 14 14:07:01 2021 +0000
Revision:
9:fd1f07a4a0ff
Parent:
5:9a9cc43f3c2c
Child:
10:137cf2c92871
Added rotary functions.; Fixed some minor things and comments.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tuxx0046 3:02e7aac23ff9 1 /**
tuxx0046 9:fd1f07a4a0ff 2 @file setup_functions.h
tuxx0046 3:02e7aac23ff9 3 @brief Contains functions used for initial setup of the unit, specifically to set the building and room where unit installation is planned.
tuxx0046 3:02e7aac23ff9 4
tuxx0046 3:02e7aac23ff9 5 @author Tu Tri Huynh
tuxx0046 3:02e7aac23ff9 6 @date 1/13/2021
tuxx0046 3:02e7aac23ff9 7 */
tuxx0046 3:02e7aac23ff9 8
tuxx0046 3:02e7aac23ff9 9
tuxx0046 3:02e7aac23ff9 10 /**
tuxx0046 3:02e7aac23ff9 11 Declaration of the function (prototype) to allow other functions to call it
tuxx0046 3:02e7aac23ff9 12 @date 1/13/2021
tuxx0046 3:02e7aac23ff9 13 */
tuxx0046 3:02e7aac23ff9 14 void setup_set_room_and_building();
tuxx0046 3:02e7aac23ff9 15
tuxx0046 3:02e7aac23ff9 16 /**
tuxx0046 3:02e7aac23ff9 17 Prompt user for confirmation if happy with inputted information
tuxx0046 3:02e7aac23ff9 18 @date 1/13/2021
tuxx0046 3:02e7aac23ff9 19 */
tuxx0046 3:02e7aac23ff9 20 void setup_confirm()
tuxx0046 3:02e7aac23ff9 21 {
tuxx0046 3:02e7aac23ff9 22 char answer;
tuxx0046 5:9a9cc43f3c2c 23 printf("Type y for Yes, n to redo: ");
tuxx0046 3:02e7aac23ff9 24 scanf("%1s",&answer);
tuxx0046 3:02e7aac23ff9 25 if (answer == 'y' || answer == 'Y')
tuxx0046 3:02e7aac23ff9 26 {
tuxx0046 3:02e7aac23ff9 27 printf("Setup successfully completed.\n");
tuxx0046 3:02e7aac23ff9 28 }
tuxx0046 3:02e7aac23ff9 29 else
tuxx0046 3:02e7aac23ff9 30 {
tuxx0046 3:02e7aac23ff9 31 setup_set_room_and_building();
tuxx0046 3:02e7aac23ff9 32 }
tuxx0046 3:02e7aac23ff9 33 /*
tuxx0046 3:02e7aac23ff9 34 printf("setup_confirm function end\n");
tuxx0046 3:02e7aac23ff9 35 */
tuxx0046 3:02e7aac23ff9 36 }
tuxx0046 3:02e7aac23ff9 37
tuxx0046 3:02e7aac23ff9 38 /**
tuxx0046 3:02e7aac23ff9 39 Show inputted information, and call setup_confirm to ask for confirmation.
tuxx0046 3:02e7aac23ff9 40 @date 1/13/2021
tuxx0046 3:02e7aac23ff9 41 */
tuxx0046 3:02e7aac23ff9 42 void setup_show_settings()
tuxx0046 3:02e7aac23ff9 43 {
tuxx0046 3:02e7aac23ff9 44 printf("Is this correct?\n");
tuxx0046 5:9a9cc43f3c2c 45 printf("----------------------------\n");
tuxx0046 3:02e7aac23ff9 46 printf("Building: %s\n", building);
tuxx0046 3:02e7aac23ff9 47 printf("Room: %s\n", room);
tuxx0046 3:02e7aac23ff9 48 printf("----------------------------\n");
tuxx0046 3:02e7aac23ff9 49 setup_confirm();
tuxx0046 3:02e7aac23ff9 50 }
tuxx0046 3:02e7aac23ff9 51
tuxx0046 3:02e7aac23ff9 52 /**
tuxx0046 3:02e7aac23ff9 53 Function to set building and room. Will call setup_show_settings to show what has been inputted.
tuxx0046 3:02e7aac23ff9 54 @date 1/13/2021
tuxx0046 3:02e7aac23ff9 55 */
tuxx0046 3:02e7aac23ff9 56 void setup_set_room_and_building()
tuxx0046 3:02e7aac23ff9 57 {
tuxx0046 5:9a9cc43f3c2c 58 char temp;
tuxx0046 5:9a9cc43f3c2c 59
tuxx0046 5:9a9cc43f3c2c 60 /** 1/14/2021
tuxx0046 5:9a9cc43f3c2c 61 When using %s, string will be terminated when white space i found.
tuxx0046 5:9a9cc43f3c2c 62 Therefore, set it to read white spaces with %[^\n]
tuxx0046 5:9a9cc43f3c2c 63 Also, changed wording to reduce "please" sentences.*/
tuxx0046 5:9a9cc43f3c2c 64 /**
tuxx0046 3:02e7aac23ff9 65 printf("Please set the building (maximum 30 characters): ");
tuxx0046 3:02e7aac23ff9 66 scanf("%30s", building);
tuxx0046 3:02e7aac23ff9 67 printf("Please set the room (maximum 30 characters): ");
tuxx0046 5:9a9cc43f3c2c 68 scanf("%30s", room); */
tuxx0046 5:9a9cc43f3c2c 69 printf("Enter name of building (maximum 30 characters): ");
tuxx0046 5:9a9cc43f3c2c 70 scanf("%[^\n]", building);
tuxx0046 5:9a9cc43f3c2c 71 printf("Enter name of room (maximum 30 characters): ");
tuxx0046 5:9a9cc43f3c2c 72 /// temp statement to clear buffer
tuxx0046 5:9a9cc43f3c2c 73 scanf("%c", &temp);
tuxx0046 5:9a9cc43f3c2c 74 scanf("%[^\n]", room);
tuxx0046 5:9a9cc43f3c2c 75
tuxx0046 3:02e7aac23ff9 76 setup_show_settings();
tuxx0046 3:02e7aac23ff9 77 }
tuxx0046 3:02e7aac23ff9 78
tuxx0046 3:02e7aac23ff9 79 /**
tuxx0046 3:02e7aac23ff9 80 Function to run the initial setup process.
tuxx0046 3:02e7aac23ff9 81 @date 1/13/2021
tuxx0046 3:02e7aac23ff9 82 */
tuxx0046 3:02e7aac23ff9 83 void setup_run_setup()
tuxx0046 3:02e7aac23ff9 84 {
tuxx0046 3:02e7aac23ff9 85 printf("\n*********************************************************\n");
tuxx0046 3:02e7aac23ff9 86 printf("Welcome to the Light Control System initial setup process\n");
tuxx0046 3:02e7aac23ff9 87 printf("Please set the units' location...\n\n");
tuxx0046 3:02e7aac23ff9 88 setup_set_room_and_building();
tuxx0046 3:02e7aac23ff9 89 }