Use with a Nucleo F401RE and a Sharp Optical Dust Sensor GP2Y1010AU0F to measure dust with a Nokia 5110 display to show result.
Revision 0:99fdd85b4929, committed 2014-06-14
- Comitter:
- kirchnet
- Date:
- Sat Jun 14 02:25:52 2014 +0000
- Commit message:
- Use with a Nucleo F401RE and a Sharp Optical Dust Sensor GP2Y1010AU0F to measure dust with a Nokia 5110 display to show results.
Changed in this revision
diff -r 000000000000 -r 99fdd85b4929 NOKIA_5110.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/NOKIA_5110.cpp Sat Jun 14 02:25:52 2014 +0000 @@ -0,0 +1,173 @@ +// Project: Nokia5110 - Controlling a NK5110 display from an NXP LPC1768 +// File: NOKIA_5110.cpp +// Author: Chris Yan +// Created: January, 2012 +// Revised: January, 2014 +// Desc: Supporting code for the NokiaLcd class + +#include "NOKIA_5110.h" +#include "mbed.h" + +NokiaLcd::NokiaLcd(LcdPins pinout) +{ + // SPI + LcdSpi = new SPI(pinout.mosi, pinout.miso, pinout.sclk); + LcdSpi->format(LCD_SPI_BITS, LCD_SPI_MODE); + LcdSpi->frequency(LCD_FREQ); + + // Control Pins + Pins = new DigitalOut*[3]; + Pins[PIN_RST] = new DigitalOut(pinout.rst); + Pins[PIN_SCE] = new DigitalOut(pinout.sce); + Pins[PIN_DC] = new DigitalOut(pinout.dc); + + // Initial Command Instructions, note the initial command mode + FunctionSet.V = CMD_FS_HORIZONTAL_MODE; + FunctionSet.H = CMD_FS_EXTENDED_MODE; + FunctionSet.PD = CMD_FS_ACTIVE_MODE; + FunctionChar = CreateFunctionChar(); + + TempControlChar = CMD_TC_TEMP_2; + DispControlChar = CMD_DC_NORMAL_MODE; + BiasChar = CMD_BI_MUX_48; + VopChar = CMD_VOP_7V38; +} + +void NokiaLcd::ShutdownLcd() +{ + FunctionSet.PD = CMD_FS_POWER_DOWN_MODE; + + ClearLcdMem(); + SendFunction( CMD_DC_CLEAR_DISPLAY ); + SendFunction( CreateFunctionChar() ); +} + +void NokiaLcd::ClearLcdMem() +{ + for(int tick = 0; tick <= 503; tick++) + LcdSpi->write(0x00); +} + +void NokiaLcd::TestLcd(char test_pattern) +{ + for(int tick = 0; tick <= 503; tick++) + LcdSpi->write(test_pattern); // Command gets sent +} + +void NokiaLcd::InitLcd() +{ + ResetLcd(); + Pins[PIN_SCE]->write(0); // Chip Select goes low + + // Redefine the FunctionChar in case it has changed + FunctionSet.V = CMD_FS_HORIZONTAL_MODE; + FunctionSet.H = CMD_FS_EXTENDED_MODE; + FunctionSet.PD = CMD_FS_ACTIVE_MODE; + SendFunction( CreateFunctionChar() ); // Extended CMD set + SendFunction( VopChar ); // | Vop + SendFunction( TempControlChar ); // | Temp + SendFunction( BiasChar ); // | Bias + + FunctionSet.H = CMD_FS_BASIC_MODE; + SendFunction( CreateFunctionChar() ); // Basic CMD set + SendFunction( DispControlChar ); // | Display Mode + + ClearLcdMem(); + Pins[PIN_DC]->write(1); // Data/CMD goes back to Data mode +} + +void NokiaLcd::ResetLcd() +{ + Pins[PIN_RST]->write(0); // Reset goes low + Pins[PIN_RST]->write(1); // Reset goes high +} + +char NokiaLcd::CreateFunctionChar() +{ + return ( 0x20 | FunctionSet.PD | FunctionSet.V | FunctionSet.H ); +} + +void NokiaLcd::SendDrawData(char data) +{ + LcdSpi->write(data); // Command gets sent +} + +void NokiaLcd::DrawChar(char character) +{ + for( int i = 0; i < 6; i++) + SendDrawData( FONT_6x6[ ((character - 32)*6) + i] ); +} + +void NokiaLcd::DrawString(char* s) +{ + char len = strlen(s); + for( int idx = 0; idx < len; idx++ ) + { + for( int i = 0; i < 6; i++) + SendDrawData( FONT_6x6[ ((s[idx] - 32)*6) + i] ); + } +} + +void NokiaLcd::DrawFrameChar(char character) +{ + for( int i = 0; i < 6; i++) + SendDrawData((( FONT_6x6[ ((character - 32)*6) + i] ) << 1 ) | 0x81); +} + +void NokiaLcd::DrawNegFrameChar(char character) +{ + for( int i = 0; i < 6; i++) + SendDrawData(~(( FONT_6x6[ ((character - 32)*6) + i] ) << 1 ) | 0x81); +} + +char* NokiaLcd::NumToStr(int num) +{ + if(num <= 0) + return "0"; + + double length = 0; + int tlen = 0; + int temp = 1; + char c; + + // Get number of digits + while( temp <= num ) + { + temp *= 10; + length++; + } + tlen = length; + char* numString = new char[tlen+1]; + + // Convert each place in number to a stand-alone representative number + temp = 0; + for(int idx = pow(10, length); idx>1; idx = (idx/10)) + { + c = (char)( ((num % idx)-(num % (idx/10)))/(idx/10) + 48); + numString[temp] = c; + temp++; + } + numString[temp] = '\0'; + return numString; +} + +void NokiaLcd::SetXY(char x, char y) +{ + if( (x > 83) || (y > 5) ) + return; + + SendFunction( x | 0x80 ); + SendFunction( y | 0x40 ); +} + +void NokiaLcd::SendFunction(char cmd) //TODO:Detection of what H should be +{ + Pins[PIN_DC]->write(0); // Data/CMD goes low + LcdSpi->write(cmd); // Command gets sent + Pins[PIN_DC]->write(1); // Data/CMD goes back to Data mode +} + +NokiaLcd::~NokiaLcd() +{ + ShutdownLcd(); +}
diff -r 000000000000 -r 99fdd85b4929 NOKIA_5110.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/NOKIA_5110.h Sat Jun 14 02:25:52 2014 +0000 @@ -0,0 +1,238 @@ +// Project: Nokia5110 - Controlling a NK5110 display from an NXP LPC1768 +// File: NOKIA_5110.h +// Author: Chris Yan +// Created: January, 2012 +// Revised: January, 2014 +// Desc: Commands, fonts, and class for using a +// Nokia 5110 LCD via the Phillips 8554 LCD driver. +// +// Typical Usage: User must fill the LcdPins struct with the pinout used to control the LCD and +// instantiate the NokiaLcd class - passing the created LcdPins struct to the constructor. +// The class function NokiaLcd::InitLcd may then be called to reset and start the LCD driver. +// A simple 6x6 font (6x8 in LCD space and ~5x5 character space) is included to facilitate +// the NokiaLcd::DrawChar( char character ) function, which will copy the character 8 bits +// at a time for 6 clock cycles. +// Commands may be sent to the LCD via the NokiaLcd::SendFunction(char cmd) +// function, but be aware that certain commands require the Function Set register's H-value +// to be either 1 or 0, depending on the command. This class does not check to see whether +// the H-value is of proper status. The Function Set register /may/ be changed via the +// NokiaLcd::SendFunction(char cmd), but the code uses this internally and expects that +// most function registers have not been changed by the user. +// +// Example: +// #include "mbed.h" +// #include "NOKIA_5110.h" +// +// int main() { +// LcdPins myLcdPins = { p11, NC, p13, p10, p8, p9 }; +// NokiaLcd myLcd( myLcdPins ); // SPI is started here (8-bits, mode 1) +// myLcd.InitLcd(); // LCD is reset and DDRAM is cleared +// myLcd.TestLcd( 0xAA ); // Draws a vertical pattern where every other pixel is on +// wait(10); +// myLcd.ShutdownLcd(); // Clears the LCD's DDRAM and powers it down via CMD_FS_POWER_DOWN_MODE, H=0 +// while(1) +// { }; +// } + +// Command Instructions +// H = 0 +#ifndef __NOKIA_5110_H__ +#define __NOKIA_5110_H__ + +// Command Instructions +// H = 0 +#define CMD_DC_CLEAR_DISPLAY 0x08 +#define CMD_DC_NORMAL_MODE 0x0C +#define CMD_DC_FILL_DISPLAY 0x09 +#define CMD_DC_INVERT_VIDEO 0x0D +#define CMD_FS_HORIZONTAL_MODE 0x00 +#define CMD_FS_VERTICAL_MODE 0x02 +#define CMD_FS_BASIC_MODE 0x00 +#define CMD_FS_EXTENDED_MODE 0x01 +#define CMD_FS_ACTIVE_MODE 0x00 +#define CMD_FS_POWER_DOWN_MODE 0x04 +// H = 1 +#define CMD_TC_TEMP_0 0x04 +#define CMD_TC_TEMP_1 0x05 +#define CMD_TC_TEMP_2 0x06 +#define CMD_TC_TEMP_3 0x07 +#define CMD_BI_MUX_24 0x15 +#define CMD_BI_MUX_48 0x13 +#define CMD_BI_MUX_100 0x10 +#define CMD_VOP_6V06 0xB2 +#define CMD_VOP_7V38 0xC8 + +// LCD Characteristics +#define LCD_FREQ 1000000 +#define LCD_SPI_MODE 0x01 +#define LCD_SPI_BITS 0x08 +#define LCD_X_MAX 84 +#define LCD_Y_MAX 48 + +#define PIN_RST 0x00 +#define PIN_SCE 0x01 +#define PIN_DC 0x02 + +#include "mbed.h" + +struct LcdPins +{ + PinName mosi; + PinName miso; + PinName sclk; + PinName dc; + PinName sce; + PinName rst; +}; + +struct LcdFunctionSet +{ + char PD; + char V; + char H; +}; + +typedef char LcdFunctionChar; +typedef char LcdTempControl; +typedef char LcdDispControl; +typedef char LcdBiasChar; +typedef char LcdVopChar; + +class NokiaLcd +{ + public: + NokiaLcd(LcdPins lcd_pinout); + ~NokiaLcd(); + + public: + void InitLcd(); + void ClearLcdMem(); + void ShutdownLcd(); + void SendFunction(char cmd); + void TestLcd(char test_pattern); + void SendDrawData(char data); + + public: + void DrawString(char* str); + void DrawChar(char character); + void SetXY(char x, char y); + void DrawFrameChar(char character); + void DrawNegFrameChar(char character); + char* NumToStr(int num); + + private: + char CreateFunctionChar(); + void ResetLcd(); + + private: + LcdFunctionChar FunctionChar; + LcdTempControl TempControlChar; + LcdDispControl DispControlChar; + LcdFunctionSet FunctionSet; + LcdBiasChar BiasChar; + LcdVopChar VopChar; + DigitalOut** Pins; + SPI* LcdSpi; + +}; + +const char FONT_6x6[570] = //should be 564 total char +{ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // SPACE 1 + 0x00, 0x06, 0x2F, 0x06, 0x00, 0x00, // ! 2 + 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, // " 3 + 0x14, 0x3E, 0x14, 0x3E, 0x14, 0x00, // # 4 + 0x2E, 0x2A, 0x3F, 0x2A, 0x3A, 0x00, // $ 5 + 0x26, 0x16, 0x08, 0x34, 0x32, 0x00, // % 6 + 0x34, 0x2A, 0x3C, 0x18, 0x28, 0x00, // & 7 + 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, // ' 8 + 0x00, 0x00, 0x1C, 0x36, 0x22, 0x00, // ( 9 + 0x22, 0x36, 0x1C, 0x00, 0x00, 0x00, // ) 10 + 0x24, 0x18, 0x0E, 0x18, 0x24, 0x00, // * 11 + 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, // + 12 + 0x20, 0x30, 0x00, 0x00, 0x00, 0x00, // , 13 + 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, // - 14 + 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, // . 15 + 0x30, 0x18, 0x0C, 0x06, 0x00, 0x00, // / 16 + 0x00, 0x1C, 0x22, 0x22, 0x1C, 0x00, // 0 17 + 0x00, 0x24, 0x3E, 0x20, 0x00, 0x00, // 1 18 + 0x3A, 0x2A, 0x2A, 0x2A, 0x2E, 0x00, // 2 19 + 0x22, 0x2A, 0x2A, 0x2A, 0x3E, 0x00, // 3 20 + 0x0E, 0x08, 0x08, 0x3E, 0x08, 0x00, // 4 21 + 0x2E, 0x2A, 0x2A, 0x2A, 0x3A, 0x00, // 5 22 + 0x3E, 0x2A, 0x2A, 0x2A, 0x3A, 0x00, // 6 23 + 0x22, 0x12, 0x0A, 0x06, 0x02, 0x00, // 7 24 + 0x3E, 0x2A, 0x2A, 0x2A, 0x3E, 0x00, // 8 25 + 0x00, 0x2E, 0x2A, 0x2A, 0x3E, 0x00, // 9 26 + 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, // : 27 + 0x00, 0x20, 0x14, 0x00, 0x00, 0x00, // ; 28 + 0x00, 0x00, 0x08, 0x14, 0x22, 0x00, // < 29 + 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, // = 30 + 0x22, 0x14, 0x08, 0x00, 0x00, 0x00, // > 31 + 0x06, 0x01, 0x2D, 0x06, 0x00, 0x00, // ? 32 + 0x1E, 0x23, 0x19, 0x35, 0x3E, 0x00, // @ 33 + 0x3C, 0x0A, 0x0A, 0x0A, 0x3C, 0x00, // A 34 + 0x3E, 0x2A, 0x2A, 0x2A, 0x1C, 0x00, // B 35 + 0x1C, 0x22, 0x22, 0x22, 0x22, 0x00, // C 36 + 0x3E, 0x22, 0x22, 0x22, 0x1C, 0x00, // D 37 + 0x3E, 0x2A, 0x2A, 0x2A, 0x22, 0x00, // E 38 + 0x3E, 0x0A, 0x0A, 0x0A, 0x02, 0x00, // F 39 + 0x1C, 0x22, 0x2A, 0x2A, 0x18, 0x00, // G 40 + 0x3E, 0x08, 0x08, 0x08, 0x3E, 0x00, // H + 0x22, 0x22, 0x3E, 0x22, 0x22, 0x00, // I + 0x10, 0x22, 0x22, 0x1E, 0x02, 0x00, // J + 0x3E, 0x08, 0x14, 0x22, 0x00, 0x00, // K + 0x00, 0x3E, 0x20, 0x20, 0x20, 0x00, // L 45 + 0x3E, 0x04, 0x08, 0x04, 0x3E, 0x00, // M + 0x3C, 0x02, 0x02, 0x02, 0x3C, 0x00, // N + 0x1C, 0x22, 0x22, 0x22, 0x1C, 0x00, // O + 0x3E, 0x0A, 0x0A, 0x04, 0x00, 0x00, // P + 0x1C, 0x22, 0x32, 0x3C, 0x20, 0x00, // Q 50 + 0x3E, 0x0A, 0x0A, 0x1A, 0x24, 0x00, // R + 0x24, 0x2A, 0x2A, 0x2A, 0x12, 0x00, // S + 0x02, 0x02, 0x3E, 0x02, 0x02, 0x00, // T + 0x1E, 0x20, 0x20, 0x20, 0x1E, 0x00, // U + 0x06, 0x18, 0x20, 0x18, 0x06, 0x00, // V 55 + 0x0E, 0x30, 0x18, 0x30, 0x0E, 0x00, // W + 0x22, 0x14, 0x08, 0x14, 0x22, 0x00, // X + 0x02, 0x04, 0x38, 0x04, 0x02, 0x00, // Y + 0x22, 0x32, 0x2A, 0x26, 0x22, 0x00, // Z + 0x00, 0x00, 0x00, 0x3E, 0x22, 0x00, // [ 60 + 0x06, 0x0C, 0x18, 0x30, 0x00, 0x00, // backslash + 0x22, 0x3E, 0x00, 0x00, 0x00, 0x00, // ] + 0x00, 0x04, 0x02, 0x02, 0x04, 0x00, // ^ + 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, // _ + 0x00, 0x00, 0x04, 0x08, 0x00, 0x00, // ` 65 + 0x18, 0x24, 0x14, 0x38, 0x00, 0x00, // a + 0x1E, 0x28, 0x28, 0x10, 0x00, 0x00, // b + 0x18, 0x24, 0x24, 0x00, 0x00, 0x00, // c + 0x10, 0x28, 0x28, 0x1E, 0x00, 0x00, // d + 0x18, 0x2C, 0x2C, 0x08, 0x00, 0x00, // e 70 + 0x00, 0x3C, 0x12, 0x04, 0x00, 0x00, // f + 0x24, 0x2A, 0x1E, 0x00, 0x00, 0x00, // g + 0x3E, 0x08, 0x30, 0x00, 0x00, 0x00, // h + 0x00, 0x3A, 0x00, 0x00, 0x00, 0x00, // i + 0x10, 0x20, 0x1A, 0x00, 0x00, 0x00, // j 75 + 0x3E, 0x10, 0x2C, 0x20, 0x00, 0x00, // k + 0x00, 0x3E, 0x00, 0x00, 0x00, 0x00, // l + 0x38, 0x08, 0x18, 0x08, 0x30, 0x00, // m + 0x30, 0x08, 0x08, 0x30, 0x00, 0x00, // n + 0x10, 0x28, 0x28, 0x10, 0x00, 0x00, // o 80 + 0x38, 0x14, 0x14, 0x08, 0x00, 0x00, // p + 0x08, 0x14, 0x14, 0x38, 0x00, 0x00, // q + 0x3C, 0x08, 0x04, 0x00, 0x00, 0x00, // r + 0x2C, 0x34, 0x00, 0x00, 0x00, 0x00, // s + 0x08, 0x3C, 0x28, 0x00, 0x00, 0x00, // t 85 + 0x18, 0x20, 0x20, 0x18, 0x00, 0x00, // u + 0x08, 0x10, 0x20, 0x10, 0x08, 0x00, // v + 0x18, 0x20, 0x10, 0x20, 0x18, 0x00, // w + 0x28, 0x10, 0x28, 0x00, 0x00, 0x00, // x + 0x2C, 0x30, 0x1C, 0x00, 0x00, 0x00, // y 90 + 0x24, 0x34, 0x2C, 0x24, 0x00, 0x00, // z + 0x00, 0x00, 0x08, 0x3E, 0x22, 0x00, // { + 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, // | + 0x22, 0x3E, 0x08, 0x00, 0x00, 0x00, // } + 0x10, 0x08, 0x18, 0x10, 0x08, 0x00, // ~ 95 +}; + +#endif
diff -r 000000000000 -r 99fdd85b4929 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Jun 14 02:25:52 2014 +0000 @@ -0,0 +1,147 @@ +#include "mbed.h" +#include "NOKIA_5110.h" + +/* +Sketch to use with a Nucleo F401RE and a +Sharp Optical Dust Sensor GP2Y1010AU0F to measure dust with a +Nokia 5110 display to show result. Will also show results via USB on PC terminal program + +NOTE THAT THIS SENSOR USES 5V AND THE NUCLEO 3.3V. USE AT YOUR OWN RISK. +I SHALL NOT BE HELD RESPONSIBLE FOR ANY DAMAGE TO YOUR HARDWARE. + +For non-Nucleo mbed platforms you need to change the pins. + +!!!IMPORTANT!!! +A brief note on the sensor and board voltage !!!IMPORTANT!!! +STM specify in their datasheet (Feb 2014, DocID025644 Rev 2, page 38) that +pin PA1 is "FT" meaning 5V tolerant. Moreover, I have measured voltages of +no more than 3.71V in my experiments. So you should make your own decision +whether and how you want to connect the sensor. Use at your own risk. +I shall not be liable for any damage. + +This sketch is based on code by the following authors: Cyrille Médard de Chardon (serialC), Christophe Trefois (Trefex) +Their work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. +To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter +to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. +Changelog: +2014-Jun-08: Adapted to Nucleo +2014-Jun-13: Added Nokia 5110 display + +Original documentation +http://arduinodev.woofex.net/2012/12/01/standalone-sharp-dust-sensor/ +http://www.howmuchsnow.com/arduino/airquality/ + +The code for the Nokia 5110 is adapted from work by Chris Yan as Revised: January, 2014 + +For the scientifically inclined who are pressed for time there is a nice writeup about dust here: +http://www.who.int/occupational_health/publications/en/oehairbornedust3.pdf + +Pin connections +Sharp dust sensor GP2Y1010AU0F +Data sheet: https://www.sparkfun.com/datasheets/Sensors/gp2y1010au_e.pdf +App note: http://sharp-world.com/products/device/lineup/data/pdf/datasheet/gp2y1010au_appl_e.pdf +Remember to include the resistor and capacitor (polarity!) as described in the Sharp datasheet + Pin 1: Resistor - 5V (see datasheet) + Pin 2: Gnd (capacitor between 1 and 2 - see datasheet) + Pin 3: Digital D8 + Pin 4: Gnd + Pin 5: +5V + Pin 6: Analog A0 + Pins are counted left to right when looking at the connector from the front (i.e. so that you can see the pins) + +5110 Display + myPins.sce = PB_6; + myPins.rst = D2; + myPins.dc = D3; + myPins.mosi = PA_7;//SPI_MOSI; + myPins.miso = NC; + myPins.sclk = PA_5;//SPI_SCK; +I am not using the backlight. Feel free use another digital pin to power it +*/ + +Serial pc(SERIAL_TX, SERIAL_RX); //output for debugging + +DigitalOut myled(LED1); +DigitalOut ledPower(D8); +AnalogIn analog_value(A0); + + +int samplingTime = 280;//280 microseconds +int deltaTime = 40;//40 us to give total pulse width of 0.32ms +int sleepTime = 9680;//LED off for 9680 us to take 1 measurement per second + +float dustDensityCN = 0,dustDensitySharp = 0, voMeasured=0, voCalc=0; + +int main() { + pc.printf("Starting sensor. It can take a few measurements until it becomes stable.\n"); + LcdPins myPins; + myPins.sce = PB_6; + myPins.rst = D2; + myPins.dc = D3; + myPins.mosi = PA_7;//SPI_MOSI; + myPins.miso = NC; + myPins.sclk = PA_5;//SPI_SCK; + pc.printf("LCD pins set ok\n"); + NokiaLcd myLcd( myPins ); + + // Start the LCD + myLcd.InitLcd(); + myLcd.SetXY(char(0),char(0)); + myLcd.DrawString("SHARP DUST SENSOR"); + + pc.printf("LCD started\n"); + + while(1) { + myled = !myled; + ledPower=0; // power on the LED. Pull-down to activate + wait_us(samplingTime); + voMeasured = analog_value.read(); // Converts and read the analog input value + wait_us(deltaTime); + ledPower=1; // turn the LED off. Pull up to turn off + wait_us(sleepTime); + + voCalc = voMeasured*3.3;//Map 0:1 measured range to 0:3.3V + + // Original equation taken from Sharp data sheet measured in mg/m3 + // Sharp don't give you a best fit line, so you have to guess + dustDensitySharp = 0.5/2.8 * (float(voCalc) - 0.7); + + // Eqaution calibrated by Chris Nafis (c) 2012 + // see http://www.howmuchsnow.com/arduino/airquality/ + // measured in parts per 0.01 cf + // [I did not get meaningful values on my sensor with Chris' formula + // For me the Sharp graph works just fine. So make your own tests] + dustDensityCN = (float(voCalc) - 0.0356)*1.2; + + pc.printf(" - Measurment value: %1.3f", voMeasured); + pc.printf(" - Voltage calculated: %1.3f", voCalc); + pc.printf(" - Sharp's Dust Density [mg/m3]: %f", dustDensitySharp); + pc.printf(" - C. Nafis' Dust Density [pp.01cf](x10^4): %f\n", dustDensityCN,"\n"); + + myLcd.SetXY(char(1),char(1)); + myLcd.DrawString("Raw value:"); + char measurestring[(((sizeof voMeasured) * 8) + 2)/3 + 2]; + sprintf(measurestring, "%1.2f", voMeasured); + myLcd.DrawString(measurestring); + + myLcd.SetXY(char(1),char(2)); + myLcd.DrawString("Voltage: "); + char voltagestring[(((sizeof voCalc) * 8) + 2)/3 + 2]; + sprintf(voltagestring, "%1.3f", voCalc); + myLcd.DrawString(voltagestring); + + myLcd.SetXY(char(1),char(3)); + myLcd.DrawString("Sharp dd: "); //Units: refer to printf above + char sharpstring[(((sizeof dustDensitySharp) * 8) + 2)/3 + 2]; + sprintf(sharpstring, "%1.2f", dustDensitySharp); + myLcd.DrawString(sharpstring); + + myLcd.SetXY(char(1),char(4)); + myLcd.DrawString("Nafis dd: "); //Units: refer to printf above + char nafisstring[(((sizeof dustDensityCN) * 8) + 2)/3 + 2]; + sprintf(nafisstring, "%1.2f", dustDensityCN); + myLcd.DrawString(nafisstring); + + wait(1); +} +} \ No newline at end of file
diff -r 000000000000 -r 99fdd85b4929 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Jun 14 02:25:52 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/024bf7f99721 \ No newline at end of file