v.0.1.1 rm fontHeight_NxM
This commit is contained in:
@@ -10,8 +10,3 @@ const std::vector<uint16_t> &getFontChar_16x16(char c)
|
|||||||
}
|
}
|
||||||
return font_16x16.at(' '); // Fallback to space
|
return font_16x16.at(' '); // Fallback to space
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint8_t fontHeight_16x16()
|
|
||||||
{
|
|
||||||
return 16;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -115,6 +115,5 @@ const std::map<uint8_t, std::vector<uint16_t>> font_16x16 = {
|
|||||||
|
|
||||||
// Declarations only
|
// Declarations only
|
||||||
const std::vector<uint16_t> &getFontChar_16x16(char c);
|
const std::vector<uint16_t> &getFontChar_16x16(char c);
|
||||||
const uint8_t fontHeight_16x16();
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -10,8 +10,3 @@ const std::vector<uint8_t> &getFontChar_5x7(char c)
|
|||||||
}
|
}
|
||||||
return font_5x7.at(' '); // Fallback to space
|
return font_5x7.at(' '); // Fallback to space
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint8_t fontHeight_5x7()
|
|
||||||
{
|
|
||||||
return 7;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -117,6 +117,5 @@ const std::map<uint8_t, std::vector<uint8_t>> font_5x7 = {
|
|||||||
|
|
||||||
// Declarations only
|
// Declarations only
|
||||||
const vector<uint8_t> &getFontChar_5x7(char c);
|
const vector<uint8_t> &getFontChar_5x7(char c);
|
||||||
const uint8_t fontHeight_5x7();
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -10,8 +10,3 @@ const std::vector<uint8_t> &getFontChar_8x8(char c)
|
|||||||
}
|
}
|
||||||
return font_8x8.at(' '); // Fallback to space
|
return font_8x8.at(' '); // Fallback to space
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint8_t fontHeight_8x8()
|
|
||||||
{
|
|
||||||
return 8;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -112,6 +112,5 @@ const std::map<uint8_t, std::vector<uint8_t>> font_8x8 = {
|
|||||||
|
|
||||||
// Declarations only
|
// Declarations only
|
||||||
const std::vector<uint8_t> &getFontChar_8x8(char c);
|
const std::vector<uint8_t> &getFontChar_8x8(char c);
|
||||||
const uint8_t fontHeight_8x8();
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -59,17 +59,19 @@ void LedMatrix::drawPixel(int x, int y, CRGB color)
|
|||||||
uint8_t LedMatrix::drawChar(int x, int y, char c, CRGB color)
|
uint8_t LedMatrix::drawChar(int x, int y, char c, CRGB color)
|
||||||
{
|
{
|
||||||
#ifdef USE_FONT_5x7
|
#ifdef USE_FONT_5x7
|
||||||
|
const u_int8_t font_width = 5;
|
||||||
const std::map<uint8_t, std::vector<uint8_t>> &font = font_5x7;
|
const std::map<uint8_t, std::vector<uint8_t>> &font = font_5x7;
|
||||||
#elifdef USE_FONT_8x8
|
#elifdef USE_FONT_8x8
|
||||||
|
const u_int8_t font_width = 8;
|
||||||
const std::map<uint8_t, std::vector<uint8_t>> &font = font_8x8;
|
const std::map<uint8_t, std::vector<uint8_t>> &font = font_8x8;
|
||||||
#elifdef USE_FONT_16x16
|
#elifdef USE_FONT_16x16
|
||||||
const std::map<uint8_t, std::vector<uint8_t>> &font = font_16x16;
|
const u_int8_t font_width = 16;
|
||||||
|
const std::map<uint8_t, std::vector<uint16_t>> &font = font_16x16;
|
||||||
#endif
|
#endif
|
||||||
const vector<uint8_t> &fontData_ = getFontChar(c, font);
|
const vector<uint8_t> &fontData_ = getFontChar(c, font);
|
||||||
const uint8_t *fontData = fontData_.data();
|
const uint8_t *fontData = fontData_.data();
|
||||||
const u_int8_t char_width_pixel = charWidth(fontData);
|
const u_int8_t char_width_pixel = charWidth(fontData);
|
||||||
const u_int8_t font_height = getFontHeight();
|
const u_int8_t font_height = getFontHeight();
|
||||||
const u_int8_t font_width = 5;
|
|
||||||
|
|
||||||
for (u_int8_t row = 0; row < font_height; row++)
|
for (u_int8_t row = 0; row < font_height; row++)
|
||||||
{
|
{
|
||||||
@@ -118,7 +120,7 @@ const uint8_t LedMatrix::getTextWidth(const char *text)
|
|||||||
#elifdef USE_FONT_8x8
|
#elifdef USE_FONT_8x8
|
||||||
const std::map<uint8_t, std::vector<uint8_t>> &font = font_8x8;
|
const std::map<uint8_t, std::vector<uint8_t>> &font = font_8x8;
|
||||||
#elifdef USE_FONT_16x16
|
#elifdef USE_FONT_16x16
|
||||||
const std::map<uint8_t, std::vector<uint8_t>> &font = font_16x16;
|
const std::map<uint8_t, std::vector<uint16_t>> &font = font_16x16;
|
||||||
#endif
|
#endif
|
||||||
const vector<uint8_t> &fontData_ = getFontChar(text[i], font);
|
const vector<uint8_t> &fontData_ = getFontChar(text[i], font);
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#define USE_FONT_5x7
|
// #define USE_FONT_5x7
|
||||||
// #define USE_FONT_8x8
|
#define USE_FONT_8x8
|
||||||
// #define USE_FONT_16x16
|
// #define USE_FONT_16x16
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|||||||
25
src/main.cpp
25
src/main.cpp
@@ -6,23 +6,27 @@
|
|||||||
|
|
||||||
LedMatrix matrix;
|
LedMatrix matrix;
|
||||||
|
|
||||||
|
#ifdef USE_FONT_5x7
|
||||||
|
const uint8_t _fontWidthPixel = 5;
|
||||||
|
#elifdef USE_FONT_8x8
|
||||||
|
const uint8_t _fontWidthPixel = 8;
|
||||||
|
#elifdef USE_FONT_16x16
|
||||||
|
const uint8_t _fontWidthPixel = 16;
|
||||||
|
#endif
|
||||||
|
|
||||||
void printCharMatrixSimple(char c)
|
void printCharMatrixSimple(char c)
|
||||||
{
|
{
|
||||||
matrix.drawText(58, 56, &c, CRGB::YellowGreen);
|
|
||||||
matrix.show();
|
|
||||||
|
|
||||||
#ifdef USE_FONT_5x7
|
#ifdef USE_FONT_5x7
|
||||||
const vector<uint8_t> &fontData_ = getFontChar_5x7(c);
|
const vector<uint8_t> &fontData_ = getFontChar_5x7(c);
|
||||||
const u_int8_t font_height = fontHeight_5x7();
|
const u_int8_t font_height = 7;
|
||||||
#elifdef USE_FONT_8x8
|
#elifdef USE_FONT_8x8
|
||||||
const vector<uint8_t> &fontData_ = getFontChar_8x8(c);
|
const vector<uint8_t> &fontData_ = getFontChar_8x8(c);
|
||||||
const u_int8_t font_height = fontHeight_8x8();
|
const u_int8_t font_height = 8;
|
||||||
#elifdef USE_FONT_16x16
|
#elifdef USE_FONT_16x16
|
||||||
const vector<uint16_t> &fontData_ = getFontChar_16x16(c);
|
const vector<uint16_t> &fontData_ = getFontChar_16x16(c);
|
||||||
const u_int8_t font_height = fontHeight_16x16();
|
const u_int8_t font_height = 16;
|
||||||
#endif
|
#endif
|
||||||
const auto *fontData = fontData_.data();
|
const auto *fontData = fontData_.data();
|
||||||
const u_int8_t char_width_pixel = 5;
|
|
||||||
|
|
||||||
Serial.print("<");
|
Serial.print("<");
|
||||||
Serial.print(c);
|
Serial.print(c);
|
||||||
@@ -33,9 +37,9 @@ void printCharMatrixSimple(char c)
|
|||||||
{
|
{
|
||||||
uint16_t line = fontData[row];
|
uint16_t line = fontData[row];
|
||||||
|
|
||||||
for (int col = 0; col < char_width_pixel; col++)
|
for (int col = 0; col < _fontWidthPixel; col++)
|
||||||
{
|
{
|
||||||
if (line & (1 << ((char_width_pixel - 1) - col)))
|
if (line & (1 << ((_fontWidthPixel - 1) - col)))
|
||||||
{
|
{
|
||||||
mtrx += "•";
|
mtrx += "•";
|
||||||
}
|
}
|
||||||
@@ -47,6 +51,9 @@ void printCharMatrixSimple(char c)
|
|||||||
mtrx += "\n\r";
|
mtrx += "\n\r";
|
||||||
}
|
}
|
||||||
Serial.println(mtrx);
|
Serial.println(mtrx);
|
||||||
|
|
||||||
|
matrix.drawText(64 - font_height - 1, 64 - _fontWidthPixel - 1, &c, CRGB::YellowGreen);
|
||||||
|
matrix.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void playWithBlinkLed()
|
void playWithBlinkLed()
|
||||||
|
|||||||
Reference in New Issue
Block a user