Circles (working)
This commit is contained in:
parent
02d8870981
commit
47dd3fc899
|
|
@ -180,6 +180,63 @@ void Adafruit_RA8875::fillRect(void) {
|
||||||
writeData(RA8875_DCR_LINESQUTRI_START | RA8875_DCR_FILL | RA8875_DCR_DRAWSQUARE);
|
writeData(RA8875_DCR_LINESQUTRI_START | RA8875_DCR_FILL | RA8875_DCR_DRAWSQUARE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Adafruit_RA8875::circleHelper(int16_t x0, int16_t y0, int16_t r, uint16_t color, bool filled)
|
||||||
|
{
|
||||||
|
/* Set X */
|
||||||
|
writeCommand(0x99);
|
||||||
|
writeData(x0);
|
||||||
|
writeCommand(0x9a);
|
||||||
|
writeData(x0 >> 8);
|
||||||
|
|
||||||
|
/* Set Y */
|
||||||
|
writeCommand(0x9b);
|
||||||
|
writeData(y0);
|
||||||
|
writeCommand(0x9c);
|
||||||
|
writeData(y0 >> 8);
|
||||||
|
|
||||||
|
/* Set Radius */
|
||||||
|
writeCommand(0x9d);
|
||||||
|
writeData(r);
|
||||||
|
|
||||||
|
/* Set Color */
|
||||||
|
writeCommand(0x63);
|
||||||
|
writeData((color & 0xf800) >> 11);
|
||||||
|
writeCommand(0x64);
|
||||||
|
writeData((color & 0x07e0) >> 5);
|
||||||
|
writeCommand(0x65);
|
||||||
|
writeData((color & 0x001f));
|
||||||
|
|
||||||
|
/* Draw! */
|
||||||
|
writeCommand(RA8875_DCR);
|
||||||
|
if (filled)
|
||||||
|
{
|
||||||
|
writeData(RA8875_DCR_CIRCLE_START | RA8875_DCR_FILL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
writeData(RA8875_DCR_CIRCLE_START | RA8875_DCR_NOFILL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wait for the command to finish */
|
||||||
|
bool finished = false;
|
||||||
|
while (!finished)
|
||||||
|
{
|
||||||
|
uint8_t temp = readReg(RA8875_DCR);
|
||||||
|
if (!(temp & RA8875_DCR_CIRCLE_STATUS))
|
||||||
|
finished = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Adafruit_RA8875::drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
|
||||||
|
{
|
||||||
|
circleHelper(x0, y0, r, color, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Adafruit_RA8875::fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
|
||||||
|
{
|
||||||
|
circleHelper(x0, y0, r, color, true);
|
||||||
|
}
|
||||||
|
|
||||||
/************************* Mid Level ***********************************/
|
/************************* Mid Level ***********************************/
|
||||||
|
|
||||||
void Adafruit_RA8875::GPIOX(boolean on) {
|
void Adafruit_RA8875::GPIOX(boolean on) {
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,10 @@ class Adafruit_RA8875 {
|
||||||
void graphicsMode(void);
|
void graphicsMode(void);
|
||||||
void setXY(uint16_t x, uint16_t y);
|
void setXY(uint16_t x, uint16_t y);
|
||||||
void fillRect(void);
|
void fillRect(void);
|
||||||
|
|
||||||
|
/* HW accelerated wrapper functions */
|
||||||
|
void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
|
||||||
|
void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
|
||||||
|
|
||||||
/* Backlight */
|
/* Backlight */
|
||||||
void GPIOX(boolean on);
|
void GPIOX(boolean on);
|
||||||
|
|
@ -43,6 +47,9 @@ class Adafruit_RA8875 {
|
||||||
private:
|
private:
|
||||||
void PLLinit(void);
|
void PLLinit(void);
|
||||||
void initialize(void);
|
void initialize(void);
|
||||||
|
|
||||||
|
/* GFX Helper Functions */
|
||||||
|
void circleHelper(int16_t x0, int16_t y0, int16_t r, uint16_t color, bool filled);
|
||||||
|
|
||||||
uint8_t _cs, _rst;
|
uint8_t _cs, _rst;
|
||||||
uint16_t _width, _height;
|
uint16_t _width, _height;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue