@@ -264,6 +264,9 @@ from qtvcp.core import Qhal
264264----
265265
266266This is to allow access to *QtVCP's HAL component*.
267+ <<cha:qtvcp:Qhal,For more info: Qhal>> +
268+ Qhal's newPin function returns a QPin object.
269+ <<cha:qtvcp:QPin,For more info: QPin>>
267270
268271.Instantiate `Qhal` in the `INSTANTIATE LIBRARY SECTION`
269272[source,python]
@@ -272,7 +275,7 @@ QHAL = Qhal()
272275----
273276
274277.Add a function that gets called when the pin state changes
275- Under the `initialised__ ` function, make sure there is an entry similar to this:
278+ Under the `initialized__ ` function, make sure there is an entry similar to this:
276279
277280[source,python]
278281----
@@ -284,8 +287,8 @@ Under the `initialised__` function, make sure there is an entry similar to this:
284287# the widgets are instantiated.
285288# the HAL pins are built but HAL is not set ready
286289def initialized__(self):
287- self.pin_cycle_start_in = QHAL.newpin ('cycle-start-in',QHAL.HAL_BIT, QHAL.HAL_IN)
288- self.pin_cycle_start_in.value_changed .connect(lambda s: self.cycleStart(s))
290+ self.pin_cycle_start_in = QHAL.newPin ('cycle-start-in',QHAL.HAL_BIT, QHAL.HAL_IN)
291+ self.pin_cycle_start_in.pinValueChanged .connect(lambda o, s: self.cycleStart(s))
289292----
290293
291294.Define the function called by pin state change in the `GENERAL FUNCTIONS SECTION`
@@ -313,6 +316,35 @@ In this way the cycle start button works differently depending on what tab is sh
313316
314317This is simplified - _checking state and error trapping might be helpful_.
315318
319+ == Read/Write System HAL Pins Directly
320+ Sometimes you need to read a system pin and creating a HAL pin and connecting to it,
321+ is more work then required. You can read it directly without connecting to it.
322+
323+ Here is how to read a pin, parameter, or signal:
324+
325+ [source,python]
326+ ----
327+ self.h.hal.get_value('spindle.0.at-speed')
328+
329+ # or use the Qhal library like this:
330+ QHAL.getValue('spindle.0.at-speed')
331+ ----
332+
333+ Here is how to write to an unconnected pin or a non driven signal:
334+
335+ [source,python]
336+ ----
337+ self.h.hal.set_p('componentName.pinName','10')
338+ self.h.hal.set_s('componentName.signalName','10')
339+
340+ # or use the Qhal library like this:
341+ QHAL.setPin('componentName.pinName', '10')
342+ QHAL.setSignal('componentName.signalName', '10')
343+ ----
344+
345+ Using 'self.h.hal' or 'QHAL.hal' allows access to the HAL python module functions:
346+ <<cha:python-hal-interface, Python HAL Interface>>
347+
316348== Add A Special Max Velocity Slider Based On Percent
317349
318350Some times you want to *build a widget to do something not built in*.
0 commit comments