Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Let us take an example Cyclops program and perform a walkthrough. For details on usage, design, implementation please refer the developer documentation.

Example: rpc_loop

Tip

The rpc_loop example is included in the /src/teensy/ directory of the repository.

 

File: MySources.h

1.  #ifndef CL_MY_SOURCES_H
3.  #define CL_MY_SOURCES_H
4.  //
5.  // This file contains the globals definitions of the Source objects Just include
6.  // this file into your main `.ino` script, and you'll get access to the objects
7.  // here.
8.  //
9.  
10. uint16_t triangle_wave(uint8_t seq){
11.   return (abs(20 - seq)/40.0)*2048;
12. }
13. 
14. uint32_t triangle_update_period(uint8_t seq){
15.   return 30000 + seq;
16. }
17. 
18. uint16_t vd_1[] = {1, 2048};
19. uint32_t ht_1[] = {70000, 70000};
20. 
21. cyclops::generatedSource gen ( triangle_wave
23.                              , triangle_update_period
24.                              , 40
25.                              , cyclops::source::LOOPBACK);
26. 
27. cyclops::storedSource sto_1 ( vd_1
28.                             , ht_1
29.                             , 2
30.                             , cyclops::source::LOOPBACK);
31. 
33. cyclops::squareSource square (cyclops::source::LOOPBACK);
34. 
35. /* You must register these sources with the library, by:
36.  *
37.  * 1. making a globally scoped array of pointers to the objects.
38.  * 2. assign the global array to the ``globalSourceList_ptr``
39.  *
40.  * Only the registered sources are guaranteed to work when using the RPC,
41.  * especially when using the OE GUI.
43.  */
44. cyclops::Source* globalSourceList[] = { &gen
45.                                       , &sto_1
46.                                       , &square
47.                                       };
48. // Assigning this array to the special pointer.
49. REGISTER_SOURCE_LIST(globalSourceList, 3);
50. #endif

...

To interact with the Cyclops, look for a python Tkinter application in /src/cyclops-ctrl-gui/gui_main.py. Usage instructions can be found in packet_gen.py and by passing a command-line flag to invoke, like so:

python gui_main.py -h

Quickly defining Source objects

We provide a python script, the SignalEditor (in /plugin-GUI/Resources/Python) which makes it super easy to edit and view signals live from an IPython shell. This script can save the signals in various formats.

Choose the Cyclops Objects format which would show the plain-text C++ array and Object definition code which you can copy and paste into mySources.h.

More info can be found here.

Further Reading

At this point, you know how the Cyclops Library should (and can) be used.

If you wish to know all about the inner working and design, we lay it bare for you in Design. With that knowledge you can start tweaking the Cyclops Library and work in baremetal mode with the Teensy. You could add more RPC for your custom script, or add cool modules to use other features of the Teensy like ADC, PWM generation, etc.

...

If you are going to use Cyclops only with the Open-Ephys GUI, you need not worry about the Library internals and -- just get familiar with the CyclopsPlugin API. That's the next section, so read on!