This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit 6a8344bf3794e44f93fccc30c868c6faf2d9a4cd
Author: raiden00pl <[email protected]>
AuthorDate: Sat Dec 2 18:57:23 2023 +0100

    examples/nxscope: change the vector data sent by nxscope to be a 3-phase 
sin waveform
    
    A changing waveform is nicer to visualize than a static vector.
---
 examples/nxscope/nxscope_main.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/examples/nxscope/nxscope_main.c b/examples/nxscope/nxscope_main.c
index e10011af4..fd2a89fd3 100644
--- a/examples/nxscope/nxscope_main.c
+++ b/examples/nxscope/nxscope_main.c
@@ -30,6 +30,7 @@
 #include <pthread.h>
 #include <stdio.h>
 #include <unistd.h>
+#include <math.h>
 
 #ifdef CONFIG_EXAMPLES_NXSCOPE_TIMER
 #  include <sys/ioctl.h>
@@ -41,6 +42,16 @@
 
 #include "logging/nxscope/nxscope.h"
 
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifdef CONFIG_LIBM_NONE
+#  error "math library must be selected for this example"
+#endif
+
+#define SIN_DT (0.01f)
+
 /****************************************************************************
  * Private Type Definition
  ****************************************************************************/
@@ -197,14 +208,14 @@ static FAR void *nxscope_samples_thr(FAR void *arg)
   sigaddset(&set, CONFIG_EXAMPLES_NXSCOPE_TIMER_SIGNO);
 #endif
 
-  /* Initialize float vector */
-
-  v[0] = -1.0f;
-  v[1] = 0.0f;
-  v[2] = 1.0f;
-
   while (1)
     {
+      /* Float vector - tree-phase sine waveform */
+
+      v[0] = sinf(i * SIN_DT);
+      v[1] = sinf(i * SIN_DT + (2.0f / 3.0f) * M_PI);
+      v[2] = sinf(i * SIN_DT + (4.0f / 3.0f) * M_PI);
+
       /* Channel 0 */
 
       nxscope_put_uint8(envp->nxs, 0, i);

Reply via email to