two CC13110 and grove LCD rgb working with Energia  - Page 1
Forum section: electronics / general

author: Ahmad
author_rank: Newbie
timestamp: June 03, 2017, 05:23:43 am
content: 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,/*EasyLinkRxA 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 LaunchPadThis 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_50kbps2gfsklcd.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 TimerxPacket.rxTimeout = EasyLink_ms_To_RadioTime(2000);// Turn the receiver on immediatelyrxPacket.absTime = EasyLink_ms_To_RadioTime(0);EasyLink_Status status = myLink.receive(&rxPacket);if (status == EasyLink_Status_Success) {memcpy(&value,&rxPacket.payload, sizeof(uint16_t));//lcd.print("Packet received with lenght ");lcd.setCursor(0,0);lcd.print("North: ");lcd.print(rxPacket.payload);memcpy(&address,&rxPacket.payload, sizeof(uint8_t));lcd.setCursor(0,1);lcd.print("East:");lcd.print(rxPacket.payload);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();}_______________________/*EasyLinkTxA 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 LaunchPadThis 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_50kbps2gfskmyLink.begin(EasyLink_Phy_625bpsLrm);Serial.println(myLink.version());// Set the destination address to 0xaatxPacket.dstAddr = 0xaa;}float x = 32.281062;float y = 106.753838;void loop() {uint16_t value= {y};uint8_t address= {x};uint32_t xbee= 16;// Copy the analog value into the txPacket payloadmemcpy(&txPacket.payload, &value, sizeof(uint16_t));memcpy(&txPacket.payload, &address, sizeof(uint8_t));// Set the length of the packettxPacket.len = sizeof(uint16_t);// Transmit immediatelytxPacket.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 packettxPacket.len = sizeof(uint8_t);// Transmit immediatelytxPacket.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);}

author: David Chamberlain
author_rank: Frequent Contributor
timestamp: June 03, 2017, 05:19:23 pm
content: 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= {y};uint8_t address= {x};This might help.https://stackoverflow.com/questions/6910115/how-to-represent-float-number-in-memory-in-cOr use sprintf and sent your values as stings.

author: Ahmad
author_rank: Newbie
timestamp: June 04, 2017, 08:09:11 am
content: 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

author: Ahmad
author_rank: Newbie
timestamp: June 05, 2017, 08:52:26 am
content: Any help guys ?

author: Buriedcode
author_rank: Super Contributor
timestamp: June 05, 2017, 12:42:27 pm
content: 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.