Created
January 8, 2016 15:56
-
-
Save deladriere/de4f18bebcd712ea84c8 to your computer and use it in GitHub Desktop.
Hello word to SSI-263
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# Author: Jean-Luc Deladriere | |
# Description: Arduino/nanpy & ssi263 hello world from Python | |
from nanpy import Arduino | |
from nanpy import serial_manager | |
from random import randrange | |
import time | |
serial_manager.connect('/dev/tty.usbmodem1411') | |
time.sleep(2) | |
#A/R | |
Arduino.pinMode(15, Arduino.INPUT) | |
#Strobe | |
Arduino.pinMode(13, Arduino.OUTPUT) | |
Arduino.digitalWrite(13,1) | |
#Data bus as output | |
for i in range(2,13): | |
Arduino.pinMode(i, Arduino.OUTPUT) | |
def Strobe(): | |
Arduino.digitalWrite(13,0) | |
#time.sleep(0.001) | |
Arduino.digitalWrite(13,1) | |
def Command(register,value): | |
print'Sending Command: ' + str(register) + "," + str(value) +" "+ hex(int(value))+ " " +bin(int(value)) | |
# writing the command address | |
for i in range(4): | |
b=(int(register) & pow(2,i))/ pow(2,i) | |
Arduino.digitalWrite(i+10, b) | |
# writing the data | |
for i in range(8): | |
b=(int(value) & pow(2,i))/ pow(2,i) | |
Arduino.digitalWrite(i+2, b) | |
while True: | |
if Arduino.digitalRead(15)==0: # wait for the SSI to be done (A/R going low) | |
break | |
Strobe() | |
#Prepare registers | |
Command(0,192) # load DR1 DR2 bit to 1 (to activate A/R request mode) (192) | |
Command(3,127) # Control bit to 1 (127) | |
Command(3,0) # Control bit to 0 (to activate A/R request mode by going to 0) (0) | |
Command(3,116) # Set articulation to normal and amplitude to maximum (116) | |
Command(4,231) # Set Filter frequency to normal (231) | |
Command(2,168) # Set Speech rate to normal (168) | |
Command(1,127) # Set Inflection to normal (127) | |
#Voice Demo | |
hello=[44,10,32,17,35,0,0x23,0x1C,0x20,0x25,0] | |
while True: | |
for i in hello: | |
Command(0,i) | |
time.sleep(2) # pausing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment