Hi all
Well after a short break am back to trying to sort this problem out.
Here is the new code that i have been trying, the attanSwitch
part has not been tested yet, will deal with that later.
i also have a short video of the display showing the pulsing\flickering
if i can work out how to send it lol.
Thanks for looking
Howard
[code]
#include <Wire.h>
#include <EEPROM.h>
#include <TFT_HX8357.h> // Hardware-specific library
TFT_HX8357 tft = TFT_HX8357(); // Invoke custom library
#include "z_Free_Fonts.h" // Include the header file attached to this sketch
//#define TFT_GREY1 0x8410 // New colour // HERE WE CORRECT THE GRAY COLOR !!!!! 11 0x8410 - GREEN LABEL 0x39E7 - YELLOW LABEL
int audioSwitch = A11; // set up a constant for the Audio Filter switch
int audioSwitchState = 0; // variable to hold the value of the switchPin
int prevaudioSwitchState = 0; // variable to hold previous value of the switchpin
int audioSwitchCounter = 0; // counter for the number of button presses //audiobuttonPushCounter
//int attanSwitch = ; // set up a constant for the Audio Filter switch
//int attanSwitchState = 0; // variable to hold the value of the switchPin
//int prevattanSwitchState = 0; // variable to hold previous value of the switchpin
//int attanSwitchCounter = 0; // counter for the number of button presses //audiobuttonPushCounter
void setup() { // PUT YOUR SETUP CODE HERE, TO RUN ONCE:
delay (100);
Wire.begin();
//***************** display setting ************************
tft.init();
tft.setRotation(1); //3// 1 WORKS
tft.fillScreen(0x0000); // erase everything
//**************** PERMANENT INFO DISPLAY PROGRAM ****************
tft.fillScreen(TFT_BLACK);
//tft.fillRect(225, 108, 50, 23, TFT_GREY1); // стираем старое x y width hight //(355, 117, 90, 23, TFT_BLACK)
tft.setTextColor(TFT_WHITE );
//tft.setFreeFont(FF6);
tft.setFreeFont(FF41);//6
//tft.fillRoundRect(72, 45, 55, 23, 5, TFT_WHITE);tft.setCursor(80, 62, 1);tft.println("ATT");
//tft.fillRoundRect(72, 45, 55, 23, 5, TFT_GREY1);tft.setCursor(80, 62, 1);tft.println("ATT");
//************************************************************
tft.setCursor(300, 139, 1); // 285, 139, 1 //152, 150, 1 //
tft.println("MODE"); //
//tft.setCursor(60, 17, 1);
tft.setCursor(300, 106, 1); //292, 106, 1
tft.println("RIT ");
tft.setCursor(152, 125, 1);
tft.setFreeFont(FF41);
tft.setTextColor(TFT_WHITE );
tft.println("AUDIO");
tft.setFreeFont(FF41); // 21
tft.setCursor(10, 182, 1);
tft.println("VCC - V");
//tft.setFreeFont(FF26);//6
tft.drawRoundRect(140, 15, 334, 143, 5,TFT_BLUE ); // x,y,width,high,radius,color, rectangle A
//********* Setup Inputs And Outputs ************
pinMode(audioSwitch,INPUT); // set up the switch pin as an input [ INPUT_PULLUP ]
digitalWrite(audioSwitch,HIGH); // turn on pullup resistor
pinMode(A12, OUTPUT); // Initiates off pin
pinMode(A13, OUTPUT); // Initiates 1.5Khz pin
pinMode(A14, OUTPUT); // Initiates 2.0Khz pin
pinMode(A15, OUTPUT); // Initiates 2.5Khz pin
//pinMode(attanSwitch,INPUT); // set up the switch pin as an input [ INPUT_PULLUP ]
//digitalWrite(attanSwitch,HIGH); // turn on pullup resistor
//pinMode(A12, OUTPUT); // Initiates off pin
//pinMode(A13, OUTPUT); // Initiates 10dB pin
//pinMode(A14, OUTPUT); // Initiates 20dB pin
//pinMode(A15, OUTPUT); // Initiates 30dB pin
}
void loop() { // PUT YOUR MAIN CODE HERE, TO RUN REPEATEDLY:
audioSwitchState = digitalRead(audioSwitch); // check the status of the switch
if (audioSwitchState != prevaudioSwitchState) // compare the switchState to its previous state
{
if (audioSwitchState == LOW) // If the switch is pressed, count the press
{
audioSwitchCounter ++;
audioSwitchCounter %= 4;
}
}
switch (audioSwitchCounter)
{
case 0: // Off
tft.fillRoundRect(225, 108, 60, 23, 5, TFT_WHITE);tft.setCursor(230, 125, 1);tft.println(" OFF");
tft.fillRoundRect(225, 108, 60, 23, 5, TFT_BLACK);tft.setCursor(230, 125, 1);tft.println(" OFF");
//tft.setCursor(230, 125, 1); // SetCursor(230, 125, 1);
//tft.setTextColor(TFT_WHITE); // Set up text color
//tft.setFreeFont(FF41); // Set up Font Size
//tft.println("OFF"); // print to display ("OFF")
//tft.setTextColor(TFT_BLACK);
//tft.setFreeFont(FF41);
//tft.setCursor(230, 125, 1);
//tft.println("OFF"); // print to display ("OFF")
digitalWrite(A12, HIGH); // Output on
digitalWrite(A13, LOW); // Output off
digitalWrite(A14, LOW); // Output off
digitalWrite(A15, LOW); // Output off
break;
case 1: // 1.5Khz
tft.fillRoundRect(225, 108, 60, 23, 5, TFT_WHITE);tft.setCursor(230, 125, 1);tft.println("1.5Khz");
tft.fillRoundRect(225, 108, 60, 23, 5, TFT_BLACK);tft.setCursor(230, 125, 1);tft.println("1.5Khz");
//tft.setCursor(230, 125, 1); // SetCursor(0, 0);
//tft.setTextColor(TFT_WHITE); // Set up text color
//tft.setFreeFont(FF41); // Set up Font Size
//tft.println("1.5K"); // print to display ("1.5K")
//tft.setTextColor(TFT_BLACK);
//tft.setFreeFont(FF41);
//tft.setCursor(230, 125, 1);
//tft.println("1.5K"); // print to display ("1.5K")
//tft.fillRect(225, 108, 75, 33, TFT_BLACK); //225, 108, 48, 23, TFT_BLACK
digitalWrite(A12, LOW); // Output off
digitalWrite(A13, HIGH); // Output on
digitalWrite(A14, LOW); // Output off
digitalWrite(A15, LOW); // Output off
break;
case 2: // 2.0Khz
tft.fillRoundRect(225, 108, 60, 23, 5, TFT_WHITE);tft.setCursor(230, 125, 1);tft.println("2.0Khz");
tft.fillRoundRect(225, 108, 60, 23, 5, TFT_BLACK);tft.setCursor(230, 125, 1);tft.println("2.0Khz");
//tft.setCursor(230, 125, 1); // SetCursor(0, 0);
//tft.setTextColor(TFT_WHITE); // Set up text color
//tft.setFreeFont(FF41); // Set up Font Size
//tft.println("2.0K"); // print to display ("2.0K")
//tft.setTextColor(TFT_BLACK);
//tft.setFreeFont(FF41);
//tft.setCursor(230, 125, 1);
//tft.println("2.0K"); // print to display ("2.0K")
digitalWrite(A12, LOW); // Output off
digitalWrite(A13, LOW); // Output off
digitalWrite(A14, HIGH); // Output on
digitalWrite(A15, LOW); // Output off
break;
case 3: // 2.5Khz
tft.fillRoundRect(225, 108, 60, 23, 5, TFT_WHITE);tft.setCursor(230, 125, 1);tft.println("2.5Khz");
tft.fillRoundRect(225, 108, 60, 23, 5, TFT_BLACK);tft.setCursor(230, 125, 1);tft.println("2.5Khz");
//tft.setCursor(230, 125, 1); // SetCursor(0, 0);
//tft.setTextColor(TFT_WHITE); // Set up text color
//tft.setFreeFont(FF41); // Set up Font Size
//tft.println("2.5K"); // print to display ("2.5K")
//tft.setTextColor(TFT_BLACK);
//tft.setFreeFont(FF41);
//tft.setCursor(230, 125, 1);
//tft.println("2.5K"); // print to display ("2.5K")
digitalWrite(A12, LOW); // Output off
digitalWrite(A13, LOW); // Output off
digitalWrite(A14, LOW); // Output off
digitalWrite(A15, HIGH); // Output on
break;
}
prevaudioSwitchState = audioSwitchState; // save the current switch state as the last state
//attanSwitchState = digitalRead(attanSwitch); // check the status of the switch
//if (attanSwitchState != prevattanSwitchState) // compare the switchState to its previous state
//{
//if (attanSwitchState == LOW) // If the switch is pressed, count the press
//{
//attanSwitchCounter ++;
//attanSwitchCounter %= 4;
//}
//}
//switch (attanSwitchCounter)
//{
//case 0: // Off
//tft.fillRoundRect(225, 108, 50, 23, 5, TFT_WHITE);tft.setCursor(230, 125, 1);tft.println("OFF");
//tft.fillRoundRect(225, 108, 50, 23, 5, TFT_BLACK);tft.setCursor(230, 125, 1);tft.println("OFF");
//digitalWrite(A12, HIGH); // Output on
//digitalWrite(A13, LOW); // Output off
//digitalWrite(A14, LOW); // Output off
//digitalWrite(A15, LOW); // Output off
//break;
//case 1: //10dB
//tft.fillRoundRect(225, 108, 50, 23, 5, TFT_WHITE);tft.setCursor(230, 125, 1);tft.println("10dB");
//tft.fillRoundRect(225, 108, 50, 23, 5, TFT_BLACK);tft.setCursor(230, 125, 1);tft.println("10dB");
//digitalWrite(A12, LOW); // Output off
//digitalWrite(A13, HIGH); // Output on
//digitalWrite(A14, LOW); // Output off
//digitalWrite(A15, LOW); // Output off
//break;
//case 2: //20dB
//tft.fillRoundRect(225, 108, 50, 23, 5, TFT_WHITE);tft.setCursor(230, 125, 1);tft.println("20dB");
//tft.fillRoundRect(225, 108, 50, 23, 5, TFT_BLACK);tft.setCursor(230, 125, 1);tft.println("20dB");
//digitalWrite(A12, LOW); // Output off
//digitalWrite(A13, LOW); // Output off
//digitalWrite(A14, HIGH); // Output on
//digitalWrite(A15, LOW); // Output off
//break;
//case 3: //30dB
//tft.fillRoundRect(225, 108, 50, 23, 5, TFT_WHITE);tft.setCursor(230, 125, 1);tft.println("30dB");
//tft.fillRoundRect(225, 108, 50, 23, 5, TFT_BLACK);tft.setCursor(230, 125, 1);tft.println("30dB");
//digitalWrite(A12, LOW); // Output off
//digitalWrite(A13, LOW); // Output off
//digitalWrite(A14, LOW); // Output off
//digitalWrite(A15, HIGH); // Output on
//break;
//}
//prevattanSwitchState = attanSwitchState; // save the current switch state as the last state
}
[/code]