Browse Source

Added BlinkM support over i2c

pull/1/head
Tim Koster 11 years ago
parent
commit
3b315b3da0
  1. 23
      Marlin/BlinkM.cpp
  2. 14
      Marlin/BlinkM.h
  3. 3
      Marlin/Configuration.h
  4. 17
      Marlin/Marlin_main.cpp

23
Marlin/BlinkM.cpp

@ -0,0 +1,23 @@
/*
BlinkM.cpp - Library for controlling a BlinkM over i2c
Created by Tim Koster, August 21 2013.
*/
#if (ARDUINO >= 100)
# include "Arduino.h"
#else
# include "WProgram.h"
#endif
#include "BlinkM.h"
void SendColors(byte red, byte grn, byte blu)
{
Wire.begin();
Wire.beginTransmission(0x09);
Wire.write('o'); //to disable ongoing script, only needs to be used once
Wire.write('n');
Wire.write(red);
Wire.write(grn);
Wire.write(blu);
Wire.endTransmission();
}

14
Marlin/BlinkM.h

@ -0,0 +1,14 @@
/*
BlinkM.h
Library header file for BlinkM library
*/
#if (ARDUINO >= 100)
# include "Arduino.h"
#else
# include "WProgram.h"
#endif
#include "Wire.h"
void SendColors(byte red, byte grn, byte blu);

3
Marlin/Configuration.h

@ -533,6 +533,9 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
# endif
#endif
// define BlinkM Support
#define BlinkM
// Increase the FAN pwm frequency. Removes the PWM noise but increases heating in the FET/Arduino
//#define FAST_PWM_FAN

17
Marlin/Marlin_main.cpp

@ -40,6 +40,9 @@
#include "language.h"
#include "pins_arduino.h"
#include "BlinkM.h"
#include "Wire.h"
#if NUM_SERVOS > 0
#include "Servo.h"
#endif
@ -109,6 +112,7 @@
// M128 - EtoP Open (BariCUDA EtoP = electricity to air pressure transducer by jmil)
// M129 - EtoP Closed (BariCUDA EtoP = electricity to air pressure transducer by jmil)
// M140 - Set bed target temp
// 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.
// M190 - Sxxx Wait for bed current temp to reach target temp. Waits only when heating
// Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling
// M200 - Set filament diameter
@ -1613,6 +1617,19 @@ void process_commands()
#endif
break;
//TODO: update for all axis, use for loop
case 150: // M150
{
byte red;
byte grn;
byte blu;
if(code_seen('R')) red = code_value();
if(code_seen('U')) grn = code_value();
if(code_seen('B')) blu = code_value();
SendColors(red,grn,blu);
}
break;
case 201: // M201
for(int8_t i=0; i < NUM_AXIS; i++)
{

Loading…
Cancel
Save