Naming and coding style convention, new linter tool. (#945)

* Makefile, Scripts: new linter
* About: remove ID from IC
* Firmware: remove double define for DIVC/DIVR
* Scripts: check folder names too. Docker: replace syntax check with make lint.
* Reformat Sources and Migrate to new file naming convention
* Docker: symlink clang-format-12 to clang-format
* Add coding style guide
This commit is contained in:
あく
2022-01-05 19:10:18 +03:00
committed by GitHub
parent c98e54da10
commit 389ff92cc1
899 changed files with 379245 additions and 373421 deletions

View File

@@ -6,7 +6,6 @@
#include <furi.h>
#include "../irda_i.h"
IrdaMessage* irda_decoder_nec_check_ready(void* ctx) {
return irda_common_decoder_check_ready(ctx);
}
@@ -16,12 +15,12 @@ bool irda_decoder_nec_interpret(IrdaCommonDecoder* decoder) {
bool result = false;
if (decoder->databit_cnt == 32) {
if(decoder->databit_cnt == 32) {
uint8_t address = decoder->data[0];
uint8_t address_inverse = decoder->data[1];
uint8_t command = decoder->data[2];
uint8_t command_inverse = decoder->data[3];
if ((command == (uint8_t) ~command_inverse) && (address == (uint8_t) ~address_inverse)) {
if((command == (uint8_t)~command_inverse) && (address == (uint8_t)~address_inverse)) {
decoder->message.protocol = IrdaProtocolNEC;
decoder->message.address = address;
decoder->message.command = command;
@@ -34,16 +33,15 @@ bool irda_decoder_nec_interpret(IrdaCommonDecoder* decoder) {
decoder->message.repeat = false;
result = true;
}
} else if (decoder->databit_cnt == 42) {
uint32_t* data1 = (void*) decoder->data;
uint16_t* data2 = (void*) (data1 + 1);
} else if(decoder->databit_cnt == 42) {
uint32_t* data1 = (void*)decoder->data;
uint16_t* data2 = (void*)(data1 + 1);
uint16_t address = *data1 & 0x1FFF;
uint16_t address_inverse = (*data1 >> 13) & 0x1FFF;
uint16_t command = ((*data1 >> 26) & 0x3F) | ((*data2 & 0x3) << 6);
uint16_t command_inverse = (*data2 >> 2) & 0xFF;
if ((address == (~address_inverse & 0x1FFF))
&& (command == (~command_inverse & 0xFF))) {
if((address == (~address_inverse & 0x1FFF)) && (command == (~command_inverse & 0xFF))) {
decoder->message.protocol = IrdaProtocolNEC42;
decoder->message.address = address;
decoder->message.command = command;
@@ -100,4 +98,3 @@ void irda_decoder_nec_free(void* decoder) {
void irda_decoder_nec_reset(void* decoder) {
irda_common_decoder_reset(decoder);
}

View File

@@ -20,9 +20,9 @@ void irda_encoder_nec_reset(void* encoder_ptr, const IrdaMessage* message) {
IrdaCommonEncoder* encoder = encoder_ptr;
irda_common_encoder_reset(encoder);
uint32_t* data1 = (void*) encoder->data;
uint32_t* data1 = (void*)encoder->data;
uint32_t* data2 = data1 + 1;
if (message->protocol == IrdaProtocolNEC) {
if(message->protocol == IrdaProtocolNEC) {
uint8_t address = message->address;
uint8_t address_inverse = ~address;
uint8_t command = message->command;
@@ -32,11 +32,11 @@ void irda_encoder_nec_reset(void* encoder_ptr, const IrdaMessage* message) {
*data1 |= command << 16;
*data1 |= command_inverse << 24;
encoder->bits_to_encode = 32;
} else if (message->protocol == IrdaProtocolNECext) {
*data1 = (uint16_t) message->address;
} else if(message->protocol == IrdaProtocolNECext) {
*data1 = (uint16_t)message->address;
*data1 |= (message->command & 0xFFFF) << 16;
encoder->bits_to_encode = 32;
} else if (message->protocol == IrdaProtocolNEC42) {
} else if(message->protocol == IrdaProtocolNEC42) {
/* 13 address + 13 inverse address + 8 command + 8 inv command */
*data1 = message->address & 0x1FFFUL;
*data1 |= (~message->address & 0x1FFFUL) << 13;
@@ -44,7 +44,7 @@ void irda_encoder_nec_reset(void* encoder_ptr, const IrdaMessage* message) {
*data2 = (message->command & 0xC0UL) >> 6;
*data2 |= (~message->command & 0xFFUL) << 2;
encoder->bits_to_encode = 42;
} else if (message->protocol == IrdaProtocolNEC42ext) {
} else if(message->protocol == IrdaProtocolNEC42ext) {
*data1 = message->address & 0x3FFFFFF;
*data1 |= ((message->command & 0x3F) << 26);
*data2 = (message->command & 0xFFC0) >> 6;
@@ -54,7 +54,8 @@ void irda_encoder_nec_reset(void* encoder_ptr, const IrdaMessage* message) {
}
}
IrdaStatus irda_encoder_nec_encode_repeat(IrdaCommonEncoder* encoder, uint32_t* duration, bool* level) {
IrdaStatus
irda_encoder_nec_encode_repeat(IrdaCommonEncoder* encoder, uint32_t* duration, bool* level) {
furi_assert(encoder);
/* space + 2 timings preambule + payload + stop bit */
@@ -63,7 +64,7 @@ IrdaStatus irda_encoder_nec_encode_repeat(IrdaCommonEncoder* encoder, uint32_t*
furi_assert(encoder->timings_encoded >= timings_encoded_up_to_repeat);
if (repeat_cnt > 0) {
if(repeat_cnt > 0) {
*duration = repeat_timings[repeat_cnt % COUNT_OF(repeat_timings)];
} else {
*duration = IRDA_NEC_REPEAT_PERIOD - encoder->timings_sum;
@@ -87,4 +88,3 @@ void irda_encoder_nec_free(void* encoder_ptr) {
IrdaStatus irda_encoder_nec_encode(void* encoder_ptr, uint32_t* duration, bool* level) {
return irda_common_encode(encoder_ptr, duration, level);
}

View File

@@ -2,47 +2,46 @@
#include "irda_protocol_defs_i.h"
static const IrdaProtocolSpecification irda_nec_protocol_specification = {
.name = "NEC",
.address_length = 8,
.command_length = 8,
.frequency = IRDA_COMMON_CARRIER_FREQUENCY,
.duty_cycle = IRDA_COMMON_DUTY_CYCLE,
.name = "NEC",
.address_length = 8,
.command_length = 8,
.frequency = IRDA_COMMON_CARRIER_FREQUENCY,
.duty_cycle = IRDA_COMMON_DUTY_CYCLE,
};
static const IrdaProtocolSpecification irda_necext_protocol_specification = {
.name = "NECext",
.address_length = 16,
.command_length = 16,
.frequency = IRDA_COMMON_CARRIER_FREQUENCY,
.duty_cycle = IRDA_COMMON_DUTY_CYCLE,
.name = "NECext",
.address_length = 16,
.command_length = 16,
.frequency = IRDA_COMMON_CARRIER_FREQUENCY,
.duty_cycle = IRDA_COMMON_DUTY_CYCLE,
};
static const IrdaProtocolSpecification irda_nec42_protocol_specification = {
.name = "NEC42",
.address_length = 13,
.command_length = 8,
.frequency = IRDA_COMMON_CARRIER_FREQUENCY,
.duty_cycle = IRDA_COMMON_DUTY_CYCLE,
.name = "NEC42",
.address_length = 13,
.command_length = 8,
.frequency = IRDA_COMMON_CARRIER_FREQUENCY,
.duty_cycle = IRDA_COMMON_DUTY_CYCLE,
};
static const IrdaProtocolSpecification irda_nec42ext_protocol_specification = {
.name = "NEC42ext",
.address_length = 26,
.command_length = 16,
.frequency = IRDA_COMMON_CARRIER_FREQUENCY,
.duty_cycle = IRDA_COMMON_DUTY_CYCLE,
.name = "NEC42ext",
.address_length = 26,
.command_length = 16,
.frequency = IRDA_COMMON_CARRIER_FREQUENCY,
.duty_cycle = IRDA_COMMON_DUTY_CYCLE,
};
const IrdaProtocolSpecification* irda_nec_get_spec(IrdaProtocol protocol) {
if (protocol == IrdaProtocolNEC)
if(protocol == IrdaProtocolNEC)
return &irda_nec_protocol_specification;
else if (protocol == IrdaProtocolNECext)
else if(protocol == IrdaProtocolNECext)
return &irda_necext_protocol_specification;
else if (protocol == IrdaProtocolNEC42)
else if(protocol == IrdaProtocolNEC42)
return &irda_nec42_protocol_specification;
else if (protocol == IrdaProtocolNEC42ext)
else if(protocol == IrdaProtocolNEC42ext)
return &irda_nec42ext_protocol_specification;
else
return NULL;
}