//Startup options
int Startup_Wizard = 1;
int display_tech = 1; //"1" is I2C lcd, more options coming soon!
/*
Welcome to the Main Arduino UI (for I2C LCD)! This is the part where YOU can take other parts of OUR other code and modify it for yourself! You can debloat by removing functions with the "WHILE" sign! DO NOT REMOVE ANY OTHER FUNCTIONS OR IN THE SETUP FUNCTION!
-Ethan
Version 0.3
*/
//libraries and their startup code
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
LiquidCrystal_I2C lcd(0x27,16,2);
//Apps varaible (DO NOT REMOVE system apps such as "sys_32" and "Error") [When called, the app will run, SET UP a custom app for youself]
int Slideshow = 0;
int Options = 0;
int Clock = 0;
int Error = 0;
int sys_32 = 1; //This is the default startup app! You can change this by making this variable "0" and another app to "1"!
//SDK variables (For lighting and buttons, can be changed )
const int resetMonitorPin = 2; // Pin connected to monitor the reset pin state
int Button1 = 8;
int Button2 = 9;
int YellowLight = 05;
int RedLight = 06;
int GreenLight = 07;
char *AppStrings[] = {"","Slideshow", "Options", "Clock",
" is string 4", "This is string 5", " is string 6"
}; //Leave the first string blank...Prob a bug in the UI
int Total_apps = 06; //Change this by one to allow other apps in (Max of 15 apps if arduino has enough memory!)
int Selected_app = 00; //DO NOT CHANGE THIS
//System variables and strings
char *ErrorMessage[] = {"","Err msg ln 1","Err msg ln 2"};
int Error_line = 1;
char *OptionsStrings[] = {"","1. Scr Timeout","2. Sleep in:"};
char *OptionsSelections[] = {"","< Never >","< 15 sec. >","< 30 sec. >","< 45 sec. >","< 01 min. >","< 05 min. >","< 10 min. >","< 15 min. >"};
int Options_line = 1;
int Options_selection = 1;
//SDK functions(){}
void All_LED_off(){
digitalWrite(RedLight, LOW);
digitalWrite(YellowLight, LOW);
digitalWrite(GreenLight,LOW);
}
void YellowOn(){
digitalWrite(YellowLight,HIGH);
}
void GreenOn(){
digitalWrite(GreenLight,HIGH);
}
void RedOn(){
digitalWrite(RedLight, HIGH);
}
void loading(){
digitalWrite(GreenLight, LOW);
digitalWrite(YellowLight, HIGH);
}
void load_done(){
digitalWrite(YellowLight, LOW);
digitalWrite(GreenLight, HIGH);
}
void clear(){
lcd.setCursor(1, 0);
lcd.print(" ");
lcd.setCursor(1, 1);
lcd.print(" ");
lcd.setCursor(1, 0);
}
void exit_app(){
//Close all apps running below!
Slideshow = 0;
Error = 0;
sys_32 = 1; //make system 32 run again
//For custom apps (you MUST include your app here if you less messy code) for example: mycustomvariable = 0
}
void app_selections(){
All_LED_off();
YellowOn();
clear();
lcd.print("Opening app:");
lcd.setCursor(1, 1);
lcd.print(AppStrings[Selected_app]);
delay(500);
sys_32 = 0;// Action for both buttons pressed
//Add your app in the list below! You may allow the system TOTAL apps to increase FURTHER than 15 by modifying the code here!
if (Selected_app == 1){
Slideshow = 1;
}
else if (Selected_app == 2){
Options = 1;
}
else if (Selected_app == 3){
Clock = 1;
}
else if (Selected_app == 4){
}
else if (Selected_app == 5){
}
else if (Selected_app == 6){
}
else if (Selected_app == 7){
}
else if (Selected_app == 8){
}
else if (Selected_app == 9){
}
else if (Selected_app == 10){
}
else if (Selected_app == 11){
}
else if (Selected_app == 12){
}
else if (Selected_app == 13){
}
else if (Selected_app == 14){
}
else if (Selected_app == 15){
}
else{
//Broadcast a error message that the code DOES NOT include more than 15 apps!
}
}
//System app functions
void start_32() {
// Start the system 32 home screen and monitor crucial items
if(Selected_app < 2){
Selected_app = 1;
}
if(Selected_app >Total_apps){
Selected_app = Total_apps;
}
loading();
clear(); // Clear the LCD screen
lcd.print(AppStrings[Selected_app]);
lcd.setCursor(1, 1); // Move to the second line of the LCD
//Home screen navigation
if (Selected_app < Total_apps) { // If number is below total apps
// Display the Total_apps selected with 'X'
if (Selected_app < 2){
if(Selected_app == Total_apps){
lcd.print("<X App: ");
lcd.print(Selected_app < 10 ? "0" : ""); // Print leading zero for single digits
lcd.print(Selected_app);
lcd.print(" X>");
Selected_app = 1;
}
else{//if number is one or lower
lcd.print("<X App: ");
lcd.print(Selected_app < 10 ? "0" : ""); // Print leading zero for single digits
lcd.print(Selected_app);
lcd.print(" >>");
}
}
else{
// Display the Total_apps selected with 'X'
lcd.print("<< App: ");
lcd.print(Selected_app < 10 ? "0" : ""); // Print leading zero for single digits
lcd.print(Selected_app);
lcd.print(" >>");
}
}
else {
lcd.print("<< App: ");
lcd.print(Selected_app < 10 ? "0" : ""); // Print leading zero for single digits
lcd.print(Selected_app);
lcd.print(" X>");
}
load_done();
}
void background_system(){ //Runs stuff like "Options" to do screentimeout, checks for resets and MORE! You can include "background_system();" into ur code to make things run better!
if (digitalRead(resetMonitorPin) == LOW) {
Serial.println("Reset detected via capacitor!");
}
}
//Main setup code
void setup() {
Serial.begin(9600);
lcd.init();
lcd.backlight();
lcd.clear();
lcd.setCursor(1, 0);
Wire.begin();
Serial.println("");
Serial.println("//Press and hold 2 buttons instead of single press both to enable app WITH debug mode on!");
Serial.println("");
Serial.println("Arduino UI 0.3 -By Ethan");
Serial.println("");
Serial.println("");
Serial.println("App list:");
Serial.println("1. Slideshow");
Serial.println("2. Options");
Serial.println("3. Clock");
Serial.println("");
Serial.println("");
Serial.println("Systems apps:");
Serial.println("1. Error");
Serial.println("2. Sys_32");
clear();
pinMode(Button1,INPUT);
pinMode(Button2,INPUT);
pinMode(GreenLight,OUTPUT);
pinMode(YellowLight,OUTPUT);
pinMode(RedLight,OUTPUT);
pinMode(resetMonitorPin, INPUT_PULLUP); // Enable pull-up resistor
digitalWrite(YellowLight, HIGH);
digitalWrite(RedLight, HIGH);
digitalWrite(GreenLight, HIGH);
delay(100);
lcd.setCursor(1,0);
lcd.print("Arduino UI");
lcd.setCursor(1,1);
lcd.print("Ver. 0.3 -Ethan");
delay(500);
digitalWrite(RedLight, LOW);
digitalWrite(GreenLight, LOW);
delay(500);
}
//Apps (You can create custom too BUT you have to add and MODIFY quite a bit of code in the "void loop")
/*
Here is an example: (Make a varible on top too for your custom app!)
if(customappvariable == 1){
//This is the one time set up section!
while(customappvariable == 1){ //While the app is looped
//Loops below until app exits!
if(digitalRead(Button1 == LOW)){
//When button1 is clicked
if(digitalRead(Button2 == LOW)){
customappvariable = 0; //Set your app to NOT run to exit!
exit(); //SDK exit app function!
}
else if(digitalRead(Button2 == LOW)){
//When button2 is clicked
if(digitalRead(Button1 == LOW)){
customappvariable = 0; //Set your app to NOT run to exit!
exit(); //SDK exit app function!
}
}
else{
[Normal app functions when no button pressed]
}
}
}
[You may use and modify OUR app code to your liking ;)]
*/
void loop() {
//System app: "Sys_32" Notes: Do not delete THIS or ANY OTHER SYSTEM APP! Keep me on top!
if(sys_32 == 1){
clear();
load_done();
if(Selected_app == 0){
lcd.setCursor(1,0);
lcd.print("Choose your app");
lcd.setCursor(1,1);
lcd.print("Input needed!");
}
while (sys_32 == 1) {
background_system();
// Loops below until the app exits!
if (digitalRead(Button1) == 0) {
delay(100);
// Check if Button2 is also pressed
if (digitalRead(Button2) == LOW) {
app_selections();
//method to open another app!
// Action for both buttons pressed
}
else{
// Button1 clicked
if (Selected_app == 0) {
start_32();
}
else{
Selected_app++;
start_32();
}
}
delay(100);
}
if (digitalRead(Button2) == 0) {
delay(200);
// Check if Button1 is also pressed
if (digitalRead(Button1) == LOW) {
app_selections();
}
else{
// Button2 clicked
if (Selected_app == 0) {
start_32();
}
else{
Selected_app--;
start_32();
}
}
delay(100);
}
}
}
//Function app: "Slideshow"
else if(Slideshow == 1){
lcd.setCursor(1,0); //Set cursor to character 1 on line 0
lcd.print("TypeToTxt...");
lcd.setCursor(1,1); //Move cursor to character 1 on line 1
lcd.print("Version 0.2");
delay(500);
clear();
load_done();
lcd.print("Type to begin!");
while(Slideshow == 1){
if(digitalRead(Button1) == LOW){
delay(100);
if(digitalRead(Button2) == LOW){
exit_app();
}
delay(100);
}
else{
clear();
lcd.print("Type to begin!");
}
if(digitalRead(Button2) == LOW){
delay(100);
if (digitalRead(Button1) == LOW){
exit_app();
}
else{
clear();
lcd.print("Type to begin!");
}
delay(100);
}
else{
if (Serial.available() > 0) {
loading();
clear();
String str = Serial.readString();
str.trim();
Serial.println( "'"+str+"' has been printed!");
clear();
lcd.print(str);
load_done();
}
}
}
}
//Function app: "Options" Notes: Function app options lets you change setting like the sreen timeout, and more
else if(Options == 1){
clear();
lcd.print("Options");
lcd.setCursor(1,1);
lcd.print("Version 0.1");
delay(250);
clear();
lcd.print("Tips: Click 2 bt");
lcd.setCursor(1,1);
lcd.print("change setting");
delay(250);
load_done();
clear();
while (Options == 1){
//No function to loop in error (Uses blank statement) [If you are a random person sampling this app, pls...add a way to exit your app! It is as simple as exit();]
;
}
}
//Function app: "Clock"
else if(Clock == 1){
Clock = 0; //Since the app ain't ready, its disabled!
}
//System app: "Error" Notes: ALWAYS KEEP THIS APP AT THE BOTTOMMOST!
else{
clear();
All_LED_off();
RedOn();
lcd.setCursor(1,0);
lcd.print("Error operating");
lcd.setCursor(1,1);
lcd.print("App not found");
delay(2000);
clear();
lcd.setCursor(1,0);
lcd.print("Please click");
lcd.setCursor(1,1);
lcd.print("The reset btn!");
Error = 1;
while (Error == 1){
//No function to loop in error (Uses blank statement) [If you are a random person sampling this app, pls...add a way to exit your app! It is as simple as exit();]
;
}
}
}