Makeblock-library-for-Arduino  V3.2.4
It's a library for arduino application developers
MePort.h
Go to the documentation of this file.
1 
54 #ifndef MEPORT_H_
55 #define MEPORT_H_
56 
57 #include <Arduino.h>
58 #include <avr/interrupt.h>
59 #include <avr/io.h>
60 #include <util/delay.h>
61 #include <stdint.h>
62 #include <stdlib.h>
63 #include "MeConfig.h"
64 
68 typedef struct
69 {
70  uint8_t s1;
71  uint8_t s2;
72 } MePort_Sig;
73 
74 extern MePort_Sig mePort[15]; // mePort[0] is nonsense
75 
76 #define NC (0) //use UART RX for NULL port
77 
78 #define PORT_1 (0x01)
79 #define PORT_2 (0x02)
80 #define PORT_3 (0x03)
81 #define PORT_4 (0x04)
82 #define PORT_5 (0x05)
83 #define PORT_6 (0x06)
84 #define PORT_7 (0x07)
85 #define PORT_8 (0x08)
86 #define PORT_9 (0x09)
87 #define PORT_10 (0x0a)
88 #define M1 (0x09)
89 #define M2 (0x0a)
90 #define PORT_11 (0x0b)
91 #define PORT_12 (0x0c)
92 #define PORT_13 (0x0d)
93 #define PORT_14 (0x0e)
94 
95 #ifdef MeMbot_H
96 #define PORT_RGB (0x05)
97 #define PORT_LightSensor (0x06)
98 #endif
99 
100 #define SLOT1 (1)
101 #define SLOT2 (2)
102 #define SLOT3 (3)
103 #define SLOT4 (4)
104 #define SLOT_1 SLOT1
105 #define SLOT_2 SLOT2
106 #define SLOT_3 SLOT3
107 #define SLOT_4 SLOT4
108 
109 #define FALSE (0)
110 #define TRUE (1)
111 
118 class MePort
119 {
120 public:
121 
126  MePort(void);
127 
134  MePort(uint8_t port);
135 
144  MePort(uint8_t port, uint8_t slot);
145 
158  uint8_t getPort(void);
159 
172  uint8_t getSlot(void);
173 
188  bool dRead1(uint8_t mode = INPUT);
189 
204  bool dRead2(uint8_t mode = INPUT);
205 
219  bool dpRead1(void);
220 
234  bool dpRead2(void);
235 
250  void dWrite1(bool value);
251 
266  void dWrite2(bool value);
267 
280  int16_t aRead1(void);
281 
294  int16_t aRead2(void);
295 
310  void aWrite1(int16_t value);
311 
326  void aWrite2(int16_t value);
327 
342  void reset(uint8_t port);
343 
360  void reset(uint8_t port, uint8_t slot);
361 
374  uint8_t pin1(void);
375 
388  uint8_t pin2(void);
389 
403  uint8_t pin(void);
404 
421  uint8_t pin(uint8_t port, uint8_t slot);
422 
423 protected:
424 
429  uint8_t s1;
430 
435  uint8_t s2;
436 
442  uint8_t _port;
443 
448  uint8_t _slot;
449 };
450 #endif // MEPORT_H_
void dWrite2(bool value)
Definition: MePort.cpp:251
Configuration file of library.
uint8_t _slot
Definition: MePort.h:448
Port Mapping for RJ25.
Definition: MePort.h:118
uint8_t pin1(void)
Definition: MePort.cpp:392
void aWrite1(int16_t value)
Definition: MePort.cpp:311
int16_t aRead1(void)
Definition: MePort.cpp:269
Definition: MePort.h:68
bool dRead2(uint8_t mode=INPUT)
Definition: MePort.cpp:167
void aWrite2(int16_t value)
Definition: MePort.cpp:330
uint8_t pin2(void)
Definition: MePort.cpp:409
uint8_t s2
Definition: MePort.h:71
bool dRead1(uint8_t mode=INPUT)
Definition: MePort.cpp:145
uint8_t s2
Definition: MePort.h:435
void dWrite1(bool value)
Definition: MePort.cpp:231
MePort_Sig mePort[15]
Definition: MeAuriga.h:74
uint8_t s1
Definition: MePort.h:429
bool dpRead2(void)
Definition: MePort.cpp:209
uint8_t s1
Definition: MePort.h:70
MePort(void)
Definition: MePort.cpp:61
uint8_t pin(void)
Definition: MePort.cpp:427
uint8_t getSlot(void)
Definition: MePort.cpp:126
uint8_t _port
Definition: MePort.h:442
bool dpRead1(void)
Definition: MePort.cpp:188
int16_t aRead2(void)
Definition: MePort.cpp:289
void reset(uint8_t port)
Definition: MePort.cpp:349
uint8_t getPort(void)
Definition: MePort.cpp:109