mraa: change all existing code to use libmraa.
* Made CMake depend on 0.4 libmraa Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
using namespace upm;
|
||||
|
||||
ST7735::ST7735 (uint8_t csLCD, uint8_t cSD, uint8_t rs, uint8_t rst) : GFX (160, 128, m_map, font) {
|
||||
maa_init();
|
||||
mraa_init();
|
||||
|
||||
m_csLCD = csLCD;
|
||||
m_cSD = cSD;
|
||||
@@ -45,84 +45,84 @@ ST7735::ST7735 (uint8_t csLCD, uint8_t cSD, uint8_t rs, uint8_t rst) : GFX (160,
|
||||
}
|
||||
|
||||
ST7735::~ST7735 () {
|
||||
maa_result_t error = MAA_SUCCESS;
|
||||
error = maa_spi_stop(m_spi);
|
||||
if (error != MAA_SUCCESS) {
|
||||
maa_result_print(error);
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
error = mraa_spi_stop(m_spi);
|
||||
if (error != MRAA_SUCCESS) {
|
||||
mraa_result_print(error);
|
||||
}
|
||||
error = maa_gpio_close (m_csLCDPinCtx);
|
||||
if (error != MAA_SUCCESS) {
|
||||
maa_result_print(error);
|
||||
error = mraa_gpio_close (m_csLCDPinCtx);
|
||||
if (error != MRAA_SUCCESS) {
|
||||
mraa_result_print(error);
|
||||
}
|
||||
error = maa_gpio_close (m_cSDPinCtx);
|
||||
if (error != MAA_SUCCESS) {
|
||||
maa_result_print(error);
|
||||
error = mraa_gpio_close (m_cSDPinCtx);
|
||||
if (error != MRAA_SUCCESS) {
|
||||
mraa_result_print(error);
|
||||
}
|
||||
error = maa_gpio_close (m_rSTPinCtx);
|
||||
if (error != MAA_SUCCESS) {
|
||||
maa_result_print(error);
|
||||
error = mraa_gpio_close (m_rSTPinCtx);
|
||||
if (error != MRAA_SUCCESS) {
|
||||
mraa_result_print(error);
|
||||
}
|
||||
error = maa_gpio_close (m_rSPinCtx);
|
||||
if (error != MAA_SUCCESS) {
|
||||
maa_result_print(error);
|
||||
error = mraa_gpio_close (m_rSPinCtx);
|
||||
if (error != MRAA_SUCCESS) {
|
||||
mraa_result_print(error);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ST7735::initModule () {
|
||||
maa_result_t error = MAA_SUCCESS;
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
m_height = 160;
|
||||
m_width = 128;
|
||||
|
||||
m_csLCDPinCtx = maa_gpio_init (m_csLCD);
|
||||
m_csLCDPinCtx = mraa_gpio_init (m_csLCD);
|
||||
if (m_csLCDPinCtx == NULL) {
|
||||
fprintf (stderr, "Are you sure that pin%d you requested is valid on your platform?", m_csLCD);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
m_cSDPinCtx = maa_gpio_init (m_cSD);
|
||||
m_cSDPinCtx = mraa_gpio_init (m_cSD);
|
||||
if (m_cSDPinCtx == NULL) {
|
||||
fprintf (stderr, "Are you sure that pin%d you requested is valid on your platform?", m_cSD);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
m_rSTPinCtx = maa_gpio_init (m_rST);
|
||||
m_rSTPinCtx = mraa_gpio_init (m_rST);
|
||||
if (m_rSTPinCtx == NULL) {
|
||||
fprintf (stderr, "Are you sure that pin%d you requested is valid on your platform?", m_rST);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
m_rSPinCtx = maa_gpio_init (m_rS);
|
||||
m_rSPinCtx = mraa_gpio_init (m_rS);
|
||||
if (m_rSPinCtx == NULL) {
|
||||
fprintf (stderr, "Are you sure that pin%d you requested is valid on your platform?", m_rS);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
error = maa_gpio_dir (m_csLCDPinCtx, MAA_GPIO_OUT);
|
||||
if (error != MAA_SUCCESS) {
|
||||
maa_result_print (error);
|
||||
error = mraa_gpio_dir (m_csLCDPinCtx, MRAA_GPIO_OUT);
|
||||
if (error != MRAA_SUCCESS) {
|
||||
mraa_result_print (error);
|
||||
}
|
||||
|
||||
error = maa_gpio_dir (m_cSDPinCtx, MAA_GPIO_OUT);
|
||||
if (error != MAA_SUCCESS) {
|
||||
maa_result_print (error);
|
||||
error = mraa_gpio_dir (m_cSDPinCtx, MRAA_GPIO_OUT);
|
||||
if (error != MRAA_SUCCESS) {
|
||||
mraa_result_print (error);
|
||||
}
|
||||
|
||||
error = maa_gpio_dir (m_rSTPinCtx, MAA_GPIO_OUT);
|
||||
if (error != MAA_SUCCESS) {
|
||||
maa_result_print (error);
|
||||
error = mraa_gpio_dir (m_rSTPinCtx, MRAA_GPIO_OUT);
|
||||
if (error != MRAA_SUCCESS) {
|
||||
mraa_result_print (error);
|
||||
}
|
||||
|
||||
error = maa_gpio_dir (m_rSPinCtx, MAA_GPIO_OUT);
|
||||
if (error != MAA_SUCCESS) {
|
||||
maa_result_print (error);
|
||||
error = mraa_gpio_dir (m_rSPinCtx, MRAA_GPIO_OUT);
|
||||
if (error != MRAA_SUCCESS) {
|
||||
mraa_result_print (error);
|
||||
}
|
||||
|
||||
m_spi = maa_spi_init (0);
|
||||
error = maa_spi_frequency(m_spi, 15 * 1000000);
|
||||
if (error != MAA_SUCCESS) {
|
||||
maa_result_print (error);
|
||||
m_spi = mraa_spi_init (0);
|
||||
error = mraa_spi_frequency(m_spi, 15 * 1000000);
|
||||
if (error != MRAA_SUCCESS) {
|
||||
mraa_result_print (error);
|
||||
}
|
||||
|
||||
lcdCSOn ();
|
||||
@@ -131,13 +131,13 @@ ST7735::initModule () {
|
||||
void
|
||||
ST7735::write (uint8_t value) {
|
||||
rsLOW ();
|
||||
maa_spi_write (m_spi, value);
|
||||
mraa_spi_write (m_spi, value);
|
||||
}
|
||||
|
||||
void
|
||||
ST7735::data (uint8_t value) {
|
||||
rsHIGH ();
|
||||
maa_spi_write (m_spi, value);
|
||||
mraa_spi_write (m_spi, value);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -177,7 +177,7 @@ ST7735::setAddrWindow(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1) {
|
||||
m_spiBuffer[1] = x0 + colstart; // XSTART
|
||||
m_spiBuffer[2] = 0x00;
|
||||
m_spiBuffer[3] = x1 + colstart; // XEND
|
||||
maa_spi_write_buf(m_spi, m_spiBuffer, 4);
|
||||
mraa_spi_write_buf(m_spi, m_spiBuffer, 4);
|
||||
|
||||
write (ST7735_RASET); // Row addr set
|
||||
|
||||
@@ -186,14 +186,14 @@ ST7735::setAddrWindow(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1) {
|
||||
m_spiBuffer[1] = y0 + rowstart; // YSTART
|
||||
m_spiBuffer[2] = 0x00;
|
||||
m_spiBuffer[3] = y1 + rowstart; // YEND
|
||||
maa_spi_write_buf(m_spi, m_spiBuffer, 4);
|
||||
mraa_spi_write_buf(m_spi, m_spiBuffer, 4);
|
||||
|
||||
write (ST7735_RAMWR); // write to RAM
|
||||
}
|
||||
|
||||
void
|
||||
ST7735::drawPixel(int16_t x, int16_t y, uint16_t color) {
|
||||
if (MAA_SUCCESS != setPixel (x, y, color)) {
|
||||
if (MRAA_SUCCESS != setPixel (x, y, color)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ ST7735::refresh () {
|
||||
|
||||
int fragmentSize = m_height * m_width * 2 / 20;
|
||||
for (int fragment = 0; fragment < 20; fragment++) {
|
||||
maa_spi_write_buf(m_spi, &m_map[fragment * fragmentSize], fragmentSize);
|
||||
mraa_spi_write_buf(m_spi, &m_map[fragment * fragmentSize], fragmentSize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,11 +216,11 @@ ST7735::configModule() {
|
||||
lcdCSOff ();
|
||||
lcdCSOn ();
|
||||
|
||||
maa_gpio_write (m_rSTPinCtx, HIGH);
|
||||
mraa_gpio_write (m_rSTPinCtx, HIGH);
|
||||
usleep (500000);
|
||||
maa_gpio_write (m_rSTPinCtx, LOW);
|
||||
mraa_gpio_write (m_rSTPinCtx, LOW);
|
||||
usleep (500000);
|
||||
maa_gpio_write (m_rSTPinCtx, HIGH);
|
||||
mraa_gpio_write (m_rSTPinCtx, HIGH);
|
||||
usleep (500000);
|
||||
|
||||
executeCMDList (Rcmd1);
|
||||
@@ -236,83 +236,83 @@ ST7735::configModule() {
|
||||
refresh ();
|
||||
}
|
||||
|
||||
maa_result_t
|
||||
mraa_result_t
|
||||
ST7735::lcdCSOn () {
|
||||
maa_result_t error = MAA_SUCCESS;
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
error = maa_gpio_write (m_csLCDPinCtx, LOW);
|
||||
if (error != MAA_SUCCESS) {
|
||||
maa_result_print (error);
|
||||
error = mraa_gpio_write (m_csLCDPinCtx, LOW);
|
||||
if (error != MRAA_SUCCESS) {
|
||||
mraa_result_print (error);
|
||||
}
|
||||
|
||||
error = maa_gpio_write (m_cSDPinCtx, HIGH);
|
||||
if (error != MAA_SUCCESS) {
|
||||
maa_result_print (error);
|
||||
error = mraa_gpio_write (m_cSDPinCtx, HIGH);
|
||||
if (error != MRAA_SUCCESS) {
|
||||
mraa_result_print (error);
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
maa_result_t
|
||||
mraa_result_t
|
||||
ST7735::lcdCSOff () {
|
||||
maa_result_t error = MAA_SUCCESS;
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
error = maa_gpio_write (m_csLCDPinCtx, HIGH);
|
||||
if (error != MAA_SUCCESS) {
|
||||
maa_result_print (error);
|
||||
error = mraa_gpio_write (m_csLCDPinCtx, HIGH);
|
||||
if (error != MRAA_SUCCESS) {
|
||||
mraa_result_print (error);
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
maa_result_t
|
||||
mraa_result_t
|
||||
ST7735::sdCSOn () {
|
||||
maa_result_t error = MAA_SUCCESS;
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
error = maa_gpio_write (m_cSDPinCtx, LOW);
|
||||
if (error != MAA_SUCCESS) {
|
||||
maa_result_print (error);
|
||||
error = mraa_gpio_write (m_cSDPinCtx, LOW);
|
||||
if (error != MRAA_SUCCESS) {
|
||||
mraa_result_print (error);
|
||||
}
|
||||
|
||||
error = maa_gpio_write (m_csLCDPinCtx, HIGH);
|
||||
if (error != MAA_SUCCESS) {
|
||||
maa_result_print (error);
|
||||
error = mraa_gpio_write (m_csLCDPinCtx, HIGH);
|
||||
if (error != MRAA_SUCCESS) {
|
||||
mraa_result_print (error);
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
maa_result_t
|
||||
mraa_result_t
|
||||
ST7735::sdCSOff () {
|
||||
maa_result_t error = MAA_SUCCESS;
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
error = maa_gpio_write (m_cSDPinCtx, HIGH);
|
||||
if (error != MAA_SUCCESS) {
|
||||
maa_result_print (error);
|
||||
error = mraa_gpio_write (m_cSDPinCtx, HIGH);
|
||||
if (error != MRAA_SUCCESS) {
|
||||
mraa_result_print (error);
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
maa_result_t
|
||||
mraa_result_t
|
||||
ST7735::rsHIGH () {
|
||||
maa_result_t error = MAA_SUCCESS;
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
error = maa_gpio_write (m_rSPinCtx, HIGH);
|
||||
if (error != MAA_SUCCESS) {
|
||||
maa_result_print (error);
|
||||
error = mraa_gpio_write (m_rSPinCtx, HIGH);
|
||||
if (error != MRAA_SUCCESS) {
|
||||
mraa_result_print (error);
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
maa_result_t
|
||||
mraa_result_t
|
||||
ST7735::rsLOW () {
|
||||
maa_result_t error = MAA_SUCCESS;
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
|
||||
error = maa_gpio_write (m_rSPinCtx, LOW);
|
||||
if (error != MAA_SUCCESS) {
|
||||
maa_result_print (error);
|
||||
error = mraa_gpio_write (m_rSPinCtx, LOW);
|
||||
if (error != MRAA_SUCCESS) {
|
||||
mraa_result_print (error);
|
||||
}
|
||||
|
||||
return error;
|
||||
|
||||
Reference in New Issue
Block a user