- Labornetzteil AliExpress    Werbung      
Ergebnis 1 bis 4 von 4

Thema: RP6Control M32: Conway's Game Of Life

Hybrid-Darstellung

Vorheriger Beitrag Vorheriger Beitrag   Nächster Beitrag Nächster Beitrag
  1. #1
    Moderator Robotik Visionär Avatar von radbruch
    Registriert seit
    27.12.2006
    Ort
    Stuttgart
    Alter
    63
    Beiträge
    5.799
    Das wäre auch eine gute Anwendung für ZOC. Stehendes Bild und Farben als Ersatz für den Loader::
    https://www.roboternetz.de/community...-f%FCr-den-RP6
    Bild  
    Atmel’s products are not intended, authorized, or warranted for use
    as components in applications intended to support or sustain life!

  2. #2
    Erfahrener Benutzer Roboter-Spezialist Avatar von RolfD
    Registriert seit
    07.02.2011
    Beiträge
    414
    Jetzt fehlt nur noch Eliza *laaach

    Für die jüngeren:
    http://de.wikipedia.org/wiki/ELIZA
    Sind Sie auch ambivalent?

  3. #3
    Erfahrener Benutzer Robotik Einstein Avatar von Dirk
    Registriert seit
    30.04.2004
    Ort
    NRW
    Beiträge
    3.803
    Jetzt fehlt nur noch Eliza *laaach
    Wie wär's mit einem kleinen Psychiater?
    Code:
    /* 
     * ****************************************************************************
     * RP6 ROBOT SYSTEM - RP6 CONTROL M32 TESTS
     * ****************************************************************************
     * Example: Doc Z
     * Author(s): Dirk
     * ****************************************************************************
     * Description:
     * This program for RP6 Control is a simple "electronic psychiatrist".
     * It asks questions (German language) and gives you an advice in the end.
     * Years ago a similar BASIC program was "Dr.Z" (K. Menzel, 1984).
     *
     * ############################################################################
     * The Robot does NOT move in this example! You can simply put it on a table
     * next to your PC and you should connect it to the PC via the USB Interface!
     * ############################################################################
     * ****************************************************************************
     */
    /*****************************************************************************/
    // Includes:
    #include "RP6ControlLib.h"   // The RP6 Control Library (1.3beta or higher). 
            // Always needs to be included!
    /*****************************************************************************/
    // Defines:
    #define MAX_TEXTNO 12   // Number of prepared questions in psyTexts()
    #define QUESTIONS 8   // Number of asked questions
    /*****************************************************************************/
    // Variables:
    // Reception buffer for the function getInputLine():
    char receiveBuffer[UART_RECEIVE_BUFFER_SIZE + 1];
    char username[UART_RECEIVE_BUFFER_SIZE + 1];
    uint8_t i, rnd, rnd1, rnd2;
    /*****************************************************************************/
    // Functions:
    // UART receive functions:
    /**
     * Get chars of an input line from the UART.
     *
     * Returns 0 (false), if the UART receive buffer is empty
     * OR a character of the input line has been received.
     * Returns 1, if the whole input line has been received
     * (with a "new line" character at the end).
     * Returns 2, if the UART receive buffer overflows.
     * The input line is stored in the receiveBuffer array.
     *
     */
    uint8_t getInputLine(void)
    {static uint8_t buffer_pos = 0;
     if(getBufferLength()) { 
      receiveBuffer[buffer_pos] = readChar();
      if(receiveBuffer[buffer_pos] == '\n') {
       receiveBuffer[buffer_pos] = '\0';
       buffer_pos = 0;
       return 1;
      }
      else if(buffer_pos >= UART_RECEIVE_BUFFER_SIZE) {
       receiveBuffer[UART_RECEIVE_BUFFER_SIZE] = '\0'; 
       buffer_pos = 0;
       return 2;
      }
      buffer_pos++;
     }
     return 0;
    }
    /**
     * Get a complete input line from the UART.
     *
     * This function waits for a whole input line from the UART.
     * The input line is stored in the receiveBuffer array.
     * The function is blocking until one of the two following
     * conditions occurs:
     * - A "new line" character has been received at the end of
     *   the input line.
     * - The UART receive buffer overflows.
     *
     */
    void enterString(void)
    {
     while(!getInputLine());
    }
    /**
     * GET SEED
     *
     * Gets a starting value for srand().
     *
     */
    uint16_t get_seed(void)
    {
     uint16_t seed = 0;
     uint16_t *p = (uint16_t*) (RAMEND + 1);
     extern uint16_t __heap_start;
     while (p >= &__heap_start + 1)
      seed ^= * (--p);
     return seed;
    }
    /**
     * PSY TEXTS
     *
     * Shows one of MAX_TEXTNO questions that the "psychiatrist" asks.
     *
     */
    void psyTexts(uint8_t textno)
    {
     switch (textno) {
      case 1 :
       writeString_P("Erzähl mir mehr!\n");
       break;
      case 2 :
       writeString_P("Fühlst du das schon lange?\n");
       break;
      case 3 :
       writeString_P("Denkst du, das ist vernünftig?\n");
       break;
      case 4 :
       writeString_P("Würden deine Freunde das glauben?\n");
       break;
      case 5 :
       writeString_P("Kannst du damit leben?\n");
       break;
      case 6 :
       writeString_P("Glaubst du, das ist normal?\n");
       break;
      case 7 :
       writeString_P("Was könnte der Grund sein?\n");
       break;
      case 8 :
       writeString_P("Hast du schon darüber gesprochen?\n");
       break;
      case 9 :
       writeString_P("Bist du manchmal ängstlich?\n");
       break;
      case 10 :
       writeString_P("Bist du oft unzufrieden?\n");
       break;
      case 11 :
       writeString_P("Schläfst du gut?\n");
       break;
      case 12 :
       writeString_P("Bist du häufig enttäuscht?\n");
       break;
    //  case 13 :
    //   writeString_P("...?\n");
    //   break;
     }
    }
    /*****************************************************************************/
    // Main function - The program starts here:
    int main(void)
    {
     initRP6Control(); // Always call this first! The Processor will not work
           // correctly otherwise. 
     initLCD(); // Initialize the LC-Display (LCD)
          // Always call this before using the LCD!
     // Write some text messages to the UART - just like on RP6Base:
     writeString_P("\n\n   _______________________\n");
     writeString_P("   \\| RP6  ROBOT SYSTEM |/\n");
     writeString_P("    \\_-_-_-_-_-_-_-_-_-_/\n\n");
     writeString_P("Doc Z for RP6 CONTROL!\n"); 
     // Set the four Status LEDs:
     setLEDs(0b1111);
     mSleep(500);
     setLEDs(0b0000);
     showScreenLCD("################", "################");
     mSleep(1500);
     showScreenLCD("<<RP6  Control>>", "<<LC - DISPLAY>>");
     mSleep(2500); 
     showScreenLCD("     Doc Z      ", "  ************  ");
     mSleep(2500);
     clearLCD(); // Clear the whole LCD Screen
     // Play four sounds with the Piezo Beeper on the RP6Control:
     sound(Tone_Cis2, 300, 200);
     sound(Tone_Fis2, 200, 100);
     sound(Tone_Ais2, 100, 100);
     sound(Tone_Dis3, 50, 100);
     writeString_P("\nGuten Tag, ich bin der RP6 Psychiater.\n");
     writeString_P("Wie ist dein Name?\n");
     clearReceptionBuffer(); // Make sure reception Buffer is empty.
     enterString();
     for (i = 0; i <= UART_RECEIVE_BUFFER_SIZE; i++) {
      username[i] = receiveBuffer[i];
     }
     writeString_P("Wie fühlst du dich, ");
     writeString(username);  // Output the user's name as a String
     writeString_P("?\n");
     enterString();
     srand(get_seed());
     for (i = 1; i <= QUESTIONS; i++) {  // Ask QUESTIONS questions
      do {rnd = (rand() % MAX_TEXTNO + 1);} // rnd = [0..MAX_TEXTNO]
      while((rnd == rnd2) || (rnd == rnd1));
      rnd2 = rnd1;      // Don't repeat questions to fast
      rnd1 = rnd;
      psyTexts(rnd);      // Ask a random question
      enterString();      // Get the answer
     }
     mSleep(1500);
     writeString_P("\nIch denke, du machst gute Fortschritte\n");
     writeString_P("bei der Lösung deiner Probleme, ");
     writeString(username);
     writeString_P(".\n\n");
     writeString_P("Bis zum nächsten Mal.\n");
     while(true) {}
     return 0;
    }
    /******************************************************************************
     * Additional info
     * ****************************************************************************
     * Changelog:
     * - v. 1.0 (initial release) 02.05.2011 by Dirk
     *
     * ****************************************************************************
     */
    /*****************************************************************************/
    Schäääm ...
    Gruß
    Dirk

Ähnliche Themen

  1. Conway's Game of Life auf einem ATmega32
    Von Torrentula im Forum C - Programmierung (GCC u.a.)
    Antworten: 17
    Letzter Beitrag: 18.11.2011, 09:38
  2. Game Boy Camera an AVR -- Ein paar Fragen zur Hardware
    Von Christoph2 im Forum AVR Hardwarethemen
    Antworten: 31
    Letzter Beitrag: 26.05.2009, 21:45
  3. Game Boy Kamera
    Von moud im Forum Sensoren / Sensorik
    Antworten: 6
    Letzter Beitrag: 20.04.2005, 18:52
  4. Hat jemand Erfahrung mit der Game Boy Kamera?
    Von discostu im Forum Sensoren / Sensorik
    Antworten: 35
    Letzter Beitrag: 04.04.2005, 19:24
  5. Game Boy Programmieren ?
    Von khazad im Forum Allgemeines zum Thema Roboter / Modellbau
    Antworten: 4
    Letzter Beitrag: 30.11.2004, 20:05

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •  

    Werbung      fchao-Sinus-Wechselrichter AliExpress