aidar_i, Айдар, ради интереса посмотрел по ссылке - тот ещё писатель кода, я правда тоже...
Код тяжёлый, время-тормозящий, с масштабированием вместо одной функции математики.
Для примера:
Код: Выделить всё
//оригинал
unsigned int hexToDec(String hexString) {
unsigned int decValue = 0;
int nextInt;
for( int i = 0; i < hexString.length(); i++) {
nextInt = int(hexString.charAt(i));
if (nextInt >= 48 && nextInt <= 57) nextInt = map(nextInt, 48, 57, 0, 9);
if (nextInt >= 65 && nextInt <= 70) nextInt = map(nextInt, 65, 70, 10, 15);
if (nextInt >= 97 && nextInt <= 102) nextInt = map(nextInt, 97, 102, 10, 15);
nextInt = constrain(nextInt, 0, 15);
decValue = (decValue * 16) + nextInt;
}
return decValue;
}
// лёгкое редактирование
unsigned int hexToDec(String hexString) {
unsigned int decValue = 0;
int nextInt;
int abc = hexString.length(); // вычислим один раз длинну строки, а не в каждой итерации цикла :)
for( int i = 0; i < abc; i++) {
nextInt = int(hexString.charAt(i));
if (nextInt >= 48 && nextInt <= 57) nextInt -=48; // вместо nextInt = map(nextInt, 48, 57, 0, 9);
if (nextInt >= 65 && nextInt <= 70) nextInt -=50; // вместо nextInt = map(nextInt, 65, 70, 10, 15);
if (nextInt >= 97 && nextInt <= 102) nextInt -=80; // вместо nextInt = map(nextInt, 97, 102, 10, 15);
nextInt = constrain(nextInt, 0, 15);
decValue = (decValue * 16) + nextInt;
}
return decValue;
}
Только, честно, я так и не понял, каким образом ТС нужно отсылать данные - пакетом или поштучно, или ещё как...