Hello,
I noticed that when using the stringmanipulation function NumberToHex$(), there are no leading zero's after the conversion.
This is very annoying when displaying the result on an lcd.
A BC FF C 0 is not as readable as 0A BC FF 0C 00
Is it possible to change this behaviour or to add a switch?
Rgds,
Eric
function NumberToHex$[]
Moderator: Benj
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: function NumberToHex$[]
I have created 1 method for you. This way you can choose if you want 0x to be displayed or not.
I'm sure Ben Or Steve will know a better method. Until then at least there is a working version!
You could use this routing as a separate macro.
I'm sure Ben Or Steve will know a better method. Until then at least there is a working version!
You could use this routing as a separate macro.
Martin
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: function NumberToHex$[]
Hello
You should be able to detect if the number is less then 16 using a decision icon. This will tell you if there is only one character or two characters in the number. If there is only one character then you can print out an extra 0 before printing out your number allowing for every number to be at least 2 characters.
You should be able to detect if the number is less then 16 using a decision icon. This will tell you if there is only one character or two characters in the number. If there is only one character then you can print out an extra 0 before printing out your number allowing for every number to be at least 2 characters.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: function NumberToHex$[]
Thanks for your swift replies.
I know this issue can be circumvented with extra software, but I guess many users would appreciate if this addition of leading zero's was done by the function NumbertoHex$() itself. After all we mostly use hex notation to visually organize data into rows and columns. Leaving the leading zero's out make no sense to me. Adding them manually with an extra makro neighter.
Just a suggestion to make Flowcode more userfriendly.
Any chance for a future update?
Rgds,
Eric
I know this issue can be circumvented with extra software, but I guess many users would appreciate if this addition of leading zero's was done by the function NumbertoHex$() itself. After all we mostly use hex notation to visually organize data into rows and columns. Leaving the leading zero's out make no sense to me. Adding them manually with an extra makro neighter.
Just a suggestion to make Flowcode more userfriendly.
Any chance for a future update?
Rgds,
Eric
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: function NumberToHex$[]
Oops, left out main attachment, sorry.
- Attachments
-
- String Manipulation.fcf
- (5.5 KiB) Downloaded 321 times
Martin
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: function NumberToHex$[]
Hello
Medelecs example is pretty nice and it simulates. My fix unfortunatley does not simulate but your compiled code should not display the single character hex number anymore.
Simply close Flowcode and then copy the attached file into your "Flowcode V4/FCD" folder. You may want to back up the file before you copy so you can restore it at a later date if you so wish.
Medelecs example is pretty nice and it simulates. My fix unfortunatley does not simulate but your compiled code should not display the single character hex number anymore.
Simply close Flowcode and then copy the attached file into your "Flowcode V4/FCD" folder. You may want to back up the file before you copy so you can restore it at a later date if you so wish.
- Attachments
-
- internals.h
- (23.05 KiB) Downloaded 305 times
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: function NumberToHex$[]
Hi Ben,
I tried your solution, but I am afraid it does not solve my problem. To show my point, I need to give detailed feedback.
For the project I am working on, I need to read the data from 5 one-wire temperature sensors, which was not possible with Flowcode 3.
I am happy to tell you that in V4.1 this problem seems to be solved. As far as I have tested it, I think the one-wire component is almost fully functional now ( I come back to this later with more details )
I always use Flowcode in combination with Proteus. When I create a program in Flowcode, I test and debug it in Proteus first before I run it on hardware. These 2 programs are for me the ideal combination to develop microcontroller applications.
About the new internal.h you sent me, I show you the differences with the original one:
This is the flowcode program: It reads the scratchpad from the DS18S20 temperature sensor and uses the function NumberToHex$() to show the data in hex on the lcd. Because Flowcode does not simulates the onewire component, there are no real data shown. Therefore I run it on Proteus, the first time with the original internal.h As you can see, the real data from the scrathpad are AA 00 FF FF FF FF 0C 10
You can also see what NumToHex is making of it on the lcd. The leading zero's are suppressed but the data is correct.
Now with the new internal.h: You can see that the data is not correct ( 0C is shown as 0 ) , the 0X is still in front of each byte and leading zero's are not correctly shown.
I can understand that this is not a high priority issue ( I can circumvent it with the solution from Medelec ( thx ) but I would highly appreciate if NumToHex would convert a decimal number into hex with leading zero's and no 0x in front of it. Just plain AA 00 FF FF FF FF 0C 10.
Best regards,
Eric
I tried your solution, but I am afraid it does not solve my problem. To show my point, I need to give detailed feedback.
For the project I am working on, I need to read the data from 5 one-wire temperature sensors, which was not possible with Flowcode 3.
I am happy to tell you that in V4.1 this problem seems to be solved. As far as I have tested it, I think the one-wire component is almost fully functional now ( I come back to this later with more details )
I always use Flowcode in combination with Proteus. When I create a program in Flowcode, I test and debug it in Proteus first before I run it on hardware. These 2 programs are for me the ideal combination to develop microcontroller applications.
About the new internal.h you sent me, I show you the differences with the original one:
This is the flowcode program: It reads the scratchpad from the DS18S20 temperature sensor and uses the function NumberToHex$() to show the data in hex on the lcd. Because Flowcode does not simulates the onewire component, there are no real data shown. Therefore I run it on Proteus, the first time with the original internal.h As you can see, the real data from the scrathpad are AA 00 FF FF FF FF 0C 10
You can also see what NumToHex is making of it on the lcd. The leading zero's are suppressed but the data is correct.
Now with the new internal.h: You can see that the data is not correct ( 0C is shown as 0 ) , the 0X is still in front of each byte and leading zero's are not correctly shown.
I can understand that this is not a high priority issue ( I can circumvent it with the solution from Medelec ( thx ) but I would highly appreciate if NumToHex would convert a decimal number into hex with leading zero's and no 0x in front of it. Just plain AA 00 FF FF FF FF 0C 10.
Best regards,
Eric