void draw_path(uint16_t length, coord_t path[]) { for (int i = 0; i < length-1; ++i) { //get coords int x1 = longitude_to_x(current_map_num, path[ i ].lon) - screen_map_x; int y1 = latitude_to_y( current_map_num, path[ i ].lat) - screen_map_y; int x2 = longitude_to_x(current_map_num, path[i+1].lon) - screen_map_x; int y2 = latitude_to_y( current_map_num, path[i+1].lat) - screen_map_y; //clipping //draw tft.drawLine(x1, y1, x2, y2, tft.Color565(255,0,0)); } }
void move_window(int32_t lon, int32_t lat) { // Shift the current window to have lon and lat in top left corner screen_map_x = longitude_to_x(current_map_num, lon); screen_map_y = latitude_to_y(current_map_num, lat); move_window_to(screen_map_x, screen_map_y); }
// Takes in coordinates of path vertices and length and draws path on lcd screen void draw_path(uint16_t length, coord_t path[]) { int32_t prev_x, prev_y, cur_x, cur_y; for(int i = 1; i < length ; i++){ // grab the previous coordinates prev_x = longitude_to_x(current_map_num, path[i-1].lon)-screen_map_x; prev_y = latitude_to_y(current_map_num, path[i-1].lat)-screen_map_y; // grab the current coordinates cur_x = longitude_to_x(current_map_num, path[i].lon)-screen_map_x; cur_y = latitude_to_y(current_map_num, path[i].lat)-screen_map_y; // Draw the segments on the map tft.drawLine(prev_x, prev_y, cur_x, cur_y, BLUE); } }
void draw_path() { uint16_t x1, y1, x2, y2; //initialize vars to hold path coordinates int path_len = *path_lenptr; //get path length from global pointer //for every waypoint, draw a line from the waypoint to the next waypoint //until the second last waypoint is reached for (int i = 0; i < path_len - 1; i++) { x1 = longitude_to_x(current_map_num, waypointsptr[i].lon); x2 = longitude_to_x(current_map_num, waypointsptr[i+1].lon); y1 = latitude_to_y(current_map_num, waypointsptr[i].lat); y2 = latitude_to_y(current_map_num, waypointsptr[i+1].lat); //convert map coordinates to screen coordinates x1 = x1 - screen_map_x; x2 = x2 - screen_map_x; y1 = y1 - screen_map_y; y2 = y2 - screen_map_y; //Draw tha line tft.drawLine(x1,y1,x2,y2, BLUE); } }
uint8_t is_coord_visible(coord_t point) { // figure out the x and y positions on the current map of the // given point uint16_t point_map_y = latitude_to_y(current_map_num, point.lat); uint16_t point_map_x = longitude_to_x(current_map_num, point.lon); uint8_t r = screen_map_x < point_map_x && point_map_x < screen_map_x + display_window_width && screen_map_y < point_map_y && point_map_y < screen_map_y + display_window_height; return r; }
uint8_t set_zoom() { // set the actual map number from the shared version // this should be atomic and thus can be done outside a critical section current_map_num = shared_new_map_num; // At this point all of the cursor and map information is invalidated // except for the cursor lat and long, which is the only thing that // survives zooming. So set the map cursor position on the new map to // roughly correspond to lat and lon position that was determined by the // previous map. cursor_map_x = longitude_to_x(current_map_num, cursor_lon); cursor_map_y = latitude_to_y(current_map_num, cursor_lat); return current_map_num; }