Browse Source

Merge pull request #590 from timkoster/Marlin_v1

Added BlinkM support over i2c
ErikZalm 11 years ago
parent
commit
6a803ba9c5
4 changed files with 60 additions and 0 deletions
  1. 24
    0
      Marlin/BlinkM.cpp
  2. 14
    0
      Marlin/BlinkM.h
  3. 3
    0
      Marlin/Configuration.h
  4. 19
    0
      Marlin/Marlin_main.cpp

+ 24
- 0
Marlin/BlinkM.cpp View File

1
+/*
2
+  BlinkM.cpp - Library for controlling a BlinkM over i2c
3
+  Created by Tim Koster, August 21 2013.
4
+*/
5
+#if (ARDUINO >= 100)
6
+  # include "Arduino.h"
7
+#else
8
+  # include "WProgram.h"
9
+#endif
10
+
11
+#include "BlinkM.h"
12
+
13
+void SendColors(byte red, byte grn, byte blu)
14
+{
15
+  Wire.begin(); 
16
+  Wire.beginTransmission(0x09);
17
+  Wire.write('o');                    //to disable ongoing script, only needs to be used once
18
+  Wire.write('n');
19
+  Wire.write(red);
20
+  Wire.write(grn);
21
+  Wire.write(blu);
22
+  Wire.endTransmission();
23
+}
24
+

+ 14
- 0
Marlin/BlinkM.h View File

1
+/*
2
+  BlinkM.h
3
+  Library header file for BlinkM library
4
+ */
5
+#if (ARDUINO >= 100)
6
+  # include "Arduino.h"
7
+#else
8
+  # include "WProgram.h"
9
+#endif
10
+
11
+#include "Wire.h"
12
+
13
+void SendColors(byte red, byte grn, byte blu);
14
+

+ 3
- 0
Marlin/Configuration.h View File

561
 // Support for the BariCUDA Paste Extruder.
561
 // Support for the BariCUDA Paste Extruder.
562
 //#define BARICUDA
562
 //#define BARICUDA
563
 
563
 
564
+//define BlinkM/CyzRgb Support
565
+//#define BLINKM
566
+
564
 /*********************************************************************\
567
 /*********************************************************************\
565
 * R/C SERVO support
568
 * R/C SERVO support
566
 * Sponsored by TrinityLabs, Reworked by codexmas
569
 * Sponsored by TrinityLabs, Reworked by codexmas

+ 19
- 0
Marlin/Marlin_main.cpp View File

44
 #include "language.h"
44
 #include "language.h"
45
 #include "pins_arduino.h"
45
 #include "pins_arduino.h"
46
 
46
 
47
+#include "BlinkM.h"
48
+#include "Wire.h" 
49
+
47
 #if NUM_SERVOS > 0
50
 #if NUM_SERVOS > 0
48
 #include "Servo.h"
51
 #include "Servo.h"
49
 #endif
52
 #endif
115
 // M128 - EtoP Open (BariCUDA EtoP = electricity to air pressure transducer by jmil)
118
 // M128 - EtoP Open (BariCUDA EtoP = electricity to air pressure transducer by jmil)
116
 // M129 - EtoP Closed (BariCUDA EtoP = electricity to air pressure transducer by jmil)
119
 // M129 - EtoP Closed (BariCUDA EtoP = electricity to air pressure transducer by jmil)
117
 // M140 - Set bed target temp
120
 // M140 - Set bed target temp
121
+// M150 - Set BlinkM Colour Output R: Red<0-255> U(!): Green<0-255> B: Blue<0-255> over i2c, G for green does not work.
118
 // M190 - Sxxx Wait for bed current temp to reach target temp. Waits only when heating
122
 // M190 - Sxxx Wait for bed current temp to reach target temp. Waits only when heating
119
 //        Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling
123
 //        Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling
120
 // M200 - Set filament diameter
124
 // M200 - Set filament diameter
1935
       #endif
1939
       #endif
1936
       break;
1940
       break;
1937
       //TODO: update for all axis, use for loop
1941
       //TODO: update for all axis, use for loop
1942
+    #ifdef BLINKM  
1943
+    case 150: // M150
1944
+      {
1945
+        byte red;
1946
+        byte grn;
1947
+        byte blu;
1948
+        
1949
+        if(code_seen('R')) red = code_value();
1950
+        if(code_seen('U')) grn = code_value();
1951
+        if(code_seen('B')) blu = code_value();
1952
+        
1953
+        SendColors(red,grn,blu);        
1954
+      }
1955
+      break;
1956
+    #endif //BLINKM
1938
     case 201: // M201
1957
     case 201: // M201
1939
       for(int8_t i=0; i < NUM_AXIS; i++)
1958
       for(int8_t i=0; i < NUM_AXIS; i++)
1940
       {
1959
       {

Loading…
Cancel
Save