Personal tools
 
Document Actions

Class "misc"

Miscellaneous functions

Thierry Nancy

This tutorial provides functions and parameters description while illustrating each item with examples
Page 5 of 8.

Functions List



1.5) Class : tux.misc
1.5.1) Function : tux.misc.doc
1.5.2) Function : tux.misc.build_documentation
1.5.3) Function : tux.misc.print_api_version

Functions Details


Class : tux.misc

Class which manages the miscellaneous functions

1.5.1) Function : tux.misc.doc

Print the docstring of an element of tux api

Parameters:
"element" as methode or class

Examples:
>>> tux.misc.doc(tux)
>>> tux.misc.doc(tux.cmd.eyes_on)

1.5.2) Function : tux.misc.build_documentation

Build the documentation of this api

Parameters:
"doc_path" as string : path of the output text file

Example:
>>> tux.misc.build_documentation('/home/remi/tuxapi_doc')

1.5.3) Function : tux.misc.print_api_version

To print the version of the API

Example:
>>> tux.misc.print_api_version()

1.6) Class : tux.status (tuxapi_class.TUXStatus)

Class which manages the request of a status


Global variables of this class:
"rf_connected" as boolean : State of the droid/dongle connection

1.6.1) Function : tux.status.charger_state

Get the status of the charger

Return 1 for charging and 0 for not charging

Example:
>>>var = tux.status.charger_state()

1.6.2) Function : tux.status.eyes_closed

Get the last state of "eyes closed position switch" status

Return 1 for on and 0 for off

Example:
>>> var = tux.status.eyes_closed()

1.6.3) Function : tux.status.eyes_counter

Get the number of remaining movements of the eyes

Return an integer (0..255)

Example:
>>> var = tux.status.eyes_counter()

1.6.4) Function : tux.status.eyes_motor

Get the last state of "head motor for eyes" status

Return 1 for on and 0 for off

Example:
>>> var = tux.status.eyes_motor()

1.6.5) Function : tux.status.eyes_opened

Get the last state of "eyes open position switch" status

Return 1 for on and 0 for off

Example:
>>> var = tux.status.eyes_opened()

1.6.6) Function : tux.status.get

Get a specified status

Parameters:
"DATA_STATUS" as integer : desired status

Return a boolean
(True if the status arrives before 2 seconds)
(The raw of the status response is in tux.tcp_data)

Example:
>>> tux.status.get(DATAS_STATUS_WINGS_MOTOR_BACKWARD)

1.6.7) Function : tux.status.head_bt

Get the status of the head button

Return 1 for on and 0 for off

Example:
>>> var = tux.status.head_bt()

1.6.8) Function : tux.status.ir_led

Get the last state of "IR led" status

Return 1 for on and 0 for off

Example:
>>> var = tux.status.ir_led()

1.6.9) Function : tux.status.ir_signal

Get the last state of "IR receiver signal" status

Return 1 for on and 0 for off

Example:
>>> var = tux.status.ir_signal()

1.6.10) Function : tux.status.light_level

Get the last light level

Return an integer (0..1024, max light=0)

Example:
>>> var = tux.status.light_level()

1.6.11) Function : tux.status.lled

Get the state of the left blue led

Return 1 for on and 0 for off

Example:
>>> var = tux.status.lled()

1.6.12) Function : tux.status.lwing_bt

Get the last state of "left wing push" status

Return 1 for on and 0 for off

Example:
>>> var = tux.status.lwing_bt()

1.6.13) Function : tux.status.mouth_closed

Get the last state of "mouth closed position" status

Return 1 for on and 0 for off

Example:
>>> var = tux.status.mouth_closed()

1.6.14) Function : tux.status.mouth_counter

Get the number of remaining movements of the mouth

Return an integer (0..255)

Example:
>>> var = tux.status.mouth_counter()

1.6.15) Function : tux.status.mouth_motor

Get the last state of "head motor for mouth" status

Return 1 for on and 0 for off

Example:
>>> var = tux.status.mouth_motor()

1.6.16) Function : tux.status.mouth_opened

Get the last state of "mouth open position" status

Return 1 for on and 0 for off

Example:
>>> var = tux.status.mouth_opened()

1.6.17) Function : tux.status.power_plug

Get the last state of "power plug switch" status

Return 1 for on and 0 for off

Example:
>>> var = tux.status.power_plug()

1.6.18) Function : tux.status.rf_state

Get the last state of the RF status

Return 1 for connected and 0 for disconnected

Example:
>>>var = tux.status.rf_state()

1.6.19) Function : tux.status.rled

Get the state of the right blue led

Return 1 for on and 0 for off

Example:
>>> var = tux.status.rled()

1.6.20) Function : tux.status.rwing_bt

Get the last state of "right wing push" status

Return 1 for on and 0 for off

Example:
>>> var = tux.status.rwing_bt()

1.6.21) Function : tux.status.sounds_count

Get the number of sounds stored in the flash memory

Return a integer (0..255)

Example:
>>> var = tux.status.sounds_count()

1.6.22) Function : tux.status.sound_muted

Get the last state of "tux mute sound" status

Return 1 for on and 0 for off

Example:
>>> var = tux.status.sound_muted()

1.6.23) Function : tux.status.spin_backward

Get the last state of "spin motor forward" status

Return 1 for on and 0 for off

Example:
>>> var = tux.status.spin_forward()

1.6.24) Function : tux.status.spin_bt

Get the last state of "spin position switch" status

Return 1 for on and 0 for off

Example:
>>> var = tux.status.spin_bt()

1.6.25) Function : tux.status.spin_counter

Get the number of remaining movements of 'spinning'

Return an integer (0..255)

Example:
>>> var = tux.status.spin_counter()

1.6.26) Function : tux.status.wings_backward

Get the last state of "wings motor backward" status

Return 1 for on and 0 for off

Example:
>>> var = tux.status.wings_backward()

1.6.27) Function : tux.status.wings_counter

Get the number of remaining movements of the wings

Return an integer (0..255)

Example:
>>> var = tux.status.wings_counter()

1.6.28) Function : tux.status.wings_motor

Get the last state of "motor for wings" status

Return 1 for on and 0 for off

Example:
>>> var = tux.status.wings_motor()

1.6.29) Function : tux.status.wings_forward

Get the last state of "wings motor forward" status

Return 1 for on and 0 for off

Example:
>>> var = tux.status.wings_forward()

1.6.30) Function : tux.status.wings_bt

Get the last state of "wings position switch" status

Return 1 for on and 0 for off

Example:
>>> var = tux.status.wings_bt()

1.6.31) Function : tux.status.get_wings_position_switch

Deprecated : see 'tux.status.wings_bt'

1.6.32) Function : tux.status.to_string

Convert the current raw statuses to an explicit string

Return a string

Example:
>>> print tux.status.to_string()

1.7) Class : tux.sys (tuxapi_class.TUXsys)

Class which manages the system functions

1.7.1) Function : tux.sys.add_time_event

Add a time event in the time event handler

Parameters:
"cmd_type" as number : Command type (CT_SHELL|CT_FUNCTION)
"cmd" as string : Command to execute
"year" as integer : (ex : 2006) (9999 : parameter ignored)
"month" as integer : (ex : 12) (99 : parameter ignored)
"day" as integer : (ex : 23) (99 : parameter ignored)
"hour" as integer : (ex : 08) (99 : parameter ignored)
"minute" as integer : (ex : 55) (99 : parameter ignored)
"second" as integer : (ex : 30) (99 : parameter ignored)

Example:
>>> tux.sys.add_time_event(CT_SHELL,'xmms',9999,99,99,8,5,0)

1.7.2) Function : tux.sys.clear_time_events

Clear the time events of the time event handle

Example:
>>> tux.sys.clear_time_events()

1.7.3) Function : tux.sys.delayed_function

To execute a function with a delay

Parameters:
"function" as pointer of function : function to execute
"delay" as float : time to wait before executing
the function. In seconds

Example:
>>> def test():
... print "hello world"
...
>>> tux.sys.delayed_function(test,10)

1.7.4) Function : tux.sys.looped_function

Looping on a function with a delay

Parameters:
"function" as pointer of function: function to execute
"delay" as float : time to wait between 2 executions
of the function. In seconds

Example:
>>> def test():
... print "hello world"
... return True
...
>>> tux.sys.looped_function(test,10)

Comment:
While the return of the function is true, the loop remains
active

1.7.5) Function : tux.sys.shell

Execute a shell command

Parameters:
"command" as string : Shell command

Example:
>>> tux.sys.shell('ls -al')

1.7.6) Function : tux.sys.shell_free

Execute a shell command in free mode

Parameters:
"command" as string : Shell command

Example:
>>> tux.sys.shell_free('ls -al')

1.7.7) Function : tux.sys.time

Get the current time in seconds

Return an integer

Example:
>>> var=tux.sys.time()

1.7.8) Function : tux.sys.wait

Wait a time in seconds

Parameters:
"seconds" as float : Time to wait in seconds

Example:
>>> tux.sys.wait(2.4)

1.8) Class : tux.tts (tuxapi_class.TUXtts)

Class which manages the text to speech

Global variables of this class:
"connected" as boolean : State of the connection to tuxttsdaemon
"print_status" as boolean : Allow to print the raw statuses
"sound_on" as boolean : Speaking state of the tuxttsdaemon
"on_connected" as pof : event on tuxttsdaemon connected
"on_disconnected" as pof : event on tuxttsdaemon disconnected
"on_sound_on" as pof : event on tts speaking on
"on_sound_off" as pof : event on tts speaking off
(pof = pointer of function)

Example of associating a function to an event:
>>> def my_function():
>>> tux.cmd.mouth_open()
>>> tux.tts.on_sound_on=my_function

1.8.1) Function : tux.tts.auto_connect

Allow to connect the api to tuxttsdaemon automatically

Parameters:
"value" as boolean : turn on/off the auto_connect mode
"address" as string : Tcp/IP Host address
(default = 'localhost')
"port" as integer : Tcp/IP Port number
(default = 5500)

Examples:
>>> tux.tts.auto_connect(True)
>>> tux.tts.auto_connect(True,'192.168.0.1')
>>> tux.tts.auto_connect(True,'192.168.0.1',5500)

1.8.2) Function : tux.tts.connect

Connect tts object to tuxttsdaemon

Parameters:
"port" as integer : Tcp/IP Port number
(default = 5500)
"address" as string : Tcp/IP Host address
(default = 'localhost')

Examples:
>>> tux.tts.connect()
>>> tux.tts.connect('192.168.0.1')
>>> tux.tts.connect('localhost',5500)

Comment:
The variable "tux.tts.connected" contains the result of this method

1.8.3) Function : tux.tts.disconnect

Disconnect tts object from tuxttsdaemon

Example:
>>> tux.tts.disconnect()

1.8.4) Function : tux.tts.kill_daemon

Kill the tuxttsdaemon

Example:
>>> tux.tts.kill_daemon()

1.8.5) Function : tux.tts.pause

Pause the sound

Example:
>>> tux.tts.pause()

1.8.6) Function : tux.tts.play

Play the sound if it's in "pause" state

Example:
>>> tux.tts.play()

1.8.7) Function : tux.tts.select_voice

Select a speaker voice

Parameters:
"speaker" as integer : speaker id (SPK_FR_MALE|SPK_FR_FEMALE|
SPK_US_MALE|SPK_US_FEMALE)
"pitch" as integer : raised pitch in % (100..330)

Example:
>>> tux.tts.select_voice(SPK_FR_MALE,100)

1.8.8) Function : tux.tts.select_voice_fr_female

Select the French female speaker voice with a normal pitch

Example:
>>> tux.tts.select_voice_fr_female()

1.8.9) Function : tux.tts.select_voice_fr_female_tuxed

Select the French female speaker voice with a raised pitch

Example:
>>> tux.tts.select_voice_fr_female_tuxed()

1.8.10) Function : tux.tts.select_voice_fr_male

Select the French male speaker voice with a normal pitch

Example:
>>> tux.tts.select_voice_fr_male()

1.8.11) Function : tux.tts.select_voice_fr_male_tuxed

Select the French male speaker voice with a raised pitch

Example:
>>> tux.tts.select_voice_fr_male_tuxed(
)

1.8.12) Function : tux.tts.select_voice_us_female

Select the US English female speaker voice with a normal pitch

Example:
>>> tux.tts.select_voice_us_female()

1.8.13) Function : tux.tts.select_voice_us_female_tuxed

Select the US English female speaker voice with a raised pitch

Example:
>>> tux.tts.select_voice_us_female_tuxed()

1.8.14) Function : tux.tts.select_voice_us_male

Select the US English male speaker voice with a normal pitch

Example:
>>> tux.tts.select_voice_us_male()

1.8.15) Function : tux.tts.select_voice_us_male_tuxed

Select the US English male speaker voice with a raised pitch

Example:
>>> tux.tts.select_voice_us_male_tuxed()

1.8.16) Function : tux.tts.send_command_to_tts

Not a user function

1.8.17) Function : tux.tts.speak

Speak a text with the acapela text to speech engine

Parameters:
"text" as string : text to read

Example:
>>> tux.tts.speak('My name is tux! tux droid !')

1.8.18) Function : tux.tts.speak_free

Speak a text with the acapela text to speech engine in free mode

Parameters:
"text" as string : text to read

Example:
>>> tux.tts.speak_free('My name is tux! tux droid !')

1.8.19) Function : tux.tts.stop

Stop the sound

Example:
>>> tux.tts.stop()
 
by Thierry Nancy last modified 2007-05-02 16:16
Contributors: Rémi Jocaille, Thierry Nancy
You are here: Home Documentation Tutorials Tux API Documentation Class "misc"

Powered by Plone CMS, the Open Source Content Management System