Author Topic: two CC13110 and grove LCD rgb working with Energia  (Read 2386 times)

0 Members and 1 Guest are viewing this topic.

Offline AhmadTopic starter

  • Newbie
  • Posts: 8
  • Country: us
two CC13110 and grove LCD rgb working with Energia
« on: June 03, 2017, 05:23:43 am »
hey all,

I am working on project with two CC1310 ( TX and RX) and Grove-LCD RGB backlight working with Energia, and i have downloaded their library. i have an issue with the LCD, the issue is the LCD does not show to me the float numbers (number after the decimal point) , so what i think there is a specific code that make the floating number shows on the LCD. i attached the codes for TX and RX and also i attached the picture of is working with me now. 


thanks,

/*
  EasyLinkRx

  A basic EasyLink Receive example..
  Receive a packet and print the 16-bit value stored in the payload.
  This Sketch is the counterpart of teh EasyLinkTx example.

  Hardware Required:
    CC1310 LaunchPad

  This example code is in the public domain.
*/

#include "EasyLink.h"
#include <wire.h>
#include "rgb_lcd.h"

rgb_lcd lcd;
const int colorR = 255;
const int colorG = 30;
const int colorB = 6;


EasyLink_RxPacket rxPacket;
EasyLink myLink;

void setup() {
  //Serial.begin(115200);
  // begin defaults to EasyLink_Phy_50kbps2gfsk
  lcd.begin(16, 2);
  myLink.begin(EasyLink_Phy_625bpsLrm);
  Serial.println(myLink.version());
  lcd.setRGB(colorR, colorG, colorB);
  lcd.clear();

    lcd.setCursor(4, 0);
    //Print a message to the LCD.
    lcd.print("Recovery");
    lcd.setCursor(5, 1);
    lcd.print("System");
    delay (2000);
   

    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Owned by:Jornada");
    lcd.setCursor(0, 1);
    lcd.print("Exp. Range");
    delay(4000);
    lcd.clear();
 
    lcd.setCursor(1,0);
    lcd.print("Built By");
    lcd.setCursor(3, 1);
    lcd.print("NMSU-ECE Dept");
    delay(4000);
    lcd.clear();

}

uint16_t value;
uint8_t address;

void loop() {
  // Wait / block for 2 second to receive a packet.
  // rxTimeout is in Radio time and needs to be converted from miliseconds to Radio Time
  rxPacket.rxTimeout = EasyLink_ms_To_RadioTime(2000);
  // Turn the receiver on immediately
  rxPacket.absTime = EasyLink_ms_To_RadioTime(0);


  EasyLink_Status status = myLink.receive(&rxPacket);

  if (status == EasyLink_Status_Success) {
    memcpy(&value,&rxPacket.payload[0], sizeof(uint16_t));
    //lcd.print("Packet received with lenght ");
    lcd.setCursor(0,0);
    lcd.print("North: ");
    lcd.print(rxPacket.payload[0]); 

       
    memcpy(&address,&rxPacket.payload[1], sizeof(uint8_t));
   

    lcd.setCursor(0,1);
    lcd.print("East:");
    lcd.print(rxPacket.payload[1]);
    delay (2000);
    lcd.clear();
   
   
 
  }
 
  else {

    lcd.print("Error receiving packet with status code: ");
    //lcd.print(status);
    //lcd.print(" (");
    //lcd.print(myLink.getStatusString(status));
    //lcd.println(")");
  }
 
  delay(1000); 
  lcd.clear();
 
}




_______________________


/*
  EasyLinkTx
 
  A basic EasyLink Transmit example..
  Read the analog value from A0 (pin 2) and copy the value into the tx packet.
  This Sketch is the counterpart of teh EasyLinkRx example.
 
  Hardware Required:
  * CC1310 LaunchPad
 
  This example code is in the public domain.
*/

#include "EasyLink.h"

EasyLink_TxPacket txPacket;

EasyLink myLink;

void setup() {
  Serial.begin(115200);

  // begin defaults to EasyLink_Phy_50kbps2gfsk
  myLink.begin(EasyLink_Phy_625bpsLrm);
  Serial.println(myLink.version());

  // Set the destination address to 0xaa
  txPacket.dstAddr[0] = 0xaa;

}



  float x = 32.281062;
  float y = 106.753838;
 
  void loop() {
  uint16_t value[3]= {y};
  uint8_t  address= {x};
  uint32_t xbee= 16;
 
 
  // Copy the analog value into the txPacket payload
 memcpy(&txPacket.payload[0], &value, sizeof(uint16_t));
 memcpy(&txPacket.payload[1], &address, sizeof(uint8_t));
 
 
  // Set the length of the packet
  txPacket.len = sizeof(uint16_t);
  // Transmit immediately
  txPacket.absTime = EasyLink_ms_To_RadioTime(0);

  EasyLink_Status status = myLink.transmit(&txPacket);

  if(status == EasyLink_Status_Success) {
 
   

    Serial.println("");

  //uint8_t address= {9} ;
 
  // Set the length of the packet
  txPacket.len = sizeof(uint8_t);
  // Transmit immediately
  txPacket.absTime = EasyLink_ms_To_RadioTime(0);

  EasyLink_Status status = myLink.transmit(&txPacket);
  Serial.print("NEWVALUE");
  Serial.print(address);
   
  }
 
 
 
 
  else {
    Serial.print("Transmit failed with status code: ");
    Serial.print(status);
    Serial.print(" (");
    Serial.print(myLink.getStatusString(status));
    Serial.println(")");
  }

  delay(1000);

}
 

Offline David Chamberlain

  • Regular Contributor
  • *
  • Posts: 249
Re: two CC13110 and grove LCD rgb working with Energia
« Reply #1 on: June 03, 2017, 05:19:23 pm »
This bit. Your casting a float as an unsigned int. Not going to work.


float x = 32.281062;
float y = 106.753838;
 
uint16_t value[3]= {y};
uint8_t  address= {x};


This might help.
https://stackoverflow.com/questions/6910115/how-to-represent-float-number-in-memory-in-c

Or use sprintf and sent your values as stings.
« Last Edit: June 03, 2017, 05:23:53 pm by David Chamberlain »
 

Offline AhmadTopic starter

  • Newbie
  • Posts: 8
  • Country: us
Re: two CC13110 and grove LCD rgb working with Energia
« Reply #2 on: June 04, 2017, 08:09:11 am »
Hey David, thank you for your help but i can't see this website helpful if you can give the code or anyone can for what should change thats will be great. i really need help in this project. thank you
 

Offline AhmadTopic starter

  • Newbie
  • Posts: 8
  • Country: us
Re: two CC13110 and grove LCD rgb working with Energia
« Reply #3 on: June 05, 2017, 08:52:26 am »
Any help guys ?
 

Offline Buriedcode

  • Super Contributor
  • ***
  • Posts: 1631
  • Country: gb
Re: two CC13110 and grove LCD rgb working with Energia
« Reply #4 on: June 05, 2017, 12:42:27 pm »
Davids reply provides plenty of information.

You're casting a float to 3 unsigned 16-bit variable.  And casting another float to an 8-bit variable.  That clearly isn't going to work.

Rather than google your problem for specific hardware, perhaps look for Arduino examples or sending float values over serial port?  I only mentioned Arduino because that's generally a popular platform so should return more answers.
 
The following users thanked this post: David Chamberlain


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf