Преглед на файлове

Initial commit for custom build server

willpiper преди 4 години
родител
ревизия
27341e0c8c
променени са 3 файла, в които са добавени 47 реда и са изтрити 131 реда
  1. 14 17
      app.py
  2. 4 10
      templates/generate.html
  3. 29 104
      templates/index.html

+ 14 - 17
app.py

@@ -87,27 +87,24 @@ def index():
 @app.route('/generate', methods=['GET', 'POST'])
 def generate():
     if request.method == 'POST':
-        # parse and sanitise the input
-        try:
-            # request.form['username']
-            lat = float(request.form['lat'])
-            lon = float(request.form['long'])
-            radius = int(request.form['radius'])
-            assert lat < 90
-            assert lon < 180
-            assert lat > -90
-            assert lon > -180
-            radius = clamp(radius, 1, 400)
-        except:
-            print("Bad data")
-            return render_template('generate.html', error="Error with input")
+        # request.form['username']
+        features = []
+        for i in range(1,8):
+            value = request.form["option" + str(i)]
+            features.append(value)
+            undefine = "undef " + value.split()[1]
+            features.insert(0,undefine)
+        extra_hwdef = '\n'.join(features)
+
+        print("running...")
+
+        file = open('extra_hwdef.dat',"w")
+        file.write(extra_hwdef)
+        file.close()
 
         # UUID for this terrain generation
         uuidkey = str(uuid.uuid1())
 
-        # Flag for if user wanted a tile outside +-60deg latitude
-        outsideLat = None
-
         # get a list of files required to cover area
         filelist = []
         done = set()

+ 4 - 10
templates/generate.html

@@ -1,21 +1,15 @@
 <!doctype html>
-<title>ArduPilot Terrain Generator</title>
-<h1>ArduPilot Terrain Generator</h1>
+<title>ArduPilot Custom Firmware Builder</title>
+<h1>ArduPilot Custom Firmware Builder</h1>
 
 {% if error %}
   <p>Error: {{ error }}!</p>
 {% else %}
-  <p>Terrain Generation complete. You can download from: <a href="{{ urlkey }}" download="terrain.zip">here</a>.</p>
-  <p>This should be unzipped to the autopilot's SD card, within in the "APM/terrain" folder.</p>
+  <p>Custom firmware build complete. You can download from: <a href="{{ urlkey }}" download="custom_build.zip">here</a>.</p>
+  <p>This should be unzipped to the autopilot's SD card.</p>
   <p>This download will be available for 24 hours.</p>
 {% endif %}
 
-{% if outsideLat %}
-  <p>Tiles outside of +60 to -60 latitude were requested, which are not covered by the terrain database. These tiles are not included in the generated zip file.</p>
-{% else %}
-<p></p>
-{% endif %}
-
 <br />
 
 <footer>{{uuidkey}}</footer>

+ 29 - 104
templates/index.html

@@ -1,119 +1,44 @@
 <!doctype html>
 
-<head>
-    <link rel="stylesheet" href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css"
-        integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ=="
-        crossorigin="" />
-    <!-- Make sure you put this AFTER Leaflet's CSS -->
-    <script src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js"
-        integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew=="
-        crossorigin=""></script>
-    <style type="text/css">
-        html,
-        body {
-            height: 100%;
-            margin: 0;
-            width: 100%
-        }
-
-        #wrapper {
-            min-height: 100%;
-        }
-
-        #mapid {
-            height: 100%;
-            width: 100%;
-        }
-
-        #menu {
-            position: absolute;
-            z-index: 2000;
-            width: 28%;
-            background-color: azure;
-            margin: 5px;
-            margin-top: 7%;
-            border-radius: 10px;
-            padding: 10px;
-        }
-
-        #radius {
-            width: 100%;
-        }
-    </style>
-</head>
-
 <body>
     <div id="menu">
-        <title>ArduPilot Terrain Generator</title>
-        <h1>ArduPilot Terrain Generator</h1>
+        <title>ArduPilot Custom Firmware Builder</title>
+        <h1>ArduPilot Custom Firmware Builder</h1>
 
-        <p>CUSTOM FIRMWARE BUILDER</p>
-
-        <p>Multiple generated files can be combined on the SD card.</p>
-
-        <p>Compatible with Ardupilot Plane 4.0.6+ and Copter 4.0.4+</p>
+        <p>Please select features to be included in the reduced firmware build.</p>
         
-        <p>To download entire continents of terrain data, see <a href=https://terrain.ardupilot.org/data/continents/>here<a>.</p>
+        <!--<p>To download entire continents of terrain data, see <a href=https://terrain.ardupilot.org/data/continents/>here<a>.</p>-->
 
-        <h2>Terrain Options</h2>
+        <h2>Available Features</h2>
         <form action="/generate" method="post">
-            <label for="lat">Centre Latitude:</label><br>
-            <input type="text" id="lat" name="lat" value="-35.363261" oninput="plotCircleCoords(true);"><br>
-            <label for="long">Centre Longitude:</label><br>
-            <input type="text" id="long" name="long" value="149.165230" oninput="plotCircleCoords(true);"><br>
-            <label id="radius-label" for="radius">Radius (km):</label><br>
-            <input type="range" id="radius" name="radius" value="100" min="1" max="400"
-                oninput="plotCircleCoords(false);"><br>
+            <input type="checkbox" name="option1" value="define HAL_NAVEKF2_AVAILABLE 1">
+            <input type="hidden" name="option1" value="define HAL_NAVEKF2_AVAILABLE 0"> EKF2
+            <br>
+            <input type="checkbox" name="option2" value="define HAL_NAVEKF3_AVAILABLE 1">
+            <input type="hidden" name="option2" value="define HAL_NAVEKF3_AVAILABLE 0"> EKF3
+            <br>
+            <input type="checkbox" name="option3" value="define HAL_WITH_DSP 1">
+            <input type="hidden" name="option3" value="define HAL_WITH_DSP 0"> HAL_DSP_ENABLED
             <br>
+            <input type="checkbox" name="option4" value="define HAL_SPRAYER_ENABLED 1">
+            <input type="hidden" name="option4" value="define HAL_SPRAYER_ENABLED 0"> HAL_SPRAYER_ENABLED
+            <br>
+            <input type="checkbox" name="option5" value="define HAL_PARACHUTE_ENABLED 1">
+            <input type="hidden" name="option5" value="define HAL_PARACHUTE_ENABLED 0"> HAL_PARACHUTE_ENABLED
+            <br>
+            <input type="checkbox" name="option6" value="define HAL_MOUNT_ENABLED 1">
+            <input type="hidden" name="option6" value="define HAL_MOUNT_ENABLED 0"> HAL_MOUNT_ENABLED
+            <br>
+            <input type="checkbox" name="option7" value="define HAL_HOTT_TELEM_ENABLED 1">
+            <input type="hidden" name="option7" value="define HAL_HOTT_TELEM_ENABLED 0"> HAL_HOTT_TELEM_ENABLED
+            <br>
+            <input type="checkbox" name="option8" value="define HAL_BATTMON_FUEL_ENABLE 1">
+            <input type="hidden" name="option8" value="define HAL_BATTMON_FUEL_ENABLE 0"> HAL_BATTMON_FUEL_ENABLE
+            <br><br>
             <input type="submit" value="Generate" method="post">
         </form>
     </div>
-    <div class="wrapper">
-        <div id="mapid" style="position: absolute;height: 100%;"></div>
-    </div>
 </body>
 <br />
-<script>
-    var circle;
-    var mymap = L.map('mapid').setView([51.505, -0.09], 5);
-    L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
-        attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
-    }).addTo(mymap);
-
-    mymap.on('click', function (e) {
-        document.getElementById("lat").value = Math.max(-60, Math.min(60, e.latlng.lat))
-        var longitude = e.latlng.lng
-        // leaflet allows infinite longitudes, this wraps it to [-180, 180]
-        while (longitude > 180) {
-            longitude -= 360
-        }
-        while (longitude < -180) {
-            longitude += 360
-        }
-        document.getElementById("long").value = longitude
-        plotCircleCoords(true)
-    });
-
-    function plotCircleCoords(center) {
-        if (circle !== undefined) {
-            circle.removeFrom(mymap)
-        }
-        var lat = document.getElementById("lat").value
-        var lon = document.getElementById("long").value
-        var distance = document.getElementById("radius").value;
-        document.getElementById("radius-label").innerText = "Radius (" + distance + " km):"
-        circle = circle = L.circle([lat, lon], {
-            color: 'red',
-            fillColor: '#f03',
-            fillOpacity: 0.5,
-            radius: distance * 1000
-        }).addTo(mymap);
-        if (center) {
-            mymap.setView([lat, lon])
-        }
-    }
-    plotCircleCoords(true)
-
 
-</script>
-<footer>Created by Stephen Dade, <a href=https://github.com/stephendade/terraingen>Source Code<a>.</footer>
+<footer>Created by Will Piper, <a href=https://github.com/willpiper24/terraingen>Source Code<a>.</footer>