Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years ago.
serial textlcd not able to implement with ble? anyone tried before.
serial textlcd
#include "mbed.h"
#include "ble/BLE.h"
#include "CyclingSpeedAndCadenceService.h"
#include "ble/services/BatteryService.h"
#include "ble/services/DeviceInformationService.h"
//#include "SDFileSystem.h"
#include "SoftSerial.h"
#include "SerialLCD.h"
//SDFileSystem sd(D2, D1, D0, D3, "sd");
//SoftSerial SoftSerial(PinName D4, PinName NC, const char* name = NULL);
//SerialLCD Seriall(NC, D4);
BLE ble;
Timer timer;
Timer t;
Timeout nopulses;
InterruptIn pulses(P0_7);
DigitalOut pulses2(P0_28);
const static char DEVICE_NAME[] = "Henrymeter";
static const uint16_t uuid16_list[] = {GattService::UUID_CYCLING_SPEED_AND_CADENCE,
GattService::UUID_DEVICE_INFORMATION_SERVICE
};
uint32_t c;
uint16_t oldvalue;
uint16_t min;
uint16_t r;
//const int blades = 6;
volatile long int rpmf;
volatile long int rpm;
uint16_t total=0; // init crank to 10revs
uint16_t totalizer;
volatile long int irritime= 0;
uint32_t nextWheel = 0;
uint32_t nextCrank = 0;
//char totalstring[10], flowstring[10]; // create string arrays
static volatile bool triggerWheel = false;
static volatile bool triggerCrank = false;
static volatile bool afterreset = false;
void endprocess();
void timing();
void display();
void interup() ;
void onTick(void);
void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason)
{
ble.gap().startAdvertising(); // restart advertising
}
void setup()
{
mySerial.baud(9600); // set up serial port for 9600 baud
wait(0.5); // wait for display to boot up
mySerial.write(254); // cursor to beginning of first line
mySerial.write(130);
mySerial.write(" "); // clear display
mySerial.write(" ");
mySerial.write(254); // cursor to beginning of first line
mySerial.write(130);
mySerial.write("GPM= "); // clear display + legends
mySerial.write(254); // cursor to beginning of first line
mySerial.write(192);
mySerial.write("Ac-inch= ");
}
void loop()
{
temp = random(1000); // make some fake data
rpm = random(10000);
float speed = (((rpmf/6)*60)/ blades) * 6.28f * 9 * 322.51*0.00026417;
sprintf(flowstring,"%1.2f", speed); // create strings from the numbers
sprintf(totalstring,"%1.2f",total*0.01); // right-justify to 4 spaces
mySerial.write(254); // cursor to 7th position on first line
mySerial.write(135);
mySerial.write(flowstring); // write out the RPM value
mySerial.write(254); // cursor to 7th position on second line
mySerial.write(201);
mySerial.write(totalstring); // write out the TEMP value
wait(1); // short delay
}
the lcd i am using can be found in teh following link: https://www.sparkfun.com/products/9067
posted by jayendra mishra 19 Oct 2016