void testlines(uint16_t color) { tft.fillScreen(ST7735_BLACK); for (int16_t x=0; x < tft.width(); x+=6) { tft.drawLine(0, 0, x, tft.height()-1, color); } for (int16_t y=0; y < tft.height(); y+=6) { tft.drawLine(0, 0, tft.width()-1, y, color); } tft.fillScreen(ST7735_BLACK); for (int16_t x=0; x < tft.width(); x+=6) { tft.drawLine(tft.width()-1, 0, x, tft.height()-1, color); } for (int16_t y=0; y < tft.height(); y+=6) { tft.drawLine(tft.width()-1, 0, 0, y, color); } tft.fillScreen(ST7735_BLACK); for (int16_t x=0; x < tft.width(); x+=6) { tft.drawLine(0, tft.height()-1, x, 0, color); } for (int16_t y=0; y < tft.height(); y+=6) { tft.drawLine(0, tft.height()-1, tft.width()-1, y, color); } tft.fillScreen(ST7735_BLACK); for (int16_t x=0; x < tft.width(); x+=6) { tft.drawLine(tft.width()-1, tft.height()-1, x, 0, color); } for (int16_t y=0; y < tft.height(); y+=6) { tft.drawLine(tft.width()-1, tft.height()-1, 0, y, color); } }
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)); } }
// 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); } }