Пример #1
0
        //When the application is terminating, close the Phidget.
        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            lcd.rows[0].DisplayString = "";
            lcd.rows[1].DisplayString = "";

            lcd.Attach -= new AttachEventHandler(lcd_Attach);
            lcd.Detach -= new DetachEventHandler(lcd_Detach);
            lcd.Error  -= new ErrorEventHandler(lcd_Error);

            ifk.Attach -= new AttachEventHandler(ifk_Attach);
            ifk.Detach -= new DetachEventHandler(ifk_Detach);
            ifk.Error  -= new ErrorEventHandler(ifk_Error);

            ifk.InputChange  -= new InputChangeEventHandler(ifk_InputChange);
            ifk.OutputChange -= new OutputChangeEventHandler(ifk_OutputChange);
            ifk.SensorChange -= new SensorChangeEventHandler(ifk_SensorChange);

            //run any events in the message queue - otherwise close will hang if there are any outstanding events
            Application.DoEvents();

            lcd.close();
            ifk.close();

            lcd = null;
            ifk = null;
        }
Пример #2
0
        static void Main(string[] args)
        {
            try
            {
                //set up new textLCD object and event handlers
                TextLCD tLCD = new TextLCD();

                tLCD.Attach += new AttachEventHandler(tLCD_attach);
                tLCD.Detach += new DetachEventHandler(tLCD_detach);
                tLCD.Error += new ErrorEventHandler(tLCD_error);

                tLCD.open();

                if (!tLCD.Attached)
                {
                    Console.WriteLine("Waiting for TextLCD to be attached....");
                    tLCD.waitForAttachment();
                }

                writeLCD(0, tLCD);
                writeLCD(1, tLCD);

                Console.ReadLine();

                tLCD.close();
            }
            catch (PhidgetException e)
            {
                Console.WriteLine(e.ToString());

            }
        }
Пример #3
0
 /// <summary>
 /// Creates a new LCD Display.
 /// </summary>
 public LCDHandler()
 {
     lcdAdapter = new TextLCD();
     lastSecondRow = "";
     lastFirstRow = "";
     currentDate = string.Format("{0:HH:mm}", DateTime.Now);
 }
Пример #4
0
        //LCD Attach event handler...populate the fields and controls
        void lcdControl_Attach(object sender, AttachEventArgs e)
        {
            TextLCD attached = (TextLCD)sender;

            attachedTxt.Text = attached.Attached.ToString();
            nameTxt.Text     = attached.Name;
            serialTxt.Text   = attached.SerialNumber.ToString();
            versiontxt.Text  = attached.Version.ToString();

            backlightChk.Enabled   = true;
            cursorChk.Enabled      = true;
            cursorBlinkChk.Enabled = true;
            contrastTrkBr.Enabled  = true;

            memoryLocCmb.Enabled        = true;
            customCharScreenCmb.Enabled = true;
            storeCustom.Enabled         = true;

            switch (attached.ID)
            {
            case Phidget.PhidgetID.TEXTLCD_2x20:
            case Phidget.PhidgetID.TEXTLCD_2x20_w_0_8_8:
                break;

            case Phidget.PhidgetID.TEXTLCD_2x20_w_8_8_8:
                if (attached.Version >= 200)
                {
                    brightnessTrkBr.Visible = true;
                    brightnessLbl.Visible   = true;
                    brightnessTrkBr.Enabled = true;
                }
                break;

            case Phidget.PhidgetID.TEXTLCD_ADAPTER:
                screenCmb.Enabled       = true;
                screenSizeCmb.Enabled   = true;
                initButton.Enabled      = true;
                initButton.Visible      = true;
                brightnessTrkBr.Visible = true;
                brightnessLbl.Visible   = true;
                brightnessTrkBr.Enabled = true;
                break;
            }

            foreach (String size in System.Enum.GetNames(typeof(TextLCD.ScreenSizes)))
            {
                screenSizeCmb.Items.Add(size);
            }

            for (int i = 0; i < attached.screens.Count; i++)
            {
                screenCmb.Items.Add(i.ToString());
                customCharScreenCmb.Items.Add(i.ToString());
            }

            screenCmb.SelectedIndex           = 0;
            customCharScreenCmb.SelectedIndex = 0;
        }
Пример #5
0
        //LCD Detach event handler...Clear all the fields and disable all the controls
        void lcdControl_Detach(object sender, DetachEventArgs e)
        {
            TextLCD detached = (TextLCD)sender;

            attachedTxt.Text = detached.Attached.ToString();
            nameTxt.Clear();
            serialTxt.Clear();
            versiontxt.Clear();

            screenCmb.Items.Clear();
            customCharScreenCmb.Items.Clear();
            screenSizeCmb.Items.Clear();

            screenCmb.Enabled      = false;
            backlightChk.Enabled   = false;
            cursorChk.Enabled      = false;
            cursorBlinkChk.Enabled = false;
            contrastTrkBr.Enabled  = false;

            memoryLocCmb.Enabled        = false;
            customCharScreenCmb.Enabled = false;
            storeCustom.Enabled         = false;

            screenSizeCmb.Enabled = false;
            initButton.Enabled    = false;
            initButton.Visible    = false;

            brightnessTrkBr.Visible = false;
            brightnessLbl.Visible   = false;
            brightnessTrkBr.Enabled = false;

            row0.Enabled = false;
            row1.Enabled = false;
            row2.Enabled = false;
            row3.Enabled = false;

            cursorChk.Checked      = false;
            cursorBlinkChk.Checked = false;
            backlightChk.Checked   = false;
            brightnessTrkBr.Value  = 0;
            contrastTrkBr.Value    = 0;

            row0.Clear();
            row1.Clear();
            row2.Clear();
            row3.Clear();

            rowTextStorage[0, 0] = "";
            rowTextStorage[0, 1] = "";
            rowTextStorage[0, 2] = "";
            rowTextStorage[0, 3] = "";

            rowTextStorage[1, 0] = "";
            rowTextStorage[1, 1] = "";
            rowTextStorage[1, 2] = "";
            rowTextStorage[1, 3] = "";
        }
Пример #6
0
        //Detach event handler, we'll output the name and serial of the phidget that is
        //detached
        static void tLCD_Detach(object sender, DetachEventArgs e)
        {
            TextLCD detached = (TextLCD)sender;
            string  name     = detached.Name;
            string  serialNo = detached.SerialNumber.ToString();

            Console.WriteLine("TextLCD name:{0} serial No.: {1} Detached!", name,
                              serialNo);
        }
Пример #7
0
        //initialize the LCD object and hook the event handlers
        private void Form1_Load(object sender, EventArgs e)
        {
            lcd = new TextLCD();

            lcd.Attach += new AttachEventHandler(lcdControl_Attach);
            lcd.Detach += new DetachEventHandler(lcdControl_Detach);
            lcd.Error  += new ErrorEventHandler(lcdControl_Error);

            openCmdLine(lcd);
        }
Пример #8
0
        //detach event handler.... we will display the device attach status and clear all the other fields
        void lcd_Detach(object sender, DetachEventArgs e)
        {
            TextLCD detached = (TextLCD)sender;

            LCDattachedText.Text = detached.Attached.ToString();
            LCDnameText.Text     = "";
            LCDserialText.Text   = "";
            LCDversionText.Text  = "";

            contrastTrkBr.Enabled = false;
        }
Пример #9
0
        //When the form is being close, make sure to stop all the motors and close the Phidget.
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            lcd.Attach -= new AttachEventHandler(lcdControl_Attach);
            lcd.Detach -= new DetachEventHandler(lcdControl_Detach);
            lcd.Error  -= new ErrorEventHandler(lcdControl_Error);

            //run any events in the message queue - otherwise close will hang if there are any outstanding events
            Application.DoEvents();

            lcd.close();
            lcd = null;
        }
Пример #10
0
        //attach event handler...we will display the attach status and the attached TextLCD device's details
        //We will also enable the fields used to manipulate the TextLCD as well as do some initializing of
        //ranges and maximum values for some of these fields
        void lcd_Attach(object sender, AttachEventArgs e)
        {
            TextLCD attached = (TextLCD)sender;

            LCDattachedText.Text = attached.Attached.ToString();
            LCDnameText.Text     = attached.Name;
            LCDserialText.Text   = attached.SerialNumber.ToString();
            LCDversionText.Text  = attached.Version.ToString();

            contrastTrkBr.Enabled = true;
            contrastTrkBr.SetRange(0, 255);
            contrastTrkBr.Value = 130;
        }
Пример #11
0
        //attach event handler...we will display the attach status and the attached TextLCD device's details
        //We will also enable the fields used to manipulate the TextLCD as well as do some initializing of
        //ranges and maximum values for some of these fields
        void lcd_Attach(object sender, AttachEventArgs e)
        {
            TextLCD attached = (TextLCD)sender;

            attachedText.Text      = attached.Attached.ToString();
            nameText.Text          = attached.Name;
            serialText.Text        = attached.SerialNumber.ToString();
            versionText.Text       = attached.Version.ToString();
            dispText1.Enabled      = true;
            dispText1.MaxLength    = lcd.rows[0].MaximumLength;
            dispText2.Enabled      = true;
            dispText2.MaxLength    = lcd.rows[1].MaximumLength;
            clearBtn.Enabled       = true;
            backlightChk.Enabled   = true;
            cursorChk.Enabled      = true;
            contrastTrkBr.Enabled  = true;
            cursorBlinkChk.Enabled = true;
            customChrChk.Enabled   = true;
            contrastTrkBr.Value    = 130;

            if (attached.Version >= 200 && attached.ID == Phidget.PhidgetID.TEXTLCD_2x20_w_8_8_8)
            {
                backlightChk.Checked = false;
            }
            else
            {
                backlightChk.Checked = true;
            }
            cursorBlinkChk.Checked = false;
            cursorChk.Checked      = false;
            customChrChk.Checked   = false;

            try
            {
                brightnessTrkBr.Visible = true;
                brightnessLbl.Visible   = true;
                brightnessTrkBr.Enabled = true;
                brightnessTrkBr.Value   = attached.Brightness;
            }
            catch (PhidgetException ex)
            {
                if (ex.Type == PhidgetException.ErrorType.PHIDGET_ERR_UNSUPPORTED)
                {
                    brightnessTrkBr.Visible = false;
                    brightnessLbl.Visible   = false;
                }
            }
        }
Пример #12
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //build the arrays
            makeDigiInArray();
            makeDigiOutArray();
            makeSensorInArray();

            //initialize some of the form elements basedo n nothing being attached yet
            label9.Visible         = false;
            inputTrk.Value         = 0;
            inputTrk.Enabled       = false;
            inputTrk.Visible       = false;
            sensitivityTxt.Text    = "";
            sensitivityTxt.Visible = false;

            ratioChk.Enabled = false;
            ratioChk.Checked = false;

            contrastTrkBr.Enabled = false;

            //initiallize the TextLCD object
            lcd = new TextLCD();

            //hook the event handlers
            lcd.Attach += new AttachEventHandler(lcd_Attach);
            lcd.Detach += new DetachEventHandler(lcd_Detach);
            lcd.Error  += new ErrorEventHandler(lcd_Error);

            //initialize the InterfaceKit object
            ifk = new InterfaceKit();

            //hook the event handlers
            ifk.Attach += new AttachEventHandler(ifk_Attach);
            ifk.Detach += new DetachEventHandler(ifk_Detach);
            ifk.Error  += new ErrorEventHandler(ifk_Error);

            ifk.InputChange  += new InputChangeEventHandler(ifk_InputChange);
            ifk.OutputChange += new OutputChangeEventHandler(ifk_OutputChange);
            ifk.SensorChange += new SensorChangeEventHandler(ifk_SensorChange);

            //open the phidgets
            //Since TextLCDs come with an attached InterfaceKit 8/8/8 open the lcd and the interfacekit
            //as seperate objects. Here we are assuming the PhidgetTextLCD with 8/8/8 is the only Phidget
            //attached to your pc. If you have more phidgets or want connect to phidgets on other PC's look for the
            //other variations of open().
            lcd.open();
            ifk.open();
        }
Пример #13
0
        public CareTakerDisplay(int serialNumber)
        {
            //  Open connection to LCD display
            this.lcd = new TextLCD();
            this.lcd.open(serialNumber);

            //  Wait for connection
            if (!this.lcd.Attached) this.lcd.waitForAttachment();

            //  Set up special characters (æ, ø, å, ^, @)
            this.lcd.customCharacters[0].setCustomCharacter(190464, 16015);
            this.lcd.customCharacters[1].setCustomCharacter(603136, 22837);
            this.lcd.customCharacters[2].setCustomCharacter(47108, 15919);
            this.lcd.customCharacters[3].setCustomCharacter(7335, 0);
            this.lcd.customCharacters[4].setCustomCharacter(1048575, 1048575);
        }
Пример #14
0
        //detach event handler.... we will display the device attach status and clear all the other fields
        void lcd_Detach(object sender, DetachEventArgs e)
        {
            TextLCD detached = (TextLCD)sender;

            attachedText.Text       = detached.Attached.ToString();
            nameText.Text           = "";
            serialText.Text         = "";
            versionText.Text        = "";
            dispText1.Enabled       = false;
            dispText2.Enabled       = false;
            clearBtn.Enabled        = false;
            backlightChk.Enabled    = false;
            cursorChk.Enabled       = false;
            contrastTrkBr.Enabled   = false;
            cursorBlinkChk.Enabled  = false;
            customChrChk.Enabled    = false;
            brightnessTrkBr.Enabled = false;
        }
Пример #15
0
        //initialize our TextLCD Phidget and hook the event handlers
        private void Form1_Load(object sender, EventArgs e)
        {
            lcd = new TextLCD();

            lcd.Attach += new AttachEventHandler(lcd_Attach);
            lcd.Detach += new DetachEventHandler(lcd_Detach);
            lcd.Error  += new ErrorEventHandler(lcd_Error);

            openCmdLine(lcd);

            dispText1.Enabled       = false;
            dispText2.Enabled       = false;
            clearBtn.Enabled        = false;
            backlightChk.Enabled    = false;
            cursorChk.Enabled       = false;
            contrastTrkBr.Enabled   = false;
            cursorBlinkChk.Enabled  = false;
            customChrChk.Enabled    = false;
            brightnessTrkBr.Enabled = false;
        }
Пример #16
0
        static void writeLCD(int lineNumber, TextLCD tLCD)
        {
            Console.WriteLine("Enter text to display on line {0}:", lineNumber);
            string line = Console.ReadLine();

            if (tLCD.Attached)
            {
                if (line.Length > tLCD.rows[lineNumber].MaximumLength)
                {
                    while (line.Length > tLCD.rows[lineNumber].MaximumLength)
                    {
                        Console.WriteLine("Entered text is too long, try again...");
                        line = Console.ReadLine();
                    }
                }
                else
                {
                    if (tLCD.Attached)
                    {
                        tLCD.rows[lineNumber].DisplayString = line;
                    }
                }
            }
        }
Пример #17
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //build the arrays
            makeDigiInArray();
            makeDigiOutArray();
            makeSensorInArray();

            //initialize some of the form elements basedo n nothing being attached yet
            label9.Visible = false;
            inputTrk.Value = 0;
            inputTrk.Enabled = false;
            inputTrk.Visible = false;
            sensitivityTxt.Text = "";
            sensitivityTxt.Visible = false;

            ratioChk.Enabled = false;
            ratioChk.Checked = false;

            contrastTrkBr.Enabled = false;

            //initiallize the TextLCD object
            lcd = new TextLCD();

            //hook the event handlers
            lcd.Attach += new AttachEventHandler(lcd_Attach);
            lcd.Detach += new DetachEventHandler(lcd_Detach);
            lcd.Error += new ErrorEventHandler(lcd_Error);

            //initialize the InterfaceKit object
            ifk = new InterfaceKit();

            //hook the event handlers
            ifk.Attach += new AttachEventHandler(ifk_Attach);
            ifk.Detach += new DetachEventHandler(ifk_Detach);
            ifk.Error += new ErrorEventHandler(ifk_Error);

            ifk.InputChange += new InputChangeEventHandler(ifk_InputChange);
            ifk.OutputChange += new OutputChangeEventHandler(ifk_OutputChange);
            ifk.SensorChange += new SensorChangeEventHandler(ifk_SensorChange);

            //open the phidgets
            //Since TextLCDs come with an attached InterfaceKit 8/8/8 open the lcd and the interfacekit
            //as seperate objects. Here we are assuming the PhidgetTextLCD with 8/8/8 is the only Phidget
            //attached to your pc. If you have more phidgets or want connect to phidgets on other PC's look for the
            //other variations of open().
            lcd.open();
            ifk.open();
        }
Пример #18
0
        static void Main(string[] args)
        {
            try
            {
                //set up our Phidget TextLCD and hook the event handlers
                TextLCD tLCD = new TextLCD();

                tLCD.Attach += new AttachEventHandler(tLCD_Attach);
                tLCD.Detach += new DetachEventHandler(tLCD_Detach);
                tLCD.Error  += new ErrorEventHandler(tLCD_Error);

                tLCD.open();

                //We have to wait to make sure that a TextLCD is plugged in before
                //trying to communicate with it
                if (!tLCD.Attached)
                {
                    Console.WriteLine("Waiting for TextLCD to be attached....");
                    tLCD.waitForAttachment();
                }

                //prompt for the first line of input, Phidget TextLCD have two display
                //lines
                Console.WriteLine("Enter text to display on line 1:");
                string line1 = Console.ReadLine();

                //make sure a TextLCd is still attached before trying to communicate
                //with it...this is for if the TextLCd has been detached while waiting
                //for user input
                if (tLCD.Attached)
                {
                    if (line1.Length > tLCD.rows[0].MaximumLength)
                    {
                        while (line1.Length > tLCD.rows[0].MaximumLength)
                        {
                            Console.WriteLine("Entered text is too long, try again...");
                            line1 = Console.ReadLine();
                        }
                    }
                    else
                    {
                        if (tLCD.Attached)
                        {
                            tLCD.rows[0].DisplayString = line1;
                        }
                    }
                }

                //prompt for the second line of input
                Console.WriteLine("Enter text to display on line 2:");
                string line2 = Console.ReadLine();

                //make sure a TextLCd is still attached before trying to communicate
                //with it...this is for if the TextLCd has been detached while waiting
                //for user input
                if (tLCD.Attached)
                {
                    if (line2.Length > tLCD.rows[1].MaximumLength)
                    {
                        while (line2.Length > tLCD.rows[1].MaximumLength)
                        {
                            Console.WriteLine("Entered text is too long, try again...");
                            line2 = Console.ReadLine();
                        }
                    }
                    else
                    {
                        if (tLCD.Attached)
                        {
                            tLCD.rows[1].DisplayString = line2;
                        }
                    }
                }

                //Close the phidget
                tLCD.close();
                Console.WriteLine("ok");
            }
            catch (PhidgetException ex)
            {
                //output any exception data to the console
                Console.WriteLine(ex.ToString());
            }
        }
Пример #19
0
        //initialize the LCD object and hook the event handlers
        private void Form1_Load(object sender, EventArgs e)
        {
            lcd = new TextLCD();

            lcd.Attach += new AttachEventHandler(lcdControl_Attach);
            lcd.Detach += new DetachEventHandler(lcdControl_Detach);
            lcd.Error += new ErrorEventHandler(lcdControl_Error);

            openCmdLine(lcd);
        }
Пример #20
0
        //When the form is being close, make sure to stop all the motors and close the Phidget.
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            lcd.Attach -= new AttachEventHandler(lcdControl_Attach);
            lcd.Detach -= new DetachEventHandler(lcdControl_Detach);
            lcd.Error -= new ErrorEventHandler(lcdControl_Error);

            //run any events in the message queue - otherwise close will hang if there are any outstanding events
            Application.DoEvents();

            lcd.close();
            lcd = null;
        }
Пример #21
0
        static void Main(string[] args)
        {
            try
            {
                //set up our Phidget TextLCD and hook the event handlers
                TextLCD tLCD = new TextLCD();

                tLCD.Attach += new AttachEventHandler(tLCD_Attach);
                tLCD.Detach += new DetachEventHandler(tLCD_Detach);
                tLCD.Error += new ErrorEventHandler(tLCD_Error);

                tLCD.open();

                //We have to wait to make sure that a TextLCD is plugged in before
                //trying to communicate with it
                if(!tLCD.Attached)
                {
                    Console.WriteLine("Waiting for TextLCD to be attached....");
                    tLCD.waitForAttachment();
                }

                //prompt for the first line of input, Phidget TextLCD have two display
                //lines
                Console.WriteLine("Enter text to display on line 1:");
                string line1 = Console.ReadLine();

                //make sure a TextLCd is still attached before trying to communicate
                //with it...this is for if the TextLCd has been detached while waiting
                //for user input
                if (tLCD.Attached)
                {
                    if (line1.Length > tLCD.rows[0].MaximumLength)
                    {
                        while (line1.Length > tLCD.rows[0].MaximumLength)
                        {
                            Console.WriteLine("Entered text is too long, try again...");
                            line1 = Console.ReadLine();
                        }
                    }
                    else
                    {
                        if (tLCD.Attached)
                        {
                            tLCD.rows[0].DisplayString = line1;
                        }
                    }
                }

                //prompt for the second line of input
                Console.WriteLine("Enter text to display on line 2:");
                string line2 = Console.ReadLine();

                //make sure a TextLCd is still attached before trying to communicate
                //with it...this is for if the TextLCd has been detached while waiting
                //for user input
                if (tLCD.Attached)
                {
                    if (line2.Length > tLCD.rows[1].MaximumLength)
                    {
                        while (line2.Length > tLCD.rows[1].MaximumLength)
                        {
                            Console.WriteLine("Entered text is too long, try again...");
                            line2 = Console.ReadLine();
                        }
                    }
                    else
                    {
                        if (tLCD.Attached)
                        {
                            tLCD.rows[1].DisplayString = line2;
                        }
                    }
                }

                //Close the phidget
                tLCD.close();
                Console.WriteLine("ok");
            }
            catch (PhidgetException ex)
            {
                //output any exception data to the console
                Console.WriteLine(ex.ToString());
            }
        }
Пример #22
0
        //When the application is terminating, close the Phidget.
        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            lcd.rows[0].DisplayString = "";
            lcd.rows[1].DisplayString = "";

            lcd.Attach -= new AttachEventHandler(lcd_Attach);
            lcd.Detach -= new DetachEventHandler(lcd_Detach);
            lcd.Error -= new ErrorEventHandler(lcd_Error);

            ifk.Attach -= new AttachEventHandler(ifk_Attach);
            ifk.Detach -= new DetachEventHandler(ifk_Detach);
            ifk.Error -= new ErrorEventHandler(ifk_Error);

            ifk.InputChange -= new InputChangeEventHandler(ifk_InputChange);
            ifk.OutputChange -= new OutputChangeEventHandler(ifk_OutputChange);
            ifk.SensorChange -= new SensorChangeEventHandler(ifk_SensorChange);

            //run any events in the message queue - otherwise close will hang if there are any outstanding events
            Application.DoEvents();

            lcd.close();
            ifk.close();

            lcd = null;
            ifk = null;
        }
Пример #23
0
        //initialize our TextLCD Phidget and hook the event handlers
        private void Form1_Load(object sender, EventArgs e)
        {
            lcd = new TextLCD();

            lcd.Attach += new AttachEventHandler(lcd_Attach);
            lcd.Detach += new DetachEventHandler(lcd_Detach);
            lcd.Error += new ErrorEventHandler(lcd_Error);

            openCmdLine(lcd);

            dispText1.Enabled = false;
            dispText2.Enabled = false;
            clearBtn.Enabled = false;
            backlightChk.Enabled = false;
            cursorChk.Enabled = false;
            contrastTrkBr.Enabled = false;
            cursorBlinkChk.Enabled = false;
            customChrChk.Enabled = false;
            brightnessTrkBr.Enabled = false;
        }