While working on a project I found wanted to use LED widgets as indicators with 
out HAL pins.
With the HAL pins the LED are reset to follow the HAL pin so cannot be set in 
the program.

This patch allows one to select 'HAL pin type' 0 (no pin) or 1 (regular in pin)
in the Glade editor - it defaults to 1 which is with the HAL pin.

Ultimately I think we should allow a third option - an LED with an out pin that 
follows the

LED state - but this patch does not include this option.

It is a small patch and I hope to include it in EMC 2.5

Please advise if this is a no go for 2.5 or any other comment.

Chris M
                                          
From 2cc65387a5d773ed6b50b2f443d509214ce0c0b2 Mon Sep 17 00:00:00 2001
From: cmorley <[email protected]>
Date: Mon, 9 Jan 2012 23:48:15 -0800
Subject: [PATCH] gladevcp -add option to have an LED with no HAL pin

LEDs are useful in programs as indictators without needing HAL.
But if a HAL pin is connected to the LED the LED only follows the
hal pin. Now in the glade editor it is possible to select no HAL pin.
In the future it may make sence to allow an LED to have an output
pin - this way a program can set the LED directly and the hal pin
would be status of that.
---
 lib/python/gladevcp/led.py |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/lib/python/gladevcp/led.py b/lib/python/gladevcp/led.py
index ac08152..f13aa6b 100644
--- a/lib/python/gladevcp/led.py
+++ b/lib/python/gladevcp/led.py
@@ -17,6 +17,8 @@ class HAL_LED(gtk.DrawingArea, _HalSensitiveBase):
                     False, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
         'led_shape' : ( gobject.TYPE_INT, 'Shape', '0: round 1:oval 2:square',
                     0, 2, 0, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
+        'hal_pin_type' : ( gobject.TYPE_INT, 'HAL Pin Type', '0: None 1:In',
+                    0, 1, 1, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
         'led_size'  : ( gobject.TYPE_INT, 'Size', 'size of LED',
                     5, 30, 10, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
         'led_blink_rate' : ( gobject.TYPE_INT, 'Blink rate',  'Led blink rate (ms)',
@@ -48,6 +50,7 @@ class HAL_LED(gtk.DrawingArea, _HalSensitiveBase):
         self.pick_color_on = self.pick_color_off = None
         self.on_color = 'red'
         self.off_color = 'dark'
+        self.hal_pin_type = 1 # led has a HAL input pin
 
         self.set_color('on', gtk.gdk.Color(red=0xffff))
         self.set_color('off', self.off_color)
@@ -205,7 +208,8 @@ class HAL_LED(gtk.DrawingArea, _HalSensitiveBase):
         return True
 
     def _hal_init(self):
-        _HalSensitiveBase._hal_init(self)
+        if not self.hal_pin_type == 0:
+            _HalSensitiveBase._hal_init(self)
         self.set_color('on',  self.pick_color_on or self.on_color)
         self.set_color('off', self.pick_color_off or self.off_color)
         if self.led_blink_rate:
-- 
1.7.0.4

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to