3 Commits

Author SHA1 Message Date
Yves Ehrlich 7f77bde5c6 Code bereinigt 5 years ago
Yves Ehrlich ed28dc5065 Merge branch 'master' of https://gogs.informatik.hs-fulda.de/codeisnotevil/Roboter 5 years ago
Yves Ehrlich 64e7a371b7 Code bereinigt 5 years ago
  1. 22
      Code/miniRobot/miniRobot.ino
  2. 15
      Code/miniRobotRC/JoystickSteuerung.ino
  3. 2
      Code/miniRobotRC/_main.ino
  4. 10
      Code/miniRobotRC/interruptRoutinen.ino
  5. 6
      Code/miniRobotRC/joystick.ino
  6. 2
      Code/miniRobotRC/remoteControlInit.ino
  7. 5
      Code/miniRobotRC/temp.ino

22
Code/miniRobot/miniRobot.ino

@ -37,21 +37,9 @@ const byte address2[6] = "00002";
#define getDistance 10 //Abstand zu Objekten #define getDistance 10 //Abstand zu Objekten
//Motortreiber //Motortreiber
//#include <MX1508.h>
#include <L298N.h> #include <L298N.h>
#define BEEP 14
/*
#define PWM_PINA 10
#define PINA 8
#define PWM_PINB 9
#define PINB 7
#define NUMPWM 1
#define RESOLUTION 255 */
//MX1508 motorA(PWM_PINA,PINA, FAST_DECAY, NUMPWM);
//MX1508 motorB(PWM_PINB,PINB, FAST_DECAY, NUMPWM);
#define BEEP 14 //Motoren drehen bei diesem PWM Wert nicht, aber fiepen
L298N drive; L298N drive;
@ -61,8 +49,8 @@ bool forwardA = true;
bool forwardB = true; bool forwardB = true;
volatile bool driveOn = false; volatile bool driveOn = false;
volatile long driveTimeout = 0;
volatile long driveTimeDiff = 0;
volatile uint32_t driveTimeout = 0;
volatile uint32_t driveTimeDiff = 0;
volatile bool startNewMeasurement = true; volatile bool startNewMeasurement = true;
@ -106,7 +94,7 @@ void loop() {
// Serial.println("berechnen"); // Serial.println("berechnen");
distance = calculateDistance(); distance = calculateDistance();
} }
//wurden Kommandos empfangen?
if (radio.available()) { if (radio.available()) {
radio.read(&commands, sizeof(commands)); radio.read(&commands, sizeof(commands));
commandInterpretation(); commandInterpretation();
@ -182,7 +170,7 @@ void commandInterpretation() {
uint16_t driveTime = 0; uint16_t driveTime = 0;
driveTime = (0xFF00 & (commands[i+1] << 8)); driveTime = (0xFF00 & (commands[i+1] << 8));
driveTime |= (0x00FF & commands[i+2]); driveTime |= (0x00FF & commands[i+2]);
driveTimeout = (long)driveTime;
driveTimeout = (uint32_t)driveTime;
driveTimeDiff = millis(); driveTimeDiff = millis();
//Serial.println(driveTimeout); //Serial.println(driveTimeout);
break; break;

15
Code/miniRobotRC/JoystickSteuerung.ino

@ -44,21 +44,6 @@ void joystickInit() {
void showValuesOnLCD(){ void showValuesOnLCD(){
//TODO BUILD STRING //TODO BUILD STRING
//lcd.clear();
/*lcd.gotoXY(0,0);
lcd.print(" ");
lcd.gotoXY(0,0);
lcd.print("WithLib");
lcd.gotoXY(0,1);
lcd.print(" ");
lcd.gotoXY(0,1);
lcd.print("LeftPWM: ");
lcd.print(left -> PWMValue);
lcd.gotoXY(0,2);
lcd.print(" ");
lcd.gotoXY(0,2);
lcd.print("RightPWM: ");
lcd.print(right -> PWMValue);*/
lcdLines[0] = "Links: " + String(left -> PWMValue, DEC); lcdLines[0] = "Links: " + String(left -> PWMValue, DEC);
lcdLines[1] = "Rechts: " + String(right -> PWMValue, DEC); lcdLines[1] = "Rechts: " + String(right -> PWMValue, DEC);
} }

2
Code/miniRobotRC/_main.ino

@ -19,8 +19,6 @@ void setup() {
} }
void loop() { void loop() {
//lcdMenu();
while(!tasten.getButtonCycle(buttonStart)) { while(!tasten.getButtonCycle(buttonStart)) {
manualDigitalDrive(); manualDigitalDrive();
updateTemp(); updateTemp();

10
Code/miniRobotRC/interruptRoutinen.ino

@ -1,15 +1,5 @@
//HIER KOMMT ALLES REIN WAS 1 MAL PRO ms AUFGERUFEN WERDEN SOLL!!! //HIER KOMMT ALLES REIN WAS 1 MAL PRO ms AUFGERUFEN WERDEN SOLL!!!
ISR(TIMER2_COMPA_vect) { ISR(TIMER2_COMPA_vect) {
tasten.checkButtons(); 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;
} */
} }
//ALLE anderen ISR kommen HIER drunter!!! //ALLE anderen ISR kommen HIER drunter!!!

6
Code/miniRobotRC/joystick.ino

@ -20,14 +20,8 @@ void motorMapping() {
pwmB = map(leftPWM, -255,255,leftMin,leftMax); pwmB = map(leftPWM, -255,255,leftMin,leftMax);
pwmA = map(rightPWM, -255,255,rightMin,rightMax); pwmA = map(rightPWM, -255,255,rightMin,rightMax);
if((millis() - temp) > 100) { if((millis() - temp) > 100) {
// lcd.clear();
// lcd.println("Links: ");
lcdLines[0] = "Links: " + String(pwmB, DEC); lcdLines[0] = "Links: " + String(pwmB, DEC);
// lcd.println(pwmB);
// lcd.gotoXY(0,2);
// lcd.println("Rechts: ");
lcdLines[1] = "Rechts: " + String(pwmA, DEC); lcdLines[1] = "Rechts: " + String(pwmA, DEC);
// lcd.println(pwmA);
} }
senden(); senden();

2
Code/miniRobotRC/remoteControlInit.ino

@ -7,7 +7,7 @@ void remoteControlInit() {
//Pegelwandler ein //Pegelwandler ein
pinMode(_OE_LEVEL, OUTPUT); pinMode(_OE_LEVEL, OUTPUT);
digitalWrite(_OE_LEVEL, HIGH); digitalWrite(_OE_LEVEL, HIGH);
//Hintergrundbeleuchtung an, halbe Helligkeit
//Hintergrundbeleuchtung an
pinMode(BL, OUTPUT); pinMode(BL, OUTPUT);
BRIGHTNESS = 30; BRIGHTNESS = 30;
//LCD init, invert, vop, tempcoef, bias //LCD init, invert, vop, tempcoef, bias

5
Code/miniRobotRC/temp.ino

@ -11,11 +11,6 @@
radio.startListening(); radio.startListening();
while(!radio.available()){ while(!radio.available()){
//Serial.println("nix"); //Serial.println("nix");
/* unsigned long currentMicros = micros();
if((unsigned long)(currentMicros - start) >= 1){
err = true;
} */
if((millis() - temp_time) >= 10) break; if((millis() - temp_time) >= 10) break;
} }
if(/* !err */ true){ if(/* !err */ true){

Loading…
Cancel
Save