Commit 6c9dd7ad authored by MagoKimbra's avatar MagoKimbra

Merge remote-tracking branch 'refs/remotes/origin/master' into dev

parents 521315e2 0d32d485
......@@ -5,7 +5,7 @@
https://github.com/MagoKimbra/MarlinKimbra
Use the "Download Zip" button on the right.
3. Some boards require special files and/or libraries from the ArduinoAddons directory.
4. Start the arduino IDE.
4. Start the arduino IDE 1.6.7.
5. Select Tools -> Board -> Arduino Mega 2560 or your microcontroller
6. Select the correct serial port in Tools ->Serial Port
7. Open MarlinKimbra.ino
......
......@@ -31,7 +31,7 @@
#include "Marlin_main.h"
#include "ultralcd.h"
#include "nextion_lcd.h"
#include "nextion/nextion_lcd.h"
#include "base.h"
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
#include "vector_3.h"
......
......@@ -47,7 +47,7 @@
#include "Configuration_Feature.h"
#include "Configuration_Overall.h"
#include "language.h"
#include "language/language.h"
#include "conditionals.h"
#include "sanitycheck.h"
#include "thermistortables.h"
......
......@@ -132,8 +132,8 @@
#define SERIAL_STEPPER_TOO_HIGH "Steprate too high: "
#define SERIAL_ENDSTOPS_HIT "endstops hit: "
#define SERIAL_ERR_COLD_EXTRUDE_STOP " cold extrusion prevented"
#define SERIAL_ERR_LONG_EXTRUDE_STOP " too long extrusion prevented"
#define SERIAL_ERR_COLD_EXTRUDE_STOP "cold extrusion prevented"
#define SERIAL_ERR_LONG_EXTRUDE_STOP "too long extrusion prevented"
#define SERIAL_MICROSTEP_MS1_MS2 "MS1,MS2 Pins"
#define SERIAL_MICROSTEP_X "X:"
#define SERIAL_MICROSTEP_Y "Y:"
......
/*
* Copyright (C) 2015, MagoKimbra
* All right reserved.
* Author: Alberto Cotronei <magokimbra@hotmail.com>
*
* 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 2
* 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.
*
*/
#include "../base.h"
#if ENABLED(NEXTION_GFX)
#include "../Marlin_main.h"
#include "../stepper.h"
#include "nextion_gfx.h"
const int INSIDE = 0; // 0000
const int LEFT = 1; // 0001
const int RIGHT = 2; // 0010
const int BOTTOM = 4; // 0100
const int TOP = 8; // 1000
static int ComputeOutCode(int x, int y, int w, int h) {
int code;
code = INSIDE; // initialised as being inside of clip window
if (x < 0) // to the left of clip window
code |= LEFT;
else if (x > w) // to the right of clip window
code |= RIGHT;
if (y < 0) // below the clip window
code |= BOTTOM;
else if (y > h) // above the clip window
code |= TOP;
return code;
}
static uint16_t r5g6b5(const float* color_a, const float* cinc, int pixel) {
return (((int)((color_a[0] + cinc[0] * pixel) * 31) & 0x1f) << 11) |
(((int)((color_a[1] + cinc[1] * pixel) * 63) & 0x3f) << 5) |
(((int)((color_a[2] + cinc[2] * pixel) * 31) & 0x1f) << 0);
}
static void fcolor(float* c, uint16_t r5g6b5, float y, float max_y) {
float dim;
max_y *= 1.5;
dim = (max_y - y) / max_y;
c[0] = ((r5g6b5 >> 11) & 0x1f) / 31.0 * dim;
c[1] = ((r5g6b5 >> 5) & 0x3f) / 63.0 * dim;
c[2] = ((r5g6b5 >> 0) & 0x1f) / 31.0 * dim;
}
void GFX::_line2d_clipped(const float* color_a, const struct point* a, const float* color_b, const struct point* b) {
int x0, y0, x1, y1;
x0 = a->x;
y0 = a->y;
x1 = b->x;
y1 = b->y;
int outcode0 = ComputeOutCode(x0, y0, _width, _height);
int outcode1 = ComputeOutCode(x1, y1, _width, _height);
bool accept = false;
while (true) {
if (!(outcode0 | outcode1)) {
accept = true;
break;
}
else if (outcode0 & outcode1) {
break;
}
else {
int x = 0, y = 0;
int outcodeOut = outcode0 ? outcode0 : outcode1;
if (outcodeOut & TOP) {
x = x0 + (x1 - x0) * (_height - y0) / (y1 - y0);
y = _height;
}
else if (outcodeOut & BOTTOM) {
x = x0 + (x1 - x0) * ( - y0) / (y1 - y0);
y = 0;
}
else if (outcodeOut & RIGHT) {
y = y0 + (y1 - y0) * (_width - x0) / (x1 - x0);
x = _width;
}
else if (outcodeOut & LEFT) {
y = y0 + (y1 - y0) * ( - x0) / (x1 - x0);
x = 0;
}
if (outcodeOut == outcode0) {
x0 = x;
y0 = y;
outcode0 = ComputeOutCode(x0, y0, _width, _height);
}
else {
x1 = x;
y1 = y;
outcode1 = ComputeOutCode(x1, y1, _width, _height);
}
}
}
if (!accept) return;
int delta_x(x1 - x0);
signed char const ix((delta_x > 0) - (delta_x < 0));
delta_x = abs(delta_x) << 1;
int delta_y(y1 - y0);
signed char const iy((delta_y > 0) - (delta_y < 0));
delta_y = abs(delta_y) << 1;
float dist = sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0));
float cinc[3];
int pixel = 0;
for (int i = 0; i < 3; i++)
cinc[i] = (color_b[i] - color_a[i]) / dist;
drawPixel(_left + x0, _top + y0, r5g6b5(color_a, cinc, pixel++));
if (delta_x >= delta_y) {
int error(delta_y - (delta_x >> 1));
while (x0 != x1) {
if ((error >= 0) && (error || (ix > 0))) {
error -= delta_x;
y0 += iy;
}
error += delta_y;
x0 += ix;
drawPixel(_left + x0, _top + y0, r5g6b5(color_a, cinc, pixel++));
}
}
else {
int error(delta_x - (delta_y >> 1));
while (y0 != y1) {
if ((error >= 0) && (error || (iy > 0))) {
error -= delta_y;
x0 += ix;
}
error += delta_x;
y0 += iy;
drawPixel(_left + x0, _top + y0, r5g6b5(color_a, cinc, pixel++));
}
}
}
void GFX::line_to(int ndx, const float *pos) {
struct point loc;
_flatten(pos, &loc);
if (ndx >= 0 && ndx < VC_MAX) {
float color1[3], color2[3];
fcolor(color1, _color[ndx], _cursor.position[Y_AXIS], _max[Y_AXIS]);
fcolor(color2, _color[ndx], pos[Y_AXIS], _max[Y_AXIS]);
_line2d_clipped(color1, &_cursor.point, color2, &loc);
}
for (int i = 0; i < 3; i++)
_cursor.position[i] = pos[i];
_cursor.point = loc;
}
#endif // NEXTION
\ No newline at end of file
/*
* Copyright (C) 2015, MagoKimbra
* All right reserved.
* Author: Alberto Cotronei <magokimbra@hotmail.com>
*
* 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 2
* 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.
*
*/
#ifndef NEXTION_GFX_H
#define NEXTION_GFX_H
#if ENABLED(NEXTION_GFX)
#include <nextion.h>
#define VC_AXIS 0
#define VC_MOVE 3
#define VC_TOOL 4
#define VC_BACKGROUND 5
#define VC_MAX 6
struct point {
int x, y;
};
class GFX {
private:
/* Location of visualization in NEXTION LCD*/
int _top, _left, _width, _height;
float _scale, _max[3], _origin[3];
uint16_t _color[VC_MAX];
struct {
struct point point;
float position[3];
} _cursor;
public:
GFX(int width, int height, int x = 0, int y = 0) {
_top = y + 1;
_left = x + 1;
_width = width - 2;
_height = height - 2;
for (int i = 0; i < 3; i++)
_max[i] = 1000.0;
for (int i = 0; i < VC_MAX; i++)
_color[i] = 65535;
_color[VC_BACKGROUND] = 0;
}
void clear() {
float zero[3] = {}, old_origin[3];
fill(_left, _top, _width, _height, _color[VC_BACKGROUND]);
memcpy(old_origin, _origin, sizeof(_origin));
memcpy(_origin, zero, sizeof(_origin));
for (int i = 0; i < 3; i++) {
float pos[3] = {};
pos[i] = _max[i];
cursor_to(zero);
line_to(VC_AXIS + i, pos);
}
cursor_to(0, 0, _max[Z_AXIS]);
line_to(VC_AXIS + Y_AXIS, 0, _max[Y_AXIS], _max[Z_AXIS]);
line_to(VC_AXIS + Z_AXIS, 0, _max[Y_AXIS], 0);
line_to(VC_AXIS + X_AXIS, _max[X_AXIS], _max[Y_AXIS], 0);
line_to(VC_AXIS + Z_AXIS, _max[X_AXIS], _max[Y_AXIS], _max[Z_AXIS]);
line_to(VC_AXIS + Y_AXIS, _max[X_AXIS], 0, _max[Z_AXIS]);
line_to(VC_AXIS + Z_AXIS, _max[X_AXIS], 0, 0);
line_to(VC_AXIS + Y_AXIS, _max[X_AXIS], _max[Y_AXIS], 0);
cursor_to(0, 0, _max[Z_AXIS]);
line_to(VC_AXIS + X_AXIS, _max[X_AXIS], 0, _max[Z_AXIS]);
memcpy(_origin, old_origin, sizeof(_origin));
}
void clear(float scale) {
_scale = scale;
clear();
}
void clear(float x_mm, float y_mm, float z_mm) {
/* Bounding box for the build volume */
float scale_y = _height / (z_mm + y_mm / 4.0);
float scale_x = _width / (x_mm + y_mm / 4.0);
_max[X_AXIS] = x_mm;
_max[Y_AXIS] = y_mm;
_max[Z_AXIS] = z_mm;
clear(scale_x > scale_y ? scale_y : scale_x);
}
void origin(float x, float y, float z) {
_origin[X_AXIS] = x;
_origin[Y_AXIS] = y;
_origin[Z_AXIS] = z;
clear();
}
void color_set(int color_ndx, uint16_t color) {
_color[color_ndx] = color;
}
void cursor_to(const float *pos) {
for (int i = 0; i < 3; i++)
_cursor.position[i] = pos[i];
_flatten(_cursor.position, &_cursor.point);
}
void line_to(int color_ndx, const float *pos);
void cursor_to(float x, float y, float z) {
float pos[3] = { x, y, z };
cursor_to(pos);
}
void line_to(int color_ndx, float x, float y, float z) {
float pos[3] = { x, y, z };
line_to(color_ndx, pos);
}
private:
void _flatten(const float* pos, struct point* pt) {
pt->x = ((pos[X_AXIS] - _origin[X_AXIS]) +
(pos[Y_AXIS] - _origin[Y_AXIS]) / 4.0) * _scale + 1;
pt->y = (_height - 1) -
((pos[Z_AXIS] - _origin[Z_AXIS]) +
(pos[Y_AXIS] - _origin[Y_AXIS]) / 4) * _scale - 1;
}
void _line2d_clipped(const float* a_color, const struct point* a,
const float* b_color, const struct point* b);
bool fill(const int x0, const int y0, const int x1, const int y1, uint16_t color) {
char buf0[10], buf1[10], buf2[10], buf3[10], buf4[10] = {0};
String cmd;
utoa(x0, buf0, 10);
utoa(y0, buf1, 10);
utoa(x1, buf2, 10);
utoa(y1, buf3, 10);
utoa(color, buf4,10);
cmd += "fill ";
cmd += buf0;
cmd += ",";
cmd += buf1;
cmd += ",";
cmd += buf2;
cmd += ",";
cmd +=buf3;
cmd += ",";
cmd += buf4;
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
bool drawPixel(const int x, const int y, uint16_t color) {
char buf0[10], buf1[10], buf2[10] = {0};
String cmd;
utoa(x, buf0, 10);
utoa(y, buf1, 10);
utoa(color, buf2,10);
cmd += "line ";
cmd += buf0;
cmd += ",";
cmd += buf1;
cmd += ",";
cmd += buf0;
cmd += ",";
cmd += buf1;
cmd += ",";
cmd += buf2;
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
};
#endif // NEXTION
#endif /* NEXTION_GFX */
#include "base.h"
#include "../base.h"
#if ENABLED(NEXTION)
#include "Marlin_main.h"
#include "cardreader.h"
#include "temperature.h"
#include "../Marlin_main.h"
#include "../cardreader.h"
#include "../temperature.h"
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
#include "vector_3.h"
#include "../vector_3.h"
#endif
#include "planner.h"
#include "stepper_indirection.h"
#include "stepper.h"
#include "configuration_store.h"
#include "../planner.h"
#include "../stepper_indirection.h"
#include "../stepper.h"
#include "../configuration_store.h"
#include "nextion_lcd.h"
#include "nextion_gfx.h"
#include <Nextion.h>
const float MaxWave = 0.2;
bool NextionON = false;
bool PageInfo = false;
bool gfxON = false;
char buffer[100] = {0};
uint32_t slidermaxval = 20;
char lcd_status_message[30] = WELCOME_MSG;
char lcd_status_message[30] = WELCOME_MSG; // worst case is kana with up to 3*LCD_WIDTH+1
uint8_t lcd_status_message_level = 0;
static millis_t next_lcd_update_ms;
#if ENABLED(NEXTION_GFX)
GFX gfx = GFX(196, 194);
GFX gfx = GFX(200, 190);
#endif
// Page
......@@ -41,10 +39,10 @@
NexPage Pmove = NexPage(6, 0, "move");
// Text
NexText Hotend0 = NexText(1, 1, "t0");
NexText Hotend0 = NexText(1, 2, "t0");
NexText Hotend1 = NexText(1, 4, "t1");
NexText Hotend2 = NexText(1, 5, "t2");
NexText Hotend21 = NexText(1, 6, "h2");
NexText Hotend21 = NexText(1, 5, "h2");
NexText Hotend2 = NexText(1, 6, "t2");
NexText LedStatus = NexText(1, 7, "t4");
NexText LedCoord = NexText(1, 8, "t5");
NexText set0 = NexText(2, 2, "set0");
......@@ -57,15 +55,15 @@
NexText sdfolder = NexText(4, 23, "sdfolder");
// Picture
NexPicture Menu = NexPicture(1, 10, "p0");
NexPicture MSD = NexPicture(1, 11, "p1");
NexPicture MSetup = NexPicture(1, 12, "p2");
NexPicture Hend0 = NexPicture(1, 13, "p3");
NexPicture Menu = NexPicture(1, 9, "p0");
NexPicture MSD = NexPicture(1, 10, "p1");
NexPicture MSetup = NexPicture(1, 11, "p2");
NexPicture Hend0 = NexPicture(1, 12, "p3");
NexPicture Hend1 = NexPicture(1, 14, "p4");
NexPicture Hend2 = NexPicture(1, 15, "p5");
NexPicture Fanpic = NexPicture(1, 19, "p6");
NexPicture NPlay = NexPicture(1, 27, "p7");
NexPicture NStop = NexPicture(1, 28, "p8");
NexPicture Hend2 = NexPicture(1, 16, "p5");
NexPicture Fanpic = NexPicture(1, 18, "p6");
NexPicture NPlay = NexPicture(1, 24, "p7");
NexPicture NStop = NexPicture(1, 25, "p8");
NexPicture Exit1 = NexPicture(3, 4, "p3");
NexPicture Folder0 = NexPicture(4, 9, "p0");
NexPicture Folder1 = NexPicture(4, 10, "p1");
......@@ -86,32 +84,29 @@
NexPicture ZDown = NexPicture(6, 12, "p11");
// Progress Bar
NexProgressBar sdbar = NexProgressBar(1, 26, "j0");
NexProgressBar sdbar = NexProgressBar(1, 23, "j0");
// Slider
NexSlider sdlist = NexSlider(4, 1, "h0");
// Wafeform
NexWaveform Graph0 = NexWaveform(1, 9, "s0");
NexWaveform Graph1 = NexWaveform(1, 24, "s1");
NexWaveform Graph2 = NexWaveform(1, 25, "s2");
// Touch area
NexHotspot hot0 = NexHotspot(1, 14, "hot0");
NexHotspot hot1 = NexHotspot(1, 16, "hot1");
NexHotspot hot2 = NexHotspot(1, 18, "hot2");
NexHotspot hot0 = NexHotspot(1, 13, "hot0");
NexHotspot hot1 = NexHotspot(1, 15, "hot1");
NexHotspot hot2 = NexHotspot(1, 17, "hot2");
NexHotspot m11 = NexHotspot(2, 14, "m11");
NexHotspot tup = NexHotspot(2, 16, "tup");
NexHotspot tdown = NexHotspot(2, 17, "tdown");
// Timer
NexTimer startimer = NexTimer(0, 1, "tm0");
NexTimer fantimer = NexTimer(1, 23, "tm0");
NexTimer fantimer = NexTimer(1, 22, "tm0");
// Variable
NexVar Hotend = NexVar(1, 20, "he");
NexVar Hotend = NexVar(1, 19, "he");
NexVar Bed = NexVar(1, 20, "bed");
NexVar set1 = NexVar(2, 17, "set1");
NexVar Bed = NexVar(1, 21, "bed");
NexVar filename0 = NexVar(4, 19, "va0");
NexVar filename1 = NexVar(4, 20, "va1");
NexVar filename2 = NexVar(4, 21, "va2");
......@@ -165,14 +160,6 @@
NULL
};
NexWaveform *graph_list[] =
{
&Graph0,
&Graph1,
&Graph2,
NULL
};
NexText *row_list[] =
{
&sdrow0,
......@@ -211,6 +198,10 @@
PageInfo = true;
#if ENABLED(NEXTION_GFX)
gfx_clear(X_MAX_POS, Y_MAX_POS, Z_MAX_POS);
#endif
#if HAS_TEMP_0
Hotend.setValue(1);
#endif
......@@ -278,7 +269,6 @@
static void setpagesdcard() {
PageInfo = false;
gfxON = false;
Psdcard.show();
uint16_t fileCnt = card.getnrfilenames();
......@@ -436,12 +426,10 @@
void setpagePopCallback(void *ptr) {
if (ptr == &Menu) {
PageInfo = false;
gfxON = false;
Pmenu.show();
}
else if (ptr == &MSetup) {
PageInfo = false;
gfxON = false;
Psetup.show();
}
......@@ -561,11 +549,6 @@
hotend_list[h]->setText(buffer);
hotend_list[h]->setColor(color);
if (!gfxON) {
graph_list[h]->addValue(0, (int)(T1 * MaxWave));
graph_list[h]->addValue(1, (int)(T2 * MaxWave));
}
}
static void coordtoLCD() {
......@@ -678,19 +661,17 @@
#if ENABLED(NEXTION_GFX)
void gfx_clear(float x, float y, float z) {
if (PageInfo) {
if (PageInfo)
gfx.clear(x, y, z);
gfxON = true;
}
}
void gfx_cursor_to(float x, float y, float z) {
if (PageInfo && gfxON)
if (PageInfo)
gfx.cursor_to(x, y, z);
}
void gfx_line_to(float x, float y, float z){
if (PageInfo && gfxON)
if (PageInfo)
gfx.line_to(VC_TOOL, x, y, z);
}
#endif
......
......@@ -56,7 +56,6 @@
#include "stepper.h"
#include "temperature.h"
#include "ultralcd.h"
#include "language.h"
//===========================================================================
//============================= public variables ============================
......
......@@ -36,8 +36,8 @@
#include "stepper.h"
#include "temperature.h"
#include "ultralcd.h"
#include "nextion_lcd.h"
#include "language.h"
#include "nextion/nextion_lcd.h"
#if ENABLED(SDSUPPORT)
#include "cardreader.h"
#endif
......
......@@ -24,7 +24,7 @@
#include "vector_3.h"
#endif
#include "ultralcd.h"
#include "nextion_lcd.h"
#include "nextion/nextion_lcd.h"
#include "planner.h"
#include "stepper_indirection.h"
#if MB(ALLIGATOR)
......@@ -32,14 +32,13 @@
#endif
#include "stepper.h"
#include "temperature.h"
#include "thermistortables.h"
#if ENABLED(USE_WATCHDOG)
#include "watchdog.h"
#endif
#if ENABLED(SDSUPPORT)
#include "Sd2PinMap.h"
#endif
#include "temperature.h"
#include "thermistortables.h"
//===========================================================================
//================================== macros =================================
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment