mirror of
https://github.com/OpenVoiceOS/OpenVoiceOS
synced 2025-03-10 16:40:11 +01:00
Addition of specific Mark-2 scripts
This commit is contained in:
parent
4c0b9957be
commit
30354a6f0a
@ -6,6 +6,7 @@ After=pulseaudio.service NetworkManager.service systemd-timesyncd.service
|
|||||||
User=mycroft
|
User=mycroft
|
||||||
WorkingDirectory=/home/mycroft
|
WorkingDirectory=/home/mycroft
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
|
ExecStartPre=-/usr/bin/sj201-reset-led
|
||||||
ExecStart=/bin/true
|
ExecStart=/bin/true
|
||||||
RemainAfterExit=yes
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
@ -17,4 +17,4 @@ gpio -g write $XMOS_RESET 1
|
|||||||
sleep 1
|
sleep 1
|
||||||
xvf3510-flash --direct "/usr/lib/firmware/xvf3510/app_xvf3510_int_spi_boot_v4_1_0.bin"
|
xvf3510-flash --direct "/usr/lib/firmware/xvf3510/app_xvf3510_int_spi_boot_v4_1_0.bin"
|
||||||
sleep 1
|
sleep 1
|
||||||
i2cdetect -y 1
|
tas5806-init
|
||||||
|
97
buildroot-external/rootfs-overlay/usr/bin/sj201-reset-led
Executable file
97
buildroot-external/rootfs-overlay/usr/bin/sj201-reset-led
Executable file
@ -0,0 +1,97 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
##########################################################################
|
||||||
|
# sj201-reset-led
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
##########################################################################
|
||||||
|
'''
|
||||||
|
Color ring test interface for Mycroft SJ201 over Pi I2C
|
||||||
|
|
||||||
|
'''
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
|
||||||
|
class mycroftSJ201:
|
||||||
|
DeviceAddr = 0x04
|
||||||
|
num_pixels = 12
|
||||||
|
|
||||||
|
def setColor(self, pixel,colors ):
|
||||||
|
redVal = colors[0]
|
||||||
|
greenVal = colors[1]
|
||||||
|
blueVal = colors[2]
|
||||||
|
|
||||||
|
commandOS = "i2cset -y 1 %d %d %d %d %d i " % (
|
||||||
|
self.DeviceAddr,
|
||||||
|
pixel,
|
||||||
|
redVal,
|
||||||
|
greenVal,
|
||||||
|
blueVal)
|
||||||
|
|
||||||
|
#print(commandOS)
|
||||||
|
os.system(commandOS)
|
||||||
|
|
||||||
|
|
||||||
|
def readMemory(self):
|
||||||
|
commandOS = " i2cget " + str(self.DeviceAddr) + " 0 16"
|
||||||
|
#print(commandOS)
|
||||||
|
os.system(commandOS)
|
||||||
|
|
||||||
|
for x in range(4):
|
||||||
|
os.system(self.vfctrl +" GET_I2C ")
|
||||||
|
|
||||||
|
def wheel(self, pos):
|
||||||
|
# Input a value 0 to 255 to get a color value.
|
||||||
|
# The colours are a transition r - g - b - back to r.
|
||||||
|
if pos < 0 or pos > 255:
|
||||||
|
return (0, 0, 0)
|
||||||
|
if pos < 85:
|
||||||
|
return (255 - pos * 3, pos * 3, 0)
|
||||||
|
if pos < 170:
|
||||||
|
pos -= 85
|
||||||
|
return (0, 255 - pos * 3, pos * 3)
|
||||||
|
pos -= 170
|
||||||
|
return (pos * 3, 0, 255 - pos * 3)
|
||||||
|
|
||||||
|
def rainbow_cycle(self, wait):
|
||||||
|
for j in range(255):
|
||||||
|
for i in range(self.num_pixels):
|
||||||
|
rc_index = (i * 256 // self.num_pixels) + j
|
||||||
|
colors = self.wheel(rc_index & 255)
|
||||||
|
self.setColor(i,colors)
|
||||||
|
|
||||||
|
def color_chase(self, color, wait):
|
||||||
|
for i in range(self.num_pixels):
|
||||||
|
self.setColor(i,color)
|
||||||
|
time.sleep(wait)
|
||||||
|
|
||||||
|
def setState(self, stateNum):
|
||||||
|
self.setColor( stateNum + 12, (255, 0, 0, 0) )
|
||||||
|
|
||||||
|
|
||||||
|
sj = mycroftSJ201()
|
||||||
|
|
||||||
|
pixel = 1
|
||||||
|
redVal = 49
|
||||||
|
greenVal = 30
|
||||||
|
blueVal = 255
|
||||||
|
RED = (255, 0, 0, 0)
|
||||||
|
YELLOW = (255, 150, 0, 0)
|
||||||
|
GREEN = (0, 255, 0, 0)
|
||||||
|
CYAN = (0, 255, 255, 0)
|
||||||
|
BLUE = (0, 0, 255, 0)
|
||||||
|
PURPLE = (180, 0, 255, 0)
|
||||||
|
BLACK = (0, 0, 0, 0)
|
||||||
|
|
||||||
|
sj.color_chase(RED,0)
|
||||||
|
time.sleep(1)
|
||||||
|
sj.color_chase(BLACK,0)
|
146
buildroot-external/rootfs-overlay/usr/bin/tas5806-init
Executable file
146
buildroot-external/rootfs-overlay/usr/bin/tas5806-init
Executable file
@ -0,0 +1,146 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
##########################################################################
|
||||||
|
# tas5806-init
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
##########################################################################
|
||||||
|
'''
|
||||||
|
install:
|
||||||
|
pip3 install smbus2
|
||||||
|
|
||||||
|
run:
|
||||||
|
python3 tas5806Test.py
|
||||||
|
'''
|
||||||
|
from smbus2 import SMBus
|
||||||
|
# Open i2c bus 1 and read one byte from address 80, offset 0
|
||||||
|
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
class tasTest:
|
||||||
|
devAddr = 0x2f
|
||||||
|
bus = ""
|
||||||
|
|
||||||
|
commandReturn = ""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.bus = SMBus(1)
|
||||||
|
|
||||||
|
def dumpData(self):
|
||||||
|
#for i in range(0x10):
|
||||||
|
# b = self.bus.read_byte_data(self.devAddr, i)
|
||||||
|
# print("%s: %s" % (hex(i), hex(b)) )
|
||||||
|
|
||||||
|
#print("------------------")
|
||||||
|
commandSend = 'i2cdump -y 1 ' +str( self.devAddr) +' W'
|
||||||
|
#os.system(commandSend)
|
||||||
|
self.commandReturn = os.popen(commandSend).read()
|
||||||
|
#print(self.commandReturn)
|
||||||
|
self.checkErrors()
|
||||||
|
|
||||||
|
'''
|
||||||
|
Check through error codes in i2cDump
|
||||||
|
'''
|
||||||
|
def checkErrors(self):
|
||||||
|
|
||||||
|
# register 0x37
|
||||||
|
fsMon = self.commandReturn.splitlines()[4][25:27]
|
||||||
|
fsMonBin = "{0:08b}".format(int(fsMon, 16))
|
||||||
|
fsMonStr = ["FS Error","","","","","","32KHz","","Reserved","48KHz","","96KHz"]
|
||||||
|
#print("FS_MON: %s (0x37)" % (fsMon))
|
||||||
|
print("FS_MON: %s (reg: 0x37)" % fsMonStr[int(fsMon)] )
|
||||||
|
|
||||||
|
|
||||||
|
# (reg: 0x70)
|
||||||
|
errorString = self.commandReturn.splitlines()[8][4:6]
|
||||||
|
errorStringBin = "{0:08b}".format(int(errorString, 16))
|
||||||
|
if(errorStringBin[-4] == "1" ):
|
||||||
|
print("Left channel DC fault" )
|
||||||
|
if(errorStringBin[-3] == "1" ):
|
||||||
|
print("Right channel DC fault" )
|
||||||
|
if(errorStringBin[-2] == "1" ):
|
||||||
|
print("Left channel over current fault" )
|
||||||
|
if(errorStringBin[-1] == "1" ):
|
||||||
|
print("Right channel over current fault" )
|
||||||
|
|
||||||
|
# (reg: 0x71)
|
||||||
|
errorString = self.commandReturn.splitlines()[8][7:9]
|
||||||
|
errorStringBin = "{0:08b}".format(int(errorString, 16))
|
||||||
|
if(errorStringBin[-3] == "1" ):
|
||||||
|
print("Clock fault (reg: 0x71)" )
|
||||||
|
|
||||||
|
|
||||||
|
# register 0x68
|
||||||
|
runStatus = self.commandReturn.splitlines()[7][29:31]
|
||||||
|
runStatusBin = "{0:08b}".format(int(runStatus, 16))
|
||||||
|
#print(runStatus)
|
||||||
|
runStatusStr = ["Deep sleep","Sleep","HIZ","Play"]
|
||||||
|
print("Run Status: %s (reg: 0x68)" % runStatusStr[int(runStatus)] )
|
||||||
|
|
||||||
|
def writeData(self, addr, val, comment = "" ):
|
||||||
|
self.bus.write_byte_data(self.devAddr, addr , val)
|
||||||
|
#print("write: %s: %s - %s" %(hex(addr),hex(val), comment ) )
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
self.bus.close()
|
||||||
|
|
||||||
|
'''
|
||||||
|
Start Sequence for the TAS5806
|
||||||
|
'''
|
||||||
|
def startSequence(self):
|
||||||
|
self.writeData(0x01,0x11, "Reset Chip") #reset chip
|
||||||
|
self.writeData(0x78,0x80, "Clear Faults") #clear fault - works
|
||||||
|
self.dumpData()
|
||||||
|
self.writeData(0x01,0x00 , "Remove Reset") #remove reset
|
||||||
|
self.writeData(0x78,0x00 , "Remove Clear Fault") #remove clear fault
|
||||||
|
self.dumpData()
|
||||||
|
|
||||||
|
#self.writeData(51,3) # 0x33 h set bit rate
|
||||||
|
#self.writeData(118,64) # 0x76
|
||||||
|
##self.writeData(0x6A,3 , "")
|
||||||
|
##self.dumpData()
|
||||||
|
|
||||||
|
#self.writeData(0x33,0x00, "16-bit")
|
||||||
|
#self.writeData(0x33,0x01, "20-bit")
|
||||||
|
#self.writeData(0x33,0x02, "24-bit")
|
||||||
|
self.writeData(0x33,0x03, "32-bit")
|
||||||
|
self.dumpData()
|
||||||
|
self.setVolume(0x60)
|
||||||
|
self.writeData(0x30,0x01, "SDOUT is the DSP input (pre-processing)")
|
||||||
|
|
||||||
|
|
||||||
|
self.writeData(0x03,0x00, "Deep Sleep") #Deep Sleep
|
||||||
|
self.dumpData()
|
||||||
|
#self.writeData(0x03,0x01) #Sleep
|
||||||
|
#self.dumpData()
|
||||||
|
|
||||||
|
|
||||||
|
self.writeData(0x03,0x02, "HiZ") #HiZ
|
||||||
|
self.dumpData()
|
||||||
|
|
||||||
|
self.writeData(0x5C,0x01, "coefficient") #Indicate the first coefficient of a BQ is starting to write
|
||||||
|
self.dumpData()
|
||||||
|
self.writeData(0x03,0x03 , "Play") #Play
|
||||||
|
self.dumpData()
|
||||||
|
|
||||||
|
def setVolume(self, vol):
|
||||||
|
setVolStr = "Set Volume %s" %( str (vol) )
|
||||||
|
self.writeData(0x4c,vol ,setVolStr) #Set volume
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
tt = tasTest()
|
||||||
|
tt.startSequence()
|
||||||
|
tt.setVolume(50)
|
||||||
|
tt.close()
|
Loading…
x
Reference in New Issue
Block a user