コード例 #1
0
ファイル: ULA.cs プロジェクト: m4k3r-org/ZxSpectrumSimulator
        /// <summary>
        /// Power On
        /// </summary>
        public ULA()
        {
            _cpuCLK = SignalState.LOW;
            _cpuINT = SignalState.HIGH;

            Address = new BusConnector <ushort>();
            Data    = new BusConnector <byte>();

            VideoAddress = new BusConnector <ushort>();
            VideoData    = new BusConnector <byte>();

            _videoMREQ = SignalState.HIGH;
            _videoRD   = SignalState.HIGH;

            ColorSignal = new AnalogOutputPin <byte>(0);
            _hSync      = SignalState.HIGH;
            _vSync      = SignalState.HIGH;

            KeyboardData = new BusConnector <byte>();
            _keyboardRD  = SignalState.HIGH;

            SpeakerSoundSignal = new AnalogOutputPin <byte>(0);
            _soundSampleCLK    = SignalState.HIGH;

            TapeInputSignal = new AnalogInputPin <byte>();
            TapeOuputSignal = new AnalogOutputPin <byte>(0);
        }
コード例 #2
0
        public static void Run()
        {
            var scope = new DebugScope();
            //scope.UpdatePeriod.Value = 1;

            var accel = new Memsic2125();

            accel.XPwmInput.ConnectTo(new DigitalInputPin(Pins.GPIO_PIN_D6).Output);
            accel.YPwmInput.ConnectTo(new DigitalInputPin(Pins.GPIO_PIN_D7).Output);
            scope.ConnectTo(accel.XAccelerationOutput);
            scope.ConnectTo(accel.YAccelerationOutput);

            var compass = new Grove3AxisDigitalCompass();

            scope.ConnectTo(compass.XGaussOutput);
            scope.ConnectTo(compass.YGaussOutput);
            scope.ConnectTo(compass.ZGaussOutput);

            var a0 = new AnalogInputPin(AnalogChannels.ANALOG_PIN_A0);

            scope.ConnectTo(a0.Analog);

            var sharp = new SharpGP2D12();

            a0.Analog.ConnectTo(sharp.AnalogInput);
            scope.ConnectTo(sharp.DistanceOutput);

            var therm = new Thermistor();

            therm.AnalogInput.ConnectTo(a0.Analog);
            scope.ConnectTo(therm.Temperature);

            var b = new CelsiusToFahrenheit();

            therm.Temperature.ConnectTo(b.Celsius);
            scope.ConnectTo(b.Fahrenheit);


            var bmp = new Bmp085();

            scope.ConnectTo(bmp.Temperature);

            var b2 = new CelsiusToFahrenheit();

            bmp.Temperature.ConnectTo(b2.Celsius);
            scope.ConnectTo(b2.Fahrenheit);


            for (; ;)
            {
                Debug.Print("Tick");
                Thread.Sleep(1000);
            }
        }
コード例 #3
0
        /// <summary>
        /// Power On
        /// </summary>
        public Screen()
        {
            ColorSignal = new AnalogInputPin <byte>();

            // To help unit tests, we pretend that the screen is already
            // synchronized with the ULA during the first frame
            Line           = 56;
            Column         = 32 /* Offset : because of the time necessary to read the first pixels in video memory, color output begins only 13 cycles after the master counter */ - 13 /* Offset : C0 is directly used to drive CPU clock, but CPU T state starts with High state while ULA counter should start with C0 low */ + 1;
            BlankingPeriod = false;

            // Initialize black screen
            Display = new byte[WIDTH * HEIGHT / 2];
            internalDisplayIndex = (Line * WIDTH + Column) / 2;
        }
コード例 #4
0
        /// <summary>
        /// Power On
        /// </summary>
        public Screen()
        {
            ColorSignal = new AnalogInputPin<byte>();

            // To help unit tests, we pretend that the screen is already
            // synchronized with the ULA during the first frame
            Line = 56;
            Column = 32 /* Offset : because of the time necessary to read the first pixels in video memory, color output begins only 13 cycles after the master counter */ - 13 /* Offset : C0 is directly used to drive CPU clock, but CPU T state starts with High state while ULA counter should start with C0 low */ + 1;
            BlankingPeriod = false;

            // Initialize black screen
            Display = new byte[WIDTH * HEIGHT / 2];
            internalDisplayIndex = (Line * WIDTH + Column) / 2;
        }
コード例 #5
0
 public Speaker()
 {
     SoundSignal = new AnalogInputPin<byte>();
 }
コード例 #6
0
 /// <summary>
 /// Creates an instance.
 /// </summary>
 /// <param name="pin">The ADC input pin to be read by this object.</param>
 public AnalogAdcInput(AnalogInputPin pin)
 {
     _channel = AdcController.GetDefault().OpenChannel((int)pin);
 }
コード例 #7
0
        /// <summary>
        /// Power On
        /// </summary>
        public ULA()
        {
            _cpuCLK = SignalState.LOW;
            _cpuINT = SignalState.HIGH;

            Address = new BusConnector<ushort>();
            Data = new BusConnector<byte>();

            VideoAddress = new BusConnector<ushort>();
            VideoData = new BusConnector<byte>();

            _videoMREQ = SignalState.HIGH;
            _videoRD = SignalState.HIGH;

            ColorSignal = new AnalogOutputPin<byte>(0);
            _hSync = SignalState.HIGH;
            _vSync = SignalState.HIGH;

            KeyboardData = new BusConnector<byte>();
            _keyboardRD = SignalState.HIGH;

            SpeakerSoundSignal = new AnalogOutputPin<byte>(0);
            _soundSampleCLK = SignalState.HIGH;

            TapeInputSignal = new AnalogInputPin<byte>();
            TapeOuputSignal = new AnalogOutputPin<byte>(0);
        }
コード例 #8
0
        public static void Run()
        {
            //
            // Start with the basic robot
            //
            var leftMotor  = HBridgeMotor.CreateForNetduino(PWMChannels.PWM_PIN_D3, Pins.GPIO_PIN_D1, Pins.GPIO_PIN_D2);
            var rightMotor = HBridgeMotor.CreateForNetduino(PWMChannels.PWM_PIN_D6, Pins.GPIO_PIN_D4, Pins.GPIO_PIN_D5);
            var robot      = new TwoWheeledRobot(leftMotor, rightMotor);

            //
            // Create a range finder and scope it
            //
            var scope = new DebugScope();
            var a0    = new AnalogInputPin(AnalogChannels.ANALOG_PIN_A0, 10);

            scope.ConnectTo(a0.Analog);
            var sharp = new SharpGP2D12();

            a0.Analog.ConnectTo(sharp.AnalogInput);
            scope.ConnectTo(sharp.DistanceOutput);
            scope.ConnectTo(robot.SpeedInput);

            //
            // This is the cruising (unobstructed) speed
            //
            var distanceToSpeed = new Transform(distance => {
                const double min = 0.1;
                const double max = 0.5;
                if (distance > max)
                {
                    return(1.0);
                }
                else if (distance < min)
                {
                    return(0.0);
                }
                return((distance - min) / (max - min));
            });

            distanceToSpeed.Input.ConnectTo(sharp.DistanceOutput);

            //
            // Take different actions depending on our environment:
            //   0: cruising
            //   1: collided
            //
            var sw = new Switch(
                new [] {
                new Connection(distanceToSpeed.Output, robot.SpeedInput),
                new Connection(new SineWave(0.5, 0.333, 0, updateFrequency: 10).Output, robot.DirectionInput),
                new Connection(new Constant(0).Output, robot.SpinInput),
            },
                new[] {
                new Connection(new Constant(0.6).Output, robot.SpinInput),
                new Connection(new Constant(0).Output, robot.DirectionInput),
                new Connection(new Constant(0).Output, robot.SpeedInput),
            });

            var collided = new Transform(distance => distance < 0.2 ? 1 : 0);

            collided.Input.ConnectTo(sharp.DistanceOutput);
            collided.Output.ConnectTo(sw.Input);

            //
            // Loop to keep us alive
            //
            for (; ;)
            {
                //Debug.Print ("TwoWheeled Tick");

                Thread.Sleep(1000);
            }
        }
コード例 #9
0
 public Speaker()
 {
     SoundSignal = new AnalogInputPin <byte>();
 }
コード例 #10
0
 public override void ClosePin(AnalogInputPin pin)
 {
     _board.Firmata.DisableAnalogReporting(pin.PinNumber);
 }
コード例 #11
0
 new public void Setup()
 {
     _pin = new AnalogInputPin(1, _mockParent.Object, 0, 200);
 }
コード例 #12
0
 public void Setup()
 {
     _mockParent = new Mock <IAnalogInputDevice>(MockBehavior.Strict);
     _pin        = new AnalogInputPin(1, _mockParent.Object);
 }