Skip to content

Commit

Permalink
Added progress bar and CRT animation.
Browse files Browse the repository at this point in the history
  • Loading branch information
fornellas committed Nov 13, 2012
1 parent 8ecc676 commit 51346d3
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 37 deletions.
29 changes: 29 additions & 0 deletions SFRGBLEDMatrix/SFRGBLEDMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,32 @@ Color SFRGBLEDMatrix::spectrum(uint16_t value, uint16_t max){
}
return 0;
}

void SFRGBLEDMatrix::progressBarInit(Color borderColor){
clear();
box(borderColor, 0, height/2-2, width-1, height/2+1);
show();
}

void SFRGBLEDMatrix::progressBarUpdate(Color barColor, uint16_t vaule, uint16_t max){
box(barColor, 1, height/2-1, round((double)vaule*((double)width-2.0)/(double)max), height/2);
show();
}

void SFRGBLEDMatrix::CRT(Color bgColor, Color borderColor){
for(byte p=0;p<height/2-1;p++){
if(p)
box(bgColor, p-1, p-1, width-1-p+1, height-1-p+1);
box(borderColor, p, p, width-1-p, height-1-p);
show();
}
for(byte p=height/2-1;p<width/2;p++){
box(bgColor, p-1, height/2-2-1, width-1-p+1, height/2+1+1);
box(borderColor, p, height/2-2, width-1-p, height/2+1);
show();
}
for(byte p=height/2-2;p<height/2;p++){
box(bgColor, width/2-2, p, width/2+1, height-p-1);
show();
}
}
7 changes: 6 additions & 1 deletion SFRGBLEDMatrix/SFRGBLEDMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,14 @@ class SFRGBLEDMatrix {
void box(const Color color, const int x0, const int y0, const int x1, const int y1);
// Enable / disable gamma correction
void gamma(boolean state);
//
// Spectrum
uint8_t spectrumLen();
Color spectrum(uint16_t value, uint16_t max);
// Progress bar
void progressBarInit(Color borderColor);
void progressBarUpdate(Color barColor, uint16_t vaule, uint16_t max);
// CRT out animation
void CRT(Color bgColor, Color borderColor);
};

#endif
75 changes: 39 additions & 36 deletions SFRGBLEDMatrix/keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,55 +7,58 @@
#######################################

SFRGBLEDMatrix KEYWORD1
Color KEYWORD1
Color KEYWORD1

#######################################
# Methods and Functions (KEYWORD2)
#######################################

width KEYWORD2
height KEYWORD2
pixels KEYWORD2
setupSPI KEYWORD2
setupPINs KEYWORD2
show KEYWORD2
print KEYWORD2
print_PF KEYWORD2
paintPixel KEYWORD2
fill KEYWORD2
clear KEYWORD2
line KEYWORD2
box KEYWORD2
gamma KEYWORD2
spectrumLen KEYWORD2
spectrum KEYWORD2
width KEYWORD2
height KEYWORD2
pixels KEYWORD2
setupSPI KEYWORD2
setupPINs KEYWORD2
show KEYWORD2
print KEYWORD2
print_PF KEYWORD2
paintPixel KEYWORD2
fill KEYWORD2
clear KEYWORD2
line KEYWORD2
box KEYWORD2
gamma KEYWORD2
spectrumLen KEYWORD2
spectrum KEYWORD2
progressBarInit KEYWORD2
progressBarUpdate KEYWORD2
CRT KEYWORD2

#######################################
# Constants (LITERAL1)
#######################################

BITS_PER_COLOR LITERAL1
MAX_C LITERAL1
MID_C LITERAL1
RGB(r,g,b) LITERAL1
GET_RED(c) LITERAL1
MAX_C LITERAL1
MID_C LITERAL1
RGB(r,g,b) LITERAL1
GET_RED(c) LITERAL1
GET_GREEN(c) LITERAL1
GET_BLUE(c) LITERAL1
BLACK LITERAL1
WHITE LITERAL1
RED LITERAL1
RED_MAGENTA LITERAL1
RED_YELLOW LITERAL1
GREEN LITERAL1
GREEN_CYAN LITERAL1
GET_BLUE(c) LITERAL1
BLACK LITERAL1
WHITE LITERAL1
RED LITERAL1
RED_MAGENTA LITERAL1
RED_YELLOW LITERAL1
GREEN LITERAL1
GREEN_CYAN LITERAL1
GREEN_YELLOW LITERAL1
BLUE LITERAL1
BLUE_CYAN LITERAL1
BLUE LITERAL1
BLUE_CYAN LITERAL1
BLUE_MAGENTA LITERAL1
CYAN LITERAL1
MAGENTA LITERAL1
YELLOW LITERAL1
MAGENTA LITERAL1
ORANGE LITERAL1
CYAN LITERAL1
MAGENTA LITERAL1
YELLOW LITERAL1
MAGENTA LITERAL1
ORANGE LITERAL1


0 comments on commit 51346d3

Please sign in to comment.