Old SandTable project

This commit is contained in:
Your Name
2026-08-08 16:11:57 +03:00
commit 59c9f942f0
68 changed files with 2686 additions and 0 deletions
+50
View File
@@ -0,0 +1,50 @@
import sqlite3
import os
import playTrack, playControl
DB_PATH = '/home/pi/SandTable/db.sqlite3'
def PlayQ():
connection = sqlite3.connect(DB_PATH)
cursor = connection.cursor()
playControl.init_control_table()
playControl.set_command(playControl.COMMAND_PLAY)
playControl.set_status(playControl.STATUS_PLAYING, pid=os.getpid())
# Reading the queue table
rows = cursor.execute("SELECT id, file, track_length, pic FROM sandtable_queue").fetchall()
# Let the first playTrack() call ask the device for its position; after
# that we just keep tracking it in memory as moves complete.
coords = None
# While there are entries in the table
while rows:
file = rows[0][1]
# Playing the track in the first index
coords = playTrack.playTrack(file, coords=coords)
# A stop request means playTrack() bailed out mid-file - leave this
# track in the queue (so it picks back up / can be replayed) rather
# than deleting it like a normally-finished or skipped ("next")
# track.
if playControl.get_command() == playControl.COMMAND_STOP:
break
# Deleting the first track that was just played
cursor.execute("DELETE FROM sandtable_queue WHERE id = ?", (rows[0][0],))
connection.commit()
# Reading the new table
rows = cursor.execute("SELECT id, file, track_length, pic FROM sandtable_queue").fetchall()
playControl.set_status(playControl.STATUS_IDLE, pid=0)
connection.close()
if __name__ == "__main__":
PlayQ()