#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#define BGCOLOR 0x05d4
#define Firbtn 17
#define Secbtn 5
#define Xj 0
#define Yj 12
#define TFT_DC 2
#define TFT_CS 15
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
int xcursor = 158;
int ycursor = 118;
bool cursordrawn = false;
int launchedappid = 0;
/*
IDs:
0 - desktop
*/
void setup() {
tft.begin(); //tft begin
tft.setRotation(1); //print "booted succesfuly"
tft.fillScreen(ILI9341_BLUE);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(5);
tft.println("booted succesfuly");
pinMode(Firbtn, INPUT); //buttons and joystick begin
pinMode(Secbtn, INPUT);
pinMode(Xj, INPUT);
pinMode(Yj, INPUT);
Serial.begin(9600); //serial begin
tft.fillScreen(ILI9341_BLACK);
tft.fillScreen(BGCOLOR);
tft.fillRect(-1, 224, 325, 16, 0x036c);
tft.setCursor(3, 229);
tft.setTextSize(1);
tft.setTextColor(ILI9341_BLACK);
tft.println("SofaOS ALPHA! ver 1.1a");
}
void loop() {
// GOVNO //
tft.setCursor(0,0);
// GOVNO //
// CURSOR DRAWING //
if(!cursordrawn){
if(launchedappid == 0){ DrawDesktopPart(); }
tft.drawRect(xcursor, ycursor, 8, 8, ILI9341_BLACK);
cursordrawn = true;
}
int XJPos = analogRead(Xj);
int YJPos = analogRead(Yj);
if(XJPos < 2000 && xcursor < 312){ xcursor++; cursordrawn = false; }
if(XJPos > 4048 && xcursor > 0){ xcursor--; cursordrawn = false; }
if(YJPos < 2000 && ycursor < 232){ ycursor++; cursordrawn = false; }
if(YJPos > 4048 && ycursor > 0){ ycursor--; cursordrawn = false; }
delay(10);
// CURSOR DRAWING //
}
void DrawDesktopPart(){
if(ycursor+7 < 224){
tft.fillRect(xcursor-1, ycursor-1, 10, 10, BGCOLOR);
} else {
tft.drawRect(xcursor-1, ycursor-1, 10, 10, BGCOLOR);
tft.fillRect(-1, 224, 325, 16, 0x036c);
tft.setCursor(3, 229);
tft.setTextSize(1);
tft.setTextColor(ILI9341_BLACK);
tft.println("SofaOS ALPHA! ver 1.1a");
}
}