Loading MatrixOrbital/MatrixOrbital.cs +37 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,26 @@ public static class Display { device.Write(text); device.Close(); } public static void DrawBitmap(this SerialPort? device, int x, int y, int w, int h, byte[] bitmap) { /* MatrixOrbital.Display.DrawBitmap(device, bitmap) Draws a bitmap to the display device (required) device name of the controller x (required) x position from 1 to 192 y (required) y position from 1 to 64 w (required) bitmap width h (required) bitmap height bitmap (required) bitmap data */ bool sanity = SerialControl.CheckSerialPermissionAndOpen(device); if (sanity) return; byte[] initbytepayload = new byte[6] { 254,100,(byte)x,(byte)y,(byte)w,(byte)h }; var t = new MemoryStream(); t.Write(initbytepayload, 0, initbytepayload.Length); t.Write(bitmap, 0, bitmap.Length); var bytepayload = t.ToArray(); SerialControl.WriteAndClose(device, bytepayload); } public static void ClearDisplay(this SerialPort? device) { /* MatrixOrbital.Display.ClearDisplay(device) Clears the contents of the display. Loading Loading @@ -155,6 +175,23 @@ public static class LED { } public static class Keypad { /*public static string ReceiveKeypress(this SerialPort? device) { // MatrixOrbital.Keypad.ReceiveKeypress(device) // I don't know if this works yet. // device (required) device name of the controller // bool sanity = SerialControl.CheckSerialPermissionAndOpen(device); if (sanity) return "None"; device.DataReceived += new SerialDataReceivedEventHandler(ReceiveKeypressEvent); return ""; } public static void ReceiveKeypressEvent(object sender, SerialDataReceivedEventArgs e) { SerialPort sp = (SerialPort)sender; string indata = sp.ReadExisting(); }*/ public static void BacklightControl(this SerialPort? device, int b ) { /* MatrixOrbital.Keypad.BacklightControl(device, b) Sets the keypad backlight brightness or turns it off. Loading ripnet.hex 0 → 100644 +1008 B File added.No diff preview for this file type. View file ripnetlogobw.bmp 0 → 100755 +1.04 KiB Loading image diff... testing/Program.cs +13 −14 Original line number Diff line number Diff line using System; using System.IO; using System.IO.Ports; using MatrixOrbital; Loading @@ -7,21 +8,19 @@ class Program { static SerialPort _serialPort; static void Main() { _serialPort = new SerialPort("/dev/ttyUSB0",19200); var loadedfile = new FileStream(@"ripnet.hex",FileMode.Open); //insert other display commands here /*var bitmapdata = new byte[(int)loadedfile.Length]; loadedfile.Read(bitmapdata, 0, (int)loadedfile.Length); MatrixOrbital.Display.ClearDisplay(_serialPort); MatrixOrbital.Display.WriteText(_serialPort, "Sup nerds. nerdsnerdsnerds"); MatrixOrbital.Display.PositionCursor(_serialPort,15,3); MatrixOrbital.Display.WriteText(_serialPort, "nerds"); MatrixOrbital.Display.PositionCursor(_serialPort,7,6); MatrixOrbital.Display.WriteText(_serialPort, "nerds"); MatrixOrbital.Display.PositionCursor(_serialPort,20,4); MatrixOrbital.Display.WriteText(_serialPort, "nerds"); MatrixOrbital.Display.PositionCursor(_serialPort,1,7); MatrixOrbital.Display.WriteText(_serialPort, "nerds"); MatrixOrbital.LED.SetColor(_serialPort, 0, 0); MatrixOrbital.LED.SetColor(_serialPort, 1, 1); MatrixOrbital.LED.SetColor(_serialPort, 2, 2); MatrixOrbital.Display.BacklightControl(_serialPort, 192); MatrixOrbital.Keypad.BacklightControl(_serialPort, 192); MatrixOrbital.Display.DrawBitmap(_serialPort,1,11,192,42,bitmapdata);*/ _serialPort.DataReceived += new SerialDataReceivedEventHandler(MatrixOrbital.Keypad.ReceiveKeypressEvent); _serialPort.Open(); Console.WriteLine("Press any key to continue..."); Console.WriteLine(); Console.ReadKey(); _serialPort.Close(); } } No newline at end of file Loading
MatrixOrbital/MatrixOrbital.cs +37 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,26 @@ public static class Display { device.Write(text); device.Close(); } public static void DrawBitmap(this SerialPort? device, int x, int y, int w, int h, byte[] bitmap) { /* MatrixOrbital.Display.DrawBitmap(device, bitmap) Draws a bitmap to the display device (required) device name of the controller x (required) x position from 1 to 192 y (required) y position from 1 to 64 w (required) bitmap width h (required) bitmap height bitmap (required) bitmap data */ bool sanity = SerialControl.CheckSerialPermissionAndOpen(device); if (sanity) return; byte[] initbytepayload = new byte[6] { 254,100,(byte)x,(byte)y,(byte)w,(byte)h }; var t = new MemoryStream(); t.Write(initbytepayload, 0, initbytepayload.Length); t.Write(bitmap, 0, bitmap.Length); var bytepayload = t.ToArray(); SerialControl.WriteAndClose(device, bytepayload); } public static void ClearDisplay(this SerialPort? device) { /* MatrixOrbital.Display.ClearDisplay(device) Clears the contents of the display. Loading Loading @@ -155,6 +175,23 @@ public static class LED { } public static class Keypad { /*public static string ReceiveKeypress(this SerialPort? device) { // MatrixOrbital.Keypad.ReceiveKeypress(device) // I don't know if this works yet. // device (required) device name of the controller // bool sanity = SerialControl.CheckSerialPermissionAndOpen(device); if (sanity) return "None"; device.DataReceived += new SerialDataReceivedEventHandler(ReceiveKeypressEvent); return ""; } public static void ReceiveKeypressEvent(object sender, SerialDataReceivedEventArgs e) { SerialPort sp = (SerialPort)sender; string indata = sp.ReadExisting(); }*/ public static void BacklightControl(this SerialPort? device, int b ) { /* MatrixOrbital.Keypad.BacklightControl(device, b) Sets the keypad backlight brightness or turns it off. Loading
testing/Program.cs +13 −14 Original line number Diff line number Diff line using System; using System.IO; using System.IO.Ports; using MatrixOrbital; Loading @@ -7,21 +8,19 @@ class Program { static SerialPort _serialPort; static void Main() { _serialPort = new SerialPort("/dev/ttyUSB0",19200); var loadedfile = new FileStream(@"ripnet.hex",FileMode.Open); //insert other display commands here /*var bitmapdata = new byte[(int)loadedfile.Length]; loadedfile.Read(bitmapdata, 0, (int)loadedfile.Length); MatrixOrbital.Display.ClearDisplay(_serialPort); MatrixOrbital.Display.WriteText(_serialPort, "Sup nerds. nerdsnerdsnerds"); MatrixOrbital.Display.PositionCursor(_serialPort,15,3); MatrixOrbital.Display.WriteText(_serialPort, "nerds"); MatrixOrbital.Display.PositionCursor(_serialPort,7,6); MatrixOrbital.Display.WriteText(_serialPort, "nerds"); MatrixOrbital.Display.PositionCursor(_serialPort,20,4); MatrixOrbital.Display.WriteText(_serialPort, "nerds"); MatrixOrbital.Display.PositionCursor(_serialPort,1,7); MatrixOrbital.Display.WriteText(_serialPort, "nerds"); MatrixOrbital.LED.SetColor(_serialPort, 0, 0); MatrixOrbital.LED.SetColor(_serialPort, 1, 1); MatrixOrbital.LED.SetColor(_serialPort, 2, 2); MatrixOrbital.Display.BacklightControl(_serialPort, 192); MatrixOrbital.Keypad.BacklightControl(_serialPort, 192); MatrixOrbital.Display.DrawBitmap(_serialPort,1,11,192,42,bitmapdata);*/ _serialPort.DataReceived += new SerialDataReceivedEventHandler(MatrixOrbital.Keypad.ReceiveKeypressEvent); _serialPort.Open(); Console.WriteLine("Press any key to continue..."); Console.WriteLine(); Console.ReadKey(); _serialPort.Close(); } } No newline at end of file