Я хочу преобразовать строку в uint16_t в Arduino - PullRequest
0 голосов
/ 20 июня 2019

Я хочу преобразовать строку onn в uint-16_t, которую я использую с помощью rawdata с ИК-пульта, и код, подобный этому, который я хочу использовать z в irsend Я пробовал это так, но не не работает:

 uint16_t onn30 [227] = {2980, 1802,  448, 1102,  394, 1134,  418, 408,  418, 410,  418, 434,  392, 1156,  448, 380,  392, 448,  394, 1156,  420, 1130,  394, 410,  418, 1158,  392, 434,  420, 406,  394, 1156,  394, 1172,  448, 356,  416, 1156,  394, 1158,  394, 434,  392, 434,  394, 1158,  392, 434,  394, 450,  392, 1156,  394, 434,  394, 434,  392, 408,  418, 434,  392, 434,  394, 410,  418, 448,  394, 434,  394, 410,  416, 410,  418, 434,  392, 434,  394, 434,  394, 434,  392, 448,  392, 434,  392, 434,  394, 1156,  392, 434,  392, 434,  394, 1158,  392, 434,  394, 448,  394, 1158,  392, 1158,  394, 434,  392, 434,  392, 436,  418, 408,  392, 434,  392, 450,  392, 410,  418, 434,  394, 410,  416, 436,  392, 408,  442, 410,  392, 434,  392, 448,  394, 434,  394, 434,  392, 434,  394, 434,  392, 434,  394, 410,  416, 1134,  416, 448,  394, 434,  392, 436,  392, 434,  392, 434,  394, 410,  416, 434,  392, 434,  420, 422,  392, 434,  392, 434,  394, 434,  394, 434,  394, 432,  418, 408,  394, 434,  394, 426,  416, 434,  418, 384,  418, 434,  394, 434,  392, 434,  418, 384,  416, 434,  394, 448,  394, 434,  394, 432,  394, 434,  394, 434,  392, 434,  394, 410,  444, 408,  394, 448,  394, 434,  418, 410,  392, 1158,  418, 1130,  394, 1158,  394, 1156,  448, 1104,  392, 428,  416};  // UNKNOWN F0A17D53

 uint16_t onn27 [227] = {2980, 1776,  420, 1156,  394, 1158,  392, 434,  396, 408,  418, 432,  394, 1156,  394, 434,  394, 448,  394, 1132,  420, 1134,  416, 434,  448, 1102,  394, 410,  418, 432,  394, 1132,  418, 1170,  394, 432,  394, 1156,  394, 1156,  394, 432,  420, 408,  394, 1156,  420, 408,  394, 448,  448, 1102,  394, 432,  394, 432,  394, 434,  394, 432,  394, 434,  450, 354,  418, 448,  394, 434,  394, 432,  394, 434,  394, 410,  442, 408,  394, 434,  394, 434,  420, 422,  394, 410,  442, 384,  418, 1158,  394, 434,  394, 434,  418, 1108,  418, 434,  394, 448,  394, 1132,  418, 1158,  394, 432,  394, 410,  418, 434,  394, 432,  396, 432,  394, 448,  394, 434,  394, 434,  394, 1158,  392, 434,  392, 434,  394, 434,  418, 384,  418, 448,  394, 434,  392, 434,  394, 410,  418, 434,  446, 356,  418, 434,  418, 1132,  394, 448,  394, 410,  418, 432,  394, 410,  418, 432,  420, 408,  420, 408,  394, 434,  392, 448,  394, 432,  394, 434,  394, 434,  446, 380,  394, 432,  394, 432,  394, 434,  448, 392,  392, 434,  394, 432,  394, 432,  418, 410,  394, 432,  394, 410,  416, 434,  418, 424,  392, 410,  442, 408,  394, 434,  392, 432,  448, 378,  394, 432,  448, 380,  394, 448,  394, 432,  420, 408,  394, 432,  394, 434,  394, 432,  394, 434,  394, 432,  448, 1120,  394};  // UNKNOWN 1794BB83

 String onn = "onn";
 uint16_t x = strtol(onn.c_str(), NULL, 0);
 uint16_t y;
 uint16_t z;
 y = setpoint;
 z = x+y;

 //Serial.println(z); which z should print like onn30 or onn27 depends on the setpoint

 irsend.sendRaw( z, 227, 38);
...