Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : gui number box
Author | Message | ||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2129 |
|
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2129 |
Hi. I was asked to code a simple square wave gen that did input number of pulses but the gui num box is baffling. idea is input number of pulses then turn port on/off but can't figure gui num box though it shows numeric keypad. any help on what seems simple but not. ' OPTION EXPLICIT OPTION DEFAULT NONE dim pulsewidth%,pulsecount% Font 5 cls text 0,0, "PULSE WIDTH=" 'GUI INTERRUPT PenDown GUI NUMBERBOX #1, 80, 100, 140, 64, rgb(blue), rgb(yellow) 'cls 'pulsewidth%=CtrlVal(#1) do 'pulsewidth%=CtrlVal(#1) text 0,0, "PULSE WIDTH=",str$(pulsewidth%) loop sub PenDown pulsewidth%=CtrlVal(#1) end sub |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6100 |
' OPTION EXPLICIT OPTION DEFAULT NONE DIM pulsewidth%,pulsecount% FONT 3 CLS TEXT 0,0, "PULSE WIDTH=" GUI NUMBERBOX #1, 80, 100, 140, 64, RGB(BLUE), RGB(YELLOW) CTRLVAL(#1) = 100 DO pulsewidth%=CTRLVAL(#1) TEXT 0,0, "PULSE WIDTH="+STR$(pulsewidth%) LOOP VK7JH MMedit MMBasic Help |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2129 |
Ta Jim. it was TEXT 0,0, "PULSE WIDTH="+STR$(pulsewidth%). I used a comma. This is for a mate who can't code but is wanting a number of pulses to control a stepper motor controller for another old guys cnc. took many attempts to make this loop. I think I need interrupt subs..cos. OPTION EXPLICIT OPTION DEFAULT NONE CONST outpin = 31 dim pulsewidth%,pulsecount%,count% pulsewidth%=20 Font 5 cls GUI NUMBERBOX #1, 0, 100, 240, 64, rgb(blue), rgb(yellow) do CtrlVal(#1) = "##PULSES?" do pulsecount%=CtrlVal(#1) loop while pulsecount%=0 text 0,200, "Count " for count%=1 to pulsecount% text 160,200, str$(count%)+" " pin(outpin)=1 pause pulsewidth% pin(outpin)=0 pause pulsewidth% next count% pause 2000 loop end edit line text 160,200, str$(count%)+" " and it works ok for 50Hz square wave Edited 2023-09-23 07:35 by stanleyella |
||||
Print this page |