![]() |
Repetier-Firmware
0.80
|
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 #if defined(ARDUINO) && ARDUINO >= 100 00023 #include "Arduino.h" 00024 #else 00025 #include "WProgram.h" 00026 #define COMPAT_PRE1 00027 #endif 00028 #include <avr/pgmspace.h> 00029 #include "gcode.h" 00030 00031 // ---------------------------------------------------------------------------- 00032 // Action codes 00033 // 1-999 : Autorepeat 00034 // 1000-1999 : Execute 00035 // 2000-2999 : Write code 00036 // 4000-4999 : Show menu 00037 // Add UI_ACTION_TOPMENU to show a menu as top menu 00038 // ---------------------------------------------------------------------------- 00039 00040 #define UI_ACTION_TOPMENU 8192 00041 00042 #define UI_ACTION_NEXT 1 00043 #define UI_ACTION_PREVIOUS 2 00044 00045 #define UI_ACTION_X_UP 100 00046 #define UI_ACTION_X_DOWN 101 00047 #define UI_ACTION_Y_UP 102 00048 #define UI_ACTION_Y_DOWN 103 00049 #define UI_ACTION_Z_UP 104 00050 #define UI_ACTION_Z_DOWN 105 00051 #define UI_ACTION_EXTRUDER_UP 106 00052 #define UI_ACTION_EXTRUDER_DOWN 107 00053 #define UI_ACTION_EXTRUDER_TEMP_UP 108 00054 #define UI_ACTION_EXTRUDER_TEMP_DOWN 109 00055 #define UI_ACTION_HEATED_BED_UP 110 00056 #define UI_ACTION_HEATED_BED_DOWN 111 00057 #define UI_ACTION_FAN_UP 112 00058 #define UI_ACTION_FAN_DOWN 113 00059 00060 #define UI_ACTION_DUMMY 10000 00061 #define UI_ACTION_BACK 1000 00062 #define UI_ACTION_OK 1001 00063 #define UI_ACTION_MENU_UP 1002 00064 #define UI_ACTION_TOP_MENU 1003 00065 #define UI_ACTION_EMERGENCY_STOP 1004 00066 #define UI_ACTION_XPOSITION 1005 00067 #define UI_ACTION_YPOSITION 1006 00068 #define UI_ACTION_ZPOSITION 1007 00069 #define UI_ACTION_EPOSITION 1008 00070 #define UI_ACTION_BED_TEMP 1009 00071 #define UI_ACTION_EXTRUDER_TEMP 1010 00072 #define UI_ACTION_SD_DELETE 1012 00073 #define UI_ACTION_SD_PRINT 1013 00074 #define UI_ACTION_SD_PAUSE 1014 00075 #define UI_ACTION_SD_CONTINUE 1015 00076 #define UI_ACTION_SD_UNMOUNT 1016 00077 #define UI_ACTION_SD_MOUNT 1017 00078 #define UI_ACTION_XPOSITION_FAST 1018 00079 #define UI_ACTION_YPOSITION_FAST 1019 00080 #define UI_ACTION_ZPOSITION_FAST 1020 00081 #define UI_ACTION_HOME_ALL 1021 00082 #define UI_ACTION_HOME_X 1022 00083 #define UI_ACTION_HOME_Y 1023 00084 #define UI_ACTION_HOME_Z 1024 00085 #define UI_ACTION_SELECT_EXTRUDER1 1025 00086 #define UI_ACTION_OPS_RETRACTDISTANCE 1026 00087 #define UI_ACTION_OPS_BACKLASH 1027 00088 #define UI_ACTION_OPS_MOVE_AFTER 1028 00089 #define UI_ACTION_OPS_MINDISTANCE 1029 00090 #define UI_ACTION_STORE_EEPROM 1030 00091 #define UI_ACTION_LOAD_EEPROM 1031 00092 #define UI_ACTION_PRINT_ACCEL_X 1032 00093 #define UI_ACTION_PRINT_ACCEL_Y 1033 00094 #define UI_ACTION_PRINT_ACCEL_Z 1034 00095 #define UI_ACTION_MOVE_ACCEL_X 1035 00096 #define UI_ACTION_MOVE_ACCEL_Y 1036 00097 #define UI_ACTION_MOVE_ACCEL_Z 1037 00098 #define UI_ACTION_MAX_JERK 1038 00099 #define UI_ACTION_MAX_ZJERK 1039 00100 #define UI_ACTION_BAUDRATE 1040 00101 #define UI_ACTION_HOMING_FEEDRATE_X 1041 00102 #define UI_ACTION_HOMING_FEEDRATE_Y 1042 00103 #define UI_ACTION_HOMING_FEEDRATE_Z 1043 00104 #define UI_ACTION_MAX_FEEDRATE_X 1044 00105 #define UI_ACTION_MAX_FEEDRATE_Y 1045 00106 #define UI_ACTION_MAX_FEEDRATE_Z 1046 00107 #define UI_ACTION_STEPS_X 1047 00108 #define UI_ACTION_STEPS_Y 1048 00109 #define UI_ACTION_STEPS_Z 1049 00110 #define UI_ACTION_FAN_OFF 1050 00111 #define UI_ACTION_FAN_25 1051 00112 #define UI_ACTION_FAN_50 1052 00113 #define UI_ACTION_FAN_75 1053 00114 #define UI_ACTION_FAN_FULL 1054 00115 #define UI_ACTION_FEEDRATE_MULTIPLY 1055 00116 #define UI_ACTION_STEPPER_INACTIVE 1056 00117 #define UI_ACTION_MAX_INACTIVE 1057 00118 #define UI_ACTION_PID_PGAIN 1058 00119 #define UI_ACTION_PID_IGAIN 1059 00120 #define UI_ACTION_PID_DGAIN 1060 00121 #define UI_ACTION_DRIVE_MIN 1061 00122 #define UI_ACTION_DRIVE_MAX 1062 00123 #define UI_ACTION_X_OFFSET 1063 00124 #define UI_ACTION_Y_OFFSET 1064 00125 #define UI_ACTION_EXTR_STEPS 1065 00126 #define UI_ACTION_EXTR_ACCELERATION 1066 00127 #define UI_ACTION_EXTR_MAX_FEEDRATE 1067 00128 #define UI_ACTION_EXTR_START_FEEDRATE 1068 00129 #define UI_ACTION_EXTR_HEATMANAGER 1069 00130 #define UI_ACTION_EXTR_WATCH_PERIOD 1070 00131 #define UI_ACTION_PID_MAX 1071 00132 #define UI_ACTION_ADVANCE_K 1072 00133 #define UI_ACTION_SET_ORIGIN 1073 00134 #define UI_ACTION_DEBUG_ECHO 1074 00135 #define UI_ACTION_DEBUG_INFO 1075 00136 #define UI_ACTION_DEBUG_ERROR 1076 00137 #define UI_ACTION_DEBUG_DRYRUN 1077 00138 #define UI_ACTION_POWER 1078 00139 #define UI_ACTION_PREHEAT_PLA 1079 00140 #define UI_ACTION_COOLDOWN 1080 00141 #define UI_ACTION_HEATED_BED_OFF 1081 00142 #define UI_ACTION_EXTRUDER0_OFF 1082 00143 #define UI_ACTION_EXTRUDER1_OFF 1083 00144 #define UI_ACTION_HEATED_BED_TEMP 1084 00145 #define UI_ACTION_EXTRUDER0_TEMP 1085 00146 #define UI_ACTION_EXTRUDER1_TEMP 1086 00147 #define UI_ACTION_OPS_OFF 1087 00148 #define UI_ACTION_OPS_CLASSIC 1088 00149 #define UI_ACTION_OPS_FAST 1089 00150 #define UI_ACTION_DISABLE_STEPPER 1090 00151 #define UI_ACTION_RESET_EXTRUDER 1091 00152 #define UI_ACTION_EXTRUDER_RELATIVE 1092 00153 #define UI_ACTION_SELECT_EXTRUDER0 1093 00154 #define UI_ACTION_ADVANCE_L 1094 00155 #define UI_ACTION_PREHEAT_ABS 1095 00156 #define UI_ACTION_FLOWRATE_MULTIPLY 1096 00157 #define UI_ACTION_KILL 1097 00158 #define UI_ACTION_RESET 1098 00159 #define UI_ACTION_PAUSE 1099 00160 #define UI_ACTION_EXTR_WAIT_RETRACT_TEMP 1100 00161 #define UI_ACTION_EXTR_WAIT_RETRACT_UNITS 1101 00162 00163 #define UI_ACTION_MENU_XPOS 4000 00164 #define UI_ACTION_MENU_YPOS 4001 00165 #define UI_ACTION_MENU_ZPOS 4002 00166 #define UI_ACTION_MENU_XPOSFAST 4003 00167 #define UI_ACTION_MENU_YPOSFAST 4004 00168 #define UI_ACTION_MENU_ZPOSFAST 4005 00169 #define UI_ACTION_MENU_SDCARD 4006 00170 #define UI_ACTION_MENU_QUICKSETTINGS 4007 00171 #define UI_ACTION_MENU_EXTRUDER 4008 00172 #define UI_ACTION_MENU_POSITIONS 4009 00173 #define UI_ACTION_SHOW_MEASUREMENT 4010 00174 #define UI_ACTION_RESET_MEASUREMENT 4011 00175 #define UI_ACTION_SET_MEASURED_ORIGIN 4012 00176 #define UI_ACTION_SET_P1 4013 00177 #define UI_ACTION_SET_P2 4014 00178 #define UI_ACTION_SET_P3 4015 00179 #define UI_ACTION_CALC_LEVEL 4016 00180 00181 #define UI_ACTION_SHOW_USERMENU1 4101 00182 #define UI_ACTION_SHOW_USERMENU2 4102 00183 #define UI_ACTION_SHOW_USERMENU3 4103 00184 #define UI_ACTION_SHOW_USERMENU4 4104 00185 #define UI_ACTION_SHOW_USERMENU5 4105 00186 #define UI_ACTION_SHOW_USERMENU6 4106 00187 #define UI_ACTION_SHOW_USERMENU7 4107 00188 #define UI_ACTION_SHOW_USERMENU8 4108 00189 #define UI_ACTION_SHOW_USERMENU9 4109 00190 #define UI_ACTION_SHOW_USERMENU10 4110 00191 00192 // Load basic language definition to make sure all values are defined 00193 #include "uilang.h" 00194 00195 #include "Configuration.h" 00196 #include <avr/pgmspace.h> 00197 #include "fastio.h" 00198 00199 typedef struct { 00200 const char *text; // Menu text 00201 unsigned char menuType; // 0 = Info, 1 = Headline, 2 = submenu ref, 3 = direct action command, 4 = modify action command 00202 unsigned int action; 00203 } const UIMenuEntry; 00204 00205 typedef struct { 00206 // 0 = info page 00207 // 1 = file selector 00208 // 2 = submenu 00209 // 3 = modififaction menu 00210 unsigned char menuType; 00211 int id; // Type of modification 00212 int numEntries; 00213 const UIMenuEntry * const * entries; 00214 } const UIMenu; 00215 extern const int8_t encoder_table[16] PROGMEM ; 00216 00217 //#ifdef COMPILE_I2C_DRIVER 00218 00219 /************************************************************************* 00220 * Title: C include file for the I2C master interface 00221 * (i2cmaster.S or twimaster.c) 00222 * Author: Peter Fleury <pfleury@gmx.ch> http://jump.to/fleury 00223 * File: $Id: i2cmaster.h,v 1.10 2005/03/06 22:39:57 Peter Exp $ 00224 * Software: AVR-GCC 3.4.3 / avr-libc 1.2.3 00225 * Target: any AVR device 00226 * Usage: see Doxygen manual 00227 **************************************************************************/ 00228 00229 #if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 00230 #error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" 00231 #endif 00232 00233 #include <avr/io.h> 00234 00236 #define I2C_READ 1 00237 00238 #define I2C_WRITE 0 00239 00245 extern void i2c_stop(void); 00253 extern unsigned char i2c_start(unsigned char addr); 00261 extern void i2c_start_wait(unsigned char addr); 00268 extern unsigned char i2c_write(unsigned char data); 00273 extern unsigned char i2c_readAck(void); 00278 extern unsigned char i2c_readNak(void); 00288 extern unsigned char i2c_read(unsigned char ack); 00289 #define i2c_read(ack) (ack) ? i2c_readAck() : i2c_readNak(); 00290 00294 //extern const int matrixActions[] PROGMEM; 00295 // Key codes 00296 #define UI_KEYS_INIT_CLICKENCODER_LOW(pinA,pinB) SET_INPUT(pinA);SET_INPUT(pinB); WRITE(pinA,HIGH);WRITE(pinB,HIGH); 00297 #define UI_KEYS_INIT_BUTTON_LOW(pin) SET_INPUT(pin);WRITE(pin,HIGH); 00298 #define UI_KEYS_INIT_CLICKENCODER_HIGH(pinA,pinB) SET_INPUT(pinA);SET_INPUT(pinB); WRITE(pinA,LOW);WRITE(pinB,LOW); 00299 #define UI_KEYS_INIT_BUTTON_HIGH(pin) SET_INPUT(pin);WRITE(pin,LOW); 00300 00301 #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]); 00302 #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]); 00303 #define UI_KEYS_BUTTON_LOW(pin,action_) if(READ(pin)==0) action=action_; 00304 #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]); 00305 #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]); 00306 #define UI_KEYS_BUTTON_HIGH(pin,action_) if(READ(pin)!=0) action=action_; 00307 #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);}\ 00308 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);\ 00309 if(r1>=0)WRITE(r1,LOW);if(r2>=0)WRITE(r2,LOW);if(r3>=0)WRITE(r3,LOW);if(r4>=0)WRITE(r4,LOW); 00310 // 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)); 00311 #define UI_KEYS_MATRIX(r1,r2,r3,r4,c1,c2,c3,c4) {byte r = (c1>=0?READ(c1):0) && (c2>=0?READ(c2):0) && (c3>=0?READ(c3):0) && (c4>=0?READ(c4):0);\ 00312 if(!r) {\ 00313 r = 255;\ 00314 if(r2>=0)WRITE(r2,HIGH);if(r3>=0)WRITE(r3,HIGH);if(r4>=0)WRITE(r4,HIGH);\ 00315 if(r1>=0) {\ 00316 asm volatile ("nop\nnop\nnop\nnop\nnop");\ 00317 if(!((c1>=0?READ(c1):1) && (c2>=0?READ(c2):1) && (c3>=0?READ(c3):1) && (c4>=0?READ(c4):1))) r = 0;\ 00318 else WRITE(r1,HIGH);\ 00319 }\ 00320 if(r==255 && r2>=0) {\ 00321 WRITE(r2,LOW);asm volatile ("nop\nnop\nnop\nnop\nnop");\ 00322 if(!((c1>=0?READ(c1):1) && (c2>=0?READ(c2):1) && (c3>=0?READ(c3):1) && (c4>=0?READ(c4):1))) r = 4;\ 00323 else WRITE(r2,HIGH);\ 00324 }\ 00325 if(r==255 && r3>=0) {\ 00326 WRITE(r3,LOW);asm volatile ("nop\nnop\nnop\nnop\nnop");\ 00327 if(!((c1>=0?READ(c1):0) && (c2>=0?READ(c2):1) && (c3>=0?READ(c3):1) && (c4>=0?READ(c4):1))) r = 8;\ 00328 else WRITE(r3,HIGH);\ 00329 }\ 00330 if(r==255 && r4>=0) {\ 00331 WRITE(r4,LOW);asm volatile ("nop\nnop\nnop\nnop\nnop");\ 00332 if(!((c1>=0?READ(c1):1) && (c2>=0?READ(c2):1) && (c3>=0?READ(c3):1) && (c4>=0?READ(c4):1))) r = 12;\ 00333 else WRITE(r4,HIGH);\ 00334 }\ 00335 if(c2>=0 && !READ(c2)) r+=1;\ 00336 else if(c3>=0 && !READ(c3)) r+=2;\ 00337 else if(c4>=0 && !READ(c4)) r+=3;\ 00338 if(r<16) {action = pgm_read_word(&(matrixActions[r]));}\ 00339 }if(r1>=0)WRITE(r1,LOW);if(r2>=0)WRITE(r2,LOW);if(r3>=0)WRITE(r3,LOW);if(r4>=0)WRITE(r4,LOW);} 00340 // I2C keymask tests 00341 #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]); 00342 #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]); 00343 #define UI_KEYS_I2C_BUTTON_LOW(pin,action_) if((keymask & pin)==0) action=action_; 00344 #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]); 00345 #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]); 00346 #define UI_KEYS_I2C_BUTTON_HIGH(pin,action_) if((pin & keymask)!=0) action=action_; 00347 00348 #define UI_STRING(name,text) const char PROGMEM name[] = text; 00349 00350 #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);\ 00351 UIMenuEntry name ## _1 PROGMEM ={name ## _1txt,0,0};\ 00352 UIMenuEntry name ## _2 PROGMEM ={name ## _2txt,0,0};\ 00353 UIMenuEntry name ## _3 PROGMEM ={name ## _3txt,0,0};\ 00354 UIMenuEntry name ## _4 PROGMEM ={name ## _4txt,0,0};\ 00355 const UIMenuEntry * const name ## _entries [] PROGMEM = {&name ## _1,&name ## _2,&name ## _3,&name ## _4};\ 00356 const UIMenu name PROGMEM = {0,0,4,name ## _entries}; 00357 #define UI_PAGE2(name,row1,row2) UI_STRING(name ## _1txt,row1);UI_STRING(name ## _2txt,row2);\ 00358 UIMenuEntry name ## _1 PROGMEM ={name ## _1txt,0,0};\ 00359 UIMenuEntry name ## _2 PROGMEM ={name ## _2txt,0,0};\ 00360 const UIMenuEntry * const name ## _entries[] PROGMEM = {&name ## _1,&name ## _2};\ 00361 const UIMenu name PROGMEM = {0,0,2,name ## _entries}; 00362 #define UI_MENU_ACTION4C(name,action,rows) UI_MENU_ACTION4(name,action,rows) 00363 #define UI_MENU_ACTION2C(name,action,rows) UI_MENU_ACTION2(name,action,rows) 00364 #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);\ 00365 UIMenuEntry name ## _1 PROGMEM ={name ## _1txt,0,0};\ 00366 UIMenuEntry name ## _2 PROGMEM ={name ## _2txt,0,0};\ 00367 UIMenuEntry name ## _3 PROGMEM ={name ## _3txt,0,0};\ 00368 UIMenuEntry name ## _4 PROGMEM ={name ## _4txt,0,0};\ 00369 const UIMenuEntry * const name ## _entries[] PROGMEM = {&name ## _1,&name ## _2,&name ## _3,&name ## _4};\ 00370 const UIMenu name PROGMEM = {3,action,4,name ## _entries}; 00371 #define UI_MENU_ACTION2(name,action,row1,row2) UI_STRING(name ## _1txt,row1);UI_STRING(name ## _2txt,row2);\ 00372 UIMenuEntry name ## _1 PROGMEM ={name ## _1txt,0,0};\ 00373 UIMenuEntry name ## _2 PROGMEM ={name ## _2txt,0,0};\ 00374 const UIMenuEntry * const name ## _entries[] PROGMEM = {&name ## _1,&name ## _2};\ 00375 const UIMenu name PROGMEM = {3,action,2,name ## _entries}; 00376 #define UI_MENU_HEADLINE(name,text) UI_STRING(name ## _txt,text);UIMenuEntry name PROGMEM = {name ## _txt,1,0}; 00377 #define UI_MENU_CHANGEACTION(name,row,action) UI_STRING(name ## _txt,row);UIMenuEntry name PROGMEM = {name ## _txt,4,action}; 00378 #define UI_MENU_ACTIONCOMMAND(name,row,action) UI_STRING(name ## _txt,row);UIMenuEntry name PROGMEM = {name ## _txt,3,action}; 00379 #define UI_MENU_ACTIONSELECTOR(name,row,entries) UI_STRING(name ## _txt,row);UIMenuEntry name PROGMEM = {name ## _txt,2,(unsigned int)&entries}; 00380 #define UI_MENU_SUBMENU(name,row,entries) UI_STRING(name ## _txt,row);UIMenuEntry name PROGMEM = {name ## _txt,2,(unsigned int)&entries}; 00381 #define UI_MENU(name,items,itemsCnt) const UIMenuEntry * const name ## _entries[] PROGMEM = items;const UIMenu name PROGMEM = {2,0,itemsCnt,name ## _entries} 00382 #define UI_MENU_FILESELECT(name,items,itemsCnt) const UIMenuEntry *name ## _entries[] PROGMEM = items;const UIMenu name PROGMEM = {1,0,itemsCnt,name ## _entries} 00383 00384 class UIDisplay { 00385 public: 00386 volatile byte flags; // 1 = fast key action, 2 = slow key action, 4 = slow action running, 8 = key test running 00387 byte col; // current col for buffer prefill 00388 byte menuLevel; // current menu level, 0 = info, 1 = group, 2 = groupdata select, 3 = value change 00389 byte menuPos[5]; // Positions in menu 00390 void *menu[5]; // Menus active 00391 byte menuTop[5]; // Top row in menu 00392 int pageDelay; // Counter. If 0 page is refreshed if menuLevel is 0. 00393 void *errorMsg; 00394 unsigned int activeAction; // action for ok/next/previous 00395 unsigned int lastAction; 00396 unsigned long lastSwitch; // Last time display switched pages 00397 unsigned long lastRefresh; 00398 unsigned int lastButtonAction; 00399 unsigned long lastButtonStart; 00400 unsigned long nextRepeat; // Time of next autorepeat 00401 unsigned int outputMask; // Output mask for backlight, leds etc. 00402 int repeatDuration; // Time beween to actions if autorepeat is enabled 00403 void addInt(int value,byte digits); // Print int into printCols 00404 void addLong(long value,char digits); 00405 void addFloat(float number, char fixdigits,byte digits); 00406 void addStringP(PGM_P text); 00407 void okAction(); 00408 void nextPreviousAction(char next); 00409 char statusMsg[17]; 00410 char encoderPos; 00411 int8_t encoderLast; 00412 PGM_P statusText; 00413 UIDisplay(); 00414 void createChar(byte location,const byte charmap[]); 00415 void initialize(); // Initialize display and keys 00416 void printRow(byte r,char *txt); // Print row on display 00417 void printRowP(byte r,PGM_P txt); 00418 void parse(char *txt,bool ram); 00419 void refreshPage(); 00420 void executeAction(int action); 00421 void finishAction(int action); 00422 void slowAction(); 00423 void fastAction(); 00424 void mediumAction(); 00425 void pushMenu(void *men,bool refresh); 00426 void setStatusP(PGM_P txt); 00427 void setStatus(char *txt); 00428 inline void setOutputMaskBits(unsigned int bits) {outputMask|=bits;} 00429 inline void unsetOutputMaskBits(unsigned int bits) {outputMask&=~bits;} 00430 #if SDSUPPORT 00431 void updateSDFileCount(); 00432 void sdrefresh(byte &r); 00433 void goDir(char *name); 00434 bool isDirname(char *name); 00435 char cwd[SD_MAX_FOLDER_DEPTH*13+2]; 00436 byte folderLevel; 00437 #endif 00438 }; 00439 extern UIDisplay uid; 00440 00441 #if FEATURE_CONTROLLER==1 00442 #include "uiconfig.h" 00443 #endif 00444 #if FEATURE_CONTROLLER==0 // No controller at all 00445 #define UI_HAS_KEYS 0 00446 #define UI_DISPLAY_TYPE 0 00447 #ifdef UI_MAIN 00448 void ui_init_keys() {} 00449 void ui_check_keys(int &action) {} 00450 inline void ui_check_slow_encoder() {} 00451 void ui_check_slow_keys(int &action) {} 00452 #endif 00453 #endif 00454 #if FEATURE_CONTROLLER==2 // reprapdiscount smartcontroller 00455 #undef SDCARDDETECT 00456 #define SDCARDDETECT 49 00457 #undef SDCARDDETECTINVERTED 00458 #define SDCARDDETECTINVERTED false 00459 #undef SDSUPPORT 00460 #define SDSUPPORT true 00461 #define UI_HAS_KEYS 1 00462 #define UI_HAS_BACK_KEY 0 00463 #define UI_DISPLAY_TYPE 1 00464 #define UI_DISPLAY_CHARSET 1 00465 #define BEEPER_TYPE 1 00466 #define UI_COLS 20 00467 #define UI_ROWS 4 00468 #if MOTHERBOARD==80 // Rumba has different pins as RAMPS! 00469 #define BEEPER_PIN 44 00470 #define UI_DISPLAY_RS_PIN 19 00471 #define UI_DISPLAY_RW_PIN -1 00472 #define UI_DISPLAY_ENABLE_PIN 42 00473 #define UI_DISPLAY_D0_PIN 18 00474 #define UI_DISPLAY_D1_PIN 38 00475 #define UI_DISPLAY_D2_PIN 41 00476 #define UI_DISPLAY_D3_PIN 40 00477 #define UI_DISPLAY_D4_PIN 18 00478 #define UI_DISPLAY_D5_PIN 38 00479 #define UI_DISPLAY_D6_PIN 41 00480 #define UI_DISPLAY_D7_PIN 40 00481 #define UI_ENCODER_A 12 00482 #define UI_ENCODER_B 11 00483 #define UI_ENCODER_CLICK 43 00484 #define UI_RESET_PIN 46 00485 #else 00486 #define BEEPER_PIN 37 00487 #define UI_DISPLAY_RS_PIN 16 00488 #define UI_DISPLAY_RW_PIN -1 00489 #define UI_DISPLAY_ENABLE_PIN 17 00490 #define UI_DISPLAY_D0_PIN 23 00491 #define UI_DISPLAY_D1_PIN 25 00492 #define UI_DISPLAY_D2_PIN 27 00493 #define UI_DISPLAY_D3_PIN 29 00494 #define UI_DISPLAY_D4_PIN 23 00495 #define UI_DISPLAY_D5_PIN 25 00496 #define UI_DISPLAY_D6_PIN 27 00497 #define UI_DISPLAY_D7_PIN 29 00498 #define UI_ENCODER_A 33 00499 #define UI_ENCODER_B 31 00500 #define UI_ENCODER_CLICK 35 00501 #define UI_RESET_PIN 41 00502 #endif 00503 #define UI_DELAYPERCHAR 320 00504 #define UI_INVERT_MENU_DIRECTION false 00505 #ifdef UI_MAIN 00506 void ui_init_keys() { 00507 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. 00508 UI_KEYS_INIT_BUTTON_LOW(UI_ENCODER_CLICK); // push button, connects gnd to pin 00509 UI_KEYS_INIT_BUTTON_LOW(UI_RESET_PIN); // Kill pin 00510 } 00511 void ui_check_keys(int &action) { 00512 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. 00513 UI_KEYS_BUTTON_LOW(UI_ENCODER_CLICK,UI_ACTION_OK); // push button, connects gnd to pin 00514 UI_KEYS_BUTTON_LOW(UI_RESET_PIN,UI_ACTION_RESET); 00515 } 00516 inline void ui_check_slow_encoder() {} 00517 void ui_check_slow_keys(int &action) {} 00518 #endif 00519 #endif // Controller 2 00520 00521 #if FEATURE_CONTROLLER==3 // Adafruit RGB controller 00522 #define UI_HAS_KEYS 1 00523 #define UI_HAS_BACK_KEY 1 00524 #define UI_DISPLAY_TYPE 3 00525 #define UI_DISPLAY_CHARSET 1 00526 #define UI_COLS 16 00527 #define UI_ROWS 2 00528 #define UI_DISPLAY_I2C_CHIPTYPE 1 00529 #define UI_DISPLAY_I2C_ADDRESS 0x40 00530 #define UI_DISPLAY_I2C_OUTPUT_PINS 65504 00531 #define UI_DISPLAY_I2C_OUTPUT_START_MASK 0 00532 #define UI_DISPLAY_I2C_PULLUP 31 00533 #define UI_I2C_CLOCKSPEED 400000L 00534 #define UI_DISPLAY_RS_PIN _BV(15) 00535 #define UI_DISPLAY_RW_PIN _BV(14) 00536 #define UI_DISPLAY_ENABLE_PIN _BV(13) 00537 #define UI_DISPLAY_D0_PIN _BV(12) 00538 #define UI_DISPLAY_D1_PIN _BV(11) 00539 #define UI_DISPLAY_D2_PIN _BV(10) 00540 #define UI_DISPLAY_D3_PIN _BV(9) 00541 #define UI_DISPLAY_D4_PIN _BV(12) 00542 #define UI_DISPLAY_D5_PIN _BV(11) 00543 #define UI_DISPLAY_D6_PIN _BV(10) 00544 #define UI_DISPLAY_D7_PIN _BV(9) 00545 #define UI_INVERT_MENU_DIRECTION true 00546 #define UI_HAS_I2C_KEYS 00547 #define UI_HAS_I2C_ENCODER 0 00548 #define UI_I2C_KEY_ADDRESS 0x40 00549 #ifdef UI_MAIN 00550 void ui_init_keys() {} 00551 void ui_check_keys(int &action) {} 00552 inline void ui_check_slow_encoder() { 00553 i2c_start_wait(UI_DISPLAY_I2C_ADDRESS+I2C_WRITE); 00554 i2c_write(0x12); // GIOA 00555 i2c_stop(); 00556 i2c_start_wait(UI_DISPLAY_I2C_ADDRESS+I2C_READ); 00557 unsigned int keymask = i2c_readAck(); 00558 keymask = keymask + (i2c_readNak()<<8); 00559 i2c_stop(); 00560 } 00561 void ui_check_slow_keys(int &action) { 00562 i2c_start_wait(UI_DISPLAY_I2C_ADDRESS+I2C_WRITE); 00563 i2c_write(0x12); // GPIOA 00564 i2c_stop(); 00565 i2c_start_wait(UI_DISPLAY_I2C_ADDRESS+I2C_READ); 00566 unsigned int keymask = i2c_readAck(); 00567 keymask = keymask + (i2c_readNak()<<8); 00568 i2c_stop(); 00569 UI_KEYS_I2C_BUTTON_LOW(4,UI_ACTION_PREVIOUS); // Up button 00570 UI_KEYS_I2C_BUTTON_LOW(8,UI_ACTION_NEXT); // down button 00571 UI_KEYS_I2C_BUTTON_LOW(16,UI_ACTION_BACK); // left button 00572 UI_KEYS_I2C_BUTTON_LOW(2,UI_ACTION_OK); // right button 00573 UI_KEYS_I2C_BUTTON_LOW(1,UI_ACTION_MENU_QUICKSETTINGS); //Select button 00574 } 00575 #endif 00576 #endif // Controller 3 00577 00578 #if FEATURE_CONTROLLER==4 // Foltyn 3D Master 00579 #define UI_HAS_KEYS 1 00580 #define UI_HAS_BACK_KEY 1 00581 #define UI_DISPLAY_TYPE 1 00582 #define UI_DISPLAY_CHARSET 2 00583 #define UI_COLS 20 00584 #define UI_ROWS 4 00585 #define UI_DISPLAY_RS_PIN 63 // PINK.1, 88, D_RS 00586 #define UI_DISPLAY_RW_PIN -1 00587 #define UI_DISPLAY_ENABLE_PIN 65 // PINK.3, 86, D_E 00588 #define UI_DISPLAY_D0_PIN 59 // PINF.5, 92, D_D4 00589 #define UI_DISPLAY_D1_PIN 64 // PINK.2, 87, D_D5 00590 #define UI_DISPLAY_D2_PIN 44 // PINL.5, 40, D_D6 00591 #define UI_DISPLAY_D3_PIN 66 // PINK.4, 85, D_D7 00592 #define UI_DISPLAY_D4_PIN 59 // PINF.5, 92, D_D4 00593 #define UI_DISPLAY_D5_PIN 64 // PINK.2, 87, D_D5 00594 #define UI_DISPLAY_D6_PIN 44 // PINL.5, 40, D_D6 00595 #define UI_DISPLAY_D7_PIN 66 // PINK.4, 85, D_D7 00596 #define UI_DELAYPERCHAR 320 00597 #define UI_INVERT_MENU_DIRECTION false 00598 #ifdef UI_MAIN 00599 void ui_init_keys() { 00600 UI_KEYS_INIT_BUTTON_LOW(4); // push button, connects gnd to pin 00601 UI_KEYS_INIT_BUTTON_LOW(5); 00602 UI_KEYS_INIT_BUTTON_LOW(6); 00603 UI_KEYS_INIT_BUTTON_LOW(11); 00604 UI_KEYS_INIT_BUTTON_LOW(42); 00605 } 00606 void ui_check_keys(int &action) { 00607 UI_KEYS_BUTTON_LOW(4,UI_ACTION_OK); // push button, connects gnd to pin 00608 UI_KEYS_BUTTON_LOW(5,UI_ACTION_NEXT); // push button, connects gnd to pin 00609 UI_KEYS_BUTTON_LOW(6,UI_ACTION_PREVIOUS); // push button, connects gnd to pin 00610 UI_KEYS_BUTTON_LOW(11,UI_ACTION_BACK); // push button, connects gnd to pin 00611 UI_KEYS_BUTTON_LOW(42,UI_ACTION_SD_PRINT ); // push button, connects gnd to pin 00612 } 00613 inline void ui_check_slow_encoder() {} 00614 void ui_check_slow_keys(int &action) {} 00615 #endif 00616 #endif // Controller 4 00617 00618 00619 #if FEATURE_CONTROLLER>0 00620 00621 #if UI_ROWS==4 00622 #if UI_COLS==16 00623 #define UI_LINE_OFFSETS {0,0x40,0x10,0x50} // 4x16 00624 #elif UI_COLS==20 00625 //#define UI_LINE_OFFSETS {0,0x20,0x40,0x60} // 4x20 with KS0073 00626 #define UI_LINE_OFFSETS {0,0x40,0x14,0x54} // 4x20 with HD44780 00627 #else 00628 #error Unknown combination off rows/columns - define UI_LINE_OFFSETS manually. 00629 #endif 00630 #else 00631 #define UI_LINE_OFFSETS {0,0x40,0x10,0x50} // 2x16, 2x20, 2x24 00632 #endif 00633 #include "uilang.h" 00634 #include "uimenu.h" 00635 #endif 00636 00637 #define UI_VERSION_STRING "Repetier " REPETIER_VERSION 00638 00639 #ifdef UI_HAS_I2C_KEYS 00640 #define COMPILE_I2C_DRIVER 00641 #endif 00642 00643 #if UI_DISPLAY_TYPE!=0 00644 00645 00646 #if UI_DISPLAY_TYPE==3 00647 #define COMPILE_I2C_DRIVER 00648 #endif 00649 00650 #ifndef UI_TEMP_PRECISION 00651 #if UI_COLS>16 00652 #define UI_TEMP_PRECISION 1 00653 #else 00654 #define UI_TEMP_PRECISION 0 00655 #endif 00656 #endif 00657 00658 #define UI_INITIALIZE uid.initialize(); 00659 #define UI_FAST if(pwm_count & 4) {uid.fastAction();} 00660 #define UI_MEDIUM uid.mediumAction(); 00661 #define UI_SLOW uid.slowAction(); 00662 #define UI_STATUS(status) uid.setStatusP(PSTR(status)); 00663 #define UI_STATUS_UPD(status) {uid.setStatusP(PSTR(status));uid.refreshPage();} 00664 #define UI_STATUS_RAM(status) uid.setStatus(status); 00665 #define UI_STATUS_UPD_RAM(status) {uid.setStatus(status);uid.refreshPage();} 00666 #define UI_ERROR(msg) {uid.errorMsg=PSTR(msg);pushMenu((void*)&ui_menu_error,true);} 00667 #define UI_CLEAR_STATUS {uid.statusMsg[0]=0;} 00668 #else 00669 #define UI_INITIALIZE {} 00670 #define UI_FAST {} 00671 #define UI_MEDIUM {} 00672 #define UI_SLOW {} 00673 #define UI_STATUS(status) {} 00674 #define UI_STATUS_UPD(status) {} 00675 #define UI_CLEAR_STATUS {} 00676 #define UI_ERROR(msg) {} 00677 #define UI_STATUS_UPD_RAM(status) {} 00678 #endif // Display 00679 00680 // Beeper methods 00681 #if BEEPER_TYPE==0 00682 #define BEEP_SHORT {} 00683 #define BEEP_LONG {} 00684 #else 00685 #define BEEP_SHORT beep(BEEPER_SHORT_SEQUENCE); 00686 #define BEEP_LONG beep(BEEPER_LONG_SEQUENCE); 00687 #endif 00688 extern void beep(byte duration,byte count); 00689 00690 #endif 00691