A simple meter using Adafruit 2.8 TFT with touch v2
Dependencies: SPI_STMPE610 UniGraphic mbed vt100
A dumb simple voltage tester using ADC.
With FRDM-KL25Z, you can measure about 0V to 3.28V.
Nothing to drop your jaw nor holding your breath
but I wanted one, so I wrote one ;-)
とても単純はADCを使用した電圧テスターです。
FRDM-KL25Z を使用した場合、0V ~ 3.28V くらいが測定範囲です。
特に目新しいことも、驚くこともありませんが、
自分が欲しいので書いてみました (^ - ^)
On 18-May-2018
I changed the number display from 0.00 to 0.000
so that I can measure the change of a small loadcell.
2018年5月18日
ロードセル (重量センサ)の出力値の変化を見たかったので
有効数字を小数点以下2桁から3桁に変更しました。
Diff: main.cpp
- Revision:
- 0:d01def9cf41e
- Child:
- 3:bf8761c8eb17
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Jul 20 02:37:13 2017 +0000
@@ -0,0 +1,72 @@
+#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"
+
+vt100 *tty = 0 ;
+ILI9341 *tft = 0 ;
+SPI_STMPE610 *tsc = 0 ;
+meter *tacho = 0 ;
+
+DigitalOut myled(LED1, 1);
+DigitalOut *backlight = 0 ;
+AnalogIn *vin = 0 ;
+
+float min_value = 0.0 ;
+float max_value = 3.3 ;
+
+void initTFT(void)
+{
+ //Configure the display driver
+ tft->BusEnable(true) ;
+ tft->FastWindow(true) ;
+ tft->background(Black);
+ tft->foreground(White);
+ wait(0.01) ;
+ tft->cls();
+ tft->BusEnable(false) ;
+ backlight = new DigitalOut(PIN_BL_TFT, 1) ;
+}
+
+void init_hardware(void)
+{
+ 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") ;
+ 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) ;
+}
+
+int main() {
+ float value = 0.0 ;
+ float prev_value = 0.0 ;
+ int intvalue = 0 ;
+ init_hardware() ;
+ *backlight = 1 ;
+
+ tacho->drawFrame() ;
+ tacho->drawScale() ;
+ while(1) {
+ value = 3.28 * vin->read() ;
+ intvalue = (int)(100.0 * value + 0.5) ;
+ value = (double)intvalue / 100.0 ;
+ if (value != prev_value) {
+ tacho->drawHand(value) ;
+ tacho->drawValue(value) ;
+ prev_value = value ;
+ }
+ wait(0.2) ;
+ }
+}