HAL Component Help
- cmorley
- Offline
- Moderator
Less
More
- Posts: 7780
- Thank you received: 2075
08 Jun 2020 22:55 #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
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 or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
Less
More
- Posts: 7780
- Thank you received: 2075
09 Jun 2020 06:38 #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 ...
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 ...
The following user(s) said Thank You: Bend
Please Log in or Create an account to join the conversation.
- rodw
- Offline
- Platinum Member
Less
More
- Posts: 10820
- Thank you received: 3564
09 Jun 2020 07:15 #170771
by rodw
Replied by rodw on topic HAL Component Help
Thats a handy idea Chris!
Please Log in or Create an account to join the conversation.
- Bend
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 0
09 Jun 2020 13:46 - 09 Jun 2020 13:50 #170834
by Bend
Replied by Bend on topic HAL Component Help
That's a pretty slick idea, i will give that a try. Thanks.
Last edit: 09 Jun 2020 13:50 by Bend.
Please Log in or Create an account to join the conversation.
- bbsr_5a
- Offline
- Platinum Member
Less
More
- Posts: 544
- Thank you received: 105
09 Jun 2020 13:50 #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 or Create an account to join the conversation.
- Bend
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 0
09 Jun 2020 14:19 #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 or Create an account to join the conversation.
Time to create page: 0.062 seconds