Welcome! Log In Create A New Profile

Advanced

Followup on Adafruit RGB LCD Shield

Posted by jcabrer 
Followup on Adafruit RGB LCD Shield
August 09, 2012 01:53PM
Did controlling the RGB LED over I2C make it into the firmware? When using a single color LCD, those two or three signals could be used for other stuff. Maybe via M-Codes?
Re: Followup on Adafruit RGB LCD Shield
August 10, 2012 07:36AM
So far no G-code support for this. You can set the pins at startup by changing


// For MCP 23017 define which pins should be output
#define UI_DISPLAY_I2C_OUTPUT_PINS 65504
// Set the output mask that is or'd over the output data. This is needed to activate
// a backlight switched over the I2C. 
// The adafruit RGB shields enables a light if the bit is not set. Bits 6-8 are used for backlight.
#define UI_DISPLAY_I2C_OUTPUT_START_MASK 0
in uiconfig.h

You can also set/unset the bits later in the firmware by calling

uid.setOutputMaskBits(unsigned int bits);
uid.unsetOutputMaskBits(unsigned int bits);

so writing a command for it is not a big deal. The pins will then be changed on the next write command to the display.

Any idea on which M command I could add this. Don't want to interfere with other firmwares having important functions on the same code.


Repetier-Software - the home of Repetier-Host (Windows, Linux and Mac OS X) and Repetier-Firmware.
Repetier-Server - the solution to control your printer from everywhere.
Visit us on Facebook and Twitter!
Re: Followup on Adafruit RGB LCD Shield
August 10, 2012 06:03PM
Maybe someone here knows where custom M-Codes are being maintained. I will have a look around the RepRap wiki, and see what turns up.
Re: Followup on Adafruit RGB LCD Shield
August 10, 2012 06:07PM
Apparently you can reserve code here.
Re: Followup on Adafruit RGB LCD Shield
August 11, 2012 03:11AM
Isn't very official, but I can use a not described value and describe it there. Maybe it helps avoiding the double assignments.


Repetier-Software - the home of Repetier-Host (Windows, Linux and Mac OS X) and Repetier-Firmware.
Repetier-Server - the solution to control your printer from everywhere.
Visit us on Facebook and Twitter!
Re: Followup on Adafruit RGB LCD Shield
August 16, 2012 03:33PM
How would I map 1 LED to turn on with say the Heated bed turn on? Where would I place the set/unset command?

I also replaced the buzzer activation lines since Im using an externally driven piezo buzzer on the Azteeg X3 controller. I found the code online as a function wherein you can define the freq of the buzzer but snipped these lines to make it less complicated and replaced the WRITE command to set the beeper high. While it works, Im not sure if it affects the operation of the printer because of the delays introduced. There's probably a better way of doing it. I also commented out the WRITE command to set it low a couple of lines below this on ui.cpp

#if BEEPER_TYPE==1
   //WRITE(BEEPER_PIN,HIGH);
 for (long i=0; i < 80; i++){ // for the calculated length of time...
    digitalWrite(BEEPER_PIN,HIGH); // write the buzzer pin high to push out the diaphram
    delayMicroseconds(100); // wait for the calculated delay value
    digitalWrite(BEEPER_PIN,LOW); // write the buzzer pin low to pull back the diaphram
    delayMicroseconds(80); // wait again for the calculated delay value
 }
Re: Followup on Adafruit RGB LCD Shield
August 16, 2012 04:18PM
royco Wrote:
-------------------------------------------------------
> How would I map 1 LED to turn on with say the
> Heated bed turn on? Where would I place the
> set/unset command?

That depends on what you want. The above discussed method is for a connected I2C port expander, which is used for a display and has some pins unused. Update for these outputs occurs only on display updates, which is once a second.

The right position depends on what you exactly want. Do you want so mimic the led on the ramps board, you need to put it into the ISR(PWM_TIMER_VECTOR) function at the end of Repetier.pde. There the pwms are simulated and you can turn a led in sync with the output changes.
If you want to turn it on/off depending of temperature you should do this in extruder_set_temperature and heated_bed_set_temperature in extruder.cpp. This would work well with the display method.

>
> I also replaced the buzzer activation lines since
> Im using an externally driven piezo buzzer on the
> Azteeg X3 controller. I found the code online as a
> function wherein you can define the freq of the
> buzzer but snipped these lines to make it less
> complicated and replaced the WRITE command to set
> the beeper high. While it works, Im not sure if it
> affects the operation of the printer because of
> the delays introduced. There's probably a better
> way of doing it. I also commented out the WRITE
> command to set it low a couple of lines below this
> on ui.cpp
>

Yes it stops the main thread, so no new command reading or move preprocessing occurs. The queued moves are interrupt driven, so no harm is taken, as long as the beep is not too long or frequent. That's why I choose rather short clicks for normal key feedback.

There is already a beep function in ui.cpp allowing different timings and repeat counts:
void beep(byte duration,byte count)

>
> #if BEEPER_TYPE==1
> //WRITE(BEEPER_PIN,HIGH);
> for (long i=0; i < 80; i++){ // for the
> calculated length of time...
> digitalWrite(BEEPER_PIN,HIGH); // write the
> buzzer pin high to push out the diaphram
> delayMicroseconds(100); // wait for the
> calculated delay value
> digitalWrite(BEEPER_PIN,LOW); // write the
> buzzer pin low to pull back the diaphram
> delayMicroseconds(80); // wait again for the
> calculated delay value
> }
>


Repetier-Software - the home of Repetier-Host (Windows, Linux and Mac OS X) and Repetier-Firmware.
Repetier-Server - the solution to control your printer from everywhere.
Visit us on Facebook and Twitter!
Sorry, only registered users may post in this forum.

Click here to login