Fixed code
This commit is contained in:
@@ -14,11 +14,9 @@
|
|||||||
|
|
||||||
#define RDWS_TAG "remotedisplay"
|
#define RDWS_TAG "remotedisplay"
|
||||||
|
|
||||||
namespace remotedisplay
|
namespace remotedisplay {
|
||||||
{
|
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
|
|
||||||
enum class msg_type : uint8_t
|
enum class msg_type : uint8_t
|
||||||
{
|
{
|
||||||
@@ -145,10 +143,10 @@ void drawGenericString(msg_type type, std::string_view string, int32_t x, int32_
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
drawString_msg dcstr = { (int16_t)x, (int16_t)y, font };
|
drawString_msg dcstr = { static_cast<int16_t>(x), static_cast<int16_t>(y), font };
|
||||||
std::string buf;
|
std::string buf;
|
||||||
emitMessageHeader(buf, msg_type::drawCentreString);
|
emitMessageHeader(buf, msg_type::drawCentreString);
|
||||||
buf += std::string_view((char *)&dcstr, sizeof(dcstr));
|
buf += std::string_view(reinterpret_cast<char *>(&dcstr), sizeof(dcstr));
|
||||||
buf += (char)string.length();
|
buf += (char)string.length();
|
||||||
buf += string;
|
buf += string;
|
||||||
|
|
||||||
@@ -164,52 +162,52 @@ void drawCentreString(std::string_view string, int32_t x, int32_t y, uint8_t fon
|
|||||||
|
|
||||||
void drawChar(int32_t x, int32_t y, uint16_t c, uint16_t color, uint16_t bg, uint8_t size)
|
void drawChar(int32_t x, int32_t y, uint16_t c, uint16_t color, uint16_t bg, uint8_t size)
|
||||||
{
|
{
|
||||||
drawChar_msg dc = { (int16_t)x, (int16_t)y, (uint16_t)c, color, bg, size };
|
drawChar_msg dc = { static_cast<int16_t>(x), static_cast<int16_t>(y), static_cast<uint16_t>(c), color, bg, size };
|
||||||
sendDrawMsg(msg_type::drawChar, std::string_view((char *)&dc, sizeof(dc)));
|
sendDrawMsg(msg_type::drawChar, std::string_view(reinterpret_cast<char *>(&dc), sizeof(dc)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawCircle(int32_t x, int32_t y, int32_t r, uint32_t color)
|
void drawCircle(int32_t x, int32_t y, int32_t r, uint32_t color)
|
||||||
{
|
{
|
||||||
drawCircle_msg dcirc = { (int16_t)x, (int16_t)y, (int16_t)r, (uint16_t)color };
|
drawCircle_msg dcirc = { static_cast<int16_t>(x), static_cast<int16_t>(y), static_cast<int16_t>(r), static_cast<uint16_t>(color) };
|
||||||
sendDrawMsg(msg_type::drawCircle, std::string_view((char *)&dcirc, sizeof(dcirc)));
|
sendDrawMsg(msg_type::drawCircle, std::string_view(reinterpret_cast<char *>(&dcirc), sizeof(dcirc)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawEllipse(int16_t x, int16_t y, int32_t rx, int32_t ry, uint16_t color)
|
void drawEllipse(int16_t x, int16_t y, int32_t rx, int32_t ry, uint16_t color)
|
||||||
{
|
{
|
||||||
drawEllipse_msg dellip = { (int16_t)x, (int16_t)y, (int16_t)rx, (int16_t)ry, color };
|
drawEllipse_msg dellip = { static_cast<int16_t>(x), static_cast<int16_t>(y), static_cast<int16_t>(rx), static_cast<int16_t>(ry), color };
|
||||||
sendDrawMsg(msg_type::drawEllipse, std::string_view((char *)&dellip, sizeof(dellip)));
|
sendDrawMsg(msg_type::drawEllipse, std::string_view(reinterpret_cast<char *>(&dellip), sizeof(dellip)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawFastHLine(int32_t x, int32_t y, int32_t w, uint16_t color)
|
void drawFastHLine(int32_t x, int32_t y, int32_t w, uint16_t color)
|
||||||
{
|
{
|
||||||
drawHVLine_msg dhl = { (int16_t)x, (int16_t)y, (int16_t)w, color };
|
drawHVLine_msg dhl = { static_cast<int16_t>(x), static_cast<int16_t>(y), static_cast<int16_t>(w), color };
|
||||||
sendDrawMsg(msg_type::drawHLine, std::string_view((char *)&dhl, sizeof(dhl)));
|
sendDrawMsg(msg_type::drawHLine, std::string_view(reinterpret_cast<char *>(&dhl), sizeof(dhl)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawFastVLine(int32_t x, int32_t y, int32_t h, uint16_t color)
|
void drawFastVLine(int32_t x, int32_t y, int32_t h, uint16_t color)
|
||||||
{
|
{
|
||||||
drawHVLine_msg dvl = { (int16_t)x, (int16_t)y, (int16_t)h, color };
|
drawHVLine_msg dvl = { static_cast<int16_t>(x), static_cast<int16_t>(y), static_cast<int16_t>(h), color };
|
||||||
sendDrawMsg(msg_type::drawVLine, std::string_view((char *)&dvl, sizeof(dvl)));
|
sendDrawMsg(msg_type::drawVLine, std::string_view(reinterpret_cast<char *>(&dvl), sizeof(dvl)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawLine(int32_t xs, int32_t ys, int32_t xe, int32_t ye, uint16_t color)
|
void drawLine(int32_t xs, int32_t ys, int32_t xe, int32_t ye, uint16_t color)
|
||||||
{
|
{
|
||||||
drawLine_msg dl = { (int16_t)xs, (int16_t)ys, (int16_t)xe, (int16_t)ye, color };
|
drawLine_msg dl = { static_cast<int16_t>(xs), static_cast<int16_t>(ys), static_cast<int16_t>(xe), static_cast<int16_t>(ye), color };
|
||||||
sendDrawMsg(msg_type::drawLine, std::string_view((char *)&dl, sizeof(dl)));
|
sendDrawMsg(msg_type::drawLine, std::string_view(reinterpret_cast<char *>(&dl), sizeof(dl)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawPixel(int32_t x, int32_t y, uint16_t color)
|
void drawPixel(int32_t x, int32_t y, uint16_t color)
|
||||||
{
|
{
|
||||||
return; // wont support
|
return; // won't support
|
||||||
drawPixel_msg dp = { (int16_t)x, (int16_t)y, color };
|
drawPixel_msg dp = { static_cast<int16_t>(x), static_cast<int16_t>(y), color };
|
||||||
sendDrawMsg(msg_type::drawPixel, std::string_view((char *)&dp, sizeof(dp)));
|
sendDrawMsg(msg_type::drawPixel, std::string_view(reinterpret_cast<char *>(&dp), sizeof(dp)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color)
|
void drawRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color)
|
||||||
{
|
{
|
||||||
// same parameters as fillRect -> can use same struct
|
// same parameters as fillRect -> can use same struct
|
||||||
drawRect_msg dr = { (int16_t)x, (int16_t)y, (int16_t)w, (int16_t)h, (uint16_t)color };
|
drawRect_msg dr = { static_cast<int16_t>(x), static_cast<int16_t>(y), static_cast<int16_t>(w), static_cast<int16_t>(h), static_cast<uint16_t>(color) };
|
||||||
sendDrawMsg(msg_type::drawRect, std::string_view((char *)&dr, sizeof(dr)));
|
sendDrawMsg(msg_type::drawRect, std::string_view(reinterpret_cast<char *>(&dr), sizeof(dr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawRightString(std::string_view string, int32_t x, int32_t y, uint8_t font)
|
void drawRightString(std::string_view string, int32_t x, int32_t y, uint8_t font)
|
||||||
@@ -220,10 +218,10 @@ void drawRightString(std::string_view string, int32_t x, int32_t y, uint8_t font
|
|||||||
void drawRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t radius, uint32_t color)
|
void drawRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t radius, uint32_t color)
|
||||||
{
|
{
|
||||||
drawRoundRect_msg drr = {
|
drawRoundRect_msg drr = {
|
||||||
(int16_t)x, (int16_t)y, (int16_t)w, (int16_t)h,
|
static_cast<int16_t>(x), static_cast<int16_t>(y), static_cast<int16_t>(w), static_cast<int16_t>(h),
|
||||||
(int16_t)radius, (uint16_t)color
|
static_cast<int16_t>(radius), static_cast<uint16_t>(color)
|
||||||
};
|
};
|
||||||
sendDrawMsg(msg_type::drawRoundRect, std::string_view((char *)&drr, sizeof(drr)));
|
sendDrawMsg(msg_type::drawRoundRect, std::string_view(reinterpret_cast<char *>(&drr), sizeof(drr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawString(std::string_view string, int32_t poX, int32_t poY, uint8_t font)
|
void drawString(std::string_view string, int32_t poX, int32_t poY, uint8_t font)
|
||||||
@@ -234,62 +232,62 @@ void drawString(std::string_view string, int32_t poX, int32_t poY, uint8_t font)
|
|||||||
void drawSunkenRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color0, uint32_t color1, uint32_t color2)
|
void drawSunkenRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color0, uint32_t color1, uint32_t color2)
|
||||||
{
|
{
|
||||||
drawSunkenRect_msg dsr = {
|
drawSunkenRect_msg dsr = {
|
||||||
(int16_t)x, (int16_t)y, (int16_t)w, (int16_t)h,
|
static_cast<int16_t>(x), static_cast<int16_t>(y), static_cast<int16_t>(w), static_cast<int16_t>(h),
|
||||||
(uint16_t)color0, (uint16_t)color1, (uint16_t)color2
|
static_cast<uint16_t>(color0), static_cast<uint16_t>(color1), static_cast<uint16_t>(color2)
|
||||||
};
|
};
|
||||||
sendDrawMsg(msg_type::drawSunkenRect, std::string_view((char *)&dsr, sizeof(dsr)));
|
sendDrawMsg(msg_type::drawSunkenRect, std::string_view(reinterpret_cast<char *>(&dsr), sizeof(dsr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawTriangle(int32_t x1,int32_t y1, int32_t x2,int32_t y2, int32_t x3,int32_t y3, uint32_t color)
|
void drawTriangle(int32_t x1,int32_t y1, int32_t x2,int32_t y2, int32_t x3,int32_t y3, uint32_t color)
|
||||||
{
|
{
|
||||||
drawTriangle_msg dt = {
|
drawTriangle_msg dt = {
|
||||||
(int16_t)x1, (int16_t)y1, (int16_t)x2, (int16_t)y2, (int16_t)x3, (int16_t)y3,
|
static_cast<int16_t>(x1), static_cast<int16_t>(y1), static_cast<int16_t>(x2), static_cast<int16_t>(y2), static_cast<int16_t>(x3), static_cast<int16_t>(y3),
|
||||||
(uint16_t)color
|
static_cast<uint16_t>(color)
|
||||||
};
|
};
|
||||||
sendDrawMsg(msg_type::drawTriangle, std::string_view((char *)&dt, sizeof(dt)));
|
sendDrawMsg(msg_type::drawTriangle, std::string_view(reinterpret_cast<char *>(&dt), sizeof(dt)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void fillCircle(int32_t x, int32_t y, int32_t r, uint32_t color)
|
void fillCircle(int32_t x, int32_t y, int32_t r, uint32_t color)
|
||||||
{
|
{
|
||||||
drawCircle_msg fcirc = { (int16_t)x, (int16_t)y, (int16_t)r, (uint16_t) color };
|
drawCircle_msg fcirc = { static_cast<int16_t>(x), static_cast<int16_t>(y), static_cast<int16_t>(r), static_cast<uint16_t>(color) };
|
||||||
sendDrawMsg(msg_type::fillCircle, std::string_view((char *)&fcirc, sizeof(fcirc)));
|
sendDrawMsg(msg_type::fillCircle, std::string_view(reinterpret_cast<char *>(&fcirc), sizeof(fcirc)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void fillEllipse(int16_t x, int16_t y, int32_t rx, int32_t ry, uint16_t color)
|
void fillEllipse(int16_t x, int16_t y, int32_t rx, int32_t ry, uint16_t color)
|
||||||
{
|
{
|
||||||
drawEllipse_msg fellip = { (int16_t)x, (int16_t)y, (int16_t)rx, (int16_t)ry, (uint16_t) color };
|
drawEllipse_msg fellip = { static_cast<int16_t>(x), static_cast<int16_t>(y), static_cast<int16_t>(rx), static_cast<int16_t>(ry), static_cast<uint16_t>(color) };
|
||||||
sendDrawMsg(msg_type::fillEllipse, std::string_view((char *)&fellip, sizeof(fellip)));
|
sendDrawMsg(msg_type::fillEllipse, std::string_view(reinterpret_cast<char *>(&fellip), sizeof(fellip)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void fillRect(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t color)
|
void fillRect(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t color)
|
||||||
{
|
{
|
||||||
drawRect_msg fr = { (int16_t)x, (int16_t)y, (int16_t)w, (int16_t)h, color };
|
drawRect_msg fr = { static_cast<int16_t>(x), static_cast<int16_t>(y), static_cast<int16_t>(w), static_cast<int16_t>(h), color };
|
||||||
sendDrawMsg(msg_type::fillRect, std::string_view((char *)&fr, sizeof(fr)));
|
sendDrawMsg(msg_type::fillRect, std::string_view(reinterpret_cast<char *>(&fr), sizeof(fr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void fillRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t radius, uint32_t color)
|
void fillRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t radius, uint32_t color)
|
||||||
{
|
{
|
||||||
drawRoundRect_msg frr = {
|
drawRoundRect_msg frr = {
|
||||||
(int16_t)x, (int16_t)y, (int16_t)w, (int16_t)h,
|
static_cast<int16_t>(x), static_cast<int16_t>(y), static_cast<int16_t>(w), static_cast<int16_t>(h),
|
||||||
(int16_t)radius, (uint16_t)color
|
static_cast<int16_t>(radius), static_cast<uint16_t>(color)
|
||||||
};
|
};
|
||||||
sendDrawMsg(msg_type::fillRoundRect, std::string_view((char *)&frr, sizeof(frr)));
|
sendDrawMsg(msg_type::fillRoundRect, std::string_view(reinterpret_cast<char *>(&frr), sizeof(frr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void fillScreen(uint32_t color)
|
void fillScreen(uint32_t color)
|
||||||
{
|
{
|
||||||
uint16_t fs = (uint16_t)color;
|
auto fs = static_cast<uint16_t>(color);
|
||||||
sendDrawMsg(msg_type::fillScreen, std::string_view((char *)&fs, sizeof(fs)));
|
sendDrawMsg(msg_type::fillScreen, std::string_view(reinterpret_cast<char *>(&fs), sizeof(fs)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void fillTriangle(int32_t x1,int32_t y1, int32_t x2,int32_t y2, int32_t x3,int32_t y3, uint32_t color)
|
void fillTriangle(int32_t x1,int32_t y1, int32_t x2,int32_t y2, int32_t x3,int32_t y3, uint32_t color)
|
||||||
{
|
{
|
||||||
drawTriangle_msg ft = {
|
drawTriangle_msg ft = {
|
||||||
(int16_t)x1, (int16_t)y1, (int16_t)x2, (int16_t)y2, (int16_t)x3, (int16_t)y3,
|
static_cast<int16_t>(x1), static_cast<int16_t>(y1), static_cast<int16_t>(x2), static_cast<int16_t>(y2), static_cast<int16_t>(x3), static_cast<int16_t>(y3),
|
||||||
(uint16_t)color
|
static_cast<uint16_t>(color)
|
||||||
};
|
};
|
||||||
sendDrawMsg(msg_type::fillTriangle, std::string_view((char *)&ft, sizeof(ft)));
|
sendDrawMsg(msg_type::fillTriangle, std::string_view(reinterpret_cast<char *>(&ft), sizeof(ft)));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace remotedisplay
|
} // namespace remotedisplay
|
||||||
|
Reference in New Issue
Block a user