ソースを参照

Changes in ultralcd_implementation_hitachi_HD44780.h in detail

Top -> down:
We don't need LiquidCrystalRus.cpp and LiquidCrystalRus.h any more. Functionality is now in utf_mapper.h
Comment on LCD_STR_BEDTEMP about behaviour in strings.
Change LCD_STR_ARROW_RIGHT from "\x7E" to ">" because "\x7E" is only ARROW_RIGHT on displays with DISPLAY_CHARSET_HD44780_JAPAN.
Introduce the counting UTF8 enabled lcd_print functions.
Replace the old lcd.print functions and make use of them.
A bit of reformatting around the changes.
AnHardt 9年前
コミット
255ca68123
3個のファイルの変更79行の追加602行の削除
  1. 0
    393
      Marlin/LiquidCrystalRus.cpp
  2. 0
    129
      Marlin/LiquidCrystalRus.h
  3. 79
    80
      Marlin/ultralcd_implementation_hitachi_HD44780.h

+ 0
- 393
Marlin/LiquidCrystalRus.cpp ファイルの表示

@@ -1,393 +0,0 @@
1
-#include "LiquidCrystalRus.h"
2
-
3
-#include <stdio.h>
4
-#include <string.h>
5
-#include <inttypes.h>
6
-#include <avr/pgmspace.h>
7
-
8
-#if defined(ARDUINO) && ARDUINO >= 100
9
-  #include "Arduino.h"
10
-#else
11
-  #include "WProgram.h"
12
-#endif
13
-
14
-// it is a Russian alphabet translation
15
-// except 0401 --> 0xa2 = ╗, 0451 --> 0xb5
16
-const PROGMEM uint8_t utf_recode[] = 
17
-       { 0x41,0xa0,0x42,0xa1,0xe0,0x45,0xa3,0xa4,
18
-         0xa5,0xa6,0x4b,0xa7,0x4d,0x48,0x4f,0xa8,
19
-         0x50,0x43,0x54,0xa9,0xaa,0x58,0xe1,0xab,
20
-         0xac,0xe2,0xad,0xae,0x62,0xaf,0xb0,0xb1,
21
-         0x61,0xb2,0xb3,0xb4,0xe3,0x65,0xb6,0xb7,
22
-         0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0x6f,0xbe,
23
-         0x70,0x63,0xbf,0x79,0xe4,0x78,0xe5,0xc0,
24
-         0xc1,0xe6,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7
25
-        };     
26
-
27
-// When the display powers up, it is configured as follows:
28
-//
29
-// 1. Display clear
30
-// 2. Function set: 
31
-//    DL = 1; 8-bit interface data 
32
-//    N = 0; 1-line display 
33
-//    F = 0; 5x8 dot character font 
34
-// 3. Display on/off control: 
35
-//    D = 0; Display off 
36
-//    C = 0; Cursor off 
37
-//    B = 0; Blinking off 
38
-// 4. Entry mode set: 
39
-//    I/D = 1; Increment by 1 
40
-//    S = 0; No shift 
41
-//
42
-// Note, however, that resetting the Arduino doesn't reset the LCD, so we
43
-// can't assume that it's in that state when a sketch starts (and the
44
-// LiquidCrystal constructor is called).
45
-// 
46
-// modified 27 Jul 2011
47
-// by Ilya V. Danilov http://mk90.ru/
48
-
49
-
50
-LiquidCrystalRus::LiquidCrystalRus(uint8_t rs, uint8_t rw, uint8_t enable,
51
-			     uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
52
-			     uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7)
53
-{
54
-  init(0, rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7);
55
-}
56
-
57
-LiquidCrystalRus::LiquidCrystalRus(uint8_t rs, uint8_t enable,
58
-			     uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
59
-			     uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7)
60
-{
61
-  init(0, rs, 255, enable, d0, d1, d2, d3, d4, d5, d6, d7);
62
-}
63
-
64
-LiquidCrystalRus::LiquidCrystalRus(uint8_t rs, uint8_t rw, uint8_t enable,
65
-			     uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3)
66
-{
67
-  init(1, rs, rw, enable, d0, d1, d2, d3, 0, 0, 0, 0);
68
-}
69
-
70
-LiquidCrystalRus::LiquidCrystalRus(uint8_t rs,  uint8_t enable,
71
-			     uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3)
72
-{
73
-  init(1, rs, 255, enable, d0, d1, d2, d3, 0, 0, 0, 0);
74
-}
75
-
76
-void LiquidCrystalRus::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable,
77
-			 uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
78
-			 uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7)
79
-{
80
-  _rs_pin = rs;
81
-  _rw_pin = rw;
82
-  _enable_pin = enable;
83
-  
84
-  _data_pins[0] = d0;
85
-  _data_pins[1] = d1;
86
-  _data_pins[2] = d2;
87
-  _data_pins[3] = d3; 
88
-  _data_pins[4] = d4;
89
-  _data_pins[5] = d5;
90
-  _data_pins[6] = d6;
91
-  _data_pins[7] = d7; 
92
-
93
-  pinMode(_rs_pin, OUTPUT);
94
-  // we can save 1 pin by not using RW. Indicate by passing 255 instead of pin#
95
-  if (_rw_pin != 255) { 
96
-    pinMode(_rw_pin, OUTPUT);
97
-  }
98
-  pinMode(_enable_pin, OUTPUT);
99
-  
100
-  if (fourbitmode)
101
-    _displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS;
102
-  else 
103
-    _displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS;
104
-  
105
-  begin(16, 1);  
106
-}
107
-
108
-void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
109
-  if (lines > 1) {
110
-    _displayfunction |= LCD_2LINE;
111
-  }
112
-  _numlines = lines;
113
-  _currline = 0;
114
-
115
-  // for some 1 line displays you can select a 10 pixel high font
116
-  if ((dotsize != 0) && (lines == 1)) {
117
-    _displayfunction |= LCD_5x10DOTS;
118
-  }
119
-
120
-  // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!
121
-  // according to datasheet, we need at least 40ms after power rises above 2.7V
122
-  // before sending commands. Arduino can turn on way before 4.5V so we'll wait 50
123
-  delayMicroseconds(50000); 
124
-  // Now we pull both RS and R/W low to begin commands
125
-  digitalWrite(_rs_pin, LOW);
126
-  digitalWrite(_enable_pin, LOW);
127
-  if (_rw_pin != 255) { 
128
-    digitalWrite(_rw_pin, LOW);
129
-  }
130
-  
131
-  //put the LCD into 4 bit or 8 bit mode
132
-  if (! (_displayfunction & LCD_8BITMODE)) {
133
-    // this is according to the Hitachi HD44780 datasheet
134
-    // figure 24, pg 46
135
-
136
-    // we start in 8bit mode, try to set 4 bit mode
137
-    writeNbits(0x03,4);
138
-    delayMicroseconds(4500); // wait min 4.1ms
139
-
140
-    // second try
141
-    writeNbits(0x03,4);
142
-    delayMicroseconds(4500); // wait min 4.1ms
143
-    
144
-    // third go!
145
-    writeNbits(0x03,4); 
146
-    delayMicroseconds(150);
147
-
148
-    // finally, set to 8-bit interface
149
-    writeNbits(0x02,4); 
150
-  } else {
151
-    // this is according to the Hitachi HD44780 datasheet
152
-    // page 45 figure 23
153
-
154
-    // Send function set command sequence
155
-    command(LCD_FUNCTIONSET | _displayfunction);
156
-    delayMicroseconds(4500);  // wait more than 4.1ms
157
-
158
-    // second try
159
-    command(LCD_FUNCTIONSET | _displayfunction);
160
-    delayMicroseconds(150);
161
-
162
-    // third go
163
-    command(LCD_FUNCTIONSET | _displayfunction);
164
-  }
165
-
166
-  // finally, set # lines, font size, etc.
167
-  command(LCD_FUNCTIONSET | _displayfunction);  
168
-
169
-  // turn the display on with no cursor or blinking default
170
-  _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;  
171
-  display();
172
-
173
-  // clear it off
174
-  clear();
175
-
176
-  // Initialize to default text direction (for romance languages)
177
-  _displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;
178
-  // set the entry mode
179
-  command(LCD_ENTRYMODESET | _displaymode);
180
-
181
-}
182
-
183
-void LiquidCrystalRus::setDRAMModel(uint8_t model) {
184
-  _dram_model = model;
185
-}
186
-
187
-/********** high level commands, for the user! */
188
-void LiquidCrystalRus::clear()
189
-{
190
-  command(LCD_CLEARDISPLAY);  // clear display, set cursor position to zero
191
-  delayMicroseconds(2000);  // this command takes a long time!
192
-}
193
-
194
-void LiquidCrystalRus::home()
195
-{
196
-  command(LCD_RETURNHOME);  // set cursor position to zero
197
-  delayMicroseconds(2000);  // this command takes a long time!
198
-}
199
-
200
-void LiquidCrystalRus::setCursor(uint8_t col, uint8_t row)
201
-{
202
-  int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 };
203
-  if ( row >= _numlines ) {
204
-    row = _numlines-1;    // we count rows starting w/0
205
-  }
206
-  
207
-  command(LCD_SETDDRAMADDR | (col + row_offsets[row]));
208
-}
209
-
210
-// Turn the display on/off (quickly)
211
-void LiquidCrystalRus::noDisplay() {
212
-  _displaycontrol &= ~LCD_DISPLAYON;
213
-  command(LCD_DISPLAYCONTROL | _displaycontrol);
214
-}
215
-void LiquidCrystalRus::display() {
216
-  _displaycontrol |= LCD_DISPLAYON;
217
-  command(LCD_DISPLAYCONTROL | _displaycontrol);
218
-}
219
-
220
-// Turns the underline cursor on/off
221
-void LiquidCrystalRus::noCursor() {
222
-  _displaycontrol &= ~LCD_CURSORON;
223
-  command(LCD_DISPLAYCONTROL | _displaycontrol);
224
-}
225
-void LiquidCrystalRus::cursor() {
226
-  _displaycontrol |= LCD_CURSORON;
227
-  command(LCD_DISPLAYCONTROL | _displaycontrol);
228
-}
229
-
230
-// Turn on and off the blinking cursor
231
-void LiquidCrystalRus::noBlink() {
232
-  _displaycontrol &= ~LCD_BLINKON;
233
-  command(LCD_DISPLAYCONTROL | _displaycontrol);
234
-}
235
-void LiquidCrystalRus::blink() {
236
-  _displaycontrol |= LCD_BLINKON;
237
-  command(LCD_DISPLAYCONTROL | _displaycontrol);
238
-}
239
-
240
-// These commands scroll the display without changing the RAM
241
-void LiquidCrystalRus::scrollDisplayLeft(void) {
242
-  command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT);
243
-}
244
-void LiquidCrystalRus::scrollDisplayRight(void) {
245
-  command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT);
246
-}
247
-
248
-// This is for text that flows Left to Right
249
-void LiquidCrystalRus::leftToRight(void) {
250
-  _displaymode |= LCD_ENTRYLEFT;
251
-  command(LCD_ENTRYMODESET | _displaymode);
252
-}
253
-
254
-// This is for text that flows Right to Left
255
-void LiquidCrystalRus::rightToLeft(void) {
256
-  _displaymode &= ~LCD_ENTRYLEFT;
257
-  command(LCD_ENTRYMODESET | _displaymode);
258
-}
259
-
260
-// This will 'right justify' text from the cursor
261
-void LiquidCrystalRus::autoscroll(void) {
262
-  _displaymode |= LCD_ENTRYSHIFTINCREMENT;
263
-  command(LCD_ENTRYMODESET | _displaymode);
264
-}
265
-
266
-// This will 'left justify' text from the cursor
267
-void LiquidCrystalRus::noAutoscroll(void) {
268
-  _displaymode &= ~LCD_ENTRYSHIFTINCREMENT;
269
-  command(LCD_ENTRYMODESET | _displaymode);
270
-}
271
-
272
-// Allows us to fill the first 8 CGRAM locations
273
-// with custom characters
274
-void LiquidCrystalRus::createChar(uint8_t location, uint8_t charmap[]) {
275
-  location &= 0x7; // we only have 8 locations 0-7
276
-  command(LCD_SETCGRAMADDR | (location << 3));
277
-  for (int i=0; i<8; i++) {
278
-    write(charmap[i]);
279
-  }
280
-}
281
-
282
-/*********** mid level commands, for sending data/cmds */
283
-
284
-inline void LiquidCrystalRus::command(uint8_t value) {
285
-  send(value, LOW);
286
-}
287
-
288
-#if defined(ARDUINO) && ARDUINO >= 100
289
-  size_t LiquidCrystalRus::write(uint8_t value)
290
-#else
291
-  void   LiquidCrystalRus::write(uint8_t value)
292
-#endif
293
-{
294
-  uint8_t out_char=value;
295
-
296
-  if (_dram_model == LCD_DRAM_WH1601) {  
297
-    uint8_t ac=recv(LOW) & 0x7f;
298
-    if (ac>7 && ac<0x14) command(LCD_SETDDRAMADDR | (0x40+ac-8));
299
-  }
300
-
301
-  if (value>=0x80) { // UTF-8 handling
302
-    if (value >= 0xc0) {
303
-      utf_hi_char = value - 0xd0;
304
-    } else {
305
-      value &= 0x3f;
306
-      if (!utf_hi_char && (value == 1)) 
307
-        send(0xa2,HIGH); // ╗
308
-      else if ((utf_hi_char == 1) && (value == 0x11)) 
309
-        send(0xb5,HIGH); // ╦
310
-      else 
311
-        send(pgm_read_byte_near(utf_recode + value + (utf_hi_char<<6) - 0x10), HIGH);
312
-    }    
313
-  } else send(out_char, HIGH);
314
-#if defined(ARDUINO) && ARDUINO >= 100
315
-  return 1; // assume success 
316
-#endif
317
-}
318
-
319
-/************ low level data pushing commands **********/
320
-
321
-// write either command or data, with automatic 4/8-bit selection
322
-void LiquidCrystalRus::send(uint8_t value, uint8_t mode) {
323
-  digitalWrite(_rs_pin, mode);
324
-
325
-  // if there is a RW pin indicated, set it low to Write
326
-  if (_rw_pin != 255) { 
327
-    digitalWrite(_rw_pin, LOW);
328
-  }
329
-  
330
-  if (_displayfunction & LCD_8BITMODE) {
331
-    writeNbits(value,8); 
332
-  } else {
333
-    writeNbits(value>>4,4);
334
-    writeNbits(value,4);
335
-  }
336
-}
337
-
338
-// read  data, with automatic 4/8-bit selection
339
-uint8_t LiquidCrystalRus::recv(uint8_t mode) {
340
-  uint8_t retval;
341
-  digitalWrite(_rs_pin, mode);
342
-
343
-  // if there is a RW pin indicated, set it low to Write
344
-  if (_rw_pin != 255) { 
345
-    digitalWrite(_rw_pin, HIGH);
346
-  }
347
-  
348
-  if (_displayfunction & LCD_8BITMODE) {
349
-    retval = readNbits(8); 
350
-  } else {
351
-    retval = readNbits(4) << 4;
352
-    retval |= readNbits(4);
353
-  }
354
-  return retval;
355
-}
356
-void LiquidCrystalRus::pulseEnable() {
357
-  digitalWrite(_enable_pin, LOW);
358
-  delayMicroseconds(1);    
359
-  digitalWrite(_enable_pin, HIGH);
360
-  delayMicroseconds(1);    // enable pulse must be >450ns
361
-  digitalWrite(_enable_pin, LOW);
362
-  delayMicroseconds(100);   // commands need > 37us to settle
363
-}
364
-
365
-void LiquidCrystalRus::writeNbits(uint8_t value, uint8_t n) {
366
-  for (int i = 0; i < n; i++) {
367
-    pinMode(_data_pins[i], OUTPUT);
368
-    digitalWrite(_data_pins[i], (value >> i) & 0x01);
369
-  }
370
-
371
-  pulseEnable();
372
-}
373
-
374
-uint8_t LiquidCrystalRus::readNbits(uint8_t n) {
375
-  uint8_t retval=0;
376
-  for (int i = 0; i < n; i++) {
377
-    pinMode(_data_pins[i], INPUT);
378
-  }
379
-
380
-  digitalWrite(_enable_pin, LOW);
381
-  delayMicroseconds(1);    
382
-  digitalWrite(_enable_pin, HIGH);
383
-  delayMicroseconds(1);    // enable pulse must be >450ns
384
-  
385
-  for (int i = 0; i < n; i++) {
386
-    retval |= (digitalRead(_data_pins[i]) == HIGH)?(1 << i):0;
387
-  }
388
-
389
-  digitalWrite(_enable_pin, LOW);
390
-
391
-  return retval;
392
-}
393
-

+ 0
- 129
Marlin/LiquidCrystalRus.h ファイルの表示

@@ -1,129 +0,0 @@
1
-//
2
-// based on LiquidCrystal library from ArduinoIDE, see http://arduino.cc
3
-//  modified 27 Jul 2011
4
-// by Ilya V. Danilov http://mk90.ru/
5
-// 
6
-
7
-#ifndef LiquidCrystalRus_h
8
-#define LiquidCrystalRus_h
9
-
10
-#include <inttypes.h>
11
-#include "Print.h"
12
-
13
-// commands
14
-#define LCD_CLEARDISPLAY 0x01
15
-#define LCD_RETURNHOME 0x02
16
-#define LCD_ENTRYMODESET 0x04
17
-#define LCD_DISPLAYCONTROL 0x08
18
-#define LCD_CURSORSHIFT 0x10
19
-#define LCD_FUNCTIONSET 0x20
20
-#define LCD_SETCGRAMADDR 0x40
21
-#define LCD_SETDDRAMADDR 0x80
22
-
23
-// flags for display entry mode
24
-#define LCD_ENTRYRIGHT 0x00
25
-#define LCD_ENTRYLEFT 0x02
26
-#define LCD_ENTRYSHIFTINCREMENT 0x01
27
-#define LCD_ENTRYSHIFTDECREMENT 0x00
28
-
29
-// flags for display on/off control
30
-#define LCD_DISPLAYON 0x04
31
-#define LCD_DISPLAYOFF 0x00
32
-#define LCD_CURSORON 0x02
33
-#define LCD_CURSOROFF 0x00
34
-#define LCD_BLINKON 0x01
35
-#define LCD_BLINKOFF 0x00
36
-
37
-// flags for display/cursor shift
38
-#define LCD_DISPLAYMOVE 0x08
39
-#define LCD_CURSORMOVE 0x00
40
-#define LCD_MOVERIGHT 0x04
41
-#define LCD_MOVELEFT 0x00
42
-
43
-// flags for function set
44
-#define LCD_8BITMODE 0x10
45
-#define LCD_4BITMODE 0x00
46
-#define LCD_2LINE 0x08
47
-#define LCD_1LINE 0x00
48
-#define LCD_5x10DOTS 0x04
49
-#define LCD_5x8DOTS 0x00
50
-
51
-// enum for 
52
-#define LCD_DRAM_Normal 0x00
53
-#define LCD_DRAM_WH1601 0x01
54
-
55
-
56
-class LiquidCrystalRus : public Print {
57
-public:
58
-  LiquidCrystalRus(uint8_t rs, uint8_t enable,
59
-		uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
60
-		uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
61
-  LiquidCrystalRus(uint8_t rs, uint8_t rw, uint8_t enable,
62
-		uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
63
-		uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
64
-  LiquidCrystalRus(uint8_t rs, uint8_t rw, uint8_t enable,
65
-		uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3);
66
-  LiquidCrystalRus(uint8_t rs, uint8_t enable,
67
-		uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3);
68
-
69
-  void init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable,
70
-	    uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
71
-	    uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
72
-    
73
-  void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS);
74
-
75
-  void clear();
76
-  void home();
77
-
78
-  void noDisplay();
79
-  void display();
80
-  void noBlink();
81
-  void blink();
82
-  void noCursor();
83
-  void cursor();
84
-  void scrollDisplayLeft();
85
-  void scrollDisplayRight();
86
-  void leftToRight();
87
-  void rightToLeft();
88
-  void autoscroll();
89
-  void noAutoscroll();
90
-
91
-  void createChar(uint8_t, uint8_t[]);
92
-  void setCursor(uint8_t, uint8_t);
93
- 
94
-#if defined(ARDUINO) && ARDUINO >= 100
95
-  virtual size_t write(uint8_t);
96
-  using Print::write;
97
-#else
98
-  virtual void write(uint8_t);
99
-#endif
100
-
101
-  void command(uint8_t);
102
-
103
-  void setDRAMModel(uint8_t);
104
-
105
-private:
106
-  void send(uint8_t, uint8_t);
107
-  void writeNbits(uint8_t, uint8_t);
108
-  uint8_t recv(uint8_t);
109
-  uint8_t readNbits(uint8_t); 
110
-  void pulseEnable();
111
-
112
-  uint8_t _rs_pin; // LOW: command.  HIGH: character.
113
-  uint8_t _rw_pin; // LOW: write to LCD.  HIGH: read from LCD.
114
-  uint8_t _enable_pin; // activated by a HIGH pulse.
115
-  uint8_t _data_pins[8];
116
-
117
-  uint8_t _displayfunction;
118
-  uint8_t _displaycontrol;
119
-  uint8_t _displaymode;
120
-
121
-  uint8_t _initialized;
122
-
123
-  uint8_t _numlines,_currline;
124
-
125
-  uint8_t _dram_model;
126
-  uint8_t utf_hi_char; // UTF-8 high part
127
-};
128
-
129
-#endif

+ 79
- 80
Marlin/ultralcd_implementation_hitachi_HD44780.h ファイルの表示

@@ -179,25 +179,20 @@
179 179
 // 2 wire Non-latching LCD SR from:
180 180
 // https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection 
181 181
 #elif defined(SR_LCD_2W_NL)
182
-
183 182
   extern "C" void __cxa_pure_virtual() { while (1); }
184 183
   #include <LCD.h>
185 184
   #include <LiquidCrystal_SR.h>
186 185
   #define LCD_CLASS LiquidCrystal_SR
187 186
   LCD_CLASS lcd(SR_DATA_PIN, SR_CLK_PIN);
188
-
189 187
 #else
190 188
   // Standard directly connected LCD implementations
191
-  #ifdef LANGUAGE_RU
192
-    #include "LiquidCrystalRus.h"
193
-    #define LCD_CLASS LiquidCrystalRus
194
-  #else 
195
-    #include <LiquidCrystal.h>
196
-    #define LCD_CLASS LiquidCrystal
197
-  #endif  
189
+  #include <LiquidCrystal.h>
190
+  #define LCD_CLASS LiquidCrystal
198 191
   LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7);  //RS,Enable,D4,D5,D6,D7
199 192
 #endif
200 193
 
194
+#include "utf_mapper.h"
195
+
201 196
 #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
202 197
   static uint16_t progressBarTick = 0;
203 198
   #if PROGRESS_MSG_EXPIRE > 0
@@ -207,7 +202,7 @@
207 202
 #endif
208 203
 
209 204
 /* Custom characters defined in the first 8 characters of the LCD */
210
-#define LCD_STR_BEDTEMP     "\x00"
205
+#define LCD_STR_BEDTEMP     "\x00"  // this will have 'unexpected' results when used in a string!
211 206
 #define LCD_STR_DEGREE      "\x01"
212 207
 #define LCD_STR_THERMOMETER "\x02"
213 208
 #define LCD_STR_UPLEVEL     "\x03"
@@ -215,7 +210,8 @@
215 210
 #define LCD_STR_FOLDER      "\x05"
216 211
 #define LCD_STR_FEEDRATE    "\x06"
217 212
 #define LCD_STR_CLOCK       "\x07"
218
-#define LCD_STR_ARROW_RIGHT "\x7E"  /* from the default character set */
213
+//#define LCD_STR_ARROW_RIGHT "\x7E"  /* from the default character set. Only available on DISPLAY_CHARSET_HD44780_JAPAN - at this place!*/
214
+#define LCD_STR_ARROW_RIGHT ">"  /* from the default character set */
219 215
 
220 216
 static void lcd_set_custom_characters(
221 217
   #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
@@ -405,15 +401,31 @@ static void lcd_implementation_clear()
405 401
 {
406 402
     lcd.clear();
407 403
 }
404
+
408 405
 /* Arduino < 1.0.0 is missing a function to print PROGMEM strings, so we need to implement our own */
409
-static void lcd_printPGM(const char* str)
410
-{
411
-    char c;
412
-    while((c = pgm_read_byte(str++)) != '\0')
413
-    {
414
-        lcd.write(c);
415
-    }
406
+char lcd_printPGM(const char* str) {
407
+  char c;
408
+  char n = 0;
409
+  while((c = pgm_read_byte(str++))) {
410
+      n += charset_mapper(c);
411
+  }
412
+  return n;
413
+}
414
+
415
+char lcd_print(char* str) {
416
+  char c;
417
+  char i = 0;
418
+  char n = 0;
419
+  while((c = str[i++])) {
420
+      n += charset_mapper(c);
421
+  }
422
+  return n;
416 423
 }
424
+
425
+unsigned lcd_print(char c) {
426
+    return charset_mapper(c);
427
+}
428
+
417 429
 /*
418 430
 Possible status screens:
419 431
 16x2   |0123456789012345|
@@ -608,8 +620,9 @@ static void lcd_implementation_status_screen()
608 620
     }
609 621
   #endif //FILAMENT_LCD_DISPLAY
610 622
 
611
-  lcd.print(lcd_status_message);
623
+  lcd_print(lcd_status_message);
612 624
 }
625
+
613 626
 static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char)
614 627
 {
615 628
     char c;
@@ -623,12 +636,12 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c
623 636
     lcd.print(pre_char);
624 637
     while( ((c = pgm_read_byte(pstr)) != '\0') && (n>0) )
625 638
     {
626
-        lcd.print(c);
639
+        n -= lcd_print(c);
627 640
         pstr++;
628
-        if ((pgm_read_byte(pstr) & 0xc0) != 0x80) n--;
629 641
     }
630
-    while(n--)
631
-        lcd.print(' ');
642
+    while(n--) {
643
+      lcd.print(' ');
644
+    }
632 645
     lcd.print(post_char);
633 646
     lcd.print(' ');
634 647
 }
@@ -643,16 +656,14 @@ static void lcd_implementation_drawmenu_setting_edit_generic(uint8_t row, const
643 656
   #endif
644 657
     lcd.setCursor(0, row);
645 658
     lcd.print(pre_char);
646
-    while( ((c = pgm_read_byte(pstr)) != '\0') && (n>0) )
647
-    {
648
-        lcd.print(c);
649
-        pstr++;
650
-        if ((pgm_read_byte(pstr) & 0xc0) != 0x80) n--;
659
+    while( ((c = pgm_read_byte(pstr)) != '\0') && (n>0) ) {
660
+      n -= lcd_print(c);
661
+      pstr++;
651 662
     }
652 663
     lcd.print(':');
653 664
     while(n--)
654
-        lcd.print(' ');
655
-    lcd.print(data);
665
+      lcd.print(' ');
666
+    lcd_print(data);
656 667
 }
657 668
 static void lcd_implementation_drawmenu_setting_edit_generic_P(uint8_t row, const char* pstr, char pre_char, const char* data)
658 669
 {
@@ -665,15 +676,13 @@ static void lcd_implementation_drawmenu_setting_edit_generic_P(uint8_t row, cons
665 676
   #endif
666 677
     lcd.setCursor(0, row);
667 678
     lcd.print(pre_char);
668
-    while( ((c = pgm_read_byte(pstr)) != '\0') && (n>0) )
669
-    {
670
-        lcd.print(c);
671
-        pstr++;
672
-        if ((pgm_read_byte(pstr) & 0xc0) != 0x80) n--;
679
+    while( ((c = pgm_read_byte(pstr)) != '\0') && (n>0) ) {
680
+      n -= lcd_print(c);
681
+      pstr++;
673 682
     }
674 683
     lcd.print(':');
675 684
     while(n--)
676
-        lcd.print(' ');
685
+      lcd.print(' ');
677 686
     lcd_printPGM(data);
678 687
 }
679 688
 #define lcd_implementation_drawmenu_setting_edit_int3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', itostr3(*(data)))
@@ -726,7 +735,7 @@ void lcd_implementation_drawedit(const char* pstr, char* value)
726 735
     #else
727 736
       lcd.setCursor(LCD_WIDTH -1 - lcd_strlen(value), 1);
728 737
    #endif
729
-    lcd.print(value);
738
+    lcd_print(value);
730 739
 }
731 740
 static void lcd_implementation_drawmenu_sdfile_selected(uint8_t row, const char* pstr, const char* filename, char* longFilename)
732 741
 {
@@ -741,9 +750,8 @@ static void lcd_implementation_drawmenu_sdfile_selected(uint8_t row, const char*
741 750
     }
742 751
     while( ((c = *filename) != '\0') && (n>0) )
743 752
     {
744
-        lcd.print(c);
753
+        n -= lcd_print(c);
745 754
         filename++;
746
-        n--;
747 755
     }
748 756
     while(n--)
749 757
         lcd.print(' ');
@@ -761,54 +769,45 @@ static void lcd_implementation_drawmenu_sdfile(uint8_t row, const char* pstr, co
761 769
     }
762 770
     while( ((c = *filename) != '\0') && (n>0) )
763 771
     {
764
-        lcd.print(c);
772
+        n -= lcd_print(c);
765 773
         filename++;
766
-        n--;
767 774
     }
768 775
     while(n--)
769 776
         lcd.print(' ');
770 777
 }
771
-static void lcd_implementation_drawmenu_sddirectory_selected(uint8_t row, const char* pstr, const char* filename, char* longFilename)
772
-{
773
-    char c;
774
-    uint8_t n = LCD_WIDTH - 2;
775
-    lcd.setCursor(0, row);
776
-    lcd.print('>');
777
-    lcd.print(LCD_STR_FOLDER[0]);
778
-    if (longFilename[0] != '\0')
779
-    {
780
-        filename = longFilename;
781
-        longFilename[LCD_WIDTH-2] = '\0';
782
-    }
783
-    while( ((c = *filename) != '\0') && (n>0) )
784
-    {
785
-        lcd.print(c);
786
-        filename++;
787
-        n--;
788
-    }
789
-    while(n--)
790
-        lcd.print(' ');
778
+static void lcd_implementation_drawmenu_sddirectory_selected(uint8_t row, const char* pstr, const char* filename, char* longFilename) {
779
+  char c;
780
+  uint8_t n = LCD_WIDTH - 2;
781
+  lcd.setCursor(0, row);
782
+  lcd.print('>');
783
+  lcd.print(LCD_STR_FOLDER[0]);
784
+  if (longFilename[0] != '\0') {
785
+    filename = longFilename;
786
+    longFilename[LCD_WIDTH-2] = '\0';
787
+  }
788
+  while( ((c = *filename) != '\0') && (n>0) ) {
789
+    n -= lcd_print(c);
790
+    filename++;
791
+  }
792
+  while(n--)
793
+    lcd.print(' ');
791 794
 }
792
-static void lcd_implementation_drawmenu_sddirectory(uint8_t row, const char* pstr, const char* filename, char* longFilename)
793
-{
794
-    char c;
795
-    uint8_t n = LCD_WIDTH - 2;
796
-    lcd.setCursor(0, row);
795
+static void lcd_implementation_drawmenu_sddirectory(uint8_t row, const char* pstr, const char* filename, char* longFilename) {
796
+  char c;
797
+  uint8_t n = LCD_WIDTH - 2;
798
+  lcd.setCursor(0, row);
799
+  lcd.print(' ');
800
+  lcd.print(LCD_STR_FOLDER[0]);
801
+  if (longFilename[0] != '\0') {
802
+    filename = longFilename;
803
+    longFilename[LCD_WIDTH-2] = '\0';
804
+  }
805
+  while( ((c = *filename) != '\0') && (n>0) ) {
806
+    n -= lcd_print(c);
807
+    filename++;
808
+  }
809
+  while(n--)
797 810
     lcd.print(' ');
798
-    lcd.print(LCD_STR_FOLDER[0]);
799
-    if (longFilename[0] != '\0')
800
-    {
801
-        filename = longFilename;
802
-        longFilename[LCD_WIDTH-2] = '\0';
803
-    }
804
-    while( ((c = *filename) != '\0') && (n>0) )
805
-    {
806
-        lcd.print(c);
807
-        filename++;
808
-        n--;
809
-    }
810
-    while(n--)
811
-        lcd.print(' ');
812 811
 }
813 812
 #define lcd_implementation_drawmenu_back_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
814 813
 #define lcd_implementation_drawmenu_back(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_UPLEVEL[0])

読み込み中…
キャンセル
保存