2026-07-16 12:43:41 +10:00
|
|
|
#pragma once
|
2026-07-16 13:13:38 +10:00
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <stdlib.h>
|
2026-07-16 14:05:01 +10:00
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdbool.h>
|
2026-07-16 12:43:41 +10:00
|
|
|
|
2026-07-16 14:05:01 +10:00
|
|
|
#define DEVICE_BUFFER_LENGTH 128
|
|
|
|
|
|
|
|
|
|
typedef struct Device Device;
|
|
|
|
|
struct Device {
|
2026-07-16 13:13:38 +10:00
|
|
|
char name[32];
|
2026-07-16 12:43:41 +10:00
|
|
|
|
2026-07-16 14:05:01 +10:00
|
|
|
uint16_t in[DEVICE_BUFFER_LENGTH];
|
|
|
|
|
uint8_t inPos;
|
|
|
|
|
|
|
|
|
|
uint16_t out[DEVICE_BUFFER_LENGTH];
|
|
|
|
|
uint8_t outPos;
|
|
|
|
|
|
|
|
|
|
void (*update)(Device* self);
|
|
|
|
|
};
|
2026-07-16 13:13:38 +10:00
|
|
|
|
|
|
|
|
Device* createDevice(
|
|
|
|
|
const char* name,
|
2026-07-16 14:05:01 +10:00
|
|
|
void (*update)(Device* self)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
uint16_t deviceRead(Device* self);
|
|
|
|
|
void deviceSend(Device* self, uint16_t value);
|
|
|
|
|
bool deviceCanRead(Device* self);
|