=====1280 Series Screen Configuration Examples===== ===Add rotation dialog on the main screen=== [[mycnc-screen:add rotation dialog|Add Rotation Dialog on Main Screen]] === Add "Servo On" and "Servo Off" buttons === **Objective:** We need to add Servo On and Servo Off buttons to the **1280M5** profile. Original profile screen (before the buttons are added) is shown below: {{ mycnc:mycnc-1280m5-001.png?500 }} We will insert our new buttons in place of the **CV** (constant velocity toggle) button 1. Find **cnc-screen.xml** configuration file in **1280M5** profile folder 2. Edit the file (in Midnight commander press F4 on the **cnc-screen.xml** file) 3. Find in the file section with **CV** button definition (F7, search "CV") Here is the code section with the CV button code: 4. Put under this button a small popup window which serve as a container for the two new buttons - **Servo ON** & **Servo Off**. Add **quick-popup-layout** section with popup window definition: popup-servo myitems * Layout for Servo buttons will be named "popup-servo", size of layout is **80x160**, layout placed to the right side of the button that activates the popup (**wa** means "Window Attributes"). * Layout contains a Window named "toolbar-servo". 5. Fix the **CV** button to show/hide **popup-servo** - image="CV/CV" action="cnc-gvariable-toggle-5710" image="motor/servo-driver-wide" action="mypopup-toggle:popup-servo" 6. Save the **cnc-screen.xml** file, restart the software and press new button with **Servo driver**. Small popup grey colour window will be shown on the right side of the button. {{ mycnc:mycnc-1280m5-002.png?700 }} 7. Add two buttons definition in the popup window: To prevent accidental servo driver activation add 1 sec delay for start button (this is not necessary, but is recommended): event="pressed-delay-1000" action function will be started only if the button press and hold for 1 sec (1000 msec). On button will turn ON the relay #3 (M62 PLC procedure) Off button will turn OFF the relay #3 (M63 PLC procedure) For more complicated configurations, a special PLC procedure can be written to handle Servo ON/OFF (for example turn ON servo power, wait some time and then check the servo Fault/Alarm inputs before turn ON **Servo On**) Result should be like this: {{ mycnc:mycnc-1280m5-003.png?700 }} == Button & XButton types == The difference between a **button** and an **xbutton** push-button types is easy to see if we compare the "Servo" button that shows/hides the popup window and the "Servo-On"/"Servo-Off" buttons. Main "Servo" button contains the **LED** display. XButton is a simple Push button with an added LED display on top of the typical button. When writing code for an XButton, the LED parameters for it are specified in the **xattr** attribute. xattr="60;4;16;16;led;red;round" name="display-gvariable-5710" type="xbutton" /> In xattr, we are able to program the start x, y positions of the LED inside the button, the width and height of the LED, to define the LED type, LED colour (red, green, blue, yellow) and the LED shape (round, square - note that the shape is rectangular by default, so a rectangular LED will be shown if no shape is specified). Custom-defined skin from SVG file are also possible and will be described in other examples. Attribute **name="display-gvariable-5710"** sets up the LED display to show current state of CNC Global variable #5710 (0 - LED is OFF, 1 or more - LED is ON) Attributes **address="outputs" number="3"** setup LED display to show current state of output pin #3. Similar to the global variable state display, LED will be OFF if the output pin is clear, LED will be ON if the output pin is set. To complete this example, we can change the LED programming to show the state of the output pin #3 in order to monitor the servo, and we can also resize the LED to check how it changes visually. The following code is to be used: {{ mycnc:mycnc-1280m5-004.png?700 }} * **where** defines the section in which the LED button (XButton) will be located * **position** defines the location of the button within that section (not within the main overall screen, but only the section into which it is inserted) * **width** and **height** for the XButton are specified in pixels == Add "Servo On" and "Servo Off" buttons (Version 2) == Here is another way to add a 2 buttons widget containers with 2 buttons. For this example, we will be using the same **1280M5** profile. Original starting screen is shown below: {{ mycnc:mycnc-1280m5-001.png?700 }} We will insert the new buttons in place of the **CV** (constant velocity) button similar to Example 1. 1. Find the **cnc-screen.xml** configuration file in the **1280M5** profile folder. The cnc-screen.xml file is present in every profile and defines the majority of that profile's screen layout. 2. Edit the file (for example, if using in Midnight Commander, press F4 when the **cnc-screen.xml** file is selected, or edit the file using your text editor of choice) 3. Find in the file section with **CV** button definition (press F7 and search for "CV") Here is the CV button code section: 4. We will put under this existing button a small popup window which will be a container for two buttons - **Servo ON** & **Servo Off**. Add a **mywidget** item - a custom small widget with some given attributes: widget name: **toolbar-servo** Widget size: 80x160 will be exactly big enough to fit two 80x80 buttons in. Built-in LED to show **output#0** state 5. Fix **CV** button to show/hide **popup-servo** - image="CV/CV" action="cnc-gvariable-toggle-5710" image="motor/servo-driver" action="mywidget-toggle:toolbar-servo" 6. Save **cnc-screen.xml**, restart the software and press the new button with **Servo driver**. Small grey popup window will be shown on the right side of the button. {{ mycnc:mycnc-1280m5-002.png?700 }} 7. Add two buttons definition in the popup window. Definition is very similar to previous example but we will need to add the button position attribute inside of the widget attributes, as well as the button width/height attributes. To prevent accidental clicks/presses which would trigger this button, we can add one second of delay in which it would be required to click and hold this button for it to trigger: event="pressed-delay-1000" In this way, the action function will be started only if the button is pressed and held for 1 sec (1000 msec). ON button will run the Servo-PID-ON procedure OFF button will run the Servo-PID-OFF procedure The result should be similar to the screenshot below: {{ mycnc:mycnc-1280m5-003.png?700 }} == Add Window with some LEDs display == **Objective**: we need to add a window with 8 LED displays and some text labels to the main screen. These will show the current state of some inputs and outputs which will be assigned to each particular LED. For this example, we will use the **1280M5** profile as a base. Original screen is shown here: {{ mycnc:mycnc-1280m5-002-1.png?700 }} We will make our main visualization widget (the screen on which the G-code program is displayed visually) a little narrower. Afterwards, we will put our new window to the left side of the shrunken visualization window. Find "glview" section in cnc-screen.xml and fix from: to: Save and reload the application. The result is the following: {{ mycnc:mycnc-1280m5-002-2.png?700 }} In the first line, add the labels and LEDs on the left and the right: Side pillar Боковой упор * **where="led-panel"** - LEDs will be added to window named "led-panel" which was added before * **address="outputs"** - Leds will show the state of our hardware **Outputs** * **** * the first (leftmost) LED is single, with no text label assigned * **Боковой упор** - second (right) led associated with text label * **position="5;5"** - the LED is placed to this position inside the parent widget specified in the **where** field The result will be the folowing: {{ mycnc:mycnc-1280m5-002-3.png?700 }} Add some more LEDs to the widget. Complete code for the widget is the following: Side pillar Боковой упор Rear pillar Задний упор Pedal Педаль Vacuum Присоски The result will be this: {{ mycnc:mycnc-1280m5-002-4.png?700 }} == Add a button with an LED display that toggles Global Variable value and shows its current state == For this example, the machine runs the same G-code on left and right sides of the machine table. To increase performance, the operator will remove the ready (finished) parts and will install a new blank piece of material on one side of the table while the machine cuts new parts on another side. Global variable #500 contains Current active side that the machine is currently working with (or will be working with). Variable value: * 0 - means machine works (or will start to work) with the left side, * 1 - means machine works on the right side. We add a button to toggle current side. We add on-button indication and add LED displays to show the current working side. The following code is used for defining the button: This should result in the following: {{ mycnc:mycnc-1280m5-001-9.png?700 }} To add "Current Side" indication on the button: //change// type from "button" to "xbutton" //add// xattr="xattr="0;0;60;60;led;green;round" //add// name="display-cnc-gvariable-500" to show current state of Variable #500 //add image files array// - images="--left;--right" The images that we are using to show the variable state have the same size as the button itself, so the image **--left** or **--right** will be drawn on the top of the button image. Images for button base, "the left state" and "the right state" are: {{mycnc:left-right.png?80}} {{mycnc:left.png?80}} {{mycnc:right.png?80}} The code for defining this button is this: The result should look like this: {{ mycnc:mycnc-1280m5-001-10.png?700 }} == Add Buttons with LED display that runs PLC procedures and shows Output pin state == **Objective**: We need to add 2 buttons on the main software screen. These buttons will be responsible for filling up and draining water from the plasma cutting machine water table. These will be the two buttons that we are adding: {{mycnc:water-up.png}} {{mycnc:water-down.png}} We need to add a button on the right side of the **Palnik ON** button: {{ mycnc:eco-001.jpg }} Go to cnc-screen.xml in the main profile folder and locate the "Palnik ON" line. Here is the code defining the **Palnik ON** button and the static text label under it: Test Plasma Поджиг Palnik ON * **where="ecocut-coordinates"** - widget where button & label are placed * **position="80;205" width="60" height="60"** - position, width and height of the button We need to add our 2 buttons just after the block of code described above by adding the following: Water Fill Water Fill Water Drain Water Drain The result will be the following: {{ mycnc:mycnc-1280m5-001-7.png?700 }} * Output pin #13 will control the Water Fill, * Output pin #12 will control the Water Drain Add LEDs display to the buttons - 1. Change type from "button" to "xbutton" 2. Add **xatrr** attribute to buttons definition with LEDs position, width, height, colour and shape 3. Add to button definition attribute address="outputs" and number="12" (or number="13") to show output pin state This should result in the following screen: {{ mycnc:mycnc-1280m5-001-8.png?700 }} To control Water Fill/Drain PLC procedure M240 with parameter "1" (to Fill) or "0" (to Drain) is used. PLC procedure M240 is described [[plc:plc_examples#Water_Fill_and_Drain_control|Here]] == Add display to show current PLC status for Gas Cutting == In this example, we will be working with the **1024G** profile. The main screen of the profile is shown below: {{ mycnc:mycnc-1024g-001.png?700 }} Put the PLC process display in the top part of the empty area next to the "THC Speed" display. To add this display element: * find and open the "cnc-screen.xml" file in the profile folder (each profile has its own cnc-screen.xml file) * find find the "THC Speed" display code block: THC Speed Z Слежение address="plc-proc" * Change type - type="radio-display" * Edit "format" attribute - format="No Cutting=0;Ignition=50;PreHeat=51;Cutting=60" * Translate text inside format attribute if need local language messages - format="Ожиидание=0;Поджиг=50;Подогрев=51;Резка=60 * Edit bgColor, fgColor, fontSize attributes to get nice looking display A complete code - Proc Процесс The final screen will look as follows: {{ mycnc:mycnc-1024g-001-1.png?700 }} == Add "Move A to 0" button to run macro with confirmation == {{ mycnc:mycnc-move-to-a-0.png?700 }} For 3 axes machine we have a button **>0<** to moves machine to work 0 position. For machines with rotational axes it is convenient to have similar button to move rotational axis **A** to work 0. We add this button to the main screen on the left of **>0<** button. Here is **Move To 0** definition - Move to Work (0,0,Tool Lift) position (macro M333). Are you sure? Переместить в положение (0,0, Tool Lift) (макро M333)? Add on the left **Move To A** definition - Move to A=0 position (macro M335). Are you sure? Вернуть в А=0 (макро M335)? * **type="button"** - Button definition * **where="magic"** - Name of Parent Widget * **image="parking/move-to-A"** - Button skin image filename (SVG format, folder relative to **/myCNC/art/buttons-no-theme/**) * **action="direct-run-confirm:M335"** - What to do if button pressed - * **direct-run-confirm:** - Open Message box to confirm, then * run G-code sequence (**";"** is used as separator of g-code blocks) * **position="1120;640" width="80" height="80"** - button position on Parent Widget, width and height of button * **Move to A=0 position (macro M335). Are you sure?** - message to show in Message Box * **Вернуть в А=0 (макро M335)?** - message to show for Russian language {{ mycnc:mycnc-move-to-a-0-1.png?700 }} Screen with **Move To A** button {{ mycnc:mycnc-move-to-a-0-2.png?700 }}Message Box when **Move To A** button pressed If button OK pressed on Message Box, g-code line **M335** (which is macro actually) will be executed to move A axs to zero. [[mycnc::move-a-to-0|M335 macro to move A to zero is described here]] == Add Centring Widget on main GUI screen == myCNC software has Centring widget to work with probing sensor and find internal and external centers, edges, corners on parts. The Centring widget looks like this: {{ mycnc:mycnc-probing-001.png?500 }} There is just 1 line to configure Centring Widget in cnc-screen.xml configuration file. * **type="centringview"** - Centring Widget definition * **where="magic"** - name of Parent Widget * **bsize="80"** - size of buttons * **position="0;80" width="880" height="320"** - Position of Centring Widget on the Parent WIdget, width and height of Centring Widget * **hidden="1"** - Centring Widget is hidden on the start of GUI * **bgColor="#c0c0c0"** - Backgroundcolor of Centring Widget Centring Widget takes up a lot of space on the main screen, so it's convenient to have it hidden while the normal work process is underway and to show the widget only when working with the probe sensor. To show/hide Centring Widget, an on-screen button is typically used. * **type="button"** - Button definition * **image="probing/centring-unit"** - image for the button skin (in SVG format, relative to images folder "/myCNC/art/buttons-no-theme/ * **action="toggle-widget-centring"** - Action definition for pressing the button - Show/Hide Centring Widget * **where="magic"** - name of Parent Widget * **position="1120;0" width="80" height="80"** - Button position on the Parent Widget, width and height on the button in pixels {{ mycnc:mycnc-centring-01.png?700 }} {{ mycnc:mycnc-centring-01-1.png?700 }}