Hallo Patrick,
ich habe mal ein kleines Programm angehängt, was NUR die Texteingabe im WIFI-Terminal und die Ausgabe auf dem LCD zeigt.
Code:
/*
* ****************************************************************************
* RP6 ROBOT SYSTEM - RP6 CONTROL M256 Examples
* ****************************************************************************
* Example: WIFI Input Example
* Author(s): Dirk
* ****************************************************************************
* Description:
* With this program you may test the text input function of the RobotLoader
* WIFI terminal. If you enter a test string (max. 16 characters), this string
* is displayed on line 1 of the LCD.
* There is a bug in RobotLoader 2.3c: If you enter upper case letters in the
* WIFI terminal, they are received via WIFI as lower case letters!
*
* ############################################################################
* 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!
* You should also connect to it via WIFI.
* ############################################################################
* ****************************************************************************
*/
/*****************************************************************************/
// Includes:
#include "RP6M256Lib.h" // The RP6 M256 Library.
// Always needs to be included!
/*****************************************************************************/
// Variables:
// Reception buffer for the function getInputLine_WIFI():
char receiveBufferWifi[UART_RECEIVE_BUFFER_SIZE_WIFI + 1];
/*****************************************************************************/
// WIFI receive functions:
/**
* Get chars of an input line from the WIFI.
*
* Returns 0 (false), if the WIFI 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 WIFI receive buffer overflows.
* The input line is stored in the receiveBufferWifi array.
*
*/
uint8_t getInputLine_WIFI(void)
{static uint16_t buffer_pos = 0;
if(getBufferLength_WIFI()) {
receiveBufferWifi[buffer_pos] = readChar_WIFI();
if((receiveBufferWifi[buffer_pos] == '\n')
|| (receiveBufferWifi[buffer_pos] == '\r')) {
receiveBufferWifi[buffer_pos] = '\0';
buffer_pos = 0;
return 1;
}
else if(buffer_pos >= UART_RECEIVE_BUFFER_SIZE_WIFI) {
receiveBufferWifi[UART_RECEIVE_BUFFER_SIZE_WIFI] = '\0';
buffer_pos = 0;
return 2;
}
buffer_pos++;
}
return 0;
}
/**
* Get a complete input line from the WIFI.
*
* This function waits for a whole input line from the WIFI.
* The input line is stored in the receiveBufferWifi 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 WIFI receive buffer overflows.
*
*/
void enterString_WIFI(void)
{
while(!getInputLine_WIFI());
}
/*****************************************************************************/
// Main function - The program starts here:
int main(void)
{
initRP6M256(); // Always call this first! The Processor will not work
// correctly otherwise.
initLCD(); // Initialize the LC-Display (LCD)
// Always call this before using the LCD!
setLEDs(0b0000);
clearLCD(); // Clear the whole LCD Screen
/*****************************************************************************/
// Main test program:
while(true)
{
writeString_P_WIFI("\n\n");
writeString_P_WIFI("\n|============================|");
writeString_P_WIFI("\n| WIFI: Input a test string |");
writeString_P_WIFI("\n| (max. 16 characters) |\n");
enterString_WIFI();
// Show the test string on line 1 of the LCD:
clearLCD();
writeStringLCD(receiveBufferWifi);
mSleep(10000);
writeString_P_WIFI("\n\n");
}
/*****************************************************************************/
// End of main:
return 0;
}
Jetzt klarer?
Lesezeichen