Go Down

Topic: Erste Schritte mit Atmel Studio  (Read 1 time) previous topic - next topic

jok3r89

Jul 20, 2015, 08:26 pm Last Edit: Jul 20, 2015, 08:48 pm by jok3r89
Hallo , ich versuche mich zurzeit an Atmel Studio 6.
Die ersten Programme laufen, jetzt hätte ich mal versucht .h und .cpp Datein zu schreiben und einzubinden.
Leider funktioniert das nicht.

Ich bräuchte also eure Hilfe

.h
Quote
// TaskManager.h

#ifndef _TASKMANAGER_h
#define _TASKMANAGER_h

#if defined(ARDUINO) && ARDUINO >= 100
   #include "arduino.h"
#else
   #include "WProgram.h"
#endif

#include "inttypes.h"

class TaskManagerClass
{
   
   private:
   
   unsigned long  previous_millis, interval_millis;
   
   public:
   
      void Manager();
      void Manager(unsigned long interval_millis);
      void interval(unsigned long interval_millis);
      uint8_t check();
      void reset();
};

#endif
.cpp
Quote
//
//
//


#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include "TaskManager.h"

void TaskManager::Manager()
{
   
   this->interval_millis = 1000;
   
}


void TastkManager::Manager(unsigned long interval_millis)
{
   
   this->interval_millis = interval_millis;
   
}


void TaskManager::interval(unsigned long interval_millis)
{
   this->interval_millis = interval_millis;
}

uint8_t TaskManager::check()
{

   unsigned long now = millis();
   
   if ( interval_millis == 0 ){
      previous_millis = now;
      return 1;
   }
   
   if ( (now - previous_millis) >= interval_millis) {
      #ifdef NOCATCH-UP
      previous_millis = now ;
      #else
      previous_millis += interval_millis ;
      #endif
      return 1;
   }
   
   return 0;

}

void TaskManager::reset()
{
   
   this->previous_millis = millis();

}
Output

Quote
TaskManager.cpp:13:6: error: 'TaskManager' has not been declared
 void TaskManager*:Manager()
TaskManager.cpp:In function 'void Manager()'
TaskManager.cpp:16:2: error: invalid use of 'this' in non-member function
TaskManager.cpp:At global scope
TaskManager.cpp:21:6: error: 'TastkManager' has not been declared
 void TastkManager*:Manager(unsigned long interval_millis)
TaskManager.cpp:In function 'void Manager(long unsigned int)'
TaskManager.cpp:24:2: error: invalid use of 'this' in non-member function
TaskManager.cpp:At global scope
TaskManager.cpp:29:6: error: 'TaskManager' has not been declared
 void TaskManager*:interval(unsigned long interval_millis)
TaskManager.cpp:In function 'void interval(long unsigned int)'
TaskManager.cpp:31:2: error: invalid use of 'this' in non-member function
TaskManager.cpp:At global scope
TaskManager.cpp:34:9: error: 'TaskManager' has not been declared
 uint8_t TaskManager*:check()
TaskManager.cpp:In function 'uint8_t check()'
TaskManager.cpp:39:7: error: 'interval_millis' was not declared in this scope
TaskManager.cpp:40:3: error: 'previous_millis' was not declared in this scope
TaskManager.cpp:44:14: error: 'previous_millis' was not declared in this scope
TaskManager.cpp:44:34: error: 'interval_millis' was not declared in this scope
TaskManager.cpp:At global scope
TaskManager.cpp:57:6: error: 'TaskManager' has not been declared
 void TaskManager*:reset()
TaskManager.cpp:In function 'void reset()'
TaskManager.cpp:60:2: error: invalid use of 'this' in non-member function
Error compiling
Ich habe schon einiges versucht.

Muss im Header immer der Datentyp angeben sein von der Funktion ? Weil in der Metro.h wird das nicht gemacht. Atmel Studio hat aber damit ein problem

Gruß

michael_x

Quote
class TaskManagerClass
meinst du evtl.
class TaskManager

 ?


Was willst du mit WProgram.h im Atmel Studio  ?

jok3r89

#2
Jul 20, 2015, 09:00 pm Last Edit: Jul 20, 2015, 09:04 pm by jok3r89
Irgendwann sieht man den Wald vor lauter Bäumen nicht .... Danke.

Ehrlich gesagt habe ich das übernommen.
Ich muss dazu sagen das ich mit Visualmicro plugin arbeite.

Ich ahne gerade das ist wohl ein überbleibsl aus verfangenden tagen????
Arduino.h sollte reichen ....

Go Up