Files
ATmega-Soldering-Station/software/sources/SolderingStation2_arduboy_gplib_v1.7t1.ino
createskyblue 473bec9dc1 V1.7 beta
1.由画师lihaoyun6的帮助下我们重置菜单图标,统一风格,并通过降低分辨率的形式来达到减少内存使用的目的,为未来更多功能的加入创造了可能性
2.修复英语模式中潜在的内存越界BUG
////////////////////////////////////////////////////
1. With the help of painter lihaoyun6, we recreate the menu icon, unify
the style, and reduce the memory usage by reducing the resolution, which
creates the possibility of adding more functions in the future

2. Fix
the potential memory overrun bug in English mode
2020-08-25 12:16:53 +08:00

1346 lines
73 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*License: http://creativecommons.org/licenses/by-sa/3.0/
采用CC3.0协议共享此程序
您可以自由地:-
-AZ
共享 — 在任何媒介以任何形式复制、发行本作品
演绎 — 修改、转换或以本作品为基础进行创作
在任何用途下,甚至商业目的。
本许可协议为“自由文化作品Free Cultural Works”所接受。
只要你遵守许可协议条款,许可人就无法收回你的这些权利。
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
You are free to:
Share — copy and redistribute the material in any medium or format
Adapt — remix, transform, and build upon the material
for any purpose, even commercially.
This license is acceptable for Free Cultural Works.
The licensor cannot revoke these freedoms as long as you follow the license terms.
*/
// SolderingStation2
//
// ATmega328-controlled Soldering Station for Hakko T12 Tips.
//
// This version of the code implements:
// - Temperature measurement of the tip
// - Direct or PID control of the heater
// - Temperature control via rotary encoder
// - Boost mode by short pressing rotary encoder switch
// - Setup menu by long pressing rotary encoder switch
// - Handle movement detection (by checking ball switch)
// - Iron unconnected detection (by idenfying invalid temperature readings)
// - Time driven sleep/power off mode if iron is unused (movement detection)
// - Measurement of input voltage, Vcc and ATmega's internal temperature
// - Information display on OLED
// - Buzzer
// - Calibrating and managing different soldering tips
// - Storing user settings into the EEPROM
// - Tip change detection
//
// Power supply should be in the range of 16V/2A to 24V/3A and well
// stabilized.
//
// For calibration you need a soldering iron tips thermometer. For best results
// wait at least three minutes after switching on the soldering station before
// you start the calibration process.
//
// Controller: ATmega328p
// Core: Barebones ATmega (https://github.com/carlosefr/atmega)
// Clockspeed: 16 MHz external
//
// 2019/2020 by Stefan Wagner with great support from John Glavinos
// 2020-8 UI upgrade by LHW-createskyblue
// Project Page: https://easyeda.com/wagiminator
//关于界面-项目页面二维码 ->为了加入欠压报警只能阉割掉关于页面的二维码
//const unsigned char QRCode[] PROGMEM = { 0x00, 0x00, 0x3e, 0x0e, 0x7c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x0e, 0x7c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x0e, 0x7c, 0x0c, 0x00, 0x00, 0x1f, 0xfe, 0x3f, 0xc1, 0x8c, 0x0c, 0x7f, 0xf8, 0x1f, 0xfe, 0x3f, 0xc1, 0x8c, 0x0c, 0x7f, 0xf8, 0x18, 0x06, 0x30, 0x01, 0xf3, 0x8c, 0x60, 0x18, 0x18, 0x06, 0x30, 0x01, 0xf3, 0x8c, 0x60, 0x18, 0x18, 0x06, 0x30, 0x01, 0xf3, 0x8c, 0x60, 0x18, 0x18, 0x06, 0x3e, 0x0f, 0xf0, 0x0c, 0x60, 0x18, 0x18, 0x06, 0x3e, 0x0f, 0xf0, 0x0c, 0x60, 0x18, 0x18, 0x06, 0x3f, 0xc1, 0xf0, 0x0c, 0x60, 0x18, 0x18, 0x06, 0x3f, 0xc1, 0xf0, 0x0c, 0x60, 0x18, 0x18, 0x06, 0x3f, 0xc1, 0xf0, 0x0c, 0x60, 0x18, 0x1f, 0xfe, 0x3e, 0x30, 0x70, 0x0c, 0x7f, 0xf8, 0x1f, 0xfe, 0x3e, 0x30, 0x70, 0x0c, 0x7f, 0xf8, 0x00, 0x00, 0x31, 0xce, 0x73, 0x8c, 0x00, 0x00, 0x00, 0x00, 0x31, 0xce, 0x73, 0x8c, 0x00, 0x00, 0x00, 0x00, 0x31, 0xce, 0x73, 0x8c, 0x00, 0x00, 0xff, 0xff, 0xf0, 0x01, 0x83, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x01, 0x83, 0x8f, 0xff, 0xff, 0x00, 0xc0, 0x01, 0xc1, 0x8c, 0x00, 0x7f, 0x1f, 0x00, 0xc0, 0x01, 0xc1, 0x8c, 0x00, 0x7f, 0x1f, 0x00, 0xc0, 0x01, 0xc1, 0x8c, 0x00, 0x7f, 0x1f, 0x07, 0xc7, 0xcf, 0xce, 0x7f, 0x8c, 0x1f, 0xf8, 0x07, 0xc7, 0xcf, 0xce, 0x7f, 0x8c, 0x1f, 0xf8, 0x07, 0xc7, 0xcf, 0xce, 0x7f, 0x8c, 0x1f, 0xf8, 0xf8, 0x00, 0x3e, 0x3e, 0x03, 0xf0, 0x7f, 0x00, 0xf8, 0x00, 0x3e, 0x3e, 0x03, 0xf0, 0x7f, 0x00, 0xe0, 0xc7, 0xcf, 0xfe, 0x03, 0x80, 0x1f, 0xe7, 0xe0, 0xc7, 0xcf, 0xfe, 0x03, 0x80, 0x1f, 0xe7, 0xe0, 0xc7, 0xcf, 0xfe, 0x03, 0x80, 0x1f, 0xe7, 0x18, 0xc0, 0x31, 0xfe, 0x0c, 0x0c, 0x1c, 0xe0, 0x18, 0xc0, 0x31, 0xfe, 0x0c, 0x0c, 0x1c, 0xe0, 0xe7, 0x39, 0xf1, 0xf0, 0x03, 0xfc, 0x7c, 0xf8, 0xe7, 0x39, 0xf1, 0xf0, 0x03, 0xfc, 0x7c, 0xf8, 0xe7, 0x39, 0xf1, 0xf0, 0x03, 0xfc, 0x7c, 0xf8, 0x1f, 0x00, 0x31, 0xcf, 0xf3, 0x8c, 0x03, 0x00, 0x1f, 0x00, 0x31, 0xcf, 0xf3, 0x8c, 0x03, 0x00, 0xe0, 0x3f, 0xff, 0xc1, 0x83, 0x8f, 0x9c, 0xe7, 0xe0, 0x3f, 0xff, 0xc1, 0x83, 0x8f, 0x9c, 0xe7, 0xe0, 0x3f, 0xff, 0xc1, 0x83, 0x8f, 0x9c, 0xe7, 0x18, 0x00, 0x30, 0x0e, 0x00, 0x00, 0x00, 0xff, 0x18, 0x00, 0x30, 0x0e, 0x00, 0x00, 0x00, 0xff, 0x18, 0x00, 0x30, 0x0e, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xf0, 0x3e, 0x7c, 0x0f, 0xe0, 0x00, 0xff, 0xff, 0xf0, 0x3e, 0x7c, 0x0f, 0xe0, 0x00, 0x00, 0x00, 0x31, 0xce, 0x0c, 0x0c, 0x63, 0xe0, 0x00, 0x00, 0x31, 0xce, 0x0c, 0x0c, 0x63, 0xe0, 0x00, 0x00, 0x31, 0xce, 0x0c, 0x0c, 0x63, 0xe0, 0x1f, 0xfe, 0x30, 0x01, 0x83, 0x8f, 0xe0, 0xff, 0x1f, 0xfe, 0x30, 0x01, 0x83, 0x8f, 0xe0, 0xff, 0x18, 0x06, 0x31, 0xf1, 0x8f, 0x80, 0x03, 0xe7, 0x18, 0x06, 0x31, 0xf1, 0x8f, 0x80, 0x03, 0xe7, 0x18, 0x06, 0x31, 0xf1, 0x8f, 0x80, 0x03, 0xe7, 0x18, 0x06, 0x3f, 0xff, 0x83, 0x83, 0xe3, 0x1f, 0x18, 0x06, 0x3f, 0xff, 0x83, 0x83, 0xe3, 0x1f, 0x18, 0x06, 0x31, 0xfe, 0x73, 0x8f, 0x80, 0xf8, 0x18, 0x06, 0x31, 0xfe, 0x73, 0x8f, 0x80, 0xf8, 0x18, 0x06, 0x31, 0xfe, 0x73, 0x8f, 0x80, 0xf8, 0x1f, 0xfe, 0x31, 0xfe, 0x00, 0x0c, 0x60, 0xe7, 0x1f, 0xfe, 0x31, 0xfe, 0x00, 0x0c, 0x60, 0xe7, 0x00, 0x00, 0x31, 0xfe, 0x0c, 0x0f, 0x9f, 0xe0, 0x00, 0x00, 0x31, 0xfe, 0x0c, 0x0f, 0x9f, 0xe0, 0x00, 0x00, 0x31, 0xfe, 0x0c, 0x0f, 0x9f, 0xe0 };
//const unsigned char QRCode[] PROGMEM = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x03, 0x86, 0x70, 0x80, 0x03, 0x80, 0x03, 0x86, 0x70, 0x80, 0x03, 0x9f, 0xf3, 0xe1, 0x30, 0x9f, 0xf3, 0x9f, 0xf3, 0xe1, 0x30, 0x9f, 0xf3, 0x98, 0x33, 0x01, 0xcc, 0x98, 0x33, 0x98, 0x33, 0x01, 0xcc, 0x98, 0x33, 0x98, 0x33, 0x87, 0xc0, 0x98, 0x33, 0x98, 0x33, 0xe1, 0xc0, 0x98, 0x33, 0x98, 0x33, 0xe1, 0xc0, 0x98, 0x33, 0x9f, 0xf3, 0x98, 0xc0, 0x9f, 0xf3, 0x9f, 0xf3, 0x98, 0xc0, 0x9f, 0xf3, 0x80, 0x03, 0x66, 0xcc, 0x80, 0x03, 0x80, 0x03, 0x66, 0xcc, 0x80, 0x03, 0xff, 0xff, 0x01, 0x0c, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x1f, 0xff, 0x81, 0x00, 0x61, 0x30, 0x1f, 0x3f, 0x87, 0x3c, 0xe6, 0xfc, 0x87, 0x33, 0x87, 0x3c, 0xe6, 0xfc, 0x87, 0xf3, 0xf8, 0x03, 0x9e, 0x0f, 0x1f, 0x03, 0xf8, 0x03, 0x9e, 0x0f, 0x1f, 0x03, 0xe1, 0x3c, 0xfe, 0x0c, 0x07, 0xcf, 0xe1, 0x3c, 0xfe, 0x0c, 0x07, 0xcf, 0x99, 0x03, 0x3e, 0x30, 0x86, 0xc3, 0xe6, 0xcf, 0x38, 0x0f, 0x9e, 0xf3, 0xe6, 0xcf, 0x38, 0x0f, 0x9e, 0xf3, 0x9e, 0x03, 0x27, 0xcc, 0x81, 0x03, 0x9e, 0x03, 0x27, 0xcc, 0x81, 0x03, 0xe0, 0xff, 0xe1, 0x0c, 0xe6, 0xcf, 0xe0, 0xff, 0xe1, 0x0c, 0xe6, 0xcf, 0x98, 0x03, 0x06, 0x00, 0x00, 0xff, 0x98, 0x03, 0x06, 0x00, 0x00, 0xff, 0xff, 0xff, 0x1e, 0xf0, 0xf8, 0x03, 0x80, 0x03, 0x66, 0x30, 0x99, 0xc3, 0x80, 0x03, 0x66, 0x30, 0x99, 0xc3, 0x9f, 0xf3, 0x01, 0x0c, 0xf8, 0xff, 0x9f, 0xf3, 0x01, 0x0c, 0xf8, 0xff, 0x98, 0x33, 0x39, 0x3c, 0x01, 0xcf, 0x98, 0x33, 0x39, 0x3c, 0x01, 0xcf, 0x98, 0x33, 0xff, 0x0c, 0x79, 0x3f, 0x98, 0x33, 0x3e, 0xcc, 0xe0, 0xf3, 0x98, 0x33, 0x3e, 0xcc, 0xe0, 0xf3, 0x9f, 0xf3, 0x3e, 0x00, 0x98, 0xcf, 0x9f, 0xf3, 0x3e, 0x00, 0x98, 0xcf, 0x80, 0x03, 0x3e, 0x30, 0xe7, 0xc3, 0x80, 0x03, 0x3e, 0x30, 0xe7, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
//ICO
//width:16,height:16
const unsigned char Tag[] PROGMEM = { 0x00, 0x00, 0x3b, 0xec, 0x7b, 0xee, 0x63, 0xe6, 0x63, 0xe6, 0x63, 0xe6, 0x63, 0xe6, 0x63, 0xe6, 0x63, 0xe6, 0x63, 0x66, 0x62, 0x26, 0x60, 0x06, 0x60, 0x06, 0x7f, 0xfe, 0x3f, 0xfc, 0x00, 0x00 };
const unsigned char Chip[] PROGMEM = { 0x14, 0xa0, 0x3f, 0xf0, 0x7f, 0xf8, 0xe0, 0x1c, 0x6e, 0x18, 0xec, 0x1c, 0x68, 0x18, 0x60, 0x18, 0xe0, 0x1c, 0x60, 0x58, 0xe0, 0x1c, 0x7f, 0xf8, 0x3f, 0xf0, 0x14, 0xa0 };
//const unsigned char HeatPipe[] PROGMEM = { 0x00, 0x00, 0x09, 0x90, 0x11, 0x88, 0x21, 0x84, 0x11, 0x88, 0x09, 0x90, 0x11, 0x88, 0x21, 0x84, 0x11, 0x88, 0x09, 0x90, 0x11, 0x88, 0x21, 0x84, 0x11, 0x88, 0x09, 0x90, 0x01, 0x80, 0x00, 0x00 };
const unsigned char Lightning[] PROGMEM = { 0x0f, 0xe0, 0x1f, 0xc0, 0x1f, 0xc0, 0x3f, 0x80, 0x3f, 0xf8, 0x7f, 0xf0, 0x7f, 0xe0, 0x07, 0xc0, 0x07, 0x80, 0x0f, 0x00, 0x0e, 0x00, 0x1c, 0x00, 0x18, 0x00, 0x10, 0x00 };
//const unsigned char Thermometer[] PROGMEM = { 0x01, 0x80, 0x02, 0x40, 0x03, 0x40, 0x02, 0x40, 0x03, 0x40, 0x02, 0x40, 0x03, 0x40, 0x02, 0x40, 0x03, 0x40, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x07, 0xe0, 0x07, 0xe0, 0x07, 0xe0, 0x03, 0xc0 };
const unsigned char Pointer[] PROGMEM = { 0x20, 0x20, 0x70, 0xf8 };
//状态提示
//width:14,height:14 图标库
const unsigned char c1[] PROGMEM = { 0x03, 0x00, 0x07, 0x80, 0x0f, 0xc0, 0x0c, 0xc0, 0x1c, 0xe0, 0x1c, 0xe0, 0x3c, 0xf0, 0x3c, 0xf0, 0x7f, 0xf8, 0x7f, 0xf8, 0xfc, 0xfc, 0xfc, 0xfc, 0xff, 0xfc, 0x7f, 0xf8 };
const unsigned char c2[] PROGMEM = { 0x7f, 0xf8, 0xff, 0xfc, 0xc0, 0x0c, 0xc3, 0x0c, 0xcb, 0x4c, 0xdb, 0x6c, 0xdb, 0x6c, 0xd8, 0x6c, 0xdc, 0xec, 0xcf, 0xcc, 0xc7, 0x8c, 0xc0, 0x0c, 0xff, 0xfc, 0x7f, 0xf8 };
const unsigned char c3[] PROGMEM = { 0x00, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x18, 0xf8, 0x38, 0xf0, 0x30, 0x30, 0x70, 0x60, 0x70, 0x78, 0x78, 0xf8, 0x78, 0x00, 0x3c, 0x02, 0x3f, 0x0c, 0x1f, 0xf8, 0x0f, 0xf0, 0x03, 0xc0, 0x00, 0x00 };
const unsigned char c5[] PROGMEM = { 0x7f, 0xf0, 0xff, 0xe0, 0xc0, 0x08, 0xc0, 0x1c, 0xc0, 0x38, 0xc8, 0x70, 0xdc, 0xe4, 0xcf, 0xcc, 0xc7, 0x8c, 0xc3, 0x0c, 0xc0, 0x0c, 0xc0, 0x0c, 0xff, 0xfc, 0x7f, 0xf8 };
const unsigned char c6[] PROGMEM = { 0x1e, 0x10, 0x33, 0x38, 0x2d, 0x7c, 0x25, 0x38, 0x2d, 0x38, 0x25, 0x38, 0x2d, 0x38, 0x6d, 0x80, 0xde, 0xc0, 0xbf, 0x40, 0xbf, 0x40, 0xde, 0xc0, 0x61, 0x80, 0x3f, 0x00 };
const unsigned char c7[] PROGMEM = { 0x1f, 0xe0, 0x3f, 0xf0, 0x70, 0x38, 0x60, 0x18, 0x60, 0x18, 0x60, 0x18, 0xff, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xf8, 0x7c, 0xf8, 0x7c, 0xfc, 0xfc, 0x7f, 0xf8 };
const unsigned char c_NO[] PROGMEM = { 0x80, 0x04, 0x00, 0x00, 0x3f, 0xf0, 0x37, 0xb0, 0x23, 0x10, 0x30, 0x30, 0x38, 0x70, 0x38, 0x70, 0x30, 0x30, 0x23, 0x10, 0x37, 0xb0, 0x3f, 0xf0, 0x00, 0x00, 0x80, 0x04 };
const unsigned char *C_table[] = {c1, c2, c3, Lightning, c5, c6, c7};
//设置(陈星汉认为语言是一种低像素的表达方式,容易造成隔阂; 交互界面设计尽可能形象化)
// width: 48, height: 48
const unsigned char Set0[] PROGMEM = { 0x88,0x24,0x08,0x20,0x38,0x30,0x38,0x30,0x38,0x30,0x38,0x30,0x38,0x30,0x38,0x30,0x39,0x30,0x3b,0xb0,0x3f,0xf0,0x3f,0xf0,0x00,0x00,0x80,0x04 };
const unsigned char Set1[] PROGMEM = { 0xf8,0x7c,0xf3,0x3c,0xf4,0xbc,0xf6,0xbc,0xf4,0xbc,0xf6,0xbc,0xf4,0xbc,0xe4,0x9c,0xc8,0x4c,0xd0,0x2c,0xd0,0x2c,0xc8,0x4c,0xe7,0x9c,0xf0,0x3c };
const unsigned char Set2[] PROGMEM = { 0x8f, 0xc4, 0x10, 0x20, 0x20, 0x10, 0x4c, 0xc8, 0x9f, 0xe4, 0x3d, 0xf0, 0x3d, 0xf0, 0x1d, 0xe0, 0x3e, 0xf0, 0x3f, 0x70, 0x9f, 0xe4, 0x8c, 0xc4, 0x00, 0x00, 0x30, 0x30 };
const unsigned char Set3[] PROGMEM = { 0xc3, 0xfc, 0x18, 0x00, 0x18, 0x00, 0xc3, 0xfc, 0xff, 0xfc, 0xff, 0x0c, 0x00, 0x60, 0x00, 0x60, 0xff, 0x0c, 0xff, 0xfc, 0xf0, 0xfc, 0x06, 0x00, 0x06, 0x00, 0xf0, 0xfc };
const unsigned char Set4[] PROGMEM = { 0x80, 0x04, 0x00, 0x00, 0x20, 0x00, 0x10, 0x00, 0x08, 0x00, 0x10, 0x00, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x04 };
const unsigned char Set4F[] PROGMEM = { 0x80, 0x04, 0x00, 0x00, 0x3f, 0xf0, 0x38, 0x30, 0x33, 0x10, 0x3f, 0x90, 0x38, 0x10, 0x33, 0x90, 0x27, 0x90, 0x26, 0x10, 0x30, 0x90, 0x3f, 0xf0, 0x00, 0x00, 0x80, 0x04 };
const unsigned char Set4FF[] PROGMEM = { 0x80, 0x04, 0x00, 0x00, 0x3f, 0xf0, 0x24, 0x30, 0x21, 0x90, 0x27, 0x90, 0x27, 0x30, 0x20, 0x70, 0x27, 0xf0, 0x23, 0x30, 0x30, 0x70, 0x3f, 0xf0, 0x00, 0x00, 0x80, 0x04 };
const unsigned char Set5[] PROGMEM = { 0xfc, 0xfc, 0xf8, 0x7c, 0xe0, 0x1c, 0xc0, 0x0c, 0xc0, 0x0c, 0xc0, 0x0c, 0xc0, 0x0c, 0xc0, 0x0c, 0xc0, 0x0c, 0x80, 0x04, 0x80, 0x04, 0xff, 0xfc, 0xf8, 0x7c, 0xfc, 0xfc };
const unsigned char Set5_1[] PROGMEM = { 0xfc, 0xf4, 0xf8, 0x60, 0xe0, 0x44, 0xc0, 0x8c, 0xc1, 0x1c, 0xc2, 0x2c, 0xc4, 0x4c, 0xc8, 0x8c, 0xd1, 0x0c, 0xa2, 0x04, 0xc4, 0x04, 0x8f, 0xfc, 0x18, 0x7c, 0xbc, 0xfc };
const unsigned char Set6[] PROGMEM = { 0xf8, 0x7c, 0xe0, 0x1c, 0xc0, 0x0c, 0xcf, 0xcc, 0xcf, 0xcc, 0xcf, 0xcc, 0xcf, 0xcc, 0xcf, 0xcc, 0xcf, 0xcc, 0xcf, 0xcc, 0xc8, 0x4c, 0xcf, 0xcc, 0xc0, 0x0c, 0xe0, 0x1c };
const unsigned char Set_LANG[] PROGMEM = { 0xf0, 0x3c, 0xce, 0x4c, 0xbc, 0x34, 0xb8, 0x14, 0x18, 0x80, 0x10, 0x80, 0x42, 0x30, 0x60, 0x78, 0x60, 0xf8, 0x44, 0xc0, 0x80, 0x04, 0xb8, 0x84, 0xcf, 0xcc, 0xf0, 0x3c };
const unsigned char Set7[] PROGMEM = { 0x80, 0x0c, 0x00, 0x1c, 0x3f, 0xf4, 0x3f, 0xe0, 0x3f, 0xc4, 0x37, 0x8c, 0x23, 0x18, 0x30, 0x30, 0x38, 0x70, 0x3c, 0xf0, 0x3f, 0xf0, 0x3f, 0xf0, 0x00, 0x00, 0x80, 0x04 };
const unsigned char Set11[] PROGMEM = { 0xf3, 0xfc, 0xe7, 0xfc, 0xce, 0x0c, 0x8e, 0x1c, 0x9f, 0x9c, 0x1f, 0x3c, 0x1f, 0x0c, 0x0e, 0x0c, 0x0f, 0xfc, 0x87, 0xf8, 0x81, 0xe4, 0xc0, 0x0c, 0xe0, 0x1c, 0xf8, 0x7c };
const unsigned char Set8[] PROGMEM = { 0x81, 0xdc, 0x55, 0x9c, 0x29, 0x04, 0x55, 0x00, 0x29, 0x90, 0x55, 0xd0, 0x03, 0xfc, 0xff, 0x00, 0x2e, 0x00, 0x26, 0x70, 0x02, 0x50, 0x82, 0x70, 0xe6, 0x00, 0xee, 0x04 };
const unsigned char Set9[] PROGMEM = { 0xf0, 0x3c, 0xce, 0x0c, 0xbf, 0x04, 0xb3, 0x04, 0x73, 0x00, 0x7f, 0x00, 0x7e, 0x00, 0x7c, 0x00, 0x7c, 0x00, 0x7c, 0x60, 0xbc, 0x64, 0xbe, 0x04, 0xcf, 0x0c, 0xf0, 0x3c };
const unsigned char Set10[] PROGMEM = { 0xf8, 0x7c, 0xf7, 0xbc, 0x00, 0x00, 0x7f, 0xf8, 0x00, 0x00, 0xbf, 0xf4, 0xab, 0x54, 0xab, 0x54, 0xab, 0x54, 0xab, 0x54, 0xab, 0x54, 0xab, 0x54, 0xbf, 0xf4, 0xc0, 0x0c };
const unsigned char Set13[] PROGMEM = { 0x80, 0x04, 0x00, 0x00, 0x3f, 0xf0, 0x3c, 0xf0, 0x34, 0xb0, 0x24, 0x90, 0x24, 0x90, 0x27, 0x90, 0x23, 0x10, 0x30, 0x30, 0x38, 0x70, 0x3f, 0xf0, 0x00, 0x00, 0x80, 0x04 };
const unsigned char Set12[] PROGMEM = { 0x80, 0x04, 0x00, 0x00, 0x3f, 0xf0, 0x3c, 0xf0, 0x3c, 0xf0, 0x3c, 0xf0, 0x20, 0x10, 0x20, 0x10, 0x3c, 0xf0, 0x3c, 0xf0, 0x3c, 0xf0, 0x3f, 0xf0, 0x00, 0x00, 0x80, 0x04 };
const unsigned char Set14[] PROGMEM = { 0xff, 0x7c, 0xfe, 0x7c, 0xfc, 0xec, 0xe8, 0xdc, 0xc8, 0x4c, 0x98, 0x4c, 0x88, 0x24, 0x08, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x04, 0xe0, 0x1c };
const unsigned char Set15[] PROGMEM = { 0x15, 0x54, 0x3f, 0xfc, 0x15, 0x54, 0x3f, 0xfc, 0x15, 0x54, 0x3c, 0x04, 0x14, 0x04, 0x3c, 0xfc, 0x14, 0x54, 0x3c, 0xfc, 0x00, 0x54, 0x00, 0xa8, 0x00, 0x00, 0x00, 0x00 };
const unsigned char Set16[] PROGMEM = { 0x15, 0x54, 0x3f, 0xf8, 0x15, 0x50, 0x3f, 0xf0, 0x15, 0x50, 0x38, 0x70, 0x10, 0x20, 0x31, 0x04, 0x13, 0x8c, 0x22, 0xa8, 0x17, 0xfc, 0x2a, 0xa8, 0x00, 0x00, 0x00, 0x00 };
const unsigned char Set17[] PROGMEM = { 0x80, 0x00, 0xbf, 0xf8, 0x1f, 0xf8, 0xb0, 0x08, 0x18, 0x08, 0xb9, 0xe8, 0x19, 0xb8, 0xb8, 0x38, 0x18, 0x38, 0xb9, 0xb8, 0xb9, 0xf8, 0xb0, 0xf8, 0xbf, 0xf8, 0x80, 0x00 };
const unsigned char Set18[] PROGMEM = { 0x80, 0x00, 0xbf, 0xf8, 0x1f, 0xf8, 0xb0, 0x28, 0x1f, 0xf8, 0xb4, 0x08, 0x1f, 0xf8, 0xb1, 0x08, 0x1f, 0xf8, 0xb0, 0x48, 0xbf, 0xf8, 0xb2, 0x88, 0xbf, 0xf8, 0x80, 0x00 };
const unsigned char Lang_CN[] PROGMEM = { 0x80, 0x04, 0x00, 0x00, 0x3f, 0xf0, 0x3c, 0xf0, 0x3c, 0xf0, 0x20, 0x10, 0x24, 0x90, 0x24, 0x90, 0x20, 0x10, 0x3c, 0xf0, 0x3c, 0xf0, 0x3f, 0xf0, 0x00, 0x00, 0x80, 0x04 };
const unsigned char Lang_EN[] PROGMEM = { 0x80, 0x04, 0x00, 0x00, 0x3f, 0xf0, 0x38, 0x70, 0x30, 0x30, 0x23, 0x10, 0x27, 0x90, 0x20, 0x10, 0x20, 0x10, 0x27, 0x90, 0x27, 0x90, 0x3f, 0xf0, 0x00, 0x00, 0x80, 0x04 };
const unsigned char Save[] PROGMEM = { 0x00, 0x04, 0x58, 0x08, 0x58, 0x08, 0x58, 0x08, 0x40, 0x08, 0x7f, 0xf8, 0x60, 0x18, 0x5f, 0xe8, 0x5b, 0x68, 0x5f, 0xe8, 0x5b, 0x68, 0x1c, 0xe8, 0x5f, 0xe8, 0x00, 0x00 };
const unsigned char *Ico_table[] = {
Set0, Set1, Set2, Set3, Set4, Set5, Set6, Set_LANG, Set7,
Set8, Set9, Set0, Set10, Set12, Save,
Set0, Set11, Set14, Save,
Set11, Set13, Set14, Save,
Set15, Set16,
Set17, Set18, //5
Set5_1, Set5,
c_NO, Set7,
Lang_CN, Lang_EN, //8
Set4F, Set4FF,
Set4, Set4F, Save,
};
const byte Menu_table[] = {9, 6, 4, 4, 2, 2, 2, 2, 2, 2, 3}; //菜单 标签 温控 定时 控制方式 首页 蜂鸣器 标签删除确认界面 语言菜单 翻转 显示
byte MenuLevel = 0; //菜单层级
/*////////////////////////////////////////////////////////////////////////////////////////////////////
多语言支持
Multilingual support
///////////////////////////////////////////////////////////////////////////////////////////////////
*/
/*
英语库 ENGLISH
*/
const char EN_0[] PROGMEM = "Tip";
const char EN_1[] PROGMEM = "Temp";
const char EN_2[] PROGMEM = "Timer";
const char EN_3[] PROGMEM = "Control";
const char EN_4[] PROGMEM = "Screen";
const char EN_5[] PROGMEM = "Buzzer";
const char EN_6[] PROGMEM = "LOW Vol";
const char EN_7[] PROGMEM = "Lang";
const char EN_8[] PROGMEM = "Return";
const char EN_9[] PROGMEM = "Change";
const char EN_10[] PROGMEM = "Calibrate";
const char EN_11[] PROGMEM = "Rename";
const char EN_12[] PROGMEM = "Delete";
const char EN_13[] PROGMEM = "Add";
const char EN_14[] PROGMEM = "Save";
const char EN_15[] PROGMEM = "Default";
const char EN_16[] PROGMEM = "Sleep";
const char EN_17[] PROGMEM = "Boost";
const char EN_18[] PROGMEM = "Save";
const char EN_19[] PROGMEM = "Sleep";
const char EN_20[] PROGMEM = "Off";
const char EN_21[] PROGMEM = "Boost";
const char EN_22[] PROGMEM = "Save";
const char EN_23[] PROGMEM = "Direct";
const char EN_24[] PROGMEM = "PID";
const char EN_25[] PROGMEM = "Big";
const char EN_26[] PROGMEM = "Infos";
const char EN_27[] PROGMEM = "OFF";
const char EN_28[] PROGMEM = "ON";
const char EN_29[] PROGMEM = "NO";
const char EN_30[] PROGMEM = "YES";
const char EN_31[] PROGMEM = "CN";
const char EN_32[] PROGMEM = "EN";
const char EN_33[] PROGMEM = "NO";
const char EN_34[] PROGMEM = "OK";
const char EN_35[] PROGMEM = "Main Screen";
const char EN_36[] PROGMEM = "Flip";
const char EN_37[] PROGMEM = "Save";
const char *const EN_table[] PROGMEM = {EN_0, EN_1, EN_2, EN_3, EN_4, EN_5, EN_6, EN_7, EN_8, EN_9, EN_10, EN_11, EN_12, EN_13, EN_14, EN_15, EN_16, EN_17, EN_18, EN_19, EN_20, EN_21, EN_22, EN_23, EN_24, EN_25, EN_26, EN_27, EN_28, EN_29, EN_30, EN_31, EN_32, EN_33, EN_34, EN_35, EN_36, EN_37,};
/*
#!/usr/bin/python
# -*- coding: UTF-8 -*-
for num in range(0,38):
print("EN_",end="")
print(num,end='')
print(",",end="")
*/
/*
中文语言库 CHINESE
////////////////////////////////////////////////////////////////////////////////////////////////////////
本地化提示:你可以按照位图的大小,把这里的文字位图替换成你的语言,确保位图分辨率一致即可,我们欢迎你把程序翻译为你当地的语言!
Localization tips: you can according to the size of the bitmap,
replace the text bitmap here with your language,
ensure that the bitmap resolution is consistent,
we welcome you to translate the program into your local language!
////////////////////////////////////////////////////////////////////////////////////////////////////////
*/
//width:28,height:14 主界面中文提示
//Main Screen
//错误-ERROR
const unsigned char S1[] PROGMEM = { 0x20, 0x92, 0x1f, 0xc0, 0x3d, 0xf9, 0x90, 0x40, 0x20, 0x90, 0x90, 0x40, 0x40, 0x90, 0x1f, 0xc0, 0x7b, 0xff, 0x00, 0x00, 0xa0, 0x01, 0x3f, 0xe0, 0x21, 0xf9, 0x02, 0x00, 0xfd, 0x09, 0x02, 0x00, 0x21, 0x09, 0x7f, 0xf0, 0x21, 0xf9, 0x05, 0x00, 0x21, 0x09, 0x45, 0x00, 0x29, 0x09, 0x88, 0x80, 0x31, 0xf9, 0x10, 0x70, 0x21, 0x08, 0x20, 0x20 };
//关机-OFF
const unsigned char S2[] PROGMEM = { 0x10, 0x40, 0x47, 0xc0, 0x17, 0xfc, 0x44, 0x40, 0x20, 0x03, 0xf4, 0x40, 0x23, 0xf8, 0x44, 0x40, 0x62, 0x08, 0xc4, 0x40, 0xa3, 0xf8, 0xe4, 0x40, 0x20, 0x01, 0x54, 0x40, 0x2f, 0xfd, 0x44, 0x40, 0x28, 0x06, 0x44, 0x40, 0x23, 0xf8, 0x44, 0x40, 0x20, 0x40, 0x44, 0x50, 0x20, 0x40, 0x48, 0x50, 0x21, 0x40, 0x50, 0x30, 0x20, 0x80, 0x40, 0x00 };
//休眠-SLEEP
const unsigned char S3[] PROGMEM = { 0x10, 0x83, 0xdf, 0xc0, 0x10, 0x82, 0x50, 0x40, 0x20, 0x82, 0x50, 0x40, 0x2f, 0xff, 0xdf, 0xc0, 0x60, 0x82, 0x52, 0x00, 0x61, 0xc2, 0x52, 0x00, 0xa1, 0xc2, 0x5f, 0xe0, 0x22, 0xa3, 0xd2, 0x00, 0x22, 0xa2, 0x51, 0x00, 0x24, 0x92, 0x51, 0x00, 0x28, 0x8e, 0x50, 0x90, 0x30, 0x8b, 0xd4, 0x50, 0x20, 0x82, 0x58, 0x30, 0x20, 0x80, 0x10, 0x10 };
//提温-BOOST
const unsigned char S4[] PROGMEM = { 0x23, 0xf2, 0x1f, 0xc0, 0x22, 0x11, 0x10, 0x40, 0xfb, 0xf0, 0x90, 0x40, 0x22, 0x12, 0x1f, 0xc0, 0x2a, 0x11, 0x10, 0x40, 0x33, 0xf1, 0x10, 0x40, 0x60, 0x00, 0x5f, 0xc0, 0xaf, 0xfc, 0x80, 0x00, 0x20, 0x41, 0x3f, 0xe0, 0x22, 0x43, 0x25, 0x20, 0x22, 0x79, 0x25, 0x20, 0x22, 0x41, 0x25, 0x20, 0xa5, 0x41, 0x25, 0x20, 0x48, 0xfd, 0x7f, 0xf0 };
//正常工作-WORKY
const unsigned char S5[] PROGMEM = { 0x7f, 0xf8, 0x48, 0x80, 0x02, 0x00, 0x49, 0x00, 0x02, 0x01, 0xff, 0xf0, 0x02, 0x01, 0x00, 0x10, 0x02, 0x02, 0x7f, 0x20, 0x22, 0x00, 0x41, 0x00, 0x23, 0xf0, 0x7f, 0x00, 0x22, 0x00, 0x08, 0x00, 0x22, 0x00, 0xff, 0x80, 0x22, 0x00, 0x88, 0x80, 0x22, 0x00, 0x88, 0x80, 0x22, 0x00, 0x8a, 0x80, 0x22, 0x00, 0x89, 0x00, 0xff, 0xfc, 0x08, 0x00 };
//加热-HEAT
const unsigned char S6[] PROGMEM = { 0x0f, 0x42, 0x1f, 0xc0, 0x78, 0x41, 0x10, 0x40, 0x08, 0x40, 0x90, 0x40, 0x08, 0x42, 0x1f, 0xc0, 0x08, 0x41, 0x10, 0x40, 0xff, 0xfd, 0x10, 0x40, 0x08, 0x40, 0x5f, 0xc0, 0x08, 0x40, 0x80, 0x00, 0x08, 0x41, 0x3f, 0xe0, 0x08, 0x43, 0x25, 0x20, 0x10, 0x41, 0x25, 0x20, 0x10, 0x41, 0x25, 0x20, 0x20, 0x41, 0x25, 0x20, 0x40, 0x41, 0x7f, 0xf0 };
//维持-HOLD
const unsigned char S7[] PROGMEM = { 0x11, 0x40, 0x82, 0x00, 0x21, 0x20, 0x8f, 0xe0, 0x23, 0xfc, 0x82, 0x00, 0x4a, 0x23, 0xe2, 0x00, 0xfe, 0x20, 0x9f, 0xf0, 0x13, 0xf8, 0x80, 0x80, 0x22, 0x20, 0xc0, 0x80, 0x42, 0x21, 0xbf, 0xf0, 0xfb, 0xfa, 0x88, 0x80, 0x02, 0x20, 0x84, 0x80, 0x02, 0x20, 0x84, 0x80, 0x1a, 0x20, 0x80, 0x80, 0xe3, 0xfe, 0x82, 0x80, 0x02, 0x01, 0x01, 0x00 };
const unsigned char *S_table[] = {S1, S2, S3, S4, S5, S6, S7};
// 菜单 width:36,height:16
//MENU Oj
/*
The order here(↓) can refer to EN_table(↑↑↑)
*/
const unsigned char t0[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x7f, 0x90, 0xf8, 0x00, 0x01, 0x08, 0x08, 0x88, 0x00, 0x0a, 0x10, 0x08, 0x88, 0x00, 0x04, 0x7f, 0x01, 0x07, 0x00, 0x1f, 0xc1, 0x3a, 0x00, 0x00, 0x05, 0x49, 0x09, 0xfc, 0x00, 0x04, 0x49, 0x08, 0x84, 0x00, 0x04, 0x49, 0x08, 0x88, 0x00, 0x04, 0x49, 0x08, 0x48, 0x00, 0x04, 0x49, 0x08, 0x50, 0x00, 0x04, 0x49, 0x0a, 0x20, 0x00, 0x04, 0x16, 0x0c, 0x58, 0x00, 0x14, 0x21, 0x89, 0x87, 0x00, 0x08, 0xc0, 0x86, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
const unsigned char t1[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xfe, 0x08, 0x20, 0x00, 0x08, 0x82, 0x0b, 0xff, 0x00, 0x04, 0x82, 0x0a, 0x01, 0x00, 0x10, 0xfe, 0x3c, 0x51, 0x00, 0x08, 0x82, 0x08, 0x88, 0x00, 0x08, 0x82, 0x09, 0x04, 0x00, 0x02, 0xfe, 0x0c, 0x00, 0x00, 0x04, 0x00, 0x19, 0xfc, 0x00, 0x09, 0xff, 0x28, 0x20, 0x00, 0x19, 0x29, 0x08, 0x20, 0x00, 0x09, 0x29, 0x08, 0x20, 0x00, 0x09, 0x29, 0x08, 0x20, 0x00, 0x09, 0x29, 0x2b, 0xff, 0x00, 0x0b, 0xff, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
const unsigned char t2[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x20, 0x3e, 0x04, 0x00, 0x1f, 0xff, 0xa2, 0x04, 0x00, 0x10, 0x00, 0xa2, 0xff, 0x00, 0x00, 0x01, 0x22, 0x04, 0x00, 0x0f, 0xfe, 0x22, 0x04, 0x00, 0x00, 0x40, 0x3e, 0x44, 0x00, 0x00, 0x40, 0x22, 0x24, 0x00, 0x04, 0x40, 0x22, 0x24, 0x00, 0x04, 0x7c, 0x22, 0x04, 0x00, 0x04, 0x40, 0x22, 0x04, 0x00, 0x0a, 0x40, 0x3e, 0x04, 0x00, 0x09, 0x40, 0x22, 0x24, 0x00, 0x10, 0xff, 0x80, 0x14, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00 };
const unsigned char t3[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x10, 0x12, 0x02, 0x00, 0x05, 0xff, 0x9f, 0xd2, 0x00, 0x05, 0x00, 0x92, 0x12, 0x00, 0x1e, 0x28, 0xa2, 0x12, 0x00, 0x04, 0x44, 0x3f, 0xf2, 0x00, 0x04, 0x82, 0x02, 0x12, 0x00, 0x06, 0x00, 0x02, 0x12, 0x00, 0x0c, 0xfe, 0x1f, 0xd2, 0x00, 0x14, 0x10, 0x12, 0x52, 0x00, 0x04, 0x10, 0x12, 0x42, 0x00, 0x04, 0x10, 0x13, 0x42, 0x00, 0x04, 0x10, 0x12, 0x82, 0x00, 0x15, 0xff, 0x82, 0x0a, 0x00, 0x08, 0x00, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
const unsigned char t4[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xfe, 0x0f, 0xf8, 0x00, 0x04, 0x02, 0x00, 0x00, 0x00, 0x04, 0x02, 0x00, 0x00, 0x00, 0x07, 0xfe, 0x00, 0x00, 0x00, 0x04, 0x02, 0x3f, 0xfe, 0x00, 0x04, 0x02, 0x00, 0x80, 0x00, 0x07, 0xfe, 0x00, 0x80, 0x00, 0x00, 0x90, 0x04, 0x90, 0x00, 0x08, 0x91, 0x0c, 0x88, 0x00, 0x06, 0x93, 0x10, 0x86, 0x00, 0x02, 0x94, 0x20, 0x82, 0x00, 0x00, 0x90, 0x00, 0x80, 0x00, 0x00, 0x90, 0x02, 0x80, 0x00, 0x1f, 0xff, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
const unsigned char t5[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x80, 0x00, 0x1f, 0xff, 0x9f, 0xfc, 0x00, 0x00, 0x40, 0x04, 0x10, 0x00, 0x0f, 0xff, 0x02, 0x20, 0x00, 0x00, 0x00, 0x3f, 0xff, 0x00, 0x0f, 0xfe, 0x00, 0x00, 0x00, 0x08, 0x42, 0x0f, 0xf8, 0x00, 0x08, 0x42, 0x08, 0x08, 0x00, 0x0f, 0xfe, 0x08, 0x08, 0x00, 0x08, 0x02, 0x0f, 0xf8, 0x00, 0x08, 0x00, 0x08, 0x08, 0x00, 0x08, 0x00, 0x08, 0x08, 0x00, 0x08, 0x00, 0x0f, 0xf8, 0x00, 0x10, 0x00, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
const unsigned char t6[] PROGMEM = { 0x09, 0xff, 0x00, 0x40, 0x00, 0x04, 0x20, 0x3f, 0xff, 0x00, 0x04, 0x20, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x1c, 0x42, 0x0f, 0xfc, 0x00, 0x04, 0x42, 0x00, 0x00, 0x00, 0x07, 0xff, 0x80, 0x00, 0x00, 0x04, 0x00, 0x0f, 0xfc, 0x00, 0x04, 0xff, 0x00, 0x00, 0x00, 0x04, 0x81, 0x00, 0x00, 0x00, 0x05, 0x81, 0x0f, 0xfc, 0x00, 0x06, 0x81, 0x08, 0x04, 0x00, 0x04, 0xff, 0x08, 0x04, 0x00, 0x00, 0x81, 0x0f, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
const unsigned char t7[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0f, 0xfe, 0x00, 0x01, 0x00, 0x08, 0x20, 0x00, 0x03, 0xff, 0x08, 0x20, 0x00, 0x02, 0x01, 0x08, 0x20, 0x00, 0x04, 0x22, 0x08, 0x20, 0x00, 0x08, 0x20, 0x0b, 0xfe, 0x00, 0x10, 0x20, 0x08, 0x20, 0x00, 0x00, 0x50, 0x08, 0x28, 0x00, 0x00, 0x50, 0x08, 0x24, 0x00, 0x00, 0x88, 0x08, 0x22, 0x00, 0x00, 0x88, 0x10, 0x20, 0x00, 0x01, 0x04, 0x10, 0x20, 0x00, 0x02, 0x03, 0xa7, 0xff, 0x00, 0x0c, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
const unsigned char Back[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x07, 0x00, 0x00, 0x00, 0x08, 0xf8, 0x3f, 0xfe, 0x00, 0x04, 0x80, 0x20, 0x02, 0x00, 0x00, 0x80, 0x20, 0x02, 0x00, 0x00, 0xbe, 0x23, 0xe2, 0x00, 0x1c, 0x82, 0x22, 0x22, 0x00, 0x04, 0xa4, 0x22, 0x22, 0x00, 0x04, 0x94, 0x22, 0x22, 0x00, 0x04, 0x88, 0x22, 0x22, 0x00, 0x04, 0x94, 0x23, 0xe2, 0x00, 0x05, 0x22, 0x20, 0x02, 0x00, 0x05, 0x42, 0x20, 0x02, 0x00, 0x0a, 0x00, 0x3f, 0xfe, 0x00, 0x11, 0xff, 0xa0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
const unsigned char t1_1[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x08, 0x20, 0x90, 0x00, 0x02, 0x7f, 0x98, 0x90, 0x00, 0x1f, 0x80, 0x09, 0xff, 0x00, 0x02, 0x22, 0x01, 0x10, 0x00, 0x06, 0x21, 0x8b, 0x10, 0x00, 0x07, 0x62, 0x8d, 0xfe, 0x00, 0x0a, 0xa2, 0x09, 0x10, 0x00, 0x0a, 0x14, 0x11, 0x10, 0x00, 0x12, 0x14, 0x31, 0xfe, 0x00, 0x02, 0x08, 0x11, 0x10, 0x00, 0x02, 0x14, 0x11, 0x10, 0x00, 0x02, 0x22, 0x11, 0x10, 0x00, 0x02, 0x43, 0x91, 0xff, 0x00, 0x02, 0x81, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
const unsigned char t1_2[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x80, 0x00, 0x00, 0x50, 0x01, 0xfc, 0x00, 0x00, 0x88, 0x01, 0x04, 0x00, 0x01, 0x04, 0x03, 0x08, 0x00, 0x06, 0xfb, 0x04, 0x90, 0x00, 0x08, 0x00, 0xc0, 0x60, 0x00, 0x07, 0xdf, 0x01, 0x80, 0x00, 0x04, 0x51, 0x06, 0x00, 0x00, 0x04, 0x51, 0x1b, 0xfe, 0x00, 0x04, 0x51, 0x02, 0x02, 0x00, 0x07, 0xd9, 0x02, 0x02, 0x00, 0x04, 0x56, 0x02, 0x02, 0x00, 0x00, 0x10, 0x03, 0xfe, 0x00, 0x00, 0x10, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
const unsigned char t1_3[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x78, 0xbc, 0x20, 0x00, 0x09, 0x48, 0xa4, 0x50, 0x00, 0x09, 0x4a, 0xa8, 0x50, 0x00, 0x09, 0x4a, 0xa8, 0x88, 0x00, 0x09, 0x4a, 0xb1, 0x04, 0x00, 0x1f, 0xfe, 0xaa, 0xfb, 0x00, 0x09, 0x4a, 0xa4, 0x20, 0x00, 0x09, 0x4a, 0xa4, 0x20, 0x00, 0x09, 0x4a, 0xa7, 0xfe, 0x00, 0x09, 0x4a, 0xb4, 0x20, 0x00, 0x09, 0x48, 0xa9, 0x24, 0x00, 0x0b, 0x48, 0xa2, 0x22, 0x00, 0x08, 0x8a, 0xa4, 0xa2, 0x00, 0x11, 0x19, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
const unsigned char t1_4[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x00, 0x10, 0x00, 0x1f, 0xdc, 0x3e, 0xfe, 0x00, 0x08, 0x90, 0x02, 0x12, 0x00, 0x05, 0x10, 0x04, 0xff, 0x00, 0x1f, 0xdf, 0x84, 0x12, 0x00, 0x02, 0x12, 0x0c, 0xfe, 0x00, 0x1f, 0xd2, 0x02, 0x10, 0x00, 0x02, 0x12, 0x22, 0xfe, 0x00, 0x0a, 0x92, 0x14, 0x10, 0x00, 0x0a, 0x52, 0x14, 0x10, 0x00, 0x12, 0x22, 0x0d, 0xff, 0x00, 0x02, 0x22, 0x08, 0x10, 0x00, 0x0a, 0x42, 0x14, 0x10, 0x00, 0x04, 0x02, 0x23, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
//默认
const unsigned char t2_0[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xc8, 0x10, 0x20, 0x00, 0x12, 0x4a, 0x0c, 0x20, 0x00, 0x1a, 0xc9, 0x04, 0x20, 0x00, 0x17, 0x48, 0x00, 0x20, 0x00, 0x1f, 0xff, 0xb8, 0x20, 0x00, 0x02, 0x08, 0x08, 0x50, 0x00, 0x1f, 0xc8, 0x08, 0x50, 0x00, 0x02, 0x08, 0x08, 0x50, 0x00, 0x03, 0xc8, 0x08, 0x48, 0x00, 0x1e, 0x14, 0x08, 0x88, 0x00, 0x01, 0x54, 0x0a, 0x88, 0x00, 0x15, 0x22, 0x0c, 0x84, 0x00, 0x14, 0x43, 0x89, 0x07, 0x00, 0x00, 0x81, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
//休眠
const unsigned char t2_1[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x10, 0x3d, 0xfc, 0x00, 0x02, 0x10, 0x25, 0x04, 0x00, 0x04, 0x10, 0x25, 0x04, 0x00, 0x05, 0xff, 0xbd, 0xfc, 0x00, 0x0c, 0x10, 0x25, 0x20, 0x00, 0x0c, 0x38, 0x25, 0x20, 0x00, 0x14, 0x38, 0x25, 0xfe, 0x00, 0x04, 0x54, 0x3d, 0x20, 0x00, 0x04, 0x54, 0x25, 0x10, 0x00, 0x04, 0x92, 0x25, 0x10, 0x00, 0x05, 0x11, 0xa5, 0x09, 0x00, 0x06, 0x11, 0x3d, 0x45, 0x00, 0x04, 0x10, 0x25, 0x83, 0x00, 0x04, 0x10, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
//提温
const unsigned char t2_2[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x7e, 0x21, 0xfc, 0x00, 0x04, 0x42, 0x11, 0x04, 0x00, 0x1f, 0x7e, 0x09, 0x04, 0x00, 0x04, 0x42, 0x21, 0xfc, 0x00, 0x05, 0x42, 0x11, 0x04, 0x00, 0x06, 0x7e, 0x11, 0x04, 0x00, 0x0c, 0x00, 0x05, 0xfc, 0x00, 0x15, 0xff, 0x88, 0x00, 0x00, 0x04, 0x08, 0x13, 0xfe, 0x00, 0x04, 0x48, 0x32, 0x52, 0x00, 0x04, 0x4f, 0x12, 0x52, 0x00, 0x04, 0x48, 0x12, 0x52, 0x00, 0x14, 0xa8, 0x12, 0x52, 0x00, 0x09, 0x1f, 0x97, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
//关机
const unsigned char t3_1[] PROGMEM = { 0x01, 0x04, 0x04, 0x7c, 0x00, 0x00, 0x88, 0x04, 0x44, 0x00, 0x0f, 0xff, 0x3f, 0x44, 0x00, 0x00, 0x20, 0x04, 0x44, 0x00, 0x00, 0x20, 0x0c, 0x44, 0x00, 0x00, 0x20, 0x0e, 0x44, 0x00, 0x1f, 0xff, 0x95, 0x44, 0x00, 0x00, 0x20, 0x14, 0x44, 0x00, 0x00, 0x50, 0x24, 0x44, 0x00, 0x00, 0x50, 0x04, 0x44, 0x00, 0x00, 0x88, 0x04, 0x45, 0x00, 0x01, 0x04, 0x04, 0x85, 0x00, 0x06, 0x03, 0x85, 0x03, 0x00, 0x18, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
const unsigned char t_4[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x20, 0x00, 0x0f, 0xff, 0x09, 0xfc, 0x00, 0x00, 0x20, 0x08, 0x00, 0x00, 0x00, 0x20, 0x3e, 0x88, 0x00, 0x03, 0xfe, 0x08, 0x50, 0x00, 0x02, 0x02, 0x0b, 0xfe, 0x00, 0x03, 0xfe, 0x0c, 0x40, 0x00, 0x02, 0x02, 0x18, 0x40, 0x00, 0x03, 0xfe, 0x2b, 0xfe, 0x00, 0x02, 0x02, 0x08, 0x48, 0x00, 0x03, 0xfe, 0x08, 0x88, 0x00, 0x02, 0x02, 0x08, 0x50, 0x00, 0x02, 0x02, 0x28, 0x30, 0x00, 0x1f, 0xff, 0x91, 0xcc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
const unsigned char t_PID[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc3, 0xf1, 0xe0, 0x00, 0x0f, 0xe3, 0xf1, 0xf8, 0x00, 0x0c, 0x70, 0xc1, 0x9e, 0x00, 0x0c, 0x30, 0xc1, 0x86, 0x00, 0x0c, 0x30, 0xc1, 0x83, 0x00, 0x0c, 0x30, 0xc1, 0x83, 0x00, 0x0c, 0x60, 0xc1, 0x83, 0x00, 0x0c, 0x60, 0xc1, 0x83, 0x00, 0x0f, 0xc0, 0xc1, 0x83, 0x00, 0x0f, 0xc0, 0xc1, 0x86, 0x00, 0x0c, 0x00, 0xc1, 0x86, 0x00, 0x0c, 0x00, 0xc1, 0x98, 0x00, 0x0c, 0x03, 0xf1, 0xf8, 0x00, 0x0c, 0x03, 0xf1, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
const unsigned char t5_0[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xdf, 0x88, 0x40, 0x00, 0x0a, 0x24, 0x10, 0x40, 0x00, 0x11, 0x42, 0x10, 0xfe, 0x00, 0x04, 0x00, 0x22, 0x82, 0x00, 0x02, 0xff, 0x3d, 0x02, 0x00, 0x08, 0x01, 0x0a, 0x42, 0x00, 0x09, 0xf9, 0x10, 0x32, 0x00, 0x09, 0x09, 0x20, 0x12, 0x00, 0x09, 0xf9, 0x3e, 0x02, 0x00, 0x09, 0x09, 0x00, 0x02, 0x00, 0x09, 0x09, 0x0e, 0x02, 0x00, 0x09, 0xf9, 0x30, 0x22, 0x00, 0x08, 0x05, 0x00, 0x14, 0x00, 0x08, 0x02, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
const unsigned char t5_1[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x44, 0x10, 0xfe, 0x00, 0x04, 0x28, 0x10, 0x92, 0x00, 0x05, 0xff, 0x22, 0x92, 0x00, 0x00, 0x10, 0x3c, 0x92, 0x00, 0x00, 0x10, 0x08, 0x92, 0x00, 0x1c, 0xfe, 0x10, 0x92, 0x00, 0x04, 0x10, 0x20, 0xfe, 0x00, 0x04, 0x10, 0x3e, 0x92, 0x00, 0x05, 0xff, 0x80, 0x92, 0x00, 0x04, 0x10, 0x00, 0x92, 0x00, 0x05, 0x10, 0x0e, 0x92, 0x00, 0x06, 0x10, 0x30, 0x92, 0x00, 0x04, 0x10, 0x00, 0xfe, 0x00, 0x00, 0x10, 0x00, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
const unsigned char t5_3[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x08, 0x3f, 0xfe, 0x00, 0x1f, 0xff, 0x81, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x07, 0xfe, 0x0f, 0xf8, 0x00, 0x04, 0x02, 0x08, 0x08, 0x00, 0x04, 0x02, 0x08, 0x88, 0x00, 0x07, 0xfe, 0x08, 0x88, 0x00, 0x04, 0x02, 0x08, 0x88, 0x00, 0x04, 0x02, 0x08, 0x88, 0x00, 0x07, 0xfe, 0x08, 0x88, 0x00, 0x04, 0x02, 0x09, 0x48, 0x00, 0x04, 0x02, 0x02, 0x30, 0x00, 0x07, 0xfe, 0x04, 0x0c, 0x00, 0x04, 0x02, 0x18, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
const unsigned char t_off[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x04, 0xff, 0x00, 0x00, 0x44, 0x02, 0x01, 0x00, 0x07, 0xff, 0x90, 0x21, 0x00, 0x00, 0x10, 0x10, 0x21, 0x00, 0x00, 0x10, 0x17, 0xfd, 0x00, 0x00, 0x10, 0x10, 0x21, 0x00, 0x0f, 0xff, 0xd0, 0x61, 0x00, 0x00, 0x10, 0x10, 0xa1, 0x00, 0x00, 0x28, 0x11, 0x21, 0x00, 0x00, 0x28, 0x12, 0x21, 0x00, 0x00, 0x44, 0x14, 0x21, 0x00, 0x00, 0x82, 0x10, 0xa1, 0x00, 0x03, 0x01, 0xd0, 0x45, 0x00, 0x0c, 0x00, 0x90, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
const unsigned char t_on[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0x80, 0x20, 0x00, 0x00, 0x84, 0x07, 0xff, 0x00, 0x00, 0x84, 0x04, 0x01, 0x00, 0x00, 0x84, 0x04, 0x01, 0x00, 0x00, 0x84, 0x04, 0x01, 0x00, 0x0f, 0xff, 0xc7, 0xff, 0x00, 0x00, 0x84, 0x04, 0x00, 0x00, 0x00, 0x84, 0x04, 0x00, 0x00, 0x00, 0x84, 0x05, 0xff, 0x00, 0x00, 0x84, 0x05, 0x01, 0x00, 0x01, 0x04, 0x09, 0x01, 0x00, 0x01, 0x04, 0x09, 0x01, 0x00, 0x02, 0x04, 0x11, 0xff, 0x00, 0x04, 0x04, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
const unsigned char t_NO[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xf0, 0x04, 0x91, 0x00, 0x04, 0x40, 0x02, 0x52, 0x00, 0x04, 0x7f, 0x90, 0x54, 0x00, 0x04, 0x50, 0x88, 0xff, 0x00, 0x07, 0xd0, 0x84, 0x81, 0x00, 0x04, 0x51, 0x00, 0x81, 0x00, 0x04, 0x49, 0x01, 0xff, 0x00, 0x07, 0xca, 0x02, 0x81, 0x00, 0x04, 0x44, 0x04, 0x81, 0x00, 0x04, 0x4a, 0x1c, 0xff, 0x00, 0x07, 0xea, 0x04, 0x81, 0x00, 0x0c, 0x51, 0x04, 0x81, 0x00, 0x00, 0x61, 0xc4, 0x85, 0x00, 0x00, 0x40, 0x80, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
const unsigned char t_OK[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xdf, 0x10, 0x20, 0x00, 0x02, 0x12, 0x0c, 0x20, 0x00, 0x02, 0x24, 0x04, 0x20, 0x00, 0x04, 0x7f, 0x80, 0x20, 0x00, 0x04, 0x24, 0xb8, 0x20, 0x00, 0x0f, 0xa4, 0x88, 0x50, 0x00, 0x14, 0xbf, 0x88, 0x50, 0x00, 0x04, 0xa4, 0x88, 0x50, 0x00, 0x04, 0xa4, 0x88, 0x48, 0x00, 0x04, 0xbf, 0x88, 0x88, 0x00, 0x04, 0xa4, 0x8a, 0x88, 0x00, 0x07, 0xa4, 0x8c, 0x84, 0x00, 0x04, 0x44, 0x89, 0x07, 0x00, 0x00, 0x81, 0x86, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
const unsigned char t_CN_CN[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x80, 0x00, 0x00, 0x40, 0x00, 0x80, 0x00, 0x0f, 0xff, 0x3f, 0xff, 0x00, 0x08, 0x41, 0x04, 0x08, 0x00, 0x08, 0x41, 0x04, 0x08, 0x00, 0x08, 0x41, 0x04, 0x10, 0x00, 0x08, 0x41, 0x02, 0x10, 0x00, 0x0f, 0xff, 0x02, 0x20, 0x00, 0x08, 0x41, 0x01, 0x20, 0x00, 0x00, 0x40, 0x00, 0xc0, 0x00, 0x00, 0x40, 0x01, 0x30, 0x00, 0x00, 0x40, 0x02, 0x08, 0x00, 0x00, 0x40, 0x0c, 0x07, 0x00, 0x00, 0x40, 0x30, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
const unsigned char t_CN_EN[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x80, 0x00, 0x1f, 0xff, 0x80, 0x80, 0x00, 0x01, 0x10, 0x3f, 0xff, 0x00, 0x00, 0x40, 0x04, 0x08, 0x00, 0x07, 0xfc, 0x04, 0x08, 0x00, 0x04, 0x44, 0x04, 0x10, 0x00, 0x04, 0x44, 0x02, 0x10, 0x00, 0x04, 0x44, 0x02, 0x20, 0x00, 0x1f, 0xff, 0x81, 0x20, 0x00, 0x00, 0x40, 0x00, 0xc0, 0x00, 0x00, 0xa0, 0x01, 0x30, 0x00, 0x01, 0x10, 0x02, 0x08, 0x00, 0x06, 0x0c, 0x0c, 0x07, 0x00, 0x18, 0x03, 0xb0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
//翻转
const unsigned char t4f[] PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x1d, 0xc2, 0x08, 0x00, 0x05, 0x44, 0x42, 0x08, 0x00, 0x03, 0x84, 0x5f, 0xbf, 0x00, 0x0f, 0xe4, 0x44, 0x10, 0x00, 0x01, 0x15, 0x45, 0x10, 0x00, 0x05, 0x4c, 0xc9, 0x7f, 0x80, 0x09, 0x24, 0x4f, 0x90, 0x00, 0x07, 0xc4, 0xc1, 0x10, 0x00, 0x05, 0x4d, 0x41, 0x3f, 0x00, 0x05, 0x54, 0x43, 0x81, 0x00, 0x07, 0xc4, 0x4d, 0x02, 0x00, 0x05, 0x44, 0x41, 0x14, 0x00, 0x05, 0x55, 0x41, 0x08, 0x00, 0x07, 0xc8, 0x81, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
//保存
const unsigned char t_save[] PROGMEM = { 0x02, 0xfe, 0x01, 0x00, 0x00, 0x02, 0x82, 0x3f, 0xff, 0x00, 0x04, 0x82, 0x02, 0x00, 0x00, 0x04, 0xfe, 0x02, 0x00, 0x00, 0x0c, 0x10, 0x04, 0xfc, 0x00, 0x14, 0x10, 0x04, 0x08, 0x00, 0x05, 0xff, 0x8c, 0x10, 0x00, 0x04, 0x10, 0x14, 0x10, 0x00, 0x04, 0x38, 0x25, 0xff, 0x00, 0x04, 0x34, 0x04, 0x10, 0x00, 0x04, 0x52, 0x04, 0x10, 0x00, 0x04, 0x91, 0x84, 0x10, 0x00, 0x05, 0x10, 0x04, 0x50, 0x00, 0x04, 0x10, 0x04, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
const unsigned char *CN_table[] = {
t0, t1, t2, t3, t4, t5, t7, t6, Back, //0
t0, t1_1, t1_2, t1_3, t1_4, t_save, //1
t2_0, t2_1, t2_2, t_save, //2
t2_1, t3_1, t2_2, t_save,//3
t_4, t_PID,//4
t5_0, t5_1,//5
t_off, t_on,//6
t_NO, t_OK,//7
t_CN_CN, t_CN_EN,//8
t_NO, t_OK,//9
t5_3, t4f, t_save, //10
};
bool lastbutton;
#include <Arduboy2.h> //注意 这里使用被阉割的图形库,只有绘图功能,并非通用的版本
Arduboy2 arduboy;
#include <EEPROM.h>
#include <PID_v1.h>
#include <avr/sleep.h>
// Firmware version
#define VERSION "v1.7t1"
// Type of rotary encoder
#define ROTARY_TYPE 1 // 0: 2 increments/step; 1: 4 increments/step
// Pins
#define SENSOR_PIN A0 // temperature sense
#define VIN_PIN A1 // input voltage sense
#define BUZZER_PIN 5 // buzzer
#define BUTTON_PIN 6 // rotary encoder switch
#define ROTARY_1_PIN 7 // rotary encoder 1
#define ROTARY_2_PIN 8 // rotary encoder 2
#define CONTROL_PIN 9 // heater MOSFET PWM control
#define SWITCH_PIN 10 // handle vibration switch
// Default temperature control values (recommended soldering temperature: 300-380°C)
#define ChipTempCalVal 330 //芯片内部温度读取校准值 -->可以根据实际情况修改不同机器情况不同通常误差在10°C内
#define TEMP_MIN 50 // min selectable temperature
#define TEMP_MAX 400 // max selectable temperature
#define TEMP_DEFAULT 320 // default start setpoint
#define TEMP_SLEEP 150 // temperature in sleep mode
#define TEMP_BOOST 60 // temperature increase in boost mode
#define TEMP_STEP 10 // rotary encoder temp change steps
// Default tip temperature calibration values
#define TEMP200 216 // temperature at ADC = 200
#define TEMP280 308 // temperature at ADC = 280
#define TEMP360 390 // temperature at ADC = 360
#define TEMPCHP 30 // chip temperature while calibration
#define TIPMAX 8 // max number of tips
#define TIPNAMELENGTH 6 // max length of tip names (including termination)
#define TIPNAME "BC1.5" // default tip name
// Default timer values (0 = disabled)
#define TIME2SLEEP 5 // time to enter sleep mode in minutes
#define TIME2OFF 15 // time to shut off heater in minutes
#define TIMEOFBOOST 40 // time to stay in boost mode in seconds
// Control values
#define TIME2SETTLE 950 // time in microseconds to allow OpAmp output to settle
#define SMOOTHIE 0.05 // OpAmp output smooth factor (1=no smoothing; 0.05 default)
#define PID_ENABLE true // enable PID control
#define BEEP_ENABLE true // enable/disable buzzer
#define MAINSCREEN 1 // type of main screen (0: big numbers; 1: more infos)
// EEPROM identifier
#define EEPROM_IDENT 0x08FF // to identify if EEPROM was written by this program
//Beep
#define SetBeepCoolTime 200
unsigned long BeepCoolTime;
// Define the aggressive and conservative PID tuning parameters
double aggKp = 11, aggKi = 0.5, aggKd = 1;
double consKp = 11, consKi = 3, consKd = 5;
// Default values that can be changed by the user and stored in the EEPROM
uint16_t DefaultTemp = TEMP_DEFAULT;
uint16_t SleepTemp = TEMP_SLEEP;
uint8_t BoostTemp = TEMP_BOOST;
uint8_t time2sleep = TIME2SLEEP;
uint8_t time2off = TIME2OFF;
uint8_t timeOfBoost = TIMEOFBOOST;
uint8_t MainScrType = MAINSCREEN;
bool PIDenable = PID_ENABLE;
bool beepEnable = BEEP_ENABLE;
// Default values for tips
uint16_t CalTemp[TIPMAX][4] = {TEMP200, TEMP280, TEMP360, TEMPCHP};
char TipName[TIPMAX][TIPNAMELENGTH] = {TIPNAME};
uint8_t CurrentTip = 0;
uint8_t NumberOfTips = 1;
// Menu items
/*
这个可以选择进行界面美化
const char *DeleteMessage[] = { "Warning", "You cannot", "delete your", "last tip!" };
const char *MaxTipMessage[] = { "Warning", "You reached", "maximum number", "of tips!" };
*/
// Variables for pin change interrupt
volatile uint8_t a0, b0, c0, d0;
volatile bool ab0;
volatile int count, countMin, countMax, countStep;
volatile bool handleMoved;
// Variables for temperature control
uint16_t SetTemp, ShowTemp, gap, Step;
double Input, Output, Setpoint, RawTemp, CurrentTemp, ChipTemp;
// Variables for voltage readings
uint16_t Vcc, Vin;
// State variables
bool inSleepMode = false;
bool inOffMode = false;
bool inBoostMode = false;
bool inCalibMode = false;
bool isWorky = true;
bool beepIfWorky = true;
bool TipIsPresent = true;
bool FlipState = false;
// Timing variables
uint32_t sleepmillis;
uint32_t boostmillis;
uint32_t buttonmillis;
uint8_t goneMinutes;
uint8_t goneSeconds;
uint8_t SensorCounter = 255;
//串口助手
int x, y, a, b;
//欠压报警
byte UnderVoltage = 0;
// Control variables
uint16_t time2settle = 300;
//模拟数字滚轮 Numerical scrolling effect
String value;
int LastValue[3];
float SlidingAnimationY[3];
// Specify the links and initial PID tuning parameters
PID ctrl(&Input, &Output, &Setpoint, aggKp, aggKi, aggKd, REVERSE);
//LANG 语言支持
/* 0 - 中文 CHINESE
1 - 英文 ENGLISH
*/
byte LANG = 0;
void Flip(bool Fmode) {
arduboy.flipVertical(Fmode);
arduboy.flipHorizontal(Fmode);
}
void setup() {
arduboy.begin();
arduboy.setFrameRate(30);
//Serial.begin(115200);
// set the pin modes
pinMode(SENSOR_PIN, INPUT);
pinMode(VIN_PIN, INPUT);
pinMode(BUZZER_PIN, OUTPUT);
pinMode(CONTROL_PIN, OUTPUT);
pinMode(ROTARY_1_PIN, INPUT_PULLUP);
pinMode(ROTARY_2_PIN, INPUT_PULLUP);
pinMode(BUTTON_PIN, INPUT_PULLUP);
pinMode(SWITCH_PIN, INPUT_PULLUP);
analogWrite(CONTROL_PIN, 255); // this shuts off the heater
digitalWrite(BUZZER_PIN, LOW); // must be LOW when buzzer not in use
// setup ADC
ADCSRA |= bit (ADPS0) | bit (ADPS1) | bit (ADPS2); // set ADC prescaler to 128
ADCSRA |= bit (ADIE); // enable ADC interrupt
interrupts (); // enable global interrupts
// setup pin change interrupt for rotary encoder
PCMSK0 = bit (PCINT0); // Configure pin change interrupt on Pin8
PCICR = bit (PCIE0); // Enable pin change interrupt
PCIFR = bit (PCIF0); // Clear interrupt flag
// get default values from EEPROM
getEEPROM();
//设置屏幕反转状态
Flip(FlipState);
// read supply voltages in mV
Vcc = getVCC(); Vin = getVIN();
// read and set current iron temperature
SetTemp = DefaultTemp;
RawTemp = denoiseAnalog(SENSOR_PIN);
ChipTemp = getChipTemp();
calculateTemp();
// turn on heater if iron temperature is well below setpoint
if ((CurrentTemp + 20) < DefaultTemp) analogWrite(CONTROL_PIN, 0);
// tell the PID to range between 0 and the full window size
ctrl.SetOutputLimits(0, 255);
// start PID
ctrl.SetMode(AUTOMATIC);
// set initial rotary encoder values
a0 = PINB & 1; b0 = PIND >> 7 & 1; ab0 = (a0 == b0);
setRotary(TEMP_MIN, TEMP_MAX, TEMP_STEP, DefaultTemp);
// reset sleep timer
sleepmillis = millis();
// long beep for setup completion
beep(); beep();
}
void loop() {
//HelpMeSerialer();
ROTARYCheck(); // check rotary encoder (temp/boost setting, enter setup menu)
SLEEPCheck(); // check and activate/deactivate sleep modes
SENSORCheck(); // reads temperature and vibration switch of the iron
Thermostat(); // heater control
MainScreen(); // updates the main page on the OLED
//beep(0);
}
// check rotary encoder; set temperature, toggle boost mode, enter setup menu accordingly
void ROTARYCheck() {
// set working temperature according to rotary encoder value
SetTemp = getRotary();
// check rotary encoder switch
uint8_t c = digitalRead(BUTTON_PIN);
if ( !c && c0 ) {
beep();
buttonmillis = millis();
while ( (!digitalRead(BUTTON_PIN)) && ((millis() - buttonmillis) < 500) );
if ((millis() - buttonmillis) >= 500) SetupScreen();
else {
inBoostMode = !inBoostMode;
if (inBoostMode) boostmillis = millis();
handleMoved = true;
}
}
c0 = c;
// check timer when in boost mode
if (inBoostMode && timeOfBoost) {
goneSeconds = (millis() - boostmillis) / 1000;
if (goneSeconds >= timeOfBoost) {
inBoostMode = false; // stop boost mode
beep(); // beep if boost mode is over
beepIfWorky = true; // beep again when working temperature is reached
}
}
}
// check and activate/deactivate sleep modes
void SLEEPCheck() {
if (handleMoved) { // if handle was moved
if (inSleepMode) { // in sleep or off mode?
if ((CurrentTemp + 20) < SetTemp) // if temp is well below setpoint
analogWrite(CONTROL_PIN, 0); // then start the heater right now
beep(); // beep on wake-up
beepIfWorky = true; // beep again when working temperature is reached
}
handleMoved = false; // reset handleMoved flag
inSleepMode = false; // reset sleep flag
inOffMode = false; // reset off flag
sleepmillis = millis(); // reset sleep timer
}
// check time passed since the handle was moved
goneMinutes = (millis() - sleepmillis) / 60000;
if ( (!inSleepMode) && (time2sleep > 0) && (goneMinutes >= time2sleep) ) {
inSleepMode = true;
beep();
}
if ( (!inOffMode) && (time2off > 0) && (goneMinutes >= time2off ) ) {
inOffMode = true;
beep();
}
}
// reads temperature, vibration switch and supply voltages
void SENSORCheck() {
analogWrite(CONTROL_PIN, 255); // shut off heater in order to measure temperature
delayMicroseconds(time2settle); // wait for voltage to settle
uint16_t temp = denoiseAnalog(SENSOR_PIN); // read ADC value for temperature
uint8_t d = digitalRead(SWITCH_PIN); // check handle vibration switch
if (d != d0) {
handleMoved = true; // set flag if handle was moved
d0 = d;
}
if (! SensorCounter--) Vin = getVIN(); // get Vin every now and then
analogWrite(CONTROL_PIN, Output); // turn on again heater
RawTemp += (temp - RawTemp) * SMOOTHIE; // stabilize ADC temperature reading
calculateTemp();
// stabilize displayed temperature when around setpoint
if ((ShowTemp != Setpoint) || (abs(ShowTemp - CurrentTemp) > 5)) ShowTemp = CurrentTemp;
// set state variable if temperature is in working range; beep if working temperature was just reached
gap = abs(SetTemp - CurrentTemp);
if (gap < 5) {
if (!isWorky && beepIfWorky) beep();
isWorky = true;
beepIfWorky = false;
}
else isWorky = false;
// checks if tip is present or currently inserted
if (ShowTemp > 500) TipIsPresent = false; // tip removed ?
if (!TipIsPresent && (ShowTemp < 500)) { // new tip inserted ?
analogWrite(CONTROL_PIN, 255); // shut off heater
beep(); // beep for info
TipIsPresent = true; // tip is present now
ChangeTipScreen(); // show tip selection screen
updateEEPROM(); // update setting in EEPROM
handleMoved = true; // reset all timers
RawTemp = denoiseAnalog(SENSOR_PIN); // restart temp smooth algorithm
c0 = LOW; // switch must be released
setRotary(TEMP_MIN, TEMP_MAX, TEMP_STEP, SetTemp); // reset rotary encoder
}
}
// calculates real temperature value according to ADC reading and calibration values
void calculateTemp() {
if (RawTemp < 200) CurrentTemp = map (RawTemp, 0, 200, 21, CalTemp[CurrentTip][0]);
else if (RawTemp < 280) CurrentTemp = map (RawTemp, 200, 280, CalTemp[CurrentTip][0], CalTemp[CurrentTip][1]);
else CurrentTemp = map (RawTemp, 280, 360, CalTemp[CurrentTip][1], CalTemp[CurrentTip][2]);
}
//调温
void Thermostat() {
// define Setpoint acoording to current working mode
if (inOffMode) Setpoint = 0;
else if (inSleepMode) Setpoint = SleepTemp;
else if (inBoostMode) Setpoint = SetTemp + BoostTemp;
else Setpoint = SetTemp;
// control the heater (PID or direct)
gap = abs(Setpoint - CurrentTemp);
if (PIDenable) {
Input = CurrentTemp;
if (gap < 30) ctrl.SetTunings(consKp, consKi, consKd);
else ctrl.SetTunings(aggKp, aggKi, aggKd);
ctrl.Compute();
} else {
// turn on heater if current temperature is below setpoint
if ((CurrentTemp + 0.5) < Setpoint) Output = 0; else Output = 255;
}
analogWrite(CONTROL_PIN, Output); // set heater PWM
}
// creates a short beep on the buzzer
void beep() {
/*
if (beepEnable) {
if (BeepCoolTime + SetBeepCoolTime < millis()) {
if (state) BeepCoolTime = millis();
analogWrite(BUZZER_PIN, 0);
} else analogWrite(BUZZER_PIN, 127);
} else analogWrite(BUZZER_PIN, 0);
*/
//体谅一下,没内存了,只能用原始的办法驱动无源蜂鸣器,否则我也不想牺牲宝贵响应资源换内存
if (beepEnable) {
for (uint8_t i = 0; i < 255; i++) {
digitalWrite(BUZZER_PIN, HIGH);
delayMicroseconds(125);
digitalWrite(BUZZER_PIN, LOW);
delayMicroseconds(125);
}
}
}
//设置旋转编码器的起始值
// sets start values for rotary encoder
void setRotary(int rmin, int rmax, int rstep, int rvalue) {
countMin = rmin << ROTARY_TYPE;
countMax = rmax << ROTARY_TYPE;
countStep = rstep;
count = rvalue << ROTARY_TYPE;
}
// reads current rotary encoder value
int getRotary() {
return (count >> ROTARY_TYPE);
}
// reads user settings from EEPROM; if EEPROM values are invalid, write defaults
void getEEPROM() {
uint16_t identifier = (EEPROM.read(0) << 8) | EEPROM.read(1);
if (identifier == EEPROM_IDENT) {
DefaultTemp = (EEPROM.read(2) << 8) | EEPROM.read(3);
SleepTemp = (EEPROM.read(4) << 8) | EEPROM.read(5);
BoostTemp = EEPROM.read(6);
time2sleep = EEPROM.read(7);
time2off = EEPROM.read(8);
timeOfBoost = EEPROM.read(9);
MainScrType = EEPROM.read(10);
PIDenable = EEPROM.read(11);
beepEnable = EEPROM.read(12);
CurrentTip = EEPROM.read(13);
NumberOfTips = EEPROM.read(14);
LANG = EEPROM.read(15);
FlipState = EEPROM.read(16);
UnderVoltage = EEPROM.read(17);
uint8_t i, j;
uint16_t counter = 18;
for (i = 0; i < NumberOfTips; i++) {
for (j = 0; j < TIPNAMELENGTH; j++) {
TipName[i][j] = EEPROM.read(counter++);
}
for (j = 0; j < 4; j++) {
CalTemp[i][j] = EEPROM.read(counter++) << 8;
CalTemp[i][j] |= EEPROM.read(counter++);
}
}
}
else {
EEPROM.update(0, EEPROM_IDENT >> 8); EEPROM.update(1, EEPROM_IDENT & 0xFF);
updateEEPROM();
}
}
// writes user settings to EEPROM using updade function to minimize write cycles
void updateEEPROM() {
EEPROM.update( 2, DefaultTemp >> 8);
EEPROM.update( 3, DefaultTemp & 0xFF);
EEPROM.update( 4, SleepTemp >> 8);
EEPROM.update( 5, SleepTemp & 0xFF);
EEPROM.update( 6, BoostTemp);
EEPROM.update( 7, time2sleep);
EEPROM.update( 8, time2off);
EEPROM.update( 9, timeOfBoost);
EEPROM.update(10, MainScrType);
EEPROM.update(11, PIDenable);
EEPROM.update(12, beepEnable);
EEPROM.update(13, CurrentTip);
EEPROM.update(14, NumberOfTips);
EEPROM.update(15, LANG);
EEPROM.update(16, FlipState);
EEPROM.update(17, UnderVoltage);
uint8_t i, j;
uint16_t counter = 18;
for (i = 0; i < NumberOfTips; i++) {
for (j = 0; j < TIPNAMELENGTH; j++) EEPROM.update(counter++, TipName[i][j]);
for (j = 0; j < 4; j++) {
EEPROM.update(counter++, CalTemp[i][j] >> 8);
EEPROM.update(counter++, CalTemp[i][j] & 0xFF);
}
}
}
//此片段用于DEBUG
void HelpMeSerialer() {
//串口助手
if (Serial.available()) {
char TmpChar = Serial.read();
switch (TmpChar) {
case 'x': x = Serial.parseInt();
case 'y': y = Serial.parseInt();
case 'a': a = Serial.parseInt();
case 'b': b = Serial.parseInt();
}
}
/*
Serial.println(String("X ->") + x);
Serial.println(String("Y ->") + y);
Serial.println(String("A ->") + a);
Serial.println(String("B ->") + b);
*/
}
// draws the main screen
void MainScreen() {
if (!(arduboy.nextFrame())) //帧率锁
return;
byte SysState;
if (MainScrType) {
arduboy.clear();
//详细信息页
arduboy.fillRect(0, 0, 128, 64, 1); //白底
arduboy.setTextSize(1);
SetTextColor(0);
//预设名
arduboy.drawSlowXYBitmap(0, 0, Tag, 16, 16, 0);
arduboy.setCursor(19, 4); arduboy.print(TipName[CurrentTip]);
//状态显示
if (ShowTemp > 500) SysState = 0;
else if (inOffMode) SysState = 1;
else if (inSleepMode) SysState = 2;
else if (inBoostMode) SysState = 3;
else if (isWorky) SysState = 4;
else if (Output < 180) SysState = 5;
else SysState = 6;
//显示状态
arduboy.setCursor(53, 1);
arduboy.setTextSize(2);
switch (LANG) {
case 0: arduboy.drawSlowXYBitmap(80, 1, S_table[SysState], 28, 14, 0); break; //中文 Chinese
default: //英文 English
switch (SysState) {
case 1: arduboy.print(F("OFF")); break;
case 2: arduboy.print(F("SLEEP")); break;
case 3: arduboy.print(F("BOOST")); break;
case 4: arduboy.print(F("WORKY")); break;
case 5: arduboy.print(F("HEAT")); break;
case 6: arduboy.print(F("HOLD")); break;
default: arduboy.print(F("ERROR")); break;
} break;
}
arduboy.drawSlowXYBitmap(113, 1, C_table[SysState], 14, 14, 0);
arduboy.setTextSize(1);
//芯片
//R1
if (getChipTemp() > 80 && ((millis() * 4) / 1000) % 2) beep(); else arduboy.drawSlowXYBitmap(2, 18, Chip, 14, 14, 0);
//R2
if ((float)Vin / 100 < UnderVoltage && ((millis() * 4) / 1000) % 2) beep(); else arduboy.drawSlowXYBitmap(2, 34, Lightning, 14, 14, 0);
//R3
arduboy.setCursor(19, 16); arduboy.print(getChipTemp(), 1); arduboy.print((char)248); arduboy.print(F("C")); //芯片温度
arduboy.setCursor(19, 24); arduboy.print((float)getVCC() / 1000, 2); arduboy.print(F("V")); //芯片电压
arduboy.setCursor(19, 32); arduboy.print((float)Vin / 1000, 1); arduboy.print(F("V")); //输入电压
arduboy.setCursor(19, 40); arduboy.print(F(VERSION)); //固件
//显示探头温度
arduboy.setCursor(57, 18);
arduboy.setTextSize(4);
if (ShowTemp > 500) arduboy.print(F("000")); else arduboy.print(ShowTemp);
arduboy.drawRect(55, 16, 72, 32, 0);
DrawStatusBar(0);
arduboy.display();
} else {
arduboy.clear();
if (getChipTemp() > 80 && ((millis() * 4) / 1000) % 2) beep();
if ((float)Vin / 100 < UnderVoltage && ((millis() * 4) / 1000) % 2) beep();
if (ShowTemp > 500) DisplayNum(999); else DisplayNum(ShowTemp);
arduboy.fillRect(0, 48, 128, 3, 0);
DrawStatusBar(1);
arduboy.display();
}
}
void DrawStatusBar(bool color) {
SetTextColor(color);
arduboy.setTextSize(1);
//温度条
//框
arduboy.drawRect(1, 49, 102, 14, color);
//条
if (ShowTemp <= 500) arduboy.fillRect(1, 49, map(ShowTemp, 0, 500, 2, 102), 14, color);
//指示部分
arduboy.fillRect(map(Setpoint, 0, 500, 2, 102) - 2, 50, 3, 13, color);
//先来个白底
arduboy.fillRect(map(Setpoint, 0, 500, 2, 102) - 3, 60, 5, 4, color);
arduboy.drawLine(map(Setpoint, 0, 500, 2, 102) - 1, 60, map(Setpoint, 0, 500, 2, 102) - 1, 49, !color);
//画指示针
arduboy.drawSlowXYBitmap(map(Setpoint, 0, 500, 2, 102) - 3, 59, Pointer, 5, 4, !color);
//功率条
arduboy.drawRect(104, 49, 23, 14, color);
arduboy.fillRect(104, 49, map(Output, 255, 0, 0, 23), 14, color);
SetTextColor(!color);
//////////////进入反色////////////////////////////////
arduboy.setCursor(2, 55); arduboy.print(Setpoint, 0); arduboy.print((char)248); arduboy.print(F("C")); //探头预设温度
arduboy.setCursor(105, 55); arduboy.print(map(Output, 255, 0, 0, 100)); arduboy.print(F("%")); //功率百分比
SetTextColor(color);
}
//设置画笔颜色
void SetTextColor(bool color) {
arduboy.setTextBackground(!color);
arduboy.setTextColor(color);
}
// setup screen
void SetupScreen() {
analogWrite(CONTROL_PIN, 255); // shut off heater
beep();
uint16_t SaveSetTemp = SetTemp;
uint8_t selection = 0;
bool repeat = true;
while (repeat) {
MenuLevel = 0; //默认打开主菜单
selection = MenuScreen(selection);
switch (selection) {
case 0: MenuLevel = 1; TipScreen(); repeat = false; break;
case 1: MenuLevel = 2; TempScreen(); break;
case 2: MenuLevel = 3; TimerScreen(); break;
case 3: MenuLevel = 4; PIDenable = MenuScreen(PIDenable); break;
case 4: MenuLevel = 10; ScreenSet(); break;
case 5: MenuLevel = 6; beepEnable = MenuScreen(beepEnable); break;
case 7: MenuLevel = 8; LANG = MenuScreen(LANG); break;
case 6: UnderVoltageSet(); break;
default: repeat = false; break;
}
}
updateEEPROM();
handleMoved = true;
SetTemp = SaveSetTemp;
setRotary(TEMP_MIN, TEMP_MAX, TEMP_STEP, SetTemp);
}
//显示设置菜单
// tip settings screen
void ScreenSet() {
uint8_t selection = 0;
bool repeat = true;
while (repeat) {
MenuLevel = 10;
selection = MenuScreen(selection);
switch (selection) {
case 0: MenuLevel = 5; MainScrType = MenuScreen(MainScrType); break;
case 1: MenuLevel = 9; FlipState = MenuScreen(FlipState); break;
default: repeat = false; break;
}
Flip(FlipState); //设置屏幕反转状态
}
updateEEPROM();
}
//预设设置菜单
// tip settings screen
void TipScreen() {
uint8_t selection = 0;
bool repeat = true;
while (repeat) {
MenuLevel = 1;
selection = MenuScreen(selection);
switch (selection) {
case 0: ChangeTipScreen(); break;
case 1: CalibrationScreen(); break;
case 2: InputNameScreen(); break;
case 3: DeleteTipScreen(); break;
case 4: AddTipScreen(); break;
default: repeat = false; break;
}
}
}
//温控设置菜单
// temperature settings screen
void TempScreen() {
uint8_t selection = 0;
bool repeat = true;
while (repeat) {
selection = MenuScreen(selection);
switch (selection) {
case 0: setRotary(TEMP_MIN, TEMP_MAX, TEMP_STEP, DefaultTemp);
DefaultTemp = InputScreen(); break;
case 1: setRotary(20, 200, TEMP_STEP, SleepTemp);
SleepTemp = InputScreen(); break;
case 2: setRotary(10, 100, TEMP_STEP, BoostTemp);
BoostTemp = InputScreen(); break;
default: repeat = false; break;
}
}
updateEEPROM();
}
//定时器设置菜单
// timer settings screen
void TimerScreen() {
uint8_t selection = 0;
bool repeat = true;
while (repeat) {
selection = MenuScreen(selection);
switch (selection) {
case 0: setRotary(0, 30, 1, time2sleep);
time2sleep = InputScreen(); break;
case 1: setRotary(0, 60, 5, time2off);
time2off = InputScreen(); break;
case 2: setRotary(0, 180, 10, timeOfBoost);
timeOfBoost = InputScreen(); break;
default: repeat = false; break;
}
}
updateEEPROM();
}
//英语支持
void Print_EN(byte i) {
char buffer[11];
strcpy_P(buffer, (char *)pgm_read_word(&(EN_table[i])));
arduboy.print(buffer);
}
//菜单界面
// menu screen
uint8_t MenuScreen(uint8_t selected) {
int SlidingAnimationX;
uint8_t lastselected = selected;
setRotary(0, Menu_table[MenuLevel] - 1, 1, selected);
lastbutton = (!digitalRead(BUTTON_PIN));
SetTextColor(1);
do {
selected = getRotary();
//非线性滑动动画
SlidingAnimationX += (selected - lastselected) * 56;
if (SlidingAnimationX != 0) SlidingAnimationX += 0.5 * (-SlidingAnimationX);
lastselected = selected;
arduboy.clear();
//绘制图标 如果有指定的话
for (byte i = 0; i < 5; i++) if (selected - 2 + i >= 0 && selected - 2 + i < Menu_table[MenuLevel]) {
DrawUIFrame(-72 + i * 56 + SlidingAnimationX, 0, 1);
drawSlowXYBitmapResize(-72 + i * 56 + SlidingAnimationX + 3, 3, Ico_table[selected - 2 + i + QueryMenuObject()], 14, 14, 3, 1);
}
if (LANG == 0) arduboy.drawSlowXYBitmap(48, 48, CN_table[selected + QueryMenuObject()], 36, 16, 1); else {
arduboy.setCursor(48, 49);
arduboy.setTextSize(1);
Print_EN(selected + QueryMenuObject());
}
arduboy.display();
CheckLastButton();
//beep(0);
} while (digitalRead(BUTTON_PIN) || lastbutton);
beep();
return selected;
}
void DrawUIFrame(int x, int y, bool color) {
arduboy.fillRect(x, y, 48, 48, color);
arduboy.fillRect(x + 3, y + 3, 42, 42, !color); //雕空
DrawPoint(x, y, 0);
DrawPoint(x + 47, y, 0);
DrawPoint(x, y + 47, 0);
DrawPoint(x + 47, y + 47, 0);
}
void DrawPoint(int x, int y, bool color) {
arduboy.drawPixel(x + 1, y, color);
arduboy.drawPixel(x - 1, y, color);
arduboy.drawPixel(x, y + 1, color);
arduboy.drawPixel(x, y - 1, color);
arduboy.drawPixel(x, y, color);
}
//检查按键
void CheckLastButton() {
if (lastbutton && digitalRead(BUTTON_PIN)) {
delay(10);
lastbutton = false;
}
}
//返回对应层数的对象数
byte QueryMenuObject() {
int SUM = 0;
for (int i = 0; i < (MenuLevel); i++) SUM += Menu_table[i];
return SUM;
}
//信息窗
/*
void MessageScreen(const char *Items[], uint8_t numberOfItems) {
lastbutton = (!digitalRead(BUTTON_PIN));
//u8g.setFont(//u8g_font_9x15);
//u8g.setFontPosTop();
for (uint8_t i = 0; i < numberOfItems; i++) //u8g.drawStr( 0, i * 16, Items[i]);
do {
CheckLastButton();
} while (digitalRead(BUTTON_PIN) || lastbutton);
beep();
}
*/
/*
好看是好看,但是浪费内存
int wav(byte wavi, int num) {
return (wavi + byte(millis() / 100)) * (float(float(num - countMin) / float(countMax - countMin)) - 0.5) * 5;
}
*/
//模拟数字滚轮 Numerical scrolling effect
void DisplayNum(int Num) {
arduboy.setTextSize(6);
SetTextColor(0);
//数字滚轮
for (byte i = 0; i < 3; i++) LastValue[i] = byte(value[i]);
value = Num;
for (byte i = 0; i < 3; i++) {
SlidingAnimationY[i] += (byte(value[i]) - LastValue[i]) * 50;
if (SlidingAnimationY[i] != 0) SlidingAnimationY[i] += 0.8 * (-SlidingAnimationY[i]);
arduboy.fillRect(0 + i * 44, 0, 38, 50, 1); //白底
for (int ii = -1; ii < 2; ii++) {
arduboy.setCursor(4 + i * 44, 4 - SlidingAnimationY[i] + ii * 50);
arduboy.print(LastValue[i] + ii - 48);
}
}
//刻度标
arduboy.fillRect(0, 0, 128, 2, 0); //上遮罩层
arduboy.fillRect(0, 51, 128, 13, 0); //下遮罩层
}
//数值输入界面
// input value screen
uint16_t InputScreen() {
lastbutton = (!digitalRead(BUTTON_PIN));
do {
arduboy.clear();
DisplayNum(getRotary());
arduboy.display();
CheckLastButton();
} while (digitalRead(BUTTON_PIN) || lastbutton);
beep();
return value.toInt();
}
//欠压报警设置
// information display screen
void UnderVoltageSet() {
setRotary(0, 250, 1, UnderVoltage);
UnderVoltage = InputScreen();
beep();
}
//更换预设界面
// change tip screen
void ChangeTipScreen() {
uint8_t selected = CurrentTip;
uint8_t lastselected = selected;
int8_t arrow = 0;
if (selected) arrow = 1;
setRotary(0, NumberOfTips - 1, 1, selected);
lastbutton = (!digitalRead(BUTTON_PIN));
do {
//beep(0);
arduboy.clear();
selected = getRotary();
arrow = constrain(arrow + selected - lastselected, 0, 2);
lastselected = selected;
SetTextColor(0);
arduboy.setTextSize(2);
arduboy.setCursor(0, 0); arduboy.print(F("Select Tip"));
SetTextColor(1);
arduboy.setCursor(0, 16 * (arrow + 1)); arduboy.print(F(">"));
for (uint8_t i = 0; i < 3; i++) {
uint8_t drawnumber = selected + i - arrow;
if (drawnumber < NumberOfTips) {
arduboy.setCursor(12, 16 * (i + 1)); arduboy.print(TipName[selected + i - arrow]);
}
}
CheckLastButton();
arduboy.display();
} while (digitalRead(BUTTON_PIN) || lastbutton);
beep();
CurrentTip = selected;
}
//温度校准界面
// temperature calibration screen
void CalibrationScreen() {
uint16_t CalTempNew[4];
for (uint8_t CalStep = 0; CalStep < 3; CalStep++) {
SetTemp = CalTemp[CurrentTip][CalStep];
setRotary(100, 500, 1, SetTemp);
beepIfWorky = true;
lastbutton = (!digitalRead(BUTTON_PIN));
do {
arduboy.clear();
arduboy.setTextSize(2);
SENSORCheck(); // reads temperature and vibration switch of the iron
Thermostat(); // heater control
arduboy.setCursor(0, 0); arduboy.print(F("Step: ")); arduboy.print(CalStep + 1); arduboy.print("/3");
if (isWorky) {
arduboy.setCursor(0, 16); arduboy.print(F("Set measured"));
arduboy.setCursor(0, 32); arduboy.print(F("temp: ")); arduboy.print(getRotary());
} else {
arduboy.setCursor(0, 16); arduboy.print(F("ADC: ")); arduboy.print(uint16_t(RawTemp));
arduboy.setCursor(0, 32); arduboy.print(F("Please wait"));
}
CheckLastButton();
arduboy.display();
} while (digitalRead(BUTTON_PIN) || lastbutton);
CalTempNew[CalStep] = getRotary();
beep(); delay (10);
}
analogWrite(CONTROL_PIN, 255); // shut off heater
delayMicroseconds(time2settle); // wait for voltage to settle
CalTempNew[3] = getChipTemp(); // read chip temperature
if ((CalTempNew[0] + 30 < CalTempNew[1]) && (CalTempNew[1] + 30 < CalTempNew[2])) {
MenuLevel = 7;
if (MenuScreen(0)) {
for (uint8_t i = 0; i < 4; i++) CalTemp[CurrentTip][i] = CalTempNew[i];
}
}
}
//命名界面 文本输入界面
// input tip name screen
void InputNameScreen() {
uint8_t value;
for (uint8_t digit = 0; digit < (TIPNAMELENGTH - 1); digit++) {
lastbutton = (!digitalRead(BUTTON_PIN));
setRotary(31, 96, 1, 65);
do {
value = getRotary();
if (value == 31) {
value = 95;
setRotary(31, 96, 1, 95);
}
if (value == 96) {
value = 32;
setRotary(31, 96, 1, 32);
}
//arduboy.setCursor(0, 0);arduboy.print();
arduboy.clear();
arduboy.setTextSize(2);
arduboy.setCursor(16 * digit, 48); arduboy.print(char(94));
arduboy.setCursor(0, 32);
for (uint8_t i = 0; i < digit; i++) arduboy.print(TipName[CurrentTip][i]);
arduboy.setCursor(16 * digit, 32); arduboy.print(char(value));
CheckLastButton();
arduboy.display();
} while (digitalRead(BUTTON_PIN) || lastbutton);
TipName[CurrentTip][digit] = value;
beep(); delay (10);
}
TipName[CurrentTip][TIPNAMELENGTH - 1] = 0;
return value;
}
// delete tip screen
void DeleteTipScreen() {
MenuLevel = 7;
if (NumberOfTips == 1) {
//MessageScreen(DeleteMessage, sizeof(DeleteMessage));
}
else if (MenuScreen(0)) {
if (CurrentTip == (NumberOfTips - 1)) {
CurrentTip--;
}
else {
for (uint8_t i = CurrentTip; i < (NumberOfTips - 1); i++) {
for (uint8_t j = 0; j < TIPNAMELENGTH; j++) TipName[i][j] = TipName[i + 1][j];
for (uint8_t j = 0; j < 4; j++) CalTemp[i][j] = CalTemp[i + 1][j];
}
}
NumberOfTips--;
}
}
// add new tip screen
void AddTipScreen() {
if (NumberOfTips < TIPMAX) {
CurrentTip = NumberOfTips++; InputNameScreen();
CalTemp[CurrentTip][0] = TEMP200; CalTemp[CurrentTip][1] = TEMP280;
CalTemp[CurrentTip][2] = TEMP360; CalTemp[CurrentTip][3] = TEMPCHP;
} //MessageScreen(MaxTipMessage, sizeof(MaxTipMessage)); 信息窗
}
// average several ADC readings in sleep mode to denoise
uint16_t denoiseAnalog (byte port) {
uint16_t result = 0;
ADCSRA |= bit (ADEN) | bit (ADIF); // enable ADC, turn off any pending interrupt
if (port >= A0) port -= A0; // set port and
ADMUX = (0x0F & port) | bit(REFS0); // reference to AVcc
set_sleep_mode (SLEEP_MODE_ADC); // sleep during sample for noise reduction
for (uint8_t i = 0; i < 32; i++) { // get 32 readings
sleep_mode(); // go to sleep while taking ADC sample
while (bitRead(ADCSRA, ADSC)); // make sure sampling is completed
result += ADC; // add them up
}
bitClear (ADCSRA, ADEN); // disable ADC
return (result >> 5); // devide by 32 and return value
}
//读取芯片温度
// get internal temperature by reading ADC channel 8 against 1.1V reference
double getChipTemp() {
unsigned int wADC;
double t;
ADMUX = (_BV(REFS1) | _BV(REFS0) | _BV(MUX3));
ADCSRA |= _BV(ADEN);
delay(5);
ADCSRA |= _BV(ADSC);
while (bit_is_set(ADCSRA, ADSC));
wADC = ADCW;
t = (wADC - ChipTempCalVal ) / 1.22;
return (t);
}
/*
// get internal temperature by reading ADC channel 8 against 1.1V reference
double getChipTemp() {
uint16_t result = 0;
ADCSRA |= bit (ADEN) | bit (ADIF); // enable ADC, turn off any pending interrupt
ADMUX = bit (REFS1) | bit (REFS0) | bit (MUX3); // set reference and mux
delay(20); // wait for voltages to settle
set_sleep_mode (SLEEP_MODE_ADC); // sleep during sample for noise reduction
for (uint8_t i = 0; i < 32; i++) { // get 32 readings
sleep_mode(); // go to sleep while taking ADC sample
while (bitRead(ADCSRA, ADSC)); // make sure sampling is completed
result += ADC; // add them up
}
bitClear (ADCSRA, ADEN); // disable ADC
result >>= 2; // devide by 4
return ((result - 2594) / 9.76); // calculate internal temperature in degrees C
}
*/
// get input voltage in mV by reading 1.1V reference against AVcc
uint16_t getVCC() {
uint16_t result = 0;
ADCSRA |= bit (ADEN) | bit (ADIF); // enable ADC, turn off any pending interrupt
// set Vcc measurement against 1.1V reference
ADMUX = bit (REFS0) | bit (MUX3) | bit (MUX2) | bit (MUX1);
delay(1); // wait for voltages to settle
set_sleep_mode (SLEEP_MODE_ADC); // sleep during sample for noise reduction
for (uint8_t i = 0; i < 16; i++) { // get 16 readings
sleep_mode(); // go to sleep while taking ADC sample
while (bitRead(ADCSRA, ADSC)); // make sure sampling is completed
result += ADC; // add them up
}
bitClear (ADCSRA, ADEN); // disable ADC
result >>= 4; // devide by 16
return (1125300L / result); // 1125300 = 1.1 * 1023 * 1000
}
// get supply voltage in mV
uint16_t getVIN() {
long result;
result = denoiseAnalog (VIN_PIN); // read supply voltage via voltage divider
return (result * Vcc / 179.474); // 179.474 = 1023 * R13 / (R12 + R13)
}
//ADC中断服务
// ADC interrupt service routine
EMPTY_INTERRUPT (ADC_vect); // nothing to be done here
//旋转编码器触发中断
// Pin change interrupt service routine for rotary encoder
ISR (PCINT0_vect) {
uint8_t a = PINB & 1;
uint8_t b = PIND >> 7 & 1;
if (a != a0) { // A changed
a0 = a;
if (b != b0) { // B changed
b0 = b;
count = constrain(count + ((a == b) ? countStep : -countStep), countMin, countMax);
if (ROTARY_TYPE && ((a == b) != ab0)) {
count = constrain(count + ((a == b) ? countStep : -countStep), countMin, countMax);;
}
ab0 = (a == b);
handleMoved = true;
}
}
}
//显示位图,并允许放大 代码片段改自arduboy2
void drawSlowXYBitmapResize(int x, int y, const uint8_t *bitmap, uint8_t w, uint8_t h, uint8_t size, uint8_t color) {
// no need to draw at all of we're offscreen
if (x + w < 0 || x > WIDTH - 1 || y + h < 0 || y > HEIGHT - 1)
return;
int16_t xi, yi, byteWidth = (w + 7) / 8;
for (yi = 0; yi < h; yi ++) {
for (xi = 0; xi < w; xi ++) {
if (pgm_read_byte(bitmap + yi * byteWidth + xi / 8) & (128 >> (xi & 7))) {
//arduboy.drawPixel(x + xi, y + yi, color);
arduboy.fillRect(x + xi * size, y + yi * size, size, size, color);
}
}
}
}