School project.
Dependencies: Timezone NTPClient BSP_DISCO_F746NG Grove_temperature
setup_functions.h@3:02e7aac23ff9, 2021-01-13 (annotated)
- Committer:
- tuxx0046
- Date:
- Wed Jan 13 12:11:54 2021 +0000
- Revision:
- 3:02e7aac23ff9
- Child:
- 5:9a9cc43f3c2c
Started working on basic LCD functionalities, using code from a previous project.; Changed some minor things in comments.; Renamed filename.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tuxx0046 | 3:02e7aac23ff9 | 1 | /** |
tuxx0046 | 3:02e7aac23ff9 | 2 | @file setup_unit.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 | |
tuxx0046 | 3:02e7aac23ff9 | 7 | @date 1/13/2021 |
tuxx0046 | 3:02e7aac23ff9 | 8 | */ |
tuxx0046 | 3:02e7aac23ff9 | 9 | |
tuxx0046 | 3:02e7aac23ff9 | 10 | |
tuxx0046 | 3:02e7aac23ff9 | 11 | /** |
tuxx0046 | 3:02e7aac23ff9 | 12 | Declaration of the function (prototype) to allow other functions to call it |
tuxx0046 | 3:02e7aac23ff9 | 13 | @date 1/13/2021 |
tuxx0046 | 3:02e7aac23ff9 | 14 | */ |
tuxx0046 | 3:02e7aac23ff9 | 15 | void setup_set_room_and_building(); |
tuxx0046 | 3:02e7aac23ff9 | 16 | |
tuxx0046 | 3:02e7aac23ff9 | 17 | /** |
tuxx0046 | 3:02e7aac23ff9 | 18 | Prompt user for confirmation if happy with inputted information |
tuxx0046 | 3:02e7aac23ff9 | 19 | @date 1/13/2021 |
tuxx0046 | 3:02e7aac23ff9 | 20 | */ |
tuxx0046 | 3:02e7aac23ff9 | 21 | void setup_confirm() |
tuxx0046 | 3:02e7aac23ff9 | 22 | { |
tuxx0046 | 3:02e7aac23ff9 | 23 | char answer; |
tuxx0046 | 3:02e7aac23ff9 | 24 | printf("Type y for Yes, n for no: "); |
tuxx0046 | 3:02e7aac23ff9 | 25 | scanf("%1s",&answer); |
tuxx0046 | 3:02e7aac23ff9 | 26 | if (answer == 'y' || answer == 'Y') |
tuxx0046 | 3:02e7aac23ff9 | 27 | { |
tuxx0046 | 3:02e7aac23ff9 | 28 | printf("Setup successfully completed.\n"); |
tuxx0046 | 3:02e7aac23ff9 | 29 | } |
tuxx0046 | 3:02e7aac23ff9 | 30 | else |
tuxx0046 | 3:02e7aac23ff9 | 31 | { |
tuxx0046 | 3:02e7aac23ff9 | 32 | setup_set_room_and_building(); |
tuxx0046 | 3:02e7aac23ff9 | 33 | } |
tuxx0046 | 3:02e7aac23ff9 | 34 | /* |
tuxx0046 | 3:02e7aac23ff9 | 35 | printf("setup_confirm function end\n"); |
tuxx0046 | 3:02e7aac23ff9 | 36 | */ |
tuxx0046 | 3:02e7aac23ff9 | 37 | } |
tuxx0046 | 3:02e7aac23ff9 | 38 | |
tuxx0046 | 3:02e7aac23ff9 | 39 | /** |
tuxx0046 | 3:02e7aac23ff9 | 40 | Show inputted information, and call setup_confirm to ask for confirmation. |
tuxx0046 | 3:02e7aac23ff9 | 41 | @date 1/13/2021 |
tuxx0046 | 3:02e7aac23ff9 | 42 | */ |
tuxx0046 | 3:02e7aac23ff9 | 43 | void setup_show_settings() |
tuxx0046 | 3:02e7aac23ff9 | 44 | { |
tuxx0046 | 3:02e7aac23ff9 | 45 | printf("Is this correct?\n"); |
tuxx0046 | 3:02e7aac23ff9 | 46 | printf("\n----------------------------\n"); |
tuxx0046 | 3:02e7aac23ff9 | 47 | printf("Building: %s\n", building); |
tuxx0046 | 3:02e7aac23ff9 | 48 | printf("Room: %s\n", room); |
tuxx0046 | 3:02e7aac23ff9 | 49 | printf("----------------------------\n"); |
tuxx0046 | 3:02e7aac23ff9 | 50 | setup_confirm(); |
tuxx0046 | 3:02e7aac23ff9 | 51 | } |
tuxx0046 | 3:02e7aac23ff9 | 52 | |
tuxx0046 | 3:02e7aac23ff9 | 53 | /** |
tuxx0046 | 3:02e7aac23ff9 | 54 | Function to set building and room. Will call setup_show_settings to show what has been inputted. |
tuxx0046 | 3:02e7aac23ff9 | 55 | @date 1/13/2021 |
tuxx0046 | 3:02e7aac23ff9 | 56 | */ |
tuxx0046 | 3:02e7aac23ff9 | 57 | void setup_set_room_and_building() |
tuxx0046 | 3:02e7aac23ff9 | 58 | { |
tuxx0046 | 3:02e7aac23ff9 | 59 | printf("Please set the building (maximum 30 characters): "); |
tuxx0046 | 3:02e7aac23ff9 | 60 | scanf("%30s", building); |
tuxx0046 | 3:02e7aac23ff9 | 61 | printf("Please set the room (maximum 30 characters): "); |
tuxx0046 | 3:02e7aac23ff9 | 62 | scanf("%30s", room); |
tuxx0046 | 3:02e7aac23ff9 | 63 | setup_show_settings(); |
tuxx0046 | 3:02e7aac23ff9 | 64 | } |
tuxx0046 | 3:02e7aac23ff9 | 65 | |
tuxx0046 | 3:02e7aac23ff9 | 66 | /** |
tuxx0046 | 3:02e7aac23ff9 | 67 | Function to run the initial setup process. |
tuxx0046 | 3:02e7aac23ff9 | 68 | @date 1/13/2021 |
tuxx0046 | 3:02e7aac23ff9 | 69 | */ |
tuxx0046 | 3:02e7aac23ff9 | 70 | void setup_run_setup() |
tuxx0046 | 3:02e7aac23ff9 | 71 | { |
tuxx0046 | 3:02e7aac23ff9 | 72 | printf("\n*********************************************************\n"); |
tuxx0046 | 3:02e7aac23ff9 | 73 | printf("Welcome to the Light Control System initial setup process\n"); |
tuxx0046 | 3:02e7aac23ff9 | 74 | printf("Please set the units' location...\n\n"); |
tuxx0046 | 3:02e7aac23ff9 | 75 | setup_set_room_and_building(); |
tuxx0046 | 3:02e7aac23ff9 | 76 | } |