Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Netduino is running slower in certain classes than others(Video)..Why?


  • Please log in to reply
4 replies to this topic

#1 gismo

gismo

    Advanced Member

  • Members
  • PipPipPip
  • 110 posts

Posted 18 June 2015 - 02:11 AM

I've attached a video of the behavior.
 
I've created some state-pattern code to run my device. So far I'm pretty happy with it until I created a "Menu" state. I've created some high level functions to shift/animate text around in my menu state. When within the menu state the device seems to run MUCH slower than when it's in another state. This is shown by how slow the text slides when in the Menu mode. When out of the menu mode, you can see how fast the text is supposed to move. WHY? 

 

Video Clip:

https://youtu.be/RqGceeNpyJI

(Yes, I know I have a few typos in the menu item counter  :) )

 

 

Some thoughts, the scrolling text in the "Menu" is within the interrupt handler while the other code where there is scrolling text is not within the interrupt handler. Could that have any effect? I also might have some locking going on, but I'm not sure how to really diagnose it.



#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 18 June 2015 - 02:46 AM

Hi gismo,

Do you have any "tight loops" or busy code happening on background threads?

My first recommendation is to isolate each section of code, to figure out if something is chewing up a bunch of cycles.

Chris

#3 gismo

gismo

    Advanced Member

  • Members
  • PipPipPip
  • 110 posts

Posted 18 June 2015 - 03:38 AM

Thanks Chris... I had and extremely "tight loop"... In my Menu State my "Main Task" Method. I originally had a while(true){} but then there was no way to break out..so I just removed it all..creating that tight loop. The Main program constantly calls the Main Task of the current state. 

 

To fix it, I just put:

Thread.Sleep(Timeout.Infinite);

into the main task and that fixed it!

 

EDIT: Not totally fixed yet..I can't seem to get out of the Menu..I think I need to wake the thread up when I get the interrupt...



#4 HSven1611

HSven1611

    Member

  • Members
  • PipPip
  • 14 posts

Posted 18 June 2015 - 12:20 PM

You could also try something like

while (flag)
{
    Thread.Sleep(100);
}

While your Flag is set this loops but with enough time for other Threads to work.



#5 gismo

gismo

    Advanced Member

  • Members
  • PipPipPip
  • 110 posts

Posted 18 June 2015 - 01:16 PM

You could also try something like

while (flag)
{
    Thread.Sleep(100);
}

While your Flag is set this loops but with enough time for other Threads to work.

 

This works and is dead simple! ...I have to wonder if there's a better way to do it with Threading...And also which approach is better? (Also, would be nice to get my toes wet with some threading...






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.