cely program v přiloze neni ...zde je :
//
https://blog.startingelectronics.com/ho ... ial-ports/
//
https://www.arduino.cc/reference/en/lan ... nalogread/
#define LB_MODE_3 (0xFC)// uzamceni !!!!!!!!!!!!!!!!!!!!!!!!!!!!
#include "Adafruit_GFX.h"
#include "MCUFRIEND_kbv.h"
//MCUFRIEND_kbv tft;
#include "Fonts/FreeSans9pt7b.h"
#include "Fonts/FreeSans12pt7b.h"
#include "Fonts/FreeSerif12pt7b.h"
#include "FreeDefaultFonts.h"
//----------------------------------------------------------------------------------------
#define BLACK 0x0000 /* 0, 0, 0 */
#define DARKGREEN 0x03E0 /* 0, 128, 0 */
#define BLUE 0x001F /* 0, 0, 255 */
#define GREEN 0x07E0 /* 0, 255, 0 */
#define RED 0xF800 /* 255, 0, 0 */
#define MAGENTA 0xF81F /* 255, 0, 255 */
#define YELLOW 0xFFE0 /* 255, 255, 0 */
#define WHITE 0xFFFF /* 255, 255, 255 */
#define GREENYELLOW 0xAFE5 /* 173, 255, 47 */
//----------------------------------------------------------------------------------------
int i=0;
int t = 0; // pocet tlaků
int z;
int n=101; // hodnota pro graf osy x = pocatek sloupce
int a;
int f;
int b;
int k = 0; // citac sloupcu
int w=0; // citac vsech tlaku
//int analogPin = A8; // potentiometer wiper (middle terminal) connected to analog pin 3
//int val = 0; // variable to store the value read
int senzor = A8;
int x = 0;
int trimr1 = A9;
int y = 0;
int x1 = 0;
int x2 = 0;
int x3 = 0;
int x4 = 0;
int x5 = 0;
//=========================================================================================
void showmsgXY(int x, int y, int sz, const GFXfont *f, const char *msg)
{
int16_t x1, y1;
uint16_t wid, ht;
tft.setFont(f);
tft.setCursor(x, y);
tft.setTextColor(0x0000); //BÍLÁ
//tft.setTextColor(0x001F); //BLUE 0x001F...INVERT ....ŽLUTÁ..Color of the Screen
tft.setTextSize(sz);
tft.print(msg);
}
//---------------------------------------------------------------------------------------
void setup() {
tft.reset();
uint16_t ID = tft.readID();
tft.begin(ID);
tft.setRotation(1);
tft.invertDisplay(true);
tft.fillScreen(0xffff);
showmsgXY(29,60,2, &FreeSans9pt7b, "PRESS ON TAMPER in Kg"); // souradnice X(0-480) ,Y(0-380) , velikost pismene(1 , 2, 3)
//showmsgXY(20,290,1, &FreeSans9pt7b, "RANGE OF 20 METERS AND THE NEED FOR ON ...");
//showmsgXY(80,310,1, &FreeSans9pt7b, "CHARGED ACCU - YOUR HEAVY TAMPER");
showmsgXY(8,290,1, &FreeSans9pt7b, "NENI-LI NULA NUTNO RESET or OPRAVIT SENZOR !");
showmsgXY(8,310,1, &FreeSans9pt7b, "30 PROF.KONSTANTA PRO TESTY MECHANIKY ");
//=========graf=====================================================================================
showmsgXY(70,180,1, &FreeSans9pt7b, "20"); // souradnice X(0-480) ,Y(0-380) , velikost pismene(1 , 2, 3)
showmsgXY(70,195,1, &FreeSans9pt7b, "15"); // souradnice X(0-480) ,Y(0-380) , velikost pismene(1 , 2, 3)
showmsgXY(70,210,1, &FreeSans9pt7b, "10"); // souradnice X(0-480) ,Y(0-380) , velikost pismene(1 , 2, 3)
showmsgXY(70,225,1, &FreeSans9pt7b, "5"); // souradnice X(0-480) ,Y(0-380) , velikost pismene(1 , 2, 3)
showmsgXY(70,240,1, &FreeSans9pt7b, "0"); // souradnice X(0-480) ,Y(0-380) , velikost pismene(1 , 2, 3)
//for (uint16_t a=0; a<450; a++)
//{ tft.drawFastVLine(x+a, y, h, t);} //která začíná v místě x a y, a délka je h pixel a barva t.
for (uint16_t a=0; a<350; a++)
{ tft.drawFastVLine(100+a, 235, 1, 1);} //která začíná v místě x a y, a délka je h pixel a barva t.
//for (uint16_t a=0; a<200; a++)
//{ tft.drawFastHLine(x, y-a, w, t);} //která začíná v místě x a y, a délka je w pixel a barva t.
for (uint16_t a=0; a<60; a++)
{ tft.drawFastHLine(100, 235-a, 1, 1);} //která začíná v místě x a y, a délka je w pixel a barva t.
//=========================================MAZANI=========================================================
if (k > 12){
for (uint16_t b=1; b<71; b++)
{
for (uint16_t a=0; a<60; a++)
{ tft.drawFastHLine(101, 235-b, 351, 65535);} //která začíná v místě x a y, a délka je w pixel a barva t.
}
}
//=========================================MAZANI KONEC=========================================================
showmsgXY(200,150,1, &FreeSans9pt7b, " "); //VELIKOST
tft.setTextColor(BLACK);
tft.setCursor(20,100);
tft.print("Kalibrace = ");delay(1500);
x = analogRead(senzor);x5=x5+x;delay(10);
x = analogRead(senzor);x5=x5+x;delay(10);
x = analogRead(senzor);x5=x5+x;delay(10);
x = analogRead(senzor);x5=x5+x;delay(10);
x = analogRead(senzor);x5=x5+x;delay(10);
x = analogRead(senzor);x5=x5+x;delay(10);
x = analogRead(senzor);x5=x5+x;delay(10);
x = analogRead(senzor);x5=x5+x;delay(10);
x = analogRead(senzor);x5=x5+x;delay(10);
x5=(x5/9);tft.print(x5);
Serial.begin(115200); // setup serial
}
//===========================================HLAVNI PROGRAM ===============================================================
void loop() {
x = analogRead(senzor);
Serial.println(x);
x1=x;
showmsgXY(200,150,1, &FreeSans9pt7b, " "); //VELIKOST
tft.setTextColor(BLACK);
tft.setCursor(20,130);
tft.print(x1);tft.print(" = Detektor");
//==========================================vazici program=================================
x = (x5-x)/10;// 10= konstanta lehka ,15= konstanta tezka , 20 = realna konstanta
x = abs(x);x2=x;
//============================================zobrazení===================================
showmsgXY(200,150,5, &FreeSans9pt7b, " "); //VELIKOST
tft.setTextColor(BLACK);
tft.setCursor(200,150);
tft.print(x);
delay (300);
showmsgXY(200,150,5, &FreeSans9pt7b, " "); //VELIKOST
tft.setTextColor(WHITE);// mazani predesle hodnoty=WHITE...mazani
tft.setCursor(200,150);
tft.print(x);
//-------------------------detektor------------------------------------------------
showmsgXY(200,150,1, &FreeSans9pt7b, " "); //VELIKOST
tft.setTextColor(WHITE);
tft.setCursor(20,130);
tft.print(x1);
}
//====================================konec ====================================================================