Utkarsh Original Code (Given in India)
Dependencies: mbed LoRaWAN-lib SX1276Lib
Revision 13:72e65a3fc561, committed 2019-01-15
- Comitter:
- amirchaudhary
- Date:
- Tue Jan 15 17:28:28 2019 +0000
- Parent:
- 12:c1cf0e717684
- Commit message:
- Utkarsh Original Code (Given in India)
Changed in this revision
app/main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/app/main.cpp Thu Jan 03 16:12:43 2019 +0000 +++ b/app/main.cpp Tue Jan 15 17:28:28 2019 +0000 @@ -148,13 +148,6 @@ AnalogIn LIGHT_2_PIN(A5); AnalogIn VCE_PIN(PB_1); -InterruptIn button1(USER_BUTTON); -volatile bool button1_pressed = false; // Used in the main loop -volatile bool button1_enabled = true; // Used for debouncing -Timeout button1_timeout; // Used for debouncing -int press_count; -Timeout buttonOptions_timeout; // Used for determining number of presses - unsigned int time_window = 5; // Default 3600 seconds in an hour unsigned long long_interval = 604800; // Default 31557600 seconds in a year unsigned int hb_interval = 3600; // Default 86400 seconds in a day @@ -337,20 +330,11 @@ } } -// Enables button when bouncing is over -void button1_enabled_cb(void) -{ - button1_enabled = true; -} - -// ISR handling button pressed event -void button1_onpressed_cb(void) -{ - if (button1_enabled) { // Disabled while the button is bouncing - button1_enabled = false; - button1_pressed = true; // To be read by the main loop - button1_timeout.attach(callback(button1_enabled_cb), 0.3); // Debounce time 300 ms - } +void flash_builtin() { + myled = 1; // turn the LED on (HIGH is the voltage level) + wait(2); // wait for a second + myled = 0; // turn the LED off by making the voltage LOW + wait(1); // wait for a second } // **************************** COMMUNICATION PACKET DEFINITION METHODS ******************************** // @@ -894,6 +878,9 @@ } void startTest(uint8_t *measurements) { + // Signal that test is running + flash_builtin(); + flash_builtin(); // Determine test length & measurement interval switch (MessageType) @@ -922,8 +909,6 @@ // Start test relayPin = 1; - AppLedStateOn = 1; - Led3StateChanged = true; } void endTest(uint8_t *measurements) { @@ -949,37 +934,6 @@ // End test relayPin = 0; - AppLedStateOn = 0; - Led3StateChanged = true; -} - -void button_options_handler(void) -{ - if (press_count >= 3) { - // Run long test - MessageType = MESSAGE_TYPE_LONG_TEST; - measurements = l_measurements; - - startTest(measurements); - - running_test = true; - test_start = current_time; - last_measurement = current_time; - } - if (press_count == 2) { - // Run short test - MessageType = MESSAGE_TYPE_SHORT_TEST; - measurements = s_measurements; - - startTest(measurements); - - running_test = true; - test_start = current_time; - last_measurement = current_time; - } - - // Reset count - press_count = 0; } @@ -1010,6 +964,11 @@ set_time(1514764800); relayPin = 0; + flash_builtin(); + flash_builtin(); + flash_builtin(); + flash_builtin(); + running_test = false; joining = true; received_downlink = false; @@ -1017,11 +976,6 @@ last_hb = start_time; last_measurement = start_time; - - //button1.mode(PullUp); // Activate pull-up - button1.fall(callback(button1_onpressed_cb)); // Attach ISR to handle button press event - AppLedStateOn = 0; - Led3StateChanged = true; while( 1 ) { @@ -1241,15 +1195,6 @@ // dl_handler(received_data); //} - //check if button is pressed - if (button1_pressed) { // Set when button is pressed - if (press_count == 0) { - buttonOptions_timeout.attach(callback(button_options_handler), 2); // Debounce time 300 ms - } - button1_pressed = false; - press_count++; - } - //check if it's time to run a test if (current_time >= next_stest || current_time >= next_ltest) { @@ -1294,3 +1239,4 @@ } } } +