Fork of Smoothie to port to mbed non-LPC targets.

Dependencies:   mbed

Fork of Smoothie by Stéphane Cachat

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Smoothiepanel.h Source File

Smoothiepanel.h

00001 /*
00002       This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl).
00003       Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
00004       Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
00005       You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
00006 
00007 Much of this was copied from LiquidTWI2
00008   LiquidTWI2 High Performance i2c LCD driver for MCP23008 & MCP23017
00009   hacked by Sam C. Lin / http://www.lincomatic.com
00010   from
00011    LiquidTWI by Matt Falcon (FalconFour) / http://falconfour.com
00012    logic gleaned from Adafruit RGB LCD Shield library
00013 */
00014 
00015 #ifndef SMOOTHIEPANEL_H
00016 #define SMOOTHIEPANEL_H
00017 #include "LcdBase.h"
00018 #include "libs/Pin.h"
00019 #include "Button.h"
00020 #include "smoothiepanel/Wiichuck.h"
00021 
00022 
00023 // Smoothiepanel specific settings
00024 
00025 // readButtons() will only return these bit values
00026 //#define ALL_BUTTON_BITS (BUTTON_AUX2|BUTTON_AUX1|BUTTON_SELECT)
00027 
00028 
00029 #define PCA9505_ADDRESS 0x40
00030 #define PCA9634_ADDRESS 0x50
00031 
00032 // config settings for Smoothiepanel
00033 #define panel_checksum             CHECKSUM("panel")
00034 #define i2c_pins_checksum          CHECKSUM("i2c_pins")
00035 #define i2c_address_checksum       CHECKSUM("i2c_address")
00036 #define i2c_frequency_checksum     CHECKSUM("i2c_frequency")
00037 #define i2c_interrupt_pin_checksum CHECKSUM("i2c_interrupt_pin")
00038 
00039 #define lcd_contrast_checksum      CHECKSUM("lcd_contrast")
00040 #define lcd_led_checksum           CHECKSUM("lcd_led")
00041 #define lcd_led_red_checksum       CHECKSUM("lcd_led_red")
00042 #define lcd_led_green_checksum     CHECKSUM("lcd_led_green")
00043 #define lcd_led_blue_checksum      CHECKSUM("lcd_led_blue")
00044 
00045 #define encoder_a_pin_checksum     CHECKSUM("encoder_a_pin")
00046 #define encoder_b_pin_checksum     CHECKSUM("encoder_b_pin")
00047 #define encoder_led_hue_checksum   CHECKSUM("encoder_led_hue")
00048 
00049 #define play_led_brightness_checksum CHECKSUM("play_led_brightness")
00050 #define back_led_brightness_checksum CHECKSUM("back_led_brightness")
00051 
00052 class Smoothiepanel : public LcdBase {
00053     public:
00054         Smoothiepanel();
00055         ~Smoothiepanel();
00056 
00057         void home();
00058         void clear();
00059         void display();
00060         void setCursor(uint8_t col, uint8_t row);
00061         void init();
00062         void write(const char* line, int len);
00063 
00064         void setBacklight(uint8_t status);
00065         void setBacklightColor(uint8_t r, uint8_t g, uint8_t b);
00066         void setBacklightByHue(int h);
00067         void setEncoderLED(uint8_t r, uint8_t g, uint8_t b);
00068         void setEncoderByHue(int h);
00069         void setPlayLED(uint8_t v);
00070         void setBackLED(uint8_t v);
00071 
00072         uint8_t readButtons();
00073         int readEncoderDelta();
00074         int getEncoderResolution() { return 4; }
00075 
00076         void setLed(int led, bool on);
00077         void setLedBrightness(int led, int val);
00078         void buzz(long,uint16_t);
00079 
00080         void noCursor();
00081         void cursor();
00082         void noBlink();
00083         void blink();
00084         void scrollDisplayLeft();
00085         void scrollDisplayRight();
00086         void leftToRight();
00087         void rightToLeft();
00088         void autoscroll();
00089         void noAutoscroll();
00090         void noDisplay();
00091 
00092     private:
00093 /*
00094         void send(uint8_t, uint8_t);
00095 */
00096         void command(uint8_t value);
00097 /*
00098         void burstBits16(uint16_t);
00099         void burstBits8b(uint8_t);
00100 */
00101         char displaymode;
00102         char displayfunction;
00103         char displaycontrol;
00104         char i2c_address;
00105         int i2c_frequency;
00106         int lcd_contrast;
00107         int encoder_hue;
00108         char backlight_red;
00109         char backlight_green;
00110         char backlight_blue;
00111         char backlightval;
00112         char playledval;
00113         char backledval;
00114         uint8_t _numlines,_currline;
00115 //        uint16_t _backlightBits; // only for MCP23017
00116         mbed::I2C* i2c;
00117 
00118         Pin interrupt_pin;
00119         Pin encoder_a_pin;
00120         Pin encoder_b_pin;
00121         Wiichuck* wii;
00122         bool wii_connected;
00123         bool encoder_changed;
00124 };
00125 
00126 #endif // SMOOTHIEPANEL_H