slave_comms.h

changeset 0
2c8ba1964db7
equal deleted inserted replaced
-1:000000000000 0:2c8ba1964db7
1 #ifndef _SLAVE_COMMSH
2 #define _SLAVE_COMMSH
3 /*
4 Functions to drive, and to return values from, a slave processor
5
6 Adrian Bowyer 29 July 2012
7 */
8
9 #ifdef REPRAPPRO_MULTIMATERIALS
10
11 extern float txyz[];
12 extern char slaveBuffer[];
13 extern long timeout;
14 #define TIMEOUT 4 // ms
15
16 float slaveDegHotend(uint8_t extruder);
17 void slaveSetTargetHotend(const float &celsius, uint8_t extruder);
18 float slaveDegTargetHotend(uint8_t extruder);
19 bool slaveIsHeatingHotend(uint8_t extruder);
20 bool slaveIsCoolingHotend(uint8_t extruder);
21 void slaveRemoteStep(int8_t extruder, int8_t v);
22 void slaveRemoteDir(int8_t extruder, bool forward);
23 void talkToSlave(char s[]);
24 char* listenToSlave();
25 void setup_slave();
26
27
28 FORCE_INLINE float slaveDegHotend(uint8_t extruder) { return txyz[extruder]; }
29 FORCE_INLINE void slaveSetTargetHotend(const float &celsius, uint8_t extruder) {txyz[extruder] = celsius; }
30 FORCE_INLINE float slaveDegTargetHotend(uint8_t extruder) { return txyz[extruder]; }
31 FORCE_INLINE bool slaveIsHeatingHotend(uint8_t extruder) { return false; }
32 FORCE_INLINE bool slaveIsCoolingHotend(uint8_t extruder) { return false; }
33
34
35 FORCE_INLINE void slaveRemoteStep(int8_t extruder, int8_t v)
36 {
37
38 }
39
40 FORCE_INLINE void toggleSlaveClock()
41 {
42 digitalWrite(SLAVE_CLOCK, !digitalRead(SLAVE_CLOCK));
43 }
44
45 FORCE_INLINE void slaveRemoteDir(int8_t extruder, bool forward)
46 {
47
48 }
49
50 FORCE_INLINE void talkToSlave(char s[]) { MYSERIAL1.println(s); }
51 FORCE_INLINE char* listenToSlave()
52 {
53 int c = 0;
54 timeout = millis();
55 int8_t i = 0;
56 while(c != '\n' && (millis() - timeout < TIMEOUT))
57 {
58 while(!MYSERIAL1.available() && (millis() - timeout < TIMEOUT));
59 c = MYSERIAL1.read();
60 //timeout = millis();
61 slaveBuffer[i] = (char)c;
62 i++;
63 }
64 slaveBuffer[i] = 0;
65 return slaveBuffer;
66 }
67
68 #endif
69
70 #endif
71

mercurial