Free Arduino string library for PROGMEM
Автор: resonance2001
Загружено: 2020-09-19
Просмотров: 1002
Here's the link to the Arduino library in zip form:
https://1drv.ms/u/s!AoticBc4xuQQgTV3s...
This wraps a string of text using PROGMEM in to something that approximates the String object used on the Arduino.
This is incomplete as there are a few more functions I may add in the future except the ones that mutate the string as
this cannot happen by its very nature. I have used some of the functions available but not well-known for string searching
and copying e.g.strcmp_P (the PROGMEM version of strcmp()) internally and also I used the word 'Near' to emphasise that this currently
uses near pointers for strings in the first 64 kB of flash memory which I don't expect to be a problem but again, I may write a similar
library called 'RomStringFar' for the Arduino Due etc.
This library compares with strings in RAM at the moment. I may expand this to search within a string in ROM for a substring in ROM.
I'll see how popular this library is first.
Currently, the supported functions are:
char charAt(int i) which is the same as using []
int compareTo(char *c) (returns -1, 0 or 1)
bool equals(char *c) or use ==
bool equalsIgnoreCase(char *c) same, but for ignoring the case of the string in RAM
indexOf(char val) search for a character and returns the index or -1 if not found. This doesn't currently search for a substring
int indexOf(char val, unsigned int from) you can specify a starting index
int lastIndexOf(char val) searches for the last occurence of 'va' or -1 if not found
size_t length() the size of the string, not including the trailing 0
String substring (unsigned int inclusive, unsigned int exclusive) gets a substring. This starts at 'inclusive' up to the character BEFORE exclusive
void toCharArray(char *buf, unsigned int len) This copies at most len-1 and handles the trailing 0
void use(char *c) //This can set the object to point to a new string in ROM
Operators:
== (are they the same?)
!= (are they different?)
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: