Changeset 20391

Show
Ignore:
Timestamp:
06/29/07 16:32:39 (1 year ago)
Author:
patrick
Message:

MFT 20386: Get this to compile again.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • juggler/branches/2.2/modules/gadgeteer/samples/tutorials/device.drivers/Makefile

    r19729 r20391  
    3737SRCS=           buttondevice.cpp 
    3838 
    39 include $(GADGET_BASE_DIR)/share/gadgeteer/gadget.driver.mk 
     39GADGET_BASE_DIR=$(shell flagpoll gadgeteer --get-prefix) 
     40GADGET_VERSION= $(shell flagpoll gadgeteer --modversion) 
     41 
     42include $(GADGET_BASE_DIR)/share/gadgeteer-$(GADGET_VERSION)/gadget.driver.mk 
  • juggler/branches/2.2/modules/gadgeteer/samples/tutorials/device.drivers/buttondevice.cpp

    r19729 r20391  
    2828 
    2929#include <vector> 
     30#include <boost/bind.hpp> 
    3031 
    3132#include <vpr/vpr.h> 
     
    7980bool ButtonDevice::startSampling() 
    8081{ 
    81    mRunning = true; 
    82    mSampleThread = new vpr::Thread(threadedSampleFunction, (void*) this); 
     82   mRunning = false; 
    8383 
    84    if ( ! mSampleThread->valid() ) 
     84   try 
    8585   { 
    86       mRunning = false; 
    87       return false; // thread creation failed 
     86      mSampleThread = 
     87         new vpr::Thread(boost::bind(&ButtonDevice::threadedSampleFunction, 
     88                                     this)); 
     89      mRunning = true; 
    8890   } 
    89    else 
     91   catch (vpr::Exception& ex) 
    9092   { 
    91       return true; // thread creation success 
     93      std::cerr << "Failed to spawn sample thread!\n" << ex.what() 
     94                << std::endl; 
    9295   } 
     96 
     97   return mRunning; 
    9398} 
    9499 
     
    140145// This function is declared as a static member of ButtonDevice.  It simply 
    141146// calls ButtonDevice::sample() over and over. 
    142 void ButtonDevice::threadedSampleFunction(void* classPointer
     147void ButtonDevice::threadedSampleFunction(
    143148{ 
    144    ButtonDevice* this_ptr = static_cast<ButtonDevice*>( classPointer ); 
    145  
    146149   // spin until someone kills "mSampleThread" 
    147    while ( this_ptr->mRunning ) 
     150   while ( mRunning ) 
    148151   { 
    149      this_ptr->sample(); 
    150      vpr::System::sleep(1); //specify some time here, so you don't waste CPU cycles 
     152      sample(); 
     153      vpr::System::sleep(1); //specify some time here, so you don't waste CPU cycles 
    151154   } 
    152155} 
    153  
  • juggler/branches/2.2/modules/gadgeteer/samples/tutorials/device.drivers/buttondevice.h

    r19729 r20391  
    112112   /** 
    113113    * Our sampling function that is executed by the spawned sample thread. 
    114     * This function is declared as a static member of ButtonDevice.  It simply 
    115     * calls ButtonDevice::sample() over and over. 
     114    * This function simply calls ButtonDevice::sample() over and over. 
    116115    */ 
    117    static void threadedSampleFunction(void* classPointer); 
     116   void threadedSampleFunction(); 
    118117 
    119118   vpr::Thread*  mSampleThread;