Forum Rule: Always post complete source code & details to reproduce any issue!
Page 2 of 2 FirstFirst 1 2
Results 26 to 28 of 28

Thread: Teensyduino 1.59 Beta #3

  1. #26
    Unfortunately I do not have this Teensy any more.

  2. #27
    Senior Member
    Join Date
    Oct 2016
    Posts
    1,217

    Should IntervalTimer.h have two versions of update()?

    IntervalTimer.h now has just one version of begin() that uses "template <typename period_t" and handles both integer and float period arguments, but there are still two versions of update(). One takes unsigned int and the other uses the template approach. Is this correct? Can update(unsigned int) be removed?

    EDIT: I tested by commenting out the update(unsigned int), and the template version seems to work correctly for both integer and float arguments.

    Code:
    	template <typename period_t>
    	bool begin(callback_t funct, period_t period) {
    		uint32_t cycles = cyclesFromPeriod(period);
    		return cycles >= 17 ? beginCycles(funct, cycles) : false;
    	}
    
    	// Change the timer's interval.  The current interval is completed
    	// as previously configured, and then the next interval begins with
    	// with this new setting.
    	void update(unsigned int microseconds) {
    		if (microseconds == 0 || microseconds > MAX_PERIOD) return;
    		uint32_t cycles = (24000000 / 1000000) * microseconds - 1;
    		if (cycles < 17) return;
    		if (channel) channel->LDVAL = cycles;
    	}
    
    	// Change the timer's interval.  The current interval is completed
    	// as previously configured, and then the next interval begins with
    	// with this new setting.
    	template <typename period_t>
    	void update(period_t period){
    		uint32_t cycles = cyclesFromPeriod(period);
    		if (cycles < 17) return;
    		if (channel) channel->LDVAL = cycles;
    	}

  3. #28
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    2,105
    Yes, there is already a PR for this

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •