Browse Source

LCD Darstellung geaendert, jetzt alle 100ms refresh der 6 Zeilen

master
Yves Ehrlich 5 years ago
parent
commit
80eb9f8ab4
  1. 2
      .~lock.ideen_mechanik_und_elektronik.odt#
  2. 15
      Code/miniRobotRC/fahrsteuerung_old.ino
  3. 5
      Code/miniRobotRC/interruptRoutinen.ino
  4. 36
      Code/miniRobotRC/joystick.ino
  5. 33
      Code/miniRobotRC/miniRobotRC.ino
  6. BIN
      ideen_mechanik_und_elektronik.odt

2
.~lock.ideen_mechanik_und_elektronik.odt#

@ -1 +1 @@
,yves,yves-UB,05.02.2020 13:15,file:///home/yves/.config/libreoffice/4;
,yves,yves-UB,05.02.2020 13:51,file:///home/yves/.config/libreoffice/4;

15
Code/miniRobotRC/fahrsteuerung_old.ino

@ -3,35 +3,30 @@ void manualDigitalDrive() {
// while(!tasten.getButtonCycle(buttonL1)) {
clearCommands();
if(!tasten.getAnyPressed()) {
lcd.clear();
lcd.println("Warte...");
lcdLines[0] = "Warte...";
}
if(tasten.checkButton(buttonB) || tasten.checkButton(buttonUp)) {
pwmA = -215;
pwmB = -255;
lcd.clear();
lcd.println("geradeaus fahren");
lcdLines[0] = "geradeaus fahren";
goOn =true;
}
if(tasten.checkButton(buttonC) || tasten.checkButton(buttonDown)) {
pwmA = 100;
pwmB = 255;
lcd.clear();
lcd.println("rueckwaerts fahren");
lcdLines[0] = "rueckwaerts fahren";
goOn =true;
}
if(tasten.checkButton(buttonRight)) {
pwmA = -100; //rechter Motor
pwmB = 100;
lcd.clear();
lcd.println("rechts lenken");
lcdLines[0] = "rechts lenken";
goOn =true;
}
if(tasten.checkButton(buttonLeft)) {
pwmB = -100;
pwmA = 100;
lcd.clear();
lcd.println("links lenken");
lcdLines[0] = "links lenken";
goOn =true;
}
if(goOn) {

5
Code/miniRobotRC/interruptRoutinen.ino

@ -3,6 +3,11 @@ ISR(TIMER2_COMPA_vect) {
tasten.checkButtons();
renderTime++;
if(renderTime >= renderTimeout) {
lcd.clear();
for(uint8_t i = 0; i < sizeof(lcdLines); i++) {
lcd.gotoXY(0, i);
lcd.print(lcdLines[i]);
}
lcd.renderAll();
renderTime = 0;
}

36
Code/miniRobotRC/joystick.ino

@ -10,28 +10,8 @@ volatile int16_t yValue = 0;
volatile int16_t leftPWM = 0;
volatile int16_t rightPWM = 0;
const int16_t deadZone = 10;
/*
void setup() {
Serial.begin(115200);
}
void loop() {
koordinaten(analogRead(xPin), analogRead(yPin));
motorPWM();
Serial.print("X: ");
Serial.println(xValue);
Serial.print("Y: ");
Serial.println(yValue);
Serial.print("links: ");
Serial.println(leftPWM);
Serial.print("rechts: ");
Serial.println(rightPWM);
delay(200);
const int16_t deadZone = 40;
}
*/
void motorMapping() {
static long temp = millis();
koordinaten(analogRead(xPin), analogRead(yPin));
@ -40,12 +20,14 @@ void motorMapping() {
pwmB = map(leftPWM, -255,255,leftMin,leftMax);
pwmA = map(rightPWM, -255,255,rightMin,rightMax);
if((millis() - temp) > 100) {
lcd.clear();
lcd.println("Links: ");
lcd.println(pwmB);
lcd.gotoXY(0,2);
lcd.println("Rechts: ");
lcd.println(pwmA);
// lcd.clear();
// lcd.println("Links: ");
lcdLines[0] = "Links: " + String(pwmB, DEC);
// lcd.println(pwmB);
// lcd.gotoXY(0,2);
// lcd.println("Rechts: ");
lcdLines[0] = "Rechts: " + String(pwmA, DEC);
// lcd.println(pwmA);
}
senden();

33
Code/miniRobotRC/miniRobotRC.ino

@ -4,7 +4,7 @@
#define CLR_BIT(p,n) ((p) &= ~((1) << (n)))
#define SET_BIT(p,n) ((p) |= (1 << (n)))
//Pinzuordnungen
#define BL 10 //backlight, Hintergrundbeleuchtung LCD
#define SD_CARD_CS 2 //D2 ist Chip Enable
#define BAT_VOLTAGE A7 //Akkuspannung an A7
@ -17,7 +17,8 @@ volatile myInterrupts pwmBL;
volatile shiftRegButton tasten;
//LCD
uint8_t renderTime = 0;
#define renderTimeout 100
#define renderTimeout 100 //es wird alle 100ms gerendert
String lcdLines[6]; //Strings welche alle 100ms ausgegeben werden
//Kommandos
#define nothing 9 //reset/nichts tun
@ -31,15 +32,15 @@ uint8_t renderTime = 0;
#define timeToDrive 8 //Zeitdauer des fahrens
#define getDistance 10 //Abstand zu Objekten
int pwmA = 0;
int pwmB = 0;
int16_t pwmA = 0;
int16_t pwmB = 0;
bool forwardA = true;
bool forwardB = true;
bool driveOn = false;
uint16_t driveTimeout = 0;
int distance;
int temperature;
int16_t distance;
int16_t temperature;
//Funk
#include <SPI.h>
@ -51,23 +52,3 @@ RF24 radio(A2, A3); // CE, CSN
const byte address[6] = "00001";
uint8_t commands[32];
/*
const String mainMenu[] = {
"fahren", //0
"stoppen", //1
"manuell fahren", //2
"", //3
"", //4
"", //5
"", //6
"", //7
"", //8
"" //9
};
const String subMenuEntry0[] = {
"Zeitdauer",
"Speed A",
"Speed B",
"Starten"
}; */

BIN
ideen_mechanik_und_elektronik.odt

Loading…
Cancel
Save