/*
Copyright (c) 2022-present ArduinoOS, NokoDev
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include <LiquidCrystal_I2C.h>
#define TFT_DC 9
#define TFT_CS 10
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 20, 4);
int x = 0;
int prev_voltage = 0;
void printf_tft(char text[], uint16_t color){
print_tft(text, color);
x = x + 8;
}
void print_tft(char text[], uint16_t color){
tft.setCursor(0, x);
tft.setRotation(1);
tft.setTextColor(color);
tft.println(text);
}
void print_slashn(){
printf_tft("", ILI9341_WHITE);
}
void setup() {
tft.begin();
tft.setTextSize(1);
printf_tft("Copyright (c) 2022-present ArdruinoOS, NokoDev", ILI9341_WHITE);
printf_tft("(c) 2022 ArdruinoOS. All rights reserved.", ILI9341_WHITE);
print_slashn();
printf_tft("Due to limitations. it currently dosen't support in", ILI9341_WHITE);
printf_tft("the display. The input is on a LCD Display. This will", ILI9341_WHITE);
printf_tft("be changed in the future.", ILI9341_WHITE);
lcd.init();
lcd.backlight();
int newvolt = (analogRead("A0") * 5.0);
lcd.clear();
lcd.print("Voltage: ");
lcd.print(newvolt);
prev_voltage = newvolt;
}
void loop() {
if(prev_voltage != (analogRead("A0") * 5.0)){
int newvolt = (analogRead("A0") * 5.0);
lcd.clear();
lcd.print("Millivolts : ");
lcd.print(newvolt);
prev_voltage = newvolt;
}
}