#include #include "Ucglib.h" #include Ucglib_ILI9341_18x240x320_SWSPI ucg(/*sclk=*/ 8, /*data=*/ 10, /*cd=*/ A0, /*cs=*/ A2, /*reset=*/ 5); bool startFlag = 0; String exposureType = ""; int powerLevel = 0; int exposureTime = 0; void setup(void) { Serial.begin(9600); delay(1000); ucg.begin(UCG_FONT_MODE_SOLID); ucg.setRotate90(); ucg.clearScreen(); Serial.println("Cleared"); pinMode(SS, OUTPUT); // CS for flash digitalWrite(SS, HIGH); // <-- Set CS pin HIGH to deselect } void loop(void) { ucg.setFont(ucg_font_ncenR12_tr); ucg.setColor(255, 255, 255); ucg.setPrintPos(10 , 20); ucg.print("Lithography Settings"); ucg.setPrintPos(100 , 60); ucg.print("White"); ucg.setPrintPos(200 , 60); ucg.setColor(200, 0, 200); ucg.print("UV"); ucg.setPrintPos(10 , 100); ucg.setColor(255, 255, 255); ucg.print("Power Level: "); ucg.setPrintPos(10 , 175); ucg.print("Exposure Time: "); // while(!startFlag){ // delay(10000); // Serial.println("Press any key to input exposure parameters"); // while (Serial.available() == 0) { // } // input = Serial.read(); // if(input != ""){ // startFlag = 1; // } // delay(100); // } // while((exposureType != "w") || (exposureType != "uv")){ // Serial.println("Enter 'w' or 'uv' to select White or UV exposure mode"); // while (Serial.available() == 0) { // } // exposureType = Serial.readString(); // } if (Serial.available() > 0) { int incomingByte0 = Serial.read(); if(incomingByte0 == 1) { updateParameters(); } if(incomingByte0 == 2) { runExposure(); } } delay(500); } void updateParameters(){ ucg.setColor(0, 255, 0); int incomingByte0 = Serial.read(); if(incomingByte0 == 1){ ucg.setColor(0, 0, 0); ucg.drawFrame(195, 43, 36, 25); ucg.setColor(0, 255, 0); ucg.drawFrame(95, 43, 55, 25); exposureType = "white"; } if(incomingByte0 == 2){ ucg.setColor(0, 0, 0); ucg.drawFrame(95, 43, 55, 25); ucg.setColor(0, 255, 0); ucg.drawFrame(195, 43, 36, 25); exposureType = "uv"; } int incomingByte1 = Serial.read(); ucg.setPrintPos(120 , 100); ucg.print(String(incomingByte1)); powerLevel = incomingByte1; int incomingByte2 = Serial.read(); ucg.setPrintPos(145, 175); ucg.print(String(incomingByte2)); exposureTime = incomingByte2; } void runExposure(){ ucg.setColor(0, 255, 0); ucg.setPrintPos(120 , 220); ucg.print("EXPOSING:"); int countDown = exposureTime; while(countDown >= 0){ ucg.setColor(0, 0, 0); ucg.drawBox(220, 180, 40, 40); ucg.setColor(0, 255, 0); ucg.setPrintPos(220, 220); ucg.print(String(countDown)); countDown = countDown - 1; delay(1000); } ucg.setColor(0, 0, 0); ucg.drawBox(120, 180, 140, 40); }