hello linux delay thread

This commit is contained in:
Kizarm 2024-08-18 21:29:44 +02:00
parent 273a477a37
commit f653fe0914
2 changed files with 1 additions and 5 deletions

View file

@ -55,6 +55,7 @@ static constexpr int CC = MAXPWM / 2;
static pthread_t rc; static pthread_t rc;
void * WriteHandler (void * data) { void * WriteHandler (void * data) {
usleep(10'000);
printf ("Start thread\n"); printf ("Start thread\n");
PwmClass * pA = (PwmClass *) data; PwmClass * pA = (PwmClass *) data;
Sample buf [BufLen]; Sample buf [BufLen];

View file

@ -1,10 +1,8 @@
#include <cstdio> #include <cstdio>
#include <mutex> #include <mutex>
#include "utils.h" #include "utils.h"
static std::mutex Mutex;
void print_morse_table (const TABLE<unsigned char, 64> & tab) { void print_morse_table (const TABLE<unsigned char, 64> & tab) {
Mutex.lock();
int n = 0; int n = 0;
printf("static const unsigned char compressed_table [] = {"); printf("static const unsigned char compressed_table [] = {");
for (auto & e: tab) { for (auto & e: tab) {
@ -13,10 +11,8 @@ void print_morse_table (const TABLE<unsigned char, 64> & tab) {
n++; n++;
} }
printf("\n};\n"); printf("\n};\n");
Mutex.unlock();
} }
void print_sinus_table (const TABLE<unsigned short, 256> & tab) { void print_sinus_table (const TABLE<unsigned short, 256> & tab) {
Mutex.lock();
int n = 0; int n = 0;
printf("static const uint16_t sin_tab [] = {"); printf("static const uint16_t sin_tab [] = {");
for (auto & e: tab) { for (auto & e: tab) {
@ -25,5 +21,4 @@ void print_sinus_table (const TABLE<unsigned short, 256> & tab) {
n++; n++;
} }
printf("\n};\n"); printf("\n};\n");
Mutex.unlock();
} }