2.0 KiB
Introduction
oscp is related to a simple analog oscilloscope module in the C language. It defines some constants related to the functions of the oscilloscope and provides several key function interfaces. These interfaces can be used to set the address of the value to be monitored, set the time scale, and there is also a display processing task function that needs to be called regularly. It's convenient for developers to implement functions related to the analog oscilloscope in C language projects, such as monitoring specific data and presenting it according to the set time scale.
Interfaces
Functions
void oscp_handle(void);
int oscp_set_monitor(int *m);
int oscp_set_scale(int s);
oscp_handle Function:
This function is responsible for handling the display processing tasks related to the analog oscilloscope.
oscp_set_monitor Function:
This function is used to set the address of the value to be monitored.
oscp_set_scale Function:
This function is used to set the time scale.
Usage Example
int level = 0;
static unsigned int get_msec(void)
{
struct timeval mstime;
unsigned int ms = 0;
gettimeofday(&mstime, NULL);
ms = mstime.tv_sec * 1000 + mstime.tv_usec / 1000;
return ms;
}
static void task1(void)
{
oscp_handle();
}
static void task2(void)
{
static int count = 0;
count++;
if (count > 628) count = 0;
level = RESOLUTION / 2 * sin((double)count / 10) + RESOLUTION / 2;
}
static void test_base(void)
{
#if defined(TEST_TARGET_oscp)
uint32_t count = 0;
oscp_set_scale(O_SCALE_50MS);
oscp_set_monitor(&level);
while (1)
{
count++;
if (count >= 25200000) count = 0;
if (count % 5 == 0) task1();
if (count % 50 == 0) task2();
usleep(1000);
}
#else
printf("create task %d\r\n", task_create(5, task1));
printf("create task %d\r\n", task_create(50, task2));
oscp_set_scale(O_SCALE_50MS);
oscp_set_monitor(&level);
#endif
}