forked from Michel2/LoLshield
Reduce some type sizes, use DISPLAY_ROWS/DISPLAY_COLS more uniformly.
This commit is contained in:
+12
-12
@@ -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; x<DISPLAY_COLS; x++)
|
||||
for (uint8_t y=0; y<DISPLAY_ROWS; y++)
|
||||
Set(x, y, c);
|
||||
}
|
||||
|
||||
|
||||
@@ -366,9 +366,9 @@ void LedSign::Clear(int set) {
|
||||
* @param y is the y coordinate of the line to clear/light [0-8]
|
||||
* @param set if 1 : make all led ON, if not set or 0 : make all led OFF
|
||||
*/
|
||||
void LedSign::Horizontal(int y, int set) {
|
||||
for(int x=0;x<14;x++)
|
||||
Set(x,y,set);
|
||||
void LedSign::Horizontal(uint8_t y, uint8_t c) {
|
||||
for (uint8_t x=0; x<DISPLAY_COLS; x++)
|
||||
Set(x, y, c);
|
||||
}
|
||||
|
||||
|
||||
@@ -377,9 +377,9 @@ void LedSign::Horizontal(int y, int set) {
|
||||
* @param x is the x coordinate of the line to clear/light [0-13]
|
||||
* @param set if 1 : make all led ON, if not set or 0 : make all led OFF
|
||||
*/
|
||||
void LedSign::Vertical(int x, int set) {
|
||||
for(int y=0;y<9;y++)
|
||||
Set(x,y,set);
|
||||
void LedSign::Vertical(uint8_t x, uint8_t c) {
|
||||
for (uint8_t y=0; y<DISPLAY_ROWS; y++)
|
||||
Set(x, y, c);
|
||||
}
|
||||
|
||||
|
||||
@@ -399,8 +399,8 @@ void LedSign::Set(uint8_t x, uint8_t y, uint8_t c)
|
||||
c = SHADES-1;
|
||||
#endif
|
||||
|
||||
uint16_t mask = 1 << pgm_read_byte_near(&ledMap[x+y*14].high);
|
||||
uint8_t cycle = pgm_read_byte_near(&ledMap[x+y*14].cycle);
|
||||
uint16_t mask = 1 << pgm_read_byte_near(&ledMap[x+y*DISPLAY_COLS].high);
|
||||
uint8_t cycle = pgm_read_byte_near(&ledMap[x+y*DISPLAY_COLS].cycle);
|
||||
|
||||
uint16_t *p = &workBuffer->pixels[cycle*(SHADES-1)];
|
||||
int i;
|
||||
|
||||
+3
-4
@@ -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
|
||||
|
||||
+22
-29
@@ -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 <DISPLAY_COLS &&
|
||||
charCol + x >=0 &&
|
||||
charRow + y <9 &&
|
||||
charRow + y <DISPLAY_ROWS &&
|
||||
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 <DISPLAY_COLS &&
|
||||
charRow + x >=0 &&
|
||||
charCol + y <9 &&
|
||||
charCol + y <DISPLAY_ROWS &&
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
+2
-6
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user