Repetier-Firmware
0.91
|
00001 /* 00002 This file is part of Repetier-Firmware. 00003 00004 Repetier-Firmware is free software: you can redistribute it and/or modify 00005 it under the terms of the GNU General Public License as published by 00006 the Free Software Foundation, either version 3 of the License, or 00007 (at your option) any later version. 00008 00009 Repetier-Firmware is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with Repetier-Firmware. If not, see <http://www.gnu.org/licenses/>. 00016 00017 */ 00018 00019 #ifndef _ui_h 00020 #define _ui_h 00021 00022 #include "gcode.h" 00023 00024 // ---------------------------------------------------------------------------- 00025 // Action codes 00026 // 1-999 : Autorepeat 00027 // 1000-1999 : Execute 00028 // 2000-2999 : Write code 00029 // 4000-4999 : Show menu 00030 // Add UI_ACTION_TOPMENU to show a menu as top menu 00031 // ---------------------------------------------------------------------------- 00032 00033 #define UI_ACTION_TOPMENU 8192 00034 00035 #define UI_ACTION_NEXT 1 00036 #define UI_ACTION_PREVIOUS 2 00037 00038 #define UI_ACTION_X_UP 100 00039 #define UI_ACTION_X_DOWN 101 00040 #define UI_ACTION_Y_UP 102 00041 #define UI_ACTION_Y_DOWN 103 00042 #define UI_ACTION_Z_UP 104 00043 #define UI_ACTION_Z_DOWN 105 00044 #define UI_ACTION_EXTRUDER_UP 106 00045 #define UI_ACTION_EXTRUDER_DOWN 107 00046 #define UI_ACTION_EXTRUDER_TEMP_UP 108 00047 #define UI_ACTION_EXTRUDER_TEMP_DOWN 109 00048 #define UI_ACTION_HEATED_BED_UP 110 00049 #define UI_ACTION_HEATED_BED_DOWN 111 00050 #define UI_ACTION_FAN_UP 112 00051 #define UI_ACTION_FAN_DOWN 113 00052 00053 #define UI_ACTION_DUMMY 10000 00054 #define UI_ACTION_BACK 1000 00055 #define UI_ACTION_OK 1001 00056 #define UI_ACTION_MENU_UP 1002 00057 #define UI_ACTION_TOP_MENU 1003 00058 #define UI_ACTION_EMERGENCY_STOP 1004 00059 #define UI_ACTION_XPOSITION 1005 00060 #define UI_ACTION_YPOSITION 1006 00061 #define UI_ACTION_ZPOSITION 1007 00062 #define UI_ACTION_EPOSITION 1008 00063 #define UI_ACTION_BED_TEMP 1009 00064 #define UI_ACTION_EXTRUDER_TEMP 1010 00065 #define UI_ACTION_SD_DELETE 1012 00066 #define UI_ACTION_SD_PRINT 1013 00067 #define UI_ACTION_SD_PAUSE 1014 00068 #define UI_ACTION_SD_CONTINUE 1015 00069 #define UI_ACTION_SD_UNMOUNT 1016 00070 #define UI_ACTION_SD_MOUNT 1017 00071 #define UI_ACTION_XPOSITION_FAST 1018 00072 #define UI_ACTION_YPOSITION_FAST 1019 00073 #define UI_ACTION_ZPOSITION_FAST 1020 00074 #define UI_ACTION_HOME_ALL 1021 00075 #define UI_ACTION_HOME_X 1022 00076 #define UI_ACTION_HOME_Y 1023 00077 #define UI_ACTION_HOME_Z 1024 00078 #define UI_ACTION_SELECT_EXTRUDER1 1025 00079 #define UI_ACTION_STORE_EEPROM 1030 00080 #define UI_ACTION_LOAD_EEPROM 1031 00081 #define UI_ACTION_PRINT_ACCEL_X 1032 00082 #define UI_ACTION_PRINT_ACCEL_Y 1033 00083 #define UI_ACTION_PRINT_ACCEL_Z 1034 00084 #define UI_ACTION_MOVE_ACCEL_X 1035 00085 #define UI_ACTION_MOVE_ACCEL_Y 1036 00086 #define UI_ACTION_MOVE_ACCEL_Z 1037 00087 #define UI_ACTION_MAX_JERK 1038 00088 #define UI_ACTION_MAX_ZJERK 1039 00089 #define UI_ACTION_BAUDRATE 1040 00090 #define UI_ACTION_HOMING_FEEDRATE_X 1041 00091 #define UI_ACTION_HOMING_FEEDRATE_Y 1042 00092 #define UI_ACTION_HOMING_FEEDRATE_Z 1043 00093 #define UI_ACTION_MAX_FEEDRATE_X 1044 00094 #define UI_ACTION_MAX_FEEDRATE_Y 1045 00095 #define UI_ACTION_MAX_FEEDRATE_Z 1046 00096 #define UI_ACTION_STEPS_X 1047 00097 #define UI_ACTION_STEPS_Y 1048 00098 #define UI_ACTION_STEPS_Z 1049 00099 #define UI_ACTION_FAN_OFF 1050 00100 #define UI_ACTION_FAN_25 1051 00101 #define UI_ACTION_FAN_50 1052 00102 #define UI_ACTION_FAN_75 1053 00103 #define UI_ACTION_FAN_FULL 1054 00104 #define UI_ACTION_FEEDRATE_MULTIPLY 1055 00105 #define UI_ACTION_STEPPER_INACTIVE 1056 00106 #define UI_ACTION_MAX_INACTIVE 1057 00107 #define UI_ACTION_PID_PGAIN 1058 00108 #define UI_ACTION_PID_IGAIN 1059 00109 #define UI_ACTION_PID_DGAIN 1060 00110 #define UI_ACTION_DRIVE_MIN 1061 00111 #define UI_ACTION_DRIVE_MAX 1062 00112 #define UI_ACTION_X_OFFSET 1063 00113 #define UI_ACTION_Y_OFFSET 1064 00114 #define UI_ACTION_EXTR_STEPS 1065 00115 #define UI_ACTION_EXTR_ACCELERATION 1066 00116 #define UI_ACTION_EXTR_MAX_FEEDRATE 1067 00117 #define UI_ACTION_EXTR_START_FEEDRATE 1068 00118 #define UI_ACTION_EXTR_HEATMANAGER 1069 00119 #define UI_ACTION_EXTR_WATCH_PERIOD 1070 00120 #define UI_ACTION_PID_MAX 1071 00121 #define UI_ACTION_ADVANCE_K 1072 00122 #define UI_ACTION_SET_ORIGIN 1073 00123 #define UI_ACTION_DEBUG_ECHO 1074 00124 #define UI_ACTION_DEBUG_INFO 1075 00125 #define UI_ACTION_DEBUG_ERROR 1076 00126 #define UI_ACTION_DEBUG_DRYRUN 1077 00127 #define UI_ACTION_POWER 1078 00128 #define UI_ACTION_PREHEAT_PLA 1079 00129 #define UI_ACTION_COOLDOWN 1080 00130 #define UI_ACTION_HEATED_BED_OFF 1081 00131 #define UI_ACTION_EXTRUDER0_OFF 1082 00132 #define UI_ACTION_EXTRUDER1_OFF 1083 00133 #define UI_ACTION_HEATED_BED_TEMP 1084 00134 #define UI_ACTION_EXTRUDER0_TEMP 1085 00135 #define UI_ACTION_EXTRUDER1_TEMP 1086 00136 #define UI_ACTION_OPS_OFF 1087 00137 #define UI_ACTION_OPS_CLASSIC 1088 00138 #define UI_ACTION_OPS_FAST 1089 00139 #define UI_ACTION_DISABLE_STEPPER 1090 00140 #define UI_ACTION_RESET_EXTRUDER 1091 00141 #define UI_ACTION_EXTRUDER_RELATIVE 1092 00142 #define UI_ACTION_SELECT_EXTRUDER0 1093 00143 #define UI_ACTION_ADVANCE_L 1094 00144 #define UI_ACTION_PREHEAT_ABS 1095 00145 #define UI_ACTION_FLOWRATE_MULTIPLY 1096 00146 #define UI_ACTION_KILL 1097 00147 #define UI_ACTION_RESET 1098 00148 #define UI_ACTION_PAUSE 1099 00149 #define UI_ACTION_EXTR_WAIT_RETRACT_TEMP 1100 00150 #define UI_ACTION_EXTR_WAIT_RETRACT_UNITS 1101 00151 #define UI_ACTION_EXTRUDER2_OFF 1102 00152 #define UI_ACTION_EXTRUDER2_TEMP 1103 00153 #define UI_ACTION_SELECT_EXTRUDER2 1104 00154 #define UI_ACTION_WRITE_DEBUG 1105 00155 #define UI_ACTION_FANSPEED 1106 00156 #define UI_ACTION_LIGHTS_ONOFF 1107 00157 #define UI_ACTION_SD_STOP 1108 00158 00159 #define UI_ACTION_MENU_XPOS 4000 00160 #define UI_ACTION_MENU_YPOS 4001 00161 #define UI_ACTION_MENU_ZPOS 4002 00162 #define UI_ACTION_MENU_XPOSFAST 4003 00163 #define UI_ACTION_MENU_YPOSFAST 4004 00164 #define UI_ACTION_MENU_ZPOSFAST 4005 00165 #define UI_ACTION_MENU_SDCARD 4006 00166 #define UI_ACTION_MENU_QUICKSETTINGS 4007 00167 #define UI_ACTION_MENU_EXTRUDER 4008 00168 #define UI_ACTION_MENU_POSITIONS 4009 00169 //#define UI_ACTION_SHOW_MEASUREMENT 4010 00170 //#define UI_ACTION_RESET_MEASUREMENT 4011 00171 #define UI_ACTION_SET_MEASURED_ORIGIN 4012 00172 #define UI_ACTION_SET_P1 4013 00173 #define UI_ACTION_SET_P2 4014 00174 #define UI_ACTION_SET_P3 4015 00175 #define UI_ACTION_CALC_LEVEL 4016 00176 00177 #define UI_ACTION_SHOW_USERMENU1 4101 00178 #define UI_ACTION_SHOW_USERMENU2 4102 00179 #define UI_ACTION_SHOW_USERMENU3 4103 00180 #define UI_ACTION_SHOW_USERMENU4 4104 00181 #define UI_ACTION_SHOW_USERMENU5 4105 00182 #define UI_ACTION_SHOW_USERMENU6 4106 00183 #define UI_ACTION_SHOW_USERMENU7 4107 00184 #define UI_ACTION_SHOW_USERMENU8 4108 00185 #define UI_ACTION_SHOW_USERMENU9 4109 00186 #define UI_ACTION_SHOW_USERMENU10 4110 00187 00188 // Load basic language definition to make sure all values are defined 00189 #include "uilang.h" 00190 00191 typedef struct { 00192 const char *text; // Menu text 00193 uint8_t menuType; // 0 = Info, 1 = Headline, 2 = submenu ref, 3 = direct action command, 4 = modify action command 00194 unsigned int action; // must be int so it gets 32 bit on arm! 00195 uint8_t filter; // allows dynamic menu filtering based on Printer::menuMode bits set. 00196 uint8_t nofilter; // Hide if one of these bits are set 00197 bool showEntry() const; 00198 } const UIMenuEntry; 00199 00200 typedef struct { 00201 // 0 = info page 00202 // 1 = file selector 00203 // 2 = submenu 00204 // 3 = modififaction menu 00205 unsigned char menuType; 00206 int id; // Type of modification 00207 int numEntries; 00208 const UIMenuEntry * const * entries; 00209 } const UIMenu; 00210 extern const int8_t encoder_table[16] PROGMEM ; 00211 00212 //#ifdef COMPILE_I2C_DRIVER 00213 00214 /************************************************************************* 00215 * Title: C include file for the I2C master interface 00216 * (i2cmaster.S or twimaster.c) 00217 * Author: Peter Fleury <pfleury@gmx.ch> http://jump.to/fleury 00218 * File: $Id: i2cmaster.h,v 1.10 2005/03/06 22:39:57 Peter Exp $ 00219 * Software: AVR-GCC 3.4.3 / avr-libc 1.2.3 00220 * Target: any AVR device 00221 * Usage: see Doxygen manual 00222 **************************************************************************/ 00223 00224 00225 00226 00227 00228 //extern const int matrixActions[] PROGMEM; 00229 // Key codes 00230 #define UI_KEYS_INIT_CLICKENCODER_LOW(pinA,pinB) SET_INPUT(pinA);SET_INPUT(pinB); PULLUP(pinA,HIGH);PULLUP(pinB,HIGH); 00231 #define UI_KEYS_INIT_BUTTON_LOW(pin) SET_INPUT(pin);PULLUP(pin,HIGH); 00232 #define UI_KEYS_INIT_CLICKENCODER_HIGH(pinA,pinB) SET_INPUT(pinA);SET_INPUT(pinB); PULLUP(pinA,LOW);PULLUP(pinB,LOW); 00233 #define UI_KEYS_INIT_BUTTON_HIGH(pin) SET_INPUT(pin);PULLUP(pin,LOW); 00234 00235 #define UI_KEYS_CLICKENCODER_LOW(pinA,pinB) uid.encoderLast = (uid.encoderLast << 2) & 0x0F;if (!READ(pinA)) uid.encoderLast |=2;if (!READ(pinB)) uid.encoderLast |=1; uid.encoderPos += pgm_read_byte(&encoder_table[uid.encoderLast]); 00236 #define UI_KEYS_CLICKENCODER_LOW_REV(pinA,pinB) uid.encoderLast = (uid.encoderLast << 2) & 0x0F;if (!READ(pinA)) uid.encoderLast |=2;if (!READ(pinB)) uid.encoderLast |=1; uid.encoderPos -= pgm_read_byte(&encoder_table[uid.encoderLast]); 00237 #define UI_KEYS_BUTTON_LOW(pin,action_) if(READ(pin)==0) action=action_; 00238 #define UI_KEYS_CLICKENCODER_HIGH(pinA,pinB) uid.encoderLast = (uid.encoderLast << 2) & 0x0F;if (READ(pinA)) uid.encoderLast |=2;if (READ(pinB)) uid.encoderLast |=1; uid.encoderPos += pgm_read_byte(&encoder_table[uid.encoderLast]); 00239 #define UI_KEYS_CLICKENCODER_HIGH_REV(pinA,pinB) uid.encoderLast = (uid.encoderLast << 2) & 0x0F;if (READ(pinA)) uid.encoderLast |=2;if (READ(pinB)) uid.encoderLast |=1; uid.encoderPos -= pgm_read_byte(&encoder_table[uid.encoderLast]); 00240 #define UI_KEYS_BUTTON_HIGH(pin,action_) if(READ(pin)!=0) action=action_; 00241 #define UI_KEYS_INIT_MATRIX(r1,r2,r3,r4,c1,c2,c3,c4) if(c1>=0){SET_INPUT(c1);WRITE(c1,HIGH);}if(c2>=0){SET_INPUT(c2);WRITE(c2,HIGH);}if(c3>=0){SET_INPUT(c3);WRITE(c3,HIGH);}\ 00242 if(c4>=0) {SET_INPUT(c4);WRITE(c4,HIGH);}if(r1>=0)SET_OUTPUT(r1);if(r2>=0)SET_OUTPUT(r2);if(r3>=0)SET_OUTPUT(r3);if(r4>=0)SET_OUTPUT(r4);\ 00243 if(r1>=0)WRITE(r1,LOW);if(r2>=0)WRITE(r2,LOW);if(r3>=0)WRITE(r3,LOW);if(r4>=0)WRITE(r4,LOW); 00244 // out.print_int_P(PSTR("r4=>c1:"),READ(c1));out.print_int_P(PSTR(" c2:"),READ(c2));out.print_int_P(PSTR(" c3:"),READ(c3));out.println_int_P(PSTR(" c4:"),READ(c4)); 00245 #define UI_KEYS_MATRIX(r1,r2,r3,r4,c1,c2,c3,c4) {uint8_t r = (c1>=0?READ(c1):0) && (c2>=0?READ(c2):0) && (c3>=0?READ(c3):0) && (c4>=0?READ(c4):0);\ 00246 if(!r) {\ 00247 r = 255;\ 00248 if(r2>=0)WRITE(r2,HIGH);if(r3>=0)WRITE(r3,HIGH);if(r4>=0)WRITE(r4,HIGH);\ 00249 if(r1>=0) {\ 00250 asm volatile ("nop\nnop\nnop\nnop\nnop");\ 00251 if(!((c1>=0?READ(c1):1) && (c2>=0?READ(c2):1) && (c3>=0?READ(c3):1) && (c4>=0?READ(c4):1))) r = 0;\ 00252 else WRITE(r1,HIGH);\ 00253 }\ 00254 if(r==255 && r2>=0) {\ 00255 WRITE(r2,LOW);asm volatile ("nop\nnop\nnop\nnop\nnop");\ 00256 if(!((c1>=0?READ(c1):1) && (c2>=0?READ(c2):1) && (c3>=0?READ(c3):1) && (c4>=0?READ(c4):1))) r = 4;\ 00257 else WRITE(r2,HIGH);\ 00258 }\ 00259 if(r==255 && r3>=0) {\ 00260 WRITE(r3,LOW);asm volatile ("nop\nnop\nnop\nnop\nnop");\ 00261 if(!((c1>=0?READ(c1):0) && (c2>=0?READ(c2):1) && (c3>=0?READ(c3):1) && (c4>=0?READ(c4):1))) r = 8;\ 00262 else WRITE(r3,HIGH);\ 00263 }\ 00264 if(r==255 && r4>=0) {\ 00265 WRITE(r4,LOW);asm volatile ("nop\nnop\nnop\nnop\nnop");\ 00266 if(!((c1>=0?READ(c1):1) && (c2>=0?READ(c2):1) && (c3>=0?READ(c3):1) && (c4>=0?READ(c4):1))) r = 12;\ 00267 else WRITE(r4,HIGH);\ 00268 }\ 00269 if(c2>=0 && !READ(c2)) r+=1;\ 00270 else if(c3>=0 && !READ(c3)) r+=2;\ 00271 else if(c4>=0 && !READ(c4)) r+=3;\ 00272 if(r<16) {action = pgm_read_word(&(matrixActions[r]));}\ 00273 }if(r1>=0)WRITE(r1,LOW);if(r2>=0)WRITE(r2,LOW);if(r3>=0)WRITE(r3,LOW);if(r4>=0)WRITE(r4,LOW);} 00274 // I2C keymask tests 00275 #define UI_KEYS_I2C_CLICKENCODER_LOW(pinA,pinB) uid.encoderLast = (uid.encoderLast << 2) & 0x0F;if (!(keymask & pinA)) uid.encoderLast |=2;if (!(keymask & pinB)) uid.encoderLast |=1; uid.encoderPos += pgm_read_byte(&encoder_table[uid.encoderLast]); 00276 #define UI_KEYS_I2C_CLICKENCODER_LOW_REV(pinA,pinB) uid.encoderLast = (uid.encoderLast << 2) & 0x0F;if (!(keymask & pinA)) uid.encoderLast |=2;if (!(keymask & pinB)) uid.encoderLast |=1; uid.encoderPos -= pgm_read_byte(&encoder_table[uid.encoderLast]); 00277 #define UI_KEYS_I2C_BUTTON_LOW(pin,action_) if((keymask & pin)==0) action=action_; 00278 #define UI_KEYS_I2C_CLICKENCODER_HIGH(pinA,pinB) uid.encoderLast = (uid.encoderLast << 2) & 0x0F;if (keymask & pinA) uid.encoderLast |=2;if (keymask & pinB) uid.encoderLast |=1; uid.encoderPos += pgm_read_byte(&encoder_table[uid.encoderLast]); 00279 #define UI_KEYS_I2C_CLICKENCODER_HIGH_REV(pinA,pinB) uid.encoderLast = (uid.encoderLast << 2) & 0x0F;if (keymask & pinA) uid.encoderLast |=2;if (keymask & pinB) uid.encoderLast |=1; uid.encoderPos -= pgm_read_byte(&encoder_table[uid.encoderLast]); 00280 #define UI_KEYS_I2C_BUTTON_HIGH(pin,action_) if((pin & keymask)!=0) action=action_; 00281 00282 #define UI_STRING(name,text) const char PROGMEM name[] = text; 00283 00284 #define UI_PAGE6(name,row1,row2,row3,row4,row5,row6) UI_STRING(name ## _1txt,row1);UI_STRING(name ## _2txt,row2);UI_STRING(name ## _3txt,row3);UI_STRING(name ## _4txt,row4);UI_STRING(name ## _5txt,row5);UI_STRING(name ## _6txt,row6);\ 00285 UIMenuEntry name ## _1 PROGMEM ={name ## _1txt,0,0,0,0};\ 00286 UIMenuEntry name ## _2 PROGMEM ={name ## _2txt,0,0,0,0};\ 00287 UIMenuEntry name ## _3 PROGMEM ={name ## _3txt,0,0,0,0};\ 00288 UIMenuEntry name ## _4 PROGMEM ={name ## _4txt,0,0,0,0};\ 00289 UIMenuEntry name ## _5 PROGMEM ={name ## _5txt,0,0,0,0};\ 00290 UIMenuEntry name ## _6 PROGMEM ={name ## _6txt,0,0,0,0};\ 00291 const UIMenuEntry * const name ## _entries [] PROGMEM = {&name ## _1,&name ## _2,&name ## _3,&name ## _4,&name ## _5,&name ## _6};\ 00292 const UIMenu name PROGMEM = {0,0,6,name ## _entries}; 00293 #define UI_PAGE4(name,row1,row2,row3,row4) UI_STRING(name ## _1txt,row1);UI_STRING(name ## _2txt,row2);UI_STRING(name ## _3txt,row3);UI_STRING(name ## _4txt,row4);\ 00294 UIMenuEntry name ## _1 PROGMEM ={name ## _1txt,0,0,0,0};\ 00295 UIMenuEntry name ## _2 PROGMEM ={name ## _2txt,0,0,0,0};\ 00296 UIMenuEntry name ## _3 PROGMEM ={name ## _3txt,0,0,0,0};\ 00297 UIMenuEntry name ## _4 PROGMEM ={name ## _4txt,0,0,0,0};\ 00298 const UIMenuEntry * const name ## _entries [] PROGMEM = {&name ## _1,&name ## _2,&name ## _3,&name ## _4};\ 00299 const UIMenu name PROGMEM = {0,0,4,name ## _entries}; 00300 #define UI_PAGE2(name,row1,row2) UI_STRING(name ## _1txt,row1);UI_STRING(name ## _2txt,row2);\ 00301 UIMenuEntry name ## _1 PROGMEM ={name ## _1txt,0,0,0,0};\ 00302 UIMenuEntry name ## _2 PROGMEM ={name ## _2txt,0,0,0,0};\ 00303 const UIMenuEntry * const name ## _entries[] PROGMEM = {&name ## _1,&name ## _2};\ 00304 const UIMenu name PROGMEM = {0,0,2,name ## _entries}; 00305 #define UI_MENU_ACTION4C(name,action,rows) UI_MENU_ACTION4(name,action,rows) 00306 #define UI_MENU_ACTION2C(name,action,rows) UI_MENU_ACTION2(name,action,rows) 00307 #define UI_MENU_ACTION4(name,action,row1,row2,row3,row4) UI_STRING(name ## _1txt,row1);UI_STRING(name ## _2txt,row2);UI_STRING(name ## _3txt,row3);UI_STRING(name ## _4txt,row4);\ 00308 UIMenuEntry name ## _1 PROGMEM ={name ## _1txt,0,0,0,0};\ 00309 UIMenuEntry name ## _2 PROGMEM ={name ## _2txt,0,0,0,0};\ 00310 UIMenuEntry name ## _3 PROGMEM ={name ## _3txt,0,0,0,0};\ 00311 UIMenuEntry name ## _4 PROGMEM ={name ## _4txt,0,0,0,0};\ 00312 const UIMenuEntry * const name ## _entries[] PROGMEM = {&name ## _1,&name ## _2,&name ## _3,&name ## _4};\ 00313 const UIMenu name PROGMEM = {3,action,4,name ## _entries}; 00314 #define UI_MENU_ACTION2(name,action,row1,row2) UI_STRING(name ## _1txt,row1);UI_STRING(name ## _2txt,row2);\ 00315 UIMenuEntry name ## _1 PROGMEM ={name ## _1txt,0,0,0,0};\ 00316 UIMenuEntry name ## _2 PROGMEM ={name ## _2txt,0,0,0,0};\ 00317 const UIMenuEntry * const name ## _entries[] PROGMEM = {&name ## _1,&name ## _2};\ 00318 const UIMenu name PROGMEM = {3,action,2,name ## _entries}; 00319 #define UI_MENU_HEADLINE(name,text) UI_STRING(name ## _txt,text);UIMenuEntry name PROGMEM = {name ## _txt,1,0,0,0}; 00320 #define UI_MENU_CHANGEACTION(name,row,action) UI_STRING(name ## _txt,row);UIMenuEntry name PROGMEM = {name ## _txt,4,action,0,0}; 00321 #define UI_MENU_ACTIONCOMMAND(name,row,action) UI_STRING(name ## _txt,row);UIMenuEntry name PROGMEM = {name ## _txt,3,action,0,0}; 00322 #define UI_MENU_ACTIONSELECTOR(name,row,entries) UI_STRING(name ## _txt,row);UIMenuEntry name PROGMEM = {name ## _txt,2,(unsigned int)&entries,0,0}; 00323 #define UI_MENU_SUBMENU(name,row,entries) UI_STRING(name ## _txt,row);UIMenuEntry name PROGMEM = {name ## _txt,2,(unsigned int)&entries,0,0}; 00324 #define UI_MENU_CHANGEACTION_FILTER(name,row,action,filter,nofilter) UI_STRING(name ## _txt,row);UIMenuEntry name PROGMEM = {name ## _txt,4,action,filter,nofilter}; 00325 #define UI_MENU_ACTIONCOMMAND_FILTER(name,row,action,filter,nofilter) UI_STRING(name ## _txt,row);UIMenuEntry name PROGMEM = {name ## _txt,3,action,filter,nofilter}; 00326 #define UI_MENU_ACTIONSELECTOR_FILTER(name,row,entries,filter,nofilter) UI_STRING(name ## _txt,row);UIMenuEntry name PROGMEM = {name ## _txt,2,(unsigned int)&entries,filter,nofilter}; 00327 #define UI_MENU_SUBMENU_FILTER(name,row,entries,filter,nofilter) UI_STRING(name ## _txt,row);UIMenuEntry name PROGMEM = {name ## _txt,2,(unsigned int)&entries,filter,nofilter}; 00328 #define UI_MENU(name,items,itemsCnt) const UIMenuEntry * const name ## _entries[] PROGMEM = items;const UIMenu name PROGMEM = {2,0,itemsCnt,name ## _entries} 00329 #define UI_MENU_FILESELECT(name,items,itemsCnt) const UIMenuEntry * const name ## _entries[] PROGMEM = items;const UIMenu name PROGMEM = {1,0,itemsCnt,name ## _entries} 00330 00331 #if FEATURE_CONTROLLER==2 || FEATURE_CONTROLLER==10 || FEATURE_CONTROLLER==11 // reprapdiscount smartcontroller has a sd card buildin 00332 #undef SDCARDDETECT 00333 #define SDCARDDETECT 49 00334 #undef SDCARDDETECTINVERTED 00335 #define SDCARDDETECTINVERTED false 00336 #undef SDSUPPORT 00337 #define SDSUPPORT true 00338 #endif 00339 00340 // Maximum size of a row - if row is larger, text gets scrolled 00341 #define MAX_COLS 28 00342 00343 class UIDisplay { 00344 public: 00345 volatile uint8_t flags; // 1 = fast key action, 2 = slow key action, 4 = slow action running, 8 = key test running 00346 uint8_t col; // current col for buffer prefill 00347 uint8_t menuLevel; // current menu level, 0 = info, 1 = group, 2 = groupdata select, 3 = value change 00348 uint8_t menuPos[5]; // Positions in menu 00349 void *menu[5]; // Menus active 00350 uint8_t menuTop[5]; // Top row in menu 00351 int8_t shift; // Display shift for scrolling text 00352 int pageDelay; // Counter. If 0 page is refreshed if menuLevel is 0. 00353 void *errorMsg; 00354 uint16_t activeAction; // action for ok/next/previous 00355 uint16_t lastAction; 00356 millis_t lastSwitch; // Last time display switched pages 00357 millis_t lastRefresh; 00358 uint16_t lastButtonAction; 00359 millis_t lastButtonStart; 00360 millis_t nextRepeat; // Time of next autorepeat 00361 millis_t lastNextPrev; // for increasing speed settings 00362 float lastNextAccumul; // Accumulated value 00363 unsigned int outputMask; // Output mask for backlight, leds etc. 00364 int repeatDuration; // Time beween to actions if autorepeat is enabled 00365 int8_t oldMenuLevel; 00366 uint8_t encoderStartScreen; 00367 void addInt(int value,uint8_t digits,char fillChar=' '); // Print int into printCols 00368 void addLong(long value,char digits); 00369 void addFloat(float number, char fixdigits,uint8_t digits); 00370 void addStringP(PGM_P text); 00371 void okAction(); 00372 void nextPreviousAction(int8_t next); 00373 char statusMsg[17]; 00374 int8_t encoderPos; 00375 int8_t encoderLast; 00376 PGM_P statusText; 00377 UIDisplay(); 00378 void createChar(uint8_t location,const uint8_t charmap[]); 00379 void initialize(); // Initialize display and keys 00380 void waitForKey(); 00381 void printRow(uint8_t r,char *txt,char *txt2,uint8_t changeAtCol); // Print row on display 00382 void printRowP(uint8_t r,PGM_P txt); 00383 void parse(char *txt,bool ram); 00384 void refreshPage(); 00385 void executeAction(int action); 00386 void finishAction(int action); 00387 void slowAction(); 00388 void fastAction(); 00389 void mediumAction(); 00390 void pushMenu(void *men,bool refresh); 00391 void setStatusP(PGM_P txt); 00392 void setStatus(char *txt); 00393 inline void setOutputMaskBits(unsigned int bits) {outputMask|=bits;} 00394 inline void unsetOutputMaskBits(unsigned int bits) {outputMask&=~bits;} 00395 #if SDSUPPORT 00396 void updateSDFileCount(); 00397 //void sdrefresh(uint8_t &r,char cache[UI_ROWS][MAX_COLS+1]); 00398 void goDir(char *name); 00399 bool isDirname(char *name); 00400 char cwd[SD_MAX_FOLDER_DEPTH*LONG_FILENAME_LENGTH+2]; 00401 uint8_t folderLevel; 00402 #endif 00403 }; 00404 extern UIDisplay uid; 00405 00406 00407 #if FEATURE_CONTROLLER==1 00408 #include "uiconfig.h" 00409 #endif 00410 #if FEATURE_CONTROLLER==0 // No controller at all 00411 #define UI_HAS_KEYS 0 00412 #define UI_DISPLAY_TYPE 0 00413 #ifdef UI_MAIN 00414 void ui_init_keys() {} 00415 void ui_check_keys(int &action) {} 00416 inline void ui_check_slow_encoder() {} 00417 void ui_check_slow_keys(int &action) {} 00418 #endif 00419 #endif 00420 #if FEATURE_CONTROLLER==2 || FEATURE_CONTROLLER==10 || FEATURE_CONTROLLER==11 // reprapdiscount smartcontroller (2) gadgets3d (10) 00421 #define UI_HAS_KEYS 1 00422 #define UI_HAS_BACK_KEY 0 00423 #if FEATURE_CONTROLLER==11 00424 #define UI_DISPLAY_TYPE 5 00425 #define U8GLIB_ST7920 00426 #define UI_LCD_WIDTH 128 00427 #define UI_LCD_HEIGHT 64 00428 00429 //select font size 00430 #define UI_FONT_6X10 //default font 00431 #ifdef UI_FONT_6X10 00432 #define UI_FONT_WIDTH 6 00433 #define UI_FONT_HEIGHT 10 00434 #define UI_FONT_SMALL_HEIGHT 7 00435 #define UI_FONT_DEFAULT repetier_6x10 00436 #define UI_FONT_SMALL repetier_5x7 00437 #define UI_FONT_SMALL_WIDTH 5 //smaller font for status display 00438 #define UI_ANIMATION false // Animations are too slow 00439 #endif 00440 00441 //calculate rows and cols available with current font 00442 #define UI_COLS (UI_LCD_WIDTH/UI_FONT_WIDTH) 00443 #define UI_ROWS (UI_LCD_HEIGHT/UI_FONT_HEIGHT) 00444 #define UI_DISPLAY_CHARSET 3 00445 #else 00446 #define UI_DISPLAY_TYPE 1 00447 #define UI_DISPLAY_CHARSET 1 00448 #define UI_COLS 20 00449 #define UI_ROWS 4 00450 #endif 00451 #define BEEPER_TYPE 1 00452 #if FEATURE_CONTROLLER==10 // Gadgets3d shield 00453 #define BEEPER_PIN 33 00454 #define UI_DISPLAY_RS_PIN 16 00455 #define UI_DISPLAY_RW_PIN -1 00456 #define UI_DISPLAY_ENABLE_PIN 17 00457 #define UI_DISPLAY_D0_PIN 23 00458 #define UI_DISPLAY_D1_PIN 25 00459 #define UI_DISPLAY_D2_PIN 27 00460 #define UI_DISPLAY_D3_PIN 29 00461 #define UI_DISPLAY_D4_PIN 23 00462 #define UI_DISPLAY_D5_PIN 25 00463 #define UI_DISPLAY_D6_PIN 27 00464 #define UI_DISPLAY_D7_PIN 29 00465 #define UI_ENCODER_A 35 00466 #define UI_ENCODER_B 37 00467 #define UI_ENCODER_CLICK 31 00468 #define UI_RESET_PIN 41 00469 #else // Smartcontroller 00470 #if MOTHERBOARD==80 // Rumba has different pins as RAMPS! 00471 #define BEEPER_PIN 44 00472 #define UI_DISPLAY_RS_PIN 19 00473 #define UI_DISPLAY_RW_PIN -1 00474 #define UI_DISPLAY_ENABLE_PIN 42 00475 #define UI_DISPLAY_D0_PIN 18 00476 #define UI_DISPLAY_D1_PIN 38 00477 #define UI_DISPLAY_D2_PIN 41 00478 #define UI_DISPLAY_D3_PIN 40 00479 #define UI_DISPLAY_D4_PIN 18 00480 #define UI_DISPLAY_D5_PIN 38 00481 #define UI_DISPLAY_D6_PIN 41 00482 #define UI_DISPLAY_D7_PIN 40 00483 #define UI_ENCODER_A 12 00484 #define UI_ENCODER_B 11 00485 #define UI_ENCODER_CLICK 43 00486 #define UI_RESET_PIN 46 00487 #else 00488 #define BEEPER_PIN 37 00489 #define UI_DISPLAY_RS_PIN 16 00490 #define UI_DISPLAY_RW_PIN -1 00491 #define UI_DISPLAY_ENABLE_PIN 17 00492 #define UI_DISPLAY_D0_PIN 23 00493 #define UI_DISPLAY_D1_PIN 25 00494 #define UI_DISPLAY_D2_PIN 27 00495 #define UI_DISPLAY_D3_PIN 29 00496 #define UI_DISPLAY_D4_PIN 23 00497 #define UI_DISPLAY_D5_PIN 25 00498 #define UI_DISPLAY_D6_PIN 27 00499 #define UI_DISPLAY_D7_PIN 29 00500 #define UI_ENCODER_A 33 00501 #define UI_ENCODER_B 31 00502 #define UI_ENCODER_CLICK 35 00503 #define UI_RESET_PIN 41 00504 #endif 00505 #endif 00506 #define UI_DELAYPERCHAR 320 00507 #define UI_INVERT_MENU_DIRECTION false 00508 #ifdef UI_MAIN 00509 void ui_init_keys() { 00510 UI_KEYS_INIT_CLICKENCODER_LOW(UI_ENCODER_A,UI_ENCODER_B); // click encoder on pins 47 and 45. Phase is connected with gnd for signals. 00511 UI_KEYS_INIT_BUTTON_LOW(UI_ENCODER_CLICK); // push button, connects gnd to pin 00512 UI_KEYS_INIT_BUTTON_LOW(UI_RESET_PIN); // Kill pin 00513 } 00514 void ui_check_keys(int &action) { 00515 UI_KEYS_CLICKENCODER_LOW_REV(UI_ENCODER_A,UI_ENCODER_B); // click encoder on pins 47 and 45. Phase is connected with gnd for signals. 00516 UI_KEYS_BUTTON_LOW(UI_ENCODER_CLICK,UI_ACTION_OK); // push button, connects gnd to pin 00517 UI_KEYS_BUTTON_LOW(UI_RESET_PIN,UI_ACTION_RESET); 00518 } 00519 inline void ui_check_slow_encoder() {} 00520 void ui_check_slow_keys(int &action) {} 00521 #endif 00522 #endif // Controller 2 and 10 00523 00524 #if FEATURE_CONTROLLER==3 // Adafruit RGB controller 00525 #define UI_HAS_KEYS 1 00526 #define UI_HAS_BACK_KEY 1 00527 #define UI_DISPLAY_TYPE 3 00528 #define UI_DISPLAY_CHARSET 1 00529 #define UI_COLS 16 00530 #define UI_ROWS 2 00531 #define UI_DISPLAY_I2C_CHIPTYPE 1 00532 #define UI_DISPLAY_I2C_ADDRESS 0x40 00533 #define UI_DISPLAY_I2C_OUTPUT_PINS 65504 00534 #define UI_DISPLAY_I2C_OUTPUT_START_MASK 0 00535 #define UI_DISPLAY_I2C_PULLUP 31 00536 #define UI_I2C_CLOCKSPEED 400000L 00537 #define UI_DISPLAY_RS_PIN _BV(15) 00538 #define UI_DISPLAY_RW_PIN _BV(14) 00539 #define UI_DISPLAY_ENABLE_PIN _BV(13) 00540 #define UI_DISPLAY_D0_PIN _BV(12) 00541 #define UI_DISPLAY_D1_PIN _BV(11) 00542 #define UI_DISPLAY_D2_PIN _BV(10) 00543 #define UI_DISPLAY_D3_PIN _BV(9) 00544 #define UI_DISPLAY_D4_PIN _BV(12) 00545 #define UI_DISPLAY_D5_PIN _BV(11) 00546 #define UI_DISPLAY_D6_PIN _BV(10) 00547 #define UI_DISPLAY_D7_PIN _BV(9) 00548 #define UI_INVERT_MENU_DIRECTION true 00549 #define UI_HAS_I2C_KEYS 00550 #define UI_HAS_I2C_ENCODER 0 00551 #define UI_I2C_KEY_ADDRESS 0x40 00552 #ifdef UI_MAIN 00553 void ui_init_keys() {} 00554 void ui_check_keys(int &action) {} 00555 inline void ui_check_slow_encoder() { 00556 HAL::i2cStartWait(UI_DISPLAY_I2C_ADDRESS+I2C_WRITE); 00557 HAL::i2cWrite(0x12); // GIOA 00558 HAL::i2cStop(); 00559 HAL::i2cStartWait(UI_DISPLAY_I2C_ADDRESS+I2C_READ); 00560 unsigned int keymask = HAL::i2cReadAck(); 00561 keymask = keymask + (HAL::i2cReadNak()<<8); 00562 HAL::i2cStop(); 00563 } 00564 void ui_check_slow_keys(int &action) { 00565 HAL::i2cStartWait(UI_DISPLAY_I2C_ADDRESS+I2C_WRITE); 00566 HAL::i2cWrite(0x12); // GPIOA 00567 HAL::i2cStop(); 00568 HAL::i2cStartWait(UI_DISPLAY_I2C_ADDRESS+I2C_READ); 00569 unsigned int keymask = HAL::i2cReadAck(); 00570 keymask = keymask + (HAL::i2cReadNak()<<8); 00571 HAL::i2cStop(); 00572 UI_KEYS_I2C_BUTTON_LOW(4,UI_ACTION_PREVIOUS); // Up button 00573 UI_KEYS_I2C_BUTTON_LOW(8,UI_ACTION_NEXT); // down button 00574 UI_KEYS_I2C_BUTTON_LOW(16,UI_ACTION_BACK); // left button 00575 UI_KEYS_I2C_BUTTON_LOW(2,UI_ACTION_OK); // right button 00576 UI_KEYS_I2C_BUTTON_LOW(1,UI_ACTION_MENU_QUICKSETTINGS); //Select button 00577 } 00578 #endif 00579 #endif // Controller 3 00580 00581 #if FEATURE_CONTROLLER==4 // Foltyn 3D Master 00582 #define UI_HAS_KEYS 1 00583 #define UI_HAS_BACK_KEY 1 00584 #define UI_DISPLAY_TYPE 1 00585 #define UI_DISPLAY_CHARSET 2 00586 #define UI_COLS 20 00587 #define UI_ROWS 4 00588 #define UI_DISPLAY_RS_PIN 63 // PINK.1, 88, D_RS 00589 #define UI_DISPLAY_RW_PIN -1 00590 #define UI_DISPLAY_ENABLE_PIN 65 // PINK.3, 86, D_E 00591 #define UI_DISPLAY_D0_PIN 59 // PINF.5, 92, D_D4 00592 #define UI_DISPLAY_D1_PIN 64 // PINK.2, 87, D_D5 00593 #define UI_DISPLAY_D2_PIN 44 // PINL.5, 40, D_D6 00594 #define UI_DISPLAY_D3_PIN 66 // PINK.4, 85, D_D7 00595 #define UI_DISPLAY_D4_PIN 59 // PINF.5, 92, D_D4 00596 #define UI_DISPLAY_D5_PIN 64 // PINK.2, 87, D_D5 00597 #define UI_DISPLAY_D6_PIN 44 // PINL.5, 40, D_D6 00598 #define UI_DISPLAY_D7_PIN 66 // PINK.4, 85, D_D7 00599 #define UI_DELAYPERCHAR 320 00600 #define UI_INVERT_MENU_DIRECTION false 00601 #ifdef UI_MAIN 00602 void ui_init_keys() { 00603 UI_KEYS_INIT_BUTTON_LOW(4); // push button, connects gnd to pin 00604 UI_KEYS_INIT_BUTTON_LOW(5); 00605 UI_KEYS_INIT_BUTTON_LOW(6); 00606 UI_KEYS_INIT_BUTTON_LOW(11); 00607 UI_KEYS_INIT_BUTTON_LOW(42); 00608 } 00609 void ui_check_keys(int &action) { 00610 UI_KEYS_BUTTON_LOW(4,UI_ACTION_OK); // push button, connects gnd to pin 00611 UI_KEYS_BUTTON_LOW(5,UI_ACTION_NEXT); // push button, connects gnd to pin 00612 UI_KEYS_BUTTON_LOW(6,UI_ACTION_PREVIOUS); // push button, connects gnd to pin 00613 UI_KEYS_BUTTON_LOW(11,UI_ACTION_BACK); // push button, connects gnd to pin 00614 UI_KEYS_BUTTON_LOW(42,UI_ACTION_SD_PRINT ); // push button, connects gnd to pin 00615 } 00616 inline void ui_check_slow_encoder() {} 00617 void ui_check_slow_keys(int &action) {} 00618 #endif 00619 #endif // Controller 4 00620 00621 00622 #if FEATURE_CONTROLLER==5 // Viki Lcd 00623 00624 // You need to change these 3 button according to the positions 00625 // where you put them into your board! 00626 #define UI_ENCODER_A 7 // pins the click encoder are connected to 00627 #define UI_ENCODER_B 22 00628 #define UI_RESET_PIN 32 // single button for reset 00629 #define SDCARDDETECT 49 // Set to -1 if you have not connected that pin 00630 #define SDSS 53 // Chip select pin 00631 00632 #define SDSUPPORT true 00633 #define SDCARDDETECTINVERTED false 00634 00635 #define UI_HAS_KEYS 1 00636 #define UI_HAS_BACK_KEY 1 00637 #define UI_DISPLAY_TYPE 3 00638 #define UI_DISPLAY_CHARSET 1 00639 #define UI_COLS 20 00640 #define UI_ROWS 4 00641 #define UI_DISPLAY_I2C_CHIPTYPE 1 00642 #define UI_DISPLAY_I2C_ADDRESS 0x40 00643 #define UI_DISPLAY_I2C_OUTPUT_PINS 0xFFE0 00644 #define UI_DISPLAY_I2C_OUTPUT_START_MASK 0x01C0 // bits that are high always, for now the 3 viki leds 00645 #define UI_DISPLAY_I2C_PULLUP 0x001F 00646 #define UI_I2C_CLOCKSPEED 100000L // Note with very long cables make this much smaller, for 2ft cables I found 80000 worked ok 00647 00648 #define UI_DISPLAY_RS_PIN _BV(15) 00649 #define UI_DISPLAY_RW_PIN _BV(14) 00650 #define UI_DISPLAY_ENABLE_PIN _BV(13) 00651 #define UI_DISPLAY_D0_PIN _BV(12) 00652 #define UI_DISPLAY_D1_PIN _BV(11) 00653 #define UI_DISPLAY_D2_PIN _BV(10) 00654 #define UI_DISPLAY_D3_PIN _BV(9) 00655 #define UI_DISPLAY_D4_PIN _BV(12) 00656 #define UI_DISPLAY_D5_PIN _BV(11) 00657 #define UI_DISPLAY_D6_PIN _BV(10) 00658 #define UI_DISPLAY_D7_PIN _BV(9) 00659 00660 00661 #if true || !defined(BEEPER_PIN) || BEEPER_PIN<0 00662 #define BEEPER_PIN _BV(5) 00663 #define BEEPER_TYPE 2 00664 #define BEEPER_ADDRESS UI_DISPLAY_I2C_ADDRESS // I2C address of the chip with the beeper pin 00665 #endif 00666 #define UI_I2C_HEATBED_LED _BV(8) 00667 #define UI_I2C_HOTEND_LED _BV(7) 00668 #define UI_I2C_FAN_LED _BV(6) 00669 00670 #define UI_INVERT_MENU_DIRECTION false 00671 #define UI_HAS_I2C_KEYS 00672 #define UI_HAS_I2C_ENCODER 0 00673 #define UI_I2C_KEY_ADDRESS 0x40 00674 #ifdef UI_MAIN 00675 void ui_init_keys() { 00676 UI_KEYS_INIT_CLICKENCODER_LOW(UI_ENCODER_A,UI_ENCODER_B); // click encoder on real pins. Phase is connected with gnd for signals. 00677 UI_KEYS_INIT_BUTTON_LOW(UI_RESET_PIN); // Kill pin 00678 } 00679 void ui_check_keys(int &action) { 00680 UI_KEYS_CLICKENCODER_LOW_REV(UI_ENCODER_A,UI_ENCODER_B); // click encoder on real pins 00681 UI_KEYS_BUTTON_LOW(UI_RESET_PIN,UI_ACTION_RESET); 00682 } 00683 inline void ui_check_slow_encoder() { }// not used in Viki 00684 void ui_check_slow_keys(int &action) { 00685 HAL::i2cStartWait(UI_DISPLAY_I2C_ADDRESS+I2C_WRITE); 00686 HAL::i2cWrite(0x12); // GPIOA 00687 HAL::i2cStop(); 00688 HAL::i2cStartWait(UI_DISPLAY_I2C_ADDRESS+I2C_READ); 00689 unsigned int keymask = HAL::i2cReadAck(); 00690 keymask = keymask + (HAL::i2cReadNak()<<8); 00691 HAL::i2cStop(); 00692 UI_KEYS_I2C_BUTTON_LOW(4,UI_ACTION_MENU_SDCARD); // Up button 00693 UI_KEYS_I2C_BUTTON_LOW(8,UI_ACTION_MENU_QUICKSETTINGS); // down button 00694 UI_KEYS_I2C_BUTTON_LOW(16,UI_ACTION_BACK); // left button 00695 UI_KEYS_I2C_BUTTON_LOW(2,UI_ACTION_MENU_POSITIONS); // right button 00696 UI_KEYS_I2C_BUTTON_LOW(1,UI_ACTION_OK); //Select button 00697 00698 } 00699 #endif 00700 #endif // Controller 5 00701 00702 #if FEATURE_CONTROLLER==6 // ReprapWorld Keypad / LCD 00703 #define UI_HAS_KEYS 1 00704 #define UI_HAS_BACK_KEY 0 00705 #define UI_DISPLAY_TYPE 1 00706 #define UI_DISPLAY_CHARSET 0 00707 #define UI_COLS 20 00708 #define UI_ROWS 2 00709 00710 #if MOTHERBOARD==701 // Megatronics v2.0 00711 #define UI_DISPLAY_RS_PIN 14 00712 #define UI_DISPLAY_RW_PIN -1 00713 #define UI_DISPLAY_ENABLE_PIN 15 00714 #define UI_DISPLAY_D4_PIN 30 00715 #define UI_DISPLAY_D5_PIN 31 00716 #define UI_DISPLAY_D6_PIN 32 00717 #define UI_DISPLAY_D7_PIN 33 00718 #define UI_ENCODER_A 61 00719 #define UI_ENCODER_B 59 00720 #define UI_ENCODER_CLICK 43 00721 00722 #define UI_SHIFT_OUT 17 00723 #define UI_SHIFT_LD 42 00724 #define UI_SHIFT_CLK 63 00725 00726 #else // RAMPS 1.4 00727 #define UI_DISPLAY_RS_PIN 16 00728 #define UI_DISPLAY_RW_PIN -1 00729 #define UI_DISPLAY_ENABLE_PIN 17 00730 #define UI_DISPLAY_D4_PIN 23 00731 #define UI_DISPLAY_D5_PIN 25 00732 #define UI_DISPLAY_D6_PIN 27 00733 #define UI_DISPLAY_D7_PIN 29 00734 #define UI_ENCODER_A 64 00735 #define UI_ENCODER_B 59 00736 #define UI_ENCODER_CLICK 63 00737 00738 #define UI_SHIFT_OUT 40 00739 #define UI_SHIFT_LD 42 00740 #define UI_SHIFT_CLK 44 00741 #endif 00742 00743 #define UI_DELAYPERCHAR 320 00744 #define UI_INVERT_MENU_DIRECTION true 00745 #ifdef UI_MAIN 00746 void ui_init_keys() { 00747 UI_KEYS_INIT_CLICKENCODER_LOW(UI_ENCODER_A,UI_ENCODER_B); 00748 UI_KEYS_INIT_BUTTON_LOW(UI_ENCODER_CLICK); 00749 00750 SET_OUTPUT(UI_SHIFT_CLK); 00751 SET_OUTPUT(UI_SHIFT_LD); 00752 SET_INPUT(UI_SHIFT_OUT); 00753 00754 WRITE(UI_SHIFT_OUT,HIGH); 00755 WRITE(UI_SHIFT_LD,HIGH); 00756 } 00757 00758 void ui_check_keys(int &action) { 00759 UI_KEYS_CLICKENCODER_LOW_REV(UI_ENCODER_A,UI_ENCODER_B); 00760 UI_KEYS_BUTTON_LOW(UI_ENCODER_CLICK,UI_ACTION_OK); 00761 } 00762 00763 inline void ui_check_slow_encoder() {} // not used 00764 00765 void ui_check_slow_keys(int &action) { 00766 00767 WRITE(UI_SHIFT_LD,LOW); 00768 WRITE(UI_SHIFT_LD,HIGH); 00769 00770 for(int8_t i=1;i<=8;i++) { 00771 if(!READ(UI_SHIFT_OUT)) { // pressed button = logical 0 (false) 00772 switch (i) { 00773 case 1: action = UI_ACTION_Z_DOWN; break; // F3 00774 case 2: action = UI_ACTION_Z_UP; break; // F2 00775 case 3: action = UI_ACTION_EMERGENCY_STOP; break; // F1 00776 case 4: action = UI_ACTION_Y_UP; break; // UP 00777 case 5: action = UI_ACTION_X_UP; break; // RIGHT 00778 case 6: action = UI_ACTION_HOME_ALL; break; // MID 00779 case 7: action = UI_ACTION_Y_DOWN; break; // DOWN 00780 case 8: action = UI_ACTION_X_DOWN; break; // LEFT 00781 } 00782 i = 9; // if button detected, exit "for loop" 00783 } 00784 WRITE(UI_SHIFT_CLK,HIGH); 00785 WRITE(UI_SHIFT_CLK,LOW); 00786 } 00787 } 00788 #endif 00789 #endif // Controller 6 00790 #if FEATURE_CONTROLLER==7 // RADDS pin assignment for displays 00791 #define UI_HAS_KEYS 1 00792 #define UI_HAS_BACK_KEY 0 00793 #define UI_DISPLAY_TYPE 1 00794 #define UI_DISPLAY_CHARSET 1 00795 #define BEEPER_TYPE 1 00796 #define UI_COLS 20 00797 #define UI_ROWS 4 00798 #define BEEPER_PIN 41 00799 #define UI_DISPLAY_RS_PIN 42 00800 #define UI_DISPLAY_RW_PIN -1 00801 #define UI_DISPLAY_ENABLE_PIN 43 00802 #define UI_DISPLAY_D0_PIN 44 00803 #define UI_DISPLAY_D1_PIN 45 00804 #define UI_DISPLAY_D2_PIN 46 00805 #define UI_DISPLAY_D3_PIN 47 00806 #define UI_DISPLAY_D4_PIN 44 00807 #define UI_DISPLAY_D5_PIN 45 00808 #define UI_DISPLAY_D6_PIN 46 00809 #define UI_DISPLAY_D7_PIN 47 00810 #define UI_ENCODER_A 52 00811 #define UI_ENCODER_B 50 00812 #define UI_ENCODER_CLICK 48 00813 #define UI_RESET_PIN -1 00814 #define UI_DELAYPERCHAR 320 00815 #define UI_INVERT_MENU_DIRECTION false 00816 #ifdef UI_MAIN 00817 void ui_init_keys() { 00818 UI_KEYS_INIT_CLICKENCODER_LOW(UI_ENCODER_A,UI_ENCODER_B); // click encoder on pins 47 and 45. Phase is connected with gnd for signals. 00819 UI_KEYS_INIT_BUTTON_LOW(UI_ENCODER_CLICK); // push button, connects gnd to pin 00820 } 00821 void ui_check_keys(int &action) { 00822 UI_KEYS_CLICKENCODER_LOW_REV(UI_ENCODER_A,UI_ENCODER_B); // click encoder on pins 47 and 45. Phase is connected with gnd for signals. 00823 UI_KEYS_BUTTON_LOW(UI_ENCODER_CLICK,UI_ACTION_OK); // push button, connects gnd to pin 00824 } 00825 inline void ui_check_slow_encoder() {} 00826 void ui_check_slow_keys(int &action) {} 00827 #endif 00828 #endif // Controller 7 00829 00830 #if FEATURE_CONTROLLER==8 || FEATURE_CONTROLLER==9 // PiBot Expansion Port 00831 00832 #define UI_HAS_KEYS 1 00833 #define UI_HAS_BACK_KEY 1 00834 #define UI_DISPLAY_TYPE 1 00835 #define UI_DISPLAY_CHARSET 1 00836 #define UI_DELAYPERCHAR 320 00837 #define UI_INVERT_MENU_DIRECTION true 00838 #define BEEPER_SHORT_SEQUENCE 6,2 // Needs longer beep sequence 00839 #define BEEPER_LONG_SEQUENCE 24,8 00840 #define BEEPER_TYPE 1 00841 #define BEEPER_TYPE_INVERTING true 00842 00843 #if FEATURE_CONTROLLER==9 // 16x02 Display 00844 #define UI_COLS 16 00845 #define UI_ROWS 2 00846 #else ////20x04 Display 00847 #define UI_COLS 20 00848 #define UI_ROWS 4 00849 #endif 00850 00851 #ifdef PiBot_V_1_4 00852 #define BEEPER_PIN 31 00853 #define UI_DISPLAY_RS_PIN 45 00854 #define UI_DISPLAY_RW_PIN -1 00855 #define UI_DISPLAY_ENABLE_PIN 44 00856 #define UI_DISPLAY_D0_PIN 43 00857 #define UI_DISPLAY_D1_PIN 42 00858 #define UI_DISPLAY_D2_PIN 19 00859 #define UI_DISPLAY_D3_PIN 18 00860 #define UI_DISPLAY_D4_PIN 43 00861 #define UI_DISPLAY_D5_PIN 42 00862 #define UI_DISPLAY_D6_PIN 19 00863 #define UI_DISPLAY_D7_PIN 18 00864 #define UI_ENCODER_A 61 00865 #define UI_ENCODER_B 62 00866 #define UI_ENCODER_CLICK 63 00867 #define UI_RESET_PIN 28 00868 #define UI_DELAYPERCHAR 320 00869 #define UI_BUTTON_OK 49 00870 #define UI_BUTTON_NEXT 48 00871 #define UI_BUTTON_PREVIOUS 47 00872 #define UI_BUTTON_BACK 46 00873 #define UI_BUTTON_SD_PRINT 29 00874 #else 00875 #define BEEPER_PIN 37 00876 #define UI_DISPLAY_RS_PIN 16 00877 #define UI_DISPLAY_RW_PIN -1 00878 #define UI_DISPLAY_ENABLE_PIN 17 00879 #define UI_DISPLAY_D0_PIN 23 00880 #define UI_DISPLAY_D1_PIN 25 00881 #define UI_DISPLAY_D2_PIN 27 00882 #define UI_DISPLAY_D3_PIN 29 00883 #define UI_DISPLAY_D4_PIN 23 00884 #define UI_DISPLAY_D5_PIN 25 00885 #define UI_DISPLAY_D6_PIN 27 00886 #define UI_DISPLAY_D7_PIN 29 00887 #define UI_ENCODER_A 33 00888 #define UI_ENCODER_B 31 00889 #define UI_ENCODER_CLICK 35 00890 #define UI_RESET_PIN 41 00891 #define UI_DELAYPERCHAR 320 00892 #define UI_BUTTON_OK 4 00893 #define UI_BUTTON_NEXT 6 00894 #define UI_BUTTON_PREVIOUS 5 00895 #define UI_BUTTON_BACK 11 00896 #define UI_BUTTON_SD_PRINT 42 00897 #endif 00898 00899 #ifdef UI_MAIN 00900 void ui_init_keys() { 00901 UI_KEYS_INIT_BUTTON_LOW(UI_BUTTON_OK); // push button, connects gnd to pin 00902 UI_KEYS_INIT_BUTTON_LOW(UI_BUTTON_NEXT); 00903 UI_KEYS_INIT_BUTTON_LOW(UI_BUTTON_PREVIOUS); 00904 UI_KEYS_INIT_BUTTON_LOW(UI_BUTTON_BACK); 00905 UI_KEYS_INIT_BUTTON_LOW(UI_BUTTON_SD_PRINT); 00906 } 00907 void ui_check_keys(int &action) { 00908 UI_KEYS_BUTTON_LOW(UI_BUTTON_OK,UI_ACTION_OK); // push button, connects gnd to pin 00909 UI_KEYS_BUTTON_LOW(UI_BUTTON_NEXT,UI_ACTION_NEXT); // push button, connects gnd to pin 00910 UI_KEYS_BUTTON_LOW(UI_BUTTON_PREVIOUS,UI_ACTION_PREVIOUS); // push button, connects gnd to pin 00911 UI_KEYS_BUTTON_LOW(UI_BUTTON_BACK,UI_ACTION_BACK); // push button, connects gnd to pin 00912 UI_KEYS_BUTTON_LOW(UI_BUTTON_SD_PRINT,UI_ACTION_SD_PRINT ); // push button, connects gnd to pin 00913 } 00914 inline void ui_check_slow_encoder() {} 00915 void ui_check_slow_keys(int &action) {} 00916 #endif 00917 #endif 00918 00919 #if FEATURE_CONTROLLER>0 00920 #if UI_ROWS==4 00921 #if UI_COLS==16 00922 #define UI_LINE_OFFSETS {0,0x40,0x10,0x50} // 4x16 00923 #elif UI_COLS==20 00924 //#define UI_LINE_OFFSETS {0,0x20,0x40,0x60} // 4x20 with KS0073 00925 #define UI_LINE_OFFSETS {0,0x40,0x14,0x54} // 4x20 with HD44780 00926 #else 00927 #error Unknown combination off rows/columns - define UI_LINE_OFFSETS manually. 00928 #endif 00929 #else 00930 #define UI_LINE_OFFSETS {0,0x40,0x10,0x50} // 2x16, 2x20, 2x24 00931 #endif 00932 #include "uilang.h" 00933 #include "uimenu.h" 00934 #endif 00935 00936 #define UI_VERSION_STRING "Repetier " REPETIER_VERSION 00937 00938 #ifdef UI_HAS_I2C_KEYS 00939 #define COMPILE_I2C_DRIVER 00940 #endif 00941 00942 #if UI_DISPLAY_TYPE!=0 00943 00944 00945 #if UI_DISPLAY_TYPE==3 00946 #define COMPILE_I2C_DRIVER 00947 #endif 00948 00949 #ifndef UI_TEMP_PRECISION 00950 #if UI_COLS>16 00951 #define UI_TEMP_PRECISION 1 00952 #else 00953 #define UI_TEMP_PRECISION 0 00954 #endif 00955 #endif 00956 00957 #define UI_INITIALIZE uid.initialize(); 00958 #define UI_FAST if(pwm_count & 4) {uid.fastAction();} 00959 #define UI_MEDIUM uid.mediumAction(); 00960 #define UI_SLOW uid.slowAction(); 00961 #define UI_STATUS(status) uid.setStatusP(PSTR(status)); 00962 #define UI_STATUS_UPD(status) {uid.setStatusP(PSTR(status));uid.refreshPage();} 00963 #define UI_STATUS_RAM(status) uid.setStatus(status); 00964 #define UI_STATUS_UPD_RAM(status) {uid.setStatus(status);uid.refreshPage();} 00965 #define UI_ERROR(msg) {uid.errorMsg=(void*)PSTR(msg);pushMenu((void*)&ui_menu_error,true);} 00966 #define UI_CLEAR_STATUS {uid.statusMsg[0]=0;} 00967 #else 00968 #define UI_INITIALIZE {} 00969 #define UI_FAST {} 00970 #define UI_MEDIUM {} 00971 #define UI_SLOW {} 00972 #define UI_STATUS(status) {} 00973 #define UI_STATUS_UPD(status) {} 00974 #define UI_CLEAR_STATUS {} 00975 #define UI_ERROR(msg) {} 00976 #define UI_STATUS_UPD_RAM(status) {} 00977 #endif // Display 00978 00979 // Beeper methods 00980 #if BEEPER_TYPE==0 00981 #define BEEP_SHORT {} 00982 #define BEEP_LONG {} 00983 #else 00984 #define BEEP_SHORT beep(BEEPER_SHORT_SEQUENCE); 00985 #define BEEP_LONG beep(BEEPER_LONG_SEQUENCE); 00986 #endif 00987 extern void beep(uint8_t duration,uint8_t count); 00988 00989 #endif 00990