protected LedCube(IO60P16Module parentModule, byte size, IOPin[] levelPins, IOPin[] ledPins, CubeOrientations orientation = CubeOrientations.ZPos ) { _module = parentModule; Size = size; Orientation = orientation; Levels = new OutputPort[Size]; Leds = new OutputPort[Size*Size]; // Make sure we have the correct number of level pins. if(levelPins.Length != size) { throw new ArgumentOutOfRangeException("levelPins", "You must define " + Size + " level pins."); } // Make sure we have the correct number of LED pins. if (ledPins.Length != size * size) { throw new ArgumentOutOfRangeException("ledPins", "You must define " + Size*Size + " led pins."); } // Create level ports. for (byte lvl = 0; lvl < Size; lvl++ ) { Levels[lvl] = _module.CreateOutputPort(levelPins[lvl], false); } // Create LED ports. for (byte led = 0; led < Size*Size; led++) { Leds[led] = _module.CreateOutputPort(ledPins[led], false); } }
public InterruptPort(IO60P16Module parentModule, IOPin pin, ResistorMode resistorMode, InterruptMode interruptMode) : base(parentModule, pin) { Resistor = resistorMode; Interrupt = interruptMode; EnableInterrupt(); }
public PWM(IO60P16Module parentModule, PwmPin pin, double frequency_Hz, double dutyCycle, bool invertOutput) { _parentModule = parentModule; _pin = pin; _frequency = frequency_Hz; _dutyCycle = dutyCycle; _invertOutput = invertOutput; }
public PWM(IO60P16Module parentModule, PwmPin pin, uint period, uint duration, ScaleFactor scale, bool invertOutput) { _parentModule = parentModule; _pin = pin; _period_ns = period * (uint)scale; _duration_ns = duration * (uint)scale; _scale = scale; _invertOutput = invertOutput; }
/// <summary> /// Constructor. /// </summary> /// <param name="parentModule">The module to which this pin belongs.</param> /// <param name="pin">The pin ID that this object represents.</param> /// <param name="initialState">The initial state of the port.</param> public OutputPort(IO60P16Module parentModule, IOPin pin, bool initialState) : base(parentModule, pin) { ParentModule.SetDirection((IOPin)PinNumber, PinDirection.Output); Write(initialState); }
public LedCube3(IO60P16Module parentModule, byte size, IOPin[] levelPins, IOPin[] ledPins, CubeOrientations orientation = CubeOrientations.ZPos) : base(parentModule, size, levelPins, ledPins, orientation) { }
//private static LedCube3 _ledCube; // Create a function to replace .Start() private void SetPwm(IO60P16Module _parentModule, byte port, byte pin, byte period, byte pulseWidth, PWM.PwmClockSource clock, byte clockDivider = 0) { _parentModule.WriteRegister(0x18, port); // Select port var b = _parentModule.ReadRegister(0x1a)[0]; b |= (byte)((1 << pin)); _parentModule.WriteRegister(0x1a, b); // select PWM for port output b = _parentModule.ReadRegister(0x1C)[0]; b &= (byte)(~(1 << pin)); _parentModule.WriteRegister(0x1C, b); // Set pin for output. _parentModule.WriteRegister(0x28, (byte)(0x08 + pin)); // Select the PWM pin to configure. _parentModule.WriteRegister(0x29, (byte)clock); // Config PWM (select 32kHz clock source) if (clockDivider > 0) _parentModule.WriteRegister(0x2c, clockDivider); // Set the clock divider (if using 367.6 Hz clock) _parentModule.WriteRegister(0x2a, period); // set the period (0-256) _parentModule.WriteRegister(0x2b, pulseWidth); // set the pulse width (0-(period-1)) }
/// <summary> /// Constructor /// </summary> /// <param name="parentModule">The instance of the parent IO60P16 module to which this pin is contained.</param> /// <param name="pin">The pin being setup for input.</param> public InputPort(IO60P16Module parentModule, IOPin pin) : base(parentModule, pin) { ParentModule.SetDirection(pin, PinDirection.Input); }
/// <summary> /// Constructor. /// </summary> /// <param name="parentModule">The module to which this port belongs.</param> /// <param name="pin">The pin ID that this port represents.</param> /// <param name="resistorMode">The resistor mode to assign to the pin.</param> protected Port(IO60P16Module parentModule, IOPin pin, ResistorMode resistorMode) : this(parentModule, pin) { Resistor = resistorMode; }
/// <summary> /// Constructor. /// </summary> /// <param name="parentModule">The module to which this port belongs.</param> /// <param name="pin">The pin ID that this port represents.</param> protected Port(IO60P16Module parentModule, IOPin pin) { _parentModule = parentModule; _id = (byte)pin; }