示例#1
0
        int valoreProporzionaleBotola; //Valore proporzionale asseganto alla botola.

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Costruttore
        /// </summary>
        /// <param name="pwm1">pwm1</param>
        /// <param name="pwm2">pwm2</param>
        /// <param name="pinApertura">pin perl' apertura</param>
        /// <param name="pinChiusura">pin per la chiusura</param>
        public Botola(FEZ_Pin.PWM pwm1, FEZ_Pin.PWM pwm2, FEZ_Pin.Digital pinApertura, FEZ_Pin.Digital pinChiusura)
        {
            open = new InputPort((Cpu.Pin)pinApertura, true, Port.ResistorMode.PullUp);     //Creazione porta per l' apertura.
            close = new InputPort((Cpu.Pin)pinChiusura, true, Port.ResistorMode.PullUp);    //Creazione porta per la chiusura.
            pwm5 = new PWM((PWM.Pin)pwm1);  //Creazione porta pwm.
            pwm6 = new PWM((PWM.Pin)pwm2);  //Creazione porta pwm.
        }
示例#2
0
 /// <summary>
 /// Creates an instance of the driver, that only lets you move, choose direction, sleep, and select step mode
 /// </summary>
 /// <param name="DirectionPin">a digital pint that is used for direction</param>
 /// <param name="StepPin">a digital pint that is used for steps</param>
 /// <param name="SleepPin">a digital pint that is used for sleep function</param>
 /// <param name="StepModePinOne">pin one used to change step mode</param>
 /// <param name="StepModePinTwo">pin two used to change step mode</param>
 public EasyStepperDriver(FEZ_Pin.Digital DirectionPin, FEZ_Pin.Digital StepPin, FEZ_Pin.Digital SleepPin, FEZ_Pin.Digital StepModePinOne, FEZ_Pin.Digital StepModePinTwo)
 {
     _DirectionPin = new OutputPort((Cpu.Pin)DirectionPin, false);
     _StepPin = new OutputPort((Cpu.Pin)StepPin, false);
     _SleepPin = new OutputPort((Cpu.Pin)SleepPin, false);
     _StepModePinOne = new OutputPort((Cpu.Pin)StepModePinOne, true);
     _StepModePinTwo = new OutputPort((Cpu.Pin)StepModePinTwo, true);
 }
示例#3
0
        /// <summary>
        /// Costruttore
        /// </summary>
        /// <param name="encPin">pin dell' encoder</param>
        public Encoder(FEZ_Pin.Interrupt encPin)
        {
            //Dichiarazione e creazione dell'encoder.
            Encoder = new InterruptPort((Cpu.Pin)encPin, true,
            Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeLow);

            //Abilita l'interrupt sul pin del segnale tachimetrico
            Encoder.OnInterrupt += Encoder_OnInterrupt;
        }
 public ReflectiveSensor(FEZ_Pin.AnalogIn pin, int reflection_detection_trigger_percentage)
 {
     adc = new AnalogIn((AnalogIn.Pin)pin);
     adc.SetLinearScale(0, 100);
     if (reflection_detection_trigger_percentage < 100 && reflection_detection_trigger_percentage >= 0)
         trigger_level = reflection_detection_trigger_percentage;
     else
         throw new Exception("You must enter a percentage value betweeon 0 and 100");
 }
示例#5
0
        public Switch(string switchName, FEZ_Pin.Interrupt IOport, string downScript, string upScript, Port.InterruptMode ActivateState)
        {
            SwitchName = switchName;
            IOPort = IOport;
            DownScript = downScript;
            UpScript = upScript;

            InterruptPort IntButton = new InterruptPort((Cpu.Pin)IOPort, false, Port.ResistorMode.PullUp, ActivateState);
            IntButton.OnInterrupt += new NativeEventHandler(this.Press);
        }
示例#6
0
        public Encoder(FEZ_Pin.Digital pin)
        {
            //encoder = new InterruptPort((Cpu.Pin)pin, true, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeHigh);
            //encoder.OnInterrupt += new NativeEventHandler(encoder_OnInterrupt);
            encoder = new InputPort((Cpu.Pin)pin, true, Port.ResistorMode.PullDown);
            stepmm = GlobalVal.wheelPerimeter_mm / GlobalVal.interruptsWheel;
            this.resetDistance();

            Thread th = new Thread(new ThreadStart(this.Run));
            th.Start();
        }
示例#7
0
        public SpiFloorIndicator(SPI.SPI_module module, FEZ_Pin.Digital latchPin)
        {
            var config = new SPI.Configuration(Cpu.Pin.GPIO_NONE, false, 0, 0, false, true, 200, module);
            spi = new SPI(config);

            latch = new OutputPort((Cpu.Pin) latchPin, true);

            CurrentFloor = 1;

            timer = new ExtendedTimer(UpdateIndicator, null, DateTime.Now,
                TimeSpan.FromTicks(25 * TimeSpan.TicksPerMillisecond));
        }
示例#8
0
                /// <summary>
                /// Create a new instance of <see cref="LCDConfiguration"/>
                /// </summary>
                /// <param name="reset"></param>
                /// <param name="chipSelect"></param>
                /// <param name="RS"></param>
                /// <param name="backLight"></param>
                /// <param name="dataPins"></param>
                /// <param name="writePin"></param>
                /// <param name="readPin"></param>
                public LCDConfiguration(FEZ_Pin.Digital reset, FEZ_Pin.Digital chipSelect, FEZ_Pin.Digital RS, FEZ_Pin.Digital backLight, FEZ_Pin.Digital[] dataPins, FEZ_Pin.Digital writePin, FEZ_Pin.Digital readPin)
                {
                    this.dataPins = new Cpu.Pin[8];
                    for (int i = 0; i < 8; i++)
                        this.dataPins[i] = (Cpu.Pin)dataPins[i];

                    this.writePin = (Cpu.Pin)writePin;
                    this.readPin = (Cpu.Pin)readPin;
                    this.chipSelect = (Cpu.Pin)chipSelect;
                    this.reset = (Cpu.Pin)reset;
                    this.RS = (Cpu.Pin)RS;
                    this.backLight = (Cpu.Pin)backLight;
                }
示例#9
0
 public LCD2x16( FEZ_Pin.Digital bit0,
   FEZ_Pin.Digital bit1, 
   FEZ_Pin.Digital bit2, 
   FEZ_Pin.Digital bit3, 
   FEZ_Pin.Digital enable, 
   FEZ_Pin.Digital registerSelect)
 {
     _LCDRegisterSelect = new OutputPort((Cpu.Pin)registerSelect, false);
     _LCDEnable = new OutputPort((Cpu.Pin)enable, false);
     _LCDBit0 = new OutputPort((Cpu.Pin)bit0, false);
     _LCDBit1 = new OutputPort((Cpu.Pin)bit1, false);
     _LCDBit2 = new OutputPort((Cpu.Pin)bit2, false);
     _LCDBit3 = new OutputPort((Cpu.Pin)bit3, false);
     _LCDRegisterSelect.Write(false);
     //Comunicazione a 4 bit.
     Thread.Sleep(50);
     _LCDBit3.Write(false);
     _LCDBit2.Write(false);
     _LCDBit1.Write(true);
     _LCDBit0.Write(true);
     _LCDEnable.Write(true);
     _LCDEnable.Write(false);
     Thread.Sleep(50);
     _LCDBit3.Write(false);
     _LCDBit2.Write(false);
     _LCDBit1.Write(true);
     _LCDBit0.Write(true);
     _LCDEnable.Write(true);
     _LCDEnable.Write(false);
     Thread.Sleep(50);
     _LCDBit3.Write(false);
     _LCDBit2.Write(false);
     _LCDBit1.Write(true);
     _LCDBit0.Write(true);
     _LCDEnable.Write(true);
     _LCDEnable.Write(false);
     Thread.Sleep(50);
     _LCDBit3.Write(false);
     _LCDBit2.Write(false);
     _LCDBit1.Write(true);
     _LCDBit0.Write(false);
     _LCDEnable.Write(true);
     _LCDEnable.Write(false);
     SendCmd(DISP_ON);
     SendCmd(CLR_DISP);
 }
示例#10
0
        public DistanceDetector(FEZ_Pin.AnalogIn pin, SharpSensorType type)
        {
            adc = new AnalogIn((AnalogIn.Pin)pin);
            adc.SetLinearScale(0, 330);
            switch (type)
            {
                case SharpSensorType.GP2Y0A21YK:
                    Y0 = 10;
                    X0 = 315;
                    Y1 = 80;
                    X1 = 30;
                    break;

                case SharpSensorType.GP2D120:
                    Y0 = 3;
                    X0 = 315;
                    Y1 = 30;
                    X1 = 30;
                    break;
            }
            C = (Y1 - Y0) / (1 / X1 - 1 / X0);
        }
 public LED(FEZ_Pin.Digital pin)
 {
     led = new OutputPort((Cpu.Pin)pin, true);
     timer = new Timer(Callback, null, Timeout.Infinite, Timeout.Infinite);
     State = false;
 }
 public DCMotor(PWM.Pin pwmPin, FEZ_Pin.Digital dirPin1, FEZ_Pin.Digital dirPin2)
 {
     _pwm = new PWM(pwmPin);
     _dir1 = new OutputPort((Cpu.Pin)dirPin1, false);
     _dir2 = new OutputPort((Cpu.Pin)dirPin2, false);
 }
示例#13
0
 public Lamp(string name, FEZ_Pin.Digital IOport)
 {
     Name = name;
     IOPort = IOport;
     LED = new OutputPort((Cpu.Pin)IOPort, false);
 }
示例#14
0
 public Button(FEZ_Pin.Interrupt pin)
 {
     button = new InterruptPort((Cpu.Pin)pin, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);
     button.OnInterrupt += new NativeEventHandler(OnInterrupt);
 }
示例#15
0
 public SerialAudioZone(AudioControllerCoordinator coord, byte address, FEZ_Pin.Digital isPlayingPin)
 {
     this.coord = coord;
     this.address = address;
     isPlaying = new InputPort((Cpu.Pin)isPlayingPin, false, Port.ResistorMode.Disabled);
 }
示例#16
0
 public Button(FEZ_Pin.Digital pin, Port.ResistorMode mode = Port.ResistorMode.PullUp)
 {
     interrupt = new InputPort((Cpu.Pin) pin, false, mode);
     thread  = new Thread(Run);
     thread.Start();
 }
 public Button(FEZ_Pin.Interrupt pin)
 {
     InnerPort = new InputPort((Cpu.Pin)pin, true, Port.ResistorMode.PullUp);
 }
 public NativeUSSensor(FEZ_Pin.Digital pin)
 {
     InnerPort = new TristatePort((Cpu.Pin)pin, false, false, Port.ResistorMode.PullDown);
 }
 public LightGate(FEZ_Pin.AnalogIn pin, int threshold)
 {
     InnerPort = new AnalogIn((AnalogIn.Pin)pin);
     Threshold = threshold;
 }
示例#20
0
 public Servo(FEZ_Pin.PWM pin)
 {
     pwm = new PWM((PWM.Pin)pin);
 }
示例#21
0
 /// <summary>
 /// Costruttore
 /// </summary>
 /// <param name="pinVentola">Pin della ventola</param>
 /// <param name="pinAperturaBotola">Pin per l'apertura</param>
 /// <param name="pinChiusuraBotola">Pin per la chiusura</param>
 /// <param name="pwmBotola1">Pin pwm</param>
 /// <param name="pwmBotola2">Pin pwm</param>
 /// <param name="pinEnc">Pin encoder</param>
 public Aerazione(FEZ_Pin.PWM pinVentola, FEZ_Pin.Digital pinAperturaBotola, FEZ_Pin.Digital pinChiusuraBotola, FEZ_Pin.PWM pwmBotola1, FEZ_Pin.PWM pwmBotola2,FEZ_Pin.Interrupt pinEnc)
 {
     v = new Ventola(pinVentola); //Creazione oggetto ventola e passaggio porta.
     b = new Botola(pwmBotola1, pwmBotola2, pinAperturaBotola, pinChiusuraBotola); //Creazione oggetto botala e passaggio porte.
     e = new Encoder(pinEnc); //Creazione oggetto encoder e passaggio porta.
 }
示例#22
0
文件: FEZ.cs 项目: Vanaheimr/Nyi
 /// <summary>
 /// Creates a new LED attached to a digital pin on FEZ hardware.
 /// </summary>
 /// <param name="Pin">The digital CPU pin.</param>
 /// <param name="InitialState">The optional initial state of the LED.</param>
 /// <returns>A new LED object.</returns>
 public static LED New(FEZ_Pin.Digital Pin, Boolean InitialState = false)
 {
     return new LED((Cpu.Pin)Pin, LEDType.DigitalPin, InitialState);
 }
示例#23
0
 public Piezo(FEZ_Pin.PWM pin)
 {
     pwm = new PWM((PWM.Pin)pin);
 }
示例#24
0
 public RelayPatriotLight(FEZ_Pin.Digital redPin, FEZ_Pin.Digital whitePin, FEZ_Pin.Digital bluePin)
 {
     red = new Relay(redPin);
     white = new Relay(whitePin);
     blue = new Relay(bluePin);
 }
示例#25
0
文件: PWMLED.cs 项目: Vanaheimr/Nyi
 public PWMLED(FEZ_Pin.PWM Pin, Boolean InitialState = false)
 {
     this.Fader = new PWM((PWM.Pin) Pin);
 }
示例#26
0
 public ServoMotor(FEZ_Pin.Digital pin)
 {
     oc = new OutputCompare((Cpu.Pin)pin, true, 5);
 }
 public NativeIRSensor(FEZ_Pin.Digital pin)
 {
     InnerPort = new InputPort((Cpu.Pin)pin, false, Port.ResistorMode.PullUp);
 }
示例#28
0
 public Button(FEZ_Pin.Digital pin)
 {
     button = new InputPort((Cpu.Pin)pin, false, Port.ResistorMode.PullUp);
 }
 public LEDGroup(FEZ_Pin.Digital purple, FEZ_Pin.Digital orange, FEZ_Pin.Digital green, FEZ_Pin.Digital white)
 {
     Purple = new LED(purple); //3.2-3.8V, 30mA => < 100 Ohms
     Orange = new LED(orange); //1.8-2.2V, 30mA => 37-50 ohms
     Green = new LED(green); //2.8-3V, 20mA => 15-25 ohms
     White = new LED(white); //3.5V, 20mA ????
 }
示例#30
0
 /// <summary>
 /// Creates an instance of the driver, that only lets you move, choose direction and put the controller to sleep
 /// </summary>
 /// <param name="DirectionPin">a digital pint that is used for direction</param>
 /// <param name="StepPin">a digital pint that is used for steps</param>
 /// <param name="SleepPin">a digital pint that is used for sleep function</param>
 public EasyStepperDriver(FEZ_Pin.Digital DirectionPin, FEZ_Pin.Digital StepPin, FEZ_Pin.Digital SleepPin)
 {
     _DirectionPin = new OutputPort((Cpu.Pin)DirectionPin, false);
     _StepPin = new OutputPort((Cpu.Pin)StepPin, false);
     _SleepPin = new OutputPort((Cpu.Pin)SleepPin, false);
 }