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:
@@ -37,10 +37,8 @@
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8x8.h"
|
||||
|
||||
|
||||
/*==========================================*/
|
||||
/* internal library function */
|
||||
|
||||
@@ -49,11 +47,10 @@
|
||||
It can be called within the display callback function to carry out the usual standard tasks.
|
||||
|
||||
*/
|
||||
void u8x8_d_helper_display_setup_memory(u8x8_t *u8x8, const u8x8_display_info_t *display_info)
|
||||
{
|
||||
/* 1) set display info struct */
|
||||
u8x8->display_info = display_info;
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
void u8x8_d_helper_display_setup_memory(u8x8_t* u8x8, const u8x8_display_info_t* display_info) {
|
||||
/* 1) set display info struct */
|
||||
u8x8->display_info = display_info;
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -61,105 +58,93 @@ void u8x8_d_helper_display_setup_memory(u8x8_t *u8x8, const u8x8_display_info_t
|
||||
It can be called within the display callback function to carry out the usual standard tasks.
|
||||
|
||||
*/
|
||||
void u8x8_d_helper_display_init(u8x8_t *u8x8)
|
||||
{
|
||||
/* 2) apply port directions to the GPIO lines and apply default values for the IO lines*/
|
||||
u8x8_gpio_Init(u8x8);
|
||||
u8x8_cad_Init(u8x8);
|
||||
void u8x8_d_helper_display_init(u8x8_t* u8x8) {
|
||||
/* 2) apply port directions to the GPIO lines and apply default values for the IO lines*/
|
||||
u8x8_gpio_Init(u8x8);
|
||||
u8x8_cad_Init(u8x8);
|
||||
|
||||
/* 3) do reset */
|
||||
u8x8_gpio_SetReset(u8x8, 1);
|
||||
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_MILLI, u8x8->display_info->reset_pulse_width_ms);
|
||||
u8x8_gpio_SetReset(u8x8, 0);
|
||||
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_MILLI, u8x8->display_info->reset_pulse_width_ms);
|
||||
u8x8_gpio_SetReset(u8x8, 1);
|
||||
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_MILLI, u8x8->display_info->post_reset_wait_ms);
|
||||
}
|
||||
/* 3) do reset */
|
||||
u8x8_gpio_SetReset(u8x8, 1);
|
||||
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_MILLI, u8x8->display_info->reset_pulse_width_ms);
|
||||
u8x8_gpio_SetReset(u8x8, 0);
|
||||
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_MILLI, u8x8->display_info->reset_pulse_width_ms);
|
||||
u8x8_gpio_SetReset(u8x8, 1);
|
||||
u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_MILLI, u8x8->display_info->post_reset_wait_ms);
|
||||
}
|
||||
|
||||
/*==========================================*/
|
||||
/* official functions */
|
||||
|
||||
uint8_t u8x8_DrawTile(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t cnt, uint8_t *tile_ptr)
|
||||
{
|
||||
u8x8_tile_t tile;
|
||||
tile.x_pos = x;
|
||||
tile.y_pos = y;
|
||||
tile.cnt = cnt;
|
||||
tile.tile_ptr = tile_ptr;
|
||||
return u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_DRAW_TILE, 1, (void *)&tile);
|
||||
uint8_t u8x8_DrawTile(u8x8_t* u8x8, uint8_t x, uint8_t y, uint8_t cnt, uint8_t* tile_ptr) {
|
||||
u8x8_tile_t tile;
|
||||
tile.x_pos = x;
|
||||
tile.y_pos = y;
|
||||
tile.cnt = cnt;
|
||||
tile.tile_ptr = tile_ptr;
|
||||
return u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_DRAW_TILE, 1, (void*)&tile);
|
||||
}
|
||||
|
||||
/* should be implemented as macro */
|
||||
void u8x8_SetupMemory(u8x8_t *u8x8)
|
||||
{
|
||||
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_SETUP_MEMORY, 0, NULL);
|
||||
void u8x8_SetupMemory(u8x8_t* u8x8) {
|
||||
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_SETUP_MEMORY, 0, NULL);
|
||||
}
|
||||
|
||||
void u8x8_InitDisplay(u8x8_t *u8x8)
|
||||
{
|
||||
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_INIT, 0, NULL);
|
||||
void u8x8_InitDisplay(u8x8_t* u8x8) {
|
||||
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_INIT, 0, NULL);
|
||||
}
|
||||
|
||||
void u8x8_SetPowerSave(u8x8_t *u8x8, uint8_t is_enable)
|
||||
{
|
||||
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_SET_POWER_SAVE, is_enable, NULL);
|
||||
void u8x8_SetPowerSave(u8x8_t* u8x8, uint8_t is_enable) {
|
||||
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_SET_POWER_SAVE, is_enable, NULL);
|
||||
}
|
||||
|
||||
void u8x8_SetFlipMode(u8x8_t *u8x8, uint8_t mode)
|
||||
{
|
||||
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_SET_FLIP_MODE, mode, NULL);
|
||||
void u8x8_SetFlipMode(u8x8_t* u8x8, uint8_t mode) {
|
||||
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_SET_FLIP_MODE, mode, NULL);
|
||||
}
|
||||
|
||||
void u8x8_SetContrast(u8x8_t *u8x8, uint8_t value)
|
||||
{
|
||||
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_SET_CONTRAST, value, NULL);
|
||||
void u8x8_SetContrast(u8x8_t* u8x8, uint8_t value) {
|
||||
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_SET_CONTRAST, value, NULL);
|
||||
}
|
||||
|
||||
void u8x8_RefreshDisplay(u8x8_t *u8x8)
|
||||
{
|
||||
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_REFRESH, 0, NULL);
|
||||
void u8x8_RefreshDisplay(u8x8_t* u8x8) {
|
||||
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_REFRESH, 0, NULL);
|
||||
}
|
||||
|
||||
void u8x8_ClearDisplayWithTile(u8x8_t *u8x8, const uint8_t *buf)
|
||||
{
|
||||
u8x8_tile_t tile;
|
||||
uint8_t h;
|
||||
void u8x8_ClearDisplayWithTile(u8x8_t* u8x8, const uint8_t* buf) {
|
||||
u8x8_tile_t tile;
|
||||
uint8_t h;
|
||||
|
||||
tile.x_pos = 0;
|
||||
tile.cnt = 1;
|
||||
tile.tile_ptr = (uint8_t *)buf; /* tile_ptr should be const, but isn't */
|
||||
|
||||
h = u8x8->display_info->tile_height;
|
||||
tile.y_pos = 0;
|
||||
do
|
||||
{
|
||||
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_DRAW_TILE, u8x8->display_info->tile_width, (void *)&tile);
|
||||
tile.y_pos++;
|
||||
} while( tile.y_pos < h );
|
||||
}
|
||||
|
||||
void u8x8_ClearDisplay(u8x8_t *u8x8)
|
||||
{
|
||||
uint8_t buf[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
u8x8_ClearDisplayWithTile(u8x8, buf);
|
||||
}
|
||||
|
||||
void u8x8_FillDisplay(u8x8_t *u8x8)
|
||||
{
|
||||
uint8_t buf[8] = { 255, 255, 255, 255, 255, 255, 255, 255 };
|
||||
u8x8_ClearDisplayWithTile(u8x8, buf);
|
||||
}
|
||||
|
||||
void u8x8_ClearLine(u8x8_t *u8x8, uint8_t line)
|
||||
{
|
||||
uint8_t buf[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
u8x8_tile_t tile;
|
||||
if ( line < u8x8->display_info->tile_height )
|
||||
{
|
||||
tile.x_pos = 0;
|
||||
tile.y_pos = line;
|
||||
tile.cnt = 1;
|
||||
tile.tile_ptr = (uint8_t *)buf; /* tile_ptr should be const, but isn't */
|
||||
u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_DRAW_TILE, u8x8->display_info->tile_width, (void *)&tile);
|
||||
}
|
||||
tile.tile_ptr = (uint8_t*)buf; /* tile_ptr should be const, but isn't */
|
||||
|
||||
h = u8x8->display_info->tile_height;
|
||||
tile.y_pos = 0;
|
||||
do {
|
||||
u8x8->display_cb(
|
||||
u8x8, U8X8_MSG_DISPLAY_DRAW_TILE, u8x8->display_info->tile_width, (void*)&tile);
|
||||
tile.y_pos++;
|
||||
} while(tile.y_pos < h);
|
||||
}
|
||||
|
||||
void u8x8_ClearDisplay(u8x8_t* u8x8) {
|
||||
uint8_t buf[8] = {0, 0, 0, 0, 0, 0, 0, 0};
|
||||
u8x8_ClearDisplayWithTile(u8x8, buf);
|
||||
}
|
||||
|
||||
void u8x8_FillDisplay(u8x8_t* u8x8) {
|
||||
uint8_t buf[8] = {255, 255, 255, 255, 255, 255, 255, 255};
|
||||
u8x8_ClearDisplayWithTile(u8x8, buf);
|
||||
}
|
||||
|
||||
void u8x8_ClearLine(u8x8_t* u8x8, uint8_t line) {
|
||||
uint8_t buf[8] = {0, 0, 0, 0, 0, 0, 0, 0};
|
||||
u8x8_tile_t tile;
|
||||
if(line < u8x8->display_info->tile_height) {
|
||||
tile.x_pos = 0;
|
||||
tile.y_pos = line;
|
||||
tile.cnt = 1;
|
||||
tile.tile_ptr = (uint8_t*)buf; /* tile_ptr should be const, but isn't */
|
||||
u8x8->display_cb(
|
||||
u8x8, U8X8_MSG_DISPLAY_DRAW_TILE, u8x8->display_info->tile_width, (void*)&tile);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user