fix(format): check more source code (#3493)
and sync .pre-commit-config.yaml with scripts/code-format.py Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
@@ -19,12 +19,9 @@ repos:
|
||||
verbose: true
|
||||
files: |
|
||||
(?x)^(
|
||||
demos/ |
|
||||
examples/ |
|
||||
src/ |
|
||||
tests/src/test_cases/
|
||||
)
|
||||
exclude: |
|
||||
(?x)^(
|
||||
src/extra/libs/ |
|
||||
src/lv_conf_internal.h
|
||||
tests/
|
||||
)
|
||||
types_or: ["c", "header"]
|
||||
@@ -25,6 +25,7 @@
|
||||
--ignore-exclude-errors
|
||||
--ignore-exclude-errors-x
|
||||
--exclude=assets
|
||||
--exclude=test_fonts
|
||||
--exclude=../src/core/lv_obj_style_gen.c
|
||||
--exclude=../src/core/lv_obj_style_gen.h
|
||||
--exclude=../src/extra/libs/gif/gifdec.c
|
||||
@@ -36,6 +37,7 @@
|
||||
--exclude=../src/extra/libs/sjpg/tjpgd.c
|
||||
--exclude=../src/extra/libs/sjpg/tjpgd.h
|
||||
--exclude=../src/extra/libs/sjpg/tjpgdcnf.h
|
||||
--exclude=../src/misc/lv_style_gen.c
|
||||
--exclude=../src/misc/lv_style_gen.h
|
||||
--exclude=../tests/src/test_cases/_test_template.c
|
||||
--exclude=../tests/unity/unity.c
|
||||
--exclude=../tests/unity/unity_internals.h
|
||||
--exclude=../tests/unity/unity_support.c
|
||||
--exclude=../tests/unity/unity_support.h
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
import os
|
||||
|
||||
print("Formatting src")
|
||||
os.system('astyle --options=code-format.cfg --recursive "../src/*.c,*.h"')
|
||||
|
||||
print("\nFormatting demos")
|
||||
os.system('astyle --options=code-format.cfg --recursive "../demos/*.c,*.h"')
|
||||
|
||||
print("\nFormatting examples")
|
||||
os.system('astyle --options=code-format.cfg --recursive "../examples/*.c,*.h"')
|
||||
|
||||
print("Formatting src")
|
||||
os.system('astyle --options=code-format.cfg --recursive "../src/*.c,*.h"')
|
||||
|
||||
print("\nFormatting tests")
|
||||
os.system('astyle --options=code-format.cfg --recursive "../tests/src/test_cases/*.c"')
|
||||
os.system('astyle --options=code-format.cfg --recursive "../tests/*.c,*.h"')
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include <stdio.h>
|
||||
#include "lvgl/lvgl.h"
|
||||
|
||||
int main(void) {
|
||||
int main(void)
|
||||
{
|
||||
lv_init();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -17,123 +17,123 @@ static bool enc_pressed;
|
||||
|
||||
void lv_test_mouse_read_cb(lv_indev_drv_t * drv, lv_indev_data_t * data)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
data->point.x = x_act;
|
||||
data->point.y = y_act;
|
||||
data->state = mouse_pressed ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED;
|
||||
LV_UNUSED(drv);
|
||||
data->point.x = x_act;
|
||||
data->point.y = y_act;
|
||||
data->state = mouse_pressed ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED;
|
||||
}
|
||||
|
||||
void lv_test_mouse_move_to(lv_coord_t x, lv_coord_t y)
|
||||
{
|
||||
x_act = x;
|
||||
y_act = y;
|
||||
x_act = x;
|
||||
y_act = y;
|
||||
}
|
||||
|
||||
void lv_test_mouse_move_by(lv_coord_t x, lv_coord_t y)
|
||||
{
|
||||
x_act += x;
|
||||
y_act += y;
|
||||
x_act += x;
|
||||
y_act += y;
|
||||
}
|
||||
|
||||
void lv_test_mouse_press(void)
|
||||
{
|
||||
mouse_pressed = true;
|
||||
mouse_pressed = true;
|
||||
}
|
||||
|
||||
void lv_test_mouse_release(void)
|
||||
{
|
||||
mouse_pressed = false;
|
||||
mouse_pressed = false;
|
||||
}
|
||||
|
||||
void lv_test_mouse_click_at(lv_coord_t x, lv_coord_t y)
|
||||
{
|
||||
lv_test_mouse_release();
|
||||
lv_test_indev_wait(50);
|
||||
lv_test_mouse_move_to(x, y);
|
||||
lv_test_mouse_press();
|
||||
lv_test_indev_wait(50);
|
||||
lv_test_mouse_release();
|
||||
lv_test_indev_wait(50);
|
||||
lv_test_mouse_release();
|
||||
lv_test_indev_wait(50);
|
||||
lv_test_mouse_move_to(x, y);
|
||||
lv_test_mouse_press();
|
||||
lv_test_indev_wait(50);
|
||||
lv_test_mouse_release();
|
||||
lv_test_indev_wait(50);
|
||||
}
|
||||
|
||||
|
||||
void lv_test_keypad_read_cb(lv_indev_drv_t * drv, lv_indev_data_t * data)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
data->key = key_act;
|
||||
data->state = key_pressed ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED;
|
||||
LV_UNUSED(drv);
|
||||
data->key = key_act;
|
||||
data->state = key_pressed ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED;
|
||||
}
|
||||
|
||||
void lv_test_key_press(uint32_t k)
|
||||
{
|
||||
key_act = k;
|
||||
key_pressed = true;
|
||||
key_act = k;
|
||||
key_pressed = true;
|
||||
}
|
||||
|
||||
void lv_test_key_release(void)
|
||||
{
|
||||
key_pressed = false;
|
||||
key_pressed = false;
|
||||
}
|
||||
|
||||
void lv_test_key_hit(uint32_t k)
|
||||
{
|
||||
lv_test_key_release();
|
||||
lv_test_indev_wait(50);
|
||||
lv_test_key_press(k);
|
||||
lv_test_mouse_press();
|
||||
lv_test_indev_wait(50);
|
||||
lv_test_key_release();
|
||||
lv_test_indev_wait(50);
|
||||
lv_test_key_release();
|
||||
lv_test_indev_wait(50);
|
||||
lv_test_key_press(k);
|
||||
lv_test_mouse_press();
|
||||
lv_test_indev_wait(50);
|
||||
lv_test_key_release();
|
||||
lv_test_indev_wait(50);
|
||||
}
|
||||
|
||||
void lv_test_encoder_read_cb(lv_indev_drv_t * drv, lv_indev_data_t * data)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
data->enc_diff = diff_act;
|
||||
data->state = enc_pressed ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED;
|
||||
diff_act = 0;
|
||||
LV_UNUSED(drv);
|
||||
data->enc_diff = diff_act;
|
||||
data->state = enc_pressed ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED;
|
||||
diff_act = 0;
|
||||
}
|
||||
|
||||
void lv_test_encoder_add_diff(int32_t d)
|
||||
{
|
||||
diff_act += d;
|
||||
diff_act += d;
|
||||
}
|
||||
|
||||
void lv_test_encoder_turn(int32_t d)
|
||||
{
|
||||
diff_act += d;
|
||||
lv_test_indev_wait(50);
|
||||
diff_act += d;
|
||||
lv_test_indev_wait(50);
|
||||
}
|
||||
|
||||
|
||||
void lv_test_encoder_press(void)
|
||||
{
|
||||
enc_pressed = true;
|
||||
enc_pressed = true;
|
||||
}
|
||||
|
||||
void lv_test_encoder_release(void)
|
||||
{
|
||||
enc_pressed = false;
|
||||
enc_pressed = false;
|
||||
}
|
||||
|
||||
void lv_test_encoder_click(void)
|
||||
{
|
||||
lv_test_encoder_release();
|
||||
lv_test_indev_wait(50);
|
||||
lv_test_encoder_press();
|
||||
lv_test_indev_wait(50);
|
||||
lv_test_encoder_release();
|
||||
lv_test_indev_wait(50);
|
||||
lv_test_encoder_release();
|
||||
lv_test_indev_wait(50);
|
||||
lv_test_encoder_press();
|
||||
lv_test_indev_wait(50);
|
||||
lv_test_encoder_release();
|
||||
lv_test_indev_wait(50);
|
||||
}
|
||||
|
||||
|
||||
void lv_test_indev_wait(uint32_t ms)
|
||||
{
|
||||
uint32_t t = lv_tick_get();
|
||||
while(lv_tick_elaps(t) < ms) {
|
||||
lv_timer_handler();
|
||||
lv_tick_inc(1);
|
||||
}
|
||||
uint32_t t = lv_tick_get();
|
||||
while(lv_tick_elaps(t) < ms) {
|
||||
lv_timer_handler();
|
||||
lv_tick_inc(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user