/** ctor */ public DisplayModule(PortDefinition port, OrientationType orientation) { if (CTRE.Util.Contains(port.types, kModulePortType)) { status = StatusCodes.OK; _port = port; Port8Definition portDef = (Port8Definition)port; if (portDef.Pin3 != Cpu.Pin.GPIO_NONE) { _outReset = new OutputPort(portDef.Pin3, false); } if (portDef.Pin4 != Cpu.Pin.GPIO_NONE) { _outBackLght = new OutputPort(portDef.Pin4, true); } _outRs = new OutputPort(portDef.Pin5, false); /* alloc the working arrays */ _cache_1B = new byte[1]; _cache_2W = new ushort[2]; _cache_manyBs = new byte[1024]; _cache_manyWs = new ushort[1024]; SPI.Configuration spiConfiguration = new SPI.Configuration(portDef.Pin6, false, 0, 0, false, true, 12000, SPI.SPI_module.SPI4); _spi = new Microsoft.SPOT.Hardware.SPI(spiConfiguration); /* reset pulse if pin is available */ if (_outReset != null) { _outReset.Write(false); Thread.Sleep(150); _outReset.Write(true); } /* setup registers */ ConfigureDisplay(); /* fixup orientation */ _orientation = orientation; ApplytOrientation(); /* empty screen */ ClearScreen(); /* start rendering thread */ var th = new Thread(RenderThread); th.Priority = ThreadPriority.Lowest; th.Start(); } else { status = StatusCodes.PORT_MODULE_TYPE_MISMATCH; Reporting.SetError(status); } }
/** * PixyCam Constructor * * Also Initializes OutputBuffer and Sets PixyState to FirstWord * * @param PortDef Port PixyCam is plugged into * @param ClockRate Clockrate of SPI */ public PixyCamera(Port8Definition PortDef, UInt16 ClockRate) { /* Constructs PixyCam */ SPI.Configuration PixyCam_SPIConfig = new SPI.Configuration(HERO.IO.Port8.Pin6, false, 0, 100, false, true, ClockRate, SPI.SPI_module.SPI4); PixyCam_SPI = new SPI(PixyCam_SPIConfig); /* Initialize Output Buffer */ OutBuffer = new byte[Pixy_OUTBUFFER_SIZE]; /* Initialze Pixy Processing State */ PixyState = States.FirstWord; }