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
main.cpp
00001 /** 00002 * main.cpp 00003 */ 00004 #include "mbed.h" 00005 #include "ILI9341.h" 00006 #include "Arial28x28.h" 00007 #include "vt100.h" 00008 #include "meter.h" 00009 #include "main.h" 00010 00011 #define ADC_MAX_VALUE 3.28 00012 00013 vt100 *tty = 0 ; 00014 ILI9341 *tft = 0 ; 00015 meter *tacho = 0 ; 00016 00017 DigitalOut *backlight = 0 ; 00018 AnalogIn *vin = 0 ; 00019 00020 float min_value = 0.0 ; 00021 float max_value = 3.3 ; 00022 00023 void initTFT(void) 00024 { 00025 //Configure the display driver 00026 tft->BusEnable(true) ; 00027 tft->FastWindow(true) ; 00028 tft->background(Black); 00029 tft->foreground(White); 00030 wait(0.01) ; 00031 tft->cls(); 00032 tft->BusEnable(false) ; 00033 backlight = new DigitalOut(PIN_BL_TFT, 1) ; 00034 } 00035 00036 void init_hardware(void) 00037 { 00038 tty = new vt100() ; 00039 tty->cls() ; 00040 tft = new ILI9341(SPI_8, 10000000, 00041 PIN_MOSI, PIN_MISO, PIN_SCLK, 00042 PIN_CS_TFT, PIN_RESET_TFT, PIN_DC_TFT, "Adafruit2.8") ; 00043 initTFT() ; 00044 tft->set_font((unsigned char*) Arial28x28); 00045 tft->foreground(White) ; 00046 tacho = new meter(5, 5, 230, 230, 0.0, 3.3) ; 00047 vin = new AnalogIn(PIN_ADC_CH0) ; 00048 *backlight = 1 ; 00049 } 00050 00051 double getRoundedValue(void) 00052 { 00053 double value = 0.0 ; 00054 int intvalue = 0 ; 00055 value = ADC_MAX_VALUE * vin->read() ; 00056 intvalue = (int)(1000.0 * value + 0.5) ; 00057 value = (double)intvalue / 1000.0 ; 00058 return( value ) ; 00059 } 00060 00061 int main() { 00062 float value = 0.0 ; 00063 float prev_value = 0.0 ; 00064 00065 init_hardware() ; 00066 tacho->draw(value) ; 00067 00068 while(1) { 00069 value = getRoundedValue() ; 00070 printf("%.2f\n", value) ; 00071 if (value != prev_value) { 00072 tacho->update(value) ; 00073 prev_value = value ; 00074 } 00075 wait(0.1) ; 00076 } 00077 }
Generated on Wed Jul 13 2022 19:37:46 by
1.7.2