tom321
59
#include <Adafruit_GFX.h>
#include <Adafruit_ST7789.h>
#include <SPI.h>
#define TFT_MOSI 23 // Data out
#define TFT_SCLK 18 // Clock out
#define TFT_CS 22//
#define TFT_DC 21 //
#define TFT_RST -1 // pin# 2
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
int Hz;
int currentHz;
int previousHz ;
void setup()
{
tft.init(170, 320); // high, with
tft.setRotation(3); // Adjust rotation as needed (0-3),0 = viertical, 1= horyzontal upside down, 2= viertical 180 deg , 3=horyzontal normal,
tft.fillScreen(ST77XX_BLUE);
tft.setTextWrap(false); // Disable text wrapping
tft.setTextSize(4); // Set text size
pinMode(12, INPUT_PULLUP); //amp ++
pinMode(14, INPUT_PULLUP); // amp --
pinMode(2, INPUT_PULLUP);
}
void loop() {
if (digitalRead(12) == LOW)
{
Hz++;
}
if (digitalRead(14) == LOW)
{
Hz--;
}
currentHz = Hz;
if ( previousHz != currentHz )
{
tft.setCursor(0, 0);
tft.setTextColor(ST77XX_BLUE); // background color
tft.print("Hz = ");
tft.print( previousHz );
tft.setCursor(0, 0);
tft.setTextColor(ST77XX_YELLOW);
tft.print("Hz = ");
tft.print( currentHz);
previousHz = currentHz;
}
delay(300);
}