DSPIC additional string library

General discussion on mikroBasic for dsPIC30/33 and PIC24.
Post Reply
Author
Message
yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

DSPIC additional string library

#1 Post by yo2lio » 06 Apr 2008 17:01

Hi,

DSPIC_aditional_string_library

Available functions and procedures :

* Swap_B
* Swap_F
* mem_cpy
* mem_cmp
* mem_set
* mem_chr
* Str_Len
* Str_Cut_Chr
* Str_Cat
* Str_Cpy
* Str_Chr
* Str_Replase_Chr
* Str_Split
* Str_Insert_Chr
* Str_AppendPre
* Str_AppendSuf
* Str_CutLeft
* Str_CutRight
* Byte2StrWithZeros
* Byte2Str
* Short2StrWithZeros
* Short2Str
* Word2StrWithZeros
* Word2Str
* Int2StrWithZeros
* Int2Str
* LongWord2StrWithZeros
* LongWord2Str
* LongInt2StrWithZeros
* LongInt2Str
* Float2Str
* Str2Byte
* Str2Word
* Str2LongWord
* Str2Short
* Str2Int
* Str2LongInt
* Str2Float
* Byte2Hex
* Hex2Byte
* Ip2Str
* Mac2Str
* Str2Ip
* Str2Mac
* Str2Ip_
* Str2Mac_
* Bcd2Dec
* Bcd2Dec16
* Dec2Bcd
* Dec2Bcd16
* DSPIC_aditional_string_library_version


You can download the code, descriptions and examples from :
http://www.microelemente.ro/MikroBasicD ... y_V1_1.zip

Enjoy !
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

bt
Posts: 217
Joined: 10 Nov 2005 23:08
Location: Oregon, USA
Contact:

#2 Post by bt » 07 Apr 2008 17:32

#### I found the error - I spelled "additional" correctly in the Include statement but you spelled with only one "d" :P

Just in time! BUT...

I'm trying to use the Float2Str and Int2StrWithZeros but, it gives an error (see below example). I unzipped and loaded the .mcl into the Uses folder and restarted dsPic Basic.
404:31 E-3 Identifier 'Float2Str' was not declared Galaxy1.dbas
These will be very useful for me - as I need to display:

0.9 currently this value displays as 9e-1 (without a decimal or zero's)

Thanks,
bt

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

#3 Post by yo2lio » 07 Apr 2008 17:56

O no ....

Put this at the top of your program after program <name> :

Code: Select all

include "DSPIC_aditional_string_library"
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

bt
Posts: 217
Joined: 10 Nov 2005 23:08
Location: Oregon, USA
Contact:

#4 Post by bt » 07 Apr 2008 18:42

Yes, I found our collective typeO. All works really well - Thank you!

One thing - more of a 'Wish' is to be able to align the decimal point, for display. For instance;

I have two floating numbers that can range from 0.000123 to 567.1234. Currently, as the numbers change, so does the position of the decimal. It would be really nice to be able to always keep the decimal in the same LCD display position, example with 4 digits to right of decimal:

Code: Select all

  0.0001
457.1234

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

#5 Post by yo2lio » 07 Apr 2008 21:18

Yes , It's easy to make this :

Code: Select all

  Float2Str(-0.1234,data1,4)
  i = Str_Len(data1)
  while i < 8 'In your particular case, max. length of string is 8
    Str_AppendPre(data1," ") ' Insert space at the beginning of the string
    inc(i)
  wend
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

bt
Posts: 217
Joined: 10 Nov 2005 23:08
Location: Oregon, USA
Contact:

#6 Post by bt » 07 Apr 2008 23:11

Thank you :!:

It works very well :D

bt

Csaba
Posts: 238
Joined: 01 Jun 2007 16:25
Location: Switzerland/Spain
Contact:

#7 Post by Csaba » 08 May 2008 19:16

Thanks yo2lio , great work.
What about a Word2Hex ? Since we are working with dsPIC that would be extremely useful.

Also is there a way that you show the source code. Just for learning purposes. I am interested in Byte2Hex in particular. So I can port it to my EasyPIC 4 too?


Thanks again

Csaba
We have machines that build machines but we need programs that write better programs.
CNC & AI

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

#8 Post by yo2lio » 09 May 2008 07:15

Csaba wrote:Thanks yo2lio , great work.
What about a Word2Hex ? Since we are working with dsPIC that would be extremely useful.

Also is there a way that you show the source code. Just for learning purposes. I am interested in Byte2Hex in particular. So I can port it to my EasyPIC 4 too?


Thanks again

Csaba

Word2Hex
will be available in the next release .

About source code ... I wrote this library in ASM, source code is not available.
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

Csaba
Posts: 238
Joined: 01 Jun 2007 16:25
Location: Switzerland/Spain
Contact:

#9 Post by Csaba » 09 May 2008 07:58

Thanks Yo2lio, I am looking forward for the new release.



Csaba
We have machines that build machines but we need programs that write better programs.
CNC & AI

extrapilot
Posts: 130
Joined: 28 Nov 2006 17:59

#10 Post by extrapilot » 12 May 2008 03:55

Hi Florin

Is there a method with this library to convert dec to ascii? Specifically, many RTCs return odd BCD values depending on the register, and often the initial conversion is to decimal (preferred for internal handling). But if you want to send that off to a USART terminal, or to a FAT file or whatever, it would be easier to convert to ASCII before send, so that it would be directly compatible with ASCII terminals and file readers. Seems like most libraries are fine for 0-9, since that is just an OR 0x30 operation, but for double-digit values, it gets a little ugly. Just wondering if this is native to one of your existing functions?

Regards,
R

mbluethunder7000
Posts: 17
Joined: 28 Apr 2008 12:16
Location: Egypt / Cairo

#11 Post by mbluethunder7000 » 14 Jun 2008 17:06

Hi

Can i use this library in MikroC for dsPIC?

In case of yes, what are the steps to add it in my program?

In case of no, how can i convert it to MikroC? And how can i make my own library?

Best Regards

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

#12 Post by yo2lio » 14 Jun 2008 17:13

Hello,

Unfortunately compiled library *.mcl file are not compatible with MikroC and source code in MikroPascal is not available.

Sorry .
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

mbluethunder7000
Posts: 17
Joined: 28 Apr 2008 12:16
Location: Egypt / Cairo

#13 Post by mbluethunder7000 » 14 Jun 2008 17:22

yo2lio wrote:Hello,

Unfortunately compiled library *.mcl file are not compatible with MikroC and source code in MikroPascal is not available.

Sorry .
Thanks for fast reply

Ok, how can I build my own library in MikroC? And how can I open the main code of your library?

If I need to go through inside the library which is combined with each compiler, How can I do that?

BR

User avatar
marko.ziv
mikroElektronika team
Posts: 531
Joined: 06 Dec 2007 10:11
Contact:

#14 Post by marko.ziv » 16 Jun 2008 13:54

mbluethunder7000 wrote: Ok, how can I build my own library in MikroC?
Hello,

Here are the steps for creating a library:
1) Create new C file (mikroC->File->New)
2) Save the file in one of the following folders:
C:\Program Files\Mikroelektronika\mikroC\Uses\P16\
C:\Program Files\Mikroelektronika\mikroC\Uses\P18\
If you are creating library for PIC16 MCU family the file should be saved in P16 folder.
If you are creating library for PIC18 MCU family the file should be saved in P18 folder.
If you are creating library for PIC16 and PIC18 MCU families the file should be saved in both folders.
3) Write the code for your library and save it
4) Open the "mlk" file for the MCU that you want to use. The "mlk" file is placed in the following folder:
C:\Program Files\Mikroelektronika\mikroC\defs\
Add the following line in the definition file for the MCU:
#pragma SetLib(Your_Lib_ Name)
note: this step should be repeated for each MCU that you intend to use
5) Restart the compiler

Best regards

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

#15 Post by yo2lio » 18 Jul 2008 16:12

Hi,

New version of MikroBasic DSPIC_Aditional_String_Library available here :

http://www.microelemente.ro/MikroBasicD ... y_V2_0.zip

Unfortunately this library was released from 12 May :oops: :oops: :oops: I forgot to put on the forum ... First signs of getting old ...

To use this library , copy DSPIC_aditional_string_library.mcl file in ../Uses/ folder and put this line at the beginning of your program :

Code: Select all

include "DSPIC_aditional_string_library"
Enjoy !
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

Post Reply

Return to “mikroBasic for dsPIC30/33 and PIC24 General”