Creality Ender 3 v2 (#17719)
parent
642112d3eb
commit
f4c258dc23
@ -0,0 +1,7 @@
|
||||
# DWIN for Creality Ender 3 v2
|
||||
|
||||
Marlin's Ender 3 v2 support requires the `DWIN_SET` included with the Ender 3 V2 [example configuration](https://github.com/MarlinFirmware/Configurations/tree/bugfix-2.0.x/config/examples/Creality/Ender-3%20V2).
|
||||
|
||||
## Easy Install
|
||||
|
||||
Copy the `DWIN_SET` folder onto a Micro-SD card and insert the card into the slot on the DWIN screen. Cycle the machine and wait for the screen to go from blue to orange. Turn the machine off and remove the SD card. When you turn on the machine the screen will display a "Creality" loading screen.
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,302 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/********************************************************************************
|
||||
* @file dwin_lcd.c
|
||||
* @author LEO / Creality3D
|
||||
* @date 2019/07/18
|
||||
* @version 2.0.1
|
||||
* @brief 迪文屏控制操作函数
|
||||
********************************************************************************/
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(DWIN_CREALITY_LCD)
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#include "dwin_lcd.h"
|
||||
#include <string.h> // for memset
|
||||
|
||||
// Make sure DWIN_SendBuf is large enough to hold the largest
|
||||
// printed string plus the draw command and tail.
|
||||
uint8_t DWIN_SendBuf[11 + 24] = { 0xAA };
|
||||
uint8_t DWIN_BufTail[4] = { 0xCC, 0x33, 0xC3, 0x3C };
|
||||
uint8_t databuf[26] = { 0 };
|
||||
uint8_t receivedType;
|
||||
|
||||
int recnum = 0;
|
||||
|
||||
inline void DWIN_Byte(size_t &i, const uint16_t bval) {
|
||||
DWIN_SendBuf[++i] = bval;
|
||||
}
|
||||
|
||||
inline void DWIN_Word(size_t &i, const uint16_t wval) {
|
||||
DWIN_SendBuf[++i] = wval >> 8;
|
||||
DWIN_SendBuf[++i] = wval & 0xFF;
|
||||
}
|
||||
|
||||
inline void DWIN_Long(size_t &i, const uint32_t lval) {
|
||||
DWIN_SendBuf[++i] = (lval >> 24) & 0xFF;
|
||||
DWIN_SendBuf[++i] = (lval >> 16) & 0xFF;
|
||||
DWIN_SendBuf[++i] = (lval >> 8) & 0xFF;
|
||||
DWIN_SendBuf[++i] = lval & 0xFF;
|
||||
}
|
||||
|
||||
inline void DWIN_String(size_t &i, char * const string) {
|
||||
const size_t len = strlen(string);
|
||||
memcpy(&DWIN_SendBuf[i+1], string, len);
|
||||
i += len;
|
||||
}
|
||||
|
||||
/*发送当前BUF中的数据以及包尾数据 len:整包数据长度*/
|
||||
inline void DWIN_Send(size_t &i) {
|
||||
++i;
|
||||
LOOP_L_N(n, i) { MYSERIAL1.write(DWIN_SendBuf[n]);
|
||||
delayMicroseconds(1); }
|
||||
LOOP_L_N(n, 4) { MYSERIAL1.write(DWIN_BufTail[n]);
|
||||
delayMicroseconds(1); }
|
||||
}
|
||||
|
||||
/*----------------------------------------------系统变量函数----------------------------------------------*/
|
||||
/*握手 1: 握手成功 2: 握手失败*/
|
||||
bool DWIN_Handshake(void) {
|
||||
size_t i = 0;
|
||||
DWIN_Byte(i, 0x00);
|
||||
DWIN_Send(i);
|
||||
|
||||
while (MYSERIAL1.available() > 0 && recnum < (signed)sizeof(databuf)) {
|
||||
databuf[recnum] = MYSERIAL1.read();
|
||||
// ignore the invalid data
|
||||
if (databuf[0] != FHONE) { // prevent the program from running.
|
||||
if (recnum > 0) {
|
||||
recnum = 0;
|
||||
ZERO(databuf);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
delay(10);
|
||||
recnum++;
|
||||
}
|
||||
|
||||
return ( recnum >= 3
|
||||
&& databuf[0] == FHONE
|
||||
&& databuf[1] == '\0'
|
||||
&& databuf[2] == 'O'
|
||||
&& databuf[3] == 'K' );
|
||||
}
|
||||
|
||||
/*设定背光亮度 luminance:亮度(0x00~0xFF)*/
|
||||
void DWIN_Backlight_SetLuminance(const uint8_t luminance) {
|
||||
size_t i = 0;
|
||||
DWIN_Byte(i, 0x30);
|
||||
DWIN_Byte(i, _MAX(luminance, 0x1F));
|
||||
DWIN_Send(i);
|
||||
}
|
||||
|
||||
/*设定画面显示方向 dir:0,0°; 1,90°; 2,180°; 3,270°*/
|
||||
void DWIN_Frame_SetDir(uint8_t dir) {
|
||||
size_t i = 0;
|
||||
DWIN_Byte(i, 0x34);
|
||||
DWIN_Byte(i, 0x5A);
|
||||
DWIN_Byte(i, 0xA5);
|
||||
DWIN_Byte(i, dir);
|
||||
DWIN_Send(i);
|
||||
}
|
||||
|
||||
/*更新显示*/
|
||||
void DWIN_UpdateLCD(void) {
|
||||
size_t i = 0;
|
||||
DWIN_Byte(i, 0x3D);
|
||||
DWIN_Send(i);
|
||||
}
|
||||
|
||||
/*----------------------------------------------绘图相关函数----------------------------------------------*/
|
||||
/*画面清屏 color:清屏颜色*/
|
||||
void DWIN_Frame_Clear(const uint16_t color) {
|
||||
size_t i = 0;
|
||||
DWIN_Byte(i, 0x01);
|
||||
DWIN_Word(i, color);
|
||||
DWIN_Send(i);
|
||||
}
|
||||
|
||||
/*画面画线 color:线段颜色 xStart:X起始坐标 yStart:Y起始坐标 xEnd:X终止坐标 yEnd:Y终止坐标*/
|
||||
void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
|
||||
size_t i = 0;
|
||||
DWIN_Byte(i, 0x03);
|
||||
DWIN_Word(i, color);
|
||||
DWIN_Word(i, xStart);
|
||||
DWIN_Word(i, yStart);
|
||||
DWIN_Word(i, xEnd);
|
||||
DWIN_Word(i, yEnd);
|
||||
DWIN_Send(i);
|
||||
}
|
||||
|
||||
/*画面画矩形 mode:0,外框;1,填充;2,异或填充 color:颜色 xStart/yStart:矩形左上坐标 xEnd/yEnd:矩形右下坐标*/
|
||||
void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color,
|
||||
uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
|
||||
size_t i = 0;
|
||||
DWIN_Byte(i, 0x05);
|
||||
DWIN_Byte(i, mode);
|
||||
DWIN_Word(i, color);
|
||||
DWIN_Word(i, xStart);
|
||||
DWIN_Word(i, yStart);
|
||||
DWIN_Word(i, xEnd);
|
||||
DWIN_Word(i, yEnd);
|
||||
DWIN_Send(i);
|
||||
}
|
||||
|
||||
/*画面区域移动 mode:0,环移;1,平移 dir:0,向左移动;1,向右移动;2,向上移动;3,向下移动 dis:移动距离
|
||||
color:填充颜色 xStart/yStart:选定区域左上坐标 xEnd/yEnd:选定区域右下坐标*/
|
||||
void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
|
||||
uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
|
||||
size_t i = 0;
|
||||
DWIN_Byte(i, 0x09);
|
||||
DWIN_Byte(i, (mode << 7) | dir);
|
||||
DWIN_Word(i, dis);
|
||||
DWIN_Word(i, color);
|
||||
DWIN_Word(i, xStart);
|
||||
DWIN_Word(i, yStart);
|
||||
DWIN_Word(i, xEnd);
|
||||
DWIN_Word(i, yEnd);
|
||||
DWIN_Send(i);
|
||||
}
|
||||
|
||||
/*----------------------------------------------文本相关函数----------------------------------------------*/
|
||||
/*画面显示字符串 widthAdjust:true,自调整字符宽度;false,不调整字符宽度 bShow:true,显示背景色;false,不显示背景色 size:字号大小
|
||||
color:字符颜色 bColor:背景颜色 x/y:字符串左上坐标 *string:字符串*/
|
||||
void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size,
|
||||
uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, char *string) {
|
||||
size_t i = 0;
|
||||
DWIN_Byte(i, 0x11);
|
||||
DWIN_Byte(i, (widthAdjust? 0x80:0x00) | (bShow? 0x40:0x00) | size);
|
||||
DWIN_Word(i, color);
|
||||
DWIN_Word(i, bColor);
|
||||
DWIN_Word(i, x);
|
||||
DWIN_Word(i, y);
|
||||
DWIN_String(i, string);
|
||||
DWIN_Send(i);
|
||||
}
|
||||
|
||||
/*画面显示正整数 bShow:true,显示背景色;false,不显示背景色 zeroFill:true,补零;false,不补零 zeroMode:1,无效0显示为0; 0,无效0显示为空格 size:字号大小
|
||||
color:字符颜色 bColor:背景颜色 iNum:位数 x/y:变量左上坐标 value:整型变量*/
|
||||
void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
|
||||
uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint16_t value) {
|
||||
size_t i = 0;
|
||||
DWIN_Byte(i, 0x14);
|
||||
DWIN_Byte(i, (bShow? 0x80:0x00) | (zeroFill? 0x20:0x00) | (zeroMode? 0x10:0x00) | size);
|
||||
DWIN_Word(i, color);
|
||||
DWIN_Word(i, bColor);
|
||||
DWIN_Byte(i, iNum);
|
||||
DWIN_Byte(i, 0); // fNum
|
||||
DWIN_Word(i, x);
|
||||
DWIN_Word(i, y);
|
||||
#if 0
|
||||
for (char count = 0; count < 8; count++) {
|
||||
DWIN_Byte(i, value);
|
||||
value >>= 8;
|
||||
if ((value&0xFF) == 0x00) break;
|
||||
}
|
||||
#else
|
||||
// Write a big-endian 64 bit integer
|
||||
const size_t p = i + 1;
|
||||
for (char count = 8; count--;) { // 7..0
|
||||
++i;
|
||||
DWIN_SendBuf[p + count] = value;
|
||||
value >>= 8;
|
||||
}
|
||||
#endif
|
||||
|
||||
DWIN_Send(i);
|
||||
}
|
||||
|
||||
/*画面显示浮点数 bShow:true,显示背景色;false,不显示背景色 zeroFill:true,补零;false,不补零 zeroMode:1,无效0显示为0; 0,无效0显示为空格 size:字号大小
|
||||
color:字符颜色 bColor:背景颜色 iNum:整数位数 fNum:小数位数 x/y:变量左上坐标 value:浮点数变量*/
|
||||
void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
|
||||
uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
|
||||
//uint8_t *fvalue = (uint8_t*)&value;
|
||||
size_t i = 0;
|
||||
DWIN_Byte(i, 0x14);
|
||||
DWIN_Byte(i, (bShow? 0x80:0x00) | (zeroFill? 0x20:0x00) | (zeroMode? 0x10:0x00) | size);
|
||||
DWIN_Word(i, color);
|
||||
DWIN_Word(i, bColor);
|
||||
DWIN_Byte(i, iNum);
|
||||
DWIN_Byte(i, fNum);
|
||||
DWIN_Word(i, x);
|
||||
DWIN_Word(i, y);
|
||||
DWIN_Long(i, value);
|
||||
/*
|
||||
DWIN_Byte(i, fvalue[3]);
|
||||
DWIN_Byte(i, fvalue[2]);
|
||||
DWIN_Byte(i, fvalue[1]);
|
||||
DWIN_Byte(i, fvalue[0]);
|
||||
*/
|
||||
DWIN_Send(i);
|
||||
}
|
||||
|
||||
/*----------------------------------------------图片相关函数----------------------------------------------*/
|
||||
/*jpg图片显示并缓存在#0虚拟显示区 id:图片ID*/
|
||||
void DWIN_JPG_ShowAndCache(const uint8_t id) {
|
||||
size_t i = 0;
|
||||
DWIN_Word(i, 0x2200);
|
||||
DWIN_Byte(i, id);
|
||||
DWIN_Send(i); //AA 23 00 00 00 00 08 00 01 02 03 CC 33 C3 3C
|
||||
}
|
||||
|
||||
/*图标显示 libID:图标库ID picID:图标ID x/y:图标左上坐标*/
|
||||
void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
|
||||
NOMORE(x, DWIN_WIDTH - 1);
|
||||
NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
|
||||
size_t i = 0;
|
||||
DWIN_Byte(i, 0x23);
|
||||
DWIN_Word(i, x);
|
||||
DWIN_Word(i, y);
|
||||
DWIN_Byte(i, 0x80 | libID);
|
||||
DWIN_Byte(i, picID);
|
||||
DWIN_Send(i);
|
||||
}
|
||||
|
||||
/*jpg图片解压到#1虚拟显示区 id:图片ID*/
|
||||
void DWIN_JPG_CacheToN(uint8_t n, uint8_t id) {
|
||||
size_t i = 0;
|
||||
DWIN_Byte(i, 0x25);
|
||||
DWIN_Byte(i, n);
|
||||
DWIN_Byte(i, id);
|
||||
DWIN_Send(i);
|
||||
}
|
||||
|
||||
/*从虚拟显示区复制区域至当前画面 cacheID:虚拟区号 xStart/yStart:虚拟区左上坐标 xEnd/yEnd:虚拟区右下坐标 x/y:当前画面粘贴坐标*/
|
||||
void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart,
|
||||
uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
|
||||
size_t i = 0;
|
||||
DWIN_Byte(i, 0x27);
|
||||
DWIN_Byte(i, 0x80 | cacheID);
|
||||
DWIN_Word(i, xStart);
|
||||
DWIN_Word(i, yStart);
|
||||
DWIN_Word(i, xEnd);
|
||||
DWIN_Word(i, yEnd);
|
||||
DWIN_Word(i, x);
|
||||
DWIN_Word(i, y);
|
||||
DWIN_Send(i);
|
||||
}
|
||||
|
||||
#endif // DWIN_CREALITY_LCD
|
@ -0,0 +1,111 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/********************************************************************************
|
||||
* @file dwin_lcd.h
|
||||
* @author LEO / Creality3D
|
||||
* @date 2019/07/18
|
||||
* @version 2.0.1
|
||||
* @brief 迪文屏控制操作函数
|
||||
********************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define RECEIVED_NO_DATA 0x00
|
||||
#define RECEIVED_SHAKE_HAND_ACK 0x01
|
||||
|
||||
#define FHONE 0xAA
|
||||
|
||||
#define DWIN_SCROLL_UP 2
|
||||
#define DWIN_SCROLL_DOWN 3
|
||||
|
||||
#define DWIN_WIDTH 272
|
||||
#define DWIN_HEIGHT 480
|
||||
|
||||
/*接收数据解析 返回值:true,接收到数据;false,未接收到数据*/
|
||||
bool DWIN_ReceiveAnalyze(void);
|
||||
|
||||
/*发送当前BUF中的数据以及包尾数据 len:整包数据长度*/
|
||||
void DWIN_Send_BufTail(const uint8_t len);
|
||||
|
||||
/*----------------------------------------------系统变量函数----------------------------------------------*/
|
||||
/*握手 1: 握手成功 2: 握手失败*/
|
||||
bool DWIN_Handshake(void);
|
||||
|
||||
/*设定背光亮度 luminance:亮度(0x00~0xFF)*/
|
||||
void DWIN_Backlight_SetLuminance(const uint8_t luminance);
|
||||
|
||||
/*设定画面显示方向 dir:0,0°; 1,90°; 2,180°; 3,270°*/
|
||||
void DWIN_Frame_SetDir(uint8_t dir);
|
||||
|
||||
/*更新显示*/
|
||||
void DWIN_UpdateLCD(void);
|
||||
|
||||
/*----------------------------------------------绘图相关函数----------------------------------------------*/
|
||||
/*画面清屏 color:清屏颜色*/
|
||||
void DWIN_Frame_Clear(const uint16_t color);
|
||||
|
||||
/*画面画线 color:线段颜色 xStart:X起始坐标 yStart:Y起始坐标 xEnd:X终止坐标 yEnd:Y终止坐标*/
|
||||
void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
|
||||
|
||||
/*画面画矩形 mode:0,外框;1,填充;2,异或填充 color:颜色 xStart/yStart:矩形左上坐标 xEnd/yEnd:矩形右下坐标*/
|
||||
void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color,
|
||||
uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
|
||||
|
||||
/*画面区域移动 mode:0,环移;1,平移 dir:0,向左移动;1,向右移动;2,向上移动;3,向下移动 dis:移动距离
|
||||
color:填充颜色 xStart/yStart:选定区域左上坐标 xEnd/yEnd:选定区域右下坐标*/
|
||||
void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
|
||||
uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
|
||||
|
||||
/*----------------------------------------------文本相关函数----------------------------------------------*/
|
||||
/*画面显示字符串 widthAdjust:true,自调整字符宽度;false,不调整字符宽度 bShow:true,显示背景色;false,不显示背景色 size:字号大小
|
||||
color:字符颜色 bColor:背景颜色 x/y:字符串左上坐标 *string:字符串*/
|
||||
void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size,
|
||||
uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, char *string);
|
||||
|
||||
/*画面显示正整数 bShow:true,显示背景色;false,不显示背景色 zeroFill:true,补零;false,不补零 zeroMode:1,无效0显示为0; 0,无效0显示为空格 size:字号大小
|
||||
color:字符颜色 bColor:背景颜色 iNum:位数 x/y:变量左上坐标 value:整型变量*/
|
||||
void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
|
||||
uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint16_t value);
|
||||
|
||||
/*画面显示浮点数 bShow:true,显示背景色;false,不显示背景色 zeroFill:true,补零;false,不补零 zeroMode:1,无效0显示为0; 0,无效0显示为空格 size:字号大小
|
||||
color:字符颜色 bColor:背景颜色 iNum:整数位数 fNum:小数位数 x/y:变量左上坐标 value:浮点数变量*/
|
||||
void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
|
||||
uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value);
|
||||
|
||||
/*----------------------------------------------图片相关函数----------------------------------------------*/
|
||||
/*jpg图片显示并缓存在#0虚拟显示区 id:图片ID*/
|
||||
void DWIN_JPG_ShowAndCache(const uint8_t id);
|
||||
|
||||
/*图标显示 libID:图标库ID picID:图标ID x/y:图标左上坐标*/
|
||||
void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y);
|
||||
|
||||
/*jpg图片解压到#1虚拟显示区 id:图片ID*/
|
||||
void DWIN_JPG_CacheToN(uint8_t n, uint8_t id);
|
||||
|
||||
/*jpg图片解压到#1虚拟显示区 id:图片ID*/
|
||||
inline void DWIN_JPG_CacheTo1(uint8_t id) { DWIN_JPG_CacheToN(1, id); }
|
||||
|
||||
/*从虚拟显示区复制区域至当前画面 cacheID:虚拟区号 xStart/yStart:虚拟区左上坐标 xEnd/yEnd:虚拟区右下坐标 x/y:当前画面粘贴坐标*/
|
||||
void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart,
|
||||
uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
|
@ -0,0 +1,86 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/********************************************************************************
|
||||
* @file eeprom_BL24CXX.h
|
||||
* @brief i2c EEPROM for Ender 3 v2 board (4.2.2)
|
||||
********************************************************************************/
|
||||
|
||||
#include <libmaple/gpio.h>
|
||||
|
||||
/******************** IIC ********************/
|
||||
|
||||
//IO方向设置
|
||||
#define SDA_IN() do{ PIN_MAP[IIC_EEPROM_SDA].gpio_device->regs->CRH &= 0XFFFF0FFF; PIN_MAP[IIC_EEPROM_SDA].gpio_device->regs->CRH |= 8 << 12; }while(0)
|
||||
#define SDA_OUT() do{ PIN_MAP[IIC_EEPROM_SDA].gpio_device->regs->CRH &= 0XFFFF0FFF; PIN_MAP[IIC_EEPROM_SDA].gpio_device->regs->CRH |= 3 << 12; }while(0)
|
||||
|
||||
//IO操作函数
|
||||
#define IIC_SCL_0() WRITE(IIC_EEPROM_SCL, LOW)
|
||||
#define IIC_SCL_1() WRITE(IIC_EEPROM_SCL, HIGH)
|
||||
#define IIC_SDA_0() WRITE(IIC_EEPROM_SDA, LOW)
|
||||
#define IIC_SDA_1() WRITE(IIC_EEPROM_SDA, HIGH)
|
||||
#define READ_SDA() READ(IIC_EEPROM_SDA)
|
||||
|
||||
class BL24CXX;
|
||||
|
||||
// IIC所有操作函数
|
||||
class IIC {
|
||||
friend class BL24CXX;
|
||||
protected:
|
||||
static void init(); // 初始化IIC的IO口
|
||||
static void start(); // 发送IIC开始信号
|
||||
static void stop(); // 发送IIC停止信号
|
||||
static void send_byte(uint8_t txd); // IIC发送一个字节
|
||||
static uint8_t read_byte(unsigned char ack); // IIC读取一个字节
|
||||
static uint8_t wait_ack(); // IIC等待ACK信号
|
||||
static void ack(); // IIC发送ACK信号
|
||||
static void nAck(); // IIC不发送ACK信号
|
||||
|
||||
static void write_one_byte(uint8_t daddr, uint8_t addr, uint8_t data);
|
||||
static uint8_t read_one_byte(uint8_t daddr, uint8_t addr);
|
||||
};
|
||||
|
||||
/******************** EEPROM ********************/
|
||||
|
||||
#define BL24C01 127
|
||||
#define BL24C02 255
|
||||
#define BL24C04 511
|
||||
#define BL24C08 1023
|
||||
#define BL24C16 2047
|
||||
#define BL24C32 4095
|
||||
#define BL24C64 8191
|
||||
#define BL24C128 16383
|
||||
#define BL24C256 32767
|
||||
#define EE_TYPE BL24C16
|
||||
|
||||
class BL24CXX {
|
||||
public:
|
||||
static void init(); //初始化IIC
|
||||
static uint8_t check(); //检查器件
|
||||
static uint8_t readOneByte(uint16_t ReadAddr); //指定地址读取一个字节
|
||||
static void writeOneByte(uint16_t WriteAddr, uint8_t DataToWrite); //指定地址写入一个字节
|
||||
static void writeLenByte(uint16_t WriteAddr, uint32_t DataToWrite, uint8_t Len);//指定地址开始写入指定长度的数据
|
||||
static uint32_t readLenByte(uint16_t ReadAddr, uint8_t Len); //指定地址开始读取指定长度数据
|
||||
static void write(uint16_t WriteAddr, uint8_t *pBuffer, uint16_t NumToWrite); //从指定地址开始写入指定长度的数据
|
||||
static void read(uint16_t ReadAddr, uint8_t *pBuffer, uint16_t NumToRead); //从指定地址开始读出指定长度的数据
|
||||
};
|
@ -0,0 +1,249 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file rotary_encoder.cpp
|
||||
* @author LEO / Creality3D
|
||||
* @date 2019/07/06
|
||||
* @version 2.0.1
|
||||
* @brief 旋转编码器操作函数
|
||||
******************************************************************************
|
||||
**/
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(DWIN_CREALITY_LCD)
|
||||
|
||||
#include "rotary_encoder.h"
|
||||
|
||||
#include "../../MarlinCore.h"
|
||||
#include "../../HAL/shared/Delay.h"
|
||||
|
||||
#if HAS_BUZZER
|
||||
#include "../../libs/buzzer.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
ENCODER_Rate EncoderRate;
|
||||
|
||||
/*蜂鸣器响*/
|
||||
void Encoder_tick(void) {
|
||||
WRITE(BEEPER_PIN,1);
|
||||
delay(10);
|
||||
WRITE(BEEPER_PIN,0);
|
||||
}
|
||||
|
||||
/*编码器初始化 PB12:Encoder_A PB13:Encoder_B PB14:Encoder_C*/
|
||||
void Encoder_Configuration(void) {
|
||||
#if BUTTON_EXISTS(EN1)
|
||||
SET_INPUT_PULLUP(BTN_EN1);
|
||||
#endif
|
||||
#if BUTTON_EXISTS(EN2)
|
||||
SET_INPUT_PULLUP(BTN_EN2);
|
||||
#endif
|
||||
#if BUTTON_EXISTS(ENC)
|
||||
SET_INPUT_PULLUP(BTN_ENC);
|
||||
#endif
|
||||
#ifdef BEEPER_PIN
|
||||
SET_OUTPUT(BEEPER_PIN);
|
||||
#endif
|
||||
}
|
||||
|
||||
millis_t next_click_update_ms;
|
||||
/*接收数据解析 返回值:ENCODER_DIFF_NO,无状态; ENCODER_DIFF_CW,顺时针旋转; ENCODER_DIFF_CCW,逆时针旋转; ENCODER_DIFF_ENTER,按下*/
|
||||
ENCODER_DiffState Encoder_ReceiveAnalyze(void) {
|
||||
const millis_t now = millis();
|
||||
static unsigned char lastEncoderBits;
|
||||
unsigned char newbutton = 0;
|
||||
static signed char temp_diff = 0;
|
||||
|
||||
ENCODER_DiffState temp_diffState = ENCODER_DIFF_NO;
|
||||
if (BUTTON_PRESSED(EN1)) newbutton |= 0x01;
|
||||
if (BUTTON_PRESSED(EN2)) newbutton |= 0x02;
|
||||
if (BUTTON_PRESSED(ENC)) {
|
||||
if (ELAPSED(now, next_click_update_ms)) {
|
||||
next_click_update_ms = millis() + 300;
|
||||
Encoder_tick();
|
||||
#if PIN_EXISTS(LCD_LED)
|
||||
//LED_Action();
|
||||
#endif
|
||||
return ENCODER_DIFF_ENTER;
|
||||
}
|
||||
else return ENCODER_DIFF_NO;
|
||||
}
|
||||
if (newbutton != lastEncoderBits) {
|
||||
switch (newbutton) {
|
||||
case ENCODER_PHASE_0: {
|
||||
if (lastEncoderBits == ENCODER_PHASE_3) temp_diff++;
|
||||
else if (lastEncoderBits == ENCODER_PHASE_1) temp_diff--;
|
||||
}break;
|
||||
case ENCODER_PHASE_1: {
|
||||
if (lastEncoderBits == ENCODER_PHASE_0) temp_diff++;
|
||||
else if (lastEncoderBits == ENCODER_PHASE_2) temp_diff--;
|
||||
}break;
|
||||
case ENCODER_PHASE_2: {
|
||||
if (lastEncoderBits == ENCODER_PHASE_1) temp_diff++;
|
||||
else if (lastEncoderBits == ENCODER_PHASE_3) temp_diff--;
|
||||
}break;
|
||||
case ENCODER_PHASE_3: {
|
||||
if (lastEncoderBits == ENCODER_PHASE_2) temp_diff++;
|
||||
else if (lastEncoderBits == ENCODER_PHASE_0) temp_diff--;
|
||||
}break;
|
||||
}
|
||||
lastEncoderBits = newbutton;
|
||||
}
|
||||
|
||||
if (abs(temp_diff) >= ENCODER_PULSES_PER_STEP) {
|
||||
if (temp_diff > 0) temp_diffState = ENCODER_DIFF_CW;
|
||||
else temp_diffState = ENCODER_DIFF_CCW;
|
||||
|
||||
#if ENABLED(ENCODER_RATE_MULTIPLIER)
|
||||
|
||||
millis_t ms = millis();
|
||||
int32_t encoderMultiplier = 1;
|
||||
|
||||
// if must encoder rati multiplier
|
||||
if (EncoderRate.encoderRateEnabled) {
|
||||
const float abs_diff = ABS(temp_diff);
|
||||
const float encoderMovementSteps = abs_diff / (ENCODER_PULSES_PER_STEP);
|
||||
if (EncoderRate.lastEncoderTime) {
|
||||
// Note that the rate is always calculated between two passes through the
|
||||
// loop and that the abs of the temp_diff value is tracked.
|
||||
const float encoderStepRate = encoderMovementSteps / float(ms - EncoderRate.lastEncoderTime) * 1000;
|
||||
if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC) encoderMultiplier = 100;
|
||||
else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC) encoderMultiplier = 10;
|
||||
else if (encoderStepRate >= ENCODER_5X_STEPS_PER_SEC) encoderMultiplier = 5;
|
||||
}
|
||||
EncoderRate.lastEncoderTime = ms;
|
||||
}
|
||||
#else
|
||||
constexpr int32_t encoderMultiplier = 1;
|
||||
#endif // ENCODER_RATE_MULTIPLIER
|
||||
|
||||
// EncoderRate.encoderMoveValue += (temp_diff * encoderMultiplier) / (ENCODER_PULSES_PER_STEP);
|
||||
EncoderRate.encoderMoveValue = (temp_diff * encoderMultiplier) / (ENCODER_PULSES_PER_STEP);
|
||||
if (EncoderRate.encoderMoveValue < 0) EncoderRate.encoderMoveValue = -EncoderRate.encoderMoveValue;
|
||||
|
||||
temp_diff = 0;
|
||||
}
|
||||
return temp_diffState;
|
||||
}
|
||||
|
||||
#if PIN_EXISTS(LCD_LED)
|
||||
|
||||
/*取低24位有效 24Bit: G7 G6 G5 G4 G3 G2 G1 G0 R7 R6 R5 R4 R3 R2 R1 R0 B7 B6 B5 B4 B3 B2 B1 B0*/
|
||||
unsigned int LED_DataArray[LED_NUM];
|
||||
|
||||
/*LED灯操作*/
|
||||
void LED_Action(void) {
|
||||
LED_Control(RGB_SCALE_WARM_WHITE,0x0F);
|
||||
delay(30);
|
||||
LED_Control(RGB_SCALE_WARM_WHITE,0x00);
|
||||
}
|
||||
|
||||
/*LED初始化*/
|
||||
void LED_Configuration(void) {
|
||||
SET_OUTPUT(LCD_LED_PIN);
|
||||
}
|
||||
|
||||
/*LED写数据*/
|
||||
void LED_WriteData(void) {
|
||||
unsigned char tempCounter_LED, tempCounter_Bit;
|
||||
for (tempCounter_LED = 0; tempCounter_LED < LED_NUM; tempCounter_LED++) {
|
||||
for (tempCounter_Bit = 0; tempCounter_Bit < 24; tempCounter_Bit++) {
|
||||
if (LED_DataArray[tempCounter_LED] & (0x800000 >> tempCounter_Bit)) {
|
||||
LED_DATA_HIGH;
|
||||
DELAY_NS(300);
|
||||
LED_DATA_LOW;
|
||||
DELAY_NS(200);
|
||||
}
|
||||
else {
|
||||
LED_DATA_HIGH;
|
||||
LED_DATA_LOW;
|
||||
DELAY_NS(200);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*LED控制 RGB_Scale:RGB色彩配比 luminance:亮度(0~0xFF)*/
|
||||
void LED_Control(unsigned char RGB_Scale, unsigned char luminance) {
|
||||
unsigned char temp_Counter;
|
||||
for (temp_Counter = 0; temp_Counter < LED_NUM; temp_Counter++) {
|
||||
LED_DataArray[temp_Counter] = 0;
|
||||
switch(RGB_Scale) {
|
||||
case RGB_SCALE_R10_G7_B5: LED_DataArray[temp_Counter] = (luminance*10/10) << 8 | (luminance*7/10) << 16 | luminance*5/10; break;
|
||||
case RGB_SCALE_R10_G7_B4: LED_DataArray[temp_Counter] = (luminance*10/10) << 8 | (luminance*7/10) << 16 | luminance*4/10; break;
|
||||
case RGB_SCALE_R10_G8_B7: LED_DataArray[temp_Counter] = (luminance*10/10) << 8 | (luminance*8/10) << 16 | luminance*7/10; break;
|
||||
}
|
||||
}
|
||||
LED_WriteData();
|
||||
}
|
||||
|
||||
/*LED渐变控制 RGB_Scale:RGB色彩配比 luminance:亮度(0~0xFF) change_Time:渐变时间(ms)*/
|
||||
void LED_GraduallyControl(unsigned char RGB_Scale, unsigned char luminance, unsigned int change_Interval) {
|
||||
unsigned char temp_Counter;
|
||||
unsigned char LED_R_Data[LED_NUM], LED_G_Data[LED_NUM], LED_B_Data[LED_NUM];
|
||||
bool LED_R_Flag = 0, LED_G_Flag = 0, LED_B_Flag = 0;
|
||||
|
||||
for (temp_Counter = 0; temp_Counter < LED_NUM; temp_Counter++) {
|
||||
switch(RGB_Scale) {
|
||||
case RGB_SCALE_R10_G7_B5: {
|
||||
LED_R_Data[temp_Counter] = luminance*10/10;
|
||||
LED_G_Data[temp_Counter] = luminance*7/10;
|
||||
LED_B_Data[temp_Counter] = luminance*5/10;
|
||||
}break;
|
||||
case RGB_SCALE_R10_G7_B4: {
|
||||
LED_R_Data[temp_Counter] = luminance*10/10;
|
||||
LED_G_Data[temp_Counter] = luminance*7/10;
|
||||
LED_B_Data[temp_Counter] = luminance*4/10;
|
||||
}break;
|
||||
case RGB_SCALE_R10_G8_B7: {
|
||||
LED_R_Data[temp_Counter] = luminance*10/10;
|
||||
LED_G_Data[temp_Counter] = luminance*8/10;
|
||||
LED_B_Data[temp_Counter] = luminance*7/10;
|
||||
}break;
|
||||
}
|
||||
}
|
||||
for (temp_Counter = 0; temp_Counter < LED_NUM; temp_Counter++) {
|
||||
if ((unsigned char)(LED_DataArray[temp_Counter] >> 8) > LED_R_Data[temp_Counter]) LED_DataArray[temp_Counter] -= 0x000100;
|
||||
else if ((unsigned char)(LED_DataArray[temp_Counter] >> 8) < LED_R_Data[temp_Counter]) LED_DataArray[temp_Counter] += 0x000100;
|
||||
while (1) {
|
||||
else LED_R_Flag = 1;
|
||||
if ((unsigned char)(LED_DataArray[temp_Counter]>>16) > LED_G_Data[temp_Counter]) LED_DataArray[temp_Counter] -= 0x010000;
|
||||
else if ((unsigned char)(LED_DataArray[temp_Counter]>>16) < LED_G_Data[temp_Counter]) LED_DataArray[temp_Counter] += 0x010000;
|
||||
else LED_G_Flag = 1;
|
||||
if ((unsigned char)LED_DataArray[temp_Counter] > LED_B_Data[temp_Counter]) LED_DataArray[temp_Counter] -= 0x000001;
|
||||
else if ((unsigned char)LED_DataArray[temp_Counter] < LED_B_Data[temp_Counter]) LED_DataArray[temp_Counter] += 0x000001;
|
||||
else LED_B_Flag = 1;
|
||||
}
|
||||
LED_WriteData();
|
||||
if (LED_R_Flag && LED_G_Flag && LED_B_Flag) break;
|
||||
else delay(change_Interval);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // DWIN_CREALITY_LCD
|
@ -0,0 +1,105 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file rotary_encoder.h
|
||||
* @author LEO / Creality3D
|
||||
* @date 2019/07/06
|
||||
* @version 2.0.1
|
||||
* @brief 旋转编码器操作函数
|
||||
******************************************************************************
|
||||
**/
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "../../MarlinCore.h"
|
||||
|
||||
/*********************** Encoder Set ***********************/
|
||||
|
||||
#define ENCODER_PHASE_0 0
|
||||
#define ENCODER_PHASE_1 2
|
||||
#define ENCODER_PHASE_2 3
|
||||
#define ENCODER_PHASE_3 1
|
||||
|
||||
#define ENCODER_PULSES_PER_STEP 4
|
||||
|
||||
#define BUTTON_PRESSED(BN) !READ(BTN_## BN)
|
||||
|
||||
typedef struct {
|
||||
bool encoderRateEnabled = 0;
|
||||
int encoderMoveValue = 0;
|
||||
millis_t lastEncoderTime = 0;
|
||||
} ENCODER_Rate;
|
||||
|
||||
extern ENCODER_Rate EncoderRate;
|
||||
|
||||
typedef enum {
|
||||
ENCODER_DIFF_NO = 0,
|
||||
ENCODER_DIFF_CW = 1,
|
||||
ENCODER_DIFF_CCW = 2,
|
||||
ENCODER_DIFF_ENTER = 3
|
||||
} ENCODER_DiffState;
|
||||
|
||||
/*编码器初始化 PB12:Encoder_A PB13:Encoder_B PB14:Encoder_C*/
|
||||
void Encoder_Configuration(void);
|
||||
|
||||
/*接收数据解析 返回值:ENCODER_DIFF_NO,无状态; ENCODER_DIFF_CW,顺时针旋转; ENCODER_DIFF_CCW,逆时针旋转; ENCODER_DIFF_ENTER,按下*/
|
||||
ENCODER_DiffState Encoder_ReceiveAnalyze(void);
|
||||
|
||||
|
||||
/*********************** Encoder LED ***********************/
|
||||
|
||||
#if PIN_EXISTS(LCD_LED)
|
||||
|
||||
#define LED_NUM 4
|
||||
#define LED_DATA_HIGH WRITE(LCD_LED_PIN, 1)
|
||||
#define LED_DATA_LOW WRITE(LCD_LED_PIN, 0)
|
||||
|
||||
#define RGB_SCALE_R10_G7_B5 1
|
||||
#define RGB_SCALE_R10_G7_B4 2
|
||||
#define RGB_SCALE_R10_G8_B7 3
|
||||
#define RGB_SCALE_NEUTRAL_WHITE RGB_SCALE_R10_G7_B5 //正白
|
||||
#define RGB_SCALE_WARM_WHITE RGB_SCALE_R10_G7_B4 //暖白
|
||||
#define RGB_SCALE_COOL_WHITE RGB_SCALE_R10_G8_B7 //冷白
|
||||
|
||||
extern unsigned int LED_DataArray[LED_NUM];
|
||||
|
||||
/*状态LED初始化*/
|
||||
void STATE_LED_Configuration(void);
|
||||
|
||||
/*LED灯操作*/
|
||||
void LED_Action(void);
|
||||
|
||||
/*LED初始化*/
|
||||
void LED_Configuration(void);
|
||||
|
||||
/*LED写数据*/
|
||||
void LED_WriteData(void);
|
||||
|
||||
/*LED控制 RGB_Scale:RGB色彩配比 luminance:亮度(0~0xFF)*/
|
||||
void LED_Control(unsigned char RGB_Scale, unsigned char luminance);
|
||||
|
||||
/*LED渐变控制 RGB_Scale:RGB色彩配比 luminance:亮度(0~0xFF) change_Time:渐变时间(ms)*/
|
||||
void LED_GraduallyControl(unsigned char RGB_Scale, unsigned char luminance, unsigned int change_Interval);
|
||||
|
||||
#endif
|
@ -0,0 +1,167 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* CREALITY (STM32F103) board pin assignments
|
||||
*/
|
||||
|
||||
#ifndef __STM32F1__
|
||||
#error "Oops! Select an STM32F1 board in 'Tools > Board.'"
|
||||
#endif
|
||||
|
||||
#if HOTENDS > 1 || E_STEPPERS > 1
|
||||
#error "CREALITY supports up to 1 hotends / E-steppers. Comment out this line to continue."
|
||||
#endif
|
||||
|
||||
#define BOARD_INFO_NAME "CREALITY V4"
|
||||
#define DEFAULT_MACHINE_NAME "Ender 3 V2"
|
||||
|
||||
//
|
||||
// EEPROM
|
||||
//
|
||||
|
||||
/* I2C */
|
||||
#define IIC_BL24CXX_EEPROM // EEPROM on I2C-0
|
||||
//#define E2END 0x3FFF // 16Kb (24c16)
|
||||
#define IIC_EEPROM_SDA PA11
|
||||
#define IIC_EEPROM_SCL PA12
|
||||
|
||||
// SD EEPROM was in your original build, so...
|
||||
#define SDCARD_EEPROM_EMULATION
|
||||
|
||||
/* SPI */
|
||||
//#define SPI_EEPROM // EEPROM on SPI-0
|
||||
//#define SPI_CHAN_EEPROM1 ?
|
||||
//#define SPI_EEPROM1_CS ?
|
||||
// 2K EEPROM
|
||||
//#define SPI_EEPROM2_CS ?
|
||||
// 32Mb FLASH
|
||||
//#define SPI_FLASH_CS ?
|
||||
|
||||
/* FLASH */
|
||||
//#define FLASH_EEPROM_EMULATION
|
||||
|
||||
//
|
||||
// Servos
|
||||
//
|
||||
#define SERVO0_PIN PB0 // BLTouch OUT
|
||||
|
||||
//
|
||||
// Limit Switches
|
||||
//
|
||||
#define X_STOP_PIN PA5
|
||||
#define Y_STOP_PIN PA6
|
||||
#define Z_STOP_PIN PA7
|
||||
|
||||
#define Z_PROBE_PIN PB1 // BLTouch IN
|
||||
|
||||
//
|
||||
// Steppers
|
||||
//
|
||||
#define X_ENABLE_PIN PC3
|
||||
#define X_STEP_PIN PC2
|
||||
#define X_DIR_PIN PB9
|
||||
|
||||
#define Y_ENABLE_PIN PC3
|
||||
#define Y_STEP_PIN PB8
|
||||
#define Y_DIR_PIN PB7
|
||||
|
||||
#define Z_ENABLE_PIN PC3
|
||||
#define Z_STEP_PIN PB6
|
||||
#define Z_DIR_PIN PB5
|
||||
|
||||
#define E0_ENABLE_PIN PC3
|
||||
#define E0_STEP_PIN PB4
|
||||
#define E0_DIR_PIN PB3
|
||||
|
||||
//
|
||||
// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role
|
||||
//
|
||||
#define DISABLE_DEBUG
|
||||
|
||||
//
|
||||
// Temperature Sensors
|
||||
//
|
||||
#define TEMP_0_PIN PC5 // TH1
|
||||
#define TEMP_BED_PIN PC4 // TB1
|
||||
|
||||
//
|
||||
// Heaters / Fans
|
||||
//
|
||||
#define HEATER_0_PIN PA1 // HEATER1
|
||||
#define HEATER_BED_PIN PA2 // HOT BED
|
||||
|
||||
#define FAN_PIN PA0 // FAN
|
||||
#define FAN_SOFT_PWM
|
||||
|
||||
//
|
||||
// SD Card
|
||||
//
|
||||
#define SD_DETECT_PIN PC7
|
||||
#define SDCARD_CONNECTION ONBOARD
|
||||
#define ON_BOARD_SPI_DEVICE 1
|
||||
#define ONBOARD_SD_CS_PIN PA4 // SDSS
|
||||
#define SDIO_SUPPORT
|
||||
|
||||
#if ENABLED(RET6_12864_LCD)
|
||||
|
||||
/* RET6 12864 LCD */
|
||||
#define LCD_PINS_RS PB12
|
||||
#define LCD_PINS_ENABLE PB15
|
||||
#define LCD_PINS_D4 PB13
|
||||
|
||||
#define BTN_ENC PB2
|
||||
#define BTN_EN1 PB10
|
||||
#define BTN_EN2 PB14
|
||||
|
||||
#define BEEPER_PIN PC6
|
||||
#elif ENABLED(VET6_12864_LCD)
|
||||
|
||||
/* VET6 12864 LCD */
|
||||
#define LCD_PINS_RS PA4
|
||||
#define LCD_PINS_ENABLE PA7
|
||||
#define LCD_PINS_D4 PA5
|
||||
|
||||
#define BTN_ENC PC5
|
||||
#define BTN_EN1 PB10
|
||||
#define BTN_EN2 PA6
|
||||
|
||||
#elif ENABLED(DWIN_CREALITY_LCD)
|
||||
|
||||
/* RET6 DWIN ENCODER LCD */
|
||||
#define BTN_ENC PB14
|
||||
#define BTN_EN1 PB15
|
||||
#define BTN_EN2 PB12
|
||||
|
||||
//#define LCD_LED_PIN PB2
|
||||
#define BEEPER_PIN PB13
|
||||
|
||||
#elif ENABLED(DWIN_VET6_CREALITY_LCD)
|
||||
|
||||
/* VET6 DWIN ENCODER LCD */
|
||||
#define BTN_ENC PA6
|
||||
#define BTN_EN1 PA7
|
||||
#define BTN_EN2 PA4
|
||||
|
||||
#define BEEPER_PIN PA5
|
||||
|
||||
#endif
|
@ -0,0 +1,14 @@
|
||||
MEMORY
|
||||
{
|
||||
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K - 40
|
||||
rom (rx) : ORIGIN = 0x08007000, LENGTH = 512K - 28K
|
||||
}
|
||||
|
||||
/* Provide memory region aliases for common.inc */
|
||||
REGION_ALIAS("REGION_TEXT", rom);
|
||||
REGION_ALIAS("REGION_DATA", ram);
|
||||
REGION_ALIAS("REGION_BSS", ram);
|
||||
REGION_ALIAS("REGION_RODATA", rom);
|
||||
|
||||
/* Let common.inc handle the real work. */
|
||||
INCLUDE common.inc
|
@ -0,0 +1,16 @@
|
||||
import os
|
||||
Import("env")
|
||||
|
||||
# Relocate firmware from 0x08000000 to 0x08007000
|
||||
for define in env['CPPDEFINES']:
|
||||
if define[0] == "VECT_TAB_ADDR":
|
||||
env['CPPDEFINES'].remove(define)
|
||||
env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
|
||||
|
||||
custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/creality.ld")
|
||||
for i, flag in enumerate(env["LINKFLAGS"]):
|
||||
if "-Wl,-T" in flag:
|
||||
env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script
|
||||
elif flag == "-T":
|
||||
env["LINKFLAGS"][i + 1] = custom_ld_script
|
||||
|
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Build tests for STM32F103RET6_creality
|
||||
#
|
||||
|
||||
# exit on first failure
|
||||
set -e
|
||||
|
||||
#
|
||||
# Build with configs included in the PR
|
||||
#
|
||||
use_example_configs "Creality/Ender-3 V2"
|
||||
exec_test $1 $2 "Ender 3 v2"
|
||||
|
||||
restore_configs
|
Loading…
Reference in New Issue