Exemplo n.º 1
0
 /// <summary>
 /// Connect MCP3008 with clock, Serial Peripheral Interface(SPI) and channel
 /// </summary>
 /// <param name="adc_channel">MCP3008 channel number 0-7 (pin 1-8 on chip).</param>
 /// <param name="SPICLK">Clock pin</param>
 /// <param name="SPIMOSI">SPI Master Output, Slave Input (MOSI)</param>
 /// <param name="SPIMISO">SPI Master Input, Slave Output (MISO)</param>
 /// <param name="SPICS">SPI Chip Select</param>
 public MCP3008(int adc_channel, GPIO SPICLK, GPIO SPIMOSI, GPIO SPIMISO, GPIO SPICS)
 {
     adcnum = adc_channel;
     clockpin = SPICLK;
     mosipin = SPIMOSI;
     misopin = SPIMISO;
     cspin = SPICS;
     //
     if (adc_channel >= 0 && adc_channel <= 7)
     {
         //This is the range we are looking for, from CH0 to CH7. 
     }
     else
     {
         throw new IndexOutOfRangeException("MCP3008 Channel Input is out of range, Channel input should be from 0-7 (8-Channel).");
     }
 }
Exemplo n.º 2
0
 public DS1620(GPIO dq, GPIO clk, GPIO rst)
 {
     _dq = dq;
     _clk = clk;
     _rst = rst;
 }
Exemplo n.º 3
0
 public TM1638(GPIO data, GPIO clock, GPIO strobe, bool activateDisplay, byte intensity)
     : base(data, clock, strobe, 8, activateDisplay, intensity)
 {
 }
Exemplo n.º 4
0
        public TM16XX(GPIO data, GPIO clock, GPIO strobe, int displays, bool activateDisplay, int intensity)
        {
            // Set the pins
            _data = data;
            _clock = clock;
            _strobe = strobe;
            _displays = displays;

            _strobe.Write(true);
            _clock.Write(true);

            sendCommand(0x40);
            sendCommand((byte)(0x80 | (activateDisplay ? 0x08 : 0x00) | Math.Min(7, intensity)));

            _strobe.Write(false);
            send(0xC0);
            for (int i = 0; i < 16; i++)
            {
                send(0x00);
            }
            _strobe.Write(true);
        }
Exemplo n.º 5
0
		public TOLED9BitDataBus(GPIO RST, GPIO RS, GPIO CS, GPIO[] pins) {
			this.RS = RS;
			this.RST = RST;
			this.CS = CS;
			this.pins = pins;
			Array.Reverse(pins);
		}
Exemplo n.º 6
0
		public TOLEDSPIFastDataBus(TSPIEmulator spi, GPIO RST, GPIO RS) {
			this.RS = RS;
			this.RST = RST;
			this.spi = spi;

			set1 = GPIOMem.SetAddr;
			set0 = GPIOMem.ClrAddr;

			CSMask = (uint)spi.CS.Mask;
			SDIMask = (uint)spi.SDI.Mask;
			SCKMask = (uint)spi.SCK.Mask;
			RSMask = (uint)RS.Mask;
		}
Exemplo n.º 7
0
		public TOLEDSPIDataBus(TSPIDevice spi, GPIO RST, GPIO RS) {
			this.RS = RS;
			this.RST = RST;
			this.spi = spi;
		}
Exemplo n.º 8
0
		static void printPin(GPIO pin) {
			Console.Write(pin.Read() ? "1" : "0");
		}
Exemplo n.º 9
0
 private static void pinChanged(GPIO pin, bool value)
 {
     if ((int)pin.Pin == (int)GPIOPins.V2_GPIO_25) {
         //Power Toggle
         //lcd.Power(value);
         if (value) {
             player.WakeUp();
             shutdownTimer.Stop();
             GPIOHandler.Restrict(GPIOPins.GPIO_NONE);
         } else {
             player.Sleep();
             shutdownTimer.Start();
             GPIOHandler.Restrict(GPIOPins.V2_GPIO_25);
         }
     } else if (value) {
         switch ((int)pin.Pin) {
             case (int)GPIOPins.V2_GPIO_04: // Play/Pause
                 player.PlayPause();
                 break;
             case (int)GPIOPins.V2_GPIO_07: // Rewind
                 player.Rewind();
                 break;
             case (int)GPIOPins.V2_GPIO_08: // Next Song
                 player.NextSong();
                 break;
             case (int)GPIOPins.V2_GPIO_09: // Thumbs Up
                 player.ThumbsUp();
                 break;
             case (int)GPIOPins.V2_GPIO_10: // Thumbs Down
                 player.ThumbsDown();
                 break;
             case (int)GPIOPins.V2_GPIO_11: // Next Station
                 player.NextStation();
                 break;
             case (int)GPIOPins.V2_GPIO_14: // Previous Station
                 player.PreviousStation();
                 break;
         }
     }
 }