Which when clicked shows a numeric keypad, i'm trying to enter a frequency in 1Hz resolution such as 10.123456 then pressing enter.
If I print ctrlval(1) in the KeyUp interrupt routine, I do not see 10.123456 instead I see 10.12346, but if instead I enter 10.123412 then I see 10.12341, so it looks like some kind of rounding up is being applied as well as truncating the input to 5 digits after the decimal point.
From the 'Advanced Graphics Functions' document, it says
'For controls that hold a number (e.g. a SPINBOX) the value will be the number (normally a floating point number)' I understood that floating points could hold up to 14 digits of precision (from the variables section of the user manual)
I am assuming that the GUI numberbox holds a floating point number, but why is it being rounded up and truncated? and how can I get around it please as I need to use the exact entered value to set the frequency of a DDS frequency synthesiser to 1Hz resolution. I am thinking I have missed something somewhere, but fail to see what!
This is using Pico MMBasic 6.00.03 if that makes any difference.
Posted: 08:57am 28 Sep 2025 Copy link to clipboard
matherp Guru
GUI controls use single precision floating point to save memory
Posted: 03:09am 29 Sep 2025 Copy link to clipboard
58kk90 Regular Member
Thanks for that Peter, I guess it's back to the drawing board with that idea. I also looked at formatted number box in the hope that it was possible to define one's own format, that would have been perfect, but it doesn't seem to be possible and none of the predefined formats would fit. It looks like I may have to make up my own on screen number pad using Gui Area controls unless anyone has a better idea?
I also couldn't see how to easily get around the fact that once the numbers have been entered, and the enter key has been pressed, the gui re-draws with the entered value in place of the gui text that was shown before the enter key was pressed, which messed up the screen layout somewhat.
For Example, at runtime I had the button showing "FRQ" for frequency, but after the enter key was pressed, it showed 12.34568
More reading the manual and experimentation is required I think.
Posted: 05:04am 29 Sep 2025 Copy link to clipboard
phil99 Guru
This is a bit clumsy but perhaps use a number box for the integer MHz and a second number box for the remaining Hz, then multiply the MHz by 10^6 and add Hz.
Posted: 06:36am 29 Sep 2025 Copy link to clipboard
Mixtel90 Guru
From my notes:
Any use for the phone number?
Posted: 07:21am 29 Sep 2025 Copy link to clipboard
ville56 Senior Member
Had the same problem ... solved it by having the option of entering individual digits.
@Peter, could it be possible to have something like "OPTION GUI PRECISION [SINGLE | DOUBLE] at least for the RP2350 chips? There should be enough memory by now i hope.
Posted: 07:21am 29 Sep 2025 Copy link to clipboard
ville56 Senior Member
Had the same problem ... solved it by having the option of entering individual digits.
@Peter, could it be possible to have something like "OPTION GUI PRECISION [SINGLE | DOUBLE] at least for the RP2350 chips? There should be enough memory by now i hope.
Posted: 08:20am 29 Sep 2025 Copy link to clipboard
58kk90 Regular Member
Guys, thank you for the replies and suggestions
Ideally I need to enter frequencies between 0.000001MHz so 1Hz and 30.000000 or 30MHz So 6 digits after the decimal point, i'm using a RP2040 unfortunately so @ville56's question to @Peter wouldn't help me unfortunately, unless it applied to the RP2040 too ;-)
@ville56, could you clarify on how you did it using individual digits please? did you design you own custom keypad for that? That may be the way forward for me as when entering the frequency, you could put in for example 1.234 or 1.234000 or even 01.234000.
Posted: 08:43am 29 Sep 2025 Copy link to clipboard
phil99 Guru
Another workaround.
Then use the Val() function.
Posted: 09:13am 29 Sep 2025 Copy link to clipboard
ville56 Senior Member
@58kk90: i have a selectable textbox for each digit and use + and - symbol to increment/decrement the digit in the code. The frequency is converted back and forth from string to DPfloat and individual digits as needed. Use it up to 1300 MHz in 1 Hz steps (Sony IC-PCR1000).
@phil99: tried this as well. Didn't like it as the keyboard is very crowded with a 3.something inch display. But it worked of course.
Posted: 06:32am 30 Sep 2025 Copy link to clipboard
58kk90 Regular Member
Thats what I have started to do, use separate gui buttons' for each digit, surrounded by a frame.
Looks like this so far
Still a bit to do to tweak it to look nice, but I can enter a frequency and it is displayed in the box below the keyboard as each digit gets entered. Sorry for the hair stuck to the plastic film on the front of the LCD, I should have peeled the film off before taking the picture!