added ina219

This commit is contained in:
2020-06-28 21:23:15 +02:00
parent ca661a9372
commit 1bd3eb79dc
2 changed files with 107 additions and 6 deletions

View File

@@ -156,18 +156,21 @@ public:
dst.fillRect(x,y,w,h);
}
/** draw a horizontal line from x1 to x2 (inclusive) */
void drawLineHor(const Scalar x1, const Scalar x2, const Scalar y) {
dst.fillRect(x1,y,x2-x1,1);
for (Scalar x = x1; x <= x2; ++x) {dst.setPixel(x, y);}
}
/** draw a vertical line from y1 to y2 (inclusive) */
void drawLineVer(const Scalar y1, const Scalar y2, const Scalar x) {
dst.fillRect(x,y1,1,y2-y1);
for (Scalar y = y1; y <= y2; ++y) {dst.setPixel(x, y);}
}
void drawRect(const Scalar x, const Scalar y, const Scalar w, const Scalar h) {
drawLineHor(x,x+w, y); // top
drawLineHor(x,x+w, y+h); // bottom
drawLineVer(y,y+h, x); // left
drawLineVer(y,y+h, x+w); // right
drawLineHor(x, x+w-1, y); // top
drawLineHor(x, x+w-1, y+h-1); // bottom
drawLineVer(y+1, y+h-2, x); // left 2 pixels already included above
drawLineVer(y+1, y+h-2, x+w-1); // right 2 pixels already included above
}
// void drawRect(const Scalar x1, const Scalar y1, const Scalar x2, const Scalar y2) {