Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for RRW Graphical LCD #646

Open
wants to merge 8 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ArduinoDUE/Repetier/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -1662,6 +1662,7 @@ The following settings override uiconfig.h!
21 or CONTROLLER_VIKI2 Panucatt Viki2 graphic lcd
23 or CONTROLLER_SPARKLCD_ADAPTER Sparkcube LCD on RADDS with adapter
24 or CONTROLLER_ZONESTAR = Zonestar P802M with LCD 20x4 and 5 ADC button keypad
25 or CONTROLLER_REPRAPWORLD_GLCD = ReprapWorld Graphical LCD
405 or CONTROLLER_FELIX_DUE Felix LCD für due based board
*/
#define FEATURE_CONTROLLER CONTROLLER_RADDS
Expand Down
25 changes: 23 additions & 2 deletions src/ArduinoDUE/Repetier/DisplayList.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ void uiCheckSlowKeys(uint16_t &action) {}
#endif // UI_MAIN
#endif // NO_CONTROLLER

#if (FEATURE_CONTROLLER == CONTROLLER_SMARTRAMPS) || (FEATURE_CONTROLLER == CONTROLLER_GADGETS3D_SHIELD) || (FEATURE_CONTROLLER == CONTROLLER_REPRAPDISCOUNT_GLCD) || (FEATURE_CONTROLLER == CONTROLLER_BAM_DICE_DUE)
#if (FEATURE_CONTROLLER == CONTROLLER_SMARTRAMPS) || (FEATURE_CONTROLLER == CONTROLLER_GADGETS3D_SHIELD) || (FEATURE_CONTROLLER == CONTROLLER_REPRAPDISCOUNT_GLCD) || (FEATURE_CONTROLLER == CONTROLLER_BAM_DICE_DUE) || (FEATURE_CONTROLLER == CONTROLLER_REPRAPWORLD_GLCD)
#define UI_HAS_KEYS 1
#define UI_HAS_BACK_KEY 0
#if FEATURE_CONTROLLER == CONTROLLER_REPRAPDISCOUNT_GLCD
#if FEATURE_CONTROLLER == CONTROLLER_REPRAPDISCOUNT_GLCD || FEATURE_CONTROLLER == CONTROLLER_REPRAPWORLD_GLCD
#define UI_DISPLAY_TYPE DISPLAY_U8G
#define U8GLIB_ST7920
#define UI_LCD_WIDTH 128
Expand Down Expand Up @@ -267,6 +267,27 @@ void uiCheckSlowKeys(uint16_t &action) {}
#define UI_RESET_PIN -1
#define SDCARDDETECT 49

#elif ((MOTHERBOARD == 409)) // Ultratronics

#undef BEEPER_PIN
#define BEEPER_PIN 27
#define UI_DISPLAY_RS_PIN 62
#define UI_DISPLAY_ENABLE_PIN 75
#define UI_DISPLAY_D4_PIN 76
#define UI_DISPLAY_D5_PIN -1
#define UI_DISPLAY_D6_PIN -1
#define UI_DISPLAY_D7_PIN -1
#define UI_ENCODER_A 20
#define UI_ENCODER_B 21
#define UI_ENCODER_CLICK 64
#define UI_RESET_PIN -1
#undef SDCARDDETECT
#define SDCARDDETECT 60
#undef SDCARDDETECTINVERTED
#define SDCARDDETECTINVERTED 0



#else // RAMPS
#undef BEEPER_PIN
#define BEEPER_PIN 37
Expand Down
22 changes: 11 additions & 11 deletions src/ArduinoDUE/Repetier/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
#define SPR1 1

// force SdFat to use HAL (whether or not using SW spi)
#undef SOFTWARE_SPI
//#undef SOFTWARE_SPI
#define TIMER0_PRESCALE 128

// Some structures assume no padding, need to add this attribute on ARM
Expand Down Expand Up @@ -748,49 +748,49 @@ class HAL
}
static inline uint8_t spiReceive()
{
WRITE(SDSS, LOW);
//WRITE(SDSS, LOW);
uint8_t b = spiTransfer(0xff);
WRITE(SDSS, HIGH);
//WRITE(SDSS, HIGH);
return b;
}
static inline void spiReadBlock(uint8_t*buf, uint16_t nbyte)
{
if (nbyte == 0) return;
WRITE(SDSS, LOW);
//WRITE(SDSS, LOW);
for (int i = 0; i < nbyte; i++)
{
buf[i] = spiTransfer(0xff);
}
WRITE(SDSS, HIGH);
//WRITE(SDSS, HIGH);

}
static inline void spiSend(uint8_t b) {
WRITE(SDSS, LOW);
//WRITE(SDSS, LOW);
uint8_t response = spiTransfer(b);
WRITE(SDSS, HIGH);
//WRITE(SDSS, HIGH);
}

static inline void spiSend(const uint8_t* buf , size_t n)
{
if (n == 0) return;
WRITE(SDSS, LOW);
// WRITE(SDSS, LOW);
for (uint16_t i = 0; i < n; i++) {
spiTransfer(buf[i]);
}
WRITE(SDSS, HIGH);
//WRITE(SDSS, HIGH);
}

inline __attribute__((always_inline))
static void spiSendBlock(uint8_t token, const uint8_t* buf)
{
WRITE(SDSS, LOW);
//WRITE(SDSS, LOW);
spiTransfer(token);

for (uint16_t i = 0; i < 512; i++)
{
spiTransfer(buf[i]);
}
WRITE(SDSS, HIGH);
//WRITE(SDSS, HIGH);
}

#else
Expand Down
7 changes: 7 additions & 0 deletions src/ArduinoDUE/Repetier/Printer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -920,8 +920,15 @@ uint8_t Printer::setDestinationStepsFromGCode(GCode *com)
return !com->hasNoXYZ() || (com->hasE() && destinationSteps[E_AXIS] != currentPositionSteps[E_AXIS]); // ignore unproductive moves
}



void Printer::setup()
{

#if defined(MB_SETUP)
MB_SETUP;
#endif

HAL::stopWatchdog();
for(uint8_t i = 0; i < NUM_PWM; i++) pwm_pos[i] = 0;
#if FEATURE_CONTROLLER == CONTROLLER_VIKI
Expand Down
3 changes: 2 additions & 1 deletion src/ArduinoDUE/Repetier/Repetier.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,9 @@ usage or for searching for memory induced errors. Switch it off for production,
#define CONTROLLER_LCD_MP_PHARAOH_DUE 22
#define CONTROLLER_SPARKLCD_ADAPTER 23
#define CONTROLLER_ZONESTAR 24
#define CONTROLLER_REPRAPWORLD_GLCD 25
#define CONTROLLER_FELIX_DUE 405
#define CONTROLLER_ORCABOTXXLPRO2 25
#define CONTROLLER_ORCABOTXXLPRO2 27
#define CONTROLLER_AZSMZ_12864 26

//direction flags
Expand Down
17 changes: 14 additions & 3 deletions src/ArduinoDUE/Repetier/SdFat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3075,28 +3075,39 @@ static void spiInit(uint8_t spiRate) {
//------------------------------------------------------------------------------
/** SPI receive a byte */
static uint8_t spiRec() {
return HAL::spiReceive();
WRITE(SDSS, LOW);
uint8_t retval = HAL::spiReceive();
WRITE(SDSS, HIGH);
return retval;
}
//------------------------------------------------------------------------------
/** SPI read data - only one call so force inline */
static inline __attribute__((always_inline))
uint8_t spiRec(uint8_t* buf, uint16_t nbyte) {
HAL::spiReadBlock(buf,nbyte);
return 0;
WRITE(SDSS, LOW);
HAL::spiReadBlock(buf,nbyte);
WRITE(SDSS, HIGH);
return 0;
}
//------------------------------------------------------------------------------
/** SPI send a byte */
static void spiSend(uint8_t b) {
WRITE(SDSS, LOW);
HAL::spiSend(b);
WRITE(SDSS, HIGH);
}
//------------------------------------------------------------------------------
/** SPI send block - only one call so force inline */
static inline __attribute__((always_inline))
void spiSendBlock(uint8_t token, const uint8_t* buf) {
WRITE(SDSS, LOW);
HAL::spiSendBlock(token,buf);
WRITE(SDSS, HIGH);
}
static void spiSend(const uint8_t* buf , size_t n) {
WRITE(SDSS, LOW);
HAL::spiSend(buf,n);
WRITE(SDSS, HIGH);
}

//------------------------------------------------------------------------------
Expand Down
42 changes: 38 additions & 4 deletions src/ArduinoDUE/Repetier/pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ STEPPER_CURRENT_CONTROL
#define ORIG_Y_DIR_PIN 23
#define ORIG_Y_MIN_PIN 12
#define ORIG_Y_MAX_PIN 11
#define ORIG_Y_ENABLE_PIN 9
#define ORIG_Y_ENABLE_PIN 33

#define ORIG_Z_STEP_PIN 25
#define ORIG_Z_DIR_PIN 26
Expand Down Expand Up @@ -711,6 +711,8 @@ STEPPER_CURRENT_CONTROL
#define ORIG_E3_DIR_PIN 38
#define ORIG_E3_ENABLE_PIN 40

#define UI_DISPLAY_RS_PIN 62

#define SDSUPPORT -1
#define SDPOWER -1
// 4,10,52 if using HW SPI.
Expand All @@ -721,12 +723,15 @@ STEPPER_CURRENT_CONTROL

#define ORIG_SDCARDDETECT 60
#define SDCARDDETECTINVERTED 0
#define LED_PIN -1
#define ORIG_FAN_PIN 5
#define ORIG_FAN2_PIN -1
#define LED_PIN 13
#define ORIG_FAN_PIN 6
#define ORIG_FAN2_PIN 5
#define ORIG_PS_ON_PIN -1
#define KILL_PIN -1
#define SUICIDE_PIN -1 //PIN that has to be turned on right after start, to keep power flowing.
#define ENC424_SS 61



// 20 or 70
#define SDA_PIN 70
Expand All @@ -753,6 +758,34 @@ STEPPER_CURRENT_CONTROL
// the same sd card when powering up the printer
//#define EEPROM_AVAILABLE EEPROM_NONE
#define EEPROM_AVAILABLE EEPROM_SDCARD


#define MB_SETUP SET_OUTPUT(ORIG_FAN_PIN); \
WRITE(ORIG_FAN_PIN,LOW);\
SET_OUTPUT(ORIG_FAN2_PIN);\
WRITE(ORIG_FAN2_PIN,LOW);\
SET_OUTPUT(HEATER_0_PIN);\
WRITE(HEATER_0_PIN,LOW);\
SET_OUTPUT(HEATER_1_PIN);\
WRITE(HEATER_1_PIN,LOW);\
SET_OUTPUT(HEATER_2_PIN);\
WRITE(HEATER_2_PIN,LOW);\
SET_OUTPUT(HEATER_3_PIN);\
WRITE(HEATER_3_PIN,LOW);\
SET_OUTPUT(THERMOCOUPLE_0_PIN);\
WRITE(THERMOCOUPLE_0_PIN,HIGH);\
SET_OUTPUT(THERMOCOUPLE_1_PIN);\
WRITE(THERMOCOUPLE_1_PIN,HIGH);\
SET_OUTPUT(THERMOCOUPLE_2_PIN);\
WRITE(THERMOCOUPLE_2_PIN,HIGH);\
SET_OUTPUT(THERMOCOUPLE_3_PIN);\
WRITE(THERMOCOUPLE_3_PIN,HIGH);\
SET_OUTPUT(ENC424_SS);\
WRITE(ENC424_SS,HIGH);\
SET_OUTPUT(SDSS);\
WRITE(SDSS,HIGH)


#endif


Expand Down Expand Up @@ -1501,6 +1534,7 @@ AD15 CH15
#define SCK_PIN 76
//#define DUE_SOFTWARE_SPI
#else

#define DUE_SOFTWARE_SPI
/* could be any pin with software */
#ifndef MOSI_PIN
Expand Down
45 changes: 25 additions & 20 deletions src/ArduinoDUE/Repetier/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2252,10 +2252,9 @@ void UIDisplay::refreshPage()
uid.printCols[0] = 0;
while(r < UI_ROWS) // delete trailing empty rows
strcpy(cache[r++],uid.printCols);
// compute line scrolling values
uint8_t off0 = (shift <= 0 ? 0 : shift),y;
uint8_t off[UI_ROWS+UI_ROWS_EXTRA];
for(y = 0; y < UI_ROWS+UI_ROWS_EXTRA; y++)
uint8_t off[UI_ROWS];
for(y = 0; y < UI_ROWS; y++)
{
uint8_t len = strlen(cache[y]); // length of line content
off[y] = len > UI_COLS ? RMath::min(len - UI_COLS,off0) : 0;
Expand Down Expand Up @@ -2288,7 +2287,7 @@ void UIDisplay::refreshPage()
#if FAN_PIN > -1 && FEATURE_FAN_CONTROL
int fanPercent = 0;
char fanString[2];
#endif // FAN_PIN > -1 && FEATURE_FAN_CONTROL
#endif
if(menuLevel == 0 && menuPos[0] == 0 ) // Main menu with special graphics
{
if(!Printer::isPrinting()) {
Expand All @@ -2297,7 +2296,7 @@ void UIDisplay::refreshPage()
if(extruder[0].tempControl.targetTemperatureC > 30)
#else
if(Extruder::current->tempControl.targetTemperatureC > 30)
#endif // NUM_EXTRUDER < 3
#endif
cache[0][0] = Printer::isAnimation()?'\x08':'\x09';
else
cache[0][0] = '\x0a'; //off
Expand All @@ -2306,7 +2305,7 @@ void UIDisplay::refreshPage()
cache[1][0] = Printer::isAnimation()?'\x08':'\x09';
else
cache[1][0] = '\x0a'; //off
#endif // NUM_EXTRUDER == 2 && MIXING_EXTRUDER == 0
#endif
#if HAVE_HEATED_BED
//heated bed animated icons
uint8_t lin = 2 - ((NUM_EXTRUDER != 2) ? 1 : 0);
Expand All @@ -2327,7 +2326,7 @@ void UIDisplay::refreshPage()
{
fanString[0] = '\x0e';
}
#endif // FAN_PIN > -1 && FEATURE_FAN_CONTROL
#endif
#if SDSUPPORT
//SD Card
if(sd.sdactive)
Expand All @@ -2350,10 +2349,13 @@ void UIDisplay::refreshPage()
u8g_FirstPage(&u8g);
do
{
if(menuLevel == 0 && menuPos[0] == 0 )
{
if(Printer::isPrinting()) {
#if defined(UI_HEAD)
#endif

#if UI_DISPLAY_TYPE == DISPLAY_U8G
if(menuLevel == 0 && menuPos[0] == 0 )
{
if(Printer::isPrinting()) {
#if defined(UI_HEAD)
// Show status line
u8g_SetColorIndex(&u8g,1);
u8g_draw_box(&u8g, 0, 0, u8g_GetWidth(&u8g), UI_FONT_SMALL_HEIGHT + 1);
Expand All @@ -2371,17 +2373,20 @@ void UIDisplay::refreshPage()
printU8GRow(0,UI_FONT_HEIGHT*5,cache[2]); // Layer
if(u8g_IsBBXIntersection(&u8g, 0, UI_FONT_HEIGHT*6+4 - UI_FONT_HEIGHT, 1, UI_FONT_HEIGHT))
printU8GRow(0,UI_FONT_HEIGHT*6+2,cache[UI_ROWS-1]);
#else
#else
drawHProgressBar(0,UI_FONT_HEIGHT*1+2, 128, UI_FONT_HEIGHT-1, Printer::progress);
if(u8g_IsBBXIntersection(&u8g, 0, UI_FONT_HEIGHT*3+2 - UI_FONT_HEIGHT, 1, UI_FONT_HEIGHT))
printU8GRow(85,UI_FONT_HEIGHT*3+2,cache[1]); // progress value
if(Printer::maxLayer > 0 && u8g_IsBBXIntersection(&u8g, 0, UI_FONT_HEIGHT*4+8 - UI_FONT_HEIGHT, 1, UI_FONT_HEIGHT))
printU8GRow(0,UI_FONT_HEIGHT*4+8,cache[2]); // Layer
if(u8g_IsBBXIntersection(&u8g, 0, UI_FONT_HEIGHT*6+4 - UI_FONT_HEIGHT, 1, UI_FONT_HEIGHT))
printU8GRow(0,UI_FONT_HEIGHT*6+2,cache[UI_ROWS-1]);
#endif
#endif
printRow(0, cache[0], NULL, UI_COLS); // Object name
} else { // not printing
//printRow(2, cache[1], NULL, UI_COLS);
//printRow(3, cache[2], NULL, UI_COLS); // Layer
//printRow(UI_ROWS-1, cache[UI_ROWS-1], NULL, UI_COLS); // status
} else {
u8g_SetFont(&u8g,UI_FONT_SMALL);
uint8_t py = 8;
for(uint8_t r = 0; r < 3; r++)
Expand All @@ -2407,7 +2412,7 @@ void UIDisplay::refreshPage()
printU8GRow(66,52,const_cast<char *>("SD"));
drawHProgressBar(79,46, 46, 6, sdPercent);
}
#endif // SDSUPPORT
#endif
//Status
py = u8g_GetHeight(&u8g) - 2;
if(u8g_IsBBXIntersection(&u8g, 70, py - UI_FONT_SMALL_HEIGHT, 1, UI_FONT_SMALL_HEIGHT))
Expand All @@ -2421,11 +2426,11 @@ void UIDisplay::refreshPage()
u8g_draw_vline(&u8g,62, 0, 54);
}
u8g_SetFont(&u8g, UI_FONT_DEFAULT);
} // not printing
} // menu level 0 page 0
}
}
else
{
#endif // UI_DISPLAY_TYPE == DISPLAY_U8G
#endif
#if defined(UI_HEAD) && UI_DISPLAY_TYPE == DISPLAY_U8G
// Show status line
u8g_SetColorIndex(&u8g,1);
Expand All @@ -2449,11 +2454,11 @@ void UIDisplay::refreshPage()
#endif
for(y = 0; y < UI_ROWS; y++)
printRow(y, &cache[y][off[y]], NULL, UI_COLS);
#if defined(UI_HEAD) && UI_DISPLAY_TYPE == DISPLAY_U8G
#if UI_DISPLAY_TYPE == DISPLAY_U8G
}

#endif
#if UI_DISPLAY_TYPE == DISPLAY_U8G
}
}
while( u8g_NextPage(&u8g) ); //end picture loop
#endif
Expand Down