2023-09-19 08:34:06 +00:00
|
|
|
///
|
|
|
|
//
|
|
|
|
// shared.h contains some shared settings and functionality
|
|
|
|
//
|
|
|
|
///
|
|
|
|
|
2023-09-15 06:21:00 +00:00
|
|
|
#ifndef _shared_h
|
|
|
|
#define _shared_h
|
|
|
|
|
2023-09-28 12:31:14 +00:00
|
|
|
#include <stdint.h>
|
2023-09-15 06:21:00 +00:00
|
|
|
|
2023-09-19 08:34:06 +00:00
|
|
|
// wifi configuration
|
2023-09-15 06:21:00 +00:00
|
|
|
#define SSID "ESP8266"
|
|
|
|
#define PASSW "XR-Lab2023"
|
|
|
|
|
|
|
|
static const char* APP_TAG="CINEKID_LEDS";
|
|
|
|
|
2023-09-19 08:34:06 +00:00
|
|
|
// print a line with the app tag as a prefix to easilly separate our own logging from system logging
|
2023-09-15 06:21:00 +00:00
|
|
|
#define LOGLN(...) do {\
|
|
|
|
printf("%s | ", APP_TAG);\
|
|
|
|
printf(__VA_ARGS__);\
|
|
|
|
printf("\n");\
|
|
|
|
} while(0)
|
|
|
|
|
2023-09-22 10:30:43 +00:00
|
|
|
static inline
|
|
|
|
int min(int a, int b) { return a < b ? a : b; }
|
|
|
|
static inline
|
|
|
|
int max(int a, int b) { return a > b ? a : b; }
|
|
|
|
static inline
|
|
|
|
int clamp(int x, int mi, int ma) {
|
|
|
|
return max(mi, min(ma, x));
|
|
|
|
}
|
|
|
|
|
2023-09-21 10:01:02 +00:00
|
|
|
#define GLOBAL(__a) (uint8_t)(__a|0xE0)
|
|
|
|
|
2023-09-28 12:31:14 +00:00
|
|
|
struct result_t {
|
|
|
|
uint8_t is_ok;
|
|
|
|
union {
|
|
|
|
void* ok;
|
|
|
|
const char* error;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct result_t Result;
|
|
|
|
|
|
|
|
#define PARSE_ERR(__err) (Result){.is_ok=0,.error=__err}
|
|
|
|
#define PARSE_OK(__result) (Result){.is_ok=1,.ok=__result}
|
|
|
|
|
|
|
|
|
2023-09-15 06:21:00 +00:00
|
|
|
#endif // !_shared_h
|