Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: HL on January 22, 2019, 04:25:05 PM

Title: Mach4 LED's
Post by: HL on January 22, 2019, 04:25:05 PM
Hello all, I'm new here. First post.
I'm using Mach4 screen editor and have stumbled upon a seemingly not doable problem. It's those damn ugly LED's. Is there a way to replace LED's with a label that turns ON instead. Something like " Coolant ON" or "Spindle CCW"?
I could do this easily in Mach3, but LUA is not even close to C++. I'm getting old and don't want to learn yet another programming language just to get over this ugly LED B.S. I've included a screen shot of what I'm working on(not finished), and if it can't be done then I guess I won't be buying Mach4.
Thank you,
P.S. Any help will be greatly appreciated.
Title: Re: Mach4 LED's
Post by: Cbyrdtopper on January 22, 2019, 05:14:11 PM
What you want can be accomplished because LUA is quite powerful.
I would name each Text Box something easy to remember because the name will be used in the code.
You will also have to edit the code to get the handle of the Coolant, Spindle, and whatever else you want to have a notification of.
I put this code straight into the PLC script that way if the state changes, IE coolant turns on or off, the Text Box will update.

--Code Placed in the PLC Script.
--Coolant State Text Box
local hSig = mc.mcSignalGetHandle(inst, mc.OSIG_COOLANTON)
local State = mc.mcSignalGetState(hSig)
if State == 1 then
    scr.SetProperty("txtCoolantState", "Value", "Coolant On") --The text box name is "txtCoolantState"   Whatever you want it to say, replace where it says "Coolant On"
else
     scr.SetProperty("txtCoolantState", "Value", "Coolant Off")
end   

Kind of harsh wanting to ditch Mach4 because of some LEDs IMHO; but hey, that's one great thing about Mach4, you can change it and make it whatever you like.

Mach4 is very powerful and very flexible, and this forum is a great place to learn and share your experiences.  There are some very knowledgeable people that get on the forum to help everyone out as well.

Welcome to the forum!!   
Title: Re: Mach4 LED's
Post by: HL on January 22, 2019, 07:34:32 PM
Thanks Cbyrdtopper. I will give it a try. Now as for the "Kind of harsh wanting to ditch Mach4 because of some LEDs IMHO;" comment, I disagree. We're both entilled to our differing opinions, but I do have a good reason for saying that.
 I build Machine tools and retrofit some with Mach software. All of my customers have asked for a clean, non hobby looking GUI. So Yes, those goofy looking LED's that look like candy are a non starter.
Newfangled should of thought of that especially when the competition is getting better and better every year that goes by.
Like I said, I'm new at Mach4 and I just started playing with it, less than a day, and there are many things I like about it.
So I'll give it a try and if successful I'll let you know.

Again, thank you.
Title: Re: Mach4 LED's
Post by: mcardoso on February 05, 2019, 11:17:05 AM
Wow. I honestly really like that screen layout.  Never thought I'd like the "old school" machine controller view, but it is simple and fast to find information. Nice Job.  I'm sure you're keeping the design proprietary as you said it is your business, but if you'd ever consider sharing the screen set I would love to try out that setup.
Title: Re: Mach4 LED's
Post by: HL on February 05, 2019, 06:05:25 PM
Thank you mcardoso. Like I said, this is not completed yet. The screen set will be shared with any one interested when completed. Still having issues implementing Cbyrdtopper's suggestion. I wonder if it's because I'm using the hobby/trial version. I haven't worked on this for couple of weeks now, but will try again tomorrow to see how far I can go. My only other complaint of Mach4 is the raised buttons/frame. That I imagine is a whole other problem.
I'll post if any positive results come out of this.
Title: Re: Mach4 LED's
Post by: joeaverage on February 05, 2019, 06:25:56 PM
Hi,

Quote
I wonder if it's because I'm using the hobby/trial version

To my knowledge the only restriction of the Demo version is the length of time  (six minutes) that it will run
before it requires a restart. Absolutely no changes in how the GUI works.

Craig
Title: Re: Mach4 LED's
Post by: HL on February 05, 2019, 07:02:09 PM
Hi,

Quote
I wonder if it's because I'm using the hobby/trial version

To my knowledge the only restriction of the Demo version is the length of time  (six minutes) that it will run
before it requires a restart. Absolutely no changes in how the GUI works.

Craig

Thanks for confirmation.
Title: Re: Mach4 LED's
Post by: joeaverage on February 05, 2019, 08:31:15 PM
Hi,

Quote
My only other complaint of Mach4 is the raised buttons/frame. That I imagine is a whole other problem.

I think that all the buttons, panels, tabs, frames in fact all of the graphical elements in Machs screen are wxWidgets
elements. Thus Machs screen is no more than a large collection of wxLua code.

If you are at all familiar with wxWidgets then you will also be aware that there is a wide range of graphical styles from which
you can chose, including things like raised borders. When in Machs screen edit mode a number of parameters of the
button, say, are available for user update, colors, font, blink rate etc. The structure of the underlying button is not
accessible through the edit screen, things like raised borders etc.

I think that your guess 'That I imagine is a whole other problem' is probably correct. A worthwhile selection of wxWidgets
parameters are made available for user manipulation others are not, including the nature and size of the boundaries.
If you had the GUI source code then ALL the wxWidgets parameters would be available to you.

NFS does have a policy of allowing interested developers access to the inner workings of Mach and presumably the source
code. In order to secure their intellectual property you would have to enter a N(on) D(isclosure) A(greement) with NFS.

To make the case to NFS you would want to demonstrate the need and/or demand for the project you were undertaking
and your ability and stickability to achieve a result.

I have recent come across a quote that is appropriate here 'Better a diamond with a flaw than a pebble without'.
The question I pose is that 'does the visual style that Machs screen is constructed with preclude you from using it?'
I suspect from your preceeding posts that your sense of 'offended visual style' is a weak argument in face of the demonstrated
usefulness as a CNC program. Remember we are talking CNC here.....not some high end desktop publishing software.

Craig
Title: Re: Mach4 LED's
Post by: HL on February 05, 2019, 09:27:19 PM
joeaverage,
 I agree with everything you said, including commenting that my sense of style is not NFS's priority. That's perfectly fine. I can work with what they've put together.
I was only seeking help to create a clear and bare bones GUI that has little in the form of distractions. As an engineer I try my best to cut out all the fat. My GUI looks like a throw back of an antiquitated CNC panel, but it is done that way purposely.
I'm just an old fart that can't let go of the past, where flashy framed anything or 3D buttons or bubble gum LED's etc... weren't the norm, but that's just me.
I know many, like all that stuff and I think more power to them.

Thanks for all the help.
Title: Re: Mach4 LED's
Post by: joeaverage on February 05, 2019, 10:13:56 PM
Hi,
I think that with the suggestions that Chad has made, ie using those functions that NFS has left exposed for our use
you will get close to the visual style that you want.

Some other visual styles are not left exposed. I rather think you could get stuck in and do something about it but might
involve some effort and NFS's cooperation.

I too am an engineer by training and inclination and I have come to the conclusion that certain things about Mach I would
do slightly differently but faced with the scale of the challenge you are talking about I decline to go there. I could spend many
tens or hundreds of hours getting some small feature to my satisfaction but not alter, materially, how the machine behaves.
For instance I would ideally build Through Spindle Coolant into my machine or even a much better filtration system for my
existing flood coolant setup and constitutes a better use of my time and resources.

Craig
Title: Re: Mach4 LED's
Post by: HL on February 06, 2019, 12:23:51 AM
It took a while but I got text to show spindle direction( CW,CCW) and when its OFF.
Feeling good about this. Now to get coolant and mist and if that works I'll be happy.

Thanks for the help.

Title: Re: Mach4 LED's
Post by: HL on February 06, 2019, 01:49:58 AM
Big Thank You to    Cbyrdtopper.....

I can finally move on.

Got Coolant, Mist, Spindle Direction texts to work perfectly.

Couldn't of done it without you.

LUA is so different than the other languages I've programmed in before.

Thank You.
Title: Re: Mach4 LED's
Post by: Cbyrdtopper on February 06, 2019, 09:19:23 AM
Glad you got it working! =)
Title: Re: Mach4 LED's
Post by: smurph on February 07, 2019, 07:48:12 PM
All of the tools are there in the screen to implement what you want.  There is no LED in the wxWidgets framework.  So that "element" was custom coded.  This is different than buttons, as the wxWidgets framework implements stock Windows buttons.  In other words, a button on the Mach screen will look like a button in any other standard Windows application (that hasn't been dressed up).  The Terminal program Putty is a good example.  That being said, we allow the user to pretty much dress up any button they wish with the bitmap button and custom bitmaps.  My point is just because you don't see a screen element that does exactly what you want at first glance, don't assume that it can't be done. 

Back to the LEDs.  LED is an acronym for light emitting diode, as seen on many physical machine control panels.  And that is what I tried to make them look like.  Generally, people like the round LEDs because a round LED in Mach3 was not possible.  But sometimes a round LED is not what is needed or wanted, so there are properties in the control to set the shape.  You have a choice of round or square (rectangular, really).  But if you just plop a LED down on the screen in the screen editor, it is round by default and if no cursory glance at the properties is given, you may not realize that they can be made to be rectangular.  But either way, the LED screen element is rather graphical in nature under the hood.  Not textual.  It would not be easy to program it to ALSO be textual (although I'm thinking about it). 

BTW, there is a sticky topic in this forum titled "Mach 4 Feature Request".  I look at each and every post.  I don't respond in there very often, as it would consume my time that could otherwise be used to actually make the things happen.  If I think the idea has merit and I think that the majority of our user base could benefit from it, I'll implement it. 

But seeing as how text based LEDs do not exist at the present time, now it is time to start thinking outside of the box.  If I were to want a text based "Boolean" value (we won't call it an LED now), I'd start with a Static Text control and tie it to a register.  You can create a register in the regfile plugin's configuration.  Registers can contain text values, so basically whatever is put in that register will be what the Static Text control displays on the screen.  You can then tie the register's value to any signal in the signal script (or use the siglib) with a small bit of LUA code.  One could even change the color of what is displayed.  Yeah, it isn't as easy as plopping down a control and instantly having it appeal to your taste or sense of style, but it isn't THAT hard either. 

I'm not a young guy either.  And plenty on this forum know my thoughts on LUA.  Just to summarize them, I can't stand LUA.  We chose LUA not for it's looks, but because of it's speed and flexibility.  But I won't let that stand in my way of getting what I want.  :)

Here is an example of a screen set that looks NOTHING like our stock screens.  https://www.machsupport.com/forum/index.php?topic=35438.0 (https://www.machsupport.com/forum/index.php?topic=35438.0)

Steve
Title: Re: Mach4 LED's
Post by: the_buff on February 09, 2019, 01:54:13 PM
If the layer height of a screen element could be controlled, then you could place a static text element over an LED element and achieve a faux backlit type text LED.  However, just placing the screen element higher up in the list of a particular group does not appear to impact the element's layer height.     
Title: Re: Mach4 LED's
Post by: the_buff on February 09, 2019, 02:07:15 PM
HL-What font are you using in your screen?  I'm a fan of slashed zeros.  Consolas font uses slashed zeros.
Title: Re: Mach4 LED's
Post by: ger21 on February 10, 2019, 09:18:35 AM
Quote
Generally, people like the round LEDs because a round LED in Mach3 was not possible.

Sure they were. Mach3 could use dual state images for LED's, so you could make them look any way you wanted.

This is something I requested when the first Mach4 version was released, years ago.
Title: Re: Mach4 LED's
Post by: HL on February 12, 2019, 10:43:57 AM
HL-What font are you using in your screen?  I'm a fan of slashed zeros.  Consolas font uses slashed zeros.

Hello buff. For the DRO's, Brave New Era G98. For G-Code, Nouveau IBM.
Title: Re: Mach4 LED's
Post by: mcardoso on February 12, 2019, 11:00:04 AM
Thinking out loud without knowledge of how easy it is to implement...

Could you use a variable text display where the LED would be? When on, display a period or asterisk in a large font (this would just look like a solid colored square) and when the signal is off display nothing? This would be very minimalist and go along with your flat look of the display.

Mike
Title: Re: Mach4 LED's
Post by: HL on February 12, 2019, 02:23:20 PM
Thinking out loud without knowledge of how easy it is to implement...

Could you use a variable text display where the LED would be? When on, display a period or asterisk in a large font (this would just look like a solid colored square) and when the signal is off display nothing? This would be very minimalist and go along with your flat look of the display.

Mike

You could, but I much rather have text. In the end it wasn't very complicated to do.

Keep in mind this is a work in progress. Not finalized, but slowly getting there.
Title: Re: Mach4 LED's
Post by: HL on February 12, 2019, 02:42:30 PM
Just in case anyone wants to do the same, here is the code I used.( No guaranty it will work for you, and No it is most certainly not optimized). Use at your own risk...........

Code: [Select]
if (mc.mcSpindleGetDirection(0) == 1) then
scr.SetProperty("txtBoxCW", "Value", "CW")

elseif (mc.mcSpindleGetDirection(0) == 0) then
scr.SetProperty("txtBoxCW", "Value", "OFF")
else
scr.SetProperty("txtBoxCW", "Value", "CCW")
end

local CoolSig = mc.mcSignalGetHandle(0, mc.OSIG_COOLANTON)
local State = mc.mcSignalGetState(CoolSig)
if State == 1 then
    scr.SetProperty("txtBoxCoolant", "Value", "Coolant On")


else
     scr.SetProperty("txtBoxCoolant", "Value", "Coolant Off")

end

local MistSig = mc.mcSignalGetHandle(0, mc.OSIG_MISTON)
local State2 = mc.mcSignalGetState(MistSig)
if State2 == 1 then
    scr.SetProperty("txtBoxMist", "Value", "Mist On")
else
     scr.SetProperty("txtBoxMist", "Value", "Mist Off")
end

Hope this clarifies things somewhat........

P.S. I find programming very boring and repetitive, but sometimes you just have to do thing your way........I guess.