panelui.txt
1 [[cha:Panelui]](((Panelui))) 2 3 :ini: {basebackend@docbook:'':ini} 4 :hal: {basebackend@docbook:'':hal} 5 :ngc: {basebackend@docbook:'':ngc} 6 7 = Panelui 8 9 == Introduction 10 11 Panelui is a userspace component to interface buttons to linuxcnc or HAL. + 12 It decodes MESA 7I73 style key-scan codes and calls the appropriate routine. + 13 It gets input from a realtime component - sampler. + 14 Sampler gets it's input from either the MESA 7i73 or sim_matrix_kb component. + 15 Panelui is configurable using an INI style text file to define button 16 types, HAL pin types, and/or commands. 17 18 It can be extended using a Python based 'handler' file to add functions. + 19 While actual input buttons are required to be momentary, Panelui will use this 20 input to make toggle, radio, or momentary button output. + 21 22 == Loading Commands 23 The command used to load panelui (with optional -d debug switch): 24 ---- 25 loadusr -W panelui -d 26 ---- 27 This will initialize panelui, which will look for the INI file panelui.ini in 28 the config folder or user folder. 29 30 One can validate the INI file with this command: 31 ---- 32 loadusr pyui 33 ---- 34 This will read, try to correct, then save the panelui.ini file. 35 It will print errors to the terminal if found. 36 37 A typical HAL file will have these commands added: 38 [source,{hal}] 39 ---- 40 # commands needed for panelui loading 41 # 42 # sampler is needed for panelui 43 # cfg= must always be u for panelui. depth sets the available buffer 44 loadrt sampler cfg=u depth=1025 45 46 #uncomment to validate the panelui INI file 47 #loadusr pyui 48 49 # -d = debug, -v = verbose debug 50 # -d will show you keypress identification and commands called 51 # -v is for develeper info 52 loadusr -W panelui -d 53 54 # using simulated buttons instead of the MESA 7I73 card 55 # so we load the sim_matrix_kb component to convert HAL pins to keyscan codes 56 loadrt sim_matrix_kb 57 58 # connect the compnents together. 59 # sampler talks to panelui internally 60 net key-scan sim-matrix-kb.0.out 61 net key-scan sampler.0.pin.0 62 63 # add panelui components to a thread 64 65 addf sim-matrix-kb.0 servo-thread 66 addf sampler.0 servo-thread 67 ---- 68 == panelui.ini file reference 69 70 .*Key words* 71 * KEY= This is used to designate the key that the button responds to. It can be NONE or 72 ROW number and column number eg R1C2. A row and column can only be used once. 73 * OUTPUT= This sets the Button's output type, eg S32, U32, FLOAT, BIT, NONE, COMMAND 74 * DEFAULT= This sets the starting output of the group or button. 75 * GROUP= In radiobuttons, designates the group the button interacts with. 76 * GROUP_OUTPUT= sets the output the group pin will be, if this button is active. 77 * STATUS_PIN= If TRUE, a HAL pin will be added that reflects the current state of button. 78 * TRUE_STATE= sets the output the HAL pin will be, if button is TRUE 79 * FALSE_STATE= sets the OUTPUT the HAL pin will be, if the button is FALSE 80 * TRUE_COMMAND= sets the command and arguments to be called when the button is TRUE 81 * FALSE_COMMAND= sets the command and arguments to be called when the button is FALSE. 82 83 .*HAL Prefix* 84 [source,{ini}] 85 ---- 86 [HAL_PREFIX] 87 NAME= Yourname 88 ---- 89 This allows one to change the prefix of the HAL pins from 'panelui' to an arbritary name. 90 91 .*Radio Buttons* 92 Radiobutons allow only one button in the group to be active at a time. + 93 Each group has its own output pin, separate from each button in the group. + 94 Radio button definitions start with the text 'RADIO_BUTTON' inside single brackets. 95 [source,{ini}] 96 ---- 97 [RADIO_BUTTONS] 98 # The double bracket section(s) define the group(s) of radio buttons. 99 # The group name must be unique and is case sensitive. 100 # Groups output is controlled by what button is active not directly by keycode. 101 # DEFAULT references a button in the group by name and is case sensitive. 102 [[group1_name]] 103 KEY = NONE 104 OUTPUT = FLOAT 105 DEFAULT = small 106 # The triple bracket sections define the buttons in this group. 107 # button names must be unique and are case sensitive. 108 # There must be at least two buttons in a group. 109 # 110 # This button, named 'small'is controller by the row 0 column 1 key. 111 # It will cause the group output to be .0001 when it is pressed. 112 # It has no output of it's own, but has a status 113 # pin which will follow it's current state. 114 # since this button is in a group, DEFAULT has no bearing. 115 # since OUTPUT in not 'COMMAND' _COMMAND entries are ignored. 116 [[[small]]] 117 KEY = R0C1 118 GROUP = group1_name 119 GROUP_OUTPUT = .0001 120 OUTPUT = NONE 121 STATUS_PIN = True 122 TRUE_STATE = TRUE 123 FALSE_STATE = FALSE 124 TRUE_COMMAND = NONE, NONE 125 FALSE_COMMAND = NONE, NONE 126 DEFAULT = false 127 # This button, named 'large' is controller by the row 0 column 2 key. 128 # It will cause the group output to be 1000 when it is pressed. 129 # It has a S32 output of it's own, will be 20 on true and 0 on false. 130 # It also has a status pin which will follow it's current state. 131 # since this button is in a group, DEFAULT has no bearing. 132 # since OUTPUT in not 'COMMAND' _COMMAND entries are ignored. 133 [[[large]]] 134 KEY = R0C2 135 GROUP = group1_name 136 GROUP_OUTPUT = 1000 137 OUTPUT = S32 138 STATUS_PIN = True 139 TRUE_STATE = 20 140 TRUE_COMMAND = NONE, NONE 141 FALSE_COMMAND = NONE, NONE 142 FALSE_STATE = 0 143 DEFAULT = false 144 ---- 145 146 .*Toggle Buttons* 147 Togglebuttons only change state on each press of the button. 148 Toggle button definitions start with the text 'TOGGLE_BUTTON' inside single brackets. 149 [source,{ini}] 150 ---- 151 [TOGGLE_BUTTONS] 152 # Each button name inside double brackets, must be unique and is case sensitive. 153 # This button, named 'tool_change'is controller by the row 2 column 5 key. 154 # It has a BIT output, will output 1 on true state and 0 on false state. 155 # It also has a status pin which will follow it's current state. 156 # DEFAULT sets this to true when first initialized. 157 # The _COMMAND are not used since OUTPUT is not set to COMMAND but validation will 158 # add the lines regardless 159 [[tool_change]] 160 KEY = R2C5 161 OUTPUT = BIT 162 TRUE_COMMAND = NONE, NONE 163 FALSE_COMMAND = NONE, NONE 164 STATUS_PIN = True 165 DEFAULT = TRUE 166 TRUE_STATE = 1 167 FALSE_STATE = 0 168 ---- 169 170 171 .*Momentary Buttons* 172 Momentary buttons are true when pressed and false when released. 173 Momentary button definitions start with the text 'MOMENTARY_BUTTON' inside single brackets. 174 [source,{ini}] 175 ---- 176 [MOMENTARY_BUTTONS] 177 # Each button name inside double brackets, must be unique and is case sensitive. 178 # This button, named 'spindle_rev'is controller by the row 2 column 3 key. 179 # It has a COMMAND output, so will use TRUE_COMMAND and FALSE_COMMAND. 180 # It also has a status pin which will follow it's current state. 181 # COMMANDs will have a command name and then any required arguments 182 # This TRUE_COMMAND calls an internal command to start the spindle in reverse at 200 rpm 183 # If the spindle is already started, it will increase the rpm. 184 # DEFAULT is not used with Momentary buttons. 185 # The _STATE are not used since OUTPUT is set to COMMAND but validation will 186 # add the lines regardless 187 [[spindle_rev]] 188 KEY = R2C3 189 OUTPUT = COMMAND 190 TRUE_COMMAND = SPINDLE_REVERSE_INCREASE, 200 191 FALSE_COMMAND = None, NONE 192 STATUS_PIN = True 193 DEFAULT = FALSE 194 TRUE_STATE = 1 195 FALSE_STATE = 0 196 ---- 197 198 == Internal Command reference 199 There are a number of internal commands you may use. + 200 201 *mist_on* 202 203 *mist_off* 204 205 *flood_on* 206 207 *flood_off* 208 209 *estop* 210 211 *estop_reset* 212 213 *machine_off* 214 215 *machine_on* 216 217 *home_all* 218 219 *unhome_all* 220 221 .*home_selected* 222 * required argument: axis number (int) 223 224 .*unhome_selected* 225 * required argument: axis number (int) 226 227 .*override_limits* 228 229 .*spindle_forward_adjust* 230 * optional argument: starting RPM (int) - default 100 231 * Description: If the spindle is stopped it will start in the forward direction. 232 If it is already running it will increase or decrease the rpm depending on what direction 233 the spindle is running in. 234 235 .*spindle_forward* 236 * optional argument: starting RPM (int) - default 100 237 238 *spindle_stop* 239 240 .*spindle_reverse* 241 * optional argument: starting RPM (int) - default 100 242 243 .*spindle_reverse_adjust* 244 * optional argument: starting RPM (int) - default 100 245 * Description: If the spindle is stopped it will start in the reverse direction. 246 If it is already running it will increase or decrease the rpm depending on what direction 247 the spindle is running in. 248 249 .*spindle_faster* 250 * Description: increases spindle speed by 100 RPM 251 252 .*spindle_slower* 253 * Description: decreases spindle speed by 100 RPM, until RPM is 100 254 255 .*set_linear_jog_velocity* 256 * required argument: velocity in inches per minute (float) 257 * description: sets the jog velocity on axis 0,1,2,6,7,8 (X,Y,Z,U,V,W) 258 259 .*set_angular_jog_velocity* 260 * required argument: velocity in degrees per minute (float) 261 * description: sets the jog velocity on axis 3,4,5 (A.B.C) 262 263 .*continuous_jog* 264 * required arguments: axis number (int), direction (int) 265 266 .*incremental_jog* 267 * required arguments: axis number (int), direction (int), distance (float) 268 269 .*quill_up* 270 * optional arguments: machine Z axis absolute position (float) 271 * Description: Move Z axis to the given machine position 272 273 .*feed_hold* 274 * required argument: state (bool 0 or 1) 275 276 .*feed_override* 277 * required argument: rate (float) 278 279 .*rapid_override* 280 * required argument: rate (float 0-1) 281 282 .*spindle_override* 283 * required argument: rate (float) 284 285 .*max_velocity* 286 * required argument: rate (float) 287 288 *reload_tooltable* 289 290 .*optional_stop* 291 * required argument: state (bool 0 or 1) 292 293 .*block_delete* 294 * required argument: state (bool 0 or 1) 295 296 *abort* 297 298 *pause* 299 300 *resume* 301 302 .*single_block* 303 * required argument: state (bool 0 or 1) 304 305 .*smart_cycle_start* 306 * Description: If idle, starts gcode program, if paused runs one line. 307 308 .*re_start line* 309 * required argument: line number (int) 310 311 .*mdi_and_return* 312 * required argument: Gcode command(s) 313 * Description: records the current mode, calls commands and then returns to mode. 314 315 .*mdi* 316 * required argument: Gcode command(s) 317 * Description: sets mode to MDI, calls commands. 318 319 == Handler File Extension 320 A special file can be used to add custom python code that will be available as commands. 321 panelui_handler.py must be written in python and be placed in the configuration folder. 322 If panelui finds a file there it will add it's function calls to the available commands. 323 Here is an example of a handler file that adds two functions - hello_world and cycle_mode: 324 325 [source,python] 326 ---- 327 include::panelui_handler.py[] 328 ---- 329