How to apply Library Code into ZSTAR3 example source code

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to apply Library Code into ZSTAR3 example source code

991 Views
Cheng
Contributor I

Dear ZSTAR3 developer

 

We had some problems when we tried to using the C# language code from ZStar Library in Visual Studio, although it has no problem to run. 
       For example, if we want to change the DataRate of ZStar3 sensor from 30Hz to 120Hz, apply and develop it based on Example Source Code, then how would we do it? 
The related code that been given in library is shown as following: 
      public ZStar3.DataRate DataRate { get; }
      public enum DataRate
      Member                                              Description
DataRate_30Hz        Acceleration data are reading with 30Hz datarate 
DataRate_60Hz        Acceleration data are reading with 60Hz datarate 
DataRate_120Hz      Acceleration data are reading with 120Hz datarate 
In this case, do we need to create private void? and inside of bracket {...} i.e 'get;' does that mean we need to put 'DataRate_60Hz' replace the 'get;' ? (but it still not working properly) 
The similar occurred when we trying to using average filter code from library, i.e
 public int AverageFilterSamples { get; set; }
Again we are very unsure about what to do with 'get; set;', is 'get' in here means import the data? Is 'set' in here means set order value of Filter? And finally how to implement this code in the example source code to make a average filter? We need a guide and help in order to apply these useful code from library wisely. 
So it would be very kind of you if you could let us know how to use and imply the library code into example source code which is written in C# language and a detailed answer would be appreciated.

 

Thank you very much in advance.

Cheng

Labels (1)
0 Kudos
Reply
1 Reply

460 Views
Gargy
NXP Employee
NXP Employee

Hi,

 zstarlib developer.

 

First of all: get/set in bracket that you mentioned only tells you the style of the property in other words if its read only, write only or read write. Thats all

 

And for example DataRate { get; } property is only erad and there is stored current datarate of connected sensor. Thats all.

 

If you want change the datarate Then you have to use method DataRateSet(...) that "tries" to change datarate (Try - because there is a lot of thing that  could failed)

The few reasons that could failed:

 - ComPOrt is not opened

 - The sensor with this ID is not connected right now

 - The RF packet is lost in air :smileyhappy:

 ...

 

So for this reasonfor datarate (and similar) methods added into lib event on DataRateChanged and you can wait for the change with any timeout.

 

And regarding the avarage filter: The use of the filter is very simple :By the property AverageFilterSamples { get; set; } you will set the level of the filter (how much values will be use for computing the average values) and then you have to read the results not from normal results properties likes RealX but RealXFiltered.

 

Have a nice time with ZSTAR

 

0 Kudos
Reply