Created
March 28, 2017 05:14
-
-
Save linuxsable/3a8e8bf616c3e77457cfd3b9a52a8582 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "SPI.h" | |
#include "Adafruit_GFX.h" | |
#include "Adafruit_ILI9341.h" | |
// For the Adafruit shield, these are the default. | |
#define TFT_DC 9 | |
#define TFT_CS 10 | |
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC); | |
const int CV = 6; | |
const int CV_ON = 255; | |
const int CV_OFF = 0; | |
const int DELAY = 2000; | |
void setup() { | |
pinMode(CV, OUTPUT); | |
randomSeed(analogRead(0)); | |
tft.begin(); | |
uint8_t x = tft.readcommand8(ILI9341_RDMODE); | |
x = tft.readcommand8(ILI9341_RDMADCTL); | |
x = tft.readcommand8(ILI9341_RDPIXFMT); | |
x = tft.readcommand8(ILI9341_RDIMGFMT); | |
x = tft.readcommand8(ILI9341_RDSELFDIAG); | |
showText("Booting up"); | |
} | |
void loop() { | |
triggerRand(); | |
delay(DELAY); | |
triggerOff(); | |
delay(DELAY); | |
} | |
void triggerRand() { | |
int randValue = random(255); | |
analogWrite(CV, randValue); | |
showText("Trigger: " + String(randValue)); | |
} | |
void triggerOn() { | |
analogWrite(CV, CV_ON); | |
showText("Trigger: ON"); | |
} | |
void triggerOff() { | |
analogWrite(CV, CV_OFF); | |
showText("Trigger: OFF"); | |
} | |
unsigned long showText(String msg) { | |
tft.fillScreen(ILI9341_BLACK); | |
unsigned long start = micros(); | |
tft.setCursor(0, 0); | |
tft.setTextColor(ILI9341_WHITE); | |
tft.setTextSize(3); | |
tft.println(msg); | |
return micros() - start; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment