Browse Source

Merge pull request #590 from timkoster/Marlin_v1

Added BlinkM support over i2c
ErikZalm 10 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

@@ -0,0 +1,24 @@
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

@@ -0,0 +1,14 @@
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,6 +561,9 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
561 561
 // Support for the BariCUDA Paste Extruder.
562 562
 //#define BARICUDA
563 563
 
564
+//define BlinkM/CyzRgb Support
565
+//#define BLINKM
566
+
564 567
 /*********************************************************************\
565 568
 * R/C SERVO support
566 569
 * Sponsored by TrinityLabs, Reworked by codexmas

+ 19
- 0
Marlin/Marlin_main.cpp View File

@@ -44,6 +44,9 @@
44 44
 #include "language.h"
45 45
 #include "pins_arduino.h"
46 46
 
47
+#include "BlinkM.h"
48
+#include "Wire.h" 
49
+
47 50
 #if NUM_SERVOS > 0
48 51
 #include "Servo.h"
49 52
 #endif
@@ -115,6 +118,7 @@
115 118
 // M128 - EtoP Open (BariCUDA EtoP = electricity to air pressure transducer by jmil)
116 119
 // M129 - EtoP Closed (BariCUDA EtoP = electricity to air pressure transducer by jmil)
117 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 122
 // M190 - Sxxx Wait for bed current temp to reach target temp. Waits only when heating
119 123
 //        Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling
120 124
 // M200 - Set filament diameter
@@ -1935,6 +1939,21 @@ void process_commands()
1935 1939
       #endif
1936 1940
       break;
1937 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 1957
     case 201: // M201
1939 1958
       for(int8_t i=0; i < NUM_AXIS; i++)
1940 1959
       {

Loading…
Cancel
Save