Browse Source

Added BlinkM support over i2c

Tim Koster 12 years ago
parent
commit
7016cc9511
4 changed files with 57 additions and 0 deletions
  1. 23
    0
      Marlin/BlinkM.cpp
  2. 14
    0
      Marlin/BlinkM.h
  3. 3
    0
      Marlin/Configuration.h
  4. 17
    0
      Marlin/Marlin_main.cpp

+ 23
- 0
Marlin/BlinkM.cpp View File

@@ -0,0 +1,23 @@
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
+#include "BlinkM.h"
11
+
12
+void SendColors(byte red, byte grn, byte blu)
13
+{
14
+  Wire.begin(); 
15
+  Wire.beginTransmission(0x09);
16
+  Wire.write('o');                    //to disable ongoing script, only needs to be used once
17
+  Wire.write('n');
18
+  Wire.write(red);
19
+  Wire.write(grn);
20
+  Wire.write(blu);
21
+  Wire.endTransmission();
22
+}
23
+

+ 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

@@ -557,6 +557,9 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
557 557
 // Support for the BariCUDA Paste Extruder.
558 558
 //#define BARICUDA
559 559
 
560
+//define BlinkM/CyzRgb Support
561
+//#define BlinkM
562
+
560 563
 /*********************************************************************\
561 564
 * R/C SERVO support
562 565
 * Sponsored by TrinityLabs, Reworked by codexmas

+ 17
- 0
Marlin/Marlin_main.cpp View File

@@ -40,6 +40,9 @@
40 40
 #include "language.h"
41 41
 #include "pins_arduino.h"
42 42
 
43
+#include "BlinkM.h"
44
+#include "Wire.h" 
45
+
43 46
 #if NUM_SERVOS > 0
44 47
 #include "Servo.h"
45 48
 #endif
@@ -109,6 +112,7 @@
109 112
 // M128 - EtoP Open (BariCUDA EtoP = electricity to air pressure transducer by jmil)
110 113
 // M129 - EtoP Closed (BariCUDA EtoP = electricity to air pressure transducer by jmil)
111 114
 // M140 - Set bed target temp
115
+// 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.
112 116
 // M190 - Sxxx Wait for bed current temp to reach target temp. Waits only when heating
113 117
 //        Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling
114 118
 // M200 - Set filament diameter
@@ -1613,6 +1617,19 @@ void process_commands()
1613 1617
       #endif
1614 1618
       break;
1615 1619
       //TODO: update for all axis, use for loop
1620
+    case 150: // M150
1621
+      {
1622
+        byte red;
1623
+        byte grn;
1624
+        byte blu;
1625
+        
1626
+        if(code_seen('R')) red = code_value();
1627
+        if(code_seen('U')) grn = code_value();
1628
+        if(code_seen('B')) blu = code_value();
1629
+        
1630
+        SendColors(red,grn,blu);        
1631
+      }
1632
+      break;
1616 1633
     case 201: // M201
1617 1634
       for(int8_t i=0; i < NUM_AXIS; i++)
1618 1635
       {

Loading…
Cancel
Save