> 8) # Split vtxFreq into two bytes to send
- partB = (vtxFreq & 0xFF)
- i2c.write_i2c_block_data(i2cAddr[x], 0x51, [partA, partB]) # Initialize arduino defaults and set vtx frequency
- time.sleep(0.250)
diff --git a/src/delta5server/static/python/loadTestData.py b/src/delta5server/static/python/loadTestData.py
deleted file mode 100644
index 4b926bf..0000000
--- a/src/delta5server/static/python/loadTestData.py
+++ /dev/null
@@ -1,63 +0,0 @@
-# Populates the 'vtx' database with test data
-
-import MySQLdb
-
-# Open database connection
-db = MySQLdb.connect("localhost","root","delta5fpv","vtx" )
-cursor = db.cursor()
-
-# Load 'currentLaps' table
-try:
- cursor.execute("DELETE FROM `currentLaps` WHERE 1")
- db.commit()
-except MySQLdb.Error as e:
- print e
- db.rollback()
-except MySQLdb.Warning as e:
- print e
-try:
- cursor.execute("INSERT INTO `currentLaps` (`pilot`, `lap`, `min`, `sec`, `milliSec`) VALUES (1,1,0,10,510)")
- cursor.execute("INSERT INTO `currentLaps` (`pilot`, `lap`, `min`, `sec`, `milliSec`) VALUES (2,1,0,8,510)")
- cursor.execute("INSERT INTO `currentLaps` (`pilot`, `lap`, `min`, `sec`, `milliSec`) VALUES (3,1,0,9,612)")
- cursor.execute("INSERT INTO `currentLaps` (`pilot`, `lap`, `min`, `sec`, `milliSec`) VALUES (1,2,0,10,5)")
- cursor.execute("INSERT INTO `currentLaps` (`pilot`, `lap`, `min`, `sec`, `milliSec`) VALUES (2,2,0,8,12)")
- cursor.execute("INSERT INTO `currentLaps` (`pilot`, `lap`, `min`, `sec`, `milliSec`) VALUES (3,2,0,9,754)")
- cursor.execute("INSERT INTO `currentLaps` (`pilot`, `lap`, `min`, `sec`, `milliSec`) VALUES (2,3,0,8,855)")
- cursor.execute("INSERT INTO `currentLaps` (`pilot`, `lap`, `min`, `sec`, `milliSec`) VALUES (3,3,0,9,44)")
- db.commit()
-except MySQLdb.Error as e:
- print e
- db.rollback()
-except MySQLdb.Warning as e:
- print e
-
-# Edit 'pilots' table with actual names
-# try:
-# cursor.execute("UPDATE `pilots` SET `callSign` = %s, `name` = %s WHERE `pilot` = %s",('howflyquad','Alex',1))
-# db.commit()
-# except MySQLdb.Error as e:
-# print e
-# db.rollback()
-# except MySQLdb.Warning as e:
-# print e
-
-# Add group 2 pilots
-# try:
-# cursor.execute("INSERT INTO `pilots` (`pilot`, `callSign`, `name`) VALUES (6,'group2-1','Group2 One')")
-# cursor.execute("INSERT INTO `pilots` (`pilot`, `callSign`, `name`) VALUES (7,'group2-2','Group2 Two')")
-# cursor.execute("INSERT INTO `pilots` (`pilot`, `callSign`, `name`) VALUES (8,'group2-3','Group2 Three')")
-# cursor.execute("INSERT INTO `pilots` (`pilot`, `callSign`, `name`) VALUES (9,'group2-4','Group2 Four')")
-# cursor.execute("INSERT INTO `pilots` (`pilot`, `callSign`, `name`) VALUES (10,'group2-5','Group2 Five')")
-# cursor.execute("INSERT INTO `groups` (`group`, `node`, `pilot`, `vtxChan`, `rssiTrigger`) VALUES (2,1,6,'E2 5685',0)")
-# cursor.execute("INSERT INTO `groups` (`group`, `node`, `pilot`, `vtxChan`, `rssiTrigger`) VALUES (2,2,7,'F2 5760',0)")
-# cursor.execute("INSERT INTO `groups` (`group`, `node`, `pilot`, `vtxChan`, `rssiTrigger`) VALUES (2,3,8,'F4 5800',0)")
-# cursor.execute("INSERT INTO `groups` (`group`, `node`, `pilot`, `vtxChan`, `rssiTrigger`) VALUES (2,4,9,'F7 5860',0)")
-# cursor.execute("INSERT INTO `groups` (`group`, `node`, `pilot`, `vtxChan`, `rssiTrigger`) VALUES (2,5,10,'E6 5905',0)")
-# db.commit()
-# except MySQLdb.Error as e:
-# print e
-# db.rollback()
-# except MySQLdb.Warning as e:
-# print e
-
-db.close() # disconnect from database
diff --git a/src/delta5server/static/python/resetGroups.py b/src/delta5server/static/python/resetGroups.py
deleted file mode 100644
index c11b83b..0000000
--- a/src/delta5server/static/python/resetGroups.py
+++ /dev/null
@@ -1,31 +0,0 @@
-# Populates the 'vtx' database with starting values, configures number of nodes from passed argument value
-
-import MySQLdb
-
-# Open database connection
-db = MySQLdb.connect("localhost","root","delta5fpv","vtx" )
-cursor = db.cursor()
-
-# Initialize 'groups' table -- This should be generated from the number of nodes passed in!!!
-try:
- cursor.execute("TRUNCATE TABLE `groups`")
- db.commit()
-except MySQLdb.Error as e:
- print e
- db.rollback()
-except MySQLdb.Warning as e:
- print e
-try:
- cursor.execute("INSERT INTO `groups` (`group`, `node`, `pilot`, `vtxChan`, `rssiTrigger`) VALUES (1,1,1,'E2 5685',0)")
- cursor.execute("INSERT INTO `groups` (`group`, `node`, `pilot`, `vtxChan`, `rssiTrigger`) VALUES (1,2,2,'F2 5760',0)")
- cursor.execute("INSERT INTO `groups` (`group`, `node`, `pilot`, `vtxChan`, `rssiTrigger`) VALUES (1,3,3,'F4 5800',0)")
- cursor.execute("INSERT INTO `groups` (`group`, `node`, `pilot`, `vtxChan`, `rssiTrigger`) VALUES (1,4,4,'F7 5860',0)")
- cursor.execute("INSERT INTO `groups` (`group`, `node`, `pilot`, `vtxChan`, `rssiTrigger`) VALUES (1,5,5,'E6 5905',0)")
- db.commit()
-except MySQLdb.Error as e:
- print e
- db.rollback()
-except MySQLdb.Warning as e:
- print e
-
-db.close() # disconnect from database
diff --git a/src/delta5server/static/python/resetPilots.py b/src/delta5server/static/python/resetPilots.py
deleted file mode 100644
index 0fdb7b2..0000000
--- a/src/delta5server/static/python/resetPilots.py
+++ /dev/null
@@ -1,32 +0,0 @@
-# Populates the 'vtx' database with starting values, configures number of nodes from passed argument value
-
-import MySQLdb
-
-# Open database connection
-db = MySQLdb.connect("localhost","root","delta5fpv","vtx" )
-cursor = db.cursor()
-
-# Initialize 'groups' table -- This should be generated from the number of nodes passed in!!!
-try:
- cursor.execute("TRUNCATE TABLE `pilots`")
- db.commit()
-except MySQLdb.Error as e:
- print e
- db.rollback()
-except MySQLdb.Warning as e:
- print e
-try:
- cursor.execute("INSERT INTO `pilots` (`pilot`, `callSign`, `name`) VALUES (0,'','')")
- cursor.execute("INSERT INTO `pilots` (`pilot`, `callSign`, `name`) VALUES (1,'pilot1','Pilot One')")
- cursor.execute("INSERT INTO `pilots` (`pilot`, `callSign`, `name`) VALUES (2,'pilot2','Pilot Two')")
- cursor.execute("INSERT INTO `pilots` (`pilot`, `callSign`, `name`) VALUES (3,'pilot3','Pilot Three')")
- cursor.execute("INSERT INTO `pilots` (`pilot`, `callSign`, `name`) VALUES (4,'pilot4','Pilot Four')")
- cursor.execute("INSERT INTO `pilots` (`pilot`, `callSign`, `name`) VALUES (5,'pilot5','Pilot Five')")
- db.commit()
-except MySQLdb.Error as e:
- print e
- db.rollback()
-except MySQLdb.Warning as e:
- print e
-
-db.close() # disconnect from database
diff --git a/src/delta5server/static/python/saveLaps.py b/src/delta5server/static/python/saveLaps.py
deleted file mode 100644
index b6aba97..0000000
--- a/src/delta5server/static/python/saveLaps.py
+++ /dev/null
@@ -1,63 +0,0 @@
-# Saves the currentLaps table to the savedRaces table, needs updates when groups are added
-
-import MySQLdb
-
-# Open database connection
-db = MySQLdb.connect("localhost","root","delta5fpv","vtx" )
-cursor = db.cursor()
-
-# Get the current group number
-try:
- cursor.execute("SELECT `group` FROM `config`")
- results = cursor.fetchone()
- currentGroup = results[0]
- print "current group:"
- print currentGroup
- db.commit()
-except MySQLdb.Error as e:
- print e
-except MySQLdb.Warning as e:
- print e
-
-# Find next race number
-try:
- cursor.execute("SELECT MAX(`race`) AS `maxRace` FROM `savedRaces` WHERE `group` = %s",(currentGroup))
- results = cursor.fetchone()
- maxRace = results[0]
- print "max race:"
- print maxRace
- if maxRace is None:
- nextRace = 1
- else:
- nextRace = maxRace + 1
- print "next race:"
- print nextRace
- db.commit()
-except MySQLdb.Error as e:
- print e
-except MySQLdb.Warning as e:
- print e
-
-# Move Data
-# `currentLaps` (`pilot`, `lap`, `min`, `sec`, `milliSec`)
-# `savedRaces` (`race`, `group`, `pilot`, `lap`, `min`, `sec`, `milliSec`)
-try:
- cursor.execute("INSERT INTO `savedRaces` (`pilot`, `lap`, `min`, `sec`, `milliSec`) SELECT * FROM `currentLaps`")
- db.commit()
-except MySQLdb.Error as e:
- print e
- db.rollback()
-except MySQLdb.Warning as e:
- print e
-
-# Update empty race and group fields
-try:
- cursor.execute("UPDATE `savedRaces` SET `race` = %s, `group` = %s WHERE IFNULL(`race`,0) = 0",(nextRace,currentGroup))
- db.commit()
-except MySQLdb.Error as e:
- print e
- db.rollback()
-except MySQLdb.Warning as e:
- print e
-
-db.close() # disconnect from database
diff --git a/src/delta5server/static/python/setGroup.py b/src/delta5server/static/python/setGroup.py
deleted file mode 100644
index bed9133..0000000
--- a/src/delta5server/static/python/setGroup.py
+++ /dev/null
@@ -1,29 +0,0 @@
-# Changes the current group from passed argument
-
-import MySQLdb
-import argparse
-import sys
-
-# Read in the new group number from passed argument
-try:
- parser = argparse.ArgumentParser()
- parser.add_argument("newGroup", help="new group to switch to", type=int)
- args = parser.parse_args()
-except:
- e = sys.exc_info()[0]
- print e
-
-# Open database connection
-db = MySQLdb.connect("localhost","root","delta5fpv","vtx" )
-cursor = db.cursor()
-
-# Update current group variable in database
-try:
- cursor.execute("UPDATE `config` SET `group` = %s",(args.newGroup))
- db.commit()
-except MySQLdb.Error as e:
- print e
-except MySQLdb.Warning as e:
- print e
-
-db.close() # disconnect from database
diff --git a/src/delta5server/static/python/setMinLapTime.py b/src/delta5server/static/python/setMinLapTime.py
deleted file mode 100644
index 6f89df4..0000000
--- a/src/delta5server/static/python/setMinLapTime.py
+++ /dev/null
@@ -1,29 +0,0 @@
-# Takes a min lap time number in seconds and writes to the database
-
-import MySQLdb
-import argparse
-import sys
-
-try:
- parser = argparse.ArgumentParser()
- parser.add_argument("minLapTime", help="min lap time.", type=int)
- args = parser.parse_args()
-except:
- e = sys.exc_info()[0]
- print e
-
-# Open database connection
-db = MySQLdb.connect("localhost","root","delta5fpv","vtx" )
-cursor = db.cursor()
-
-# Insert min lap time into the database
-try:
- cursor.execute("UPDATE `config` SET `minLapTime` = %s",(args.minLapTime))
- db.commit()
-except MySQLdb.Error as e:
- print e
- db.rollback()
-except MySQLdb.Warning as e:
- print e
-
-db.close() # disconnect from database
diff --git a/src/delta5server/static/python/setPilotCallSign.py b/src/delta5server/static/python/setPilotCallSign.py
deleted file mode 100644
index 9acfb13..0000000
--- a/src/delta5server/static/python/setPilotCallSign.py
+++ /dev/null
@@ -1,31 +0,0 @@
-# Takes an group number, node number, and vtx channel then writes to the database and node if needed
-
-import MySQLdb
-import argparse
-import sys
-
-# Read in arguments
-try:
- parser = argparse.ArgumentParser()
- parser.add_argument("pilot", help="pilot number", type=int)
- parser.add_argument("callSign", help="new call sign", type=str)
- args = parser.parse_args()
-except:
- e = sys.exc_info()[0]
- print e
-
-# Open database connection
-db = MySQLdb.connect("localhost","root","delta5fpv","vtx" )
-cursor = db.cursor()
-
-# Update pilot in database
-try:
- cursor.execute("UPDATE `pilots` SET `callSign` = %s WHERE `pilot` = %s",(args.callSign,args.pilot))
- db.commit()
-except MySQLdb.Error as e:
- print e
- db.rollback()
-except MySQLdb.Warning as e:
- print e
-
-db.close() # disconnect from database
diff --git a/src/delta5server/static/python/setPilotName.py b/src/delta5server/static/python/setPilotName.py
deleted file mode 100644
index 47e0450..0000000
--- a/src/delta5server/static/python/setPilotName.py
+++ /dev/null
@@ -1,31 +0,0 @@
-# Takes an group number, node number, and vtx channel then writes to the database and node if needed
-
-import MySQLdb
-import argparse
-import sys
-
-# Read in arguments
-try:
- parser = argparse.ArgumentParser()
- parser.add_argument("pilot", help="pilot number", type=int)
- parser.add_argument("name", help="new pilot name", type=str)
- args = parser.parse_args()
-except:
- e = sys.exc_info()[0]
- print e
-
-# Open database connection
-db = MySQLdb.connect("localhost","root","delta5fpv","vtx" )
-cursor = db.cursor()
-
-# Update pilot in database
-try:
- cursor.execute("UPDATE `pilots` SET `name` = %s WHERE `pilot` = %s",(args.name,args.pilot))
- db.commit()
-except MySQLdb.Error as e:
- print e
- db.rollback()
-except MySQLdb.Warning as e:
- print e
-
-db.close() # disconnect from database
diff --git a/src/delta5server/static/python/setPilotPosition.py b/src/delta5server/static/python/setPilotPosition.py
deleted file mode 100644
index 2ac5daa..0000000
--- a/src/delta5server/static/python/setPilotPosition.py
+++ /dev/null
@@ -1,32 +0,0 @@
-# Updates the pilot in a group
-
-import MySQLdb
-import argparse
-import sys
-
-# Read in arguments
-try:
- parser = argparse.ArgumentParser()
- parser.add_argument("group", help="group number", type=int)
- parser.add_argument("node", help="node number", type=int)
- parser.add_argument("pilot", help="pilot number", type=int)
- args = parser.parse_args()
-except:
- e = sys.exc_info()[0]
- print e
-
-# Open database connection
-db = MySQLdb.connect("localhost","root","delta5fpv","vtx" )
-cursor = db.cursor()
-
-# Update database channel only
-try:
- cursor.execute("UPDATE `groups` SET `pilot` = %s WHERE `group` = %s AND `node` = %s",(args.pilot,args.group,args.node))
- db.commit()
-except MySQLdb.Error as e:
- print e
- db.rollback()
-except MySQLdb.Warning as e:
- print e
-
-db.close() # disconnect from database
diff --git a/src/delta5server/static/python/setRssiTrigger.py b/src/delta5server/static/python/setRssiTrigger.py
deleted file mode 100644
index 6b9f28c..0000000
--- a/src/delta5server/static/python/setRssiTrigger.py
+++ /dev/null
@@ -1,68 +0,0 @@
-# Takes an group number, node number, and trigger value then writes to the database and node if needed
-
-import smbus
-import time
-import MySQLdb
-import argparse
-import sys
-
-# Read in arguments
-try:
- parser = argparse.ArgumentParser()
- parser.add_argument("group", help="group number", type=int)
- parser.add_argument("node", help="node number", type=int)
- parser.add_argument("rssiTrigger", help="rssi trigger", type=int)
- args = parser.parse_args()
-except:
- e = sys.exc_info()[0]
- print e
-
-# start i2c bus
-i2c = smbus.SMBus(1)
-
-# Open database connection
-db = MySQLdb.connect("localhost","root","delta5fpv","vtx" )
-cursor = db.cursor()
-
-# Get current group
-try:
- cursor.execute("SELECT `group` FROM `config`")
- result = cursor.fetchone() # Fetch all the rows in a list of lists
- currentGroup = result[0]
- print "Current group: %d" % (currentGroup)
-except MySQLdb.Error as e:
- print e
-except MySQLdb.Warning as e:
- print e
-
-# If the group to update is the same as the current group then update the arduino node
-if args.group == currentGroup:
- # Get the i2c address of the node
- try:
- cursor.execute("SELECT `i2cAddr` FROM `nodes` WHERE `node` = %s",(args.node))
- result = cursor.fetchone() # Fetch all the rows in a list of lists
- i2cAddr = result[0]
- print "i2cAddr: %d" % (i2cAddr)
- except MySQLdb.Error as e:
- print e
- except MySQLdb.Warning as e:
- print e
-
- # Update node rssi trigger value
- try:
- i2c.write_byte_data(i2cAddr, 0x53, args.rssiTrigger) # Arduino set rssi threshold
- time.sleep(0.250)
- except IOError as e:
- print e
-
-# Update database rssi trigger value
-try:
- cursor.execute("UPDATE `groups` SET `rssiTrigger` = %s WHERE `group` = %s AND `node` = %s",(args.rssiTrigger,args.group,args.node))
- db.commit()
-except MySQLdb.Error as e:
- print e
- db.rollback()
-except MySQLdb.Warning as e:
- print e
-
-db.close() # Disconnect from database
diff --git a/src/delta5server/static/python/setVtxChannel.py b/src/delta5server/static/python/setVtxChannel.py
deleted file mode 100644
index 9a6a70e..0000000
--- a/src/delta5server/static/python/setVtxChannel.py
+++ /dev/null
@@ -1,70 +0,0 @@
-# Takes an group number, node number, and vtx channel then writes to the database and node if needed
-
-import smbus
-import time
-import MySQLdb
-import argparse
-import sys
-
-# Read in arguments
-try:
- parser = argparse.ArgumentParser()
- parser.add_argument("group", help="group number", type=int)
- parser.add_argument("node", help="node number", type=int)
- parser.add_argument("vtxChan", help="vtx channel", type=str) # vtx channel and frequency as a string
- args = parser.parse_args()
-except:
- e = sys.exc_info()[0]
- print e
-
-# start i2c bus
-i2c = smbus.SMBus(1)
-
-# Open database connection
-db = MySQLdb.connect("localhost","root","delta5fpv","vtx" )
-cursor = db.cursor()
-
-# Get current group
-try:
- cursor.execute("SELECT `group` FROM `config`")
- result = cursor.fetchone() # Fetch all the rows in a list of lists
- currentGroup = result[0]
- print "Current group: %d" % (currentGroup)
-except MySQLdb.Error as e:
- print e
-except MySQLdb.Warning as e:
- print e
-
-# If the group to update is the same as the current group then update the arduino node
-if args.group == currentGroup:
- # Get the i2c address of the node
- try:
- cursor.execute("SELECT `i2cAddr` FROM `nodes` WHERE `node` = %s",(args.node))
- result = cursor.fetchone() # Fetch all the rows in a list of lists
- i2cAddr = result[0]
- print "i2cAddr: %d" % (i2cAddr)
- except MySQLdb.Error as e:
- print e
- except MySQLdb.Warning as e:
- print e
- # Update node channel
- try:
- vtxFrequency = int(args.vtxChan.split()[1]) # Splits on spaces and gets the mhz number
- partA = (vtxFrequency >> 8)
- partB = (vtxFrequency & 0xFF)
- i2c.write_i2c_block_data(i2cAddr, 0x56, [partA, partB]) # Set vtx frequency
- time.sleep(0.250)
- except IOError as e:
- print e
-
-# Update database channel
-try:
- cursor.execute("UPDATE `groups` SET `vtxChan` = %s WHERE `group` = %s AND `node` = %s",(args.vtxChan,args.group,args.node))
- db.commit()
-except MySQLdb.Error as e:
- print e
- db.rollback()
-except MySQLdb.Warning as e:
- print e
-
-db.close() # disconnect from database
diff --git a/src/delta5server/static/python/startRace.py b/src/delta5server/static/python/startRace.py
deleted file mode 100644
index 4fdbdb4..0000000
--- a/src/delta5server/static/python/startRace.py
+++ /dev/null
@@ -1,56 +0,0 @@
-# Resets variables on each node then sets race status to true
-
-import smbus
-import time
-import MySQLdb
-
-# Start i2c bus
-i2c = smbus.SMBus(1)
-
-# Open database connection
-db = MySQLdb.connect("localhost","root","delta5fpv","vtx" )
-cursor = db.cursor()
-
-# Get node i2cAddr info
-i2cAddr = []
-try:
- cursor.execute("SELECT * FROM `nodes`") # Update to remove * and just get i2cAddr
- numNodes = int(cursor.rowcount)
- print "numNodes: %d" % numNodes
- for x in range(0, numNodes):
- row = cursor.fetchone()
- print row
- i2cAddr.append(int(row[1]))
- print "i2cAddr: "
- print i2cAddr
-except MySQLdb.Error as e:
- print e
-except MySQLdb.Warning as e:
- print e
-
-# Reset all lapCount to 0
-try:
- cursor.execute("UPDATE `nodesMem` SET `lapCount` = 0")
- db.commit()
-except MySQLdb.Error as e:
- print e
- db.rollback()
-except MySQLdb.Warning as e:
- print e
-
-# Set raceStatus to true
-try:
- cursor.execute("UPDATE `status` SET `raceStatus` = 1")
- db.commit()
-except MySQLdb.Error as e:
- print e
- db.rollback()
-except MySQLdb.Warning as e:
- print e
-
-db.close() # disconnect from database
-
-# Set clean race start on arduinos, reset laps and raceStatus set true
-for x in range(0, numNodes): # loops for polling each node
- i2c.write_byte(i2cAddr[x], 0x52) # race reset, raceStatus to 1
- time.sleep(0.250)
diff --git a/src/delta5server/static/python/startSystem.py b/src/delta5server/static/python/startSystem.py
deleted file mode 100644
index 92c09ee..0000000
--- a/src/delta5server/static/python/startSystem.py
+++ /dev/null
@@ -1,255 +0,0 @@
-# Starts the main comms loop with the nodes, reads rssi and lap info from nodes, writes lap
-# info to DB on new lap
-
-import smbus
-import time
-import MySQLdb
-
-# Start i2c bus
-i2c = smbus.SMBus(1)
-
-# Open database connection
-db = MySQLdb.connect("localhost","root","delta5fpv","vtx" )
-cursor = db.cursor()
-
-# Get nodes info from database
-i2cAddr = [] # I2C slave address
-rssi = [] # Current rssi value
-lapCount = [] # Current lap count
-try:
- cursor.execute("SELECT `i2cAddr` FROM `nodes`")
- numNodes = int(cursor.rowcount) # Get the number of nodes in the system from the size of nodes table
- print "numNodes:"
- print numNodes
- results = cursor.fetchall() # Fetch all the rows in a list of lists
- for row in results:
- i2cAddr.append(int(row[0]))
- rssi.append(0) # Create array size to match number of nodes
- lapCount.append(0) # Create array size to match number of nodes
- print "i2cAddr:"
- print i2cAddr
- print "rssi:"
- print rssi
- print "lapCount:"
- print lapCount
-except MySQLdb.Error as e:
- print e
-except MySQLdb.Warning as e:
- print e
-
-# Set node lapCount and rssi to zero on system start to fill MEMORY only tables
-try:
- cursor.execute("DELETE FROM `nodesMem` WHERE 1")
- db.commit()
-except MySQLdb.Error as e:
- print e
- db.rollback()
-except MySQLdb.Warning as e:
- print e
-for x in range(0, numNodes):
- try:
- cursor.execute("INSERT INTO `nodesMem` (`node`, `rssi`, `lapCount`) VALUES (%s,0,0)",(x+1))
- db.commit()
- except MySQLdb.Error as e:
- print e
- db.rollback()
- except MySQLdb.Warning as e:
- print e
-
-# Get the current config: group, min lap time
-try:
- cursor.execute("SELECT `group`, `minLapTime` FROM `config`")
- result = cursor.fetchone()
- group = int(result[0])
- minLapTime = int(result[1])
- print "group:"
- print group
- print "minLapTime:"
- print minLapTime
-except MySQLdb.Error as e:
- print e
- db.rollback()
-except MySQLdb.Warning as e:
- print e
-
-# Get the current group info: pilot, channel, trigger
-pilot = []
-vtxChan = []
-rssiTrig = []
-try:
- cursor.execute("SELECT `pilot`, `vtxChan`, `rssiTrigger` FROM `groups` WHERE `group` = %s",(group))
- results = cursor.fetchall() # Fetch all the rows in a list of lists
- for row in results:
- pilot.append(int(row[0]))
- vtxChan.append(str(row[1]))
- rssiTrig.append(int(row[2]))
- print "pilot:"
- print pilot
- print "vtxChan:"
- print vtxChan
- print "rssiTrig:"
- print rssiTrig
-except MySQLdb.Error as e:
- print e
- db.rollback()
-except MySQLdb.Warning as e:
- print e
-
-# Re-initialize arduinos with current group and config
-for x in range(0, numNodes):
- vtxFreq = int(vtxChan[x].split()[1])
- partA = (vtxFreq >> 8) # Split vtxFreq into two bytes to send
- partB = (vtxFreq & 0xFF)
- i2c.write_i2c_block_data(i2cAddr[x], 0x51, [partA, partB]) # Initialize arduino defaults and set vtx frequency
- time.sleep(0.100)
- i2c.write_byte_data(i2cAddr[x], 0x53, rssiTrig[x]) # Arduino set rssi threshold
- time.sleep(0.100)
- i2c.write_byte_data(i2cAddr[x], 0x54, minLapTime) # Set min lap time in seconds
- time.sleep(0.100)
-
-# Initialize systemStatus at 1 to start while loop
-systemStatus = 1
-# Initialize raceStatus at 0 to wait for 'start race' button
-raceStatus = 0
-try:
- cursor.execute("DELETE FROM `status` WHERE 1")
- db.commit()
-except MySQLdb.Error as e:
- print e
- db.rollback()
-except MySQLdb.Warning as e:
- print e
-try:
- cursor.execute("INSERT INTO `status` (`systemStatus`, `raceStatus`) VALUES (1,0)")
- db.commit()
-except MySQLdb.Error as e:
- print e
- db.rollback()
-except MySQLdb.Warning as e:
- print e
-
-# Main while loop
-while systemStatus == 1:
- startTime = time.time()
- print " "
- print "Starting while loop."
-
- # Read systemStatus to know when to exit the loop
- # Read raceStatus from database to know when to check nodes for laps
- try:
- cursor.execute("SELECT `systemStatus`, `raceStatus` FROM `status`")
- results = cursor.fetchall() # Fetch all the rows in a list of lists
- for row in results:
- systemStatus = row[0]
- raceStatus = row[1]
- db.commit()
- except MySQLdb.Error as e:
- print e
- except MySQLdb.Warning as e:
- print e
-
- # Read lapCounts because website buttons can reset them to zero
- try:
- cursor.execute("SELECT `lapCount` FROM `nodesMem`")
- for x in range(0, numNodes):
- row = cursor.fetchone()
- lapCount[x] = int(row[0])
- except MySQLdb.Error as e:
- print e
- except MySQLdb.Warning as e:
- print e
- print " lapCount:"
- print lapCount
-
- # Loop for polling each node
- for x in range(0, numNodes):
- print "i2c address: %d" % (i2cAddr[x])
-
- # Node request: rssi
- try:
- i2cData = i2c.read_i2c_block_data(i2cAddr[x], 0x01, 2) # Arduino get rssi
- rssi[x] = 0 # Rebuild rssi from two bytes
- partA = i2cData[0]
- partB = i2cData[1]
- rssi[x] = partA
- rssi[x] = (rssi[x] << 8) | partB
- print " rssi: %d" % (rssi[x])
- except IOError as e:
- print e
- time.sleep(0.100) # i2c data read delay
-
- # Only check lap data if race started
- if raceStatus == 1:
- # Node request: lap count and time in ms
- try:
- i2cData = i2c.read_i2c_block_data(i2cAddr[x], 0x02, 5) # Arduino get lap count and lap time in ms
- print " lapCount: %d" % (i2cData[0])
-
- milliSeconds = 0 # Rebuild ms from four bytes
- partA = i2cData[1]
- partB = i2cData[2]
- partC = i2cData[3]
- partD = i2cData[4]
- milliSeconds = partA
- milliSeconds = (milliSeconds << 8) | partB
- milliSeconds = (milliSeconds << 8) | partC
- milliSeconds = (milliSeconds << 8) | partD
- print " milliSeconds: %d" % (milliSeconds)
-
- if i2cData[0] != lapCount[x]: # Checks if the lap number is new
- # Set lapCount to new lap number and update nodes table
- lapCount[x] = i2cData[0]
- print "Updating node lapCount in database."
- try:
- cursor.execute("UPDATE `nodesMem` SET `lapCount` = %s WHERE `node` = %s",(lapCount[x],x+1))
- db.commit()
- except MySQLdb.Error as e:
- print e
- db.rollback()
- except MySQLdb.Warning as e:
- print e
-
- # Calculate lap min/sec/ms
- m = int(milliSeconds / 60000)
- over = milliSeconds % 60000
- print " minutes: %d" % (m)
- s = int(over / 1000)
- over = over % 1000
- print " seconds: %d" % (s)
- ms = int(over)
- print " milliseconds: %d" % (ms)
-
- # Add new lap to the database
- print "Adding lap to currentLaps in database."
- try:
- cursor.execute("INSERT INTO `currentLaps` (`pilot`, `lap`, `min`, `sec`, `milliSec`) VALUES (%s, %s, %s, %s, %s)",(pilot[x], lapCount[x], m, s, ms))
- db.commit()
- except MySQLdb.Error as e:
- print e
- db.rollback()
- except MySQLdb.Warning as e:
- print e
- except IOError as e:
- print e
- time.sleep(0.100) # i2c data read delay
-
- # Update all rssi values at once to lessen database load
- try:
- sql = "UPDATE `nodesMem` SET `rssi` = %s WHERE `node` = %s"
- params = []
- for x in range(0, numNodes):
- params.append((rssi[x],x+1))
- cursor.executemany(sql, params)
- db.commit()
- except MySQLdb.Error as e:
- print e
- db.rollback()
- except MySQLdb.Warning as e:
- print e
-
- time.sleep(0.500) # Main while loop delay
-
- endTime = time.time()
- print("Loop time: ", endTime - startTime)
-
-db.close() # Disconnect from database
diff --git a/src/delta5server/static/python/stopRace.py b/src/delta5server/static/python/stopRace.py
deleted file mode 100644
index cf4cd0c..0000000
--- a/src/delta5server/static/python/stopRace.py
+++ /dev/null
@@ -1,47 +0,0 @@
-# Sets race status to false on each node so they stop registering new laps
-
-import smbus
-import time
-import MySQLdb
-
-# Start i2c bus
-i2c = smbus.SMBus(1)
-
-# Open database connection
-db = MySQLdb.connect("localhost","root","delta5fpv","vtx" )
-cursor = db.cursor()
-
-# Get node i2cAddr info
-i2cAddr = []
-try:
- cursor.execute("SELECT * FROM `nodes`") # Update to remove * and just get i2cAddr
- numNodes = int(cursor.rowcount)
- print "numNodes: %d" % numNodes
- for x in range(0, numNodes):
- row = cursor.fetchone()
- print row
- i2cAddr.append(int(row[1]))
- print "i2cAddr: "
- print i2cAddr
-except MySQLdb.Error as e:
- print e
-except MySQLdb.Warning as e:
- print e
-
-try:
- cursor.execute("UPDATE `status` SET `raceStatus` = 0")
- db.commit()
-except MySQLdb.Error as e:
- print e
- db.rollback()
-except MySQLdb.Warning as e:
- print e
-
-time.sleep(1.000) # Time for main system loop to read new value
-
-db.close() # disconnect from database
-
-# raceStatus set false to stop logging laps
-for x in range(0, numNodes): # loops for polling each node
- i2c.write_byte_data(i2cAddr[x], 0x55, 0) # Arduino set race status to false
- time.sleep(0.250)
diff --git a/src/delta5server/static/python/stopSystem.py b/src/delta5server/static/python/stopSystem.py
deleted file mode 100644
index 2ffcd3d..0000000
--- a/src/delta5server/static/python/stopSystem.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# Sets comms status to false to stop the main comms loop
-
-import MySQLdb
-
-# Open database connection
-db = MySQLdb.connect("localhost","root","delta5fpv","vtx" )
-cursor = db.cursor()
-
-try:
- cursor.execute("UPDATE `status` SET `systemStatus` = 0")
- db.commit()
-except MySQLdb.Error as e:
- print e
- db.rollback()
-except MySQLdb.Warning as e:
- print e
-
-time.sleep(1.000) # Time for main system loop to read new value
-
-db.close() # disconnect from database
diff --git a/src/delta5server/templates/build_current_laps.html b/src/delta5server/templates/build_current_laps.html
deleted file mode 100644
index 4c6c198..0000000
--- a/src/delta5server/templates/build_current_laps.html
+++ /dev/null
@@ -1,20 +0,0 @@
-
- {% for node in range(num_nodes) %}
-
-
-
-
-
-
- {{ pilots.query.filter_by( pilot_id=heats.query.filter_by(heat_id=current_heat,node_index=node).first().pilot_id ).first().callsign
- }}
-
-
-
-
-
- {% endfor %}
-
\ No newline at end of file
diff --git a/src/delta5server/templates/build_heats.html b/src/delta5server/templates/build_heats.html
deleted file mode 100644
index 54d93c7..0000000
--- a/src/delta5server/templates/build_heats.html
+++ /dev/null
@@ -1,24 +0,0 @@
-
- {% for heat in heats.query.with_entities(heats.heat_id).distinct() %}
-
-
-
-
{{ heat.heat_id }}
-
-
- {% for node in range(num_nodes) %}
-
-
- {{ channels[node] }} {{ frequencies[node] }}
-
-
- {{ pilots.query.filter_by(pilot_id= heats.query.filter_by(heat_id=heat.heat_id,node_index=node).first().pilot_id ).first().callsign
- }}
-
-
- {% endfor %}
-
-
-
- {% endfor %}
-
\ No newline at end of file
diff --git a/src/delta5server/templates/build_heats_edit.html b/src/delta5server/templates/build_heats_edit.html
deleted file mode 100644
index 4b18176..0000000
--- a/src/delta5server/templates/build_heats_edit.html
+++ /dev/null
@@ -1,35 +0,0 @@
-
- {% for heat in heats.query.with_entities(heats.heat_id).distinct() %}
-
-
-
-
{{ heat.heat_id }}
-
-
- {% for node in range(num_nodes) %}
-
-
-
-
-
-
-
- {{ pilots.query.filter_by(pilot_id=
- heats.query.filter_by(heat_id=heat.heat_id,node_index=node).first().pilot_id
- ).first().callsign }}
-
-
-
-
-
- {% endfor %}
-
-
-
- {% endfor %}
-
\ No newline at end of file
diff --git a/src/delta5server/templates/build_leaderboard.html b/src/delta5server/templates/build_leaderboard.html
deleted file mode 100644
index 1174454..0000000
--- a/src/delta5server/templates/build_leaderboard.html
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
- Pos.
- Pilot
- Laps
- Last Lap
- Behind
- Average
- Fastest
- Total
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/delta5server/templates/build_node_tuning.html b/src/delta5server/templates/build_node_tuning.html
deleted file mode 100644
index d890c59..0000000
--- a/src/delta5server/templates/build_node_tuning.html
+++ /dev/null
@@ -1,28 +0,0 @@
-
\ No newline at end of file
diff --git a/src/delta5server/templates/build_nodes.html b/src/delta5server/templates/build_nodes.html
deleted file mode 100644
index 031b8f2..0000000
--- a/src/delta5server/templates/build_nodes.html
+++ /dev/null
@@ -1,46 +0,0 @@
-
- {% for node in range(num_nodes) %}
-
-
-
-
{{ node + 1 }}
-
-
-
- Freq.
-
-
-
-
-
-
-
-
-
- RSSI
-
-
-
-
-
- Trigger
-
-
-
-
-
- Peak
-
-
-
-
-
-
-
- {% endfor %}
-
\ No newline at end of file
diff --git a/src/delta5server/templates/build_pilots.html b/src/delta5server/templates/build_pilots.html
deleted file mode 100644
index 774a58d..0000000
--- a/src/delta5server/templates/build_pilots.html
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
- Pilot ID
- Call Sign
- Name
-
-
-
- {% for pilot in pilots.query.all() %} {% if pilot.pilot_id != 0 %}
-
- {{ pilot.pilot_id }}
- {{ pilot.callsign }}
- {{ pilot.name }}
-
- {% endif %} {% endfor %}
-
-
-
-
-
\ No newline at end of file
diff --git a/src/delta5server/templates/build_pilots_edit.html b/src/delta5server/templates/build_pilots_edit.html
deleted file mode 100644
index 56fc036..0000000
--- a/src/delta5server/templates/build_pilots_edit.html
+++ /dev/null
@@ -1,29 +0,0 @@
-
\ No newline at end of file
diff --git a/src/delta5server/templates/build_rounds.html b/src/delta5server/templates/build_rounds.html
deleted file mode 100644
index abe942b..0000000
--- a/src/delta5server/templates/build_rounds.html
+++ /dev/null
@@ -1,33 +0,0 @@
- {% for heat in rounds.query.with_entities(rounds.heat_id).distinct() %}
-Heat {{ heat.heat_id }}
-{% for round in rounds.query.with_entities(rounds.round_id).distinct().filter_by(heat_id=heat.heat_id) %}
-Round {{ round.round_id }}
-
- {% for node in range(num_nodes) %}
-
-
-
-
- {{ pilots.query.filter_by( pilot_id=heats.query.filter_by(heat_id=heat.heat_id,node_index=node).first().pilot_id ).first().callsign
- }}
-
-
-
-
- {% for lap in rounds.query.filter_by(heat_id=heat.heat_id, round_id=round.round_id, node_index=node).all() %}
-
-
- {{ lap.lap_id }}
-
-
- {{ lap.lap_time_formatted }}
-
-
- {% endfor %}
-
-
-
-
- {% endfor %}
-
-{% endfor %} {% endfor %}
\ No newline at end of file
diff --git a/src/delta5server/templates/heats.html b/src/delta5server/templates/heats.html
index be1b646..76f459d 100644
--- a/src/delta5server/templates/heats.html
+++ b/src/delta5server/templates/heats.html
@@ -2,8 +2,54 @@
Heats
-{% include "build_heats.html" %}
+
+ {% for heat in heats.query.with_entities(heats.heat_id).distinct().order_by(heats.heat_id) %}
+
+
+
+
{{ heat.heat_id }} (Heat note)
+
+
+ {% for node in range(num_nodes) %}
+
+
+ {{ channels[node] }} {{ frequencies[node] }}
+
+
+ {{ pilots.query.filter_by(pilot_id= heats.query.filter_by(heat_id=heat.heat_id,node_index=node).first().pilot_id ).first().callsign
+ }}
+
+
+ {% endfor %}
+
+
+
+ {% endfor %}
+
Pilots
-{% include "build_pilots.html" %} {% endblock %}
\ No newline at end of file
+
+
+
+
+
+
+ Call Sign
+ Name
+
+
+
+ {% for pilot in pilots.query.all() %} {% if pilot.pilot_id != 0 %}
+
+ {{ pilot.callsign }}
+ {{ pilot.name }}
+
+ {% endif %} {% endfor %}
+
+
+
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/src/delta5server/templates/layout.html b/src/delta5server/templates/layout.html
index 4e608c9..f9dbeab 100644
--- a/src/delta5server/templates/layout.html
+++ b/src/delta5server/templates/layout.html
@@ -44,12 +44,9 @@
-
{% block content %}{% endblock %}
-
-