#include "User_Setup.h"
#include <SPI.h>
#include <TFT_eSPI.h>
#include "NotoSansBold15.h"
#include "NotoSansBold36.h"
#include "CourierB24.h"
#include "Unicode_Test_72.h"
// Note: this library doesn't require further configuration
#include <XPT2046_Touchscreen.h>
// Create a TFT_eSPI instance:
TFT_eSPI tft = TFT_eSPI();
#define SCREEN_WIDTH 320//320
#define SCREEN_HEIGHT 480// 240
#define FONT_SIZE 1
TFT_eSprite spr = TFT_eSprite(&tft);
int oldV=-1;
int v;
float vf1;
float vf2;
void setup() {
Serial.begin(115200);
delay(1000);
// Start the tft display
tft.begin();
tft.init();
// Set the TFT display rotation in landscape mode, 1 will flip display 180 degrees
tft.setRotation(3);
// There are 24 predefined colors, see file TFT_eSPI.h in library folder for list of colors
// Can also create your own color by using an RGB hex number, example: 0x0C70
// Use this command to refresh screen by wiping with white or black
tft.fillScreen(0x0C70); // TFT_RED
// There are predefined fonts, see file User_Setup.h in library folder for list of fonts
// Takes up to 2 arguments: (text-color, text-bkg-color)
tft.setTextColor(TFT_BLACK);
// Takes up to 4 arguments: (string, x cord, y cord, text-size)
tft.drawString("Hello Craig", 10, 10); // defalult font used
tft.drawString("Font 1", 10, 20, 1);
tft.setTextColor(TFT_RED);
tft.drawString("Font 2", 10, 30, 2);
tft.setTextColor(TFT_YELLOW);
tft.drawString("Font 4", 10, 50, 4);
tft.drawString("1234", 10, 80, 6); // numbers only
tft.drawString("1234", 10, 120, 7); // numbers only
tft.drawString("1234", 10, 170, 8); // numbers only
tft.setTextColor(TFT_YELLOW, TFT_BLACK);
delay(2000);
tft.fillScreen(TFT_BLACK);
//tft.setTextFont(6);
//tft.loadFont(NotoSansBold15);
//tft.loadFont(CourierB24);
tft.loadFont(Unicode_Test_72);
//spr.loadFont(Unicode_Test_72);
spr.loadFont(NotoSansBold36);
spr.setTextColor(TFT_YELLOW, TFT_BLACK);
spr.createSprite(200, 80);
}
void loop() {
v = analogRead(3);
//for (int i = 0; i < 99; i++) {
if(oldV != v){
vf1= v/10.0;
vf2 = oldV/10.0;
oldV = v;
// Serial.println("New");
// tft.setCursor(80,80);
// tft.setTextColor(TFT_BLACK, TFT_BLACK);
// tft.print(vf2,1);
// //tft.drawString(String(vf2), 80, 80, 8);
// tft.setTextColor(TFT_YELLOW, TFT_BLACK);
// tft.setCursor(80,80);
// tft.print(vf1,1);
spr.fillSprite(TFT_BLACK); // Clear previous
//spr.drawString(String(vf1), 0, 0);
spr.setCursor(0,0);
spr.print(vf1,1);
spr.pushSprite(80, 80); // Push to screen
}
delay(500);
}
Loading
wemos-s2-mini
wemos-s2-mini
Loading
ili9341-cap-touch
ili9341-cap-touch