#include <MD_MAX72xx.h>

// Turn on debug statements to the serial output
#define  DEBUG  1

#if  DEBUG
#define PRINT(s, x) { Serial.print(F(s)); Serial.print(x); }
#define PRINTS(x) Serial.print(F(x))
#define PRINTD(x) Serial.println(x, DEC)

#else
#define PRINT(s, x)
#define PRINTS(x)
#define PRINTD(x)

#endif
#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW/*PAROLA_HW/FC16_HW*/
#define MAX_DEVICES	14

#define CLK_PIN   13  // or SCK
#define DATA_PIN  11  // or MOSI
#define CS_PIN    10  // or SS

MD_MAX72XX mx = MD_MAX72XX(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
// Specific SPI hardware interface
//MD_MAX72XX mx = MD_MAX72XX(HARDWARE_TYPE, SPI1, CS_PIN, MAX_DEVICES);
// Arbitrary pins
//MD_MAX72XX mx = MD_MAX72XX(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);

#define  DELAYTIME  60
//pin dei pulsanti
#define PULS1 9
#define PULS2 8
#define PULS3 7
#define PULS4 6
#define PULS5 5
#define PULS6 4
#define PULS7 3
#define PULS8 2
byte face=1;    //controllo della faccia
short tempo;    //tempo di blink
uint8_t cm=0;

void setup()
{
  mx.begin();

#if  DEBUG
  Serial.begin(3600);
#endif
  PRINTS("\[Test Protogen os]");
  if(!DEBUG) OSBoot();//se i debug è a 1 evito di avviare il booting per fare primax
}

void loop()
{
  if(DEBUG) Serial.println(face);//se il debug è a 1 controllo se cambia la variabile dela faccia
  tempo=0;
  switch(face){//a seconda di che pulsante si ha premuto entra in un caso della determinata faccia
    case 1:
      idleFace();//faccio vedere la faccia desiderata
      loopBlink(face);
      break;
    case 2: 
      happyFace();//faccio vedere la faccia desiderata
      loopBlink(face);
      break;
    case 3:
      angyFace();//faccio vedere la faccia desiderata
      loopBlink(face);
      break;
    case 4:
      playfulFace();//faccio vedere la faccia desiderata
      loopBlink(face);
      break;
    case 5:
      sillyFace();//faccio vedere la faccia desiderata
      loopBlink(face);
      break;
    case 6:
      kinkyFace();//faccio vedere la faccia desiderata
      loopBlink(face);
      break;
    case 7:
      deathFace();//faccio vedere la faccia desiderata
      loopBlink(face);
      break;
    case 8:
      idleFace();//faccio vedere la faccia desiderata
      loopBlink(face);
      break;
    case 9:
      mx.clear();
      boopFace();//faccio vedere la faccia desiderata
      loopBlink(face);
      break;
  }
}

void printSprite(uint8_t sprite[], byte setPosition){
  mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::OFF);              //auto update off
  mx.setBuffer(((setPosition+1)*COL_SIZE)-1, COL_SIZE, sprite); //set della sprite 
  mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::ON);               //auto update on
}

long readUltrasonicDistance(int triggerPin, int echoPin){
  long dato=0;
  pinMode(triggerPin, OUTPUT);
  digitalWrite(triggerPin, LOW);
  delay(2);
  
  digitalWrite(triggerPin, HIGH);
  delay(10);
  digitalWrite(triggerPin, LOW);
  pinMode(echoPin, INPUT);
  
  dato=pulseIn(echoPin, HIGH);
  cm = 0.01715 * dato;
  Serial.println(cm);
}

void idleFace(){//componenti della faccia di idle
  edgyEyes();
  normalNose();
  normalMouth();
  edgyEyesBlink();
}

void happyFace(){//componenti della faccia felice
  happyEyes();
  normalNose();
  normalMouth();
}

void angyFace(){//componenti della faccia arrabbiata
  angyEyes();
  normalNose();
  angyMouth();
  angyEyesBlink();
}

void playfulFace(){
  playfulEyes();
  normalNose();
  normalMouth();
}

void sillyFace(){
  owoEyes();
  normalNose();
  wMouth();
  owoEyesBlink();
}

void kinkyFace(){
  uwuEyes();
  normalNose();
  wMouth();
}

void deathFace(){
  deathEyes();
  normalNose();
  wMouth();
}

void boopFace(){

}

void setOnLine(byte x, byte y, byte riga){
  for(byte i=x ; i<y ; i++) mx.setPoint(riga, i, true);
}

void setOffLine(byte x, byte y, byte riga){
  for(byte i=x ; i<y ; i++) mx.setPoint(riga, i, false);
}

void loopBlink(byte x){
  while(tempo<=7000){//'delay' per essere recettivo e allo stesso tempo aspettare prima di fare il blink
    delay(1);
    if(digitalRead(PULS1)) face=1;//a seconda di quale pulsante è stato premuto cambia il dato da dare allo switch
    if(digitalRead(PULS2)) face=2;
    if(digitalRead(PULS3)) face=3;
    if(digitalRead(PULS4)) face=4;
    if(digitalRead(PULS5)) face=5;
    if(digitalRead(PULS6)) face=6;
    if(digitalRead(PULS7)) face=7;
    if(digitalRead(PULS8)) face=8;
    if(readUltrasonicDistance(A0, A1)>=2 && readUltrasonicDistance(A0, A1)<=4) face=9;
    if(face!=x) {//se face cambia pulisce le matrici e fa uscire istantaneamente dal while
      mx.clear();
      tempo=7000;
    }
    tempo++;
  }
}

void OSBoot(){//funzione estetica di avvio del protogen
//mx.control(MD_MAX72XX::setFont());
  scrollText("PROTOGEN OS 2.5 BOOTING..");
  delay(500);//delay per leggere
  mx.clear();//pulisco le matrici per non compenetrare i pixel dei numeri precedenti
  uint8_t sys1[COL_SIZE]{
    0b00100100,
    0b00101010,
    0b00101010,
    0b00010010,
    0b00000000,
    0b00000110,
    0b00111000,
    0b00000110
  };
  uint8_t sys2[COL_SIZE]{
    0b00000000,
    0b00100100,
    0b00101010,
    0b00101010,
    0b00010010,
    0b00000000,
    0b00000000,
    0b00000000
  };
  for(byte j=0 ; j<3 ; j++){
    for(byte i=0 ; i<10 ; i++){
      printSprite(sys1, 3);
      printSprite(sys2, 2);
      mx.setChar(18, '1'+j);
      mx.setColumn(13, 255);

      for(byte j=0 ; j<11 ; j++){
        mx.setChar(11, '0'+i);
        mx.setChar(5, '0'+j);
      delay(7);
      }
      mx.clear();
    }
    printSprite(sys1, 3);
    printSprite(sys2, 2);
    mx.setChar(18, '1'+j);
    mx.setColumn(13, 255);
    mx.setChar(10, 'O');
    mx.setChar(5, 'N');
    delay(1500);
  }
  mx.clear();
}


void scrollText(const char *p)//funzione per lo scorrimento orizzontale di parole
{
  uint8_t charWidth;
  uint8_t cBuf[8];  // this should be ok for all built-in fonts
  PRINTS("\nprotogen booting..");
  mx.clear();
  while (*p != '\0'){
    charWidth = mx.getChar(*p++, sizeof(cBuf) / sizeof(cBuf[0]), cBuf);
    for (uint8_t i=0; i<=charWidth; i++)	{// allow space between characters
      mx.transform(MD_MAX72XX::TSL);
      if (i < charWidth) mx.setColumn(0, cBuf[i]);
      delay(DELAYTIME);
    }
  }
}

void edgyEyesBlink(){
  PRINTS("\nedgy eyes blinking..");
  //ho dovuto mischiare lato destro e sinistro per colpa dei delay
  byte i, riga=1;
  for(i=32 ; i<48 ; i++){//spengo la 1/2 riga di entrambi gli occhi
    mx.setPoint(riga-1, i, false);
    mx.setPoint(riga, i, false);
  }
  for(i=64 ; i<80 ; i++){
    mx.setPoint(riga-1, i, false);
    mx.setPoint(riga, i, false);
  }
  delay(20);
  riga++;
  setOffLine(33, 48, riga);//spengo la 3 riga di entrambi gli occhi
  setOffLine(64, 79, riga);
  delay(20);
  riga++;
  riga++;
  for(i=35 ; i<47 ; i++) {//spengo la 4/5 riga di entrambi gli occhi
    mx.setPoint(riga-1, i, false);
    mx.setPoint(riga, i, false);
  }
  for(i=65 ; i<77 ; i++) {
    mx.setPoint(riga-1, i, false);
    mx.setPoint(riga, i, false);
  }
  delay(10);
  riga=7;
  setOffLine(39, 43, riga);//spengo la 6 riga di entrambi gli occhi
  setOffLine(69, 73, riga);
  delay(20);
  riga--;
  setOffLine(37, 45, riga);//spengo la 7 riga di entrambi gli occhi
  setOffLine(67, 75, riga);
  delay(20);
  riga--;
  setOffLine(36, 46, riga);//spengo la 8 riga di entrambi gli occhi
  setOffLine(66, 76, riga);
  delay(130);///////////////////////////////////////////////////////
  setOnLine(36, 46, riga);//accendo la 8 riga di entrambi gli occhi
  setOnLine(66, 76, riga);
  delay(20);
  riga++;
  setOnLine(37, 45, riga);//accendo la 7 riga di entrambi gli occhi
  setOnLine(67, 75, riga);
  delay(20);
  riga++;
  setOnLine(39, 43, riga);//accendo la 6 riga di entrambi gli occhi
  setOnLine(69, 73, riga);
  delay(20);
  riga=5;
  riga--;
  riga--;
  for(i=35 ; i<47 ; i++) {//accendo la 5/4 riga di entrambi gli occhi
    mx.setPoint(riga+1, i, true);
    mx.setPoint(riga, i, true);
  }
  for(i=65 ; i<77 ; i++) {
    mx.setPoint(riga+1, i, true);
    mx.setPoint(riga, i, true);
  }
  delay(20);
  riga--;
  setOnLine(33, 48, riga);//accendo la 3 riga di entrambi gli occhi
  setOnLine(64, 79, riga);
  delay(20);
  riga--;
  riga--;
  for(i=32 ; i<48 ; i++){//accendo la 2/1 di entrambi gli occhi
    mx.setPoint(riga+1, i, true);
    mx.setPoint(riga, i, true);
  }
  for(i=64 ; i<80 ; i++){
    mx.setPoint(riga+1, i, true);
    mx.setPoint(riga, i, true);
  }
}

void angyEyesBlink(){
  PRINTS("\nangy eyes blinking..");
  byte i, riga=0;
  setOffLine(32, 35, riga);//spengo la  riga di entrambi gli occhi
  setOffLine(77, 80, riga);
  delay(30);
  riga++;
  setOffLine(32, 38, riga);//spengo la 2 riga di entrambi gli occhi
  setOffLine(74, 80, riga);
  delay(30);
  riga++;
  setOffLine(33, 41, riga);//spengo la 3 riga di entrambi gli occhi
  setOffLine(71, 79, riga);
  delay(30);
  riga++;
  setOffLine(34, 44, riga);//spengo la 4 riga di entrambi gli occhi
  setOffLine(68, 78, riga);
  delay(30);
  riga++;
  setOffLine(34, 46, riga);//spengo la 5 riga di entrambi gli occhi
  setOffLine(66, 78, riga);
  delay(30);
  riga=7;
  setOffLine(37, 45, riga);//spengo la 6 riga di entrambi gli occhi
  setOffLine(67, 75, riga);
  delay(30);
  riga--;
  setOffLine(36, 46, riga);//spengo la 7 riga di entrambi gli occhi
  setOffLine(66, 76, riga);
  delay(30);
  riga--;
  setOffLine(35, 47, riga);//spengo la 8 riga di entrambi gli occhi
  setOffLine(65, 77, riga);
  delay(130);///////////////////////////////////////////////////////
  setOnLine(35, 47, riga);//accendo la 8 riga di entrambi gli occhi
  setOnLine(65, 77, riga);
  delay(30);
  riga++;
  setOnLine(36, 46, riga);//accendo la 7 riga di entrambi gli occhi
  setOnLine(66, 76, riga);
  delay(30);
  riga++;
  setOnLine(37, 45, riga);//accendo la 6 riga di entrambi gli occhi
  setOnLine(67, 75, riga);
  delay(30);
  riga=4;
  setOnLine(34, 46, riga);//accendo la 5 riga di entrambi gli occhi
  setOnLine(66, 78, riga);
  delay(30);
  riga--;
  setOnLine(34, 44, riga);//accendo la 4 riga di entrambi gli occhi
  setOnLine(68, 78, riga);
  delay(30);
  riga--;
  setOnLine(33, 41, riga);//accendo la 3 riga di entrambi gli occhi
  setOnLine(71, 79, riga);
  delay(30);
  riga--;
  setOnLine(32, 38, riga);//accendo la 2 riga di entrambi gli occhi
  setOnLine(74, 80, riga);
  delay(30);
  riga--;
  setOnLine(32, 35, riga);//accendo la 1 riga di entrambi gli occhi
  setOnLine(77, 80, riga);
}

void owoEyesBlink(){
  PRINTS("\nowo eyes blinking..");
  byte i, riga=0;
  setOffLine(38, 42, riga);
  setOffLine(70, 74, riga);
  delay(10);
  riga++;
  for(i=37 ; i<43 ; i++){
    if((i>=37 && i<=38) || (i>=41 && i<=42)) mx.setPoint(riga, i, false);
  }
  for(i=69 ; i<75 ; i++){
    if((i>=69 && i<=70) || (i>=73 && i<=74)) mx.setPoint(riga, i, false);
  }
  delay(10);
  riga++;
  for(i=36 ; i<44 ; i++){
    if((i>=36 && i<=37) || (i>=42 && i<=43)) mx.setPoint(riga, i, false);
  }
  for(i=68 ; i<76 ; i++){
    if((i>=68 && i<=69) || (i>=74 && i<=75)) mx.setPoint(riga, i, false);
  }
  delay(10);
  riga++;
  mx.setPoint(riga, 36, false);
  mx.setPoint(riga, 43, false);
  mx.setPoint(riga, 68, false);
  mx.setPoint(riga, 75, false);
  delay(10);
  riga++;
  mx.setPoint(riga, 36, false);
  mx.setPoint(riga, 43, false);
  mx.setPoint(riga, 68, false);
  mx.setPoint(riga, 75, false);
  delay(10);
  riga=7;
  setOffLine(38, 42, riga);
  setOffLine(70, 74, riga);
  delay(10);
  riga--;
  for(i=37 ; i<43 ; i++){
    if((i>=37 && i<=38) || (i>=41 && i<=42)) mx.setPoint(riga, i, false);
  }
  for(i=69 ; i<75 ; i++){
    if((i>=69 && i<=70) || (i>=73 && i<=74)) mx.setPoint(riga, i, false);
  }
  delay(10);
  riga--;
  for(i=36 ; i<44 ; i++){
    if((i>=36 && i<=37) || (i>=42 && i<=43)) mx.setPoint(riga, i, false);
  }
  for(i=68 ; i<76 ; i++){
    if((i>=68 && i<=69) || (i>=74 && i<=75)) mx.setPoint(riga, i, false);
  }
  delay(130);///////////////////////////////////////////////////////
  for(i=36 ; i<44 ; i++){
    if((i>=36 && i<=37) || (i>=42 && i<=43)) mx.setPoint(riga, i, true);
  }
  for(i=68 ; i<76 ; i++){
    if((i>=68 && i<=69) || (i>=74 && i<=75)) mx.setPoint(riga, i, true);
  }
  delay(10);
  riga++;
  for(i=37 ; i<43 ; i++){
    if((i>=37 && i<=38) || (i>=41 && i<=42)) mx.setPoint(riga, i, true);
  }
  for(i=69 ; i<75 ; i++){
    if((i>=69 && i<=70) || (i>=73 && i<=74)) mx.setPoint(riga, i, true);
  }
  delay(10);
  riga++;
  setOnLine(38, 42, riga);
  setOnLine(70, 74, riga);
  delay(10);
  riga=4;
  mx.setPoint(riga, 36, true);
  mx.setPoint(riga, 43, true);
  mx.setPoint(riga, 68, true);
  mx.setPoint(riga, 75, true);
  delay(10);
  riga--;
  mx.setPoint(riga, 36, true);
  mx.setPoint(riga, 43, true);
  mx.setPoint(riga, 68, true);
  mx.setPoint(riga, 75, true);
  delay(10);
  riga--;
  for(i=36 ; i<44 ; i++){
    if((i>=36 && i<=37) || (i>=42 && i<=43)) mx.setPoint(riga, i, true);
  }
  for(i=68 ; i<76 ; i++){
    if((i>=68 && i<=69) || (i>=74 && i<=75)) mx.setPoint(riga, i, true);
  }
  delay(10);
  riga--;
  for(i=37 ; i<43 ; i++){
    if((i>=37 && i<=38) || (i>=41 && i<=42)) mx.setPoint(riga, i, true);
  }
  for(i=69 ; i<75 ; i++){
    if((i>=69 && i<=70) || (i>=73 && i<=74)) mx.setPoint(riga, i, true);
  }
  delay(10);
  riga--;
  setOnLine(38, 42, riga);
  setOnLine(70, 74, riga);
}

void happyEyes(){
  PRINTS("\nhappy eyes blinking..");
  uint8_t happyEyesLeft1[COL_SIZE]{
    0b00001110,
    0b00001110,
    0b00001110,
    0b00001100,
    0b00001100,
    0b00011000,
    0b00011000,
    0b00110000,
  };
  uint8_t happyEyesleft2[COL_SIZE]{
    0b00011000,
    0b00111100,
    0b00111110,
    0b00011110,
    0b00001111,
    0b00001111,
    0b00001111,
    0b00001111,
  };
  uint8_t happyEyesright1[COL_SIZE]{
    0b00001111,
    0b00001111,
    0b00001111,
    0b00001111,
    0b00011110,
    0b00111110,
    0b00111100,
    0b00011000,
  };
  uint8_t happyEyesRight2[COL_SIZE]{
    0b00110000,
    0b00011000,
    0b00011000,
    0b00001100,
    0b00001100,
    0b00001110,
    0b00001110,
    0b00001110,
  };
  printSprite(happyEyesLeft1, 4);
  printSprite(happyEyesleft2, 5);
  printSprite(happyEyesright1, 8);
  printSprite(happyEyesRight2, 9);
  PRINTS("\nhappy eyes done");
}

void edgyEyes(){
  PRINTS("\nedgy eye booting..");
  uint8_t edgyEyesLeft1[COL_SIZE]{
    0b11111111,
    0b01111111,
    0b01111111,
    0b00111111,
    0b00011111,
    0b00000111,
    0b00000111,
    0b00000011
  };
  uint8_t edgyEyesleft2[COL_SIZE]{
    0b00000111,
    0b00011111,
    0b00111111,
    0b01111111,
    0b01111111,
    0b11111111,
    0b11111111,
    0b11111111
  };
  uint8_t edgyEyesright1[COL_SIZE]{
    0b11111111,
    0b11111111,
    0b11111111,
    0b01111111,
    0b01111111,
    0b00111111,
    0b00011111,
    0b00000111
  };
  uint8_t edgyEyesRight2[COL_SIZE]{
    0b00000011,
    0b00000111,
    0b00000111,
    0b00011111,
    0b00111111,
    0b01111111,
    0b01111111,
    0b11111111
  };
  printSprite(edgyEyesLeft1, 4);
  printSprite(edgyEyesleft2, 5);
  printSprite(edgyEyesright1, 8);
  printSprite(edgyEyesRight2, 9);
  
  PRINTS("\nedgy eye done");
}

void angyEyes(){
  PRINTS("\nangy eyes booting..");
  uint8_t angyEyesLeft1[COL_SIZE]{
    0b11111100,
    0b11111100,
    0b11111110,
    0b01111110,
    0b00111110,
    0b00011111,
    0b00000111,
    0b00000011
  };
  uint8_t angyEyesLeft2[COL_SIZE]{
    0b00000000,
    0b00100000,
    0b01110000,
    0b11110000,
    0b11111000,
    0b11111000,
    0b11111000,
    0b11111100
  };
  uint8_t angyEyesRight1[COL_SIZE]{
    0b11111100,
    0b11111000,
    0b11111000,
    0b11111000,
    0b11110000,
    0b01110000,
    0b00100000,
    0b00000000
  };
  uint8_t angyEyesRight2[COL_SIZE]{
    0b00000011,
    0b00000111,
    0b00011111,
    0b00111110,
    0b01111110,
    0b11111110,
    0b11111100,
    0b11111100
  };
  printSprite(angyEyesLeft1, 4);
  printSprite(angyEyesLeft2, 6);
  printSprite(angyEyesRight1, 8);
  printSprite(angyEyesRight2, 9);
  PRINTS("\nangy eyes done");
}

void playfulEyes(){
  PRINTS("\nplayful eyes booting..");
  uint8_t playfulEyesLeft1[COL_SIZE]{
    0b11000110,
    0b10000010,
    0b10000010,
    0b10000011,
    0b00000001,
    0b00000001,
    0b00000001,
    0b00000000
  };
  uint8_t playfulEyesLeft2[COL_SIZE]{
    0b00010000,
    0b00010000,
    0b00111000,
    0b00101000,
    0b00101000,
    0b01101100,
    0b01000100,
    0b01000100
  };
  uint8_t playfulEyesRight1[COL_SIZE]{
    0b01000100,
    0b01000100,
    0b01101100,
    0b00101000,
    0b00101000,
    0b00111000,
    0b00010000,
    0b00010000
  };
  uint8_t playfulEyesRight2[COL_SIZE]{
    0b00000001,
    0b00000001,
    0b00000001,
    0b10000011,
    0b10000010,
    0b10000010,
    0b10000010,
    0b11000110
  };
  printSprite(playfulEyesLeft1, 4);
  printSprite(playfulEyesLeft2, 5);
  printSprite(playfulEyesRight1, 8);
  printSprite(playfulEyesRight2, 9);
  PRINTS("\nplayful eyes done");
}
  
void owoEyes(){
  PRINTS("\nowo eyes booting..");
  uint8_t owoEyesLeftSide[COL_SIZE]{
    0b10000001,
    0b11000011,
    0b01100110,
    0b00111100,
    0b00000000,
    0b00000000,
    0b00000000,
    0b00000000
  };
  uint8_t owoEyesRightSide[COL_SIZE]{
    0b00000000,
    0b00000000,
    0b00000000,
    0b00000000,
    0b00111100,
    0b01100110,
    0b11000011,
    0b10000001
  };
  printSprite(owoEyesLeftSide, 4);
  printSprite(owoEyesRightSide, 5);
  printSprite(owoEyesLeftSide, 8);
  printSprite(owoEyesRightSide, 9);
  PRINTS("\nowo eyes done");
}

void uwuEyes(){
  PRINTS("\nuwu eyes booting..");
  uint8_t uwuEyesLeftSide[COL_SIZE]{
    0b10000000,
    0b11000000,
    0b01110000,
    0b00011111,
    0b00000000,
    0b00000000,
    0b00000000,
    0b00000000
  };
  uint8_t uwuEyesRightSide[COL_SIZE]{
    0b00000000,
    0b00000000,
    0b00000000,
    0b00000000,
    0b00011111,
    0b01110000,
    0b11000000,
    0b10000000
  };
  printSprite(uwuEyesLeftSide, 4);
  printSprite(uwuEyesRightSide, 5);
  printSprite(uwuEyesLeftSide, 8);
  printSprite(uwuEyesRightSide, 9);
  PRINTS("\nuwu eyes done");
}

void deathEyes(){
  PRINTS("\ndeath eyes booting..");
  uint8_t deathEyesLeftSide[COL_SIZE]{
    0b00011000,
    0b00111100,
    0b01111110,
    0b01100110,
    0b11100111,
    0b11000011,
    0b10000001,
    0b10000001
  };
  uint8_t deathEyesRightSide[COL_SIZE]{
    0b10000001,
    0b10000001,
    0b11000011,
    0b11100111,
    0b01100110,
    0b01111110,
    0b00111100,
    0b00011000
  };
  printSprite(deathEyesLeftSide, 4);
  printSprite(deathEyesRightSide, 5);
  printSprite(deathEyesLeftSide, 8);
  printSprite(deathEyesRightSide, 9);
  PRINTS("\ndeath eyes done");
}

void normalNose(){
  PRINTS("\nnormal nose booting..");
  //left e right rispetto alla faccia del protogen
  uint8_t leftboop[COL_SIZE]{
    0b00111110,
    0b00011111,
    0b00000011,
    0b00000011,
    0b00000011,
    0b00000011,
    0b00000011,
    0b00000001
  };
  uint8_t rightboop[COL_SIZE]{
    0b00000001,
    0b00000011,
    0b00000011,
    0b00000011,
    0b00000011,
    0b00000011,
    0b00011111,
    0b00111110
  };
  printSprite(leftboop, 6);
  printSprite(rightboop, 7);
  PRINTS("\nnormal nose done");
}

void normalMouth(){
  PRINTS("\nnormal mouth booting..");
  //left e right rispetto alla faccia del protogen
  uint8_t leftNormalMouth1[COL_SIZE]{
    0b00011000,
    0b00011100,
    0b00011100,
    0b00010110,
    0b00010111,
    0b00010010,
    0b00011110,
    0b00011100
  };
  uint8_t leftNormalMouth2[COL_SIZE]{
    0b10000000,
    0b11000000,
    0b11000000,
    0b01100000,
    0b01100000,
    0b00110000,
    0b00110000,
    0b00011000
  };
  uint8_t leftNormalMouth3[COL_SIZE]{
    0b00010000,
    0b00110000,
    0b00110000,
    0b01100000,
    0b01100000,
    0b11000000,
    0b11000000,
    0b10000000
  };
  uint8_t leftNormalMouth4[COL_SIZE]{
    0b11000000,
    0b01100000,
    0b01100000,
    0b00110000,
    0b00110000,
    0b00011000,
    0b00011000,
    0b00011000
  };
  uint8_t rightNormalMouth1[COL_SIZE]{
    0b00011000,
    0b00011000,
    0b00011000,
    0b00110000,
    0b00110000,
    0b01100000,
    0b01100000,
    0b11000000
  };
  uint8_t rightNormalMouth2[COL_SIZE]{
    0b10000000,
    0b11000000,
    0b11000000,
    0b01100000,
    0b01100000,
    0b00110000,
    0b00110000,
    0b00010000
  };
  uint8_t rightNormalMouth3[COL_SIZE]{
    0b00011000,
    0b00110000,
    0b00110000,
    0b01100000,
    0b01100000,
    0b11000000,
    0b11000000,
    0b10000000
  };
  uint8_t rightNormalMouth4[COL_SIZE]{
    0b00011100,
    0b00011110,
    0b00010010,
    0b00010111,
    0b00010110,
    0b00011100,
    0b00011100,
    0b00011000
  };
  
  printSprite(leftNormalMouth1, 0);
  printSprite(leftNormalMouth2, 1);
  printSprite(leftNormalMouth3, 2);
  printSprite(leftNormalMouth4, 3);
  printSprite(rightNormalMouth1, 10);
  printSprite(rightNormalMouth2, 11);
  printSprite(rightNormalMouth3, 12);
  printSprite(rightNormalMouth4, 13);
  PRINTS("\nnormal mouth done ");
}

void angyMouth(){
  PRINTS("\nangy  mouth booting..");
  //left e right rispetto alla faccia del protogen
  uint8_t leftangyMouth1[COL_SIZE]{
    0b01100000,
    0b01000000,
    0b00000000,
    0b00000000,
    0b00000000,
    0b00000000,
    0b00000000,
    0b00000000
  };
  uint8_t leftangyMouth2[COL_SIZE]{
    0b00001110,
    0b00001100,
    0b00011100,
    0b00011100,
    0b00011000,
    0b00111000,
    0b00110000,
    0b01110000
  };
  uint8_t leftangyMouth3[COL_SIZE]{
    0b00001110,
    0b00001111,
    0b00001111,
    0b00000111,
    0b00000111,
    0b00000111,
    0b00000111,
    0b00001110
  };
  uint8_t leftangyMouth4[COL_SIZE]{
    0b01111100,
    0b01111100,
    0b01111100,
    0b00111110,
    0b00111110,
    0b00011110,
    0b00011110,
    0b00011110
  };
  uint8_t rightangyMouth1[COL_SIZE]{
    0b00011110,
    0b00011110,
    0b00011110,
    0b00111110,
    0b00111110,
    0b01111100,
    0b01111100,
    0b01111100
  };
  uint8_t rightangyMouth2[COL_SIZE]{
    0b00001110,
    0b00000111,
    0b00000111,
    0b00000111,
    0b00000111,
    0b00001111,
    0b00001111,
    0b00001110
  };
  uint8_t rightangyMouth3[COL_SIZE]{
    0b01110000,
    0b00110000,
    0b00111000,
    0b00011000,
    0b00011100,
    0b00011100,
    0b00001100,
    0b00001110
  };
  uint8_t rightangyMouth4[COL_SIZE]{
    0b00000000,
    0b00000000,
    0b00000000,
    0b00000000,
    0b00000000,
    0b00000000,
    0b01000000,
    0b01100000
  };
  printSprite(leftangyMouth1, 0);
  printSprite(leftangyMouth2, 1);
  printSprite(leftangyMouth3, 2);
  printSprite(leftangyMouth4, 3);
  printSprite(rightangyMouth1, 10);
  printSprite(rightangyMouth2, 11);
  printSprite(rightangyMouth3, 12);
  printSprite(rightangyMouth4, 13);
  PRINTS("\nangy mouth done ");
}

void wMouth(){
  PRINTS("\nw  mouth booting..");
  //left e right rispetto alla faccia del protogen
  uint8_t leftWMouth1[COL_SIZE]{
    0b00110000,
    0b00011000,
    0b00011100,
    0b00010110,
    0b00010111,
    0b00010010,
    0b00011110,
    0b00011100
  };
  uint8_t leftWMouth2[COL_SIZE]{
    0b00000110,
    0b00001100,
    0b00011000,
    0b00110000,
    0b01100000,
    0b11000000,
    0b11000000,
    0b01100000
  };
  uint8_t leftWMouth3[COL_SIZE]{
    0b01100000,
    0b11000000,
    0b11000000,
    0b01100000,
    0b00110000,
    0b00011000,
    0b00001100,
    0b00000110
  };
  uint8_t leftWMouth4[COL_SIZE]{
    0b00110000,
    0b00011000,
    0b00001100,
    0b00000110,
    0b00000110,
    0b00001100,
    0b00011000,
    0b00110000
  };
  uint8_t rightWMouth1[COL_SIZE]{
    0b00110000,
    0b00011000,
    0b00001100,
    0b00000110,
    0b00000110,
    0b00001100,
    0b00011000,
    0b00110000
  };
  uint8_t rightWMouth2[COL_SIZE]{
    0b00000110,
    0b00001100,
    0b00011000,
    0b00110000,
    0b01100000,
    0b11000000,
    0b11000000,
    0b01100000
  };
  uint8_t rightWMouth3[COL_SIZE]{
    0b01100000,
    0b11000000,
    0b11000000,
    0b01100000,
    0b00110000,
    0b00011000,
    0b00001100,
    0b00000110
  };
  uint8_t rightWMouth4[COL_SIZE]{
    0b00011100,
    0b00011110,
    0b00010010,
    0b00010111,
    0b00010110,
    0b00011100,
    0b00110000,
    0b00110000
  };
  printSprite(leftWMouth1, 0);
  printSprite(leftWMouth2, 1);
  printSprite(leftWMouth3, 2);
  printSprite(leftWMouth4, 3);
  printSprite(rightWMouth1, 10);
  printSprite(rightWMouth2, 11);
  printSprite(rightWMouth3, 12);
  printSprite(rightWMouth4, 13);
  PRINTS("\nw mouth done ");
}