app: make position on RGB panel more flexibel
This commit is contained in:
parent
b0351bcaaf
commit
5e688d467d
|
@ -148,12 +148,12 @@ static void rgbmatrix_clear(void)
|
||||||
* @param[in] g if the green LED should be on
|
* @param[in] g if the green LED should be on
|
||||||
* @param[in] b if the blue LED should be on
|
* @param[in] b if the blue LED should be on
|
||||||
*/
|
*/
|
||||||
static void rgbmatrix_set(uint8_t x, uint8_t y, bool r, bool g, bool b)
|
static void rgbmatrix_set(int16_t x, int16_t y, bool r, bool g, bool b)
|
||||||
{
|
{
|
||||||
if (x >= RGBMATRIX_WIDTH) {
|
if (x < 0 || x >= RGBMATRIX_WIDTH) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (y >= RGBMATRIX_HEIGHT) {
|
if (y < 0 || y >= RGBMATRIX_HEIGHT) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const uint8_t row = y % (RGBMATRIX_HEIGHT / 2); // get the actual line/row
|
const uint8_t row = y % (RGBMATRIX_HEIGHT / 2); // get the actual line/row
|
||||||
|
@ -199,21 +199,21 @@ static void rgbmatrix_set(uint8_t x, uint8_t y, bool r, bool g, bool b)
|
||||||
* @param[in] g if the character should be drawn in green
|
* @param[in] g if the character should be drawn in green
|
||||||
* @param[in] b if the character should be drawn in blue
|
* @param[in] b if the character should be drawn in blue
|
||||||
*/
|
*/
|
||||||
static void rgbmatrix_putc(uint8_t x, uint8_t y, char c, enum font_name font, bool red, bool green, bool blue)
|
static void rgbmatrix_putc(int16_t x, int16_t y, char c, enum font_name font, bool red, bool green, bool blue)
|
||||||
{
|
{
|
||||||
// sanity checks
|
// sanity checks
|
||||||
if (x >= RGBMATRIX_WIDTH) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (y >= RGBMATRIX_HEIGHT) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (font >= FONT_MAX) {
|
if (font >= FONT_MAX) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (c < ' ' || c > '~') {
|
if (c < ' ' || c > '~') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (x + fonts[font].width < 0 || x >= RGBMATRIX_WIDTH) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (y + fonts[font].height < 0 || y >= RGBMATRIX_HEIGHT) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// draw character on buffer
|
// draw character on buffer
|
||||||
for (uint8_t col = 0; col < fonts[font].width; col++) {
|
for (uint8_t col = 0; col < fonts[font].width; col++) {
|
||||||
|
@ -238,7 +238,7 @@ static void rgbmatrix_putc(uint8_t x, uint8_t y, char c, enum font_name font, bo
|
||||||
* @param[in] g if the character should be drawn in green
|
* @param[in] g if the character should be drawn in green
|
||||||
* @param[in] b if the character should be drawn in blue
|
* @param[in] b if the character should be drawn in blue
|
||||||
*/
|
*/
|
||||||
static void rgbmatrix_puts(uint8_t x, uint8_t y, char* str, enum font_name font, bool red, bool green, bool blue)
|
static void rgbmatrix_puts(int16_t x, int16_t y, const char* str, enum font_name font, bool red, bool green, bool blue)
|
||||||
{
|
{
|
||||||
// sanity checks
|
// sanity checks
|
||||||
if (NULL == str) {
|
if (NULL == str) {
|
||||||
|
@ -247,7 +247,7 @@ static void rgbmatrix_puts(uint8_t x, uint8_t y, char* str, enum font_name font,
|
||||||
if (font >= FONT_MAX) {
|
if (font >= FONT_MAX) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (y >= RGBMATRIX_HEIGHT) {
|
if (y + fonts[font].height < 0 || y >= RGBMATRIX_HEIGHT) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,7 +256,9 @@ static void rgbmatrix_puts(uint8_t x, uint8_t y, char* str, enum font_name font,
|
||||||
if (x >= RGBMATRIX_WIDTH) {
|
if (x >= RGBMATRIX_WIDTH) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rgbmatrix_putc(x, y, str[i], font, red, green, blue);
|
if (x + fonts[font].width >= 0) {
|
||||||
|
rgbmatrix_putc(x, y, str[i], font, red, green, blue);
|
||||||
|
}
|
||||||
x += fonts[font].width + 1;
|
x += fonts[font].width + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue