-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathswitch_serial.h
39 lines (30 loc) · 993 Bytes
/
switch_serial.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// -----------------------------------------------------------------------------
// Altair 8800 Simulator
// Copyright (C) 2017 David Hansel
// -----------------------------------------------------------------------------
#ifndef SWITCH_SERIAL_H
#define SWITCH_SERIAL_H
#include <Arduino.h>
class SwitchSerialClass : public Stream
{
public:
SwitchSerialClass();
virtual void begin(unsigned long);
virtual void end();
virtual int available(void);
virtual int availableForWrite(void);
virtual int peek(void);
virtual int read(void);
virtual void flush(void);
virtual size_t write(uint8_t);
virtual size_t write(const uint8_t *buffer, size_t size);
using Print::write; // pull in write(str) from Print
virtual operator bool();
void select(uint8_t n) { m_selected = n; }
uint8_t getSelected() { return m_selected; }
private:
uint8_t m_selected;
};
extern SwitchSerialClass SwitchSerial;
#define Serial SwitchSerial
#endif