function NumberToHex$[]

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
Eric
Posts: 99
Joined: Tue Nov 06, 2007 11:04 pm
Been thanked: 1 time

function NumberToHex$[]

Post by Eric »

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

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$[]

Post by medelec35 »

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.
String Manipulation.jpg
String Manipulation.jpg (64.05 KiB) Viewed 5178 times
Martin

User avatar
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$[]

Post by Benj »

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.

Eric
Posts: 99
Joined: Tue Nov 06, 2007 11:04 pm
Been thanked: 1 time

Re: function NumberToHex$[]

Post by Eric »

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

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$[]

Post by medelec35 »

Oops, left out main attachment, sorry.
Attachments
String Manipulation.fcf
(5.5 KiB) Downloaded 321 times
Martin

User avatar
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$[]

Post by Benj »

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.
Attachments
internals.h
(23.05 KiB) Downloaded 306 times

Eric
Posts: 99
Joined: Tue Nov 06, 2007 11:04 pm
Been thanked: 1 time

Re: function NumberToHex$[]

Post by Eric »

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:
DS18S20_Read Scratchpad1.fcf
(6.5 KiB) Downloaded 301 times
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
snap0107.jpg
snap0107.jpg (136.88 KiB) Viewed 5096 times
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:
snap0108.jpg
snap0108.jpg (132.71 KiB) Viewed 5094 times
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

Post Reply