├── .gitattributes ├── 3D Models ├── CLUE Tracker Enclosure - Standard Minimal.stl └── CLUE Tracker Enclosure - Ultra Minimal.stl ├── LICENSE └── code.py /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /3D Models/CLUE Tracker Enclosure - Standard Minimal.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdoscher/CLUE-Tracker/3dec4c5cd2c109b6252b3431cfb8a5375b0dfccf/3D Models/CLUE Tracker Enclosure - Standard Minimal.stl -------------------------------------------------------------------------------- /3D Models/CLUE Tracker Enclosure - Ultra Minimal.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdoscher/CLUE-Tracker/3dec4c5cd2c109b6252b3431cfb8a5375b0dfccf/3D Models/CLUE Tracker Enclosure - Ultra Minimal.stl -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Attribution-NonCommercial 3.0 United States 2 | 3 | License 4 | THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. 5 | 6 | BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS. 7 | 8 | 1. Definitions 9 | 10 | "Collective Work" means a work, such as a periodical issue, anthology or encyclopedia, in which the Work in its entirety in unmodified form, along with one or more other contributions, constituting separate and independent works in themselves, are assembled into a collective whole. A work that constitutes a Collective Work will not be considered a Derivative Work (as defined below) for the purposes of this License. 11 | "Derivative Work" means a work based upon the Work or upon the Work and other pre-existing works, such as a translation, musical arrangement, dramatization, fictionalization, motion picture version, sound recording, art reproduction, abridgment, condensation, or any other form in which the Work may be recast, transformed, or adapted, except that a work that constitutes a Collective Work will not be considered a Derivative Work for the purpose of this License. For the avoidance of doubt, where the Work is a musical composition or sound recording, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered a Derivative Work for the purpose of this License. 12 | "Licensor" means the individual, individuals, entity or entities that offers the Work under the terms of this License. 13 | "Original Author" means the individual, individuals, entity or entities who created the Work. 14 | "Work" means the copyrightable work of authorship offered under the terms of this License. 15 | "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation. 16 | 2. Fair Use Rights. Nothing in this license is intended to reduce, limit, or restrict any rights arising from fair use, first sale or other limitations on the exclusive rights of the copyright owner under copyright law or other applicable laws. 17 | 18 | 3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below: 19 | 20 | to reproduce the Work, to incorporate the Work into one or more Collective Works, and to reproduce the Work as incorporated in the Collective Works; 21 | to create and reproduce Derivative Works provided that any such Derivative Work, including any translation in any medium, takes reasonable steps to clearly label, demarcate or otherwise identify that changes were made to the original Work. For example, a translation could be marked "The original work was translated from English to Spanish," or a modification could indicate "The original work has been modified."; 22 | to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission the Work including as incorporated in Collective Works; 23 | to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission Derivative Works; 24 | The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. All rights not expressly granted by Licensor are hereby reserved, including but not limited to the rights set forth in Sections 4(d) and 4(e). 25 | 26 | 4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions: 27 | 28 | You may distribute, publicly display, publicly perform, or publicly digitally perform the Work only under the terms of this License, and You must include a copy of, or the Uniform Resource Identifier for, this License with every copy or phonorecord of the Work You distribute, publicly display, publicly perform, or publicly digitally perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of a recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties. When You distribute, publicly display, publicly perform, or publicly digitally perform the Work, You may not impose any technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collective Work, but this does not require the Collective Work apart from the Work itself to be made subject to the terms of this License. If You create a Collective Work, upon notice from any Licensor You must, to the extent practicable, remove from the Collective Work any credit as required by Section 4(c), as requested. If You create a Derivative Work, upon notice from any Licensor You must, to the extent practicable, remove from the Derivative Work any credit as required by Section 4(c), as requested. 29 | You may not exercise any of the rights granted to You in Section 3 above in any manner that is primarily intended for or directed toward commercial advantage or private monetary compensation. The exchange of the Work for other copyrighted works by means of digital file-sharing or otherwise shall not be considered to be intended for or directed toward commercial advantage or private monetary compensation, provided there is no payment of any monetary compensation in connection with the exchange of copyrighted works. 30 | If You distribute, publicly display, publicly perform, or publicly digitally perform the Work (as defined in Section 1 above) or any Derivative Works (as defined in Section 1 above) or Collective Works (as defined in Section 1 above), You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or (ii) if the Original Author and/or Licensor designate another party or parties (e.g. a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; the title of the Work if supplied; to the extent reasonably practicable, the Uniform Resource Identifier, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and, consistent with Section 3(b) in the case of a Derivative Work, a credit identifying the use of the Work in the Derivative Work (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). The credit required by this Section 4(c) may be implemented in any reasonable manner; provided, however, that in the case of a Derivative Work or Collective Work, at a minimum such credit will appear, if a credit for all contributing authors of the Derivative Work or Collective Work appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties. 31 | For the avoidance of doubt, where the Work is a musical composition: 32 | 33 | Performance Royalties Under Blanket Licenses. Licensor reserves the exclusive right to collect whether individually or, in the event that Licensor is a member of a performance rights society (e.g. ASCAP, BMI, SESAC), via that society, royalties for the public performance or public digital performance (e.g. webcast) of the Work if that performance is primarily intended for or directed toward commercial advantage or private monetary compensation. 34 | Mechanical Rights and Statutory Royalties. Licensor reserves the exclusive right to collect, whether individually or via a music rights agency or designated agent (e.g. Harry Fox Agency), royalties for any phonorecord You create from the Work ("cover version") and distribute, subject to the compulsory license created by 17 USC Section 115 of the US Copyright Act (or the equivalent in other jurisdictions), if Your distribution of such cover version is primarily intended for or directed toward commercial advantage or private monetary compensation. 35 | Webcasting Rights and Statutory Royalties. For the avoidance of doubt, where the Work is a sound recording, Licensor reserves the exclusive right to collect, whether individually or via a performance-rights society (e.g. SoundExchange), royalties for the public digital performance (e.g. webcast) of the Work, subject to the compulsory license created by 17 USC Section 114 of the US Copyright Act (or the equivalent in other jurisdictions), if Your public digital performance is primarily intended for or directed toward commercial advantage or private monetary compensation. 36 | 5. Representations, Warranties and Disclaimer 37 | 38 | UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND ONLY TO THE EXTENT OF ANY RIGHTS HELD IN THE LICENSED WORK BY THE LICENSOR. THE LICENSOR MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MARKETABILITY, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. 39 | 40 | 6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 41 | 42 | 7. Termination 43 | 44 | This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Derivative Works (as defined in Section 1 above) or Collective Works (as defined in Section 1 above) from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License. 45 | Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above. 46 | 8. Miscellaneous 47 | 48 | Each time You distribute or publicly digitally perform the Work (as defined in Section 1 above) or a Collective Work (as defined in Section 1 above), the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License. 49 | Each time You distribute or publicly digitally perform a Derivative Work, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License. 50 | If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. 51 | No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent. 52 | This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You. -------------------------------------------------------------------------------- /code.py: -------------------------------------------------------------------------------- 1 | # Back7.co CLUE Tracker 2 | # Based on code samples from Adafruit, check out more on the CLUE here: 3 | # This project has a series of simple menus and utilizes the following hardware/software: 4 | # - Adafruit CLUE board: https://www.adafruit.com/product/4500 5 | # - Adafruit Stemma GPS: https://www.adafruit.com/product/4415 6 | # - Adafruit Stemma cable: https://www.adafruit.com/product/4399 7 | # - Back7.co 3D printed cases: 8 | # - Original (Tinkercad): https://www.tinkercad.com/things/hPm5opFnrlx-clue-tracker-enclosures/edit 9 | # - Github: 10 | # More info can be found on the project here: 11 | # A big shout out to the learn.adafruit.com authors plus/including John Park, @danh and @foamyguy on the Adafruit Discord channel 12 | 13 | from adafruit_clue import clue 14 | import adafruit_lis3mdl 15 | import adafruit_gps 16 | import time 17 | import board 18 | import busio 19 | import math 20 | from math import sin, cos, sqrt, atan2, radians, degrees 21 | 22 | # Use this reference for i2c to use the shared object (thank you @danh on Adafruit Discord for help with this) 23 | i2c = board.I2C() 24 | gps = adafruit_gps.GPS_GtopI2C(i2c, debug=False) # Use I2C interface 25 | 26 | # Reading the magnetometer off the CLUE board 27 | sensor = adafruit_lis3mdl.LIS3MDL(i2c) 28 | 29 | #gps.send_command(b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0') 30 | # Turn on just minimum info (RMC only, location): 31 | #gps.send_command(b'PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0') 32 | # Turn off everything: 33 | #gps.send_command(b'PMTK314,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0') 34 | # Turn on everything (not all of it is parsed!) 35 | # We need this one if you are going to use the GPS stats menu, otherwise data is missing and we error out 36 | gps.send_command(b'PMTK314,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0') 37 | 38 | # Set update rate to once a two second (2hz) which is what we want, but it could go even slower. 39 | gps.send_command(b'PMTK220,2000') 40 | 41 | # Set our display font size- any smaller and it's really hard to read 42 | # Any bigger and we can't get all the info on the screen 43 | clue_display = clue.simple_text_display(text_scale=2, colors=(clue.WHITE,)) 44 | 45 | #***************************** 46 | # Important - here are our default GPS target coordinates 47 | # Future feature may be to add storage to change, but it makes updating the sketch harder. 48 | # More info on the possible future stuff here: https://learn.adafruit.com/circuitpython-essentials/circuitpython-storage 49 | target_lat = 33.11111 50 | target_lon = -110.22222 51 | 52 | # GPS timing stuff 53 | timestamp = time.monotonic() 54 | last_print = time.monotonic() 55 | 56 | # Sourced from the Adafruit compass sample 57 | # https://github.com/adafruit/Adafruit_CircuitPython_LIS3MDL/blob/master/examples/lis3mdl_compass.py 58 | def vector_2_degrees(x, y): 59 | angle = degrees(atan2(y, x)) 60 | if angle < 0: 61 | angle += 360 62 | return angle 63 | 64 | # Also from the Adafruit compass sample 65 | def get_heading(_sensor): 66 | magnet_x, magnet_y, _ = _sensor.magnetic 67 | return vector_2_degrees(magnet_x, magnet_y) 68 | 69 | # Awesome public domain compass bearing code from Jérôme Renard 70 | # https://gist.github.com/jeromer/2005586 71 | def calculate_initial_compass_bearing(pointA, pointB): 72 | """ 73 | Calculates the bearing between two points. 74 | The formulae used is the following: 75 | θ = atan2(sin(Δlong).cos(lat2), 76 | cos(lat1).sin(lat2) − sin(lat1).cos(lat2).cos(Δlong)) 77 | :Parameters: 78 | - `pointA: The tuple representing the latitude/longitude for the 79 | first point. Latitude and longitude must be in decimal degrees 80 | - `pointB: The tuple representing the latitude/longitude for the 81 | second point. Latitude and longitude must be in decimal degrees 82 | :Returns: 83 | The bearing in degrees 84 | :Returns Type: 85 | float 86 | """ 87 | if (type(pointA) != tuple) or (type(pointB) != tuple): 88 | raise TypeError("Only tuples are supported as arguments") 89 | 90 | lat1 = math.radians(pointA[0]) 91 | lat2 = math.radians(pointB[0]) 92 | 93 | diffLong = math.radians(pointB[1] - pointA[1]) 94 | 95 | x = math.sin(diffLong) * math.cos(lat2) 96 | y = math.cos(lat1) * math.sin(lat2) - (math.sin(lat1) 97 | * math.cos(lat2) * math.cos(diffLong)) 98 | 99 | initial_bearing = math.atan2(x, y) 100 | 101 | # Now we have the initial bearing but math.atan2 return values 102 | # from -180° to + 180° which is not what we want for a compass bearing 103 | # The solution is to normalize the initial bearing as shown below 104 | initial_bearing = math.degrees(initial_bearing) 105 | compass_bearing = (initial_bearing + 360) % 360 106 | 107 | return compass_bearing 108 | 109 | # Rough Calculation of distance (in meters) 110 | # https://janakiev.com/blog/gps-points-distance-python/ 111 | def haversine(coord1, coord2): 112 | R = 6372800 # Earth radius in meters 113 | lat1, lon1 = coord1 114 | lat2, lon2 = coord2 115 | 116 | phi1, phi2 = math.radians(lat1), math.radians(lat2) 117 | dphi = math.radians(lat2 - lat1) 118 | dlambda = math.radians(lon2 - lon1) 119 | 120 | a = math.sin(dphi/2)**2 + \ 121 | math.cos(phi1)*math.cos(phi2)*math.sin(dlambda/2)**2 122 | 123 | return 2*R*math.atan2(math.sqrt(a), math.sqrt(1 - a)) 124 | 125 | while True: 126 | # Here's our menu system for the Adafruit CLUE 127 | # Thanks to foamyguy on the Adafruit Discord server for helping me get the button click feature 128 | # Menus are all pretty simple- set them all up and turn them off as we go through them 129 | if clue.button_a: 130 | # Turn on all menus to true, then turn them off as we toggle through them 131 | latmenux1 = True 132 | latmenux001 = True 133 | lonmenux1 = True 134 | lonmenux001 = True 135 | gpsmenu_target = True 136 | gpsmenu_stats = True 137 | 138 | # Display just the basic target info 139 | while gpsmenu_target is True: 140 | clue_display[0].text = "--Target Coordinates--" 141 | clue_display[1].text = "" 142 | clue_display[2].text = "Lat: {:.5f}".format(target_lat) 143 | clue_display[3].text = "Lon: {:.5f}".format(target_lon) 144 | clue_display[4].text = "" 145 | clue_display[5].text = "" 146 | clue_display[6].text = "" 147 | clue_display[7].text = "" 148 | clue_display[8].text = "B=Next" 149 | clue_display.show() 150 | if clue.button_b: 151 | gpsmenu_target = False 152 | clue_display.show() 153 | 154 | # Parse and display several GPS stats 155 | while gpsmenu_stats is True: 156 | gps.update() 157 | current = time.monotonic() 158 | if current - last_print >= 1.0: 159 | last_print = current 160 | if not gps.has_fix: 161 | # Try again if we don't have a fix yet. 162 | clue_display[0].text = "Waiting for fix" 163 | continue 164 | # We have a fix! (gps.has_fix is true) 165 | # Print out details about the fix like location, date, etc. 166 | clue_display[0].text = "--GPS Info--" 167 | clue_display[1].text = "" 168 | clue_display[2].text = "Lat: {:.5f}".format(gps.latitude) 169 | clue_display[3].text = "Long: {:.5f}".format(gps.longitude) 170 | clue_display[4].text = "GPS Sat#: {:.5f}".format(gps.satellites) 171 | clue_display[5].text = "Altitude: {:.5f}".format(gps.altitude_m) 172 | clue_display[6].text = "Track Angle: {:.5f}".format(gps.track_angle_deg) 173 | clue_display[7].text = "{}/{}/{} {:02}:{:02}:{:02}".format( 174 | gps.timestamp_utc.tm_mon, # Grab parts of the time from the 175 | gps.timestamp_utc.tm_mday, # struct_time object that holds 176 | gps.timestamp_utc.tm_year, # the fix time. Note you might 177 | gps.timestamp_utc.tm_hour, # not get all data like year, day, 178 | gps.timestamp_utc.tm_min, # month! 179 | gps.timestamp_utc.tm_sec) 180 | clue_display[8].text = "B=Next" 181 | clue_display.show() 182 | if clue.button_b: 183 | gpsmenu_stats = False 184 | clue_display.show() 185 | 186 | # Change the target latitude by intigers of 1 187 | while latmenux1 is True: 188 | clue_display[0].text = "Set Target Lat." 189 | clue_display[1].text = "Temp-Lat: {:.5f}".format(target_lat) 190 | clue_display[2].text = "Temp-Lon: {:.5f}".format(target_lon) 191 | clue_display[3].text = " " 192 | clue_display[4].text = " " 193 | clue_display[5].text = " " 194 | clue_display[6].text = "0=+1" 195 | clue_display[7].text = "2=-1" 196 | clue_display[8].text = "B=Next" 197 | clue_display.show() 198 | if clue.touch_0: 199 | target_lat = target_lat - 1 200 | clue_display[1].text = "Temp-Lat: {:.5f}".format(target_lat) 201 | if clue.touch_2: 202 | target_lat = target_lat + 1 203 | clue_display[1].text = "Temp-Lat: {:.5f}".format(target_lat) 204 | if clue.button_b: 205 | latmenux1 = False 206 | clue_display.show() 207 | 208 | # Change the target latitude by increments of .001 209 | while latmenux001 is True: 210 | clue_display[0].text = "Set Target Lat." 211 | clue_display[1].text = "Temp-Lat: {:.5f}".format(target_lat) 212 | clue_display[2].text = "Temp-Lon: {:.5f}".format(target_lon) 213 | clue_display[3].text = " " 214 | clue_display[4].text = " " 215 | clue_display[5].text = " " 216 | clue_display[6].text = "0=+.001" 217 | clue_display[7].text = "2=-.001" 218 | clue_display[8].text = "B=Next" 219 | clue_display.show() 220 | if clue.touch_0: 221 | target_lat = target_lat - 0.001 222 | clue_display[1].text = "Temp-Lat: {:.5f}".format(target_lat) 223 | if clue.touch_2: 224 | target_lat = target_lat + 0.001 225 | clue_display[1].text = "Temp-Lat: {:.5f}".format(target_lat) 226 | if clue.button_b: 227 | latmenux001 = False 228 | clue_display.show() 229 | 230 | # Change the target longitude by intigers of 1 231 | while lonmenux1 is True: 232 | clue_display[0].text = "Set Target Lon." 233 | clue_display[1].text = "Temp-Lat: {:.5f}".format(target_lat) 234 | clue_display[2].text = "Temp-Lon: {:.5f}".format(target_lon) 235 | clue_display[3].text = " " 236 | clue_display[4].text = " " 237 | clue_display[5].text = " " 238 | clue_display[6].text = "0=+.001" 239 | clue_display[7].text = "2=-.001" 240 | clue_display[8].text = "B=Next" 241 | clue_display.show() 242 | if clue.touch_0: 243 | target_lon = target_lon - 1 244 | clue_display[2].text = "Temp-Lon: {:.5f}".format(target_lon) 245 | if clue.touch_2: 246 | target_lon = target_lon + 1 247 | clue_display[2].text = "Temp-Lon: {:.5f}".format(target_lon) 248 | if clue.button_b: 249 | lonmenux1 = False 250 | clue_display.show() 251 | 252 | # Change the target longitude by increments of .001 253 | while lonmenux001 is True: 254 | clue_display[0].text = "Set Target Lon." 255 | clue_display[1].text = "Temp-Lat: {:.5f}".format(target_lat) 256 | clue_display[2].text = "Temp-Lon: {:.5f}".format(target_lon) 257 | clue_display[3].text = " " 258 | clue_display[4].text = " " 259 | clue_display[5].text = " " 260 | clue_display[6].text = "0=+.001" 261 | clue_display[7].text = "2=-.001" 262 | clue_display[8].text = "B=Next" 263 | clue_display.show() 264 | if clue.touch_0: 265 | target_lon = target_lon - 0.001 266 | clue_display[2].text = "Temp-Lon: {:.5f}".format(target_lon) 267 | if clue.touch_2: 268 | target_lon = target_lon + 0.001 269 | clue_display[2].text = "Temp-Lon: {:.5f}".format(target_lon) 270 | if clue.button_b: 271 | lonmenux001 = False 272 | clue_display.show() 273 | else: 274 | # We need to make sure all the GPS sections are actively updating GPS otherwise info gets stale 275 | gps.update() 276 | current = time.monotonic() 277 | if current - last_print >= 1.0: 278 | last_print = current 279 | if not gps.has_fix: 280 | # Try again if we don't have a fix yet. 281 | clue_display[0].text = "Waiting for fix" 282 | continue 283 | # We have a fix! (gps.has_fix is true) 284 | # Our default navigation screen that shows current heading, distance to target, and heading to target 285 | clue_display[0].text = "--Navigation--" 286 | clue_display[1].text = "" 287 | current_pos = (gps.latitude, gps.longitude) 288 | target_pos = (target_lat, target_lon) 289 | clue_display[2].text = "Current Heading:" 290 | clue_display[3].text = " {:.2f} degrees".format(get_heading(sensor)) 291 | clue_display[4].text = "Target Heading:" 292 | clue_display[5].text = " {:.1f} deg".format(calculate_initial_compass_bearing(current_pos,target_pos)) 293 | clue_display[6].text = "Target Distance" 294 | clue_display[7].text = " {:.1f} meters".format(haversine(current_pos,target_pos)) 295 | clue_display[8].text = "A=Toggle Display" 296 | clue_display.show() --------------------------------------------------------------------------------