/// <summary> /// Constructor for a single Expand click. /// </summary> /// <param name="socknum">mikroBUS socket number.</param> /// <param name="remdev">Remote I/O server device object.</param> public Board(int socknum, IO.Remote.Device remdev = null) { // Create Remote I/O server device object, if one wasn't supplied if (remdev == null) { remdev = new IO.Remote.Device(); } // Create a mikroBUS socket object IO.Remote.mikroBUS.Socket S = new IO.Remote.mikroBUS.Socket(socknum); // Configure hardware reset GPIO pin myrst = remdev.GPIO_Create(S.RST, IO.Interfaces.GPIO.Direction.Output, true); // Issue hardware reset Reset(); // Create MCP23S17 device object mydev = new IO.Devices.MCP23S17.Device(remdev.SPI_Create(S.SPIDev, IO.Devices.MCP23S17.Device.SPI_Mode, IO.Devices.MCP23S17.Device.SPI_WordSize, IO.Devices.MCP23S17.Device.SPI_Frequency)); }
/// <summary> /// Constructor for a single Expand 2 click. /// </summary> /// <param name="socknum">mikroBUS socket number.</param> /// <param name="addr">I<sup>2</sup>C slave address.</param> public Board(int socknum, int addr = DefaultAddress) { // Create a mikroBUS socket object IO.Objects.libsimpleio.mikroBUS.Socket S = new IO.Objects.libsimpleio.mikroBUS.Socket(socknum); // Configure hardware reset GPIO pin myrst = new IO.Objects.libsimpleio.GPIO.Pin(S.RST, IO.Interfaces.GPIO.Direction.Output, true); // Issue hardware reset Reset(); // Configure I2C bus IO.Interfaces.I2C.Bus bus; if (IO.Objects.libsimpleio.mikroBUS.Shield.I2CBus is null) { bus = new IO.Objects.libsimpleio.I2C.Bus(S.I2CBus); } else { bus = IO.Objects.libsimpleio.mikroBUS.Shield.I2CBus; } // Configure the MCP23017 mydev = new IO.Devices.MCP23017.Device(bus, addr); }
// Type 2 motor drivers, using two PWM outputs: One for CW // rotation and one for CCW rotation /// <summary> /// Constructor for a single motor, using two PWM outputs /// for clockwise and counterclockwise rotation control. /// </summary> /// <param name="clockwise">PWM output instance (for clockwise /// rotation control).</param> /// <param name="counterclockwise">PWM output instance (for /// counterclockwise rotation control).</param> /// <param name="velocity">Initial normalized motor velocity. /// Allowed values are -1.0 (full speed reverse) to +1.0 /// (full speed forward.</param> public Output(IO.Interfaces.PWM.Output clockwise, IO.Interfaces.PWM.Output counterclockwise, double velocity = IO.Interfaces.Motor.Velocities.Stop) { dirpin = null; pwm0 = clockwise; pwm1 = counterclockwise; this.velocity = velocity; }
private IO.Interfaces.PWM.Output pwm1; // CCW // Type 1 motor drivers, using one GPIO output for direction, // and one PWM output for speed /// <summary> /// Constructor for a single motor, using one GPIO pin for /// direction control, and one PWM output for speed control. /// </summary> /// <param name="direction">GPIO pin instance (for direction /// control).</param> /// <param name="speed">PWM output instance (for speed /// control).</param> /// <param name="velocity">Initial normalized motor velocity. /// Allowed values are -1.0 (full speed reverse) to +1.0 /// (full speed forward.</param> public Output(IO.Interfaces.GPIO.Pin direction, IO.Interfaces.PWM.Output speed, double velocity = IO.Interfaces.Motor.Velocities.Stop) { dirpin = direction; pwm0 = speed; pwm1 = null; this.velocity = velocity; }
/// <summary> /// Constructor for a single 7seg click. /// </summary> /// <param name="socket">mikroBUS socket number.</param> /// <param name="radix">Numerical base or radix. Allowed values are /// <c>Decimal</c> and <c>Hexadecimal</c>.</param> /// <param name="blanking">Zero blanking. Allowed values are /// <c>None</c>, <c>Leading</c>, and <c>Full</c>.</param> /// <param name="pwmfreq">PWM frequency. Set to zero to use GPIO /// instead of PWM.</param> /// <param name="remdev">Remote I/O server device object.</param> public Board(int socket, Base radix = Base.Decimal, ZeroBlanking blanking = ZeroBlanking.None, int pwmfreq = 100, IO.Remote.Device remdev = null) { // Create Remote I/O server device object, if one wasn't supplied if (remdev == null) { remdev = new IO.Remote.Device(); } // Create a mikroBUS socket object IO.Remote.mikroBUS.Socket S = new IO.Remote.mikroBUS.Socket(socket); // Configure hardware reset GPIO pin myRSTgpio = remdev.GPIO_Create(S.RST, IO.Interfaces.GPIO.Direction.Output, true); // Issue hardware reset Reset(); // Configure PWM pin -- Prefer PWM over GPIO, if possible, and // assume full brightness until otherwise changed. myPWMgpio = null; myPWMout = null; if ((pwmfreq > 0) && (S.PWMOut != IO.Remote.Device.Unavailable)) { myPWMout = remdev.PWM_Create(S.PWMOut, pwmfreq, 100.0); } else if (S.PWM != IO.Remote.Device.Unavailable) { myPWMgpio = remdev.GPIO_Create(S.PWM, IO.Interfaces.GPIO.Direction.Output, true); } // Configure 74HC595 shift register chain mychain = new SN74HC595.Device(remdev.SPI_Create(S.SPIDev, IO.Devices.SN74HC595.Device.SPI_Mode, 8, IO.Devices.SN74HC595.Device.SPI_MaxFreq), 2); myradix = radix; myblanking = blanking; Clear(); }
static void Main(string[] args) { Console.WriteLine("\nLED Toggle Test\n"); IO.Remote.Device dev = new IO.Remote.Device(new IO.Objects.USB.HID.Messenger()); IO.Interfaces.GPIO.Pin LED = dev.GPIO_Create(0, IO.Interfaces.GPIO.Direction.Output); for (;;) { LED.state = !LED.state; Thread.Sleep(500); } }
static void Main(string[] args) { Console.WriteLine("\nRemote I/O LED Toggle Test\n"); IO.Remote.Device remdev = new IO.Remote.Device(); IO.Interfaces.GPIO.Pin LED = remdev.GPIO_Create(0, IO.Interfaces.GPIO.Direction.Output); for (;;) { LED.state = !LED.state; System.Threading.Thread.Sleep(500); } }
// Type 2 motor drivers, using two PWM outputs: One for CW // rotation and one for CCW rotation /// <summary> /// Constructor for a single motor, using two PWM outputs /// for clockwise and counterclockwise rotation control. /// </summary> /// <param name="clockwise">PWM output instance (for clockwise /// rotation control).</param> /// <param name="counterclockwise">PWM output instance (for /// counterclockwise rotation control).</param> /// <param name="velocity">Initial motor velocity.</param> public Output(IO.Interfaces.PWM.Output clockwise, IO.Interfaces.PWM.Output counterclockwise, double velocity = IO.Interfaces.Motor.Velocities.Stop) { if ((velocity < IO.Interfaces.Motor.Velocities.Minimum) || (velocity > IO.Interfaces.Motor.Velocities.Maximum)) { throw new System.Exception("Invalid motor velocity"); } dirpin = null; pwm0 = clockwise; pwm1 = counterclockwise; this.velocity = velocity; }
private IO.Interfaces.PWM.Output pwm1; // CCW // Type 1 motor drivers, using one GPIO output for direction, // and one PWM output for speed /// <summary> /// Constructor for a single motor, using one GPIO pin for /// direction control, and one PWM output for speed control. /// </summary> /// <param name="direction">GPIO pin instance (for direction /// control).</param> /// <param name="speed">PWM output instance (for speed /// control).</param> /// <param name="velocity">Initial motor velocity.</param> public Output(IO.Interfaces.GPIO.Pin direction, IO.Interfaces.PWM.Output speed, double velocity = IO.Interfaces.Motor.Velocities.Stop) { if ((velocity < IO.Interfaces.Motor.Velocities.Minimum) || (velocity > IO.Interfaces.Motor.Velocities.Maximum)) { throw new System.Exception("Invalid motor velocity"); } dirpin = direction; pwm0 = speed; pwm1 = null; this.velocity = velocity; }
/// <summary> /// Constructor for a single ADAC click. /// </summary> /// <param name="socknum">mikroBUS socket number.</param> /// <param name="addr">I<sup>2</sup>C slave address.</param> /// <param name="remdev">Remote I/O server device object.</param> public Board(int socknum, int addr = DefaultAddress, IO.Remote.Device remdev = null) { // Create Remote I/O server device object, if one wasn't supplied if (remdev == null) { remdev = new IO.Remote.Device(); } // Create a mikroBUS socket object IO.Remote.mikroBUS.Socket S = new IO.Remote.mikroBUS.Socket(socknum); // Configure hardware reset GPIO pin myrst = remdev.GPIO_Create(S.RST, IO.Interfaces.GPIO.Direction.Output, true); // Issue hardware reset Reset(); // Configure I2C bus IO.Interfaces.I2C.Bus bus; if (IO.Remote.mikroBUS.Shield.I2CBus is null) { bus = remdev.I2C_Create(S.I2CBus); } else { bus = IO.Remote.mikroBUS.Shield.I2CBus; } // Configure AD5593R mydev = new IO.Devices.AD5593R.Device(bus, addr); // The ADAC click is wired for 0-5.0V on both ADC and DAC mydev.ADC_Reference = IO.Devices.AD5593R.ReferenceMode.Internalx2; mydev.DAC_Reference = IO.Devices.AD5593R.ReferenceMode.Internalx2; }
static void Main(string[] args) { Console.WriteLine("\nUSB HID Remote I/O Device LED Test\n"); IO.Interfaces.Message64.Messenger m = new IO.Objects.libsimpleio.HID.Messenger(); IO.Remote.Device dev = new IO.Remote.Device(m); IO.Interfaces.GPIO.Pin LED = dev.GPIO_Create(0, IO.Interfaces.GPIO.Direction.Output); for (;;) { LED.state = !LED.state; Thread.Sleep(500); } }
/// <summary> /// Constructor for a single A4988 device. /// </summary> /// <param name="StepsPerRotation">The number of steps per rotation. /// This is a physical characteristic of the particular stepper motor /// being driven.</param> /// <param name="Step">GPIO pin object for the /// <c>STEP</c> signal.</param> /// <param name="Dir">GPIO pin object for the /// <c>DIR</c> signal.</param> /// <param name="Enable">GPIO pin object for the /// <c>-ENABLE</c> signal.</param> /// <param name="Reset">GPIO pin object for the /// <c>-RESET</c> signal.</param> /// <param name="Sleep">GPIO pin object for the /// <c>-SLEEP</c> signal.</param> public Device(int StepsPerRotation, IO.Interfaces.GPIO.Pin Step, IO.Interfaces.GPIO.Pin Dir, IO.Interfaces.GPIO.Pin Enable = null, IO.Interfaces.GPIO.Pin Reset = null, IO.Interfaces.GPIO.Pin Sleep = null) { this.num_steps = StepsPerRotation; this.pin_step = Step; this.pin_dir = Dir; this.pin_enable = Enable; this.pin_reset = Reset; this.pin_sleep = Sleep; this.Reset(); this.Disable(); this.Sleep(); this.Wakeup(); this.Enable(); }
/// <summary> /// Constructor for a single Expand 2 click. /// </summary> /// <param name="socknum">mikroBUS socket number.</param> /// <param name="addr">I<sup>2</sup>C slave address.</param> /// <param name="remdev">Remote I/O server device object.</param> public Board(int socknum, int addr = DefaultAddress, IO.Remote.Device remdev = null) { // Create Remote I/O server device object, if one wasn't supplied if (remdev == null) { remdev = new IO.Remote.Device(); } // Create a mikroBUS socket object IO.Remote.mikroBUS.Socket S = new IO.Remote.mikroBUS.Socket(socknum); // Configure hardware reset GPIO pin myrst = remdev.GPIO_Create(S.RST, IO.Interfaces.GPIO.Direction.Output, true); // Issue hardware reset Reset(); // Configure I2C bus IO.Interfaces.I2C.Bus bus; if (IO.Remote.mikroBUS.Shield.I2CBus is null) { bus = remdev.I2C_Create(S.I2CBus); } else { bus = IO.Remote.mikroBUS.Shield.I2CBus; } // Configure the MCP23017 mydev = new IO.Devices.MCP23017.Device(bus, addr); }
/// <summary> /// Constructor for a single 7seg click. /// </summary> /// <param name="socket">mikroBUS socket number.</param> /// <param name="radix">Numerical base or radix. Allowed values are /// <c>Decimal</c> and <c>Hexadecimal</c>.</param> /// <param name="blanking">Zero blanking. Allowed values are /// <c>None</c>, <c>Leading</c>, and <c>Full</c>.</param> /// <param name="pwmfreq">PWM frequency. Set to zero to use GPIO /// instead of PWM.</param> public Board(int socket, Base radix = Base.Decimal, ZeroBlanking blanking = ZeroBlanking.None, int pwmfreq = 100) { IO.Objects.libsimpleio.mikroBUS.Socket S = new IO.Objects.libsimpleio.mikroBUS.Socket(socket); // Configure RST pin myRSTgpio = new IO.Objects.libsimpleio.GPIO.Pin(S.RST, IO.Interfaces.GPIO.Direction.Output, true); // Configure PWM pin -- Prefer PWM over GPIO, if possible, and // assume full brightness until otherwise changed. myPWMgpio = null; myPWMout = null; if ((pwmfreq > 0) && (S.PWMOut.available)) { myPWMout = new IO.Objects.libsimpleio.PWM.Output(S.PWMOut, pwmfreq, 100.0); } else if (S.PWM.available) { myPWMgpio = new IO.Objects.libsimpleio.GPIO.Pin(S.PWM, IO.Interfaces.GPIO.Direction.Output, true); } // Configure 74HC595 shift register chain mychain = new SN74HC595.Device(new IO.Objects.libsimpleio.SPI.Device(S.SPIDev, IO.Devices.SN74HC595.Device.SPI_Mode, 8, IO.Devices.SN74HC595.Device.SPI_MaxFreq, S.CS.available ? new IO.Objects.libsimpleio.GPIO.Pin(S.CS, IO.Interfaces.GPIO.Direction.Output, true) : null), 2); mybase = radix; myblanking = blanking; Clear(); }
/// <summary> /// Constructor for a single ADAC click. /// </summary> /// <param name="socknum">mikroBUS socket number.</param> /// <param name="addr">I<sup>2</sup>C slave address.</param> public Board(int socknum, int addr = DefaultAddress) { IO.Objects.libsimpleio.mikroBUS.Socket S = new IO.Objects.libsimpleio.mikroBUS.Socket(socknum); // Configure hardware reset GPIO pin myrst = new IO.Objects.libsimpleio.GPIO.Pin(S.RST, IO.Interfaces.GPIO.Direction.Output, true); // Issue hardware reset Reset(); // Configure I2C bus IO.Interfaces.I2C.Bus bus; if (IO.Objects.libsimpleio.mikroBUS.Shield.I2CBus is null) { bus = new IO.Objects.libsimpleio.I2C.Bus(S.I2CBus); } else { bus = IO.Objects.libsimpleio.mikroBUS.Shield.I2CBus; } // Configure AD5593R mydev = new IO.Devices.AD5593R.Device(bus, addr); // The ADAC click is wired for 0-5.0V on both ADC and DAC mydev.ADC_Reference = IO.Devices.AD5593R.ReferenceMode.Internalx2; mydev.DAC_Reference = IO.Devices.AD5593R.ReferenceMode.Internalx2; }
/// <summary> /// Constructor for a single Expand 2 click. /// </summary> /// <param name="socknum">mikroBUS socket number.</param> public Board(int socknum) { // Create a mikroBUS socket object IO.Objects.libsimpleio.mikroBUS.Socket S = new IO.Objects.libsimpleio.mikroBUS.Socket(socknum); // Configure hardware reset GPIO pin myrst = new IO.Objects.libsimpleio.GPIO.Pin(S.RST, IO.Interfaces.GPIO.Direction.Output, true); // Issue hardware reset Reset(); // Create MCP23S17 device object mydev = new IO.Devices.MCP23S17.Device( new IO.Objects.libsimpleio.SPI.Device(S.SPIDev, IO.Devices.MCP23S17.Device.SPI_Mode, IO.Devices.MCP23S17.Device.SPI_WordSize, IO.Devices.MCP23S17.Device.SPI_Frequency)); }