Skip to content

Instantly share code, notes, and snippets.

@cmaglie
Last active August 29, 2015 13:56
Show Gist options
  • Save cmaglie/9324412 to your computer and use it in GitHub Desktop.
Save cmaglie/9324412 to your computer and use it in GitHub Desktop.
Pluggable modules draft
#include "PKeyboard.h"
PKeyboardClass::PKeyboardClass() {
add("Keyboard");
}
void PKeyboardClass::begin() {
}
PKeyboardClass PKeyboard;
#ifndef PKEYBOARD_H
#define PKEYBOARD_H
#include "Pluggable.h"
class PKeyboardClass {
public:
PKeyboardClass();
void begin();
void inlinedBegin() { };
};
extern PKeyboardClass PKeyboard;
#endif
#include "Pluggable.h"
#include <Arduino.h>
static const int MAXBLOCKS = 5;
const char *blocks[MAXBLOCKS];
uint8_t blocksCount;
void add(const char *data) {
if (blocksCount >= MAXBLOCKS)
return;
blocks[blocksCount] = data;
blocksCount++;
}
void output() {
Serial.println();
Serial.println();
Serial.println();
Serial.println("Plugged modules");
for (uint8_t i=0; i<blocksCount; i++) {
Serial.print(i);
Serial.print(": ");
Serial.println(blocks[i]);
}
Serial.println("End of list");
}
#ifndef PLUGGABLE_H
#define PLUGGABLE_H
#include "PKeyboard.h"
#include "PMouse.h"
void add(const char *data);
void output();
#endif
#include <Pluggable.h>
void setup() {
Serial.begin(115200);
output();
//PKeyboard.begin();
//PMouse.begin();
}
void loop() {
}
#include "PMouse.h"
PMouseClass::PMouseClass() {
add("Mouse");
}
void PMouseClass::begin() {
}
PMouseClass PMouse;
#ifndef PMOUSE_H
#define PMOUSE_H
#include "Pluggable.h"
class PMouseClass {
public:
PMouseClass();
void begin();
void inlinedBegin() { };
};
extern PMouseClass PMouse;
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment