estim

package module
v0.0.0-...-71d4491 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2017 License: MIT Imports: 8 Imported by: 0

README

GoDoc

estim

A Go library for interfacing with e-stim units. Only works with the Erostek ET232 for now.

Disclaimers

This software is still in early development, and has not been well tested. Please carefully test before using.

Until I'm more satisfied with the code, the external API is subject to change at any time.

This project is not in any way associated or affiliated with Erostek. You may void your warranty, etc etc.

Installation

go get -v github.com/biribiribiri/estim

Example

package main

import (
	"flag"
	"log"
	"time"

	"github.com/biribiribiri/estim"
)

func main() {
	flag.Parse()
	e, err := estim.NewSerialET232("/dev/ttyUSB0")
	if err != nil {
		log.Fatal(err)
	}
	log.Println("Performing handshake...")
	e.Handshake() // Perform serial handshake with the device.

	// Force the mode to Intense. Turning off the device while mode is
	// overwritten requires disconnecting power.
	e.WriteSetting(estim.ModeOverride, estim.ModeIntense)

	// Override the A, B, and MA dials.
	e.WriteSetting(estim.AnalogOverride, estim.OverrideAll)

	// Set A and B to 80 (out of 255).
	e.Write(estim.PotA, 80)
	e.Write(estim.PotB, 80)

	time.Sleep(10 * time.Second)

	// Disable mode override so you can turn the thing off.
	e.WriteSetting(estim.ModeOverride, estim.OverrideOff)
}

Connecting to the ET232 via Serial

It turns out that the audio/link port on the ET232 can be used to control the device. If the device completes a handshake when it powers on, then the port will be used as a serial input rather than as an audio input.

The device uses RS232, 19200/8/N/1. The pins are as follows:

  • Tip <-> RX
  • Ring <-> TX
  • Sleeve <-> Ground

Strangely enough, you can buy a suitable cable. This is the one I bought. You can connect it to a USB-to-serial cable.

Thanks

Many thanks to the Buttshock project for providing documentation on the ET232.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ET232

type ET232 struct {
	// contains filtered or unexported fields
}

func NewSerialET232

func NewSerialET232(portName string) (*ET232, error)

NewSerialET232 returns an ET232 that will attempt to communicate with the device over the specified serial port (e.g. "COM1" on Windows or "/dev/ttyUSB0" on *nix).

func (*ET232) Handshake

func (e *ET232) Handshake() error

Handshake attempts to perform a serial handshake with the device. This must be performed every time the device is powercycled. After calling this function, the device should be powercycled for this function to succeed.

func (*ET232) Info

func (e *ET232) Info() (string, error)

Info reads from the device and summarizes the device state in a human-readable string.

func (*ET232) Read

func (e *ET232) Read(addr ET232Mem) (uint8, error)

Read reads and returns the value at address addr.

func (*ET232) Write

func (e *ET232) Write(mem ET232Mem, val uint8) error

Write writes val to the specified memory.

func (*ET232) WriteSetting

func (e *ET232) WriteSetting(mem ET232Mem, setting ET232Setting) error

WriteSetting sets the specified ET232Mem to the passed setting.

type ET232Mem

type ET232Mem uint8

ET232Mem represents an ET232 memory address.

const (
	PulseWidthA        ET232Mem = 0x08 // PulseWidthA is Channel A Pulse Width
	FreqRecA           ET232Mem = 0x09 // FreqRecA is Channel A Pulse Frequency Reciprocal
	PulseAmpA          ET232Mem = 0x0A // PulseAmpA is Channel A Pulse Amplitude
	PowerCompA         ET232Mem = 0x0B // PowerCompA is Channel A Power Compensation
	PulsePolarityEnA   ET232Mem = 0x0C // PulsePolarityEnA is Channel A Pulse Enable Polarity
	PulseWidthB        ET232Mem = 0x0E // PulseWidthB is Channel B Pulse Width
	FreqRecB           ET232Mem = 0x0F // FreqRecB is Channel B Pulse Frequency Reciprocal
	PulseAmpB          ET232Mem = 0x10 // PulseAmpB is Channel B Pulse Amplitude
	PowerCompB         ET232Mem = 0x11 // PowerCompB is Channel B Power Compensation
	PulsePolarityEnB   ET232Mem = 0x12 // PulsePolarityEnB is Channel B Pulse Enable Polarity
	PotB               ET232Mem = 0x88 // PotB is Position of Pot B
	PotMA              ET232Mem = 0x89 // PotMA is Position of MA Pot
	BatteryVoltage     ET232Mem = 0x8A // BatteryVoltage is Battery Voltage
	AudioInput         ET232Mem = 0x8B // AudioInput is Audio Input Level
	PotA               ET232Mem = 0x8C // PotA is Position of Pot A
	Mode               ET232Mem = 0xA2 // Mode is Mode Switch Position
	ModeOverride       ET232Mem = 0xA3 // ModeOverride is Mode Switch Override
	AnalogOverride     ET232Mem = 0xA4 // AnalogOverride is Analog Input Override
	AutoPowerOffTimer  ET232Mem = 0xD3 // AutoPowerOffTimer is Auto Power Off Timer
	ProgramFadeInTimer ET232Mem = 0xD8 // ProgramFadeInTimer is Program Fade In Timer
)

func ET232MemString

func ET232MemString(s string) (ET232Mem, error)

func (ET232Mem) String

func (i ET232Mem) String() string

type ET232Setting

type ET232Setting string

ET232Setting is a named setting for an ET232Mem. This is used for certain ET232Mems that only take certain discrete values (e.g. the Mode switch).

const (
	ModeWaves      ET232Setting = "ModeWaves"      // Waves setting for "Mode" and "ModeOverride"
	ModeIntense    ET232Setting = "ModeIntense"    // Intense setting for "Mode" and "ModeOverride"
	ModeRandom     ET232Setting = "ModeRandom"     // Random setting for "Mode" and "ModeOverride"
	ModeAudioSoft  ET232Setting = "ModeAudioSoft"  // AudioSoft setting for "Mode" and "ModeOverride"
	ModeAudioLoud  ET232Setting = "ModeAudioLoud"  // AudioLoud setting for "Mode" and "ModeOverride"
	ModeAudioWaves ET232Setting = "ModeAudioWaves" // AudioWaves setting for "Mode" and "ModeOverride"
	ModeUser       ET232Setting = "ModeUser"       // User setting for "Mode" and "ModeOverride"
	ModeHiFreq     ET232Setting = "ModeHiFreq"     // HiFreq setting for "Mode" and "ModeOverride"
	ModeClimb      ET232Setting = "ModeClimb"      // Climb setting for "Mode" and "ModeOverride"
	ModeThrob      ET232Setting = "ModeThrob"      // Throb setting for "Mode" and "ModeOverride"
	ModeCombo      ET232Setting = "ModeCombo"      // Combo setting for "Mode" and "ModeOverride"
	ModeThrust     ET232Setting = "ModeThrust"     // Thrust setting for "Mode" and "ModeOverride"
	ModeThump      ET232Setting = "ModeThump"      // Thump setting for "Mode" and "ModeOverride"
	ModeRamp       ET232Setting = "ModeRamp"       // Ramp setting for "Mode" and "ModeOverride"
	ModeStroke     ET232Setting = "ModeStroke"     // Stroke setting for "Mode" and "ModeOverride"
	ModeOff        ET232Setting = "ModeOff"        // Off setting for "Mode" and "ModeOverride"

	OverrideAll ET232Setting = "OverrideAll"
	OverrideOff ET232Setting = "OverrideOff"
)

func GetSetting

func GetSetting(mem ET232Mem, val uint8) (ET232Setting, error)

GetSetting returns the ET232Setting corresponding to a specified ET232Mem and value.

Directories

Path Synopsis
estim_cli is an interative shell application for interacting with the ET232.
estim_cli is an interative shell application for interacting with the ET232.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL