This is the David Smart RA8875 Library with mods for working with FRDM-K64F
Diff: RA8875.cpp
- Revision:
- 147:3494792458d9
- Parent:
- 146:373d59f08357
- Child:
- 148:33e99de1aca6
--- a/RA8875.cpp Thu Jun 01 11:00:40 2017 +0000 +++ b/RA8875.cpp Mon Jun 12 22:15:08 2017 +0000 @@ -525,20 +525,47 @@ bool RA8875::Intersect(rect_t rect1, rect_t rect2) { +#if 1 + // If one rectangle is on left side of other + if (max(rect1.p1.x,rect1.p2.x) < min(rect2.p1.x,rect2.p2.x) + || min(rect1.p1.x, rect1.p2.x) > max(rect2.p1.x, rect2.p2.x)) + return false; + // If one rectangle is above other + if (max(rect1.p1.y, rect1.p2.y) < min(rect2.p1.y, rect2.p2.y) + || min(rect1.p1.y, rect1.p2.y) > max(rect2.p1.y, rect2.p2.y)) + return false; + return true; // all that's left is they overlap +#else point_t bl, tr; - bl.x = rect2.p1.x; bl.y = rect2.p2.y; tr.x = rect2.p2.x; tr.y = rect2.p1.y; if (Intersect(rect1, rect2.p1) || Intersect(rect1, rect2.p2) - || Intersect(rect1, bl) || Intersect(rect1, tr)) + || Intersect(rect1, bl) || Intersect(rect1, tr)) return true; else return false; +#endif } +bool RA8875::Intersect(rect_t * pRect1, const rect_t * pRect2) +{ + if (Intersect(*pRect1, *pRect2)) { + rect_t iSect; + + iSect.p1.x = max(pRect1->p1.x, pRect2->p1.x); + iSect.p1.y = max(pRect1->p1.y, pRect2->p1.y); + iSect.p2.x = min(pRect1->p2.x, pRect2->p2.x); + iSect.p2.y = min(pRect1->p2.y, pRect2->p2.y); + *pRect1 = iSect; + return true; + } else { + return false; + } +} + RetCode_t RA8875::WriteCommandW(uint8_t command, uint16_t data) {