diff --git a/lib/Charliplexing.cpp b/lib/Charliplexing.cpp index 3d601cf..8e6ef3d 100644 --- a/lib/Charliplexing.cpp +++ b/lib/Charliplexing.cpp @@ -354,10 +354,10 @@ void LedSign::Flip(bool blocking) /** Clear the screen completely * @param set if 1 : make all led ON, if not set or 0 : make all led OFF */ -void LedSign::Clear(int set) { - for(int x=0;x<14;x++) - for(int y=0;y<9;y++) - Set(x,y,set); +void LedSign::Clear(uint8_t c) { + for (uint8_t x=0; xpixels[cycle*(SHADES-1)]; int i; diff --git a/lib/Charliplexing.h b/lib/Charliplexing.h index a44b481..d85af3b 100644 --- a/lib/Charliplexing.h +++ b/lib/Charliplexing.h @@ -28,11 +28,10 @@ namespace LedSign extern void Init(uint8_t mode = SINGLE_BUFFER); extern void Set(uint8_t x, uint8_t y, uint8_t c = 1); extern void SetBrightness(uint8_t brightness); - extern volatile unsigned int tcnt2; extern void Flip(bool blocking = false); - extern void Clear(int set=0); - extern void Horizontal(int y, int set=0); - extern void Vertical(int x, int set=0); + extern void Clear(uint8_t c = 0); + extern void Horizontal(uint8_t y, uint8_t c = 0); + extern void Vertical(uint8_t x, uint8_t c = 0); }; #endif diff --git a/lib/Font.cpp b/lib/Font.cpp index ff45161..72a60cf 100644 --- a/lib/Font.cpp +++ b/lib/Font.cpp @@ -117,14 +117,14 @@ const uint8_t* font2[] = { 0, 0, 0, 0, 0, 0, letters_97 /*a*/, letters_98 #endif /* ----------------------------------------------------------------- */ -/** Draws a figure (0-9). You should call it with set=1, - * wait a little them call it again with set=0 +/** Draws a figure (0-9). You should call it with c=1, + * wait a little them call it again with c=0 * @param figure is the figure [0-9] * @param x,y coordinates, - * @param set is 1 or 0 to draw or clear it + * @param c is 1 or 0 to draw or clear it */ -uint8_t Font::Draw(unsigned char letter,int x,int y,int set) { - uint16_t maxx=0; +uint8_t Font::Draw(unsigned char letter, uint8_t x, uint8_t y, uint8_t c) { + uint8_t maxx=0; uint8_t charCol; uint8_t charRow; @@ -141,25 +141,22 @@ uint8_t Font::Draw(unsigned char letter,int x,int y,int set) { character = font[letter-fontMin]; // } - int i=0; - - charCol = pgm_read_byte_near(character); - charRow = pgm_read_byte_near(character + 1); + charCol = pgm_read_byte_near(character++); + charRow = pgm_read_byte_near(character++); while (charRow!=9) { if (charCol>maxx) maxx=charCol; if ( - charCol + x <14 && + charCol + x =0 && - charRow + y <9 && + charRow + y =0 ) { - LedSign::Set(charCol + x, charRow+y, set); + LedSign::Set(charCol + x, charRow+y, c); } - i+=2; - charCol = pgm_read_byte_near(character + i); - charRow = pgm_read_byte_near(character + 1 + i); + charCol = pgm_read_byte_near(character++); + charRow = pgm_read_byte_near(character++); } return maxx+2; } @@ -169,10 +166,10 @@ uint8_t Font::Draw(unsigned char letter,int x,int y,int set) { /** Draw a figure in the other direction (rotated 90°) * @param figure is the figure [0-9] * @param x,y coordinates, - * @param set is 1 or 0 to draw or clear it + * @param c is 1 or 0 to draw or clear it */ -uint8_t Font::Draw90(unsigned char letter,int x,int y,int set) { - uint16_t maxx=0; +uint8_t Font::Draw90(unsigned char letter, uint8_t x, uint8_t y, uint8_t c) { + uint8_t maxx=0; uint8_t charCol; uint8_t charRow; @@ -189,28 +186,24 @@ uint8_t Font::Draw90(unsigned char letter,int x,int y,int set) { character = font[letter-fontMin]; // } - int i=0; - - charCol = pgm_read_byte_near(character); - charRow = pgm_read_byte_near(character + 1); + charCol = pgm_read_byte_near(character++); + charRow = pgm_read_byte_near(character++); while (charRow!=9) { if (charCol>maxx) maxx=charCol; if ( - charRow + x <14 && + charRow + x =0 && - charCol + y <9 && + charCol + y =0 ) { - LedSign::Set(7 - charRow + x, charCol + y, set); + LedSign::Set(7 - charRow + x, charCol + y, c); } - i+=2; - charCol = pgm_read_byte_near(character + i); - charRow = pgm_read_byte_near(character + 1 + i); + charCol = pgm_read_byte_near(character++); + charRow = pgm_read_byte_near(character++); } return maxx+2; - } diff --git a/lib/Font.h b/lib/Font.h index 84dd77a..a9fef63 100644 --- a/lib/Font.h +++ b/lib/Font.h @@ -29,12 +29,8 @@ namespace Font { - -extern uint8_t Draw(unsigned char letter,int x,int y,int set=1); - -extern uint8_t Draw90(unsigned char letter,int x,int y,int set=1); - + extern uint8_t Draw(unsigned char letter, uint8_t x, uint8_t y, uint8_t c=1); + extern uint8_t Draw90(unsigned char letter, uint8_t x, uint8_t y, uint8_t c=1); } #endif -