diff options
| author | Maximilien Cuony <maximilien@theglu.org> | 2016-06-03 09:29:22 +0200 |
|---|---|---|
| committer | Maximilien Cuony <maximilien@theglu.org> | 2016-06-03 09:29:22 +0200 |
| commit | 64e3e0b76ebebe2cea949e27d49c149b2e876391 (patch) | |
| tree | d277c20c822a4073efe447057116e94771a98f6b /src/simulator | |
| parent | bbe4080e94308149b74dd9ccefddf95878eec5d0 (diff) | |
| download | glutte-o-matic-64e3e0b76ebebe2cea949e27d49c149b2e876391.tar.gz glutte-o-matic-64e3e0b76ebebe2cea949e27d49c149b2e876391.tar.bz2 glutte-o-matic-64e3e0b76ebebe2cea949e27d49c149b2e876391.zip | |
Travail de train GPS
Diffstat (limited to 'src/simulator')
| -rw-r--r-- | src/simulator/.gitignore | 1 | ||||
| -rw-r--r-- | src/simulator/src/Core/main.c | 51 | ||||
| -rw-r--r-- | src/simulator/src/Gui/gui.c | 50 | ||||
| -rw-r--r-- | src/simulator/vc.h | 4 |
4 files changed, 94 insertions, 12 deletions
diff --git a/src/simulator/.gitignore b/src/simulator/.gitignore index 02e1499..994218c 100644 --- a/src/simulator/.gitignore +++ b/src/simulator/.gitignore @@ -1 +1,2 @@ FreeRTOS-Sim +vc.h diff --git a/src/simulator/src/Core/main.c b/src/simulator/src/Core/main.c index a326dbf..85e6a81 100644 --- a/src/simulator/src/Core/main.c +++ b/src/simulator/src/Core/main.c @@ -31,6 +31,49 @@ static void thread_gui(void *arg) { main_gui(); } + +extern int gui_gps_send_frame; +extern int gui_gps_frames_valid; +extern char gui_gps_lat[64]; +extern int gui_gps_lat_hem; +extern char gui_gps_lon[64]; +extern int gui_gps_lon_hem; +extern int gui_gps_send_current_time; + +static void thread_gui_gps(void *arg) { + + while(1) { + vTaskDelay(1000 / portTICK_RATE_MS); + + if (gui_gps_send_frame) { + + char gps_frame_buffer[128]; + int gps_buffer_pointer = 0; + + strcpy(gps_frame_buffer + gps_buffer_pointer, "$GPRMC,"); + gps_buffer_pointer += 7; + + strcpy(gps_frame_buffer + gps_buffer_pointer, "225446,"); + gps_buffer_pointer += 7; + + if (gui_gps_frames_valid) { + gps_frame_buffer[gps_buffer_pointer] = 'A'; + } else { + gps_frame_buffer[gps_buffer_pointer] = 'V'; + } + gps_buffer_pointer++; + gps_frame_buffer[gps_buffer_pointer] = ','; + gps_buffer_pointer++; + + + gps_frame_buffer[gps_buffer_pointer] = '\0'; + printf("%s\n", gps_frame_buffer); + + } + + } +} + void init() { /* pthread_t pth; */ @@ -45,4 +88,12 @@ void init() { tskIDLE_PRIORITY + 2UL, &task_handle); + xTaskCreate( + thread_gui_gps, + "Thread GUI GPS", + configMINIMAL_STACK_SIZE, + (void*) NULL, + tskIDLE_PRIORITY + 2UL, + &task_handle); + } diff --git a/src/simulator/src/Gui/gui.c b/src/simulator/src/Gui/gui.c index 81c80b6..72fa9ae 100644 --- a/src/simulator/src/Gui/gui.c +++ b/src/simulator/src/Gui/gui.c @@ -53,6 +53,21 @@ char led_green = 0; char led_orange = 0; char led_red = 0; +/** + * GPS + */ +int gui_gps_send_frame = 1; +int gui_gps_frames_valid = 1; +char gui_gps_lat[64] = "4719.59788"; +int gui_gps_lat_len = 10; +static const char *gps_NS[] = {"North", "South"}; +int gui_gps_lat_hem = 0; +char gui_gps_lon[64] = "00830.92084"; +int gui_gps_lon_len = 10; +static const char *gps_EW[] = {"East", "West"}; +int gui_gps_lon_hem = 0; +int gui_gps_send_current_time = 1; + struct XWindow { Display *dpy; Window win; @@ -162,8 +177,9 @@ int main_gui() { int sample_buffer, samples; glXGetFBConfigAttrib(win.dpy, fbc[i], GLX_SAMPLE_BUFFERS, &sample_buffer); glXGetFBConfigAttrib(win.dpy, fbc[i], GLX_SAMPLES, &samples); - if ((fb_best < 0) || (sample_buffer && samples > best_num_samples)) + if ((fb_best < 0) || (sample_buffer && samples > best_num_samples)) { fb_best = i; best_num_samples = samples; + } } } win.fbc = fbc[fb_best]; @@ -307,12 +323,8 @@ int main_gui() { if (l > 1) { nk_text(ctx, current_pointer - l, l, NK_TEXT_LEFT); } - - /* nk_layout_row_end(ctx); */ - - - nk_end(ctx); } + nk_end(ctx); if (nk_begin(ctx, &layout, "LEDs", nk_rect(460, 50, 100, 155), NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_MINIMIZABLE|NK_WINDOW_TITLE)) { @@ -321,7 +333,6 @@ int main_gui() { struct nk_color color; - nk_text(ctx, "", 0, NK_TEXT_LEFT); color.r = 255; color.g = 0; color.b = 0; @@ -368,9 +379,32 @@ int main_gui() { nk_text(ctx, "", 0, NK_TEXT_LEFT); - nk_end(ctx); + } + nk_end(ctx); + + if (nk_begin(ctx, &layout, "GPS", nk_rect(460, 210, 200, 455), NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_MINIMIZABLE|NK_WINDOW_TITLE)) { + + nk_layout_row_dynamic(ctx, 30, 1); + nk_checkbox_label(ctx, "Send frames", &gui_gps_send_frame); + nk_checkbox_label(ctx, "Valid frames", &gui_gps_frames_valid); + + nk_layout_row_dynamic(ctx, 30, 2); + + nk_label(ctx, "Latitude:", NK_TEXT_LEFT); + nk_edit_string(ctx, NK_EDIT_SIMPLE, gui_gps_lat, &gui_gps_lat_len, 64, nk_filter_float); + nk_label(ctx, "", NK_TEXT_LEFT); + gui_gps_lat_hem = nk_combo(ctx, gps_NS, LEN(gps_NS), gui_gps_lat_hem, 30); + + nk_label(ctx, "Longitude:", NK_TEXT_LEFT); + nk_edit_string(ctx, NK_EDIT_SIMPLE, gui_gps_lon, &gui_gps_lon_len, 64, nk_filter_float); + nk_label(ctx, "", NK_TEXT_LEFT); + gui_gps_lon_hem = nk_combo(ctx, gps_EW, LEN(gps_EW), gui_gps_lon_hem, 30); + + nk_layout_row_dynamic(ctx, 30, 1); + nk_checkbox_label(ctx, "Send current time", &gui_gps_send_current_time); } + nk_end(ctx); } diff --git a/src/simulator/vc.h b/src/simulator/vc.h deleted file mode 100644 index fa3f184..0000000 --- a/src/simulator/vc.h +++ /dev/null @@ -1,4 +0,0 @@ -// This file is generated by Makefile. -// Do not edit this file! -#define GIT_VERSION "9069fc1" - |
