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
+97 -131
View File
@@ -58,14 +58,14 @@
*/
static uint8_t u8g2_clip_intersection2(u8g2_uint_t *ap, u8g2_uint_t *len, u8g2_uint_t c, u8g2_uint_t d)
{
u8g2_uint_t a = *ap;
u8g2_uint_t b;
b = a;
b += *len;
static uint8_t
u8g2_clip_intersection2(u8g2_uint_t* ap, u8g2_uint_t* len, u8g2_uint_t c, u8g2_uint_t d) {
u8g2_uint_t a = *ap;
u8g2_uint_t b;
b = a;
b += *len;
/*
/*
Description:
clip range from a (included) to b (excluded) agains c (included) to d (excluded)
Assumptions:
@@ -78,45 +78,35 @@ static uint8_t u8g2_clip_intersection2(u8g2_uint_t *ap, u8g2_uint_t *len, u8g2_u
replaced by uint8_t u8g2_clip_intersection2
*/
/* handle the a>b case correctly. If code and time is critical, this could */
/* be removed completly (be aware about memory curruption for wrong */
/* arguments) or return 0 for a>b (will lead to skipped lines for wrong */
/* arguments) */
/* removing the following if clause completly may lead to memory corruption of a>b */
if ( a > b )
{
/* replacing this if with a simple "return 0;" will not handle the case with negative a */
if ( a < d )
{
b = d;
b--;
/* handle the a>b case correctly. If code and time is critical, this could */
/* be removed completly (be aware about memory curruption for wrong */
/* arguments) or return 0 for a>b (will lead to skipped lines for wrong */
/* arguments) */
/* removing the following if clause completly may lead to memory corruption of a>b */
if(a > b) {
/* replacing this if with a simple "return 0;" will not handle the case with negative a */
if(a < d) {
b = d;
b--;
} else {
a = c;
}
}
else
{
a = c;
}
}
/* from now on, the asumption a <= b is ok */
if ( a >= d )
return 0;
if ( b <= c )
return 0;
if ( a < c )
a = c;
if ( b > d )
b = d;
*ap = a;
b -= a;
*len = b;
return 1;
/* from now on, the asumption a <= b is ok */
if(a >= d) return 0;
if(b <= c) return 0;
if(a < c) a = c;
if(b > d) b = d;
*ap = a;
b -= a;
*len = b;
return 1;
}
/*==========================================================*/
/* draw procedures */
@@ -129,108 +119,86 @@ static uint8_t u8g2_clip_intersection2(u8g2_uint_t *ap, u8g2_uint_t *len, u8g2_u
will clip the line and call u8g2_draw_low_level_hv_line()
*/
void u8g2_draw_hv_line_2dir(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
{
void u8g2_draw_hv_line_2dir(
u8g2_t* u8g2,
u8g2_uint_t x,
u8g2_uint_t y,
u8g2_uint_t len,
uint8_t dir) {
/* clipping happens before the display rotation */
/* clipping happens before the display rotation */
/* transform to pixel buffer coordinates */
y -= u8g2->pixel_curr_row;
/* transform to pixel buffer coordinates */
y -= u8g2->pixel_curr_row;
u8g2->ll_hvline(u8g2, x, y, len, dir);
u8g2->ll_hvline(u8g2, x, y, len, dir);
}
/*
This is the toplevel function for the hv line draw procedures.
This function should be called by the user.
"dir" may have 4 directions: 0 (left to right), 1, 2, 3 (down up)
*/
void u8g2_DrawHVLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
{
/* Make a call to the callback function (e.g. u8g2_draw_l90_r0). */
/* The callback may rotate the hv line */
/* after rotation this will call u8g2_draw_hv_line_4dir() */
void u8g2_DrawHVLine(u8g2_t* u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) {
/* Make a call to the callback function (e.g. u8g2_draw_l90_r0). */
/* The callback may rotate the hv line */
/* after rotation this will call u8g2_draw_hv_line_4dir() */
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
if ( u8g2->is_page_clip_window_intersection != 0 )
if(u8g2->is_page_clip_window_intersection != 0)
#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */
if ( len != 0 )
{
/* convert to two directions */
if ( len > 1 )
{
if ( dir == 2 )
{
x -= len;
x++;
}
else if ( dir == 3 )
{
y -= len;
y++;
}
}
dir &= 1;
/* clip against the user window */
if ( dir == 0 )
{
if ( y < u8g2->user_y0 )
return;
if ( y >= u8g2->user_y1 )
return;
if ( u8g2_clip_intersection2(&x, &len, u8g2->user_x0, u8g2->user_x1) == 0 )
return;
}
else
{
if ( x < u8g2->user_x0 )
return;
if ( x >= u8g2->user_x1 )
return;
if ( u8g2_clip_intersection2(&y, &len, u8g2->user_y0, u8g2->user_y1) == 0 )
return;
}
u8g2->cb->draw_l90(u8g2, x, y, len, dir);
}
if(len != 0) {
/* convert to two directions */
if(len > 1) {
if(dir == 2) {
x -= len;
x++;
} else if(dir == 3) {
y -= len;
y++;
}
}
dir &= 1;
/* clip against the user window */
if(dir == 0) {
if(y < u8g2->user_y0) return;
if(y >= u8g2->user_y1) return;
if(u8g2_clip_intersection2(&x, &len, u8g2->user_x0, u8g2->user_x1) == 0) return;
} else {
if(x < u8g2->user_x0) return;
if(x >= u8g2->user_x1) return;
if(u8g2_clip_intersection2(&y, &len, u8g2->user_y0, u8g2->user_y1) == 0) return;
}
u8g2->cb->draw_l90(u8g2, x, y, len, dir);
}
}
void u8g2_DrawHLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len)
{
// #ifdef U8G2_WITH_INTERSECTION
// if ( u8g2_IsIntersection(u8g2, x, y, x+len, y+1) == 0 )
// return;
// #endif /* U8G2_WITH_INTERSECTION */
u8g2_DrawHVLine(u8g2, x, y, len, 0);
void u8g2_DrawHLine(u8g2_t* u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len) {
// #ifdef U8G2_WITH_INTERSECTION
// if ( u8g2_IsIntersection(u8g2, x, y, x+len, y+1) == 0 )
// return;
// #endif /* U8G2_WITH_INTERSECTION */
u8g2_DrawHVLine(u8g2, x, y, len, 0);
}
void u8g2_DrawVLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len)
{
// #ifdef U8G2_WITH_INTERSECTION
// if ( u8g2_IsIntersection(u8g2, x, y, x+1, y+len) == 0 )
// return;
// #endif /* U8G2_WITH_INTERSECTION */
u8g2_DrawHVLine(u8g2, x, y, len, 1);
void u8g2_DrawVLine(u8g2_t* u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len) {
// #ifdef U8G2_WITH_INTERSECTION
// if ( u8g2_IsIntersection(u8g2, x, y, x+1, y+len) == 0 )
// return;
// #endif /* U8G2_WITH_INTERSECTION */
u8g2_DrawHVLine(u8g2, x, y, len, 1);
}
void u8g2_DrawPixel(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y)
{
void u8g2_DrawPixel(u8g2_t* u8g2, u8g2_uint_t x, u8g2_uint_t y) {
#ifdef U8G2_WITH_INTERSECTION
if ( y < u8g2->user_y0 )
return;
if ( y >= u8g2->user_y1 )
return;
if ( x < u8g2->user_x0 )
return;
if ( x >= u8g2->user_x1 )
return;
if(y < u8g2->user_y0) return;
if(y >= u8g2->user_y1) return;
if(x < u8g2->user_x0) return;
if(x >= u8g2->user_x1) return;
#endif /* U8G2_WITH_INTERSECTION */
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
u8g2_DrawHVLine(u8g2, x, y, 1, 0);
}
/*
@@ -246,10 +214,8 @@ void u8g2_DrawPixel(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y)
7 Jan 2017: Allow color value 2 for XOR operation.
*/
void u8g2_SetDrawColor(u8g2_t *u8g2, uint8_t color)
{
u8g2->draw_color = color; /* u8g2_SetDrawColor: just assign the argument */
if ( color >= 3 )
u8g2->draw_color = 1; /* u8g2_SetDrawColor: make color as one if arg is invalid */
void u8g2_SetDrawColor(u8g2_t* u8g2, uint8_t color) {
u8g2->draw_color = color; /* u8g2_SetDrawColor: just assign the argument */
if(color >= 3)
u8g2->draw_color = 1; /* u8g2_SetDrawColor: make color as one if arg is invalid */
}