java: changed some C types to C++ types

Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>

Conflicts:
	src/mma7455/mma7455.cxx
	src/mma7455/mma7455.h
	src/sm130/sm130.cxx
	src/sm130/sm130.h
This commit is contained in:
Andrei Vasiliu
2015-09-02 14:56:13 +03:00
committed by Mihai Tudor Panu
parent b8835958e2
commit ab730038fd
46 changed files with 731 additions and 996 deletions

View File

@@ -32,8 +32,11 @@
using namespace upm;
ST7735::ST7735 (uint8_t csLCD, uint8_t cSD, uint8_t rs, uint8_t rst) : GFX (160, 128, m_map, font) {
mraa_init();
ST7735::ST7735 (uint8_t csLCD, uint8_t cSD, uint8_t rs, uint8_t rst)
: GFX (160, 128, m_map, font), m_csLCDPinCtx(m_csLCD), m_cSDPinCtx(m_cSD),
m_rSTPinCtx(m_rST), m_rSPinCtx(m_rS), m_spi(0) {
mraa::init();
m_csLCD = csLCD;
m_cSD = cSD;
@@ -44,85 +47,36 @@ ST7735::ST7735 (uint8_t csLCD, uint8_t cSD, uint8_t rs, uint8_t rst) : GFX (160,
configModule ();
}
ST7735::~ST7735 () {
mraa_result_t error = MRAA_SUCCESS;
error = mraa_spi_stop(m_spi);
if (error != MRAA_SUCCESS) {
mraa_result_print(error);
}
error = mraa_gpio_close (m_csLCDPinCtx);
if (error != MRAA_SUCCESS) {
mraa_result_print(error);
}
error = mraa_gpio_close (m_cSDPinCtx);
if (error != MRAA_SUCCESS) {
mraa_result_print(error);
}
error = mraa_gpio_close (m_rSTPinCtx);
if (error != MRAA_SUCCESS) {
mraa_result_print(error);
}
error = mraa_gpio_close (m_rSPinCtx);
if (error != MRAA_SUCCESS) {
mraa_result_print(error);
}
}
void
ST7735::initModule () {
mraa_result_t error = MRAA_SUCCESS;
mraa::Result error = mraa::SUCCESS;
m_height = 160;
m_width = 128;
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);
error = m_csLCDPinCtx.dir(mraa::DIR_OUT);
if (error != mraa::SUCCESS) {
mraa::printError (error);
}
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);
error = m_cSDPinCtx.dir(mraa::DIR_OUT);
if (error != mraa::SUCCESS) {
mraa::printError (error);
}
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);
error = m_rSTPinCtx.dir(mraa::DIR_OUT);
if (error != mraa::SUCCESS) {
mraa::printError (error);
}
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 = m_rSPinCtx.dir(mraa::DIR_OUT);
if (error != mraa::SUCCESS) {
mraa::printError (error);
}
error = mraa_gpio_dir (m_csLCDPinCtx, MRAA_GPIO_OUT);
if (error != MRAA_SUCCESS) {
mraa_result_print (error);
}
error = mraa_gpio_dir (m_cSDPinCtx, MRAA_GPIO_OUT);
if (error != MRAA_SUCCESS) {
mraa_result_print (error);
}
error = mraa_gpio_dir (m_rSTPinCtx, MRAA_GPIO_OUT);
if (error != MRAA_SUCCESS) {
mraa_result_print (error);
}
error = mraa_gpio_dir (m_rSPinCtx, MRAA_GPIO_OUT);
if (error != MRAA_SUCCESS) {
mraa_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);
error = m_spi.frequency(15 * 1000000);
if (error != mraa::SUCCESS) {
mraa::printError (error);
}
lcdCSOn ();
@@ -131,13 +85,13 @@ ST7735::initModule () {
void
ST7735::write (uint8_t value) {
rsLOW ();
mraa_spi_write (m_spi, value);
m_spi.writeByte(value);
}
void
ST7735::data (uint8_t value) {
rsHIGH ();
mraa_spi_write (m_spi, value);
m_spi.writeByte(value);
}
void
@@ -177,7 +131,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
mraa_spi_write_buf(m_spi, m_spiBuffer, 4);
m_spi.write(m_spiBuffer, 4);
write (ST7735_RASET); // Row addr set
@@ -186,14 +140,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
mraa_spi_write_buf(m_spi, m_spiBuffer, 4);
m_spi.write(m_spiBuffer, 4);
write (ST7735_RAMWR); // write to RAM
}
void
ST7735::drawPixel(int16_t x, int16_t y, uint16_t color) {
if (MRAA_SUCCESS != setPixel (x, y, color)) {
if (mraa::SUCCESS != setPixel (x, y, color)) {
return;
}
@@ -206,7 +160,7 @@ ST7735::refresh () {
int fragmentSize = m_height * m_width * 2 / 20;
for (int fragment = 0; fragment < 20; fragment++) {
mraa_spi_write_buf(m_spi, &m_map[fragment * fragmentSize], fragmentSize);
m_spi.write(&m_map[fragment * fragmentSize], fragmentSize);
}
}
@@ -216,11 +170,11 @@ ST7735::configModule() {
lcdCSOff ();
lcdCSOn ();
mraa_gpio_write (m_rSTPinCtx, HIGH);
m_rSTPinCtx.write(HIGH);
usleep (500000);
mraa_gpio_write (m_rSTPinCtx, LOW);
m_rSTPinCtx.write(LOW);
usleep (500000);
mraa_gpio_write (m_rSTPinCtx, HIGH);
m_rSTPinCtx.write(HIGH);
usleep (500000);
executeCMDList (Rcmd1);
@@ -236,83 +190,83 @@ ST7735::configModule() {
refresh ();
}
mraa_result_t
mraa::Result
ST7735::lcdCSOn () {
mraa_result_t error = MRAA_SUCCESS;
mraa::Result error = mraa::SUCCESS;
error = mraa_gpio_write (m_csLCDPinCtx, LOW);
if (error != MRAA_SUCCESS) {
mraa_result_print (error);
error = m_csLCDPinCtx.write(LOW);
if (error != mraa::SUCCESS) {
mraa::printError (error);
}
error = mraa_gpio_write (m_cSDPinCtx, HIGH);
if (error != MRAA_SUCCESS) {
mraa_result_print (error);
error = m_cSDPinCtx.write(HIGH);
if (error != mraa::SUCCESS) {
mraa::printError (error);
}
return error;
}
mraa_result_t
mraa::Result
ST7735::lcdCSOff () {
mraa_result_t error = MRAA_SUCCESS;
mraa::Result error = mraa::SUCCESS;
error = mraa_gpio_write (m_csLCDPinCtx, HIGH);
if (error != MRAA_SUCCESS) {
mraa_result_print (error);
error = m_csLCDPinCtx.write(HIGH);
if (error != mraa::SUCCESS) {
mraa::printError (error);
}
return error;
}
mraa_result_t
mraa::Result
ST7735::sdCSOn () {
mraa_result_t error = MRAA_SUCCESS;
mraa::Result error = mraa::SUCCESS;
error = mraa_gpio_write (m_cSDPinCtx, LOW);
if (error != MRAA_SUCCESS) {
mraa_result_print (error);
error = m_cSDPinCtx.write(LOW);
if (error != mraa::SUCCESS) {
mraa::printError (error);
}
error = mraa_gpio_write (m_csLCDPinCtx, HIGH);
if (error != MRAA_SUCCESS) {
mraa_result_print (error);
error = m_csLCDPinCtx.write(HIGH);
if (error != mraa::SUCCESS) {
mraa::printError (error);
}
return error;
}
mraa_result_t
mraa::Result
ST7735::sdCSOff () {
mraa_result_t error = MRAA_SUCCESS;
mraa::Result error = mraa::SUCCESS;
error = mraa_gpio_write (m_cSDPinCtx, HIGH);
if (error != MRAA_SUCCESS) {
mraa_result_print (error);
error = m_cSDPinCtx.write(HIGH);
if (error != mraa::SUCCESS) {
mraa::printError (error);
}
return error;
}
mraa_result_t
mraa::Result
ST7735::rsHIGH () {
mraa_result_t error = MRAA_SUCCESS;
mraa::Result error = mraa::SUCCESS;
error = mraa_gpio_write (m_rSPinCtx, HIGH);
if (error != MRAA_SUCCESS) {
mraa_result_print (error);
error = m_rSPinCtx.write(HIGH);
if (error != mraa::SUCCESS) {
mraa::printError (error);
}
return error;
}
mraa_result_t
mraa::Result
ST7735::rsLOW () {
mraa_result_t error = MRAA_SUCCESS;
mraa::Result error = mraa::SUCCESS;
error = mraa_gpio_write (m_rSPinCtx, LOW);
if (error != MRAA_SUCCESS) {
mraa_result_print (error);
error = m_rSPinCtx.write(LOW);
if (error != mraa::SUCCESS) {
mraa::printError (error);
}
return error;