Files
NV3030B-display-test/nv3030b-graphicstest.ino

73 lines
2.1 KiB
C++

/***************************************************
This is our GFX example for the Adafruit ILI9341 Breakout and Shield
----> http://www.adafruit.com/products/1651
Check out the links above for our tutorials and wiring diagrams
These displays use SPI to communicate, 4 or 5 pins are required to
interface (RST is optional)
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
MIT license, all text above must be included in any redistribution
****************************************************/
#include "SPI.h"
#include "Adafruit_GFX.h" // https://learn.adafruit.com/adafruit-gfx-graphics-library
#include "Adafruit_NV3030B.h"
#include <Fonts/FreeSerifBold18pt7b.h>
// For the Adafruit shield, these are the default.
#define TFT_DC 8
#define TFT_CS 17
#define TFT_MOSI 19
#define TFT_CLK 18
#define TFT_RST 12
#define TFT_MISO 16
#define TFT_BACKLIGHT 13
// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
// Adafruit_NV3030B tft = Adafruit_NV3030B(TFT_CS, TFT_DC);
// If using the breakout, change pins as desired
Adafruit_NV3030B tft = Adafruit_NV3030B(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
int moisture = 0;
int position = 0;
GFXcanvas1 canvas(240, 280); // 1-bit, 120x30 pixels
void setup() {
Serial.begin(9600);
Serial.println("NV3030B Test!");
pinMode(TFT_BACKLIGHT, OUTPUT);
digitalWrite(TFT_BACKLIGHT, HIGH);
tft.begin();
tft.fillScreen(NV3030B_BLACK);
canvas.setFont(&FreeSerifBold18pt7b); // Use custom font
canvas.setTextWrap(false);
}
void setup1(){
}
void loop(void) {
//canvas.fillScreen(0); // Clear canvas (not display)
tft.drawCircle(120, 140, position, NV3030B_BLACK);
position = moisture / 25;
//canvas.drawCircle(120, 140, position, NV3030B_BLUE);
//tft.drawBitmap(0, 0, canvas.getBuffer(), canvas.width(), canvas.height(), 0xFFFF, 0x0000);
tft.drawCircle(120, 140, position, NV3030B_BLUE);
//Serial.println(position);
}
void loop1(){
moisture = analogRead(A0);
}