|
Forum Index : Microcontroller and PC projects : ILI9488 Touch display numeric keypad issue
| Author | Message | ||||
| 58kk90 Regular Member Joined: 14/06/2023 Location: United KingdomPosts: 74 |
Morning, I have a Pico connected to an ILI9488 LCD with touch, i've put a numberbox button on the screen with GUI NUMBERBOX 1, 410, 10,50, 50, rgb(255,255,0), rgb(0,0,0) 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. |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10531 |
GUI controls use single precision floating point to save memory |
||||
| 58kk90 Regular Member Joined: 14/06/2023 Location: United KingdomPosts: 74 |
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. |
||||
| phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2786 |
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. |
||||
| Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 8232 |
From my notes: Any use for the phone number? Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
| ville56 Senior Member Joined: 08/06/2022 Location: AustriaPosts: 262 |
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. 73 de OE1HGA, Gerald |
||||
| ville56 Senior Member Joined: 08/06/2022 Location: AustriaPosts: 262 |
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. 73 de OE1HGA, Gerald |
||||
| 58kk90 Regular Member Joined: 14/06/2023 Location: United KingdomPosts: 74 |
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. |
||||
| phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2786 |
Another workaround. Then use the Val() function. |
||||
| ville56 Senior Member Joined: 08/06/2022 Location: AustriaPosts: 262 |
@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. 73 de OE1HGA, Gerald |
||||
| 58kk90 Regular Member Joined: 14/06/2023 Location: United KingdomPosts: 74 |
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! |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |