Merge pull request #1622 from AnHardt/tm-utf-minus-kanji

The big Language Pack
This commit is contained in:
Scott Lahteine
2015-03-27 18:24:19 -07:00
46 changed files with 2446 additions and 857 deletions

View File

@ -14,11 +14,9 @@
#ifndef DOGM_LCD_IMPLEMENTATION_H
#define DOGM_LCD_IMPLEMENTATION_H
#define MARLIN_VERSION "1.0.2"
/**
* Implementation of the LCD display routines for a DOGM128 graphic display. These are common LCD 128x64 pixel graphic displays.
**/
* Implementation of the LCD display routines for a DOGM128 graphic display. These are common LCD 128x64 pixel graphic displays.
*/
#ifdef ULTIPANEL
#define BLEN_A 0
@ -32,53 +30,99 @@
#include <U8glib.h>
#include "DOGMbitmaps.h"
#include "dogm_font_data_ISO10646_1_Marlin.h"
#include "ultralcd.h"
#include "ultralcd_st7920_u8glib_rrd.h"
#include "Configuration.h"
/* Russian language not supported yet, needs custom font
#ifdef LANGUAGE_RU
#include "LiquidCrystalRus.h"
#define LCD_CLASS LiquidCrystalRus
#else
#include <LiquidCrystal.h>
#define LCD_CLASS LiquidCrystal
// save 3120 bytes of PROGMEM by commenting out #define USE_BIG_EDIT_FONT
// we don't have a big font for Cyrillic, Kana
#if defined( MAPPER_C2C3 ) || defined( MAPPER_NON )
// #define USE_BIG_EDIT_FONT
#endif
*/
#define USE_BIG_EDIT_FONT // save 3120 bytes of PROGMEM by commenting out this line
#define FONT_MENU ISO10646_1_Marlin_5x7
// If you have spare 2300Byte of progmem and want to use a
// smaller font on the Info-screen uncomment the next line.
//#define USE_SMALL_INFOFONT
#ifdef USE_SMALL_INFOFONT
#include "dogm_font_data_6x9_marlin.h"
#define FONT_STATUSMENU_NAME u8g_font_6x9
#else
#define FONT_STATUSMENU_NAME FONT_MENU_NAME
#endif
#include "dogm_font_data_Marlin_symbols.h" // The Marlin special symbols
#define FONT_SPECIAL_NAME Marlin_symbols
#ifndef SIMULATE_ROMFONT
#if defined( DISPLAY_CHARSET_ISO10646_1 )
#include "dogm_font_data_ISO10646_1.h"
#define FONT_MENU_NAME ISO10646_1_5x7
#elif defined( DISPLAY_CHARSET_ISO10646_5 )
#include "dogm_font_data_ISO10646_5_Cyrillic.h"
#define FONT_MENU_NAME ISO10646_5_Cyrillic_5x7
#elif defined( DISPLAY_CHARSET_ISO10646_KANA )
#include "dogm_font_data_ISO10646_Kana.h"
#define FONT_MENU_NAME ISO10646_Kana_5x7
#else // fall-back
#include "dogm_font_data_ISO10646_1.h"
#define FONT_MENU_NAME ISO10646_1_5x7
#endif
#else // SIMULATE_ROMFONT
#if defined( DISPLAY_CHARSET_HD44780_JAPAN )
#include "dogm_font_data_HD44780_J.h"
#define FONT_MENU_NAME HD44780_J_5x7
#elif defined( DISPLAY_CHARSET_HD44780_WESTERN )
#include "dogm_font_data_HD44780_W.h"
#define FONT_MENU_NAME HD44780_W_5x7
#elif defined( DISPLAY_CHARSET_HD44780_CYRILLIC )
#include "dogm_font_data_HD44780_C.h"
#define FONT_MENU_NAME HD44780_C_5x7
#else // fall-back
#include "dogm_font_data_ISO10646_1.h"
#define FONT_MENU_NAME ISO10646_1_5x7
#endif
#endif // SIMULATE_ROMFONT
//#define FONT_STATUSMENU_NAME FONT_MENU_NAME
#define FONT_STATUSMENU 1
#define FONT_SPECIAL 2
#define FONT_MENU_EDIT 3
#define FONT_MENU 4
// DOGM parameters (size in pixels)
#define DOG_CHAR_WIDTH 6
#define DOG_CHAR_HEIGHT 12
#ifdef USE_BIG_EDIT_FONT
#define FONT_MENU_EDIT u8g_font_9x18
#define FONT_MENU_EDIT_NAME u8g_font_9x18
#define DOG_CHAR_WIDTH_EDIT 9
#define DOG_CHAR_HEIGHT_EDIT 18
#define LCD_WIDTH_EDIT 14
#else
#define FONT_MENU_EDIT ISO10646_1_Marlin_5x7
#define FONT_MENU_EDIT_NAME FONT_MENU_NAME
#define DOG_CHAR_WIDTH_EDIT 6
#define DOG_CHAR_HEIGHT_EDIT 12
#define LCD_WIDTH_EDIT 22
#endif
#define FONT_STATUSMENU FONT_MENU
#define START_ROW 0
/* Custom characters defined in font font_6x10_marlin.c */
#define LCD_STR_DEGREE "\xB0"
#define LCD_STR_REFRESH "\xF8"
#define LCD_STR_FOLDER "\xF9"
#define LCD_STR_ARROW_RIGHT "\xFA"
#define LCD_STR_UPLEVEL "\xFB"
#define LCD_STR_CLOCK "\xFC"
#define LCD_STR_FEEDRATE "\xFD"
#define LCD_STR_BEDTEMP "\xFE"
#define LCD_STR_THERMOMETER "\xFF"
/* Custom characters defined in font font_6x10_marlin_symbols */
// \x00 intentionally skipped to avoid problems in strings
#define LCD_STR_REFRESH "\x01"
#define LCD_STR_FOLDER "\x02"
#define LCD_STR_ARROW_RIGHT "\x03"
#define LCD_STR_UPLEVEL "\x04"
#define LCD_STR_CLOCK "\x05"
#define LCD_STR_FEEDRATE "\x06"
#define LCD_STR_BEDTEMP "\x07"
#define LCD_STR_THERMOMETER "\x08"
#define LCD_STR_DEGREE "\x09"
#define LCD_STR_SPECIAL_MAX '\x09'
// Maximum here is 0x1f because 0x20 is ' ' (space) and the normal charsets begin.
// Better stay below 0x10 because DISPLAY_CHARSET_HD44780_WESTERN begins here.
int lcd_contrast;
@ -97,6 +141,51 @@ U8GLIB_NHD_C12864 u8g(DOGLCD_CS, DOGLCD_A0);
U8GLIB_DOGM128 u8g(DOGLCD_CS, DOGLCD_A0); // HW-SPI Com: CS, A0
#endif
#include "utf_mapper.h"
char currentfont = 0;
static void lcd_setFont(char font_nr) {
switch(font_nr) {
case FONT_STATUSMENU : {u8g.setFont(FONT_STATUSMENU_NAME); currentfont = FONT_STATUSMENU;}; break;
case FONT_MENU : {u8g.setFont(FONT_MENU_NAME); currentfont = FONT_MENU;}; break;
case FONT_SPECIAL : {u8g.setFont(FONT_SPECIAL_NAME); currentfont = FONT_SPECIAL;}; break;
case FONT_MENU_EDIT : {u8g.setFont(FONT_MENU_EDIT_NAME); currentfont = FONT_MENU_EDIT;}; break;
break;
}
}
char lcd_print(char c) {
if ((c > 0) && (c <= LCD_STR_SPECIAL_MAX)) {
u8g.setFont(FONT_SPECIAL_NAME);
u8g.print(c);
lcd_setFont(currentfont);
return 1;
} else {
return charset_mapper(c);
}
}
char lcd_print(char* str) {
char c;
int i = 0;
char n = 0;
while ((c = str[i++])) {
n += lcd_print(c);
}
return n;
}
/* Arduino < 1.0.0 is missing a function to print PROGMEM strings, so we need to implement our own */
char lcd_printPGM(const char* str) {
char c;
char n = 0;
while ((c = pgm_read_byte(str++))) {
n += lcd_print(c);
}
return n;
}
static void lcd_implementation_init()
{
#ifdef LCD_PIN_BL // Enable LCD backlight
@ -131,7 +220,7 @@ static void lcd_implementation_init()
u8g.firstPage();
do {
u8g.drawBitmapP(offx, offy, START_BMPBYTEWIDTH, START_BMPHEIGHT, start_bmp);
u8g.setFont(FONT_MENU);
lcd_setFont(FONT_MENU);
#ifndef STRING_SPLASH_LINE2
u8g.drawStr(txt1X, u8g.getHeight() - DOG_CHAR_HEIGHT, STRING_SPLASH_LINE1);
#else
@ -144,21 +233,17 @@ static void lcd_implementation_init()
static void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
/* Arduino < 1.0.0 is missing a function to print PROGMEM strings, so we need to implement our own */
static void lcd_printPGM(const char* str) {
char c;
while ((c = pgm_read_byte(str++))) u8g.print(c);
}
static void _draw_heater_status(int x, int heater) {
bool isBed = heater < 0;
int y = 17 + (isBed ? 1 : 0);
u8g.setFont(FONT_STATUSMENU);
lcd_setFont(FONT_STATUSMENU);
u8g.setPrintPos(x,7);
u8g.print(itostr3(int((heater >= 0 ? degTargetHotend(heater) : degTargetBed()) + 0.5)));
lcd_print(itostr3(int((heater >= 0 ? degTargetHotend(heater) : degTargetBed()) + 0.5)));
lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
u8g.setPrintPos(x,28);
u8g.print(itostr3(int(heater >= 0 ? degHotend(heater) : degBed()) + 0.5));
lcd_print(itostr3(int(heater >= 0 ? degHotend(heater) : degBed()) + 0.5));
lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
if (!isHeatingHotend(0)) {
u8g.drawBox(x+7,y,2,2);
@ -190,7 +275,7 @@ static void lcd_implementation_status_screen() {
u8g.drawFrame(54,49,73,4);
// SD Card Progress bar and clock
u8g.setFont(FONT_STATUSMENU);
lcd_setFont(FONT_STATUSMENU);
if (IS_SD_PRINTING) {
// Progress bar solid part
@ -200,9 +285,9 @@ static void lcd_implementation_status_screen() {
u8g.setPrintPos(80,48);
if (starttime != 0) {
uint16_t time = (millis() - starttime) / 60000;
u8g.print(itostr2(time/60));
u8g.print(':');
u8g.print(itostr2(time%60));
lcd_print(itostr2(time/60));
lcd_print(':');
lcd_print(itostr2(time%60));
}
else {
lcd_printPGM(PSTR("--:--"));
@ -216,69 +301,79 @@ static void lcd_implementation_status_screen() {
if (EXTRUDERS < 4) _draw_heater_status(81, -1);
// Fan
u8g.setFont(FONT_STATUSMENU);
lcd_setFont(FONT_STATUSMENU);
u8g.setPrintPos(104,27);
#if defined(FAN_PIN) && FAN_PIN > -1
int per = ((fanSpeed + 1) * 100) / 256;
if (per) {
u8g.print(itostr3(per));
u8g.print('%');
lcd_print(itostr3(per));
lcd_print('%');
}
else
#endif
{
u8g.print("---");
lcd_printPGM(PSTR("---"));
}
// X, Y, Z-Coordinates
#define XYZ_BASELINE 38
u8g.setFont(FONT_STATUSMENU);
u8g.drawBox(0,30,128,9);
lcd_setFont(FONT_STATUSMENU);
#ifdef USE_SMALL_INFOFONT
u8g.drawBox(0,30,128,10);
#else
u8g.drawBox(0,30,128,9);
#endif
u8g.setColorIndex(0); // white on black
u8g.setPrintPos(2,XYZ_BASELINE);
u8g.print('X');
lcd_print('X');
u8g.drawPixel(8,XYZ_BASELINE - 5);
u8g.drawPixel(8,XYZ_BASELINE - 3);
u8g.setPrintPos(10,XYZ_BASELINE);
u8g.print(ftostr31ns(current_position[X_AXIS]));
lcd_print(ftostr31ns(current_position[X_AXIS]));
u8g.setPrintPos(43,XYZ_BASELINE);
u8g.print('Y');
lcd_print('Y');
u8g.drawPixel(49,XYZ_BASELINE - 5);
u8g.drawPixel(49,XYZ_BASELINE - 3);
u8g.setPrintPos(51,XYZ_BASELINE);
u8g.print(ftostr31ns(current_position[Y_AXIS]));
lcd_print(ftostr31ns(current_position[Y_AXIS]));
u8g.setPrintPos(83,XYZ_BASELINE);
u8g.print('Z');
lcd_print('Z');
u8g.drawPixel(89,XYZ_BASELINE - 5);
u8g.drawPixel(89,XYZ_BASELINE - 3);
u8g.setPrintPos(91,XYZ_BASELINE);
u8g.print(ftostr31(current_position[Z_AXIS]));
lcd_print(ftostr31(current_position[Z_AXIS]));
u8g.setColorIndex(1); // black on white
// Feedrate
u8g.setFont(FONT_MENU);
lcd_setFont(FONT_MENU);
u8g.setPrintPos(3,49);
u8g.print(LCD_STR_FEEDRATE[0]);
u8g.setFont(FONT_STATUSMENU);
lcd_print(LCD_STR_FEEDRATE[0]);
lcd_setFont(FONT_STATUSMENU);
u8g.setPrintPos(12,49);
u8g.print(itostr3(feedmultiply));
u8g.print('%');
lcd_print(itostr3(feedmultiply));
lcd_print('%');
// Status line
u8g.setFont(FONT_STATUSMENU);
lcd_setFont(FONT_STATUSMENU);
#ifdef USE_SMALL_INFOFONT
u8g.setPrintPos(0,62);
#else
u8g.setPrintPos(0,63);
#endif
#ifndef FILAMENT_LCD_DISPLAY
u8g.print(lcd_status_message);
lcd_print(lcd_status_message);
#else
if (millis() < message_millis + 5000) { //Display both Status message line and Filament display on the last line
u8g.print(lcd_status_message);
lcd_print(lcd_status_message);
}
else {
lcd_printPGM(PSTR("dia:"));
u8g.print(ftostr12ns(filament_width_meas));
lcd_print(ftostr12ns(filament_width_meas));
lcd_printPGM(PSTR(" factor:"));
u8g.print(itostr3(extrudemultiply));
u8g.print('%');
lcd_print(itostr3(extrudemultiply));
lcd_print('%');
}
#endif
}
@ -301,14 +396,13 @@ static void lcd_implementation_drawmenu_generic(bool isSelected, uint8_t row, co
lcd_implementation_mark_as_selected(row, isSelected);
while ((c = pgm_read_byte(pstr))) {
u8g.print(c);
while (c = pgm_read_byte(pstr)) {
n -= lcd_print(c);
pstr++;
n--;
}
while (n--) u8g.print(' ');
u8g.print(post_char);
u8g.print(' ');
while (n--) lcd_print(' ');
lcd_print(post_char);
lcd_print(' ');
}
static void _drawmenu_setting_edit_generic(bool isSelected, uint8_t row, const char* pstr, const char* data, bool pgm) {
@ -317,14 +411,13 @@ static void _drawmenu_setting_edit_generic(bool isSelected, uint8_t row, const c
lcd_implementation_mark_as_selected(row, isSelected);
while ((c = pgm_read_byte(pstr))) {
u8g.print(c);
while (c = pgm_read_byte(pstr)) {
n -= lcd_print(c);
pstr++;
n--;
}
u8g.print(':');
while (n--) u8g.print(' ');
if (pgm) { lcd_printPGM(data); } else { u8g.print(data); }
lcd_print(':');
while (n--) lcd_print(' ');
if (pgm) { lcd_printPGM(data); } else { lcd_print((char *)data); }
}
#define lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, false)
@ -358,13 +451,13 @@ void lcd_implementation_drawedit(const char* pstr, char* value) {
#ifdef USE_BIG_EDIT_FONT
if (lcd_strlen_P(pstr) <= LCD_WIDTH_EDIT - 1) {
u8g.setFont(FONT_MENU_EDIT);
lcd_setFont(FONT_MENU_EDIT);
lcd_width = LCD_WIDTH_EDIT + 1;
char_width = DOG_CHAR_WIDTH_EDIT;
if (lcd_strlen_P(pstr) >= LCD_WIDTH_EDIT - vallen) rows = 2;
}
else {
u8g.setFont(FONT_MENU);
lcd_setFont(FONT_MENU);
}
#endif
@ -375,9 +468,9 @@ void lcd_implementation_drawedit(const char* pstr, char* value) {
u8g.setPrintPos(0, rowHeight + kHalfChar);
lcd_printPGM(pstr);
u8g.print(':');
lcd_print(':');
u8g.setPrintPos((lcd_width - 1 - vallen) * char_width, rows * rowHeight + kHalfChar);
u8g.print(value);
lcd_print(value);
}
static void _drawmenu_sd(bool isSelected, uint8_t row, const char* pstr, const char* filename, char * const longFilename, bool isDir) {
@ -391,13 +484,12 @@ static void _drawmenu_sd(bool isSelected, uint8_t row, const char* pstr, const c
lcd_implementation_mark_as_selected(row, isSelected);
if (isDir) u8g.print(LCD_STR_FOLDER[0]);
while ((c = *filename)) {
u8g.print(c);
if (isDir) lcd_print(LCD_STR_FOLDER[0]);
while (c = *filename) {
n -= lcd_print(c);
filename++;
n--;
}
while (n--) u8g.print(' ');
while (n--) lcd_print(' ');
}
#define lcd_implementation_drawmenu_sdfile(sel, row, pstr, filename, longFilename) _drawmenu_sd(sel, row, pstr, filename, longFilename, false)