estim2py package¶
Submodules¶
estim2py.connection module¶
- class estim2py.connection.Estim2pyConnection(device, timeout=0.5, delay=0.05)¶
Bases:
objectConnect to the Estim 2b box, and manage communication
All method calls will return an Estim2pyStatus object.
args: device - the serial device to connect with.
keywords: timeout - Serial timeout, sent straight to pyserial delay - enforced delay. May not be needed? If you’re feeling spicy, set to 0
- BAUD = 9600¶
- BYTESIZE = 8¶
- MODE_MAX = 100¶
- PARITY = 'N'¶
- STOPBITS = 1¶
- get_status(flush=True)¶
Returns a Estim2pyStatus object
- high()¶
Sets the box to high power mode and returns Estim2pyStatus
- kill()¶
Sets channels A and B to 0 and returns Estim2pyStatus
- link()¶
Enable’s link mode and returns Estim2pyStatus. Note, does not work on my box!
- low()¶
Sets the box to low power mode and returns Estim2pyStatus
- reset()¶
Resets the box and returns Estim2pyStatus
- set_channel(channel, val)¶
Set’s the channel to value val.
Will throw a ValueError if: The channel is not a,b,c or d (upper or lowercase) The val is notan integer between 0-100 for A and B, 2-100 for C, or 1-100 for D
args: channel (str): A or B for power channels, C for Speed, D for Feeling. (generally) val (int): 1-100 for A or B, 2-200 for C, 1-100 for D
returns: Estim2pyStatus
- set_mode(mode_num)¶
Sets the mode to the numbered mode and returns Estim2pyStatus.
Doesn’t accept arguments over 100. Note that my box only accepts up to 13. (I might need an update.)
args: mode_num (int): mode number to set to.
- unlink()¶
Enable’s link mode and returns Estim2pyStatus. Note, does not work on my box!
estim2py.modes module¶
- class estim2py.modes.Estim2pyMode(mid, name, param_a, param_b, notes)¶
Bases:
objectA class representing a mode for the Estim 2b.
Construct with Estim2pyMode.get_mode(int). That will return the relevant mode by integer id.
- static get_mode(mid)¶
Returns the mode based on the integer id.
- classmethod id_names()¶
returns a dictionary of {modeid: name, …}
ie. {0: “pulse”, 1: “bounce”, …}
- mid¶
numeric id of the mode.
- modes = {0: {'name': 'pulse', 'notes': 'Pulsing on and off', 'param_a': 'pulse speed', 'param_b': 'pulse feel'}, 1: {'name': 'bounce', 'notes': 'Pulsing alternatively', 'param_a': 'pulse speed', 'param_b': 'pulse feel'}, 2: {'name': 'continious', 'notes': 'Both channels always on', 'param_a': 'pulse feel', 'param_b': None}, 3: {'name': 'asplit', 'notes': 'A Pulse B Continious', 'param_a': 'pulse speed', 'param_b': 'pulse feel'}, 4: {'name': 'bsplit', 'notes': 'B Pulse A Continious', 'param_a': 'pulse speed', 'param_b': 'pulse feel'}, 5: {'name': 'wave', 'notes': 'Output increases to power, then to 0', 'param_a': 'speed of increase', 'param_b': 'wave feel'}, 6: {'name': 'waterfall', 'notes': 'Output to power, then back down', 'param_a': 'speed of increase / decrease', 'param_b': 'waterfall feel'}, 7: {'name': 'squeeze', 'notes': 'Pulse rate increases and then drops to slow', 'param_a': 'pulse speed', 'param_b': 'feel'}, 8: {'name': 'milk', 'notes': 'Pulse rate increases and then drops to slow, b channel alternates', 'param_a': 'pulse speed', 'param_b': 'feel'}, 9: {'name': 'throb', 'notes': 'Continious, with the feel increasing to range and dropping to 0', 'param_a': 'feel range', 'param_b': None}, 10: {'name': 'thrust', 'notes': 'Continious, with the feel increasing to range and decreasing', 'param_a': 'feel range', 'param_b': None}, 11: {'name': 'random', 'notes': 'Random Levels', 'param_a': 'random range', 'param_b': 'pulse feel'}, 12: {'name': 'step', 'notes': 'Builds towards a power level slowly', 'param_a': 'step delay', 'param_b': 'pulse feel'}, 13: {'name': 'training', 'notes': 'Jumps to the power level quickly', 'param_a': 'jump delay', 'param_b': 'pulse feel'}}¶
List of modes that this class knows about. Access directly if you like!
- name¶
Short name of the mode.
- notes¶
A real short description of the mode.
- param_a¶
What channel C modifies.
- param_b¶
What channel D modifies, or None if not applicable
estim2py.simulated module¶
- class estim2py.simulated.Estim2pySimulatedConnection¶
Bases:
Estim2pyConnectionThis is a sumulated 2B box, so you don’t always have to plug a box in to write code. It should behave exactly like the real box.
If it doesn’t… that’s a bug!
The interface is exactly like Estim2pyConnection.
- get_status()¶
Returns a Estim2pyStatus object
- high()¶
Sets the box to high power mode and returns Estim2pyStatus
- kill()¶
Sets channels A and B to 0 and returns Estim2pyStatus
- link()¶
Enable’s link mode and returns Estim2pyStatus. Note, does not work on my box!
- low()¶
Sets the box to low power mode and returns Estim2pyStatus
- reset()¶
Resets the box and returns Estim2pyStatus
- reset_status()¶
Manually reset the status to the default state.
- set_channel(channel, val)¶
Set’s the channel to value val.
Will throw a ValueError if: The channel is not a,b,c or d (upper or lowercase) The val is notan integer between 0-100 for A and B, 2-100 for C, or 1-100 for D
args: channel (str): A or B for power channels, C for Speed, D for Feeling. (generally) val (int): 1-100 for A or B, 2-200 for C, 1-100 for D
returns: Estim2pyStatus
- set_mode(mode_num)¶
Sets the mode to the numbered mode and returns Estim2pyStatus.
Doesn’t accept arguments over 100. Note that my box only accepts up to 13. (I might need an update.)
args: mode_num (int): mode number to set to.
- unlink()¶
Enable’s link mode and returns Estim2pyStatus. Note, does not work on my box!
estim2py.status module¶
- class estim2py.status.Estim2pyStatus(battery, a, b, c, d, mode, power, linked, version)¶
Bases:
objectAn object that reports back the status of the Estim Box.
Object members are direct from the serial port. Object methods relate closer to what the box displays and return useful python objects.
i.e. status.a will return 200 at max power, but get_channel(‘a’) will return 100.
- as_items()¶
Returns an items-like represtation of the status.
It’s ‘items-like’ in that you can use it for iteration, but modifying the values of the tuples inside the dictionary does nothing.
NOTE, this is the raw values from the serial port.
- static from_binary(bin)¶
Return an Estim2pyStatus object form a binary string.
This is mostly internal, but may be useful in some circumstances. Check unit tests.
- get_channel(channel)¶
Returns the value of the channel as reported by the box.
Channel must be a,b,c or d (upper or lower). The value is half of what’s reported on the serial port, and is what is displayed on the LCD.
This value is compatible with Estim2pyConnection.set_channel().
- get_mode()¶
Returns an Estim2pyMode representing the current mode.
See Estim2pyMode for more information.
- high_power()¶
Returns True if the box is in high power mode, False otherwise.
- linked()¶
Return True if the box is in linked mode, False otherwise.
- low_power()¶
Returns True if the box is in low power mode, False otherwise.
- unlinked()¶
Returns True if the box is in unlinked mode, False otherwise.