Esempio n. 1
0
        /// <summary>Clears all relays.</summary>
        public void DisableAllRelays()
        {
            regData = 0;
            ushort reg = (ushort)regData;

            for (int i = 0; i < 16; i++)
            {
                if ((reg & 0x1) == 1)
                {
                    data.Write(false);
                }
                else
                {
                    data.Write(true);
                }

                clock.Write(true);
                clock.Write(false);

                reg >>= 1;
            }

            latch.Write(true);
            latch.Write(false);
        }
Esempio n. 2
0
 private void SetSpeed(GTI.PwmOutput motor, GTI.DigitalOutput direction, int speed, bool isLeft)
 {
     if (speed == 0)
     {
         direction.Write(false);
         motor.Set(FEZCerbot.MOTOR_BASE_FREQUENCY, 0.01);
     }
     else if (speed < 0)
     {
         direction.Write(isLeft ? true : false);
         motor.Set(FEZCerbot.MOTOR_BASE_FREQUENCY, speed / -100.0);
     }
     else
     {
         direction.Write(isLeft ? false : true);
         motor.Set(FEZCerbot.MOTOR_BASE_FREQUENCY, speed / 100.0);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Renders Bitmap data on the display device.
 /// </summary>
 /// <param name="bitmap">The <see cref="T:Microsoft.SPOT.Bitmap"/> object to render on the display.</param>
 protected override void Paint(Bitmap bitmap, int x, int y, int width, int height)
 {
     try
     {
         if (Mainboard.NativeBitmapCopyToSpi != null)
         {
             SetClippingArea(0, 0, bitmap.Width - 1, bitmap.Height - 1);
             WriteCommand(0x2C);
             pinDC.Write(true);
             Mainboard.NativeBitmapCopyToSpi(bitmap, netMFSpiConfig, 0, 0, bitmap.Width, bitmap.Height, GT.Mainboard.BPP.BPP16_BGR_BE);
         }
         else
         {
             Draw(bitmap);
         }
     }
     catch
     {
         ErrorPrint("Painting error");
     }
 }
Esempio n. 4
0
        private uint ReadData()
        {
            int  bitCount;
            uint data = 0;

            _cs.Write(false);
            {
                for (bitCount = 31; bitCount >= 0; bitCount--)
                {
                    _clk.Write(true);

                    if (_miso.Read())
                    {
                        data |= (uint)(1 << bitCount);
                    }

                    _clk.Write(false);
                }
            }
            _cs.Write(true);

            return(data);
        }
Esempio n. 5
0
        /// <summary>
        ///   Executes a command
        /// </summary>
        /// <param name = "command">Command</param>
        /// <param name = "address">Register to write to</param>
        /// <param name = "data">Data to write</param>
        /// <returns>Response byte array. First byte is the status register</returns>
        public byte[] WriteBlock(byte command, byte address, byte[] data)
        {
            CheckIsInitialized();

            _csPin.Write(false);

            // Create SPI Buffers with Size of Data + 1 (For Command)
            var writeBuffer = new byte[data.Length + 1];
            var readBuffer  = new byte[data.Length + 1];

            // Add command and address to SPI buffer
            writeBuffer[0] = (byte)(command | address);

            // Add data to SPI buffer
            Array.Copy(data, 0, writeBuffer, 1, data.Length);

            // Do SPI Read/Write
            _spi.WriteRead(writeBuffer, readBuffer);

            _csPin.Write(true);

            // Return ReadBuffer
            return(readBuffer);
        }
Esempio n. 6
0
 private void Reset()
 {
     pinReset.Write(false);
     Thread.Sleep(150);
     pinReset.Write(true);
 }
Esempio n. 7
0
 /// <summary>
 /// Enables or disables the display backlight.
 /// </summary>
 /// <param name="state">The state to set the backlight to.</param>
 public void SetBacklight(bool state)
 {
     pinBacklight.Write(state);
 }
Esempio n. 8
0
 private void clock(bool a) {
     Thread.Sleep(1);
     _sck.Write(a);
    
 }
Esempio n. 9
0
 /// <summary>
 /// Turns on the module's LED.
 /// </summary>
 public void TurnLEDOn()
 {
     led.Write(true);
 }
Esempio n. 10
0
 /// <summary>
 /// Enables the outputs to the relays.
 /// </summary>
 private void EnableOutputs()
 {
     enable.Write(false);
 }