Skip to content

Commit e74013a

Browse files
committed
Fix and update
1 parent c92adbb commit e74013a

31 files changed

+1131
-1308
lines changed

MarlinKimbra4due/Marlin_main.cpp

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ void get_command() {
865865

866866
if (drain_queued_commands_P()) return; // priority is given to non-serial commands
867867

868-
#ifdef NO_TIMEOUTS
868+
#if ENABLED(NO_TIMEOUTS)
869869
static millis_t last_command_time = 0;
870870
millis_t ms = millis();
871871

@@ -880,7 +880,7 @@ void get_command() {
880880
//
881881
while (MYSERIAL.available() > 0 && commands_in_queue < BUFSIZE) {
882882

883-
#ifdef NO_TIMEOUTS
883+
#if ENABLED(NO_TIMEOUTS)
884884
last_command_time = ms;
885885
#endif
886886

@@ -905,15 +905,13 @@ void get_command() {
905905
#endif
906906

907907
char *npos = strchr(command, 'N');
908-
if (npos == NULL) npos = strchr(command, 'n');
909908
char *apos = strchr(command, '*');
910909
if (npos) {
911910

912-
boolean M110 = strstr_P(command, PSTR("M110")) != NULL || strstr_P(command, PSTR("m110")) != NULL;
911+
boolean M110 = strstr_P(command, PSTR("M110")) != NULL;
913912

914913
if (M110) {
915914
char *n2pos = strchr(command + 4, 'N');
916-
if (n2pos == NULL) n2pos = strchr(command + 4, 'n');
917915
if (n2pos) npos = n2pos;
918916
}
919917

@@ -924,8 +922,6 @@ void get_command() {
924922
return;
925923
}
926924

927-
gcode_LastN = gcode_N;
928-
929925
if (apos) {
930926
byte checksum = 0, count = 0;
931927
while (command[count] != '*') checksum ^= command[count++];
@@ -940,6 +936,9 @@ void get_command() {
940936
gcode_line_error(PSTR(MSG_ERR_NO_CHECKSUM));
941937
return;
942938
}
939+
940+
gcode_LastN = gcode_N;
941+
// if no errors, continue parsing
943942
}
944943
else if (apos) { // No '*' without 'N'
945944
gcode_line_error(PSTR(MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM), false);
@@ -949,7 +948,6 @@ void get_command() {
949948
// Movement commands alert when stopped
950949
if (IsStopped()) {
951950
char *gpos = strchr(command, 'G');
952-
if (gpos == NULL) gpos = strchr(command, 'g');
953951
if (gpos) {
954952
int codenum = strtol(gpos + 1, NULL, 10);
955953
switch (codenum) {
@@ -965,7 +963,7 @@ void get_command() {
965963
}
966964

967965
// If command was e-stop process now
968-
if (strcmp(command, "M112") == 0 || strcmp(command, "m112") == 0) kill(PSTR(MSG_KILLED));
966+
if (strcmp(command, "M112") == 0) kill(PSTR(MSG_KILLED));
969967

970968
cmd_queue_index_w = (cmd_queue_index_w + 1) % BUFSIZE;
971969
commands_in_queue += 1;
@@ -1050,7 +1048,7 @@ bool code_has_value() {
10501048

10511049
float code_value() {
10521050
float ret;
1053-
char *e = strchr(seen_pointer, 'E'); if (e == NULL) e = strchr(seen_pointer, 'e');
1051+
char *e = strchr(seen_pointer, 'E');
10541052
if (e) {
10551053
*e = 0;
10561054
ret = strtod(seen_pointer + 1, NULL);
@@ -1067,7 +1065,6 @@ int16_t code_value_short() { return (int16_t)strtol(seen_pointer + 1, NULL, 10);
10671065

10681066
bool code_seen(char code) {
10691067
seen_pointer = strchr(current_command_args, code); // +3 since "G0 " is the shortest prefix
1070-
if (seen_pointer == NULL) seen_pointer = strchr(current_command_args, code + ('a'-'A'));
10711068
return (seen_pointer != NULL); //Return True if a character was found
10721069
}
10731070

@@ -3554,8 +3551,9 @@ inline void gcode_G28() {
35543551
double eqnAMatrix[abl2 * 3], // "A" matrix of the linear system of equations
35553552
eqnBVector[abl2]; // "B" vector of Z points
35563553

3554+
int8_t indexIntoAB[auto_bed_leveling_grid_points][auto_bed_leveling_grid_points];
35573555
int probePointCounter = 0;
3558-
bool zig = true;
3556+
bool zig = (auto_bed_leveling_grid_points & 1) ? true : false; //always end at [RIGHT_PROBE_BED_POSITION, BACK_PROBE_BED_POSITION]
35593557

35603558
for (int yCount = 0; yCount < auto_bed_leveling_grid_points; yCount++) {
35613559
double yProbe = front_probe_bed_position + yGridSpacing * yCount;
@@ -3572,9 +3570,8 @@ inline void gcode_G28() {
35723570
xInc = -1;
35733571
}
35743572

3575-
// If do_topography_map is set then don't zig-zag. Just scan in one direction.
3576-
// This gets the probe points in more readable order.
3577-
if (!do_topography_map) zig = !zig;
3573+
zig = !zig;
3574+
35783575
for (int xCount = xStart; xCount != xStop; xCount += xInc) {
35793576
double xProbe = left_probe_bed_position + xGridSpacing * xCount;
35803577

@@ -3606,6 +3603,7 @@ inline void gcode_G28() {
36063603
eqnAMatrix[probePointCounter + 0 * abl2] = xProbe;
36073604
eqnAMatrix[probePointCounter + 1 * abl2] = yProbe;
36083605
eqnAMatrix[probePointCounter + 2 * abl2] = 1;
3606+
indexIntoAB[xCount][yCount] = probePointCounter;
36093607

36103608
probePointCounter++;
36113609

@@ -3661,7 +3659,7 @@ inline void gcode_G28() {
36613659
for (int8_t yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) {
36623660
ECHO_S(DB);
36633661
for (int8_t xx = 0; xx < auto_bed_leveling_grid_points; xx++) {
3664-
int8_t ind = yy * auto_bed_leveling_grid_points + xx;
3662+
int8_t ind = indexIntoAB[xx][yy];
36653663

36663664
float diff = eqnBVector[ind];
36673665

@@ -3679,7 +3677,7 @@ inline void gcode_G28() {
36793677
for (int8_t yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) {
36803678
ECHO_S(DB);
36813679
for (int8_t xx = 0; xx < auto_bed_leveling_grid_points; xx++) {
3682-
int8_t ind = yy * auto_bed_leveling_grid_points + xx;
3680+
int8_t ind = indexIntoAB[xx][yy];
36833681

36843682
float diff = eqnBVector[ind] - min_diff;
36853683

@@ -3697,7 +3695,7 @@ inline void gcode_G28() {
36973695
for (int8_t yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) {
36983696
ECHO_S(DB);
36993697
for (int8_t xx = 0; xx < auto_bed_leveling_grid_points; xx++) {
3700-
int8_t ind = yy * auto_bed_leveling_grid_points + xx;
3698+
int8_t ind = indexIntoAB[xx][yy];
37013699

37023700
vector_3 probe_point = vector_3(eqnAMatrix[ind + 0 * abl2], eqnAMatrix[ind + 1 * abl2], eqnBVector[ind]);
37033701
probe_point.apply_rotation(inverse_bed_level_matrix);
@@ -3718,7 +3716,7 @@ inline void gcode_G28() {
37183716
for (int8_t yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) {
37193717
ECHO_S(DB);
37203718
for (int8_t xx = 0; xx < auto_bed_leveling_grid_points; xx++) {
3721-
int8_t ind = yy * auto_bed_leveling_grid_points + xx;
3719+
int8_t ind = indexIntoAB[xx][yy];
37223720

37233721
vector_3 probe_point = vector_3(eqnAMatrix[ind + 0 * abl2], eqnAMatrix[ind + 1 * abl2], eqnBVector[ind]);
37243722
probe_point.apply_rotation(inverse_bed_level_matrix);
@@ -6321,7 +6319,7 @@ inline void gcode_M999() {
63216319
inline void gcode_T(uint8_t tmp_extruder) {
63226320
long csteps;
63236321
if (tmp_extruder >= EXTRUDERS) {
6324-
ECHO_SMV(DB, "T", tmp_extruder);
6322+
ECHO_SMV(DB, "T", (int)tmp_extruder);
63256323
ECHO_EM(" " MSG_INVALID_EXTRUDER);
63266324
}
63276325
else {
@@ -6524,10 +6522,10 @@ inline void gcode_T(uint8_t tmp_extruder) {
65246522
if (csteps > 0) colorstep(csteps,true);
65256523
old_color = active_extruder = target_extruder;
65266524
active_driver = 0;
6527-
ECHO_LMV(DB, MSG_ACTIVE_COLOR, active_extruder);
6525+
ECHO_LMV(DB, MSG_ACTIVE_COLOR, (int)active_extruder);
65286526
#else
65296527
active_driver = active_extruder = target_extruder;
6530-
ECHO_LMV(DB, MSG_ACTIVE_EXTRUDER, active_extruder);
6528+
ECHO_LMV(DB, MSG_ACTIVE_EXTRUDER, (int)active_extruder);
65316529

65326530
#endif // end MKR4 || NPR2
65336531
#endif // end no DUAL_X_CARRIAGE

MarlinKimbra4due/NexButton.cpp

Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/**
22
* @file NexButton.cpp
33
*
4-
* API of NexButton.
4+
* The implementation of class NexButton.
55
*
66
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
7-
* @date 2015/7/10
7+
* @date 2015/8/13
88
* @copyright
99
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
1010
* This program is free software; you can redistribute it and/or
@@ -15,23 +15,11 @@
1515

1616
#include "NexButton.h"
1717

18-
/**
19-
* Constructor,inherited NexTouch's constructor function.
20-
*
21-
*/
22-
NexButton::NexButton(NexPid pid, NexCid cid, char *name, NexTouchEventCb pop, void *pop_ptr)
23-
:NexTouch(pid, cid, name, pop, pop_ptr)
18+
NexButton::NexButton(uint8_t pid, uint8_t cid, const char *name)
19+
:NexTouch(pid, cid, name)
2420
{
2521
}
2622

27-
/**
28-
* Get text value from button component.
29-
*
30-
* @param buffer - text buffer.
31-
* @param len - text buffer length.
32-
*
33-
* @return the text buffer length
34-
*/
3523
uint16_t NexButton::getText(char *buffer, uint16_t len)
3624
{
3725
String cmd;
@@ -42,14 +30,6 @@ uint16_t NexButton::getText(char *buffer, uint16_t len)
4230
return recvRetString(buffer,len);
4331
}
4432

45-
/**
46-
* Set text value of button component.
47-
*
48-
* @param buffer - text buffer.
49-
*
50-
* @retval true - success.
51-
* @retval false - failed.
52-
*/
5333
bool NexButton::setText(const char *buffer)
5434
{
5535
String cmd;
@@ -60,25 +40,3 @@ bool NexButton::setText(const char *buffer)
6040
sendCommand(cmd.c_str());
6141
return recvRetCommandFinished();
6242
}
63-
64-
/**
65-
* Register button pop callback function.
66-
*
67-
* @param pop - the pointer to button pop callback function.
68-
* @param ptr - the parameter to be transmitted to button pop callback function.
69-
*/
70-
void NexButton::attachPop(NexTouchEventCb pop, void *ptr)
71-
{
72-
NexTouch::attachPop(pop, ptr);
73-
}
74-
75-
/**
76-
* Unload button pop callback function.
77-
*
78-
*/
79-
void NexButton::detachPop(void)
80-
{
81-
NexTouch::detachPop();
82-
}
83-
84-

MarlinKimbra4due/NexButton.h

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
/**
22
* @file NexButton.h
33
*
4-
* API of NexButton.
4+
* The definition of class NexButton.
5+
*
6+
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
7+
* @date 2015/8/13
58
*
6-
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
7-
* @date 2015/7/10
89
* @copyright
910
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
1011
* This program is free software; you can redistribute it and/or
@@ -15,24 +16,51 @@
1516

1617
#ifndef __NEXBUTTON_H__
1718
#define __NEXBUTTON_H__
18-
#ifdef __cplusplus
19+
1920
#include "NexTouch.h"
21+
#include "NexHardware.h"
22+
/**
23+
* @addtogroup Component
24+
* @{
25+
*/
2026

2127
/**
22-
* NexButton,subclass of NexTouch,provides simple methods to control button component.
28+
* NexButton component.
2329
*
30+
* Commonly, you want to do something after push and pop it. It is recommanded that only
31+
* call @ref NexTouch::attachPop to satisfy your purpose.
32+
*
33+
* @warning Please do not call @ref NexTouch::attachPush on this component, even though you can.
2434
*/
2535
class NexButton: public NexTouch
2636
{
2737
public: /* methods */
28-
NexButton(NexPid pid, NexCid cid, char *name, NexTouchEventCb pop = NULL, void *pop_ptr = NULL);
29-
30-
void attachPop(NexTouchEventCb pop, void *ptr = NULL);
31-
void detachPop(void);
3238

33-
uint16_t getText(char *buffer, uint16_t len);
34-
bool setText(const char *buffer);
39+
/**
40+
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
41+
*/
42+
NexButton(uint8_t pid, uint8_t cid, const char *name);
43+
44+
/**
45+
* Get text attribute of component.
46+
*
47+
* @param buffer - buffer storing text returned.
48+
* @param len - length of buffer.
49+
* @return The real length of text returned.
50+
*/
51+
uint16_t getText(char *buffer, uint16_t len);
52+
53+
/**
54+
* Set text attribute of component.
55+
*
56+
* @param buffer - text buffer terminated with '\0'.
57+
* @return true if success, false for failure.
58+
*/
59+
bool setText(const char *buffer);
3560
};
61+
/**
62+
* @}
63+
*/
64+
3665

37-
#endif /* #ifdef __cplusplus */
3866
#endif /* #ifndef __NEXBUTTON_H__ */

0 commit comments

Comments
 (0)