本文整理汇总了C#中Microsoft.SPOT.Hardware.Cpu类的典型用法代码示例。如果您正苦于以下问题:C# Cpu类的具体用法?C# Cpu怎么用?C# Cpu使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Cpu类属于Microsoft.SPOT.Hardware命名空间,在下文中一共展示了Cpu类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LEDStrip
public LEDStrip(Cpu.Pin clockPin, Cpu.Pin dataPin)
{
NumOfLEDs = 32;
_clock = new OutputPort(clockPin, false);
_data = new OutputPort(dataPin, false);
post_frame();
}
示例2: ShiftRegister74HC595
private OutputPort stcpPort; // Storage Register Clock pin
#endregion Fields
#region Constructors
/// <summary>
/// Constructor
/// </summary>
/// <param name="ds">Pin Serial Data</param>
/// <param name="shcp">Pin Shift Register Clock</param>
/// <param name="stcp">Pin Storage Register Clock</param>
/// <param name="mr">Pin Master Reset</param>
/// <param name="oe">Pin Output Enable</param>
/// <param name="bitOrder">Bit order during transferring</param>
public ShiftRegister74HC595(Cpu.Pin ds, Cpu.Pin shcp, Cpu.Pin stcp, Cpu.Pin mr, Cpu.Pin oe, BitOrder bitOrder)
{
// Serial Data (DS) pin is necessary
if (ds == Cpu.Pin.GPIO_NONE)
throw new ArgumentException("Serial Data (DS) pin is necessary");
this.dsPort = new OutputPort(ds, false);
// Shift Register Clock (SHCP) pin is necessary
if (shcp == Cpu.Pin.GPIO_NONE)
throw new ArgumentException("Shift Register Clock (SHCP) pin is necessary");
this.shcpPort = new OutputPort(shcp, false);
// you can save 1 pin connecting STCP and SHCP together
if (stcp != Cpu.Pin.GPIO_NONE)
this.stcpPort = new OutputPort(stcp, false);
// you can save 1 pin connecting MR pin to Vcc (no reset)
if (mr != Cpu.Pin.GPIO_NONE)
this.mrPort = new OutputPort(mr, true);
// you can save 1 pin connecting OE pin to GND (shift register output pins are always enabled)
if (oe != Cpu.Pin.GPIO_NONE)
this.oePort = new OutputPort(oe, false);
this.bitOrder = bitOrder;
}
示例3: RelayPort
public RelayPort(Cpu.Pin pin, bool initialState, int timeout)
: base(pin, initialState)
{
currentstate = initialState;
relayThread = new Thread(new ThreadStart(RelayLoop));
relayThread.Start();
}
示例4: LEDRGB
/// <summary>
/// LEDRGB Constructor.
/// </summary>
/// <param name="r">Red LED PWM channel</param>
/// <param name="g">Green LED PWM channel</param>
/// <param name="b">Blkue LED PWM channel</param>
public LEDRGB(Cpu.PWMChannel r, Cpu.PWMChannel g, Cpu.PWMChannel b)
{
red = new PWM(r, 255, 0, PWM.ScaleFactor.Microseconds, false);
green = new PWM(g, 255, 0, PWM.ScaleFactor.Microseconds, false);
blue = new PWM(b, 255, 0, PWM.ScaleFactor.Microseconds, false);
color = new RGBColor(0, 0, 0);
}
示例5: OLED_sh1106
public OLED_sh1106(Cpu.Pin csPin, OutputPort dcPin, OutputPort rsPin)
{
displayStr = "";
spiDevice = new SPI(new SPI.Configuration(csPin, false, 0, 0, false, true, 10000, SPI.SPI_module.SPI1));
dataCommandPin = dcPin;
resetOutputPort = rsPin;
}
示例6: GetSerialPins
public override void GetSerialPins(string comPort, out Cpu.Pin rxPin, out Cpu.Pin txPin, out Cpu.Pin ctsPin, out Cpu.Pin rtsPin)
{
switch (comPort)
{
case "COM1":
rxPin = Pins.P6_5;
txPin = Pins.P6_4;
ctsPin = Pins.GPIO_NONE;
rtsPin = Pins.GPIO_NONE;
break;
case "COM2":
rxPin = Pins.P1_14;
txPin = Pins.P5_6;
ctsPin = Pins.P5_4;
rtsPin = Pins.P4_2;
break;
case "COM3":
rxPin = Pins.P2_11;
txPin = Pins.P2_10;
ctsPin = Pins.GPIO_NONE;
rtsPin = Pins.GPIO_NONE;
break;
default:
throw new NotSupportedException();
}
}
示例7: MidiDriver
public MidiDriver(Cpu.Pin resetPin, string serialPortName = Serial.COM2)
{
_resetPinPort = new OutputPort(resetPin, false);
_serialPort = new SerialPort(serialPortName, 31250, Parity.None, 8, StopBits.One);
_serialPort.Open();
}
示例8: Start
public static TempSensor Start(Cpu.Pin pin, int sampleInterval = 1000, TempSensorMode mode = TempSensorMode.Celcius)
{
TempSensor sensor = new TempSensor(pin, sampleInterval, mode);
sensor._thread = new Thread(sensor.Run);
sensor._thread.Start();
return sensor;
}
示例9: ShiftRegisterWriter
//private OutputPort _commitPin;
public ShiftRegisterWriter(Cpu.Pin clock, Cpu.Pin reset, Cpu.Pin data, Cpu.Pin commit)
{
_clockPin = new OutputPort(clock, false);
_dataPin = new OutputPort(data, false);
_resetPin = new OutputPort(reset, false);
_commitPin = new OutputPort(commit, false);
}
示例10: RGBLed
/// <summary>
/// Common RGB-led
/// </summary>
/// <param name="RedPin">The PWM-pin connected to Red</param>
/// <param name="GreenPin">The PWM-pin connected to Green</param>
/// <param name="BluePin">The PWM-pin connected to Blue</param>
/// <param name="CommonAnode">Specifies if the led is common anode</param>
public RGBLed(Cpu.Pin RedPin, Cpu.Pin GreenPin, Cpu.Pin BluePin, bool CommonAnode = true)
{
this._Red = new PWM(RedPin);
this._Green = new PWM(GreenPin);
this._Blue = new PWM(BluePin);
this._CommonAnode = CommonAnode;
}
示例11: PanTilter
public PanTilter(Cpu.Pin panPin, int panMin, int panMax, Cpu.Pin tiltPin, int tiltMin, int tiltMax)
{
this.tilter = new PWM(tiltPin);
this.tiltMin = tiltMin;
this.tiltMax = tiltMax;
this.tilter.SetDutyCycle(0);
}
示例12: ContactSensor
public ContactSensor(Cpu.Pin sensorPin)
{
this.sensorPin = sensorPin;
sensorPort = new InterruptPort(sensorPin, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLevelLow);
sensorPort.OnInterrupt += new NativeEventHandler(OnInterrupt);
}
示例13: Stepper
public Stepper(Cpu.Pin pinCoil1A, Cpu.Pin pinCoil1B, Cpu.Pin pinCoil2A, Cpu.Pin pinCoil2B, uint stepsPerRevolution, string name)
: base(name, "stepper")
{
// remember the steps per revolution
this.StepsPerRevolution = stepsPerRevolution;
// reset the step-counter
this.currentStep = 0;
// determine correct pins for the coils; turn off all motor pins
this.portCoil1A = new OutputPort(pinCoil1A, false);
Util.Delay(500);
this.portCoil1B = new OutputPort(pinCoil1B, false);
Util.Delay(500);
this.portCoil2A = new OutputPort(pinCoil2A, false);
Util.Delay(500);
this.portCoil2B = new OutputPort(pinCoil2B, false);
// set the maximum speed
SetSpeed(120);
}
示例14: Connect
public void Connect(Cpu.Pin pinTrig, Cpu.Pin pinEcho)
{
_portOut = new OutputPort(pinTrig, false);
_interIn = new InterruptPort(pinEcho, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeLow);
_interIn.OnInterrupt += new NativeEventHandler(interIn_OnInterrupt);
Reset();
}
示例15: Piezo
/// <summary>
/// Piezo speaker driver and notes and playback manager
/// </summary>
/// <param name="pin">From the SecretLabs.NETMF.Hardware.NetduinoPlus.PWMChannels namespace</param>
/// <param name="name">Unique identifying name for command and control</param>
public Piezo(Cpu.PWMChannel pin, string name)
: base(name, "piezo")
{
//_piezo = new PWM(pin, 2048, 0, PWM.ScaleFactor.Milliseconds, false);
_piezo = new PWM(pin, 2048, 0, false);
_piezo.Start();
}