School project.

Dependencies:   Timezone NTPClient BSP_DISCO_F746NG Grove_temperature

Committer:
tuxx0046
Date:
Wed Jan 13 10:26:45 2021 +0000
Revision:
0:ed4063a0a4d5
Child:
1:1ee11539cc43
Initial commit.; Currently working on initial setup process.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tuxx0046 0:ed4063a0a4d5 1 /*
tuxx0046 0:ed4063a0a4d5 2 @file main.cpp
tuxx0046 0:ed4063a0a4d5 3 @brief Light Control System to automatically dimmer or increase light levels depending on registered light intensity.
tuxx0046 0:ed4063a0a4d5 4
tuxx0046 0:ed4063a0a4d5 5 @author Tu Tri Huynh
tuxx0046 0:ed4063a0a4d5 6
tuxx0046 0:ed4063a0a4d5 7 @date 1/13/2021
tuxx0046 0:ed4063a0a4d5 8 */
tuxx0046 0:ed4063a0a4d5 9
tuxx0046 0:ed4063a0a4d5 10 #include "mbed.h"
tuxx0046 0:ed4063a0a4d5 11
tuxx0046 0:ed4063a0a4d5 12
tuxx0046 0:ed4063a0a4d5 13 char building[31];
tuxx0046 0:ed4063a0a4d5 14 char room[31];
tuxx0046 0:ed4063a0a4d5 15 //bool is_set = false;
tuxx0046 0:ed4063a0a4d5 16
tuxx0046 0:ed4063a0a4d5 17 void setup_set_room_and_building();
tuxx0046 0:ed4063a0a4d5 18
tuxx0046 0:ed4063a0a4d5 19 void setup_confirm()
tuxx0046 0:ed4063a0a4d5 20 {
tuxx0046 0:ed4063a0a4d5 21 char answer;
tuxx0046 0:ed4063a0a4d5 22 printf("Type y for Yes, n for no: ");
tuxx0046 0:ed4063a0a4d5 23 scanf("%1s",&answer);
tuxx0046 0:ed4063a0a4d5 24 if (answer == 'y' || answer == 'Y')
tuxx0046 0:ed4063a0a4d5 25 {
tuxx0046 0:ed4063a0a4d5 26 //is_set = true;
tuxx0046 0:ed4063a0a4d5 27 printf("Setup successfully completed.\n");
tuxx0046 0:ed4063a0a4d5 28 }
tuxx0046 0:ed4063a0a4d5 29 else
tuxx0046 0:ed4063a0a4d5 30 {
tuxx0046 0:ed4063a0a4d5 31 setup_set_room_and_building();
tuxx0046 0:ed4063a0a4d5 32 }
tuxx0046 0:ed4063a0a4d5 33 printf("setup_confirm function end\n");
tuxx0046 0:ed4063a0a4d5 34 }
tuxx0046 0:ed4063a0a4d5 35
tuxx0046 0:ed4063a0a4d5 36 void setup_show_settings()
tuxx0046 0:ed4063a0a4d5 37 {
tuxx0046 0:ed4063a0a4d5 38 printf("Is this correct?\n");
tuxx0046 0:ed4063a0a4d5 39 printf("Building: %s\n", building);
tuxx0046 0:ed4063a0a4d5 40 printf("Room: %s\n", room);
tuxx0046 0:ed4063a0a4d5 41 setup_confirm();
tuxx0046 0:ed4063a0a4d5 42 }
tuxx0046 0:ed4063a0a4d5 43
tuxx0046 0:ed4063a0a4d5 44 void setup_set_room_and_building()
tuxx0046 0:ed4063a0a4d5 45 {
tuxx0046 0:ed4063a0a4d5 46 printf("Please set the building (maximum 30 characters): ");
tuxx0046 0:ed4063a0a4d5 47 scanf("%30s", building);
tuxx0046 0:ed4063a0a4d5 48 printf("Please set the room (maximum 30 characters): ");
tuxx0046 0:ed4063a0a4d5 49 scanf("%30s", room);
tuxx0046 0:ed4063a0a4d5 50 setup_show_settings();
tuxx0046 0:ed4063a0a4d5 51 }
tuxx0046 0:ed4063a0a4d5 52
tuxx0046 0:ed4063a0a4d5 53 void setup_run_setup()
tuxx0046 0:ed4063a0a4d5 54 {
tuxx0046 0:ed4063a0a4d5 55 printf("Welcome to the Light Control System initial setup process\n");
tuxx0046 0:ed4063a0a4d5 56 printf("Please set the units' location...\n\n");
tuxx0046 0:ed4063a0a4d5 57 setup_set_room_and_building();
tuxx0046 0:ed4063a0a4d5 58 }
tuxx0046 0:ed4063a0a4d5 59
tuxx0046 0:ed4063a0a4d5 60 int main(){
tuxx0046 0:ed4063a0a4d5 61 /*
tuxx0046 0:ed4063a0a4d5 62 printf("Mbed OS version: %d,%d,%d\n\n",MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION);
tuxx0046 0:ed4063a0a4d5 63 */
tuxx0046 0:ed4063a0a4d5 64
tuxx0046 0:ed4063a0a4d5 65 setup_run_setup();
tuxx0046 0:ed4063a0a4d5 66 printf("Setup done.");
tuxx0046 0:ed4063a0a4d5 67 }