Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SPI_STMPE610 UniGraphic mbed vt100
Diff: main.cpp
- Revision:
- 3:bf8761c8eb17
- Parent:
- 0:d01def9cf41e
- Child:
- 4:0607a2a46238
diff -r 204e60dbd73d -r bf8761c8eb17 main.cpp
--- a/main.cpp Fri Jul 21 01:24:53 2017 +0000
+++ b/main.cpp Fri Jul 21 02:01:05 2017 +0000
@@ -1,20 +1,19 @@
+/**
+ * main.cpp
+ */
#include "mbed.h"
#include "ILI9341.h"
-#include "Arial12x12.h"
-#include "Arial24x23.h"
#include "Arial28x28.h"
-#include "Arial43x48_numb.h"
-#include "SPI_STMPE610.h"
#include "vt100.h"
#include "meter.h"
#include "main.h"
+#define ADC_MAX_VALUE 3.28
+
vt100 *tty = 0 ;
ILI9341 *tft = 0 ;
-SPI_STMPE610 *tsc = 0 ;
meter *tacho = 0 ;
-DigitalOut myled(LED1, 1);
DigitalOut *backlight = 0 ;
AnalogIn *vin = 0 ;
@@ -39,34 +38,39 @@
tty = new vt100() ;
tty->cls() ;
tft = new ILI9341(SPI_8, 10000000,
- PIN_MOSI, PIN_MISO, PIN_SCLK,
- PIN_CS_TFT, PIN_RESET_TFT, PIN_DC_TFT, "Adafruit2.8") ;
+ PIN_MOSI, PIN_MISO, PIN_SCLK,
+ PIN_CS_TFT, PIN_RESET_TFT, PIN_DC_TFT, "Adafruit2.8") ;
initTFT() ;
tft->set_font((unsigned char*) Arial28x28);
tft->foreground(White) ;
-// tsc = new SPI_STMPE610(PIN_MOSI, PIN_MISO, PIN_SCLK, PIN_CS_TSC) ;
tacho = new meter(5, 5, 230, 230, 0.0, 3.3) ;
vin = new AnalogIn(PIN_ADC_CH0) ;
+ *backlight = 1 ;
+}
+
+double getRoundedValue(void)
+{
+ double value = 0.0 ;
+ int intvalue = 0 ;
+ value = ADC_MAX_VALUE * vin->read() ;
+ intvalue = (int)(100.0 * value + 0.5) ;
+ value = (double)intvalue / 100.0 ;
+ return( value ) ;
}
int main() {
float value = 0.0 ;
float prev_value = 0.0 ;
- int intvalue = 0 ;
+
init_hardware() ;
- *backlight = 1 ;
-
- tacho->drawFrame() ;
- tacho->drawScale() ;
+ tacho->draw(value) ;
+
while(1) {
- value = 3.28 * vin->read() ;
- intvalue = (int)(100.0 * value + 0.5) ;
- value = (double)intvalue / 100.0 ;
+ value = getRoundedValue() ;
if (value != prev_value) {
- tacho->drawHand(value) ;
- tacho->drawValue(value) ;
+ tacho->update(value) ;
prev_value = value ;
}
- wait(0.2) ;
+ wait(0.1) ;
}
}