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

@@ -20,7 +20,7 @@ bool irda_decoder_rc5_interpret(IrdaCommonDecoder* decoder) {
furi_assert(decoder);
bool result = false;
uint32_t* data = (void*) &decoder->data[0];
uint32_t* data = (void*)&decoder->data[0];
/* Manchester (inverse):
* 0->1 : 1
* 1->0 : 0
@@ -29,20 +29,19 @@ bool irda_decoder_rc5_interpret(IrdaCommonDecoder* decoder) {
decoder->data[1] = ~decoder->data[1];
// MSB first
uint8_t address = reverse((uint8_t) decoder->data[0]) & 0x1F;
uint8_t command = (reverse((uint8_t) decoder->data[1]) >> 2) & 0x3F;
uint8_t address = reverse((uint8_t)decoder->data[0]) & 0x1F;
uint8_t command = (reverse((uint8_t)decoder->data[1]) >> 2) & 0x3F;
bool start_bit1 = *data & 0x01;
bool start_bit2 = *data & 0x02;
bool toggle = !!(*data & 0x04);
if (start_bit1 == 1) {
if(start_bit1 == 1) {
IrdaProtocol protocol = start_bit2 ? IrdaProtocolRC5 : IrdaProtocolRC5X;
IrdaMessage* message = &decoder->message;
IrdaRc5Decoder *rc5_decoder = decoder->context;
bool *prev_toggle = &rc5_decoder->toggle;
if ((message->address == address)
&& (message->command == command)
&& (message->protocol == protocol)) {
IrdaRc5Decoder* rc5_decoder = decoder->context;
bool* prev_toggle = &rc5_decoder->toggle;
if((message->address == address) && (message->command == command) &&
(message->protocol == protocol)) {
message->repeat = (toggle == *prev_toggle);
} else {
message->repeat = false;
@@ -81,4 +80,3 @@ void irda_decoder_rc5_reset(void* decoder) {
IrdaRc5Decoder* decoder_rc5 = decoder;
irda_common_decoder_reset(decoder_rc5->common_decoder);
}

View File

@@ -17,11 +17,11 @@ void irda_encoder_rc5_reset(void* encoder_ptr, const IrdaMessage* message) {
IrdaCommonEncoder* common_encoder = encoder->common_encoder;
irda_common_encoder_reset(common_encoder);
uint32_t* data = (void*) common_encoder->data;
uint32_t* data = (void*)common_encoder->data;
/* RC5 */
*data |= 0x01; // start bit
if (message->protocol == IrdaProtocolRC5) {
*data |= 0x02; // start bit
*data |= 0x01; // start bit
if(message->protocol == IrdaProtocolRC5) {
*data |= 0x02; // start bit
}
*data |= encoder->toggle_bit ? 0x04 : 0;
*data |= (reverse(message->address) >> 3) << 3; /* address 5 bit */
@@ -53,4 +53,3 @@ void irda_encoder_rc5_free(void* encoder_ptr) {
free(encoder->common_encoder);
free(encoder);
}

View File

@@ -2,27 +2,26 @@
#include "irda_protocol_defs_i.h"
static const IrdaProtocolSpecification irda_rc5_protocol_specification = {
.name = "RC5",
.address_length = 5,
.command_length = 6,
.frequency = IRDA_RC5_CARRIER_FREQUENCY,
.duty_cycle = IRDA_RC5_DUTY_CYCLE,
.name = "RC5",
.address_length = 5,
.command_length = 6,
.frequency = IRDA_RC5_CARRIER_FREQUENCY,
.duty_cycle = IRDA_RC5_DUTY_CYCLE,
};
static const IrdaProtocolSpecification irda_rc5x_protocol_specification = {
.name = "RC5X",
.address_length = 5,
.command_length = 7,
.frequency = IRDA_RC5_CARRIER_FREQUENCY,
.duty_cycle = IRDA_RC5_DUTY_CYCLE,
.name = "RC5X",
.address_length = 5,
.command_length = 7,
.frequency = IRDA_RC5_CARRIER_FREQUENCY,
.duty_cycle = IRDA_RC5_DUTY_CYCLE,
};
const IrdaProtocolSpecification* irda_rc5_get_spec(IrdaProtocol protocol) {
if (protocol == IrdaProtocolRC5)
if(protocol == IrdaProtocolRC5)
return &irda_rc5_protocol_specification;
else if (protocol == IrdaProtocolRC5X)
else if(protocol == IrdaProtocolRC5X)
return &irda_rc5x_protocol_specification;
else
return NULL;
}