Esempio n. 1
1
void loop() 
{
  if (checkRFID())
  {
    Serial.end();
    lcd.clear();
    switch (restaurantCode)
    {
    case 0:
      break;   //shouldn't get here...
    case 1:
      {
        lcd.clear();
        lcd.print("~Chipotle Menu");
      }
    default:
      break;
    }
    delay(1000);
    char select = priceSelect();
    lcd.clear();
    lcd.print("Selected: ");
    switch (select)
    {
    case 0:
      {
        lcd.print("$1-5");
        break;
      }
    case 1:
      {
        lcd.print("$5-10");
        break;
      }
    case 2:
      {
        lcd.print("$10-15");
        break;
      }
    case 3:
      {
        lcd.print("$15+up");
        break;
      }
    default:
      break; //shouldnt get here;
    }
    delay(1000);
    lcd.clear();
    lcd.print("at Chipotle");
    delay(2000);
    moneyPacketAdd(select);
    restPacketAdd(restaurantCode);
    sendPacket();
    lcd.clear();
    lcd.print("Request sent!");
    getPacket();
    parseInPacket();
    lcd.clear();
    int mealSelection = mealSelect();
    if (mealSelection == 100)
    {
      lcd.clear();
      lcd.print("Com Errors!");
      delay(5000);
      hardReset();
    }
    addPacketFood(mealSelection);
    sendPacket();
    lcd.clear();
    lcd.print("Order sent!");
    delay(3000);
    lcd.clear();
    lcd.print("-RFID Menu Scan-");
    digitalWrite(RFID_ENABLE, LOW);
    Serial.begin(2400);
    Serial.flush();
  }
  delay(500);
}
void loop() {

   statoPulsante = digitalRead(6);
   if(statoPulsante != precedenteStatoPulsante)
      if (statoPulsante == LOW) {
         risposta = random(8);

         lcd.clear();
         lcd.setCursor(0,0);
         lcd.print("La Palla dice:");
         lcd.setCursor(0,1);

       switch(risposta) {
          case 0: lcd.print("Si"); break;
          case 1: lcd.print("Molto probabilmente"); break;
          case 2: lcd.print("Certamemte"); break;
          case 3: lcd.print("Sembra di si"); break;
          case 4: lcd.print("Insicuro"); break;
          case 5: lcd.print("Domanda ancora"); break;
          case 6: lcd.print("Molto dubbio"); break;
          case 7: lcd.print("NO"); break;
          };
    };
   precedenteStatoPulsante = statoPulsante;   
}
Esempio n. 3
0
void loop() {
    static bool show_warning = false;
    int result = dht11.read();

    switch (result) {
    case Dht11::OK:
        Serial.println("Read ok");
        break;
    case Dht11::ERROR_TIMEOUT:
        Serial.println("Timeout");
        return;
    case Dht11::ERROR_CHECKSUM:
        Serial.println("Checksum error");
        return;
    default:
        Serial.println("WTF?");
        return;
    }

    lcd.setCursor(0, 0);
    lcd.print("T: ");
    // lcd.print(dht11.getTemperature());
    // lcd.print(" | ");
    // We trust more the thermistor than the humidity sensor...
    // The last one was giving **really** unrealistic results.
    float temperature = Tmp36AvgTemperature();
    lcd.print(temperature, 2);
    lcd.print(" C");

    lcd.setCursor(0, 1);
    lcd.print("Hum: ");
    lcd.print(dht11.getHumidity());
    lcd.print('%');

    if (temperature > TEMPERATURE_MAX ||
            temperature < TEMPERATURE_MIN)
        show_warning = !show_warning;
    else
        show_warning = false;

    lcd.setCursor(LCD_COLS - 3, 0);
    if (show_warning)
        lcd.print("(!)");
    else
        lcd.print("   ");

    delay(500);
}
Esempio n. 4
0
void off() {
    lcd.noDisplay();
    led.off();
}
Esempio n. 5
0
// Simple clearing of LCD screen while simultaneously
//  	updating the col and row trackers
//  	col, row: pointers to locations on LCD
void CurveInput::initLCD( byte* col, byte* row )
{
	lcd.clear();
	*col = 0; *row = 0;
	lcd.setCursor(*col, *row);
}
Esempio n. 6
0
void loop(){
  if(gameFinished == false){
    float time_to = random(1,2); //.. Aantal milliseconde om mee te beginnen
    int i;
    float current_multiplier = 0.98;
    float cashedOutMultiplier;
    int randomNumber = random(0,1000);
    if(randomNumber < 201){
      randomNumber = 0;
    }
    for(i = 0; i <= randomNumber; i++){
      switch (lcd_key){
        case btnSELECT:{
          cashedOut = true;
          cashedOutMultiplier = current_multiplier;
          break;
        }}
        lcd.clear();
        lcd.print("BustaDuino");  // print a simple message on the LCD
        lcd.setCursor(0, 1);
        if(randomNumber > 0){
          current_multiplier = current_multiplier + 0.01;
        }else{
          current_multiplier = 0;
        }
        
        lcd.print(String(current_multiplier) + "x");
        Serial.print(String(current_multiplier) + "x");
        lcd_key = read_LCD_buttons();   // read the buttons
        if(i <= randomNumber && cashedOut == true){
          lcd.clear();
          lcd.print("You Win!");
          lcd.setCursor(0, 1);
          lcd.print(String(cashedOutMultiplier) + "x");
          Serial.print(String(cashedOutMultiplier) + "x");
          gameFinished = true;
          break;
        }else if(i >= randomNumber && cashedOut == false){
          lcd.clear();
          lcd.print("BUSTED!");
          lcd.setCursor(0, 1);
          lcd.print(String(current_multiplier) + "x");
          Serial.print(String(current_multiplier) + "x");
          gameFinished = true;
        }
        delay((time_to/i) * 3000);
    }
  }
}
Esempio n. 7
0
void loop()
{

	int value = analogRead(0);

	Serial.print ( itoa ( value, buffer, 10 ) );

	int key = keypad.getKey();

    // wake up
	if ( key != NO_KEY && mode == LOW_POWER_MODE )
	{
		mode = NORMAL_MODE;
	}

	switch ( key )
	{
	case NO_KEY:

		keyPressed = 0;
		if ( mode != SET_FEED_MODE )
		{
			if ( prevKey == DOWN_KEY )
			{
				feedIndex++;
				if (feedIndex == 5)
					feedIndex = 1;
				showFeedTime(feedIndex);
			}
			else if ( prevKey == UP_KEY )
			{
				feedIndex--;
				if ( feedIndex == 0 )
					feedIndex = 4;
				showFeedTime(feedIndex);
			}
		}

		prevKey = NO_KEY;
		break;

	case SELECT_KEY:

		Serial.println("Select");

		if ( mode == SET_CLOCK_MODE && keyPressed == 0 )
		{
			Serial.println("Leaving edit mode");

			mode = NORMAL_MODE;

			//RTC.isMEZSummerTime();
			Serial.print(RTC.day);
			Serial.print(RTC.month);
			Serial.print(RTC.year);
			Serial.print(RTC.hour);
			Serial.print(RTC.minute);
			Serial.print(RTC.dow);

			RTC.second = 0;
			RTC.setTime();
			RTC.startClock();
		}
		else if ( mode == SET_FEED_MODE && keyPressed == 0 )
		{
			Serial.println("Leaving set feed mode");

			storeFeedTime(feedIndex);
			showFeedTime(feedIndex);
			mode = NORMAL_MODE;
		}
		else
		{
            // enter set clock mode after select key is long pressed
			keyPressed++;
			if ( keyPressed == 10 )
			{
				Serial.println("Entering edit mode");
				mode = SET_CLOCK_MODE;
				//keyPressed = 0;
				prevKey = NO_KEY;
				position = POS_DAY;
				RTC.stopClock();
				lcd.setCursor(0, 0);
			}
		}
		break;

	case RIGHT_KEY:
		Serial.println("Right");

        // set position to set clock
		if ( mode == SET_CLOCK_MODE )
		{
			switch ( position )
			{
			case POS_DAY:
				position = POS_MONTH;
				break;
			case POS_MONTH:
				position = POS_YEAR;
				break;
			case POS_YEAR:
				position = POS_HOUR;
				break;
			case POS_HOUR:
				position = POS_MINUTE;
				break;
			case POS_MINUTE:
				position = POS_DAY;
				break;
			}

			lcd.setCursor(0, 0);
		}
        
        // set position of feed time
		else if ( mode == SET_FEED_MODE )
		{
			switch ( position )
			{
			case POS_HOUR:
				position = POS_MINUTE;
				break;
			case POS_MINUTE:
				position = POS_CUP;
				break;
			case POS_CUP:
				position = POS_HOUR;
				break;
			}

			lcd.setCursor(0, 1);
		}
		break;

	case UP_KEY:
	case DOWN_KEY:

		Serial.println(key == UP_KEY ? "Up" : "Down");

        // set clock with up/down keys
		if ( mode == SET_CLOCK_MODE )
		{
			switch ( position )
			{
			case POS_DAY:
				if ( key == UP_KEY )
					RTC.day++;
				else
					RTC.day--;
				if ( RTC.day == 0 )
					RTC.day = 31;
				if ( RTC.day == 31 )
					RTC.day = 1;
				break;

			case POS_MONTH:
				if ( key == UP_KEY )
					RTC.month++;
				else
					RTC.month--;
				if ( RTC.month == 0 )
					RTC.month = 12;
				if ( RTC.month == 12 )
					RTC.month = 1;
				break;

			case POS_YEAR:
				if ( key == UP_KEY )
					RTC.year++;
				else
					RTC.year--;
				break;

			case POS_HOUR:
				if (key == UP_KEY)
					RTC.hour++;
				else
					RTC.hour--;
				if ( RTC.hour == 255 )
					RTC.hour = 23;
				if ( RTC.hour == 24 )
					RTC.hour = 0;
				hours = RTC.hour;
				break;

			case POS_MINUTE:
				if ( key == UP_KEY )
					RTC.minute++;
				else
					RTC.minute--;
				if ( RTC.minute == 255 )
					RTC.minute = 59;
				if ( RTC.minute == 60 )
					RTC.minute = 0;
				minutes = RTC.minute;
				break;
			}
		}
        
        // set feed time with up/down key
		else if ( mode == SET_FEED_MODE )
		{
			switch ( position )
			{
			case POS_HOUR:
				if (  key == UP_KEY )
					feedHour++;
				else
					feedHour--;
				if ( feedHour == 255 )
					feedHour = 23;
				if ( feedHour == 24 )
					feedHour = 0;
				break;

			case POS_MINUTE:
				if ( key == UP_KEY )
					feedMinute++;
				else
					feedMinute--;
				if ( feedMinute == 255 )
					feedMinute = 59;
				if ( feedMinute == 60 )
					feedMinute = 0;
				break;

			case POS_CUP:
				if ( key == UP_KEY )
					feedCup++;
				else
					feedCup--;
				if ( feedCup == 255 )
					feedCup = 9;
				if ( feedCup == 10 )
					feedCup = 0;
				break;
			}
		}
		else
		{
            // entering feed mode by long press down key
			prevKey = key;
			if ( key == DOWN_KEY )
			{
				keyPressed++;
				if ( keyPressed == 10 )
				{
					Serial.println("Entering set feed mode");

					mode = SET_FEED_MODE;

					prevKey = NO_KEY;
					//keyPressed = 0;
					position = POS_HOUR;
				}
			}
		}

		break;
	}

	int timeout = mode == LOW_POWER_MODE ? 1 : 50;
	if ( key == NO_KEY )
	{
        // timeout: switch display off and cancel previous actions
        
		displayTimeout++;
		if ( displayTimeout == timeout ) // 10 seconds timeout
		{
			pinMode(10, OUTPUT);
			digitalWrite(10, LOW);

			if ( mode == SET_CLOCK_MODE )
			{
				RTC.getTime();
				seconds = RTC.second;
				minutes = RTC.minute;
				hours = RTC.hour;
				mode = NORMAL_MODE;
			}
			else if ( mode == SET_FEED_MODE )
			{
				showFeedTime(feedIndex);
				mode = NORMAL_MODE;
			}
		}
	}
	else
	{
		if ( displayTimeout >= timeout )
		{
			prevKey = NO_KEY;
		}

		displayTimeout = 0;
		pinMode(10, INPUT);
	}

	lcd.setCursor(0, 0);              // Datum und Uhrzeit in 1. Zeile schreiben

	int blinkClock = (mode == SET_CLOCK_MODE) && (seconds % 2) && (key == NO_KEY || key == SELECT_KEY);

	if ( blinkClock && position == POS_DAY )
	{
		lcd.write("  ");
	}
	else
	{
		if (RTC.day < 10)
			lcd.write("0");
		lcd.write ( itoa ( RTC.day, buffer, 10 ) );
	}

	lcd.write(".");

	if ( blinkClock && position == POS_MONTH )
	{
		lcd.write("  ");
	}
	else
	{
		if (RTC.month < 10)
			lcd.write("0");
		lcd.write ( itoa ( RTC.month, buffer, 10 ) );
	}

	lcd.write(".");

	if ( blinkClock && position == POS_YEAR )
	{
		lcd.write ("    ");
	}
	else
	{
		lcd.write ( itoa ( RTC.year, buffer, 10 ) );
	}

	lcd.write(" ");
	//lcd.setCursor(0, 1);                                // Datum und Uhrzeit in 2. Zeile schreiben

	if ( blinkClock && position == POS_HOUR )
	{
		lcd.write("  ");
	}
	else
	{
		if (hours < 10)
			lcd.write("0");
		lcd.write(itoa(hours, buffer, 10));
	}

	if ( mode == SET_CLOCK_MODE || seconds % 2 )
	{
		lcd.write(":");
	}
	else
	{
		lcd.write (" ");
	}

	if ( blinkClock && position == POS_MINUTE )
	{
		lcd.write ("  ");
	}
	else
	{
		if ( minutes < 10 )
			lcd.write("0");

		lcd.write( itoa ( minutes, buffer, 10 ) );
	}

	lcd.setCursor(0, 1);

	lcd.write ( itoa ( feedIndex, buffer, 10 ) );
	lcd.write ("> ");

	int blinkTime = (mode == SET_FEED_MODE) && (seconds % 2) && (key == NO_KEY || key == DOWN_KEY);

	if ( blinkTime && position == POS_HOUR )
	{
		lcd.write ("  ");
	}
	else
	{
		if ( feedHour < 10 )
			lcd.write("0");
		lcd.write ( itoa ( feedHour, buffer, 10 ) );
	}

	lcd.write(":");

	if ( blinkTime && position == POS_MINUTE )
	{
		lcd.write("  ");
	}
	else
	{
		if ( feedMinute < 10 )
			lcd.write("0");
		lcd.write ( itoa ( feedMinute, buffer, 10 ) );
	}

	lcd.write("| ");

	if ( blinkTime && position == POS_CUP )
	{
		lcd.write (" ");
	}
	else
	{
		lcd.write ( itoa ( feedCup, buffer, 10 ) );
	}

	switch ( mode )
	{
	case LOW_POWER_MODE:
		waitTime = 1000;
		partsPerSec = 1;
		Serial.println("Low power mode");
		break;

	case FEED_MODE:
		waitTime = 50;
		partsPerSec = 20;
		break;

	default:
		//Serial.println("Edit mode");
		waitTime = 200;
		partsPerSec = 5;
		break;
	}

	delay(waitTime);
	if ( ++parts == partsPerSec )
	{
		parts = 0;
		seconds++;
	}

	if ( seconds >= 60 && parts == 0 && mode != SET_CLOCK_MODE )
	{
		seconds -= 60;
		minutes++;

		if ( minutes == 60 )
		{
			minutes = 0;
			hours++;
		}

        // switch off feeder after all cups are served
		if ( mode == FEED_MODE && remainingCups == 0 )
		{
			mode = NORMAL_MODE;
		}

        // finally check if it is feeding time
		if ( mode == NORMAL_MODE || mode == LOW_POWER_MODE )
		{
			for (int i = 0; i < sizeof(feedTimes) / sizeof(feedTimes[0]); i++)
			{
				byte * ptr = (byte*) &feedTimes[i];
				byte fm = ptr[0];
				byte fh = ptr[1];
				byte fc = ptr[2];

				if ( hours == fh && minutes == fm && fc > 0 )
				{
					Serial.println("It's feeding time");

					mode = FEED_MODE;
					remainingCups = fc;
					digitalWrite ( RELAIS_PIN, LOW );
					delay(10000);
					seconds += 10; // correct time
					break;
				}
			}
		}

		// sync every hour;
		if ( minutes == 0 )
		{
			RTC.getTime();
			seconds = RTC.second;
			minutes = RTC.minute;
			hours = RTC.hour;
		}
	}

    // if in feed mode wait for the end switch and decrement cups to be fed
	if ( mode == FEED_MODE )
	{
		if ( remainingCups > 0 )
		{
			if ( digitalRead ( END_SWITCH_PIN ) == LOW )
			{
				remainingCups--;
				if ( remainingCups == 0 )
				{
					digitalWrite( RELAIS_PIN, HIGH);
				}
			}
		}
	}
}
Esempio n. 8
0
void setup() {
  // set up the LCD's number of rows and columns: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}
Esempio n. 9
0
void loop()
{
    int i;
    while (RFID.available() <= 0); // force wait until rfid present
    
    if(RFID.available() > 0) //does rfid exist?
    {
        i = 0;
        
        while (i < 14)
        {
        
            tag_id = RFID.read(); //Reads character, puts into tag_id
            
            
            if (tag_id == '-1')  //Wait for scan to read
                continue;
            
            id_string = String(id_string + tag_id); //Make it a string
            
            //TESTING OUTPUT
            
            //For some reason, getting rid of this makes the tag not read correctly 
            Serial.print("Read:  "); 
            Serial.print(tag_id);
            Serial.print("\nid_string is now "); 
            Serial.print(id_string); 
            
            i++; //counts up unil 14
        }
            
        //TESTING OUTPUT
        Serial.print("\nid_string is now ");
        Serial.print(id_string);
        
        
        for(int index=0; index<5; index++)  //first we check to see if there are any current matches
        {
        
            if(id_string == id_array[index]) //if the id matches something in the array at location "i"
            {
                Serial.println("Match"); //print that it matches.
                id_array[index] = String("");    //set the array location of the removed tag to blank
                
                if (id_marker[index] == 1)  //if the id marker is equal to one
                //else //Removing this else because I dont think it makes sense. 
                {
                    // space_left++; //this isnt properly increasing the spaces left
                    //Commented out space left above because theres also one below.
                    
                    
                    // not sure if this is necessary 
                    for (int j = index; j < 4; j++)   //what purpose does j serve? Increments the search?
                    {
                        id_string[j] = id_string[j + 1]; 
                        id_marker[j] = id_marker[j + 1];
                        Serial.println(id_marker[index]);  //test print for the current marker. 
                    }
                    
                    index--;  //this might actually only subtract the last place, and not the proper location
                    space_left++;
                    no_match = 1;
                }
            
            }
        
        }//End of for loop
            
        //I added the ifs below to attempt to refine the location of the write location in the array. they dont work completely
        if (no_match == 0)
        {
            if (id_array[index] != String(""))   //if the array location is not blank, then
            {
                index ++;   //increment to the next spot
                Serial.println(i);
            }
            
            if (index == 5)  //if we're at the 5th spot
            {
                index = 0; //start back at zero
            }
            //this needs to be able to detect black values
            id_array[index] = id_string;
            id_marker[index]++;
            space_left--;  
        }
    
    }
        
    Serial.println(" "); // prints a space
    Serial.println(id_array[index]); // print the array item
    Serial.println("Finished Reading ID."); //prints out this on a line
    Serial.print("There are "); //start printing the result
    Serial.print(space_left); //then how many spaces
    Serial.print(" spaces left."); //words
    Serial.println(" "); //spaces
    
    //lcd output
    lcd.clear();
    lcd.print("There are "); //start printing the result
    lcd.print(space_left); //then how many spaces
    lcd.print("  spaces left."); //words
    lcd.println(" "); //spaces
    
    for(int i=0; i<5; i++)
    {
          //TEST OUTPUT: DISPLAY ARRAY. I put this here because its more accurate
          Serial.print("\nid_array[");
          Serial.print(i);
          Serial.print("] = ");
          Serial.print(id_array[i]);
          //Serial.print("\nid_string is ");
          //Serial.print(id_string);
    }
    no_match = 0; 
    id_string = String(""); //clear out the string
}
Esempio n. 10
0
//===============================================================================
void running() {

    if(programed == true) {
        switch(statea) {
        case 1:
            lcd.setCursor(0, 0);
            lcd.print("     Armed      ");
            lcd.setCursor(0, 1);

            if((keyBool == true) && (keyDis != true)) {
                lcd.print("K=");
                if((digitalRead(largeKey) == HIGH) && (lKey == true)) {
                    keyDis = true;
                    lcd.print("D");
                }
                else if((digitalRead(largeKey) == LOW) && (lKey == false)) {
                    keyDis = true;
                    lcd.print("D");
                }
                else
                    lcd.print("A");
            }

            if((keypadBool == true) && (keypadDis != true)) {

                but = keypadA.getKey();

                if((but != NO_KEY) && (i < 4)) {
                    butt[i] = but;
                    i++;
                    if(i == 4) {
                        if((code[0] == butt[0]) && (code[1] == butt[1]) && (code[2] == butt[2]) && (code[3] == butt[3]))
                            keypadDis = true;
                        else {
                            butt[0] = '-';
                            butt[1] = '-';
                            butt[2] = '-';
                            butt[3] = '-';
                            i = 0;
                            if(attem == true) {
                                attemCount--;
                                if(attemCount == 0) {
                                    bang = true;
                                }
                            }
                        }
                    }
                    but = '-';
                }
                lcd.print(butt[0]);
                lcd.print(butt[1]);
                lcd.print(butt[2]);
                lcd.print(butt[3]);
                lcd.print(" ");
                lcd.print(attemCount);
            }

            if(wireBool == true) {
                if((digitalRead(wire1) == LOW) && (safeWire == 1))
                    wireDis = true;
                else if((digitalRead(wire1) == LOW) && (safeWire != 1))
                    bang = true;

                if((digitalRead(wire2) == LOW) && (safeWire == 2))
                    wireDis = true;
                else if((digitalRead(wire2) == LOW) && (safeWire != 2))
                    bang = true;

                if((digitalRead(wire3) == LOW) && (safeWire == 3))
                    wireDis = true;
                else if((digitalRead(wire3) == LOW) && (safeWire != 3))
                    bang = true;

                if((digitalRead(wire4) == LOW) && (safeWire == 4))
                    wireDis = true;
                else if((digitalRead(wire4) == LOW) && (safeWire != 4))
                    bang = true;
            }

            if(bang == true) {
                statea = 3;
            }

            if((wireDis == true) || ((keyDis == keyBool) && (keypadDis == keypadBool))) {
                statea = 2;
            }
            break;

        case 2://Disarmed
            lcd.setCursor(0, 0);
            lcd.print("    Disarmed    ");
            lcd.setCursor(0, 1);
            lcd.print("                ");
            break;

        case 3://Bang
            lcd.setCursor(0, 0);
            lcd.print("      BANG      ");
            lcd.setCursor(0, 1);
            lcd.print("    You lose    ");
            break;
        }
    }
    else {
        lcd.setCursor(0, 0);
        lcd.print("Not configured");
        lcd.setCursor(0, 1);
        lcd.print("                ");
    }
}
Esempio n. 11
0
//===============================================================================
void program() {

    switch(progState) {

    case 0:

        lcd.setCursor(0,0);
        lcd.print("Use keypad ?    ");
        lcd.setCursor(0,1);
        lcd.print("*-Yes       #-No");
        programed = false;

        but = keypadA.getKey();

        if (but == '#') {
            keypadBool = false;
            progState = 1;
            but = NO_KEY;
        }
        else if (but == '*') {
            keypadBool = true;
            progState = 1;
            but = NO_KEY;
        }

        break;

    //----------------------------------------------------------------------
    case 1:
        lcd.setCursor(0,0);
        lcd.print("Use key ?       ");
        lcd.setCursor(0,1);
        lcd.print("*-Yes       #-No");

        but = keypadA.getKey();

        if (but == '#') {
            keyBool = false;
            progState = 2;
            but = NO_KEY;
        }
        else if (but == '*') {
            keyBool = true;
            progState = 2;
            but = NO_KEY;
        }
        break;

    //----------------------------------------------------------------------
    case 2:
        lcd.setCursor(0,0);
        lcd.print("Use Wires ?     ");
        lcd.setCursor(0,1);
        lcd.print("*-Yes       #-No");

        but = keypadA.getKey();

        if (but == '#') {
            wireBool = false;
            progState = 3;
            but = NO_KEY;
        }
        else if (but == '*') {
            wireBool = true;
            progState = 3;
            but = NO_KEY;
        }
        break;

    //----------------------------------------------------------------------
    case 3:
        lcd.setCursor(0,0);
        lcd.print("Use Timer ?     ");
        lcd.setCursor(0,1);
        lcd.print("*-Yes       #-No");

        but = keypadA.getKey();

        if (but == '#') {
            timerBool = false;
            progState = 4;
            but = NO_KEY;
        }
        else if (but == '*') {
            timerBool = true;
            progState = 4;
            but = NO_KEY;
        }
        break;

    //----------------------------------------------------------------------
    case 4:
        lcd.setCursor(0,0);
        lcd.print("KP-");
        lcd.print(keypadBool);
        lcd.print("Ky-");
        lcd.print(keyBool);
        lcd.print("W-");
        lcd.print(wireBool);
        lcd.print("T-");
        lcd.print(timerBool);
        lcd.setCursor(0,1);
        lcd.print("*-Yes       #-No");

        but = keypadA.getKey();

        if (but == '#') {
            progState = 5;
            but = NO_KEY;
        }
        else if (but == '*') {
            progState = 5;
            statea = 1;
            i = 0;
            but = NO_KEY;
        }
        break;

    //----------------------------------------------------------------------
    case 5:

        switch(mode) {

        case 1:
            if(keypadBool == true) {
                switch (statea) {
                case 1:
                    lcd.setCursor(0, 0);
                    lcd.print("Enter 4Digit pin");
                    lcd.setCursor(0, 1);
                    lcd.print(code[0]);
                    lcd.print(code[1]);
                    lcd.print(code[2]);
                    lcd.print(code[3]);
                    lcd.print("           ");

                    but = keypadA.getKey();

                    if((but != NO_KEY) && (i < 4)) {
                        code[i] = but;
                        i++;
                        but = '-';
                    }

                    if(i >= 4) {
                        statea = 2;
                        i = 0;
                    }
                    break;

                case 2:
                    lcd.setCursor(0, 0);
                    lcd.print("# of attempts   ");
                    lcd.setCursor(0, 1);
                    lcd.print(time[0]);
                    lcd.print(time[1]);
                    lcd.print(time[2]);
                    lcd.print(time[3]);

                    but = keypadA.getKey();

                    if((i >= 4) || (but == '#')) {
                        attempts = atoi(time);
                        if(attempts == 0)
                            attem = false;
                        else
                            attem = true;
                        statea = 3;
                        but = NO_KEY;
                    }

                    if((but != NO_KEY) && (i < 4)) {
                        time[i] = but;
                        i++;
                        but = '-';
                    }
                    break;

                case 3:
                    lcd.setCursor(0, 0);
                    lcd.print("C -");
                    lcd.print(code[0]);
                    lcd.print(code[1]);
                    lcd.print(code[2]);
                    lcd.print(code[3]);
                    lcd.print(" A -");
                    lcd.print(attempts);
                    lcd.setCursor(0, 1);
                    lcd.print("*-Yes       #-No");

                    but = keypadA.getKey();

                    if (but == '#') {
                        statea = 1;
                        i = 0;
                        code[0] = '-';
                        code[1] = '-';
                        code[2] = '-';
                        code[3] = '-';
                        but = NO_KEY;
                    }
                    else if (but == '*') {
                        statea = 5;
                        mode = 2;
                        attemCount = attempts;
                        but = NO_KEY;
                    }
                    break;
                }
            }
            else
                mode = 2;
            break;

        case 2:
            if(keyBool == true) {
                if(digitalRead(largeKey) == HIGH)
                    lKey = false;
                else
                    lKey = true;
            }
            statea = 1;
            mode = 3;
            break;

        case 3:
            if(wireBool == true) {
                switch(statea) {
                case 1:
                    lcd.setCursor(0, 0);
                    lcd.print("Sel disarm wire");
                    lcd.setCursor(0, 1);
                    lcd.print("                ");

                    but = keypadA.getKey();

                    if(but == '1') {
                        safeWire = 1;
                        but = '-';
                        statea = 2;
                    }
                    else if(but == '2') {
                        safeWire = 2;
                        but = '-';
                        statea = 2;
                    }
                    else if(but == '3') {
                        safeWire = 3;
                        but = '-';
                        statea = 2;
                    }
                    else if(but == '4') {
                        safeWire = 4;
                        but = '-';
                        statea = 2;
                    }
                    break;

                case 2:
                    lcd.setCursor(0, 0);
                    lcd.print("Disarm wire - ");
                    lcd.print(safeWire);
                    lcd.setCursor(0, 1);
                    lcd.print("*-Yes       #-No");

                    but = keypadA.getKey();

                    if (but == '#') {
                        statea = 1;
                        safeWire = 0;
                        but = NO_KEY;
                    }
                    else if (but == '*') {
                        statea = 5;
                        progState = 6;
                        but = NO_KEY;
                    }
                    break;
                }
            }
            else {
                progState = 6;
            }
            break;
        }
        break;

    //----------------------------------------------------------------------
    case 6:
        lcd.setCursor(0, 0);
        lcd.print("Remove prog key");
        lcd.setCursor(0, 1);
        lcd.print("     to arm    ");

        programed = true;
        statea = 1;
        i = 0;
        wireDis = false;
        keyDis = false;
        keypadDis = false;
        bang = false;
        break;
    }
}
Esempio n. 12
0
boolean RF22Mesh::recvfromAck(uint8_t* buf, uint8_t* len, uint8_t* source, uint8_t* dest, uint8_t* id, uint8_t* flags)
{     
    uint8_t tmpMessageLen = sizeof(_tmpMessage);
    uint8_t _source;
    uint8_t _dest;
    uint8_t _id;
    uint8_t _flags;
    uint8_t frags = 0;
    uint8_t offset = 0;
    uint8_t total_len = 0;
    uint8_t seq_no = 0;
    uint8_t x = 0, y = 0;
    uint8_t loop_once = 1;
    uint8_t have_message = 0;

    #ifndef CLIENT
    lcd.begin( 20, 4 );
    lcd.clear();
    #endif

    while( frags > 0 || loop_once == 1 ) {
        loop_once = 0;
        if (RF22Router::recvfromAck(_tmpMessage, &tmpMessageLen, &_source, &_dest, &_id, &_flags))
        {
            MeshMessageHeader* p = (MeshMessageHeader*)&_tmpMessage;

            if (   tmpMessageLen >= 1 
                && p->msgType == RF22_MESH_MESSAGE_TYPE_APPLICATION)
            {
                have_message = 1;

                MeshApplicationMessage* a = (MeshApplicationMessage*)p;
                // Handle application layer messages, presumably for our caller

                if (source) *source = _source;
                if (dest)   *dest   = _dest;
                if (id)     *id     = _id;
                if (flags)  *flags  = _flags;
                uint8_t msgLen = tmpMessageLen - sizeof(MeshMessageHeader);
                if (*len > msgLen)
                    *len = msgLen;

                frags = a->header.frag;
                #ifdef CLIENT
                Serial.print( F( "RF22Mesh::recvfromAck frags: " ) );
                Serial.println( frags );
                #endif



                seq_no = a->header.seqno;
                if( frags > 0 || (frags == 0 && a->header.seqno > 0 ) ) {
                    offset = a->header.seqno * RF22_MESH_MAX_MESSAGE_LEN;
                }

                #ifdef CLIENT
                for( int i = 0; i < *len; i++ ) {
                    Serial.print( a->data[i] );
                    Serial.print( F( ", " ) );
                }
                Serial.println( F( "" ) );
                #endif
                
                memcpy( buf + offset, a->data, *len );

                #ifndef CLIENT
                lcd.setCursor( x, y );
                lcd.print( *len );
                if( ( x + 8 ) > 20 ) {
                    y++;
                    x = 0;
                } else {
                    x += 4;
                }
                #endif

            }
            else if (   _dest == RF22_BROADCAST_ADDRESS 
                     && tmpMessageLen > 1 
                     && p->msgType == RF22_MESH_MESSAGE_TYPE_ROUTE_DISCOVERY_REQUEST)
            {
                MeshRouteDiscoveryMessage* d = (MeshRouteDiscoveryMessage*)p;
                // Handle Route discovery requests
                // Message is an array of node addresses the route request has already passed through
                // If it originally came from us, ignore it
                if (_source == _thisAddress)
                    return false;
                
                uint8_t numRoutes = tmpMessageLen - sizeof(MeshMessageHeader) - 2;
                uint8_t i;
                // Are we already mentioned?
                for (i = 0; i < numRoutes; i++)
                    if (d->route[i] == _thisAddress)
                        return false; // Already been through us. Discard
                
                // Hasnt been past us yet, record routes back to the earlier nodes
                addRouteTo(_source, headerFrom()); // The originator
                for (i = 0; i < numRoutes; i++)
                    addRouteTo(d->route[i], headerFrom());
                if (isPhysicalAddress(&d->dest, d->destlen))
                {
                    // This route discovery is for us. Unicast the whole route back to the originator
                    // as a RF22_MESH_MESSAGE_TYPE_ROUTE_DISCOVERY_RESPONSE
                    // We are certain to have a route there, becuase we just got it
                    d->header.msgType = RF22_MESH_MESSAGE_TYPE_ROUTE_DISCOVERY_RESPONSE;
                    RF22Router::sendtoWait((uint8_t*)d, tmpMessageLen, _source);
                }
                else if (i < _max_hops)
                {
                    // Its for someone else, rebroadcast it, after adding ourselves to the list
                    d->route[numRoutes] = _thisAddress;
                    tmpMessageLen++;
                    // Have to impersonate the source
                    // REVISIT: if this fails what can we do?
                    RF22Router::sendtoWait(_tmpMessage, tmpMessageLen, RF22_BROADCAST_ADDRESS, _source);
                }
            }
        } else if( frags == 0 ) {
            return false;
        } else {
            #ifdef CLIENT
            Serial.print( F( "corner case: frags: " ) );
            Serial.print( frags );
            Serial.print( F( "loop_once: " ) );
            Serial.println( loop_once );
            #endif
        }
    }

    if( have_message == 1 ) {
        *len = *len + ( seq_no * RF22_MESH_MAX_MESSAGE_LEN );

        #ifdef CLIENT
        Serial.print( F( "if have_message: frags: " ) );
        Serial.print( frags );
        Serial.print( F( "loop_once: " ) );
        Serial.println( loop_once );
        #endif

        #ifndef CLIENT
        lcd.setCursor( x, y );
        lcd.print( "t" );
        lcd.print( *len );
        #endif

        return true;
    } else {
        return false;
    }
}
Esempio n. 13
0
void loop() {
	lcd.print("Minutes: ");
	lcd.setCursor(0,1);
	lcd.blink();
	while (selectmin == true) {
		lcd_key = read_LCD_buttons();
		switch (lcd_key) {
			case btnRIGHT: 
				break;
			case btnLEFT: 
				break;
			case btnUP: {
				minutes = minutes + 1;
				lcd.setCursor(0,1);
				lcd.print(minutes);
				break;
			}
			case btnDOWN: {
				if (minutes > 0) {
					minutes = minutes - 1;
					lcd.setCursor(0,1);
					lcd.print(minutes);
				}
				break;
			}
			case btnSELECT: {
				selectmin = false;
				break;
			}
			case btnNONE: 
				break;			
		}
		delay(200); 
	}
	lcd.clear(); 
	delay(500);
	lcd.print("Seconds: ");
	lcd.setCursor(0,1);
	lcd.blink();
	while (selectsec == true) {
		lcd_key = read_LCD_buttons();
		switch (lcd_key) {
			case btnRIGHT: 
				break;
			case btnLEFT: 
				break;
			case btnUP: {
				if (seconds == 59) {
					seconds = 0;
				} else {
				seconds = seconds + 1;
				}
				lcd.setCursor(0,1);
				lcd.print(seconds);
				break;
			}
			case btnDOWN: {
				if (seconds > 0) {
					seconds = seconds - 1;
				} else if (seconds == 0) {
					seconds = 59;
				}
				lcd.setCursor(0,1);
				lcd.print(seconds);
				}
				break;
			}
			case btnSELECT: {
				selectsec = false;
				break;
			}
			case btnNONE: 
				break;			
		}
	}
Esempio n. 14
0
void setup() {
	lcd.begin(16, 2); 
	Serial.begin(9600);
}
// Prints a string to the LCD display, with an optional integer value beside it
inline void Print(String text, int value = -1) 
{
    lcd.print(text);
    if (value != -1) lcd.print(value);
}
Esempio n. 16
0
File: vis.cpp Progetto: emilio/gii-3
// Setup the out pins
void setup() {
  lcd.begin(16, 2);
  Serial.begin(115200);
  Serial.println("Setup");
  lcd.print("Hello, world!");
}
// Changes the LCD cursor location
inline void Cursor(int row, int column)
{
    lcd.setCursor(column, row);
}
Esempio n. 18
0
File: vis.cpp Progetto: emilio/gii-3
void loop() {
  Serial.println("Loop");
  lcd.setCursor(0, 0);
  lcd.print("Hello, world!");
  delay(1000);
}
Esempio n. 19
0
void setup()
{
	byte * ptr;

	Serial.begin(9600);
	Serial.println("Started");

	lcd.begin(16, 2);
	lcd.clear();
    
	//lcd.write( "DS1307 - Uhr" );
	//RTC.setRAM(0, (uint8_t *)&startAddr, sizeof(uint16_t));// Store startAddr in NV-RAM address 0x08

	/*
	 Uncomment the next 2 lines if you want to SET the clock
	 Comment them out if the clock is set.
	 DON'T ASK ME WHY: YOU MUST UPLOAD THE CODE TWICE TO LET HIM WORK
	 AFTER SETTING THE CLOCK ONCE.
	 */
//  TimeIsSet = 0xffff;
//  RTC.setRAM(54, (uint8_t *)&TimeIsSet, sizeof(uint16_t));
	/*
	 Control the clock.
	 Clock will only be set if NV-RAM Address does not contain 0xaa.
	 DS1307 should have a battery backup.
	 */
	//RTC.getRAM(54, (uint8_t *)&TimeIsSet, sizeof(uint16_t));
	//if (TimeIsSet != 0xaa55)
	//{
	//  RTC.stopClock();
	//
	//  RTC.fillByYMD(2011,4,8);
	//  RTC.fillByHMS(22,7,0);
	//
	//  RTC.setTime();
	//  TimeIsSet = 0xaa55;
	//  RTC.setRAM(54, (uint8_t *)&TimeIsSet, sizeof(uint16_t));
	//  RTC.startClock();
	//}
	//else
	//{
	if ( !RTC.isPresent() )
	{
		lcd.write("No clock detected");
	}

	RTC.getTime();
	//}

	/*
	 Control Register for SQW pin which can be used as an interrupt.
	 */
	RTC.ctrl = 0x00;                      // 0x00=disable SQW pin, 0x10=1Hz,
										  // 0x11=4096Hz, 0x12=8192Hz, 0x13=32768Hz
	RTC.setCTRL();

	uint8_t MESZ = RTC.isMEZSummerTime();

	mode = NORMAL_MODE;
	seconds = RTC.second;
	minutes = RTC.minute;
	hours = RTC.hour;
	position = POS_DAY;
	parts = 0;
	partsPerSec = 5;
	waitTime = 200;
	keyPressed = 0;
	feedIndex = 1;
	feedHour = 0;
	feedMinute = 0;
	feedCup = 0;
	displayTimeout = 0;
	remainingCups = 0;

	for (int i = 0; i < sizeof(feedTimes) / sizeof(feedTimes[0]); i++)
	{
		uint8_t addr;
		uint8_t * ptr = (uint8_t *) &feedTimes[i];

		switch (i)
		{
		case 0:
			addr = ADDR_TIME_ENTRY_1;
			break;
		case 1:
			addr = ADDR_TIME_ENTRY_2;
			break;
		case 2:
			addr = ADDR_TIME_ENTRY_3;
			break;
		case 3:
			addr = ADDR_TIME_ENTRY_4;
			break;
		default:
			break;
		}

		for (int x = 0; x < 4; x++)
		{
			uint8_t val = EEPROM.read(addr + x);

			if (val == 255)
			{
				val = 0;
			}

			ptr[x] = val;

			Serial.println ( itoa ( ptr[x], buffer, 10 ) );
		}
	}

	showFeedTime(1);

	pinMode(RELAIS_PIN, OUTPUT);
	pinMode(END_SWITCH_PIN, INPUT);
	digitalWrite(RELAIS_PIN, HIGH);
}
Esempio n. 20
0
boolean Arpege::ChangeS1S5(int value)
{
  boolean ret = false;
  if ( Menu->ChangeS1S5(value) )
  {
    if ( Menu->FirstPage )
    {  
      switch (Menu->S1S5)
      {
      case 1:
        is_mode_write = !is_mode_write;
        DessinPage();
        break;

      case 2:
        Mode = (Mode==MODE_SONG)? MODE_PATT : MODE_SONG;
        DessinPage();
        break;

      case 3 :
        if ( is_played == STOPPED  ) {
          ExStart(Mode==MODE_SONG);
          lcdM.setCursor(8,3);
          lcdM.print("Stop");
        }
        else
        {
          ExStop();
          lcdM.setCursor(8,3);
          lcdM.print("Play");
        }
        break;
      case 4:
        is_echo = !is_echo;
        DessinPage();
        break;
        
      }
    }        
    else
    {
      switch (Menu->S1S5)
      {
      case 3:
        switch( Menu->curCmd )
        {
        case 0:  /* copy */

          memcpy( &Tracks[Menu->V2-1], &Tracks[Menu->V1-1], sizeof (arpTrack) ) ;
          PatLed.Show(0);
          DessinPage();
          break;

        case 1:  /* Load */


          SPOut.AutoOff( ParamGlo.UpperDest );
          SPOut.AutoOff( ParamGlo.LowerDest );

          if ( MySD.OpenFileForRead(MODE_ARPEGE, Menu->GetFName(FileName) ) )
          {
            Restore();
            MySD.CloseFile();
          }
          PatLed.Show(0);
          DessinPage();
          break;

        case 2:  /* Save */

          if ( MySD.OpenFileForWrite(MODE_ARPEGE, Menu->MenuFName(FileName) ) )
          {
            Backup();
            MySD.CloseFile();
          }
          PatLed.Show(0);
          break;

        case 3:  /* Init */

          Init();
          PatLed.Show(0);
          DessinPage();
          UpdatePattern();
          break;
        }         
      }
    }
  }

  return ret;
}
Esempio n. 21
0
void hello() {
    lcd.setCursor(0, 0);
    lcd.print("hello, world!");
}
Esempio n. 22
0
void Arpege::TraiteEvent(uint32_t reftime)
{
  if (  cpt24==0 )  
  { 
    if ( ParamGlo.MidiInput->hNote.Version != mV_MIDI1 ) // Midi1 a changé 
    {
      mV_MIDI1 = ParamGlo.MidiInput->hNote.Version; 
      UpdatePattern();
    }


    if (is_played==PLAYED && reelLen)
    {
  
      if ( ActiFunc==NumFunc && Tracks[CurArp].Motif > 0 )  
      {
        PatLed.SetPatt( Tracks[CurArp].Pattern );
      }
  
  
      if ( is_played_Mode_Song )
      {
        if ( steep==0)
        {
          EventOff();
          nbSteep++;
          if ( nbSteep >= Songs[CurPlaySong].Repeat ) 
          {
            if ( Songs[CurPlaySong].Next > 0 ) {
              ChangeCurPlaySong( Songs[CurPlaySong].Next-1 );
              CurArp = Songs[CurPlaySong].Track-1;
              if ( ActiFunc == NumFunc && Menu->FirstPage) Menu->ShowM3(CurArp+1);
              UpdatePattern();
              NextArp=-1;
              PosTrack=0;
              nbSteep=0;
            }
            else { 
              ExStop();
              lcdM.setCursor(8,3);
              lcdM.print("Play");
            }
          }
  
        }    
      }
      else
      {
        if ( steep==0 && NextArp > -1 )
        {
          if ( IsOn ) EventOff();
          CurArp=NextArp;
          DessinPage();
          UpdatePattern();
          NextArp=-1;
          PosTrack=0;
        }    
      }
      if ( Tracks[CurArp].Motif == 0 || ( Tracks[CurArp].Motif == 1 && Pat[ steep ]  ) || ( Tracks[CurArp].Motif == 2 && ( Tracks[CurArp].Pattern & ( 1 << steep ) ) != 0  ))
      { 
        EventOn(PosTrack, reftime);
  
        if ( ActiFunc==NumFunc ) 
        {
          if ( Tracks[CurArp].Motif == 0 ) 
            PatLed.SetStep(PosTrack+1);
          else
            PatLed.SetStep(steep+1);
        }  
        PosTrack++;
  
        PosTrack %= reelLen;
      }   
      else
      {
        if ( ActiFunc==NumFunc && Tracks[CurArp].Motif > 0 )   PatLed.SetStep(steep+1);
      }  
  
      steep++;
      if ( Tracks[CurArp].Motif == 0 ) // Si pas motif on prend la longueur reel de l'arpege pour fin, sinon la longueur du motif 
        steep %= reelLen;
      else
        steep %= Tracks[CurArp].Lg;
    } 
    else
    {
      if ( ActiFunc==NumFunc && Tracks[CurArp].Motif > 0 )  
      {
        PatLed.SetPatt( Tracks[CurArp].Pattern );
      }
      else
      {
        if ( ActiFunc==NumFunc )  PatLed.SetStep(CurArp+1);
      }
    }
  }
  if (++cpt24>=nb24) cpt24=0;
}
Esempio n. 23
0
void counting() {
    lcd.setCursor(0, 1);
    // print the number of seconds since reset:
    lcd.print(millis()/1000);
}
Esempio n. 24
0
void Arpege::DessinPage()
{
  if (ActiFunc != NumFunc) return;

  int pos=CurArp;
  
  menuArp.Val_1 = ParamGlo.Tempo;
  menuArp.Val_2 = mesure;
  menuArp.Val_3 = CurArp+1;

  Menu->DessinPage();
  if ( Menu->FirstPage )
  {  
    if (is_played==PLAYED) {
      lcdM.setCursor(8,3);
      lcdM.print("Stop");
    }
    else
    {
      lcdM.setCursor(8,3);
      lcdM.print("Play");
    }

    if (is_mode_write) {
      lcdM.setCursor(0,3);
      lcdM.print("Ply");
    }
    else
    {
      lcdM.setCursor(0,3);
      lcdM.print("Drw");
    }

    if (Mode==MODE_PATT) {
      lcdM.setCursor(4,3);
      lcdM.print("Sng");
    }
    else
    {
      lcdM.setCursor(4,3);
      lcdM.print("Arp");
    }
    
    if (is_echo) {
      lcdM.setCursor(13,3);
      lcdM.print("-In");
    }
    else
    {
      lcdM.setCursor(13,3);
      lcdM.print("+In");
    }

  }
  Z_Clear();

  switch(Mode)
  {
  case MODE_PATT :

    sprintf(tmpCh,"\x02\Arpg %d",pos+1);
    Z_Titre(1,tmpCh);

    lcd_Liste(tmpVal,(char *)listDirection,Tracks[pos].Direction);
    Z_TextValue(2,"Evolu.",tmpVal);

    lcd_Num(tmpVal,Tracks[pos].Octave);
    Z_TextValue(3,"Octave",tmpVal);

    lcd_Liste(tmpVal,(char *)listNote,Tracks[pos].Note);
    Z_TextValue(4,"Note",tmpVal);

    lcd_Num(tmpVal,Tracks[pos].Duree);
    Z_TextValue(5,"Durati.",tmpVal);

    lcd_Liste(tmpVal,(char *)listVelmod,Tracks[pos].Velomod);
    Z_TextValue(6,"Vel Mod",tmpVal);

    lcd_Num(tmpVal,Tracks[pos].Veloci);
    Z_TextValue(7,"Velocit",tmpVal);

    lcd_Liste(tmpVal,(char *)listMotif,Tracks[pos].Motif);
    Z_TextValue(8,"Motif",tmpVal);

    lcd_Num(tmpVal,Tracks[pos].Lg);      
    Z_TextValue(9,"Steps",tmpVal);

    lcd_Num(tmpVal,Tracks[pos].Div);
    Z_TextValue(10,"Divide",tmpVal);
    /*
    lcd_Num(tmpVal,Tracks[pos].NMin);
     Z_TextValue(11,"Not.Min",tmpVal);
     
     lcd_Num(tmpVal,Tracks[pos].NMax);
     Z_TextValue(12,"Not.Max",tmpVal);
     */

    lcd_Liste(tmpVal,(char *)listOffOn,Tracks[pos].FillAuto);
    Z_TextValue(11,"AutoFil",tmpVal);

    lcd_NoteAbs(tmpVal,Tracks[pos].Tonale);
    Z_TextValue(12,"Dominan",tmpVal);

    lcd_Liste(tmpVal,(char *)listAccord,Tracks[pos].Accord);
    Z_TextValue(13,"Tonalit",tmpVal);

    lcd_Liste(tmpVal,(char *)listOffOnLock,Tracks[pos].Maintien);
    Z_TextValue(14,"Hold",tmpVal);

    lcd_Liste(tmpVal,(char *)listOffOn,Tracks[pos].Transpose);
    Z_TextValue(15,"Transpo",tmpVal);

    lcd_Liste(tmpVal,(char *)listMul,Tracks[pos].Modul);
    Z_TextValue(16,"Modula.",tmpVal);

    lcd_Num(tmpVal,Tracks[pos].Ampli);
    Z_TextValue(17,"M.Level",tmpVal);

    lcd_Liste(tmpVal,(char *)listDestin,Tracks[pos].Dest1);
    Z_TextValue(18,"Dest.1",tmpVal);

    lcd_Liste(tmpVal,(char *)listDestin,Tracks[pos].Dest2);
    Z_TextValue(19,"Dest.2",tmpVal);

    lcd_Num(tmpVal,Tracks[pos].Chanel);
    Z_TextValue(20,"Channel",tmpVal);

    break;


  case MODE_SONG :



    for (pos=0;pos<5;pos++)
    {

      if ( pos+CurTrSong == CurPlaySong )
        lcd1.Carac(pos*8,0,2);
      else
        if ( pos > 0 )            
          lcd1.Carac(pos*8,0,6);
        else
          lcd1.Carac(0,0,32);

      sprintf(tmpCh,"Song %d",pos+CurTrSong+1);
      Z_Text(pos+1,tmpCh);


      lcd_Num(tmpVal,Songs[pos+CurTrSong].Track);
      Z_Value(pos+1,tmpVal);

      lcd_Num(tmpVal,Songs[pos+CurTrSong].Repeat);
      Z_TextValue(pos+6,"Repeat",tmpVal);

      lcd_Num(tmpVal,Songs[pos+CurTrSong].Transpose);
      Z_TextValue(pos+11,"Transp.",tmpVal);

      if ( Songs[pos+CurTrSong].Next == 0)
        sprintf(tmpVal,"Stop");
      else
        lcd_Num(tmpVal,Songs[pos+CurTrSong].Next);
      Z_TextValue(pos+16,"Next",tmpVal);

    }
    break;

  }    

}
Esempio n. 25
0
void EventBusRx(uint8_t uPort, uint8_t uCmd, uint8_t* uuData, uint8_t uLength) 
{
	oLcd.clear();
	delay(1000);
	oLcd.setCursor(0, 0);
	oLcd.print("PORT: ");
	oLcd.print((int) uPort);
	delay(500);
	oLcd.setCursor(0, 1);
	oLcd.print("CMD: ");					
	oLcd.print((int) uCmd);
	delay(500);
	


	switch (uPort)
	{
		case LCD_PORT:
			switch (uCmd)
			{
				case LCD_CMD_CLEAR:
					oLcd.clear();
					break;
				case LCD_CMD_VERS:
					oLcd.clear();
					oLcd.setCursor(0, 0);
					oLcd.print("KUI-team (c)");
					delay(1000);
					oLcd.setCursor(0, 1);
					oLcd.print("Ver. 1.0");					
					delay(100);
					break;
				case LCD_CMD_PRINT:
					oLcd.clear();
					oLcd.setCursor(0, 0);
					for(uint8_t n = 0; n < uLength; n++)
						oLcd.print((char) uuData[n]);					
					break;
			}
	}
}
Esempio n. 26
0
void loop(){
  lcd.setCursor(0,0);
  lcd.print("I'm waiting for");
  lcd.setCursor(0,1);
  lcd.print("a card to read");
  

  val = 0;
  bytesread = 0;
  int readyToRead = 0;
  boolean valid_card = false;
/*========================================
  read 12 digit code
  ========================================*/
  
  while(bytesread < 12)
  {
      val = RFID.read();
      if(val == 3)
          { // if header or stop bytes before the 10 digit reading
            break; // stop reading
          }
          
      if(val != 2)
          {
            code[bytesread] = val; // add the digit
            bytesread++; // ready to read next digit
            code[bytesread] = '\0'; // add the NULL
            if(val != -1)
             {
               readyToRead++;
             }
          }
  }

  String readed_tag = code;    // Maintenant on a une chaine de caractère plus facile à tester
  delay(3000);
  
/*========================================
  Si un RFID tag est détécté, on le teste
  ========================================*/
  
  if(bytesread >= 12 && readyToRead == 12){
      // if 12 digit read is complete
      Serial.print("Tag: [");
      for(int i=0; code[i]!='\0' ; i++)
        {
          Serial.print(code[i]);
        }
      Serial.println("]"); //print the whole 13 bytes
      Serial.println(readed_tag);
  }
  
  if(readed_tag == master_tag){
      //    Valid_card = true;
      Serial.println("ok master Tag reconnu -------------!!!!");
      lcd.clear();
      lcd.print("MASTER CARD !!!!");
      lcd.setCursor(0,1);
      lcd.print(readed_tag);
      delay(1000);
    }
  
  for( int i = 0 ; i < ARR_LEN ; i++ ){
      if( readed_tag == target_tag[i] ){
         //     Valid_card = true;
        lcd.clear();
        lcd.print("card ID ok");
        lcd.setCursor(0,1);
        lcd.print(readed_tag);
        delay( 1000 );
        break;
      }
//  if(valid_card != true ) {
//      lcd.clear();
//      lcd.print("AU VOLEUR!!!");
//      lcd.setCursor(0,1);
//      lcd.print("LA CARTE EST FAUSSE!!");
//      delay( 1000 );
//    }
  }
  delay(100);
  lcd.clear();


}
Esempio n. 27
0
void printError(char *msg) {
  lcd.print('**** ERROR ****');
  lcd.setCursor(0, 1);
  lcd.print(msg);
}
// Clears the LCD screen
inline void Clear()
{
    lcd.clear();
}
Esempio n. 29
0
void loop() {
  
  //Start timer, this is used to lift and lower the drill.
  timer.run();
  
  // send data only when you receive data:
	if (Serial.available() > 0) {
		// read the incoming byte:
		incomingString = Serial.read();
                
				// If incoming is "q"
                if (incomingString == 101){
                  dirA = 'F';
                  dirB = 'F';
                }
				// If incoming is "e"
                else if (incomingString == 113){
                  dirA = 'F';
                  dirB = 'R';
                }
				// If incoming is "w"
                else if (incomingString == 119){
                  dirA = 'F';
                  dirB = 'N';
                }
				// If incoming is "z"
                else if (incomingString == 99){
                  dirA = 'R';
                  dirB = 'F';
                }
				// If incoming is "c"
                else if (incomingString == 122){
                  dirA = 'R';
                  dirB = 'R';
                }
				// If incoming is "x"
                else if (incomingString == 120){
                  dirA = 'R';
                  dirB = 'N';
                }
				// If incoming is "a"
                else if (incomingString == 100){
                  dirA = 'N';
                  dirB = 'F';
                }
				// If incoming is "d"
                else if (incomingString == 97){
                  dirA = 'N';
                  dirB = 'R';
                }
				// If incoming is "s"
                else if (incomingString == 115){
                  dirA = 'N';
                  dirB = 'N';
                }
				// If incoming is "r"
                else if (incomingString == 114){
                  ResetCoords();
                  dirA = 'N';
                  dirB = 'N';
                }
				// If incoming is "f"
                else if (incomingString == 102){
                  LiftDrill();
                  Serial.print("Drill is up");
                  Serial.print("\n");
                  dirA = 'N';
                  dirB = 'N';
                }
				// If incoming is "v"
                else if (incomingString == 118){
                  LowerDrill();
                  Serial.print("Drill is down");
                  Serial.print("\n");
                  dirA = 'N';
                  dirB = 'N';
                }

				//Calculate steps according to selected direction and last step
                Step(dirA, dirB);
				//Write data to ShiftRegister
                WriteData(Output);
                
				//Write coordinates to LCD
                outgoingString = "";
                outgoingString = outgoingString + "X: ";
                outgoingString = outgoingString + CoordX;
                outgoingString = outgoingString + "   Y: ";
                outgoingString = outgoingString + CoordY;
                //Write coordintes to Serial port
                Serial.print("Position");
                Serial.print(outgoingString);
                Serial.print("\n");
                Serial.print("\n");
	}

  // LCD Part of code
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print("X: ");
  lcd.setCursor(3, 1);
  lcd.print(CoordX);
  lcd.setCursor(8, 1);
  lcd.print("Y: ");
  lcd.setCursor(11, 1);
  lcd.print(CoordY);
}
Esempio n. 30
0
int mealSelect(void)
{
  byte tempCounter = 0;
  for (int i = 0; i < 16; i++)
  {
    if (option0[i] || option1[i] || option2[i])
    {
      tempCounter++;
    }
  }
  if (!tempCounter)
  {
    lcd.clear();
    lcd.print("No response...");
    delay(1000);
    return 100;
  }
  char currentSelect = 0;
  lcd.clear();
  lcd.print("Select a meal");
  for (int positionCounter = 0; positionCounter < 5; positionCounter++)
  {
    lcd.scrollDisplayLeft(); 
    lcd.scrollDisplayLeft(); 
    lcd.scrollDisplayLeft(); 
    delay(500);
  }
  while(1)
  {
    if (currentSelect < 0)
    {
      currentSelect = 0;
    }
    if (currentSelect > 2)
    {
      currentSelect = 2;
    }
    switch (currentSelect)
    {
    case 0:
      {
        lcd.print(option0);
        break;
      }
    case 1:
      {
        lcd.print(option1);
        break;
      }
    case 2:
      {
        lcd.print(option2);
        break;
      }
    default:
      break; //shouldnt get here
    }
    char response = buttonCtl();
    delay(250);
    switch (response)
    {
    case 0:
      {
        currentSelect--;
        lcd.clear();
        break;
      }
    case 1:
      {
        currentSelect++;
        lcd.clear();
        break;
      }
    case 2:
      {
        lcd.clear();
        return currentSelect;
        break;
      }
    default:
      {
        break; //shoudlnt get here
      }
    }
  }
}