示例#1
0
        public LPD6803(SPI.SPI_module spiModule, int numPixels)
        {
            var spiConfig = new SPI.Configuration(Cpu.Pin.GPIO_NONE, true, 0, 0, false, true, 500, spiModule);
            spi = new SPI(spiConfig);

            NumPixels = numPixels;

            // On a LPD6803, the PWM counter is shared with the data pin.
            // This means, when we send data, we must align the data to 256 bits (32 bytes, 16 ushorts)
            // We also have to consider the 4 byte header.
            var bufferLength = numPixels + 2;
            var alignment = 32 - (bufferLength % 32);
            bufferLength += alignment;
            Debug.Assert(bufferLength % 32 == 0);

            buffer = new ushort[bufferLength];

            oc = new OutputCompare((Cpu.Pin) FEZ_Pin.Digital.Di10, false, 2);
            oc.Set(false, new uint[] {1, 1}, 0, 2, true);
        }
示例#2
0
 public ServoMotor(FEZ_Pin.Digital pin)
 {
     oc = new OutputCompare((Cpu.Pin)pin, true, 5);
 }
 public ServoMotor(FEZ_Pin.Digital pin)
 {
     oc = new OutputCompare((Cpu.Pin)pin, true, 5);
 }
示例#4
0
 private bool PreInit(object sender, EventArgs e)
 {
     BlinkingLed = new OutputCompare(EMX.Pin.IO17, false, 2);
     Blink(100);
     OneWireBus = new OneWire(EMX.Pin.IO13);
     return true;
 }
示例#5
0
            private void InitLCD(LCDConfiguration lcdConfig)
            {
                pp = new ParallelPort(lcdConfig.dataPins, lcdConfig.writePin, lcdConfig.readPin);
                lcdReset = new OutputPort(lcdConfig.reset, true);
                lcdCS = new OutputPort(lcdConfig.chipSelect, true);
                lcdRS = new OutputPort(lcdConfig.RS, true);
                backLight = new OutputCompare(lcdConfig.backLight, true, 2);

                lcdReset.Write(true);
                Thread.Sleep(5);
                lcdReset.Write(false);
                Thread.Sleep(5);
                lcdReset.Write(true);
                Thread.Sleep(5);

                lcdCS.Write(false);

                //************* Start Initial Sequence **********//
                WriteRegister(0x0001, 0x0100); // set SS and SM bit
                WriteRegister(0x0002, 0x0200); // set 1 line inversion
                WriteRegister(0x0003, 0x0030); // set GRAM write direction and BGR=0.
                WriteRegister(0x0004, 0x0000); // Resize register
                WriteRegister(0x0008, 0x0207); // set the back porch and front porch
                WriteRegister(0x0009, 0x0000); // set non-display area refresh cycle ISC[3:0]
                WriteRegister(0x000A, 0x0000); // FMARK function
                WriteRegister(0x000C, 0x0000); // RGB interface setting
                WriteRegister(0x000D, 0x0000); // Frame marker Position
                WriteRegister(0x000F, 0x0000); // RGB interface polarity
                //*************Power On sequence ****************//
                WriteRegister(0x0010, 0x0000); // SAP, BT[3:0], AP, DSTB, SLP, STB
                WriteRegister(0x0011, 0x0007); // DC1[2:0], DC0[2:0], VC[2:0]
                WriteRegister(0x0012, 0x0000); // VREG1OUT voltage
                WriteRegister(0x0013, 0x0000); // VDV[4:0] for VCOM amplitude
                WriteRegister(0x0007, 0x0001);
                Thread.Sleep(200); // Dis-charge capacitor power voltage
                WriteRegister(0x0010, 0x1690); // SAP, BT[3:0], AP, DSTB, SLP, STB
                WriteRegister(0x0011, 0x0227); // Set DC1[2:0], DC0[2:0], VC[2:0]
                Thread.Sleep(50); // Delay 50ms
                WriteRegister(0x0012, 0x000D); // 0012
                Thread.Sleep(50); // Delay 50ms
                WriteRegister(0x0013, 0x1200); // VDV[4:0] for VCOM amplitude
                WriteRegister(0x0029, 0x000A); // 04  VCM[5:0] for VCOMH
                WriteRegister(0x002B, 0x000D); // Set Frame Rate
                Thread.Sleep(50); // Delay 50ms
                WriteRegister(0x0020, 0x0000); // GRAM horizontal Address
                WriteRegister(0x0021, 0x0000); // GRAM Vertical Address
                // ----------- Adjust the Gamma Curve ----------//
                WriteRegister(0x0030, 0x0000);
                WriteRegister(0x0031, 0x0404);
                WriteRegister(0x0032, 0x0003);
                WriteRegister(0x0035, 0x0405);
                WriteRegister(0x0036, 0x0808);
                WriteRegister(0x0037, 0x0407);
                WriteRegister(0x0038, 0x0303);
                WriteRegister(0x0039, 0x0707);
                WriteRegister(0x003C, 0x0504);
                WriteRegister(0x003D, 0x0808);
                //------------------ Set GRAM area ---------------//
                WriteRegister(0x0050, 0x0000); // Horizontal GRAM Start Address
                WriteRegister(0x0051, 0x00EF); // Horizontal GRAM End Address
                WriteRegister(0x0052, 0x0000); // Vertical GRAM Start Address
                WriteRegister(0x0053, 0x013F); // Vertical GRAM Start Address
                WriteRegister(0x0060, 0xA700); // Gate Scan Line
                WriteRegister(0x0061, 0x0001); // NDL,VLE, REV

                WriteRegister(0x006A, 0x0000); // set scrolling line
                //-------------- Partial Display Control ---------//
                WriteRegister(0x0080, 0x0000);
                WriteRegister(0x0081, 0x0000);
                WriteRegister(0x0082, 0x0000);
                WriteRegister(0x0083, 0x0000);
                WriteRegister(0x0084, 0x0000);
                WriteRegister(0x0085, 0x0000);
                //-------------- Panel Control -------------------//
                WriteRegister(0x0090, 0x0010);
                WriteRegister(0x0092, 0x0000);
                WriteRegister(0x0007, 0x0133); // 262K color and display ON

                lcdCS.Write(true);
            }