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

@@ -1,6 +1,6 @@
#include "u8g2_glue.h"
#include <furi-hal.h>
#include <furi_hal.h>
uint8_t u8g2_gpio_and_delay_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ptr) {
switch(msg) {
@@ -49,135 +49,138 @@ uint8_t u8x8_hw_spi_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_
return 1;
}
#define ST756X_CMD_ON_OFF 0b10101110 /**< 0:0 Switch Display ON/OFF: last bit */
#define ST756X_CMD_SET_LINE 0b01000000 /**< 0:0 Set Start Line: last 6 bits */
#define ST756X_CMD_SET_PAGE 0b10110000 /**< 0:0 Set Page address: last 4 bits */
#define ST756X_CMD_SET_COLUMN_MSB 0b00010000 /**< 0:0 Set Column MSB: last 4 bits */
#define ST756X_CMD_SET_COLUMN_LSB 0b00000000 /**< 0:0 Set Column LSB: last 4 bits */
#define ST756X_CMD_SEG_DIRECTION 0b10100000 /**< 0:0 Reverse scan direction of SEG: last bit */
#define ST756X_CMD_INVERSE_DISPLAY 0b10100110 /**< 0:0 Invert display: last bit */
#define ST756X_CMD_ALL_PIXEL_ON 0b10100100 /**< 0:0 Set all pixel on: last bit */
#define ST756X_CMD_BIAS_SELECT 0b10100010 /**< 0:0 Select 1/9(0) or 1/7(1) bias: last bit */
#define ST756X_CMD_R_M_W 0b11100000 /**< 0:0 Enter Read Modify Write mode: read+0, write+1 */
#define ST756X_CMD_END 0b11101110 /**< 0:0 Exit Read Modify Write mode */
#define ST756X_CMD_RESET 0b11100010 /**< 0:0 Software Reset */
#define ST756X_CMD_COM_DIRECTION 0b11000000 /**< 0:0 Com direction reverse: +0b1000 */
#define ST756X_CMD_POWER_CONTROL 0b00101000 /**< 0:0 Power control: last 3 bits VB:VR:VF */
#define ST756X_CMD_REGULATION_RATIO 0b00100000 /**< 0:0 Regulation resistor ration: last 3bits */
#define ST756X_CMD_SET_EV 0b10000001 /**< 0:0 Set electronic volume: 5 bits in next byte */
#define ST756X_CMD_SET_BOOSTER 0b11111000 /**< 0:0 Set Booster level, 4X(0) or 5X(1): last bit in next byte */
#define ST756X_CMD_NOP 0b11100011 /**< 0:0 No operation */
#define ST756X_CMD_ON_OFF 0b10101110 /**< 0:0 Switch Display ON/OFF: last bit */
#define ST756X_CMD_SET_LINE 0b01000000 /**< 0:0 Set Start Line: last 6 bits */
#define ST756X_CMD_SET_PAGE 0b10110000 /**< 0:0 Set Page address: last 4 bits */
#define ST756X_CMD_SET_COLUMN_MSB 0b00010000 /**< 0:0 Set Column MSB: last 4 bits */
#define ST756X_CMD_SET_COLUMN_LSB 0b00000000 /**< 0:0 Set Column LSB: last 4 bits */
#define ST756X_CMD_SEG_DIRECTION 0b10100000 /**< 0:0 Reverse scan direction of SEG: last bit */
#define ST756X_CMD_INVERSE_DISPLAY 0b10100110 /**< 0:0 Invert display: last bit */
#define ST756X_CMD_ALL_PIXEL_ON 0b10100100 /**< 0:0 Set all pixel on: last bit */
#define ST756X_CMD_BIAS_SELECT 0b10100010 /**< 0:0 Select 1/9(0) or 1/7(1) bias: last bit */
#define ST756X_CMD_R_M_W 0b11100000 /**< 0:0 Enter Read Modify Write mode: read+0, write+1 */
#define ST756X_CMD_END 0b11101110 /**< 0:0 Exit Read Modify Write mode */
#define ST756X_CMD_RESET 0b11100010 /**< 0:0 Software Reset */
#define ST756X_CMD_COM_DIRECTION 0b11000000 /**< 0:0 Com direction reverse: +0b1000 */
#define ST756X_CMD_POWER_CONTROL 0b00101000 /**< 0:0 Power control: last 3 bits VB:VR:VF */
#define ST756X_CMD_REGULATION_RATIO 0b00100000 /**< 0:0 Regulation resistor ration: last 3bits */
#define ST756X_CMD_SET_EV 0b10000001 /**< 0:0 Set electronic volume: 5 bits in next byte */
#define ST756X_CMD_SET_BOOSTER \
0b11111000 /**< 0:0 Set Booster level, 4X(0) or 5X(1): last bit in next byte */
#define ST756X_CMD_NOP 0b11100011 /**< 0:0 No operation */
static const uint8_t u8x8_d_st756x_powersave0_seq[] = {
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
U8X8_C(ST756X_CMD_ALL_PIXEL_ON | 0b0), /* all pixel off */
U8X8_C(ST756X_CMD_ON_OFF | 0b1), /* display on */
U8X8_END_TRANSFER(), /* disable chip */
U8X8_END() /* end of sequence */
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
U8X8_C(ST756X_CMD_ALL_PIXEL_ON | 0b0), /* all pixel off */
U8X8_C(ST756X_CMD_ON_OFF | 0b1), /* display on */
U8X8_END_TRANSFER(), /* disable chip */
U8X8_END() /* end of sequence */
};
static const uint8_t u8x8_d_st756x_powersave1_seq[] = {
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
U8X8_C(ST756X_CMD_ON_OFF | 0b0), /* display off */
U8X8_C(ST756X_CMD_ALL_PIXEL_ON | 0b1), /* all pixel on */
U8X8_END_TRANSFER(), /* disable chip */
U8X8_END() /* end of sequence */
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
U8X8_C(ST756X_CMD_ON_OFF | 0b0), /* display off */
U8X8_C(ST756X_CMD_ALL_PIXEL_ON | 0b1), /* all pixel on */
U8X8_END_TRANSFER(), /* disable chip */
U8X8_END() /* end of sequence */
};
static const uint8_t u8x8_d_st756x_flip0_seq[] = {
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
U8X8_C(0x0a1), /* segment remap a0/a1*/
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
U8X8_END_TRANSFER(), /* disable chip */
U8X8_END() /* end of sequence */
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
U8X8_C(0x0a1), /* segment remap a0/a1*/
U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
U8X8_END_TRANSFER(), /* disable chip */
U8X8_END() /* end of sequence */
};
static const uint8_t u8x8_d_st756x_flip1_seq[] = {
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
U8X8_C(0x0a0), /* segment remap a0/a1*/
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
U8X8_END_TRANSFER(), /* disable chip */
U8X8_END() /* end of sequence */
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
U8X8_C(0x0a0), /* segment remap a0/a1*/
U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
U8X8_END_TRANSFER(), /* disable chip */
U8X8_END() /* end of sequence */
};
static const u8x8_display_info_t u8x8_st756x_128x64_display_info = {
.chip_enable_level = 0,
.chip_disable_level = 1,
.post_chip_enable_wait_ns = 150, /* st7565 datasheet, table 26, tcsh */
.pre_chip_disable_wait_ns = 50, /* st7565 datasheet, table 26, tcss */
.post_chip_enable_wait_ns = 150, /* st7565 datasheet, table 26, tcsh */
.pre_chip_disable_wait_ns = 50, /* st7565 datasheet, table 26, tcss */
.reset_pulse_width_ms = 1,
.post_reset_wait_ms = 1,
.sda_setup_time_ns = 50, /* st7565 datasheet, table 26, tsds */
.sck_pulse_width_ns = 120, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
.sck_clock_hz = 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
.spi_mode = 0, /* active high, rising edge */
.sda_setup_time_ns = 50, /* st7565 datasheet, table 26, tsds */
.sck_pulse_width_ns =
120, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
.sck_clock_hz =
4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
.spi_mode = 0, /* active high, rising edge */
.i2c_bus_clock_100kHz = 4,
.data_setup_time_ns = 40, /* st7565 datasheet, table 24, tds8 */
.write_pulse_width_ns = 80, /* st7565 datasheet, table 24, tcclw */
.tile_width = 16, /* width of 16*8=128 pixel */
.data_setup_time_ns = 40, /* st7565 datasheet, table 24, tds8 */
.write_pulse_width_ns = 80, /* st7565 datasheet, table 24, tcclw */
.tile_width = 16, /* width of 16*8=128 pixel */
.tile_height = 8,
.default_x_offset = 0,
.flipmode_x_offset = 4,
.pixel_width = 128,
.pixel_height = 64
};
.pixel_height = 64};
uint8_t u8x8_d_st756x_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) {
uint8_t u8x8_d_st756x_common(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ptr) {
uint8_t x, c;
uint8_t *ptr;
uint8_t* ptr;
switch(msg) {
case U8X8_MSG_DISPLAY_DRAW_TILE:
u8x8_cad_StartTransfer(u8x8);
case U8X8_MSG_DISPLAY_DRAW_TILE:
u8x8_cad_StartTransfer(u8x8);
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
x *= 8;
x += u8x8->x_offset;
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
x = ((u8x8_tile_t*)arg_ptr)->x_pos;
x *= 8;
x += u8x8->x_offset;
u8x8_cad_SendCmd(u8x8, 0x010 | (x >> 4));
u8x8_cad_SendCmd(u8x8, 0x000 | ((x & 15)));
u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t*)arg_ptr)->y_pos));
c = ((u8x8_tile_t *)arg_ptr)->cnt;
c *= 8;
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
/*
c = ((u8x8_tile_t*)arg_ptr)->cnt;
c *= 8;
ptr = ((u8x8_tile_t*)arg_ptr)->tile_ptr;
/*
The following if condition checks the hardware limits of the st7565
controller: It is not allowed to write beyond the display limits.
This is in fact an issue within flip mode.
*/
if ( c + x > 132u ) {
c = 132u;
c -= x;
}
if(c + x > 132u) {
c = 132u;
c -= x;
}
do {
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
arg_int--;
} while( arg_int > 0 );
do {
u8x8_cad_SendData(
u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
arg_int--;
} while(arg_int > 0);
u8x8_cad_EndTransfer(u8x8);
break;
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
if ( arg_int == 0 )
u8x8_cad_SendSequence(u8x8, u8x8_d_st756x_powersave0_seq);
else
u8x8_cad_SendSequence(u8x8, u8x8_d_st756x_powersave1_seq);
break;
u8x8_cad_EndTransfer(u8x8);
break;
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
if(arg_int == 0)
u8x8_cad_SendSequence(u8x8, u8x8_d_st756x_powersave0_seq);
else
u8x8_cad_SendSequence(u8x8, u8x8_d_st756x_powersave1_seq);
break;
#ifdef U8X8_WITH_SET_CONTRAST
case U8X8_MSG_DISPLAY_SET_CONTRAST:
u8x8_cad_StartTransfer(u8x8);
u8x8_cad_SendCmd(u8x8, ST756X_CMD_SET_EV);
u8x8_cad_SendArg(u8x8, arg_int >> 2 ); /* st7565 has range from 0 to 63 */
u8x8_cad_EndTransfer(u8x8);
break;
case U8X8_MSG_DISPLAY_SET_CONTRAST:
u8x8_cad_StartTransfer(u8x8);
u8x8_cad_SendCmd(u8x8, ST756X_CMD_SET_EV);
u8x8_cad_SendArg(u8x8, arg_int >> 2); /* st7565 has range from 0 to 63 */
u8x8_cad_EndTransfer(u8x8);
break;
#endif
default:
return 0;
default:
return 0;
}
return 1;
}
void u8x8_d_st756x_init(u8x8_t *u8x8, uint8_t contrast, uint8_t regulation_ratio, bool bias) {
void u8x8_d_st756x_init(u8x8_t* u8x8, uint8_t contrast, uint8_t regulation_ratio, bool bias) {
contrast = contrast & 0b00111111;
regulation_ratio = regulation_ratio & 0b111;
@@ -201,18 +204,18 @@ void u8x8_d_st756x_init(u8x8_t *u8x8, uint8_t contrast, uint8_t regulation_ratio
u8x8_cad_EndTransfer(u8x8);
}
uint8_t u8x8_d_st756x_flipper(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) {
uint8_t u8x8_d_st756x_flipper(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ptr) {
/* call common procedure first and handle messages there */
if (u8x8_d_st756x_common(u8x8, msg, arg_int, arg_ptr) == 0) {
if(u8x8_d_st756x_common(u8x8, msg, arg_int, arg_ptr) == 0) {
/* msg not handled, then try here */
switch(msg){
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
switch(msg) {
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st756x_128x64_display_info);
break;
case U8X8_MSG_DISPLAY_INIT:
u8x8_d_helper_display_init(u8x8);
FuriHalVersionDisplay display = furi_hal_version_get_hw_display();
if (display == FuriHalVersionDisplayMgg) {
if(display == FuriHalVersionDisplayMgg) {
/* MGG v0+(ST7567)
* EV = 32
* RR = V0 / ((1 - (63 - EV) / 162) * 2.1)
@@ -231,13 +234,13 @@ uint8_t u8x8_d_st756x_flipper(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *
}
break;
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
if ( arg_int == 0 ) {
if(arg_int == 0) {
u8x8_cad_SendSequence(u8x8, u8x8_d_st756x_flip1_seq);
u8x8->x_offset = u8x8->display_info->default_x_offset;
} else {
u8x8_cad_SendSequence(u8x8, u8x8_d_st756x_flip0_seq);
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
}
}
break;
default:
/* msg unknown */
@@ -247,9 +250,13 @@ uint8_t u8x8_d_st756x_flipper(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *
return 1;
}
void u8g2_Setup_st756x_flipper(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb) {
void u8g2_Setup_st756x_flipper(
u8g2_t* u8g2,
const u8g2_cb_t* rotation,
u8x8_msg_cb byte_cb,
u8x8_msg_cb gpio_and_delay_cb) {
uint8_t tile_buf_height;
uint8_t *buf;
uint8_t* buf;
u8g2_SetupDisplay(u8g2, u8x8_d_st756x_flipper, u8x8_cad_001, byte_cb, gpio_and_delay_cb);
buf = u8g2_m_16_8_f(&tile_buf_height);
u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation);