Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: utils.cpp
- Revision:
- 9:1b54bac6d9a7
- Parent:
- 8:f23601373e8b
- Child:
- 10:e63fe4080760
--- a/utils.cpp Wed Oct 02 22:25:12 2019 +0000 +++ b/utils.cpp Thu Oct 03 23:28:56 2019 +0000 @@ -1,4 +1,5 @@ #include "utils.h" +#include "log.h" bool b_UTILS_flag_button_ESC = false; bool b_UTILS_flag_button_SECTIONS = false; @@ -6,21 +7,26 @@ Timer t_utils_timerSinceStart; s_Section* s_UTILS_currentSection = NULL; -Serial rs_UTILS_pc(USBTX, USBRX); + Serial rs_UTILS_odroid(PC_10, PC_11,115200); InterruptIn b_UTILS_button(USER_BUTTON); InterruptIn b_UTILS_emergency_signal(PD_0); +int i,j; void it_pressed() { - rs_UTILS_pc.printf("t_utils_timerSinceStart.read_ms(): %ld\r\n", t_utils_timerSinceStart.read_ms()); + rs_LOG_pc.printf("t_utils_timerSinceStart.read_ms(): %ld\r\n", t_utils_timerSinceStart.read_ms()); if(t_utils_timerSinceStart.read_ms() > 500) { - t_utils_timerSinceStart.reset(); - rs_UTILS_pc.printf("Button pressed\r\n"); - b_UTILS_flag_button_SECTIONS = true; - b_UTILS_flag_button_ESC = true; - b_UTILS_flag_emergency_stop = false; + rs_LOG_pc.printf("Button pressed\r\n"); + if(b_LOG_READY) { + b_LOG_READY = false; + } else { + t_utils_timerSinceStart.reset(); + b_UTILS_flag_button_SECTIONS = true; + b_UTILS_flag_button_ESC = true; + b_UTILS_flag_emergency_stop = false; + } } return; } @@ -28,4 +34,23 @@ void it_emergency_signal_recieved() { b_UTILS_flag_emergency_stop = true; +} + +void bubbleSort(double arr[], int n) +{ + for (i = 0; i < n-1; i++) { + // Last i elements are already in place + for (j = 0; j < n-i-1; j++) { + if (arr[j] > arr[j+1]) { + swap(&arr[j], &arr[j+1]); + } + } } +} + +void swap(double *xp, double *yp) +{ + double temp = *xp; + *xp = *yp; + *yp = temp; +} \ No newline at end of file