}
}
-maa_result_t
+maa_result_t
TM1637::setBrightness (uint8_t level) {
m_brightness = level;
}
-maa_result_t
+maa_result_t
TM1637::setSegments (const uint8_t segments[], uint8_t length, uint8_t pos) {
start();
writeByte(TM1637_I2C_COMM1);
stop();
}
-maa_result_t
+maa_result_t
TM1637::write (std::string msg) {
char leter = '\0';
uint8_t data[] = { 0x0, 0x0, 0x0, 0x0 };
setSegments(data);
}
-maa_result_t
+maa_result_t
TM1637::pinMode (maa_gpio_context ctx, gpio_dir_t mode) {
maa_result_t error = MAA_SUCCESS;
error = maa_gpio_dir(ctx, mode);
}
}
-maa_result_t
+maa_result_t
TM1637::start() {
pinMode (m_dataPinCtx, MAA_GPIO_OUT);
usleep(PULSE_LENGTH);
}
-maa_result_t
+maa_result_t
TM1637::stop() {
pinMode (m_dataPinCtx, MAA_GPIO_OUT);
usleep(PULSE_LENGTH);
usleep(PULSE_LENGTH);
}
-maa_result_t
+maa_result_t
TM1637::writeByte(uint8_t value) {
for (uint8_t idx = 0; idx < 8; idx++) {
pinMode(m_clkPinCtx, MAA_GPIO_OUT);
clear ();
usleep(4500);
- cmd (m_i2c_lcd_control, LCD_ENTRYMODESET |
- LCD_ENTRYLEFT |
+ cmd (m_i2c_lcd_control, LCD_ENTRYMODESET |
+ LCD_ENTRYLEFT |
LCD_ENTRYSHIFTDECREMENT);
setReg (m_i2c_lcd_rgb, m_rgb_address, 0, 0);
return error;
}
-maa_result_t
+maa_result_t
Jhd1313m1::setCursor (int row, int column) {
maa_result_t error = MAA_SUCCESS;
int row_addr[] = { 0x80, 0xc0, 0x14, 0x54};
uint8_t offset = ((column % 16) + row_addr[row]);
- uint8_t data[2] = { 0x80, offset };
+ uint8_t data[2] = { 0x80, offset };
error = maa_i2c_address (m_i2c_lcd_control, m_lcd_control_address);
error = maa_i2c_write (m_i2c_lcd_control, data, 2);
return error;
}
-maa_result_t
+maa_result_t
Jhd1313m1::clear () {
return cmd (m_i2c_lcd_control, LCD_CLEARDISPLAY);
}
-maa_result_t
+maa_result_t
Jhd1313m1::home () {
return cmd (m_i2c_lcd_control, LCD_RETURNHOME);
}
* private area
* **************
*/
-maa_result_t
+maa_result_t
Jhd1313m1::setReg (maa_i2c_context ctx, int deviceAdress, int addr, uint8_t value) {
maa_result_t error = MAA_SUCCESS;
return error;
}
-maa_result_t
+maa_result_t
Jhd1313m1::cmd (maa_i2c_context ctx, uint8_t value) {
maa_result_t error = MAA_SUCCESS;
}
}
-void
+void
NRF24l01::nrfInitModule (uint8_t chip_select, uint8_t chip_enable) {
maa_result_t error = MAA_SUCCESS;
m_spi = maa_spi_init (0);
}
-void
+void
NRF24l01::nrfConfigModule() {
/* Set RF channel */
nrfConfigRegister (RF_CH, m_channel);
}
/* Clocks only one byte into the given MiRF register */
-void
+void
NRF24l01::nrfConfigRegister(uint8_t reg, uint8_t value) {
nrfCSOn ();
maa_spi_write (m_spi, W_REGISTER | (REGISTER_MASK & reg));
nrfCSOff ();
}
-void
+void
NRF24l01::nrfPowerUpRX() {
m_ptx = 0;
nrfCELow();
nrfConfigRegister(CONFIG, mirf_CONFIG | ( (1<<PWR_UP) | (1<<PRIM_RX) ) );
nrfCEHigh();
- nrfConfigRegister(STATUS,(1 << TX_DS) | (1 << MAX_RT));
+ nrfConfigRegister(STATUS,(1 << TX_DS) | (1 << MAX_RT));
}
-void
+void
NRF24l01::nrfFlushRX() {
nrfCSOn ();
maa_spi_write (m_spi, FLUSH_RX);
}
/* Sets the receiving address */
-void
+void
NRF24l01::nrfSetRXaddr(uint8_t * addr) {
nrfCELow();
nrfWriteRegister(RX_ADDR_P1, addr, mirf_ADDR_LEN);
}
/* Sets the transmitting address */
-void
+void
NRF24l01::nrfSetTXaddr(uint8_t * addr)
{
/* RX_ADDR_P0 must be set to the sending addr for auto ack to work. */
}
/* The broadcast address should be 0xFFFFF */
-void
+void
NRF24l01::nrfSetBroadcastAddr (uint8_t * addr) {
nrfCELow ();
nrfWriteRegister (RX_ADDR_P2, addr, mirf_ADDR_LEN);
nrfCEHigh ();
}
-void
+void
NRF24l01::nrfSetPayload (uint8_t load) {
m_payload = load;
}
-void
-NRF24l01::nrfWriteRegister(uint8_t reg, uint8_t * value, uint8_t len)
+void
+NRF24l01::nrfWriteRegister(uint8_t reg, uint8_t * value, uint8_t len)
{
nrfCSOn ();
maa_spi_write (m_spi, W_REGISTER | (REGISTER_MASK & reg));
nrfCSOff ();
}
-void
+void
NRF24l01::nrfTransmitSync(uint8_t *dataout, uint8_t len){
uint8_t i;
for(i = 0; i < len; i++) {
}
/* Checks if data is available for reading */
-bool
+bool
NRF24l01::nrfDataReady() {
uint8_t status = nrfGetStatus();
if ( status & (1 << RX_DR) ) {
return !nrfRXFifoEmpty();
}
-uint8_t
+uint8_t
NRF24l01::nrfGetStatus () {
uint8_t rv;
nrfReadRegister (STATUS, &rv, 1);
}
/* Reads an array of bytes from the given start position in the MiRF registers. */
-void
+void
NRF24l01::nrfReadRegister (uint8_t reg, uint8_t * value, uint8_t len)
{
nrfCSOn ();
nrfCSOff ();
}
-void
+void
NRF24l01::nrfTransferSync (uint8_t *dataout,uint8_t *datain,uint8_t len) {
uint8_t i;
for(i = 0;i < len;i++) {
}
}
-bool
+bool
NRF24l01::nrfRXFifoEmpty () {
uint8_t fifo_status;
nrfReadRegister (FIFO_STATUS, &fifo_status, sizeof(fifo_status));
}
/* Reads payload bytes into data array */
-void
-NRF24l01::nrfGetData (uint8_t * data)
+void
+NRF24l01::nrfGetData (uint8_t * data)
{
nrfCSOn ();
/* Send cmd to read rx payload */
/* Sends a data package to the default address. Be sure to send the correct
* amount of bytes as configured as payload on the receiver. */
-void
+void
NRF24l01::nrfSend(uint8_t * value) {
uint8_t status;
status = nrfGetStatus();
nrfCEHigh(); // Start transmission
}
-void
+void
NRF24l01::nrfSend () {
nrfSend (m_txBuffer);
}
-bool
+bool
NRF24l01::nrfIsSending () {
uint8_t status;
if (m_ptx) { // Sending mode.
/* if sending successful (TX_DS) or max retries exceded (MAX_RT). */
if((status & ((1 << TX_DS) | (1 << MAX_RT)))){
nrfPowerUpRX();
- return false;
+ return false;
}
return true;
}
return false;
}
-void
+void
NRF24l01::nrfPowerUpTX () {
m_ptx = 1;
nrfConfigRegister (CONFIG, mirf_CONFIG | ( (1<<PWR_UP) | (0<<PRIM_RX) ) );
}
-void
+void
NRF24l01::nrfPowerDown () {
nrfCELow ();
nrfConfigRegister (CONFIG, mirf_CONFIG);
}
-maa_result_t
+maa_result_t
NRF24l01::nrfCEHigh () {
return maa_gpio_write (m_cePinCtx, HIGH);
}
-maa_result_t
+maa_result_t
NRF24l01::nrfCELow () {
return maa_gpio_write (m_cePinCtx, LOW);
}
-maa_result_t
+maa_result_t
NRF24l01::nrfCSOn () {
return maa_gpio_write (m_csnPinCtx, LOW);
}
-maa_result_t
+maa_result_t
NRF24l01::nrfCSOff () {
return maa_gpio_write (m_csnPinCtx, HIGH);
}
-void
+void
NRF24l01::nrfListenForChannel() {
if(!nrfIsSending() && nrfDataReady()) {
nrfGetData(m_rxBuffer);