- Posts: 6803
- Thank you received: 0
HAL Component Help
6 years 4 months ago #170721
by cmorley
Replied by cmorley on topic HAL Component Help
here is a fairly minimum component to show extra functions.
Though it seems you can't reference HAL pins in the functions
Though it seems you can't reference HAL pins in the functions
Code:
component test1;
pin in s32 in;
pin out bit out1;
pin out bit out2;
function _;
license "GPL";
;;
// private functions
int set(void){
return 1;
}
int unset(void){
return 0;
}
//main function
FUNCTION(_) {
if (in ==1){
out1 = set();
out2 = unset();
}
if (in ==2){
out1 = unset();
out2 = set();
}
}
Please Log in to join the conversation.
6 years 4 months ago #170761
by cmorley
Replied by cmorley on topic HAL Component Help
Similar that passes HAL bit pin reference to the function:
I'm hoping this helps you ...
Code:
component test1;
pin in s32 in;
pin out bit out1;
pin out bit out2;
function _;
license "GPL";
;;
// general pin setting function
void set(hal_bit_t *p){
*p = 1;
}
// general pin unsetting function
void unset(hal_bit_t *p){
*p = 0;
}
//main function
FUNCTION(_) {
if (in < 0){
set(&out1);
unset(&out2);
}else if (in >0){
unset(&out2);
set(&out2);
}else{
unset(&out1);
unset(&out2);
}
}
I'm hoping this helps you ...
Please Log in to join the conversation.
6 years 4 months ago #170771
by rodw
Replied by rodw on topic HAL Component Help
Thats a handy idea Chris!
Please Log in to join the conversation.
6 years 4 months ago #170834
by Bend
Replied by Bend on topic HAL Component Help
That's a pretty slick idea, i will give that a try. Thanks.
Please Log in to join the conversation.
6 years 4 months ago #170835
by bbsr_5a
Replied by bbsr_5a on topic HAL Component Help
why arend simple pinsets even in HAL done by UserMcodes
then yoiu can use things in G-code to do
simple pinsettings shoudent be done in a comp
then yoiu can use things in G-code to do
simple pinsettings shoudent be done in a comp
Please Log in to join the conversation.
6 years 4 months ago #170837
by Bend
Replied by Bend on topic HAL Component Help
In our specific case, the comp handles all of the tool change process. As such it is simpler to contain all the pin-out in the component for the tool changer.
Please Log in to join the conversation.
Time to create page: 0.048 seconds
