Skip to content

Commit 9d336d3

Browse files
committed
Change pulseTrainToString length type to uint16_t
1 parent 3ec7545 commit 9d336d3

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/PiCode.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ protocol_t* PiCode::findProtocol(const char* name) {
5555
return nullptr;
5656
}
5757

58-
/* Convert from array of pulses and lenght to pilight string format. Must be free() after use */
59-
char* PiCode::pulseTrainToString(const uint32_t* pulses, unsigned int length, uint8_t repeats){
58+
/* Convert from array of pulses and length to pilight string format. Must be free() after use */
59+
char* PiCode::pulseTrainToString(const uint32_t* pulses, uint16_t length, uint8_t repeats){
6060

6161
bool match = false;
6262
int diff = 0;
@@ -77,7 +77,7 @@ char* PiCode::pulseTrainToString(const uint32_t* pulses, unsigned int length, ui
7777
strcpy(data,"c:");
7878
}
7979

80-
for (unsigned int i = 0; i < length; i++) {
80+
for (uint16_t i = 0; i < length; i++) {
8181
match = false;
8282
for (uint8_t j = 0; j < MAX_PULSE_TYPES; j++) {
8383
// We device these numbers by 10 to normalize them a bit
@@ -186,7 +186,7 @@ static int indexOf(const char* data, char ch, unsigned int fromIndex = 0) {
186186
int PiCode::stringToPulseTrain(const char* data, uint32_t* pulses, size_t maxlength){
187187

188188
int length = 0 ; // length of pulse train
189-
unsigned int nrpulses = 0 ; // number of pulse types
189+
uint8_t nrpulses = 0 ; // number of pulse types
190190
uint32_t plstypes[MAX_PULSE_TYPES] = {0}; // array to store pulse types
191191

192192
// Aux string to compose data string //
@@ -351,7 +351,7 @@ char* PiCode::encodeToString(const char* protocol_name, const char* json_data, u
351351
if (protocol->createCode != nullptr){
352352
n_pulses = encodeToPulseTrain(pulses, protocol, json_data);
353353
if (n_pulses > 0){
354-
result = pulseTrainToString(pulses,(unsigned int)n_pulses, repeats);
354+
result = pulseTrainToString(pulses,(uint16_t)n_pulses, repeats);
355355
}
356356
}
357357
}

src/PiCode.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ class PiCode {
5151
/* Find protocol by name */
5252
protocol_t* findProtocol(const char* name);
5353

54-
/* Convert pulses and lenght to pilight string format. Must be free() after use */
55-
char* pulseTrainToString(const uint32_t* pulses, unsigned int length, uint8_t repeats = 0 );
54+
/* Convert pulses and length to pilight string format. Must be free() after use */
55+
char* pulseTrainToString(const uint32_t* pulses, uint16_t length, uint8_t repeats = 0 );
5656

5757
/* Encode protocol and json data to array of pulses if success */
5858
int encodeToPulseTrain(uint32_t* pulses, protocol_t* protocol, const char* json_data);

0 commit comments

Comments
 (0)