diff --git a/README.astyle b/README.astyle new file mode 100644 index 0000000000..7e7e9d3dfa --- /dev/null +++ b/README.astyle @@ -0,0 +1,18 @@ +Use the _astylerc config file and the 'astyle' util to format the +project source files in accordance with the project coding style. + +At project top level run these commands: + +1. To format the .c files: + $ find . -type f -name "*.c" | xargs astyle --options=_astylerc-c + -OR- (to skip creation of backup files) + $ find . -type f -name "*.c" | xargs astyle --options=_astylerc-c -n + +2. To format the .h files: + $ find . -type f -name "*.h" | xargs astyle --options=_astylerc-h + -OR- (to skip creation of backup files) + $ find . -type f -name "*.h" | xargs astyle --options=_astylerc-h -n + +3. To remove the backup file created by astyle: + $ find . -type f -name "*.bak" -delete # this are *.c backup files + $ find . -type f -name "*.orig" -delete # this are *.h backup files diff --git a/_astylerc-c b/_astylerc-c new file mode 100644 index 0000000000..9b9d7f3c95 --- /dev/null +++ b/_astylerc-c @@ -0,0 +1 @@ +--style=kr --convert-tabs --indent=spaces=4 --indent-switches --pad-oper --unpad-paren --align-pointer=middle --suffix=.bak --lineend=linux --min-conditional-indent= diff --git a/_astylerc-h b/_astylerc-h new file mode 100644 index 0000000000..d9c76337ce --- /dev/null +++ b/_astylerc-h @@ -0,0 +1 @@ +--convert-tabs --indent=spaces=4 diff --git a/lv_misc/lv_font.h b/lv_misc/lv_font.h index aa1b4a5fba..8941146152 100644 --- a/lv_misc/lv_font.h +++ b/lv_misc/lv_font.h @@ -49,8 +49,8 @@ typedef struct _lv_font_struct const uint8_t * glyph_bitmap; const lv_font_glyph_dsc_t * glyph_dsc; const uint32_t * unicode_list; - const uint8_t * (*get_bitmap)(const struct _lv_font_struct * ,uint32_t); /*Get a glyph's bitmap from a font*/ - int16_t (*get_width)(const struct _lv_font_struct * ,uint32_t); /*Get a glyph's with with a given font*/ + const uint8_t * (*get_bitmap)(const struct _lv_font_struct *,uint32_t); /*Get a glyph's bitmap from a font*/ + int16_t (*get_width)(const struct _lv_font_struct *,uint32_t); /*Get a glyph's with with a given font*/ struct _lv_font_struct * next_page; /*Pointer to a font extension*/ uint32_t bpp :4; /*Bit per pixel: 1, 2 or 4*/ } lv_font_t; diff --git a/lv_misc/lv_trigo.c b/lv_misc/lv_trigo.c new file mode 100644 index 0000000000..334b3204f8 --- /dev/null +++ b/lv_misc/lv_trigo.c @@ -0,0 +1,79 @@ + +/** + * @file lv_trigo.c + * Basic trigonometric integer functions + */ + +/********************* + * INCLUDES + *********************/ +#include "lv_trigo.h" + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * STATIC PROTOTYPES + **********************/ + +/********************** + * STATIC VARIABLES + **********************/ +static int16_t sin0_90_table[] = { + 0, 572, 1144, 1715, 2286, 2856, 3425, 3993, 4560, 5126, + 5690, 6252, 6813, 7371, 7927, 8481, 9032, 9580, 10126, 10668, + 11207, 11743, 12275, 12803, 13328, 13848, 14364, 14876, 15383, 15886, + 16383, 16876, 17364, 17846, 18323, 18794, 19260, 19720, 20173, 20621, + 21062, 21497, 21925, 22347, 22762, 23170, 23571, 23964, 24351, 24730, + 25101, 25465, 25821, 26169, 26509, 26841, 27165, 27481, 27788, 28087, + 28377, 28659, 28932, 29196, 29451, 29697, 29934, 30162, 30381, 30591, + 30791, 30982, 31163, 31335, 31498, 31650, 31794, 31927, 32051, 32165, + 32269, 32364, 32448, 32523, 32587, 32642, 32687, 32722, 32747, 32762 +}; + + +/********************** + * MACROS + **********************/ + +/********************** + * GLOBAL FUNCTIONS + **********************/ + +/** + * Return with sinus of an angle + * @param angle + * @return sinus of 'angle'. sin(-90) = -32767, sin(90) = 32767 + */ +int16_t lv_trigo_sin(int16_t angle) +{ + int16_t ret = 0; + angle = angle % 360; + + if(angle < 0) angle = 360 + angle; + + if(angle < 90) { + ret = sin0_90_table[angle]; + } else if(angle >= 90 && angle < 180) { + angle = 179 - angle; + ret = sin0_90_table[angle]; + } else if(angle >= 180 && angle < 270) { + angle = angle - 180; + ret = - sin0_90_table[angle]; + } else { /*angle >=270*/ + angle = 359 - angle; + ret = - sin0_90_table[angle]; + } + + return ret; +} + + +/********************** + * STATIC FUNCTIONS + **********************/ diff --git a/lv_misc/lv_txt.h b/lv_misc/lv_txt.h index b34700e33a..ba1f8f8260 100644 --- a/lv_misc/lv_txt.h +++ b/lv_misc/lv_txt.h @@ -83,6 +83,7 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font_p, lv_coord_t lv_txt_get_width(const char * txt, uint16_t length, const lv_font_t * font, lv_coord_t letter_space, lv_txt_flag_t flag); + /** * Check next character in a string and decide if te character is part of the command or not * @param state pointer to a txt_cmd_state_t variable which stores the current state of command processing