/// <summary> This should only be initialized from I2CBBB. </summary> internal I2CBusBBB(byte ID) { switch (ID) { case 1: this.Port = new I2CPortFS(I2CPortEnum.I2CPORT_1); break; case 2: this.Port = new I2CPortFS(I2CPortEnum.I2CPORT_2); break; default: throw new ArgumentOutOfRangeException("Only I2C ports 1 and 2 are supported."); } }
/// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= /// <summary> /// A function to provide the calls to test the LCD. 2 rows by 16 col version /// </summary> /// <history> /// 13 Jun 20 Cynic - Started /// </history> public void LCD_Test_2x16() { I2CPortFS i2cPeripheral = new I2CPortFS(I2CPortEnum.I2CPORT_2); try { BBB_LCD lcdAPI = new BBB_LCD(i2cPeripheral, 0x27, 2, 16); // initialize now Console.WriteLine("Begin LCD_Test"); lcdAPI.InitLCD(); // title bit lcdAPI.MoveTo(0, 1); lcdAPI.WriteString("CS_LCD Library"); lcdAPI.MoveTo(1, 2); lcdAPI.WriteString("Tests Begin"); Thread.Sleep(3000); lcdAPI.Clear(); // set values in all four corners lcdAPI.MoveTo(1, 2); lcdAPI.WriteString("TestCorners"); lcdAPI.MoveTo(0, 0); lcdAPI.WriteChar('A'); lcdAPI.MoveTo(1, 0); lcdAPI.WriteChar('B'); lcdAPI.MoveTo(0, 15); lcdAPI.WriteChar('1'); lcdAPI.MoveTo(1, 15); lcdAPI.WriteChar('2'); Thread.Sleep(3000); lcdAPI.Clear(); lcdAPI.MoveTo(2, 2); lcdAPI.WriteString("AutoWrapTest"); Thread.Sleep(2000); lcdAPI.MoveTo(0, 14); lcdAPI.WriteString("ABC"); Thread.Sleep(1000); lcdAPI.MoveTo(1, 14); lcdAPI.WriteString("DEF"); Thread.Sleep(1000); Thread.Sleep(3000); lcdAPI.Clear(); // now test the backlight lcdAPI.MoveTo(1, 1); lcdAPI.WriteString("BacklightOff+On"); Thread.Sleep(2000); lcdAPI.BacklightOff(); Thread.Sleep(2000); lcdAPI.BacklightOn(); Thread.Sleep(3000); lcdAPI.Clear(); // now test the display lcdAPI.MoveTo(1, 1); lcdAPI.WriteString("DisplayOff+On"); Thread.Sleep(2000); lcdAPI.DisplayOff(); Thread.Sleep(2000); lcdAPI.DisplayOn(); Thread.Sleep(3000); lcdAPI.Clear(); // now test the display lcdAPI.MoveTo(1, 1); lcdAPI.WriteString("Show Cursor"); Thread.Sleep(2000); lcdAPI.ShowCursor(); Thread.Sleep(2000); lcdAPI.MoveTo(1, 1); lcdAPI.WriteString("Blink Cursor"); lcdAPI.BlinkCursorOn(); Thread.Sleep(2000); lcdAPI.MoveTo(1, 1); lcdAPI.WriteString("Cursor Off "); lcdAPI.HideCursor(); Thread.Sleep(3000); lcdAPI.Clear(); lcdAPI.MoveTo(1, 0); lcdAPI.WriteString("Custom Char Test"); lcdAPI.HideCursor(); Thread.Sleep(2000); // now custom char test byte[] happyFace = new byte[] { 0x00, 0x0A, 0x00, 0x04, 0x00, 0x11, 0x0E, 0x00 }; byte[] sadFace = new byte[] { 0x00, 0x0A, 0x00, 0x04, 0x00, 0x0E, 0x11, 0x00 }; byte[] grinFace = new byte[] { 0x00, 0x00, 0x0A, 0x00, 0x1F, 0x11, 0x0E, 0x00 }; byte[] shockFace = new byte[] { 0x0A, 0x00, 0x04, 0x00, 0x0E, 0x11, 0x11, 0x0E }; byte[] mehFace = new byte[] { 0x00, 0x0A, 0x00, 0x04, 0x00, 0x1F, 0x00, 0x00 }; byte[] angryFace = new byte[] { 0x11, 0x0A, 0x11, 0x04, 0x00, 0x0E, 0x11, 0x00 }; byte[] tongueFace = new byte[] { 0x00, 0x0A, 0x00, 0x04, 0x00, 0x1F, 0x05, 0x02 }; lcdAPI.CustomChar(0, happyFace); lcdAPI.CustomChar(1, sadFace); lcdAPI.CustomChar(2, grinFace); lcdAPI.CustomChar(3, shockFace); lcdAPI.CustomChar(4, mehFace); lcdAPI.CustomChar(5, angryFace); lcdAPI.CustomChar(6, tongueFace); lcdAPI.MoveTo(0, 2); lcdAPI.WriteChar((char)0x00); lcdAPI.WriteChar((char)0x01); lcdAPI.WriteChar((char)0x02); lcdAPI.WriteChar((char)0x03); lcdAPI.WriteChar((char)0x04); lcdAPI.WriteChar((char)0x05); lcdAPI.WriteChar((char)0x06); Thread.Sleep(3000); lcdAPI.Clear(); lcdAPI.MoveTo(0, 1); lcdAPI.WriteString("CS_LCD Library"); lcdAPI.MoveTo(1, 1); lcdAPI.WriteString("Test Complete"); Console.WriteLine("End LCD_Test"); } finally { // close the port i2cPeripheral.ClosePort(); i2cPeripheral.Dispose(); } }