I was not able to print without a colon. I tried to use the class info on Colon() class and set up a boolean to turn off the colon. I couldn't get it print.

Dependencies:   SLCD TSI mbed

Fork of kl46z_btn_slider_toSerial by Stanley Cohen

main.cpp

Committer:
menchacaeli
Date:
2017-01-22
Revision:
8:018b01e6b807
Parent:
7:8f64ad5334ca

File content as of revision 8:018b01e6b807:

#include "mbed.h"
#include "SLCD.h"
#include "TSISensor.h"


#define LEDON false
#define LEDOFF true
#define NUMBUTS 2
#define RBUTINDEX 0
#define LBUTINDEX 1
#define LBUT PTC12  // port addresses for buttons
#define RBUT PTC3
#define DATATIME    200 //milliseconds
#define LCDLEN      10
#define PROGNAME "kl46z_btn_slider_toSerial\r\n"
#define COLOFF 0 // setting boolean to turn off colon
#define COLON 1 // setting boolean to turn on colon

// Cap slider interface
SLCD slcd; //define LCD display

TSISensor tsiScaling; // Capacitive sensor/slider
Timer dataTimer;

// Button interrrupts
InterruptIn rtButton(RBUT);
InterruptIn lfButton(LBUT); 

//char lcdData[LCDLEN];

char noColData[LCDLEN];

Serial pc(USBTX, USBRX);// set up USB as communications to Host PC via USB connectons
 
// Interrupt service routines
void rtButtonPressed(){
    pc.printf("button: right\r\n");
}

void lfButtonPressed(){
    pc.printf("button: left \r\n");
}
        
// End interrupt routines

// Regular routines
void LCDMessNoDwell(char *lMess){
        slcd.Home();
        slcd.clear();
        //using line below to turn off or on colon
        slcd.Colon(COLOFF);
        slcd.printf(lMess);
} 

// --------------------------------
 int main() {
    float sliderValue = 0.0;
    //int sliderValue = 0;
            
    pc.printf(PROGNAME);
    dataTimer.start();
    dataTimer.reset();
     
    //sprintf (lcdData,"%4.3f",0.0);
    //LCDMessNoDwell(lcdData);
    
    sprintf (noColData,"%4.3f", 0.0);
    LCDMessNoDwell(noColData);
    
// Interrupt routine setups
    rtButton.fall(&rtButtonPressed);
    lfButton.fall(&lfButtonPressed);
    
// End of setup

    while(true) {
    // All the interrupts
        
        if (dataTimer.read_ms() > DATATIME){
            // Read the slider value
            float newSliderValue = tsiScaling.readPercentage();
            // Only do stuff with it if it's a new value or if it's not zero
            if(newSliderValue > 0.0 && newSliderValue != sliderValue) {
                sliderValue = newSliderValue;
                //sprintf (lcdData,"%4.3f", sliderValue);  // Just to make things user readable
                sprintf (noColData, "%4.3f", sliderValue); 
                
                //LCDMessNoDwell(noColData);
                LCDMessNoDwell(noColData);
                pc.printf("slider: %4.3f\r\n", sliderValue);
            }
            dataTimer.reset(); 
        }   
      
    }
}