Leds work simultanously. Version 3.1

Dependencies:   HCSR

Dependents:   bertl_led bertl_led bertl_led bertl_led ... more

Fork of Bertl by Bertl_Team_PE

BULME HTL Graz-Gösting

FSST - Hardwarenahe Programmierung

Created by Prof.Dr. Franz Pucher

Inhalt

Inhalt

Start mit folgendem Code in main.cpp eines neuen Projektes mbed_blinky:

#include "mbed.h"
#include "const.h"
#include "Robot.h"

Robot bertl;
    
int main()
{
    bertl.NibbleLeds(0x0F);
    wait(1);
    bertl.NibbleLeds(0x00);
    
    while(1)
    {
        if(bertl.IsButtonPressed(BTN_BL))
        {
            bertl.TurnLedOn(LED_BL1);
        }
        if(bertl.IsButtonPressed(BTN_BR))
        {
            bertl.TurnLedOff(LED_BL1);
        }
    }
}
Revision:
15:43d6a7e6e64a
Parent:
13:3ce84646fd74
Child:
17:308802267a62
--- a/ur_Bertl.cpp	Mon Apr 27 13:13:45 2015 +0000
+++ b/ur_Bertl.cpp	Fri May 08 08:39:12 2015 +0000
@@ -16,6 +16,10 @@
 // Constructor
 ur_Bertl::ur_Bertl() : _interrupt(MOTORENC)         
 {
+    MotorSpg = 1;
+    IncrementalgeberSpg = 1;
+    LinienSensorSpg = 1;
+
     i2c.frequency(40000);                           // I2C init
     char init1[2] = {0x6, 0x00};
     char init2[2] = {0x7, 0xff};
@@ -41,16 +45,16 @@
 }
 
 // Pulblic methodes
-void ur_Bertl::Move(int move)
+void ur_Bertl::Move()
 {
     int count = _count;
     MotorR_EN=MotorL_EN=1;                  // both motor ENABLE
     MotorR_FORWARD = MotorL_FORWARD = 1;    // both motor forward ON
 #ifdef TIME
-    wait_ms(move);
+    wait_ms(MOVE);
 #else
 
-    while(_count < count+move) {
+    while(_count < count+DISTANCE) {        // DISTANCE maybe change to move
         //if(!FrontIsClear())       // more convenient because there are no accidents :-)
           //  break;
 #ifdef FRONTBUTTON
@@ -62,7 +66,7 @@
 #endif
     MotorR_FORWARD = MotorL_FORWARD = 0;    // both motor off
     MotorR_EN=MotorL_EN=0;
-    if(move == MOVE)
+    //if(move == MOVE)
         wait_ms(250);
 }
 
@@ -109,10 +113,16 @@
     wait_ms(250);           // only to step the robot
 }
 
-void ur_Bertl::ShutOff()
+void ur_Bertl::TurnOff()
 {
     MotorR_FORWARD = MotorL_FORWARD = 0;    // motor OFF
     MotorR_EN=MotorL_EN=0;                  // motor disable
+    MotorSpg = 0;
+    IncrementalgeberSpg = 0;
+    LinienSensorSpg = 0;
+    BlueLedsOFF();
+    TurnLedOff(LED_ALL);
+    NibbleLeds(0x00);
 }
 
 // Public LEDs methodes