Oje, langsam wird's zäh. Versuche mal das:
PHP-Code:
#include "stdlib.h"
#include "asuro.h"
#include "lcd.h"
#include "i2c.h"
int o = 1;
//Geschwindigkeit
int speed = 100;
void start(void)
{
int keys;
int i = 1;
while(i)
{
keys = PollSwitchLCD();
if(!keys)
{
Msleep(100);
}
else
{
switch(keys)
{
case LCD_KEY_YELLOW:
if(speed < 246) speed = speed +10;
break;
case LCD_KEY_BLUE:
if(speed > 9) speed = speed -10;
break;
case LCD_KEY_RED:
i = 0;
break;
}
ClearLCD();
PrintSetLCD(0,0,"Geschwindigkeit");
SetCursorLCD(0, 1);
PrintIntLCD(speed);
}
}
o--;
}
//Hauptprogramm
int main(void)
{
Init();
InitI2C();
InitLCD();
GREEN_LED_ON;
while(o > 0)
{
PrintSetLCD(0,0,"Geschwindigkeit");
SetCursorLCD(0, 1);
PrintIntLCD(speed);
start();
}
MotorDir(FWD,FWD);
MotorSpeed(speed,speed);
while(1); // Das Programm darf nie beendet werden!
return 0;
}
Nicht getestet, aber mit diesen Dummy-Files fehlerfrei übersetzt:
lcd.h:
PHP-Code:
#define LCD_KEY_YELLOW 1
#define LCD_KEY_BLUE 2
#define LCD_KEY_RED 4
void InitLCD(void);
int PollSwitchLCD(void);
void ClearLCD(void);
void SetCursorLCD(unsigned char colum, unsigned char line);
void PrintIntLCD(int i);
void PrintSetLCD(unsigned char colum, unsigned char line, char *data);
void InitI2C(void);
lcd.c
PHP-Code:
#define LCD_KEY_YELLOW 1
#define LCD_KEY_BLUE 2
#define LCD_KEY_RED 4
void InitLCD(void){}
int PollSwitchLCD(void){return(0);}
void ClearLCD(void){}
void SetCursorLCD(unsigned char colum, unsigned char line){}
void PrintIntLCD(int i){}
void PrintSetLCD(unsigned char colum, unsigned char line, char *data){}
void InitI2C(void){}
Lesezeichen