Styling adjustments (PR#2668 & PR#2670)

Keep "astyled" reformatting
This commit is contained in:
Scott Lahteine 2015-10-02 23:08:58 -07:00 committed by Richard Wackerbarth
parent b5fb7075b9
commit 0c7f7ebcfb
100 changed files with 10213 additions and 10618 deletions

View file

@ -57,12 +57,10 @@ int how_many_E5s_are_here( unsigned char *);
void gcode_M100() void gcode_M100() {
{
static int m100_not_initialized = 1; static int m100_not_initialized = 1;
unsigned char* sp, *ptr; unsigned char* sp, *ptr;
int i, j, n; int i, j, n;
// //
// M100 D dumps the free memory block from __brkval to the stack pointer. // M100 D dumps the free memory block from __brkval to the stack pointer.
// malloc() eats memory from the start of the block and the stack grows // malloc() eats memory from the start of the block and the stack grows
@ -72,11 +70,9 @@ int i, j, n;
// probably caused by bad pointers. Any unexpected values will be flagged in // probably caused by bad pointers. Any unexpected values will be flagged in
// the right hand column to help spotting them. // the right hand column to help spotting them.
// //
#if ENABLED(M100_FREE_MEMORY_DUMPER) // Disable to remove Dump sub-command #if ENABLED(M100_FREE_MEMORY_DUMPER) // Disable to remove Dump sub-command
if (code_seen('D')) { if (code_seen('D')) {
ptr = (unsigned char*) __brkval; ptr = (unsigned char*) __brkval;
// //
// We want to start and end the dump on a nice 16 byte boundry even though // We want to start and end the dump on a nice 16 byte boundry even though
// the values we are using are not 16 byte aligned. // the values we are using are not 16 byte aligned.
@ -84,12 +80,10 @@ int i, j, n;
SERIAL_ECHOPGM("\n__brkval : "); SERIAL_ECHOPGM("\n__brkval : ");
prt_hex_word((unsigned int) ptr); prt_hex_word((unsigned int) ptr);
ptr = (unsigned char*)((unsigned long) ptr & 0xfff0); ptr = (unsigned char*)((unsigned long) ptr & 0xfff0);
sp = top_of_stack(); sp = top_of_stack();
SERIAL_ECHOPGM("\nStack Pointer : "); SERIAL_ECHOPGM("\nStack Pointer : ");
prt_hex_word((unsigned int) sp); prt_hex_word((unsigned int) sp);
SERIAL_ECHOPGM("\n"); SERIAL_ECHOPGM("\n");
sp = (unsigned char*)((unsigned long) sp | 0x000f); sp = (unsigned char*)((unsigned long) sp | 0x000f);
n = sp - ptr; n = sp - ptr;
// //
@ -103,7 +97,6 @@ int i, j, n;
SERIAL_ECHOPGM(" "); SERIAL_ECHOPGM(" ");
delay(2); delay(2);
} }
SERIAL_ECHO("|"); // now show where non 0xE5's are SERIAL_ECHO("|"); // now show where non 0xE5's are
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
delay(2); delay(2);
@ -113,7 +106,6 @@ int i, j, n;
SERIAL_ECHOPGM("?"); SERIAL_ECHOPGM("?");
} }
SERIAL_ECHO("\n"); SERIAL_ECHO("\n");
ptr += 16; ptr += 16;
delay(2); delay(2);
} }
@ -121,7 +113,6 @@ int i, j, n;
return; return;
} }
#endif #endif
// //
// M100 F requests the code to return the number of free bytes in the memory pool along with // M100 F requests the code to return the number of free bytes in the memory pool along with
// other vital statistics that define the memory pool. // other vital statistics that define the memory pool.
@ -133,9 +124,7 @@ int i, j, n;
ptr = (unsigned char*) __brkval; ptr = (unsigned char*) __brkval;
sp = top_of_stack(); sp = top_of_stack();
n = sp - ptr; n = sp - ptr;
// Scan through the range looking for the biggest block of 0xE5's we can find // Scan through the range looking for the biggest block of 0xE5's we can find
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
if (*(ptr + i) == (unsigned char) 0xe5) { if (*(ptr + i) == (unsigned char) 0xe5) {
j = how_many_E5s_are_here((unsigned char*) ptr + i); j = how_many_E5s_are_here((unsigned char*) ptr + i);
@ -155,7 +144,6 @@ int i, j, n;
} }
if (block_cnt > 1) if (block_cnt > 1)
SERIAL_ECHOLNPGM("\nMemory Corruption detected in free memory area.\n"); SERIAL_ECHOLNPGM("\nMemory Corruption detected in free memory area.\n");
SERIAL_ECHO("\nDone.\n"); SERIAL_ECHO("\nDone.\n");
return; return;
} }
@ -171,11 +159,9 @@ int i, j, n;
ptr = (unsigned char*) __brkval; ptr = (unsigned char*) __brkval;
SERIAL_ECHOPAIR("\n__brkval : ", (long) ptr); SERIAL_ECHOPAIR("\n__brkval : ", (long) ptr);
ptr += 8; ptr += 8;
sp = top_of_stack(); sp = top_of_stack();
SERIAL_ECHOPAIR("\nStack Pointer : ", (long) sp); SERIAL_ECHOPAIR("\nStack Pointer : ", (long) sp);
SERIAL_ECHOLNPGM("\n"); SERIAL_ECHOLNPGM("\n");
n = sp - ptr - 64; // -64 just to keep us from finding interrupt activity that n = sp - ptr - 64; // -64 just to keep us from finding interrupt activity that
// has altered the stack. // has altered the stack.
j = n / (x + 1); j = n / (x + 1);
@ -188,7 +174,6 @@ int i, j, n;
return; return;
} }
#endif #endif
// //
// M100 I Initializes the free memory pool so it can be watched and prints vital // M100 I Initializes the free memory pool so it can be watched and prints vital
// statistics that define the free memory pool. // statistics that define the free memory pool.
@ -198,20 +183,15 @@ int i, j, n;
ptr = (unsigned char*) __brkval; // Repeated M100 with no sub-command will not destroy the ptr = (unsigned char*) __brkval; // Repeated M100 with no sub-command will not destroy the
SERIAL_ECHOPAIR("\n__brkval : ", (long) ptr); // state of the initialized free memory pool. SERIAL_ECHOPAIR("\n__brkval : ", (long) ptr); // state of the initialized free memory pool.
ptr += 8; ptr += 8;
sp = top_of_stack(); sp = top_of_stack();
SERIAL_ECHOPAIR("\nStack Pointer : ", (long) sp); SERIAL_ECHOPAIR("\nStack Pointer : ", (long) sp);
SERIAL_ECHOLNPGM("\n"); SERIAL_ECHOLNPGM("\n");
n = sp - ptr - 64; // -64 just to keep us from finding interrupt activity that n = sp - ptr - 64; // -64 just to keep us from finding interrupt activity that
// has altered the stack. // has altered the stack.
SERIAL_ECHO(n); SERIAL_ECHO(n);
SERIAL_ECHOLNPGM(" bytes of memory initialized.\n"); SERIAL_ECHOLNPGM(" bytes of memory initialized.\n");
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
*(ptr + i) = (unsigned char) 0xe5; *(ptr + i) = (unsigned char) 0xe5;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
if (*(ptr + i) != (unsigned char) 0xe5) { if (*(ptr + i) != (unsigned char) 0xe5) {
SERIAL_ECHOPAIR("? address : ", (unsigned long) ptr + i); SERIAL_ECHOPAIR("? address : ", (unsigned long) ptr + i);
@ -238,8 +218,7 @@ unsigned char *top_of_stack() {
// 3 support routines to print hex numbers. We can print a nibble, byte and word // 3 support routines to print hex numbers. We can print a nibble, byte and word
// //
void prt_hex_nibble( unsigned int n ) void prt_hex_nibble(unsigned int n) {
{
if (n <= 9) if (n <= 9)
SERIAL_ECHO(n); SERIAL_ECHO(n);
else else
@ -247,14 +226,12 @@ void prt_hex_nibble( unsigned int n )
delay(2); delay(2);
} }
void prt_hex_byte(unsigned int b) void prt_hex_byte(unsigned int b) {
{
prt_hex_nibble((b & 0xf0) >> 4); prt_hex_nibble((b & 0xf0) >> 4);
prt_hex_nibble(b & 0x0f); prt_hex_nibble(b & 0x0f);
} }
void prt_hex_word(unsigned int w) void prt_hex_word(unsigned int w) {
{
prt_hex_byte((w & 0xff00) >> 8); prt_hex_byte((w & 0xff00) >> 8);
prt_hex_byte(w & 0x0ff); prt_hex_byte(w & 0x0ff);
} }
@ -262,10 +239,8 @@ void prt_hex_word(unsigned int w)
// how_many_E5s_are_here() is a utility function to easily find out how many 0xE5's are // how_many_E5s_are_here() is a utility function to easily find out how many 0xE5's are
// at the specified location. Having this logic as a function simplifies the search code. // at the specified location. Having this logic as a function simplifies the search code.
// //
int how_many_E5s_are_here( unsigned char *p) int how_many_E5s_are_here(unsigned char* p) {
{
int n; int n;
for (n = 0; n < 32000; n++) { for (n = 0; n < 32000; n++) {
if (*(p + n) != (unsigned char) 0xe5) if (*(p + n) != (unsigned char) 0xe5)
return n - 1; return n - 1;

View file

@ -102,7 +102,8 @@ void MarlinSerial::end() {
int MarlinSerial::peek(void) { int MarlinSerial::peek(void) {
if (rx_buffer.head == rx_buffer.tail) { if (rx_buffer.head == rx_buffer.tail) {
return -1; return -1;
} else { }
else {
return rx_buffer.buffer[rx_buffer.tail]; return rx_buffer.buffer[rx_buffer.tail];
} }
} }
@ -162,7 +163,8 @@ void MarlinSerial::print(long n, int base) {
n = -n; n = -n;
} }
printNumber(n, 10); printNumber(n, 10);
} else { }
else {
printNumber(n, base); printNumber(n, base);
} }
} }

View file

@ -99,7 +99,6 @@ class MarlinSerial { //: public Stream
FORCE_INLINE void write(uint8_t c) { FORCE_INLINE void write(uint8_t c) {
while (!TEST(M_UCSRxA, M_UDREx)) while (!TEST(M_UCSRxA, M_UDREx))
; ;
M_UDRx = c; M_UDRx = c;
} }

View file

@ -455,12 +455,10 @@ void serial_echopair_P(const char *s_P, unsigned long v) { serialprintPGM(s_P);
int freeMemory() { int freeMemory() {
int free_memory; int free_memory;
if ((int)__brkval == 0) if ((int)__brkval == 0)
free_memory = ((int)&free_memory) - ((int)&__bss_end); free_memory = ((int)&free_memory) - ((int)&__bss_end);
else else
free_memory = ((int)&free_memory) - ((int)__brkval); free_memory = ((int)&free_memory) - ((int)__brkval);
return free_memory; return free_memory;
} }
} }
@ -509,7 +507,6 @@ void enqueuecommands_P(const char* pgcode) {
* Returns false if it doesn't add any command * Returns false if it doesn't add any command
*/ */
bool enqueuecommand(const char* cmd) { bool enqueuecommand(const char* cmd) {
if (*cmd == ';' || commands_in_queue >= BUFSIZE) return false; if (*cmd == ';' || commands_in_queue >= BUFSIZE) return false;
// This is dangerous if a mixing of serial and this happens // This is dangerous if a mixing of serial and this happens
@ -1441,39 +1438,32 @@ static void setup_for_endstop_move() {
prepare_move_raw(); // this will also set_current_to_destination prepare_move_raw(); // this will also set_current_to_destination
// Move to engage deployment // Move to engage deployment
if (Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE != Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE) { if (Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE != Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE)
feedrate = Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE; feedrate = Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE;
} if (Z_PROBE_ALLEN_KEY_DEPLOY_2_X != Z_PROBE_ALLEN_KEY_DEPLOY_1_X)
if (Z_PROBE_ALLEN_KEY_DEPLOY_2_X != Z_PROBE_ALLEN_KEY_DEPLOY_1_X) {
destination[X_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_2_X; destination[X_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_2_X;
} if (Z_PROBE_ALLEN_KEY_DEPLOY_2_Y != Z_PROBE_ALLEN_KEY_DEPLOY_1_Y)
if (Z_PROBE_ALLEN_KEY_DEPLOY_2_Y != Z_PROBE_ALLEN_KEY_DEPLOY_1_Y) {
destination[Y_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_2_Y; destination[Y_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_2_Y;
} if (Z_PROBE_ALLEN_KEY_DEPLOY_2_Z != Z_PROBE_ALLEN_KEY_DEPLOY_1_Z)
if (Z_PROBE_ALLEN_KEY_DEPLOY_2_Z != Z_PROBE_ALLEN_KEY_DEPLOY_1_Z) {
destination[Z_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_2_Z; destination[Z_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_2_Z;
}
prepare_move_raw(); prepare_move_raw();
#ifdef Z_PROBE_ALLEN_KEY_DEPLOY_3_X #ifdef Z_PROBE_ALLEN_KEY_DEPLOY_3_X
if (Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE != Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE) { if (Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE != Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE)
feedrate = Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE; feedrate = Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE;
}
// Move to trigger deployment // Move to trigger deployment
if (Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE != Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE) { if (Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE != Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE)
feedrate = Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE; feedrate = Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE;
} if (Z_PROBE_ALLEN_KEY_DEPLOY_3_X != Z_PROBE_ALLEN_KEY_DEPLOY_2_X)
if (Z_PROBE_ALLEN_KEY_DEPLOY_3_X != Z_PROBE_ALLEN_KEY_DEPLOY_2_X) {
destination[X_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_3_X; destination[X_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_3_X;
} if (Z_PROBE_ALLEN_KEY_DEPLOY_3_Y != Z_PROBE_ALLEN_KEY_DEPLOY_2_Y)
if (Z_PROBE_ALLEN_KEY_DEPLOY_3_Y != Z_PROBE_ALLEN_KEY_DEPLOY_2_Y) {
destination[Y_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_3_Y; destination[Y_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_3_Y;
} if (Z_PROBE_ALLEN_KEY_DEPLOY_3_Z != Z_PROBE_ALLEN_KEY_DEPLOY_2_Z)
if (Z_PROBE_ALLEN_KEY_DEPLOY_3_Z != Z_PROBE_ALLEN_KEY_DEPLOY_2_Z) {
destination[Z_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_3_Z; destination[Z_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_3_Z;
}
prepare_move_raw(); prepare_move_raw();
#endif #endif
} }
@ -1505,7 +1495,6 @@ static void setup_for_endstop_move() {
} }
static void stow_z_probe(bool doRaise = true) { static void stow_z_probe(bool doRaise = true) {
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (marlin_debug_flags & DEBUG_LEVELING) { if (marlin_debug_flags & DEBUG_LEVELING) {
print_xyz("stow_z_probe > current_position", current_position); print_xyz("stow_z_probe > current_position", current_position);
@ -1553,28 +1542,22 @@ static void setup_for_endstop_move() {
prepare_move_raw(); prepare_move_raw();
// Move the nozzle down to push the Z probe into retracted position // Move the nozzle down to push the Z probe into retracted position
if (Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE != Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE) { if (Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE != Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE)
feedrate = Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE; feedrate = Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE;
} if (Z_PROBE_ALLEN_KEY_STOW_2_X != Z_PROBE_ALLEN_KEY_STOW_1_X)
if (Z_PROBE_ALLEN_KEY_STOW_2_X != Z_PROBE_ALLEN_KEY_STOW_1_X) {
destination[X_AXIS] = Z_PROBE_ALLEN_KEY_STOW_2_X; destination[X_AXIS] = Z_PROBE_ALLEN_KEY_STOW_2_X;
} if (Z_PROBE_ALLEN_KEY_STOW_2_Y != Z_PROBE_ALLEN_KEY_STOW_1_Y)
if (Z_PROBE_ALLEN_KEY_STOW_2_Y != Z_PROBE_ALLEN_KEY_STOW_1_Y) {
destination[Y_AXIS] = Z_PROBE_ALLEN_KEY_STOW_2_Y; destination[Y_AXIS] = Z_PROBE_ALLEN_KEY_STOW_2_Y;
}
destination[Z_AXIS] = Z_PROBE_ALLEN_KEY_STOW_2_Z; destination[Z_AXIS] = Z_PROBE_ALLEN_KEY_STOW_2_Z;
prepare_move_raw(); prepare_move_raw();
// Move up for safety // Move up for safety
if (Z_PROBE_ALLEN_KEY_STOW_3_FEEDRATE != Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE) { if (Z_PROBE_ALLEN_KEY_STOW_3_FEEDRATE != Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE)
feedrate = Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE; feedrate = Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE;
} if (Z_PROBE_ALLEN_KEY_STOW_3_X != Z_PROBE_ALLEN_KEY_STOW_2_X)
if (Z_PROBE_ALLEN_KEY_STOW_3_X != Z_PROBE_ALLEN_KEY_STOW_2_X) {
destination[X_AXIS] = Z_PROBE_ALLEN_KEY_STOW_3_X; destination[X_AXIS] = Z_PROBE_ALLEN_KEY_STOW_3_X;
} if (Z_PROBE_ALLEN_KEY_STOW_3_Y != Z_PROBE_ALLEN_KEY_STOW_2_Y)
if (Z_PROBE_ALLEN_KEY_STOW_3_Y != Z_PROBE_ALLEN_KEY_STOW_2_Y) {
destination[Y_AXIS] = Z_PROBE_ALLEN_KEY_STOW_3_Y; destination[Y_AXIS] = Z_PROBE_ALLEN_KEY_STOW_3_Y;
}
destination[Z_AXIS] = Z_PROBE_ALLEN_KEY_STOW_3_Z; destination[Z_AXIS] = Z_PROBE_ALLEN_KEY_STOW_3_Z;
prepare_move_raw(); prepare_move_raw();
@ -1601,9 +1584,7 @@ static void setup_for_endstop_move() {
} }
Stop(); Stop();
} }
#endif // Z_PROBE_ALLEN_KEY #endif // Z_PROBE_ALLEN_KEY
} }
enum ProbeAction { enum ProbeAction {
@ -1615,7 +1596,6 @@ static void setup_for_endstop_move() {
// Probe bed height at position (x,y), returns the measured z value // Probe bed height at position (x,y), returns the measured z value
static float probe_pt(float x, float y, float z_before, ProbeAction probe_action = ProbeDeployAndStow, int verbose_level = 1) { static float probe_pt(float x, float y, float z_before, ProbeAction probe_action = ProbeDeployAndStow, int verbose_level = 1) {
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (marlin_debug_flags & DEBUG_LEVELING) { if (marlin_debug_flags & DEBUG_LEVELING) {
SERIAL_ECHOLNPGM("probe_pt >>>"); SERIAL_ECHOLNPGM("probe_pt >>>");
@ -2732,7 +2712,8 @@ inline void gcode_G28() {
} }
if (code_seen('Z')) { if (code_seen('Z')) {
z = code_value(); z = code_value();
} else { }
else {
SERIAL_PROTOCOLPGM("Z not entered.\n"); SERIAL_PROTOCOLPGM("Z not entered.\n");
return; return;
} }
@ -2824,6 +2805,7 @@ inline void gcode_G28() {
} }
int auto_bed_leveling_grid_points = AUTO_BED_LEVELING_GRID_POINTS; int auto_bed_leveling_grid_points = AUTO_BED_LEVELING_GRID_POINTS;
#if DISABLED(DELTA) #if DISABLED(DELTA)
if (code_seen('P')) auto_bed_leveling_grid_points = code_value_short(); if (code_seen('P')) auto_bed_leveling_grid_points = code_value_short();
if (auto_bed_leveling_grid_points < 2) { if (auto_bed_leveling_grid_points < 2) {
@ -3434,7 +3416,7 @@ inline void gcode_M17() {
} }
} }
#endif #endif //SDSUPPORT
/** /**
* M31: Get the time since the start of SD Print (or last M109) * M31: Get the time since the start of SD Print (or last M109)
@ -4470,7 +4452,6 @@ inline void gcode_M204() {
SERIAL_ECHOPAIR("Setting Travel Acceleration: ", travel_acceleration); SERIAL_ECHOPAIR("Setting Travel Acceleration: ", travel_acceleration);
SERIAL_EOL; SERIAL_EOL;
} }
} }
/** /**
@ -4555,7 +4536,9 @@ inline void gcode_M206() {
} }
#endif #endif
} }
#elif ENABLED(Z_DUAL_ENDSTOPS) // !DELTA && ENABLED(Z_DUAL_ENDSTOPS) #elif ENABLED(Z_DUAL_ENDSTOPS) // !DELTA && ENABLED(Z_DUAL_ENDSTOPS)
/** /**
* M666: For Z Dual Endstop setup, set z axis offset to the z2 axis. * M666: For Z Dual Endstop setup, set z axis offset to the z2 axis.
*/ */
@ -5610,7 +5593,6 @@ inline void gcode_T(uint8_t tmp_extruder) {
current_position[Z_AXIS] = current_position[Z_AXIS] - current_position[Z_AXIS] = current_position[Z_AXIS] -
extruder_offset[Z_AXIS][active_extruder] + extruder_offset[Z_AXIS][active_extruder] +
extruder_offset[Z_AXIS][tmp_extruder]; extruder_offset[Z_AXIS][tmp_extruder];
active_extruder = tmp_extruder; active_extruder = tmp_extruder;
// This function resets the max/min values - the current position may be overwritten below. // This function resets the max/min values - the current position may be overwritten below.
@ -6372,8 +6354,7 @@ void clamp_to_software_endstops(float target[3]) {
#if ENABLED(MESH_BED_LEVELING) #if ENABLED(MESH_BED_LEVELING)
// This function is used to split lines on mesh borders so each segment is only part of one mesh area // This function is used to split lines on mesh borders so each segment is only part of one mesh area
void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_rate, const uint8_t &extruder, uint8_t x_splits=0xff, uint8_t y_splits=0xff) void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_rate, const uint8_t& extruder, uint8_t x_splits = 0xff, uint8_t y_splits = 0xff) {
{
if (!mbl.active) { if (!mbl.active) {
plan_buffer_line(x, y, z, e, feed_rate, extruder); plan_buffer_line(x, y, z, e, feed_rate, extruder);
set_current_to_destination(); set_current_to_destination();
@ -6623,15 +6604,15 @@ void plan_arc(
// CCW angle of rotation between position and target from the circle center. Only one atan2() trig computation required. // CCW angle of rotation between position and target from the circle center. Only one atan2() trig computation required.
float angular_travel = atan2(r_axis0 * rt_axis1 - r_axis1 * rt_axis0, r_axis0 * rt_axis0 + r_axis1 * rt_axis1); float angular_travel = atan2(r_axis0 * rt_axis1 - r_axis1 * rt_axis0, r_axis0 * rt_axis0 + r_axis1 * rt_axis1);
if (angular_travel < 0) { angular_travel += RADIANS(360); } if (angular_travel < 0) angular_travel += RADIANS(360);
if (clockwise) { angular_travel -= RADIANS(360); } if (clockwise) angular_travel -= RADIANS(360);
// Make a circle if the angular rotation is 0 // Make a circle if the angular rotation is 0
if (current_position[X_AXIS] == target[X_AXIS] && current_position[Y_AXIS] == target[Y_AXIS] && angular_travel == 0) if (current_position[X_AXIS] == target[X_AXIS] && current_position[Y_AXIS] == target[Y_AXIS] && angular_travel == 0)
angular_travel += RADIANS(360); angular_travel += RADIANS(360);
float mm_of_travel = hypot(angular_travel * radius, fabs(linear_travel)); float mm_of_travel = hypot(angular_travel * radius, fabs(linear_travel));
if (mm_of_travel < 0.001) { return; } if (mm_of_travel < 0.001) return;
uint16_t segments = floor(mm_of_travel / MM_PER_ARC_SEGMENT); uint16_t segments = floor(mm_of_travel / MM_PER_ARC_SEGMENT);
if (segments == 0) segments = 1; if (segments == 0) segments = 1;
@ -7113,7 +7094,6 @@ void kill(const char *lcd_msg) {
void setPwmFrequency(uint8_t pin, int val) { void setPwmFrequency(uint8_t pin, int val) {
val &= 0x07; val &= 0x07;
switch (digitalPinToTimer(pin)) { switch (digitalPinToTimer(pin)) {
#if defined(TCCR0A) #if defined(TCCR0A)
case TIMER0A: case TIMER0A:
case TIMER0B: case TIMER0B:
@ -7121,7 +7101,6 @@ void kill(const char *lcd_msg) {
// TCCR0B |= val; // TCCR0B |= val;
break; break;
#endif #endif
#if defined(TCCR1A) #if defined(TCCR1A)
case TIMER1A: case TIMER1A:
case TIMER1B: case TIMER1B:
@ -7129,7 +7108,6 @@ void kill(const char *lcd_msg) {
// TCCR1B |= val; // TCCR1B |= val;
break; break;
#endif #endif
#if defined(TCCR2) #if defined(TCCR2)
case TIMER2: case TIMER2:
case TIMER2: case TIMER2:
@ -7137,7 +7115,6 @@ void kill(const char *lcd_msg) {
TCCR2 |= val; TCCR2 |= val;
break; break;
#endif #endif
#if defined(TCCR2A) #if defined(TCCR2A)
case TIMER2A: case TIMER2A:
case TIMER2B: case TIMER2B:
@ -7145,7 +7122,6 @@ void kill(const char *lcd_msg) {
TCCR2B |= val; TCCR2B |= val;
break; break;
#endif #endif
#if defined(TCCR3A) #if defined(TCCR3A)
case TIMER3A: case TIMER3A:
case TIMER3B: case TIMER3B:
@ -7154,7 +7130,6 @@ void kill(const char *lcd_msg) {
TCCR3B |= val; TCCR3B |= val;
break; break;
#endif #endif
#if defined(TCCR4A) #if defined(TCCR4A)
case TIMER4A: case TIMER4A:
case TIMER4B: case TIMER4B:
@ -7163,7 +7138,6 @@ void kill(const char *lcd_msg) {
TCCR4B |= val; TCCR4B |= val;
break; break;
#endif #endif
#if defined(TCCR5A) #if defined(TCCR5A)
case TIMER5A: case TIMER5A:
case TIMER5B: case TIMER5B:
@ -7172,8 +7146,6 @@ void kill(const char *lcd_msg) {
TCCR5B |= val; TCCR5B |= val;
break; break;
#endif #endif
}
} }
#endif // FAST_PWM_FAN #endif // FAST_PWM_FAN

View file

@ -112,10 +112,9 @@ static uint8_t spiRec() {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** Soft SPI read data */ /** Soft SPI read data */
static void spiRead(uint8_t* buf, uint16_t nbyte) { static void spiRead(uint8_t* buf, uint16_t nbyte) {
for (uint16_t i = 0; i < nbyte; i++) { for (uint16_t i = 0; i < nbyte; i++)
buf[i] = spiRec(); buf[i] = spiRec();
} }
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** Soft SPI send byte */ /** Soft SPI send byte */
static void spiSend(uint8_t data) { static void spiSend(uint8_t data) {
@ -144,10 +143,9 @@ static void spiSend(uint8_t data) {
/** Soft SPI send block */ /** Soft SPI send block */
void spiSendBlock(uint8_t token, const uint8_t* buf) { void spiSendBlock(uint8_t token, const uint8_t* buf) {
spiSend(token); spiSend(token);
for (uint16_t i = 0; i < 512; i++) { for (uint16_t i = 0; i < 512; i++)
spiSend(buf[i]); spiSend(buf[i]);
} }
}
#endif // SOFTWARE_SPI #endif // SOFTWARE_SPI
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// send command and return error code. Return zero for OK // send command and return error code. Return zero for OK
@ -257,7 +255,6 @@ bool Sd2Card::erase(uint32_t firstBlock, uint32_t lastBlock) {
} }
chipSelectHigh(); chipSelectHigh();
return true; return true;
fail: fail:
chipSelectHigh(); chipSelectHigh();
return false; return false;
@ -322,7 +319,8 @@ bool Sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin) {
// check SD version // check SD version
if ((cardCommand(CMD8, 0x1AA) & R1_ILLEGAL_COMMAND)) { if ((cardCommand(CMD8, 0x1AA) & R1_ILLEGAL_COMMAND)) {
type(SD_CARD_TYPE_SD1); type(SD_CARD_TYPE_SD1);
} else { }
else {
// only need last byte of r7 response // only need last byte of r7 response
for (uint8_t i = 0; i < 4; i++) status_ = spiRec(); for (uint8_t i = 0; i < 4; i++) status_ = spiRec();
if (status_ != 0XAA) { if (status_ != 0XAA) {
@ -384,8 +382,7 @@ bool Sd2Card::readBlock(uint32_t blockNumber, uint8_t* dst) {
if (retryCnt > 0) goto retry; if (retryCnt > 0) goto retry;
goto fail; goto fail;
} }
if (!readData(dst, 512)) if (!readData(dst, 512)) {
{
if (retryCnt > 0) goto retry; if (retryCnt > 0) goto retry;
goto fail; goto fail;
} }
@ -488,8 +485,7 @@ bool Sd2Card::readData(uint8_t* dst, uint16_t count) {
uint16_t calcCrc = CRC_CCITT(dst, count); uint16_t calcCrc = CRC_CCITT(dst, count);
uint16_t recvCrc = spiRec() << 8; uint16_t recvCrc = spiRec() << 8;
recvCrc |= spiRec(); recvCrc |= spiRec();
if (calcCrc != recvCrc) if (calcCrc != recvCrc) {
{
error(SD_CARD_ERROR_CRC); error(SD_CARD_ERROR_CRC);
goto fail; goto fail;
} }
@ -501,7 +497,6 @@ bool Sd2Card::readData(uint8_t* dst, uint16_t count) {
#endif #endif
chipSelectHigh(); chipSelectHigh();
return true; return true;
fail: fail:
chipSelectHigh(); chipSelectHigh();
return false; return false;
@ -515,7 +510,6 @@ bool Sd2Card::readRegister(uint8_t cmd, void* buf) {
goto fail; goto fail;
} }
return readData(dst, 16); return readData(dst, 16);
fail: fail:
chipSelectHigh(); chipSelectHigh();
return false; return false;
@ -539,7 +533,6 @@ bool Sd2Card::readStart(uint32_t blockNumber) {
} }
chipSelectHigh(); chipSelectHigh();
return true; return true;
fail: fail:
chipSelectHigh(); chipSelectHigh();
return false; return false;
@ -558,7 +551,6 @@ bool Sd2Card::readStop() {
} }
chipSelectHigh(); chipSelectHigh();
return true; return true;
fail: fail:
chipSelectHigh(); chipSelectHigh();
return false; return false;
@ -592,7 +584,6 @@ bool Sd2Card::waitNotBusy(uint16_t timeoutMillis) {
if (((uint16_t)millis() - t0) >= timeoutMillis) goto fail; if (((uint16_t)millis() - t0) >= timeoutMillis) goto fail;
} }
return true; return true;
fail: fail:
return false; return false;
} }
@ -626,7 +617,6 @@ bool Sd2Card::writeBlock(uint32_t blockNumber, const uint8_t* src) {
} }
chipSelectHigh(); chipSelectHigh();
return true; return true;
fail: fail:
chipSelectHigh(); chipSelectHigh();
return false; return false;
@ -644,7 +634,6 @@ bool Sd2Card::writeData(const uint8_t* src) {
if (!writeData(WRITE_MULTIPLE_TOKEN, src)) goto fail; if (!writeData(WRITE_MULTIPLE_TOKEN, src)) goto fail;
chipSelectHigh(); chipSelectHigh();
return true; return true;
fail: fail:
error(SD_CARD_ERROR_WRITE_MULTIPLE); error(SD_CARD_ERROR_WRITE_MULTIPLE);
chipSelectHigh(); chipSelectHigh();
@ -664,7 +653,6 @@ bool Sd2Card::writeData(uint8_t token, const uint8_t* src) {
goto fail; goto fail;
} }
return true; return true;
fail: fail:
chipSelectHigh(); chipSelectHigh();
return false; return false;
@ -695,7 +683,6 @@ bool Sd2Card::writeStart(uint32_t blockNumber, uint32_t eraseCount) {
} }
chipSelectHigh(); chipSelectHigh();
return true; return true;
fail: fail:
chipSelectHigh(); chipSelectHigh();
return false; return false;
@ -713,7 +700,6 @@ bool Sd2Card::writeStop() {
if (!waitNotBusy(SD_WRITE_TIMEOUT)) goto fail; if (!waitNotBusy(SD_WRITE_TIMEOUT)) goto fail;
chipSelectHigh(); chipSelectHigh();
return true; return true;
fail: fail:
error(SD_CARD_ERROR_STOP_TRAN); error(SD_CARD_ERROR_STOP_TRAN);
chipSelectHigh(); chipSelectHigh();

View file

@ -68,7 +68,6 @@ bool SdBaseFile::addDirCluster() {
// Increase directory file size by cluster size // Increase directory file size by cluster size
fileSize_ += 512UL << vol_->clusterSizeShift_; fileSize_ += 512UL << vol_->clusterSizeShift_;
return true; return true;
fail: fail:
return false; return false;
} }
@ -78,7 +77,6 @@ bool SdBaseFile::addDirCluster() {
dir_t* SdBaseFile::cacheDirEntry(uint8_t action) { dir_t* SdBaseFile::cacheDirEntry(uint8_t action) {
if (!vol_->cacheRawBlock(dirBlock_, action)) goto fail; if (!vol_->cacheRawBlock(dirBlock_, action)) goto fail;
return vol_->cache()->dir + dirIndex_; return vol_->cache()->dir + dirIndex_;
fail: fail:
return 0; return 0;
} }
@ -167,7 +165,6 @@ bool SdBaseFile::createContiguous(SdBaseFile* dirFile,
flags_ |= F_FILE_DIR_DIRTY; flags_ |= F_FILE_DIR_DIRTY;
return sync(); return sync();
fail: fail:
return false; return false;
} }
@ -191,7 +188,6 @@ bool SdBaseFile::dirEntry(dir_t* dir) {
// copy to caller's struct // copy to caller's struct
memcpy(dir, p, sizeof(dir_t)); memcpy(dir, p, sizeof(dir_t));
return true; return true;
fail: fail:
return false; return false;
} }
@ -258,7 +254,8 @@ int16_t SdBaseFile::fgets(char* str, int16_t num, char* delim) {
str[n++] = ch; str[n++] = ch;
if (!delim) { if (!delim) {
if (ch == '\n') break; if (ch == '\n') break;
} else { }
else {
if (strchr(delim, ch)) break; if (strchr(delim, ch)) break;
} }
} }
@ -392,7 +389,8 @@ bool SdBaseFile::make83Name(const char* str, uint8_t* name, const char** ptr) {
if (n == 10) goto fail; // only one dot allowed if (n == 10) goto fail; // only one dot allowed
n = 10; // max index for full 8.3 name n = 10; // max index for full 8.3 name
i = 8; // place for extension i = 8; // place for extension
} else { }
else {
// illegal FAT characters // illegal FAT characters
PGM_P p = PSTR("|<>^+=?/[];,*\"\\"); PGM_P p = PSTR("|<>^+=?/[];,*\"\\");
uint8_t b; uint8_t b;
@ -406,7 +404,6 @@ bool SdBaseFile::make83Name(const char* str, uint8_t* name, const char** ptr) {
*ptr = str; *ptr = str;
// must have a file name, extension is optional // must have a file name, extension is optional
return name[0] != ' '; return name[0] != ' ';
fail: fail:
return false; return false;
} }
@ -454,7 +451,6 @@ bool SdBaseFile::mkdir(SdBaseFile* parent, const char* path, bool pFlag) {
sub = parent != &dir1 ? &dir1 : &dir2; sub = parent != &dir1 ? &dir1 : &dir2;
} }
return mkdir(parent, dname); return mkdir(parent, dname);
fail: fail:
return false; return false;
} }
@ -503,7 +499,8 @@ bool SdBaseFile::mkdir(SdBaseFile* parent, const uint8_t dname[11]) {
if (parent->isRoot()) { if (parent->isRoot()) {
d.firstClusterLow = 0; d.firstClusterLow = 0;
d.firstClusterHigh = 0; d.firstClusterHigh = 0;
} else { }
else {
d.firstClusterLow = parent->firstCluster_ & 0XFFFF; d.firstClusterLow = parent->firstCluster_ & 0XFFFF;
d.firstClusterHigh = parent->firstCluster_ >> 16; d.firstClusterHigh = parent->firstCluster_ >> 16;
} }
@ -512,7 +509,6 @@ bool SdBaseFile::mkdir(SdBaseFile* parent, const uint8_t dname[11]) {
// write first block // write first block
return vol_->cacheFlush(); return vol_->cacheFlush();
fail: fail:
return false; return false;
} }
@ -609,7 +605,6 @@ bool SdBaseFile::open(SdBaseFile* dirFile, const char* path, uint8_t oflag) {
sub = parent != &dir1 ? &dir1 : &dir2; sub = parent != &dir1 ? &dir1 : &dir2;
} }
return open(parent, dname, oflag); return open(parent, dname, oflag);
fail: fail:
return false; return false;
} }
@ -641,7 +636,8 @@ bool SdBaseFile::open(SdBaseFile* dirFile,
} }
// done if no entries follow // done if no entries follow
if (p->name[0] == DIR_NAME_FREE) break; if (p->name[0] == DIR_NAME_FREE) break;
} else if (!memcmp(dname, p->name, 11)) { }
else if (!memcmp(dname, p->name, 11)) {
fileFound = true; fileFound = true;
break; break;
} }
@ -649,14 +645,16 @@ bool SdBaseFile::open(SdBaseFile* dirFile,
if (fileFound) { if (fileFound) {
// don't open existing file if O_EXCL // don't open existing file if O_EXCL
if (oflag & O_EXCL) goto fail; if (oflag & O_EXCL) goto fail;
} else { }
else {
// don't create unless O_CREAT and O_WRITE // don't create unless O_CREAT and O_WRITE
if (!(oflag & O_CREAT) || !(oflag & O_WRITE)) goto fail; if (!(oflag & O_CREAT) || !(oflag & O_WRITE)) goto fail;
if (emptyFound) { if (emptyFound) {
index = dirIndex_; index = dirIndex_;
p = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); p = cacheDirEntry(SdVolume::CACHE_FOR_WRITE);
if (!p) goto fail; if (!p) goto fail;
} else { }
else {
if (dirFile->type_ == FAT_FILE_TYPE_ROOT_FIXED) goto fail; if (dirFile->type_ == FAT_FILE_TYPE_ROOT_FIXED) goto fail;
// add and zero cluster for dirFile - first cluster is in cache for write // add and zero cluster for dirFile - first cluster is in cache for write
@ -674,7 +672,8 @@ bool SdBaseFile::open(SdBaseFile* dirFile,
if (dateTime_) { if (dateTime_) {
// call user date/time function // call user date/time function
dateTime_(&p->creationDate, &p->creationTime); dateTime_(&p->creationDate, &p->creationTime);
} else { }
else {
// use default date/time // use default date/time
p->creationDate = FAT_DEFAULT_DATE; p->creationDate = FAT_DEFAULT_DATE;
p->creationTime = FAT_DEFAULT_TIME; p->creationTime = FAT_DEFAULT_TIME;
@ -688,7 +687,6 @@ bool SdBaseFile::open(SdBaseFile* dirFile,
} }
// open entry in cache // open entry in cache
return openCachedEntry(index, oflag); return openCachedEntry(index, oflag);
fail: fail:
return false; return false;
} }
@ -731,7 +729,6 @@ bool SdBaseFile::open(SdBaseFile* dirFile, uint16_t index, uint8_t oflag) {
} }
// open cached entry // open cached entry
return openCachedEntry(index & 0XF, oflag); return openCachedEntry(index & 0XF, oflag);
fail: fail:
return false; return false;
} }
@ -757,10 +754,12 @@ bool SdBaseFile::openCachedEntry(uint8_t dirIndex, uint8_t oflag) {
if (DIR_IS_FILE(p)) { if (DIR_IS_FILE(p)) {
fileSize_ = p->fileSize; fileSize_ = p->fileSize;
type_ = FAT_FILE_TYPE_NORMAL; type_ = FAT_FILE_TYPE_NORMAL;
} else if (DIR_IS_SUBDIR(p)) { }
else if (DIR_IS_SUBDIR(p)) {
if (!vol_->chainSize(firstCluster_, &fileSize_)) goto fail; if (!vol_->chainSize(firstCluster_, &fileSize_)) goto fail;
type_ = FAT_FILE_TYPE_SUBDIR; type_ = FAT_FILE_TYPE_SUBDIR;
} else { }
else {
goto fail; goto fail;
} }
// save open flags for read/write // save open flags for read/write
@ -771,7 +770,6 @@ bool SdBaseFile::openCachedEntry(uint8_t dirIndex, uint8_t oflag) {
curPosition_ = 0; curPosition_ = 0;
if ((oflag & O_TRUNC) && !truncate(0)) return false; if ((oflag & O_TRUNC) && !truncate(0)) return false;
return oflag & O_AT_END ? seekEnd(0) : true; return oflag & O_AT_END ? seekEnd(0) : true;
fail: fail:
type_ = FAT_FILE_TYPE_CLOSED; type_ = FAT_FILE_TYPE_CLOSED;
return false; return false;
@ -818,7 +816,6 @@ bool SdBaseFile::openNext(SdBaseFile* dirFile, uint8_t oflag) {
return openCachedEntry(index, oflag); return openCachedEntry(index, oflag);
} }
} }
fail: fail:
return false; return false;
} }
@ -862,8 +859,9 @@ bool SdBaseFile::openParent(SdBaseFile* dir) {
// '..' is pointer to first cluster of parent. open '../..' to find parent // '..' is pointer to first cluster of parent. open '../..' to find parent
if (p->firstClusterHigh == 0 && p->firstClusterLow == 0) { if (p->firstClusterHigh == 0 && p->firstClusterLow == 0) {
if (!file.openRoot(dir->volume())) goto fail; if (!file.openRoot(dir->volume())) goto fail;
} else { }
if (!file.openCachedEntry(1, O_READ)) goto fail; else if (!file.openCachedEntry(1, O_READ)) {
goto fail;
} }
// search for parent in '../..' // search for parent in '../..'
do { do {
@ -873,7 +871,6 @@ bool SdBaseFile::openParent(SdBaseFile* dir) {
} while (c != cluster); } while (c != cluster);
// open parent // open parent
return open(&file, file.curPosition() / 32 - 1, O_READ); return open(&file, file.curPosition() / 32 - 1, O_READ);
fail: fail:
return false; return false;
} }
@ -895,11 +892,13 @@ bool SdBaseFile::openRoot(SdVolume* vol) {
type_ = FAT_FILE_TYPE_ROOT_FIXED; type_ = FAT_FILE_TYPE_ROOT_FIXED;
firstCluster_ = 0; firstCluster_ = 0;
fileSize_ = 32 * vol->rootDirEntryCount(); fileSize_ = 32 * vol->rootDirEntryCount();
} else if (vol->fatType() == 32) { }
else if (vol->fatType() == 32) {
type_ = FAT_FILE_TYPE_ROOT32; type_ = FAT_FILE_TYPE_ROOT32;
firstCluster_ = vol->rootDirStart(); firstCluster_ = vol->rootDirStart();
if (!vol->chainSize(firstCluster_, &fileSize_)) goto fail; if (!vol->chainSize(firstCluster_, &fileSize_)) goto fail;
} else { }
else {
// volume is not initialized, invalid, or FAT12 without support // volume is not initialized, invalid, or FAT12 without support
return false; return false;
} }
@ -915,7 +914,6 @@ bool SdBaseFile::openRoot(SdVolume* vol) {
dirBlock_ = 0; dirBlock_ = 0;
dirIndex_ = 0; dirIndex_ = 0;
return true; return true;
fail: fail:
return false; return false;
} }
@ -1060,14 +1058,16 @@ int16_t SdBaseFile::read(void* buf, uint16_t nbyte) {
offset = curPosition_ & 0X1FF; // offset in block offset = curPosition_ & 0X1FF; // offset in block
if (type_ == FAT_FILE_TYPE_ROOT_FIXED) { if (type_ == FAT_FILE_TYPE_ROOT_FIXED) {
block = vol_->rootDirStart() + (curPosition_ >> 9); block = vol_->rootDirStart() + (curPosition_ >> 9);
} else { }
else {
uint8_t blockOfCluster = vol_->blockOfCluster(curPosition_); uint8_t blockOfCluster = vol_->blockOfCluster(curPosition_);
if (offset == 0 && blockOfCluster == 0) { if (offset == 0 && blockOfCluster == 0) {
// start of new cluster // start of new cluster
if (curPosition_ == 0) { if (curPosition_ == 0) {
// use first cluster in file // use first cluster in file
curCluster_ = firstCluster_; curCluster_ = firstCluster_;
} else { }
else {
// get next cluster from FAT // get next cluster from FAT
if (!vol_->fatGet(curCluster_, &curCluster_)) goto fail; if (!vol_->fatGet(curCluster_, &curCluster_)) goto fail;
} }
@ -1082,7 +1082,8 @@ int16_t SdBaseFile::read(void* buf, uint16_t nbyte) {
// no buffering needed if n == 512 // no buffering needed if n == 512
if (n == 512 && block != vol_->cacheBlockNumber()) { if (n == 512 && block != vol_->cacheBlockNumber()) {
if (!vol_->readBlock(block, dst)) goto fail; if (!vol_->readBlock(block, dst)) goto fail;
} else { }
else {
// read block to cache and copy data to caller // read block to cache and copy data to caller
if (!vol_->cacheRawBlock(block, SdVolume::CACHE_FOR_READ)) goto fail; if (!vol_->cacheRawBlock(block, SdVolume::CACHE_FOR_READ)) goto fail;
uint8_t* src = vol_->cache()->data + offset; uint8_t* src = vol_->cache()->data + offset;
@ -1093,7 +1094,6 @@ int16_t SdBaseFile::read(void* buf, uint16_t nbyte) {
toRead -= n; toRead -= n;
} }
return nbyte; return nbyte;
fail: fail:
return -1; return -1;
} }
@ -1166,7 +1166,6 @@ dir_t* SdBaseFile::readDirCache() {
// return pointer to entry // return pointer to entry
return vol_->cache()->dir + i; return vol_->cache()->dir + i;
fail: fail:
return 0; return 0;
} }
@ -1202,7 +1201,6 @@ bool SdBaseFile::remove() {
// write entry to SD // write entry to SD
return vol_->cacheFlush(); return vol_->cacheFlush();
return true; return true;
fail: fail:
return false; return false;
} }
@ -1228,7 +1226,6 @@ bool SdBaseFile::remove(SdBaseFile* dirFile, const char* path) {
SdBaseFile file; SdBaseFile file;
if (!file.open(dirFile, path, O_WRITE)) goto fail; if (!file.open(dirFile, path, O_WRITE)) goto fail;
return file.remove(); return file.remove();
fail: fail:
// can't set iostate - static function // can't set iostate - static function
return false; return false;
@ -1272,7 +1269,8 @@ bool SdBaseFile::rename(SdBaseFile* dirFile, const char* newPath) {
if (!file.open(dirFile, newPath, O_CREAT | O_EXCL | O_WRITE)) { if (!file.open(dirFile, newPath, O_CREAT | O_EXCL | O_WRITE)) {
goto restore; goto restore;
} }
} else { }
else {
// don't create missing path prefix components // don't create missing path prefix components
if (!file.mkdir(dirFile, newPath, false)) { if (!file.mkdir(dirFile, newPath, false)) {
goto restore; goto restore;
@ -1358,7 +1356,6 @@ bool SdBaseFile::rmdir() {
type_ = FAT_FILE_TYPE_NORMAL; type_ = FAT_FILE_TYPE_NORMAL;
flags_ |= O_WRITE; flags_ |= O_WRITE;
return remove(); return remove();
fail: fail:
return false; return false;
} }
@ -1402,7 +1399,8 @@ bool SdBaseFile::rmRfStar() {
if (f.isSubDir()) { if (f.isSubDir()) {
// recursively delete // recursively delete
if (!f.rmRfStar()) goto fail; if (!f.rmRfStar()) goto fail;
} else { }
else {
// ignore read-only // ignore read-only
f.flags_ |= O_WRITE; f.flags_ |= O_WRITE;
if (!f.remove()) goto fail; if (!f.remove()) goto fail;
@ -1417,7 +1415,6 @@ bool SdBaseFile::rmRfStar() {
if (!rmdir()) goto fail; if (!rmdir()) goto fail;
} }
return true; return true;
fail: fail:
return false; return false;
} }
@ -1465,7 +1462,8 @@ bool SdBaseFile::seekSet(uint32_t pos) {
if (nNew < nCur || curPosition_ == 0) { if (nNew < nCur || curPosition_ == 0) {
// must follow chain from first cluster // must follow chain from first cluster
curCluster_ = firstCluster_; curCluster_ = firstCluster_;
} else { }
else {
// advance from curPosition // advance from curPosition
nNew -= nCur; nNew -= nCur;
} }
@ -1637,7 +1635,6 @@ bool SdBaseFile::timestamp(uint8_t flags, uint16_t year, uint8_t month,
d->lastWriteTime = dirTime; d->lastWriteTime = dirTime;
} }
return vol_->cacheFlush(); return vol_->cacheFlush();
fail: fail:
return false; return false;
} }
@ -1674,7 +1671,8 @@ bool SdBaseFile::truncate(uint32_t length) {
// free all clusters // free all clusters
if (!vol_->freeChain(firstCluster_)) goto fail; if (!vol_->freeChain(firstCluster_)) goto fail;
firstCluster_ = 0; firstCluster_ = 0;
} else { }
else {
uint32_t toFree; uint32_t toFree;
if (!vol_->fatGet(curCluster_, &toFree)) goto fail; if (!vol_->fatGet(curCluster_, &toFree)) goto fail;
@ -1739,16 +1737,19 @@ int16_t SdBaseFile::write(const void* buf, uint16_t nbyte) {
if (firstCluster_ == 0) { if (firstCluster_ == 0) {
// allocate first cluster of file // allocate first cluster of file
if (!addCluster()) goto fail; if (!addCluster()) goto fail;
} else { }
else {
curCluster_ = firstCluster_; curCluster_ = firstCluster_;
} }
} else { }
else {
uint32_t next; uint32_t next;
if (!vol_->fatGet(curCluster_, &next)) goto fail; if (!vol_->fatGet(curCluster_, &next)) goto fail;
if (vol_->isEOC(next)) { if (vol_->isEOC(next)) {
// add cluster if at end of chain // add cluster if at end of chain
if (!addCluster()) goto fail; if (!addCluster()) goto fail;
} else { }
else {
curCluster_ = next; curCluster_ = next;
} }
} }
@ -1768,13 +1769,15 @@ int16_t SdBaseFile::write(const void* buf, uint16_t nbyte) {
vol_->cacheSetBlockNumber(0XFFFFFFFF, false); vol_->cacheSetBlockNumber(0XFFFFFFFF, false);
} }
if (!vol_->writeBlock(block, src)) goto fail; if (!vol_->writeBlock(block, src)) goto fail;
} else { }
else {
if (blockOffset == 0 && curPosition_ >= fileSize_) { if (blockOffset == 0 && curPosition_ >= fileSize_) {
// start of new block don't need to read into cache // start of new block don't need to read into cache
if (!vol_->cacheFlush()) goto fail; if (!vol_->cacheFlush()) goto fail;
// set cache dirty and SD address of block // set cache dirty and SD address of block
vol_->cacheSetBlockNumber(block, true); vol_->cacheSetBlockNumber(block, true);
} else { }
else {
// rewrite part of block // rewrite part of block
if (!vol_->cacheRawBlock(block, SdVolume::CACHE_FOR_WRITE)) goto fail; if (!vol_->cacheRawBlock(block, SdVolume::CACHE_FOR_WRITE)) goto fail;
} }
@ -1789,7 +1792,8 @@ int16_t SdBaseFile::write(const void* buf, uint16_t nbyte) {
// update fileSize and insure sync will update dir entry // update fileSize and insure sync will update dir entry
fileSize_ = curPosition_; fileSize_ = curPosition_;
flags_ |= F_FILE_DIR_DIRTY; flags_ |= F_FILE_DIR_DIRTY;
} else if (dateTime_ && nbyte) { }
else if (dateTime_ && nbyte) {
// insure sync will update modified date and time // insure sync will update modified date and time
flags_ |= F_FILE_DIR_DIRTY; flags_ |= F_FILE_DIR_DIRTY;
} }

View file

@ -55,13 +55,11 @@ int16_t SdFile::write(const void* buf, uint16_t nbyte) {
* Use writeError to check for errors. * Use writeError to check for errors.
*/ */
#if ARDUINO >= 100 #if ARDUINO >= 100
size_t SdFile::write(uint8_t b) size_t SdFile::write(uint8_t b) {
{
return SdBaseFile::write(&b, 1); return SdBaseFile::write(&b, 1);
} }
#else #else
void SdFile::write(uint8_t b) void SdFile::write(uint8_t b) {
{
SdBaseFile::write(&b, 1); SdBaseFile::write(&b, 1);
} }
#endif #endif

View file

@ -50,7 +50,8 @@ bool SdVolume::allocContiguous(uint32_t count, uint32_t* curCluster) {
// don't save new start location // don't save new start location
setStart = false; setStart = false;
} else { }
else {
// start at likely place for free cluster // start at likely place for free cluster
bgnCluster = allocSearchStart_; bgnCluster = allocSearchStart_;
@ -75,7 +76,8 @@ bool SdVolume::allocContiguous(uint32_t count, uint32_t* curCluster) {
if (f != 0) { if (f != 0) {
// cluster in use try next cluster as bgnCluster // cluster in use try next cluster as bgnCluster
bgnCluster = endCluster + 1; bgnCluster = endCluster + 1;
} else if ((endCluster - bgnCluster + 1) == count) { }
else if ((endCluster - bgnCluster + 1) == count) {
// done - found space // done - found space
break; break;
} }
@ -99,7 +101,6 @@ bool SdVolume::allocContiguous(uint32_t count, uint32_t* curCluster) {
if (setStart) allocSearchStart_ = bgnCluster + 1; if (setStart) allocSearchStart_ = bgnCluster + 1;
return true; return true;
fail: fail:
return false; return false;
} }
@ -119,7 +120,6 @@ bool SdVolume::cacheFlush() {
cacheDirty_ = 0; cacheDirty_ = 0;
} }
return true; return true;
fail: fail:
return false; return false;
} }
@ -132,7 +132,6 @@ bool SdVolume::cacheRawBlock(uint32_t blockNumber, bool dirty) {
} }
if (dirty) cacheDirty_ = true; if (dirty) cacheDirty_ = true;
return true; return true;
fail: fail:
return false; return false;
} }
@ -146,7 +145,6 @@ bool SdVolume::chainSize(uint32_t cluster, uint32_t* size) {
} while (!isEOC(cluster)); } while (!isEOC(cluster));
*size = s; *size = s;
return true; return true;
fail: fail:
return false; return false;
} }
@ -173,9 +171,11 @@ bool SdVolume::fatGet(uint32_t cluster, uint32_t* value) {
} }
if (fatType_ == 16) { if (fatType_ == 16) {
lba = fatStartBlock_ + (cluster >> 8); lba = fatStartBlock_ + (cluster >> 8);
} else if (fatType_ == 32) { }
else if (fatType_ == 32) {
lba = fatStartBlock_ + (cluster >> 7); lba = fatStartBlock_ + (cluster >> 7);
} else { }
else {
goto fail; goto fail;
} }
if (lba != cacheBlockNumber_) { if (lba != cacheBlockNumber_) {
@ -183,11 +183,11 @@ bool SdVolume::fatGet(uint32_t cluster, uint32_t* value) {
} }
if (fatType_ == 16) { if (fatType_ == 16) {
*value = cacheBuffer_.fat16[cluster & 0XFF]; *value = cacheBuffer_.fat16[cluster & 0XFF];
} else { }
else {
*value = cacheBuffer_.fat32[cluster & 0X7F] & FAT32MASK; *value = cacheBuffer_.fat32[cluster & 0X7F] & FAT32MASK;
} }
return true; return true;
fail: fail:
return false; return false;
} }
@ -231,22 +231,24 @@ bool SdVolume::fatPut(uint32_t cluster, uint32_t value) {
} }
if (fatType_ == 16) { if (fatType_ == 16) {
lba = fatStartBlock_ + (cluster >> 8); lba = fatStartBlock_ + (cluster >> 8);
} else if (fatType_ == 32) { }
else if (fatType_ == 32) {
lba = fatStartBlock_ + (cluster >> 7); lba = fatStartBlock_ + (cluster >> 7);
} else { }
else {
goto fail; goto fail;
} }
if (!cacheRawBlock(lba, CACHE_FOR_WRITE)) goto fail; if (!cacheRawBlock(lba, CACHE_FOR_WRITE)) goto fail;
// store entry // store entry
if (fatType_ == 16) { if (fatType_ == 16) {
cacheBuffer_.fat16[cluster & 0XFF] = value; cacheBuffer_.fat16[cluster & 0XFF] = value;
} else { }
else {
cacheBuffer_.fat32[cluster & 0X7F] = value; cacheBuffer_.fat32[cluster & 0X7F] = value;
} }
// mirror second FAT // mirror second FAT
if (fatCount_ > 1) cacheMirrorBlock_ = lba + blocksPerFat_; if (fatCount_ > 1) cacheMirrorBlock_ = lba + blocksPerFat_;
return true; return true;
fail: fail:
return false; return false;
} }
@ -268,7 +270,6 @@ bool SdVolume::freeChain(uint32_t cluster) {
} while (!isEOC(cluster)); } while (!isEOC(cluster));
return true; return true;
fail: fail:
return false; return false;
} }
@ -284,9 +285,11 @@ int32_t SdVolume::freeClusterCount() {
if (fatType_ == 16) { if (fatType_ == 16) {
n = 256; n = 256;
} else if (fatType_ == 32) { }
else if (fatType_ == 32) {
n = 128; n = 128;
} else { }
else {
// put FAT12 here // put FAT12 here
return -1; return -1;
} }
@ -298,7 +301,8 @@ int32_t SdVolume::freeClusterCount() {
for (uint16_t i = 0; i < n; i++) { for (uint16_t i = 0; i < n; i++) {
if (cacheBuffer_.fat16[i] == 0) free++; if (cacheBuffer_.fat16[i] == 0) free++;
} }
} else { }
else {
for (uint16_t i = 0; i < n; i++) { for (uint16_t i = 0; i < n; i++) {
if (cacheBuffer_.fat32[i] == 0) free++; if (cacheBuffer_.fat32[i] == 0) free++;
} }
@ -381,6 +385,7 @@ bool SdVolume::init(Sd2Card* dev, uint8_t part) {
// total blocks for FAT16 or FAT32 // total blocks for FAT16 or FAT32
totalBlocks = fbs->totalSectors16 ? totalBlocks = fbs->totalSectors16 ?
fbs->totalSectors16 : fbs->totalSectors32; fbs->totalSectors16 : fbs->totalSectors32;
// total data blocks // total data blocks
clusterCount_ = totalBlocks - (dataStartBlock_ - volumeStartBlock); clusterCount_ = totalBlocks - (dataStartBlock_ - volumeStartBlock);
@ -391,14 +396,15 @@ bool SdVolume::init(Sd2Card* dev, uint8_t part) {
if (clusterCount_ < 4085) { if (clusterCount_ < 4085) {
fatType_ = 12; fatType_ = 12;
if (!FAT12_SUPPORT) goto fail; if (!FAT12_SUPPORT) goto fail;
} else if (clusterCount_ < 65525) { }
else if (clusterCount_ < 65525) {
fatType_ = 16; fatType_ = 16;
} else { }
else {
rootDirStart_ = fbs->fat32RootCluster; rootDirStart_ = fbs->fat32RootCluster;
fatType_ = 32; fatType_ = 32;
} }
return true; return true;
fail: fail:
return false; return false;
} }

View file

@ -154,11 +154,14 @@ class SdVolume {
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool allocContiguous(uint32_t count, uint32_t* curCluster); bool allocContiguous(uint32_t count, uint32_t* curCluster);
uint8_t blockOfCluster(uint32_t position) const { uint8_t blockOfCluster(uint32_t position) const {
return (position >> 9) & (blocksPerCluster_ - 1);} return (position >> 9) & (blocksPerCluster_ - 1);
}
uint32_t clusterStartBlock(uint32_t cluster) const { uint32_t clusterStartBlock(uint32_t cluster) const {
return dataStartBlock_ + ((cluster - 2) << clusterSizeShift_);} return dataStartBlock_ + ((cluster - 2) << clusterSizeShift_);
}
uint32_t blockNumber(uint32_t cluster, uint32_t position) const { uint32_t blockNumber(uint32_t cluster, uint32_t position) const {
return clusterStartBlock(cluster) + blockOfCluster(position);} return clusterStartBlock(cluster) + blockOfCluster(position);
}
cache_t* cache() {return &cacheBuffer_;} cache_t* cache() {return &cacheBuffer_;}
uint32_t cacheBlockNumber() {return cacheBlockNumber_;} uint32_t cacheBlockNumber() {return cacheBlockNumber_;}
#if USE_MULTIPLE_CARDS #if USE_MULTIPLE_CARDS
@ -187,7 +190,8 @@ class SdVolume {
return cluster >= FAT32EOC_MIN; return cluster >= FAT32EOC_MIN;
} }
bool readBlock(uint32_t block, uint8_t* dst) { bool readBlock(uint32_t block, uint8_t* dst) {
return sdCard_->readBlock(block, dst);} return sdCard_->readBlock(block, dst);
}
bool writeBlock(uint32_t block, const uint8_t* dst) { bool writeBlock(uint32_t block, const uint8_t* dst) {
return sdCard_->writeBlock(block, dst); return sdCard_->writeBlock(block, dst);
} }

View file

@ -248,10 +248,9 @@ void CardReader::release() {
} }
void CardReader::startFileprint() { void CardReader::startFileprint() {
if (cardOK) { if (cardOK)
sdprinting = true; sdprinting = true;
} }
}
void CardReader::pauseSDPrint() { void CardReader::pauseSDPrint() {
if (sdprinting) sdprinting = false; if (sdprinting) sdprinting = false;

View file

@ -50,9 +50,8 @@ void digipot_i2c_init() {
const float digipot_motor_current[] = DIGIPOT_I2C_MOTOR_CURRENTS; const float digipot_motor_current[] = DIGIPOT_I2C_MOTOR_CURRENTS;
Wire.begin(); Wire.begin();
// setup initial currents as defined in Configuration_adv.h // setup initial currents as defined in Configuration_adv.h
for(int i = 0; i < COUNT(digipot_motor_current); i++) { for (int i = 0; i < COUNT(digipot_motor_current); i++)
digipot_i2c_set_current(i, digipot_motor_current[i]); digipot_i2c_set_current(i, digipot_motor_current[i]);
} }
}
#endif //DIGIPOT_I2C #endif //DIGIPOT_I2C

View file

@ -11,44 +11,44 @@
#define START_BMPBYTES 532 // START_BMPWIDTH * START_BMPHEIGHT / 8 #define START_BMPBYTES 532 // START_BMPWIDTH * START_BMPHEIGHT / 8
const unsigned char start_bmp[START_BMPBYTES] PROGMEM = { const unsigned char start_bmp[START_BMPBYTES] PROGMEM = {
0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
,0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
,0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0xff 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF,
,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xff,0xff 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF,
,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xff,0xff 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF,
,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0xff 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF,
,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x3f,0xff 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x3F, 0xFF,
,0xc0,0x0f,0xc0,0xfc,0x00,0x00,0x00,0x00,0x00,0x78,0x18,0x00,0x1f,0xff 0xC0, 0x0F, 0xC0, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x18, 0x00, 0x1F, 0xFF,
,0xc0,0x3f,0xe1,0xff,0x00,0x00,0x00,0x00,0x00,0x78,0x3c,0x00,0x0f,0xff 0xC0, 0x3F, 0xE1, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x3C, 0x00, 0x0F, 0xFF,
,0xc0,0x7f,0xf3,0xff,0x80,0x00,0x00,0x00,0x00,0x78,0x3c,0x00,0x07,0xff 0xC0, 0x7F, 0xF3, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x78, 0x3C, 0x00, 0x07, 0xFF,
,0xc0,0xff,0xff,0xff,0xc0,0x00,0x00,0x00,0x00,0x78,0x3c,0x00,0x03,0xff 0xC0, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x78, 0x3C, 0x00, 0x03, 0xFF,
,0xc1,0xf8,0x7f,0x87,0xe0,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x01,0xff 0xC1, 0xF8, 0x7F, 0x87, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x01, 0xFF,
,0xc1,0xf0,0x3f,0x03,0xe0,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0xff 0xC1, 0xF0, 0x3F, 0x03, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0xFF,
,0xc1,0xe0,0x1e,0x01,0xe0,0x1f,0x00,0x03,0xe0,0x78,0x3c,0x03,0xf0,0x7f 0xC1, 0xE0, 0x1E, 0x01, 0xE0, 0x1F, 0x00, 0x03, 0xE0, 0x78, 0x3C, 0x03, 0xF0, 0x7F,
,0xc1,0xe0,0x1e,0x01,0xe0,0x7f,0xc0,0x0f,0xf8,0x78,0x3c,0x07,0xfc,0x3f 0xC1, 0xE0, 0x1E, 0x01, 0xE0, 0x7F, 0xC0, 0x0F, 0xF8, 0x78, 0x3C, 0x07, 0xFC, 0x3F,
,0xc1,0xe0,0x1e,0x01,0xe1,0xff,0xe0,0x1f,0xfc,0x78,0x3c,0x0f,0xfe,0x1f 0xC1, 0xE0, 0x1E, 0x01, 0xE1, 0xFF, 0xE0, 0x1F, 0xFC, 0x78, 0x3C, 0x0F, 0xFE, 0x1F,
,0xc1,0xe0,0x1e,0x01,0xe3,0xff,0xf0,0x3f,0xfe,0x78,0x3c,0x1f,0xfe,0x0f 0xC1, 0xE0, 0x1E, 0x01, 0xE3, 0xFF, 0xF0, 0x3F, 0xFE, 0x78, 0x3C, 0x1F, 0xFE, 0x0F,
,0xc1,0xe0,0x1e,0x01,0xe3,0xf3,0xf8,0x3f,0x3e,0x78,0x3c,0x3f,0x3f,0x07 0xC1, 0xE0, 0x1E, 0x01, 0xE3, 0xF3, 0xF8, 0x3F, 0x3E, 0x78, 0x3C, 0x3F, 0x3F, 0x07,
,0xc1,0xe0,0x1e,0x01,0xe7,0xe0,0xfc,0x7c,0x1f,0x78,0x3c,0x3e,0x1f,0x07 0xC1, 0xE0, 0x1E, 0x01, 0xE7, 0xE0, 0xFC, 0x7C, 0x1F, 0x78, 0x3C, 0x3E, 0x1F, 0x07,
,0xc1,0xe0,0x1e,0x01,0xe7,0xc0,0x7c,0x7c,0x0f,0x78,0x3c,0x3c,0x0f,0x03 0xC1, 0xE0, 0x1E, 0x01, 0xE7, 0xC0, 0x7C, 0x7C, 0x0F, 0x78, 0x3C, 0x3C, 0x0F, 0x03,
,0xc1,0xe0,0x1e,0x01,0xe7,0x80,0x7c,0x78,0x0f,0x78,0x3c,0x3c,0x0f,0x03 0xC1, 0xE0, 0x1E, 0x01, 0xE7, 0x80, 0x7C, 0x78, 0x0F, 0x78, 0x3C, 0x3C, 0x0F, 0x03,
,0xc1,0xe0,0x1e,0x01,0xe7,0x80,0x3c,0x78,0x00,0x78,0x3c,0x3c,0x0f,0x03 0xC1, 0xE0, 0x1E, 0x01, 0xE7, 0x80, 0x3C, 0x78, 0x00, 0x78, 0x3C, 0x3C, 0x0F, 0x03,
,0xc1,0xe0,0x1e,0x01,0xe7,0x80,0x3c,0x78,0x00,0x78,0x3c,0x3c,0x0f,0x03 0xC1, 0xE0, 0x1E, 0x01, 0xE7, 0x80, 0x3C, 0x78, 0x00, 0x78, 0x3C, 0x3C, 0x0F, 0x03,
,0xc1,0xe0,0x1e,0x01,0xe7,0x80,0x3c,0x78,0x00,0x78,0x3c,0x3c,0x0f,0x03 0xC1, 0xE0, 0x1E, 0x01, 0xE7, 0x80, 0x3C, 0x78, 0x00, 0x78, 0x3C, 0x3C, 0x0F, 0x03,
,0xc1,0xe0,0x1e,0x01,0xe7,0xc0,0x3c,0x78,0x00,0x78,0x3c,0x3c,0x0f,0x03 0xC1, 0xE0, 0x1E, 0x01, 0xE7, 0xC0, 0x3C, 0x78, 0x00, 0x78, 0x3C, 0x3C, 0x0F, 0x03,
,0xc1,0xe0,0x1e,0x01,0xe3,0xe0,0x3c,0x78,0x00,0x7c,0x3c,0x3c,0x0f,0x03 0xC1, 0xE0, 0x1E, 0x01, 0xE3, 0xE0, 0x3C, 0x78, 0x00, 0x7C, 0x3C, 0x3C, 0x0F, 0x03,
,0xc1,0xe0,0x1e,0x01,0xe3,0xff,0x3f,0xf8,0x00,0x7f,0xbc,0x3c,0x0f,0x03 0xC1, 0xE0, 0x1E, 0x01, 0xE3, 0xFF, 0x3F, 0xF8, 0x00, 0x7F, 0xBC, 0x3C, 0x0F, 0x03,
,0xc1,0xe0,0x1e,0x01,0xe1,0xff,0x3f,0xf8,0x00,0x3f,0xbf,0xfc,0x0f,0x03 0xC1, 0xE0, 0x1E, 0x01, 0xE1, 0xFF, 0x3F, 0xF8, 0x00, 0x3F, 0xBF, 0xFC, 0x0F, 0x03,
,0xc1,0xe0,0x1e,0x01,0xe0,0xff,0x3f,0xf8,0x00,0x1f,0xbf,0xfc,0x0f,0x03 0xC1, 0xE0, 0x1E, 0x01, 0xE0, 0xFF, 0x3F, 0xF8, 0x00, 0x1F, 0xBF, 0xFC, 0x0F, 0x03,
,0xc1,0xe0,0x1e,0x01,0xe0,0x7f,0x3f,0xf8,0x00,0x0f,0xbf,0xfc,0x0f,0x03 0xC1, 0xE0, 0x1E, 0x01, 0xE0, 0x7F, 0x3F, 0xF8, 0x00, 0x0F, 0xBF, 0xFC, 0x0F, 0x03,
,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E,
,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1c 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C,
,0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78,
,0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0,
,0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x80 }; 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80 };
#else #else
#define START_BMPWIDTH 56 #define START_BMPWIDTH 56
#define START_BMPHEIGHT 19 #define START_BMPHEIGHT 19
@ -56,25 +56,25 @@
#define START_BMPBYTES 133 // START_BMPWIDTH * START_BMPHEIGHT / 8 #define START_BMPBYTES 133 // START_BMPWIDTH * START_BMPHEIGHT / 8
const unsigned char start_bmp[START_BMPBYTES] PROGMEM = { const unsigned char start_bmp[START_BMPBYTES] PROGMEM = {
0x1f,0xff,0xff,0xff,0xff,0xff,0xff 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
,0x60,0x00,0x00,0x00,0x00,0x01,0xff 0x60, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF,
,0x40,0x00,0x00,0x00,0x00,0x00,0xff 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
,0x80,0x00,0x00,0x00,0x00,0x00,0x7f 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F,
,0x83,0xcf,0x00,0x00,0x0c,0x30,0x3f 0x83, 0xCF, 0x00, 0x00, 0x0C, 0x30, 0x3F,
,0x87,0xff,0x80,0x00,0x0c,0x30,0x1f 0x87, 0xFF, 0x80, 0x00, 0x0C, 0x30, 0x1F,
,0x86,0x79,0x80,0x00,0x0c,0x00,0x0f 0x86, 0x79, 0x80, 0x00, 0x0C, 0x00, 0x0F,
,0x8c,0x30,0xc7,0x83,0x8c,0x30,0xe7 0x8C, 0x30, 0xC7, 0x83, 0x8C, 0x30, 0xE7,
,0x8c,0x30,0xcf,0xc7,0xcc,0x31,0xf3 0x8C, 0x30, 0xCF, 0xC7, 0xCC, 0x31, 0xF3,
,0x8c,0x30,0xdc,0xec,0xec,0x33,0xb9 0x8C, 0x30, 0xDC, 0xEC, 0xEC, 0x33, 0xB9,
,0x8c,0x30,0xd8,0x6c,0x6c,0x33,0x19 0x8C, 0x30, 0xD8, 0x6C, 0x6C, 0x33, 0x19,
,0x8c,0x30,0xd0,0x6c,0x0c,0x33,0x19 0x8C, 0x30, 0xD0, 0x6C, 0x0C, 0x33, 0x19,
,0x8c,0x30,0xd8,0x6c,0x0c,0x33,0x19 0x8C, 0x30, 0xD8, 0x6C, 0x0C, 0x33, 0x19,
,0x8c,0x30,0xdc,0x6c,0x0e,0x3b,0x19 0x8C, 0x30, 0xDC, 0x6C, 0x0E, 0x3B, 0x19,
,0x8c,0x30,0xcf,0x7c,0x07,0x9f,0x19 0x8C, 0x30, 0xCF, 0x7C, 0x07, 0x9F, 0x19,
,0x8c,0x30,0xc7,0x7c,0x03,0x8f,0x19 0x8C, 0x30, 0xC7, 0x7C, 0x03, 0x8F, 0x19,
,0x40,0x00,0x00,0x00,0x00,0x00,0x02 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
,0x60,0x00,0x00,0x00,0x00,0x00,0x06 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
,0x1f,0xff,0xff,0xff,0xff,0xff,0xf8 }; 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8 };
#endif #endif
#endif #endif
@ -236,4 +236,3 @@
}; };
#endif // Extruders #endif // Extruders

View file

@ -154,4 +154,5 @@ const u8g_fntpgm_uint8_t u8g_font_6x9[2300] U8G_SECTION(".progmem.u8g_font_6x9")
0, 144, 144, 144, 112, 4, 6, 6, 6, 1, 0, 80, 0, 144, 144, 144, 0, 144, 144, 144, 112, 4, 6, 6, 6, 1, 0, 80, 0, 144, 144, 144,
112, 4, 9, 9, 6, 1, 254, 32, 64, 0, 144, 144, 144, 112, 144, 96, 112, 4, 9, 9, 6, 1, 254, 32, 64, 0, 144, 144, 144, 112, 144, 96,
4, 8, 8, 6, 1, 254, 128, 128, 224, 144, 144, 224, 128, 128, 4, 8, 4, 8, 8, 6, 1, 254, 128, 128, 224, 144, 144, 224, 128, 128, 4, 8,
8,6,1,254,80,0,144,144,144,112,144,96}; 8, 6, 1, 254, 80, 0, 144, 144, 144, 112, 144, 96
};

View file

@ -168,4 +168,5 @@ const u8g_fntpgm_uint8_t HD44780_C_5x7[2522] U8G_SECTION(".progmem.HD44780_C_5x7
32, 112, 32, 5, 8, 8, 6, 0, 0, 16, 144, 80, 48, 80, 144, 16, 32, 112, 32, 5, 8, 8, 6, 0, 0, 16, 144, 80, 48, 80, 144, 16,
56, 5, 8, 8, 6, 0, 0, 48, 72, 32, 80, 80, 32, 144, 96, 5, 56, 5, 8, 8, 6, 0, 0, 48, 72, 32, 80, 80, 32, 144, 96, 5,
7, 7, 6, 0, 0, 120, 168, 168, 120, 40, 40, 40, 5, 8, 8, 6, 7, 7, 6, 0, 0, 120, 168, 168, 120, 40, 40, 40, 5, 8, 8, 6,
0,0,248,248,248,248,248,248,248,248}; 0, 0, 248, 248, 248, 248, 248, 248, 248, 248
};

View file

@ -166,4 +166,5 @@ const u8g_fntpgm_uint8_t HD44780_J_5x7[2491] U8G_SECTION(".progmem.HD44780_J_5x7
32, 248, 32, 32, 5, 5, 5, 6, 0, 0, 248, 64, 120, 72, 136, 5, 32, 248, 32, 32, 5, 5, 5, 6, 0, 0, 248, 64, 120, 72, 136, 5,
5, 5, 6, 0, 0, 248, 168, 248, 136, 136, 5, 5, 5, 6, 0, 1, 5, 5, 6, 0, 0, 248, 168, 248, 136, 136, 5, 5, 5, 6, 0, 1,
32, 0, 248, 0, 32, 0, 0, 0, 6, 0, 8, 6, 10, 10, 6, 0, 32, 0, 248, 0, 32, 0, 0, 0, 6, 0, 8, 6, 10, 10, 6, 0,
254,252,252,252,252,252,252,252,252,252,252}; 254, 252, 252, 252, 252, 252, 252, 252, 252, 252, 252
};

View file

@ -200,4 +200,5 @@ const u8g_fntpgm_uint8_t HD44780_W_5x7[3034] U8G_SECTION(".progmem.HD44780_W_5x7
136, 152, 104, 5, 7, 7, 6, 0, 0, 80, 0, 136, 136, 136, 152, 104, 136, 152, 104, 5, 7, 7, 6, 0, 0, 80, 0, 136, 136, 136, 152, 104,
5, 9, 9, 6, 0, 255, 16, 32, 0, 136, 136, 136, 248, 8, 112, 4, 5, 9, 9, 6, 0, 255, 16, 32, 0, 136, 136, 136, 248, 8, 112, 4,
7, 7, 6, 1, 0, 192, 64, 96, 80, 96, 64, 224, 5, 8, 8, 6, 7, 7, 6, 1, 0, 192, 64, 96, 80, 96, 64, 224, 5, 8, 8, 6,
0,255,80,0,136,136,136,248,8,112}; 0, 255, 80, 0, 136, 136, 136, 248, 8, 112
};

View file

@ -267,4 +267,5 @@ const u8g_fntpgm_uint8_t ISO10646_CN[4105] U8G_SECTION(".progmem.ISO10646_CN") =
128, 11, 11, 22, 12, 0, 255, 39, 192, 36, 64, 247, 192, 46, 224, 42, 128, 11, 11, 22, 12, 0, 255, 39, 192, 36, 64, 247, 192, 46, 224, 42,
160, 62, 224, 225, 0, 47, 224, 35, 128, 37, 64, 105, 32, 11, 11, 22, 160, 62, 224, 225, 0, 47, 224, 35, 128, 37, 64, 105, 32, 11, 11, 22,
12, 0, 255, 20, 0, 39, 224, 42, 0, 98, 0, 163, 192, 34, 0, 34, 12, 0, 255, 20, 0, 39, 224, 42, 0, 98, 0, 163, 192, 34, 0, 34,
0,35,224,34,0,34,0,34,0}; 0, 35, 224, 34, 0, 34, 0, 34, 0
};

View file

@ -170,4 +170,5 @@ const u8g_fntpgm_uint8_t ISO10646_Kana_5x7[2549] U8G_SECTION(".progmem.ISO10646_
16, 32, 2, 2, 2, 6, 2, 2, 192, 192, 5, 1, 1, 6, 0, 3, 16, 32, 2, 2, 2, 6, 2, 2, 192, 192, 5, 1, 1, 6, 0, 3,
248, 5, 5, 5, 6, 0, 1, 128, 64, 32, 16, 8, 5, 6, 6, 6, 248, 5, 5, 5, 6, 0, 1, 128, 64, 32, 16, 8, 5, 6, 6, 6,
0, 1, 40, 128, 64, 32, 16, 8, 5, 7, 7, 6, 0, 0, 248, 8, 0, 1, 40, 128, 64, 32, 16, 8, 5, 7, 7, 6, 0, 0, 248, 8,
8,8,8,8,8}; 8, 8, 8, 8, 8
};

View file

@ -19,4 +19,5 @@ const u8g_fntpgm_uint8_t Marlin_symbols[140] U8G_SECTION(".progmem.Marlin_symbol
184, 136, 136, 112, 32, 5, 9, 9, 6, 0, 255, 224, 128, 192, 176, 168, 184, 136, 136, 112, 32, 5, 9, 9, 6, 0, 255, 224, 128, 192, 176, 168,
40, 48, 40, 40, 5, 9, 9, 6, 0, 255, 248, 168, 136, 136, 136, 136, 40, 48, 40, 40, 5, 9, 9, 6, 0, 255, 248, 168, 136, 136, 136, 136,
136, 168, 248, 5, 10, 10, 6, 0, 254, 32, 80, 80, 80, 80, 136, 168, 136, 168, 248, 5, 10, 10, 6, 0, 254, 32, 80, 80, 80, 80, 136, 168,
168,136,112,3,3,3,6,0,3,64,160,64}; 168, 136, 112, 3, 3, 3, 6, 0, 3, 64, 160, 64
};

View file

@ -448,7 +448,7 @@ static void _drawmenu_setting_edit_generic(bool isSelected, uint8_t row, const c
lcd_print(':'); lcd_print(':');
while (n--) lcd_print(' '); while (n--) lcd_print(' ');
u8g.setPrintPos(LCD_PIXEL_WIDTH - DOG_CHAR_WIDTH * vallen, (row + 1) * DOG_CHAR_HEIGHT); u8g.setPrintPos(LCD_PIXEL_WIDTH - DOG_CHAR_WIDTH * vallen, (row + 1) * DOG_CHAR_HEIGHT);
if (pgm) { lcd_printPGM(data); } else { lcd_print((char *)data); } if (pgm) lcd_printPGM(data); else lcd_print((char*)data);
} }
#define lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, false) #define lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, false)

View file

@ -1,4 +1,4 @@
The fonts are created with Fony.exe (http://hukka.ncn.fi/?fony) because Fontforge didn't do what I want (probably lack off experience). The fonts are created with Fony.exe (http://hukka.ncn.fi/?fony) because Fontforge didn't do what I want (probably lack of experience).
In Fony export the fonts to bdf-format. Maybe another one can edit them with Fontforge. In Fony export the fonts to bdf-format. Maybe another one can edit them with Fontforge.
Then run make_fonts.bat what calls bdf2u8g.exe with the needed parameters to produce the .h files. Then run make_fonts.bat what calls bdf2u8g.exe with the needed parameters to produce the .h files.
The .h files must be edited to replace '#include "u8g.h"' with '#include <utility/u8g.h>', replace 'U8G_FONT_SECTION' with 'U8G_SECTION', insert '.progmem.' right behind the first '"' and moved to the main directory. The .h files must be edited to replace '#include "u8g.h"' with '#include <utility/u8g.h>', replace 'U8G_FONT_SECTION' with 'U8G_SECTION', insert '.progmem.' right behind the first '"' and moved to the main directory.

View file

@ -81,8 +81,8 @@
#error BUILD_VERSION Information must be specified #error BUILD_VERSION Information must be specified
#endif #endif
#ifndef MACHINE_UUID #ifndef UUID
#define MACHINE_UUID "00000000-0000-0000-0000-000000000000" #define UUID "00000000-0000-0000-0000-000000000000"
#endif #endif
@ -122,7 +122,7 @@
#define MSG_INVALID_EXTRUDER "Invalid extruder" #define MSG_INVALID_EXTRUDER "Invalid extruder"
#define MSG_INVALID_SOLENOID "Invalid solenoid" #define MSG_INVALID_SOLENOID "Invalid solenoid"
#define MSG_ERR_NO_THERMISTORS "No thermistors - no temperature" #define MSG_ERR_NO_THERMISTORS "No thermistors - no temperature"
#define MSG_M115_REPORT "FIRMWARE_NAME:Marlin " DETAILED_BUILD_VERSION " SOURCE_CODE_URL:" SOURCE_CODE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID "\n" #define MSG_M115_REPORT "FIRMWARE_NAME:Marlin " DETAILED_BUILD_VERSION " SOURCE_CODE_URL:" SOURCE_CODE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" UUID "\n"
#define MSG_COUNT_X " Count X: " #define MSG_COUNT_X " Count X: "
#define MSG_ERR_KILLED "Printer halted. kill() called!" #define MSG_ERR_KILLED "Printer halted. kill() called!"
#define MSG_ERR_STOPPED "Printer stopped due to errors. Fix the error and use M999 to restart. (Temperature is reset. Set it after restarting)" #define MSG_ERR_STOPPED "Printer stopped due to errors. Fix the error and use M999 to restart. (Temperature is reset. Set it after restarting)"

View file

@ -447,8 +447,6 @@
#ifndef MSG_BED_DONE #ifndef MSG_BED_DONE
#define MSG_BED_DONE "Bed done." #define MSG_BED_DONE "Bed done."
#endif #endif
#if ENABLED(DELTA_CALIBRATION_MENU)
#ifndef MSG_DELTA_CALIBRATE #ifndef MSG_DELTA_CALIBRATE
#define MSG_DELTA_CALIBRATE "Delta Calibration" #define MSG_DELTA_CALIBRATE "Delta Calibration"
#endif #endif
@ -464,6 +462,5 @@
#ifndef MSG_DELTA_CALIBRATE_CENTER #ifndef MSG_DELTA_CALIBRATE_CENTER
#define MSG_DELTA_CALIBRATE_CENTER "Calibrate Center" #define MSG_DELTA_CALIBRATE_CENTER "Calibrate Center"
#endif #endif
#endif // DELTA_CALIBRATION_MENU
#endif // LANGUAGE_EN_H #endif // LANGUAGE_EN_H

View file

@ -280,7 +280,6 @@ void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *n
if (previous->entry_speed < current->entry_speed) { if (previous->entry_speed < current->entry_speed) {
double entry_speed = min(current->entry_speed, double entry_speed = min(current->entry_speed,
max_allowable_speed(-previous->acceleration, previous->entry_speed, previous->millimeters)); max_allowable_speed(-previous->acceleration, previous->entry_speed, previous->millimeters));
// Check for junction speed change // Check for junction speed change
if (current->entry_speed != entry_speed) { if (current->entry_speed != entry_speed) {
current->entry_speed = entry_speed; current->entry_speed = entry_speed;
@ -395,7 +394,7 @@ void plan_init() {
oldt = t; oldt = t;
setTargetHotend0(t); setTargetHotend0(t);
} }
#endif #endif //AUTOTEMP
void check_axes_activity() { void check_axes_activity() {
unsigned char axis_active[NUM_AXIS] = { 0 }, unsigned char axis_active[NUM_AXIS] = { 0 },
@ -905,7 +904,6 @@ float junction_deviation = 0.1;
double cos_theta = - previous_unit_vec[X_AXIS] * unit_vec[X_AXIS] double cos_theta = - previous_unit_vec[X_AXIS] * unit_vec[X_AXIS]
- previous_unit_vec[Y_AXIS] * unit_vec[Y_AXIS] - previous_unit_vec[Y_AXIS] * unit_vec[Y_AXIS]
- previous_unit_vec[Z_AXIS] * unit_vec[Z_AXIS] ; - previous_unit_vec[Z_AXIS] * unit_vec[Z_AXIS] ;
// Skip and use default max junction speed for 0 degree acute junction. // Skip and use default max junction speed for 0 degree acute junction.
if (cos_theta < 0.95) { if (cos_theta < 0.95) {
vmax_junction = min(previous_nominal_speed, block->nominal_speed); vmax_junction = min(previous_nominal_speed, block->nominal_speed);

View file

@ -34,17 +34,7 @@ int i4_min ( int i1, int i2 )
Output, int I4_MIN, the smaller of I1 and I2. Output, int I4_MIN, the smaller of I1 and I2.
*/ */
{ {
int value; return (i1 < i2) ? i1 : i2;
if ( i1 < i2 )
{
value = i1;
}
else
{
value = i2;
}
return value;
} }
double r8_epsilon(void) double r8_epsilon(void)
@ -81,7 +71,6 @@ double r8_epsilon ( void )
*/ */
{ {
const double value = 2.220446049250313E-016; const double value = 2.220446049250313E-016;
return value; return value;
} }
@ -112,17 +101,7 @@ double r8_max ( double x, double y )
Output, double R8_MAX, the maximum of X and Y. Output, double R8_MAX, the maximum of X and Y.
*/ */
{ {
double value; return (y < x) ? x : y;
if ( y < x )
{
value = x;
}
else
{
value = y;
}
return value;
} }
double r8_abs(double x) double r8_abs(double x)
@ -152,17 +131,7 @@ double r8_abs ( double x )
Output, double R8_ABS, the absolute value of X. Output, double R8_ABS, the absolute value of X.
*/ */
{ {
double value; return (x < 0.0) ? -x : x;
if ( 0.0 <= x )
{
value = + x;
}
else
{
value = - x;
}
return value;
} }
double r8_sign(double x) double r8_sign(double x)
@ -192,17 +161,7 @@ double r8_sign ( double x )
Output, double R8_SIGN, the sign of X. Output, double R8_SIGN, the sign of X.
*/ */
{ {
double value; return (x < 0.0) ? -1.0 : 1.0;
if ( x < 0.0 )
{
value = - 1.0;
}
else
{
value = + 1.0;
}
return value;
} }
double r8mat_amax(int m, int n, double a[]) double r8mat_amax(int m, int n, double a[])
@ -241,22 +200,13 @@ double r8mat_amax ( int m, int n, double a[] )
Output, double R8MAT_AMAX, the maximum absolute value entry of A. Output, double R8MAT_AMAX, the maximum absolute value entry of A.
*/ */
{ {
int i; double value = r8_abs(a[0 + 0 * m]);
int j; for (int j = 0; j < n; j++) {
double value; for (int i = 0; i < m; i++) {
value = r8_abs ( a[0+0*m] );
for ( j = 0; j < n; j++ )
{
for ( i = 0; i < m; i++ )
{
if (value < r8_abs(a[i + j * m])) if (value < r8_abs(a[i + j * m]))
{
value = r8_abs(a[i + j * m]); value = r8_abs(a[i + j * m]);
} }
} }
}
return value; return value;
} }
@ -294,17 +244,11 @@ void r8mat_copy( double a2[], int m, int n, double a1[] )
Output, double R8MAT_COPY_NEW[M*N], the copy of A1. Output, double R8MAT_COPY_NEW[M*N], the copy of A1.
*/ */
{ {
int i; for (int j = 0; j < n; j++) {
int j; for (int i = 0; i < m; i++)
for ( j = 0; j < n; j++ )
{
for ( i = 0; i < m; i++ )
{
a2[i + j * m] = a1[i + j * m]; a2[i + j * m] = a1[i + j * m];
} }
} }
}
/******************************************************************************/ /******************************************************************************/
@ -360,46 +304,23 @@ void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy )
Input, int INCY, the increment between successive entries of DY. Input, int INCY, the increment between successive entries of DY.
*/ */
{ {
int i; if (n <= 0 || da == 0.0) return;
int ix;
int iy;
int m;
if ( n <= 0 ) int i, ix, iy, m;
{
return;
}
if ( da == 0.0 )
{
return;
}
/* /*
Code for unequal increments or equal increments Code for unequal increments or equal increments
not equal to 1. not equal to 1.
*/ */
if ( incx != 1 || incy != 1 ) if (incx != 1 || incy != 1) {
{
if (0 <= incx) if (0 <= incx)
{
ix = 0; ix = 0;
}
else else
{
ix = (- n + 1) * incx; ix = (- n + 1) * incx;
}
if (0 <= incy) if (0 <= incy)
{
iy = 0; iy = 0;
}
else else
{
iy = (- n + 1) * incy; iy = (- n + 1) * incy;
} for (i = 0; i < n; i++) {
for ( i = 0; i < n; i++ )
{
dy[iy] = dy[iy] + da * dx[ix]; dy[iy] = dy[iy] + da * dx[ix];
ix = ix + incx; ix = ix + incx;
iy = iy + incy; iy = iy + incy;
@ -408,24 +329,17 @@ void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy )
/* /*
Code for both increments equal to 1. Code for both increments equal to 1.
*/ */
else else {
{
m = n % 4; m = n % 4;
for (i = 0; i < m; i++) for (i = 0; i < m; i++)
{
dy[i] = dy[i] + da * dx[i]; dy[i] = dy[i] + da * dx[i];
} for (i = m; i < n; i = i + 4) {
for ( i = m; i < n; i = i + 4 )
{
dy[i ] = dy[i ] + da * dx[i ]; dy[i ] = dy[i ] + da * dx[i ];
dy[i + 1] = dy[i + 1] + da * dx[i + 1]; dy[i + 1] = dy[i + 1] + da * dx[i + 1];
dy[i + 2] = dy[i + 2] + da * dx[i + 2]; dy[i + 2] = dy[i + 2] + da * dx[i + 2];
dy[i + 3] = dy[i + 3] + da * dx[i + 3]; dy[i + 3] = dy[i + 3] + da * dx[i + 3];
} }
} }
return;
} }
/******************************************************************************/ /******************************************************************************/
@ -481,45 +395,21 @@ double ddot ( int n, double dx[], int incx, double dy[], int incy )
entries of DX and DY. entries of DX and DY.
*/ */
{ {
double dtemp;
int i;
int ix;
int iy;
int m;
dtemp = 0.0; if (n <= 0) return 0.0;
int i, m;
double dtemp = 0.0;
if ( n <= 0 )
{
return dtemp;
}
/* /*
Code for unequal increments or equal increments Code for unequal increments or equal increments
not equal to 1. not equal to 1.
*/ */
if ( incx != 1 || incy != 1 ) if (incx != 1 || incy != 1) {
{ int ix = (incx >= 0) ? 0 : (-n + 1) * incx,
if ( 0 <= incx ) iy = (incy >= 0) ? 0 : (-n + 1) * incy;
{ for (i = 0; i < n; i++) {
ix = 0; dtemp += dx[ix] * dy[iy];
}
else
{
ix = ( - n + 1 ) * incx;
}
if ( 0 <= incy )
{
iy = 0;
}
else
{
iy = ( - n + 1 ) * incy;
}
for ( i = 0; i < n; i++ )
{
dtemp = dtemp + dx[ix] * dy[iy];
ix = ix + incx; ix = ix + incx;
iy = iy + incy; iy = iy + incy;
} }
@ -527,18 +417,12 @@ double ddot ( int n, double dx[], int incx, double dy[], int incy )
/* /*
Code for both increments equal to 1. Code for both increments equal to 1.
*/ */
else else {
{
m = n % 5; m = n % 5;
for (i = 0; i < m; i++) for (i = 0; i < m; i++)
{ dtemp += dx[i] * dy[i];
dtemp = dtemp + dx[i] * dy[i]; for (i = m; i < n; i = i + 5) {
} dtemp += dx[i] * dy[i]
for ( i = m; i < n; i = i + 5 )
{
dtemp = dtemp + dx[i ] * dy[i ]
+ dx[i + 1] * dy[i + 1] + dx[i + 1] * dy[i + 1]
+ dx[i + 2] * dy[i + 2] + dx[i + 2] * dy[i + 2]
+ dx[i + 3] * dy[i + 3] + dx[i + 3] * dy[i + 3]
@ -596,48 +480,27 @@ double dnrm2 ( int n, double x[], int incx )
Output, double DNRM2, the Euclidean norm of X. Output, double DNRM2, the Euclidean norm of X.
*/ */
{ {
double absxi;
int i;
int ix;
double norm; double norm;
double scale;
double ssq;
if (n < 1 || incx < 1) if (n < 1 || incx < 1)
{
norm = 0.0; norm = 0.0;
}
else if (n == 1) else if (n == 1)
{
norm = r8_abs(x[0]); norm = r8_abs(x[0]);
} else {
else double scale = 0.0, ssq = 1.0;
{ int ix = 0;
scale = 0.0; for (int i = 0; i < n; i++) {
ssq = 1.0; if (x[ix] != 0.0) {
ix = 0; double absxi = r8_abs(x[ix]);
if (scale < absxi) {
for ( i = 0; i < n; i++ )
{
if ( x[ix] != 0.0 )
{
absxi = r8_abs ( x[ix] );
if ( scale < absxi )
{
ssq = 1.0 + ssq * (scale / absxi) * (scale / absxi); ssq = 1.0 + ssq * (scale / absxi) * (scale / absxi);
scale = absxi; scale = absxi;
} } else
else
{
ssq = ssq + (absxi / scale) * (absxi / scale); ssq = ssq + (absxi / scale) * (absxi / scale);
} }
ix += incx;
} }
ix = ix + incx;
}
norm = scale * sqrt(ssq); norm = scale * sqrt(ssq);
} }
return norm; return norm;
} }
/******************************************************************************/ /******************************************************************************/
@ -717,34 +580,22 @@ void dqrank ( double a[], int lda, int m, int n, double tol, int *kr,
the QR factorization. the QR factorization.
*/ */
{ {
int i;
int j;
int job;
int k;
double work[n]; double work[n];
for ( i = 0; i < n; i++ ) for (int i = 0; i < n; i++)
{
jpvt[i] = 0; jpvt[i] = 0;
}
job = 1; int job = 1;
dqrdc(a, lda, m, n, qraux, jpvt, work, job); dqrdc(a, lda, m, n, qraux, jpvt, work, job);
*kr = 0; *kr = 0;
k = i4_min ( m, n ); int k = i4_min(m, n);
for (int j = 0; j < k; j++) {
for ( j = 0; j < k; j++ )
{
if (r8_abs(a[j + j * lda]) <= tol * r8_abs(a[0 + 0 * lda])) if (r8_abs(a[j + j * lda]) <= tol * r8_abs(a[0 + 0 * lda]))
{
return; return;
}
*kr = j + 1; *kr = j + 1;
} }
return;
} }
/******************************************************************************/ /******************************************************************************/
@ -829,60 +680,33 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[],
nonzero, pivoting is done. nonzero, pivoting is done.
*/ */
{ {
int j;
int jp; int jp;
int l; int j;
int lup; int lup;
int maxj; int maxj;
double maxnrm; double maxnrm, nrmxl, t, tt;
double nrmxl;
int pl;
int pu;
int swapj;
double t;
double tt;
pl = 1; int pl = 1, pu = 0;
pu = 0;
/* /*
If pivoting is requested, rearrange the columns. If pivoting is requested, rearrange the columns.
*/ */
if ( job != 0 ) if (job != 0) {
{ for (j = 1; j <= p; j++) {
for ( j = 1; j <= p; j++ ) int swapj = (0 < jpvt[j - 1]);
{ jpvt[j - 1] = (jpvt[j - 1] < 0) ? -j : j;
swapj = ( 0 < jpvt[j-1] ); if (swapj) {
if ( jpvt[j-1] < 0 )
{
jpvt[j-1] = -j;
}
else
{
jpvt[j-1] = j;
}
if ( swapj )
{
if (j != pl) if (j != pl)
{
dswap(n, a + 0 + (pl - 1)*lda, 1, a + 0 + (j - 1), 1); dswap(n, a + 0 + (pl - 1)*lda, 1, a + 0 + (j - 1), 1);
}
jpvt[j - 1] = jpvt[pl - 1]; jpvt[j - 1] = jpvt[pl - 1];
jpvt[pl - 1] = j; jpvt[pl - 1] = j;
pl = pl + 1; pl++;
} }
} }
pu = p; pu = p;
for (j = p; 1 <= j; j--) {
for ( j = p; 1 <= j; j-- ) if (jpvt[j - 1] < 0) {
{
if ( jpvt[j-1] < 0 )
{
jpvt[j - 1] = -jpvt[j - 1]; jpvt[j - 1] = -jpvt[j - 1];
if (j != pu) {
if ( j != pu )
{
dswap(n, a + 0 + (pu - 1)*lda, 1, a + 0 + (j - 1)*lda, 1); dswap(n, a + 0 + (pu - 1)*lda, 1, a + 0 + (j - 1)*lda, 1);
jp = jpvt[pu - 1]; jp = jpvt[pu - 1];
jpvt[pu - 1] = jpvt[j - 1]; jpvt[pu - 1] = jpvt[j - 1];
@ -896,39 +720,27 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[],
Compute the norms of the free columns. Compute the norms of the free columns.
*/ */
for (j = pl; j <= pu; j++) for (j = pl; j <= pu; j++)
{
qraux[j - 1] = dnrm2(n, a + 0 + (j - 1) * lda, 1); qraux[j - 1] = dnrm2(n, a + 0 + (j - 1) * lda, 1);
}
for (j = pl; j <= pu; j++) for (j = pl; j <= pu; j++)
{
work[j - 1] = qraux[j - 1]; work[j - 1] = qraux[j - 1];
}
/* /*
Perform the Householder reduction of A. Perform the Householder reduction of A.
*/ */
lup = i4_min(n, p); lup = i4_min(n, p);
for (int l = 1; l <= lup; l++) {
for ( l = 1; l <= lup; l++ )
{
/* /*
Bring the column of largest norm into the pivot position. Bring the column of largest norm into the pivot position.
*/ */
if ( pl <= l && l < pu ) if (pl <= l && l < pu) {
{
maxnrm = 0.0; maxnrm = 0.0;
maxj = l; maxj = l;
for ( j = l; j <= pu; j++ ) for (j = l; j <= pu; j++) {
{ if (maxnrm < qraux[j - 1]) {
if ( maxnrm < qraux[j-1] )
{
maxnrm = qraux[j - 1]; maxnrm = qraux[j - 1];
maxj = j; maxj = j;
} }
} }
if (maxj != l) {
if ( maxj != l )
{
dswap(n, a + 0 + (l - 1)*lda, 1, a + 0 + (maxj - 1)*lda, 1); dswap(n, a + 0 + (l - 1)*lda, 1, a + 0 + (maxj - 1)*lda, 1);
qraux[maxj - 1] = qraux[l - 1]; qraux[maxj - 1] = qraux[l - 1];
work[maxj - 1] = work[l - 1]; work[maxj - 1] = work[l - 1];
@ -941,44 +753,29 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[],
Compute the Householder transformation for column L. Compute the Householder transformation for column L.
*/ */
qraux[l - 1] = 0.0; qraux[l - 1] = 0.0;
if (l != n) {
if ( l != n )
{
nrmxl = dnrm2(n - l + 1, a + l - 1 + (l - 1) * lda, 1); nrmxl = dnrm2(n - l + 1, a + l - 1 + (l - 1) * lda, 1);
if (nrmxl != 0.0) {
if ( nrmxl != 0.0 )
{
if (a[l - 1 + (l - 1)*lda] != 0.0) if (a[l - 1 + (l - 1)*lda] != 0.0)
{
nrmxl = nrmxl * r8_sign(a[l - 1 + (l - 1) * lda]); nrmxl = nrmxl * r8_sign(a[l - 1 + (l - 1) * lda]);
}
dscal(n - l + 1, 1.0 / nrmxl, a + l - 1 + (l - 1)*lda, 1); dscal(n - l + 1, 1.0 / nrmxl, a + l - 1 + (l - 1)*lda, 1);
a[l - 1 + (l - 1)*lda] = 1.0 + a[l - 1 + (l - 1) * lda]; a[l - 1 + (l - 1)*lda] = 1.0 + a[l - 1 + (l - 1) * lda];
/* /*
Apply the transformation to the remaining columns, updating the norms. Apply the transformation to the remaining columns, updating the norms.
*/ */
for ( j = l + 1; j <= p; j++ ) for (j = l + 1; j <= p; j++) {
{
t = -ddot(n - l + 1, a + l - 1 + (l - 1) * lda, 1, a + l - 1 + (j - 1) * lda, 1) t = -ddot(n - l + 1, a + l - 1 + (l - 1) * lda, 1, a + l - 1 + (j - 1) * lda, 1)
/ a[l - 1 + (l - 1) * lda]; / a[l - 1 + (l - 1) * lda];
daxpy(n - l + 1, t, a + l - 1 + (l - 1)*lda, 1, a + l - 1 + (j - 1)*lda, 1); daxpy(n - l + 1, t, a + l - 1 + (l - 1)*lda, 1, a + l - 1 + (j - 1)*lda, 1);
if (pl <= j && j <= pu) {
if ( pl <= j && j <= pu ) if (qraux[j - 1] != 0.0) {
{
if ( qraux[j-1] != 0.0 )
{
tt = 1.0 - pow(r8_abs(a[l - 1 + (j - 1) * lda]) / qraux[j - 1], 2); tt = 1.0 - pow(r8_abs(a[l - 1 + (j - 1) * lda]) / qraux[j - 1], 2);
tt = r8_max(tt, 0.0); tt = r8_max(tt, 0.0);
t = tt; t = tt;
tt = 1.0 + 0.05 * tt * pow(qraux[j - 1] / work[j - 1], 2); tt = 1.0 + 0.05 * tt * pow(qraux[j - 1] / work[j - 1], 2);
if (tt != 1.0) if (tt != 1.0)
{
qraux[j - 1] = qraux[j - 1] * sqrt(t); qraux[j - 1] = qraux[j - 1] * sqrt(t);
} else {
else
{
qraux[j - 1] = dnrm2(n - l, a + l + (j - 1) * lda, 1); qraux[j - 1] = dnrm2(n - l, a + l + (j - 1) * lda, 1);
work[j - 1] = qraux[j - 1]; work[j - 1] = qraux[j - 1];
} }
@ -993,7 +790,6 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[],
} }
} }
} }
return;
} }
/******************************************************************************/ /******************************************************************************/
@ -1106,9 +902,7 @@ int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[],
*/ */
{ {
int ind; int ind;
if (lda < m) {
if ( lda < m )
{
/*fprintf ( stderr, "\n" ); /*fprintf ( stderr, "\n" );
fprintf ( stderr, "DQRLS - Fatal error!\n" ); fprintf ( stderr, "DQRLS - Fatal error!\n" );
fprintf ( stderr, " LDA < M.\n" );*/ fprintf ( stderr, " LDA < M.\n" );*/
@ -1116,8 +910,7 @@ int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[],
return ind; return ind;
} }
if ( n <= 0 ) if (n <= 0) {
{
/*fprintf ( stderr, "\n" ); /*fprintf ( stderr, "\n" );
fprintf ( stderr, "DQRLS - Fatal error!\n" ); fprintf ( stderr, "DQRLS - Fatal error!\n" );
fprintf ( stderr, " N <= 0.\n" );*/ fprintf ( stderr, " N <= 0.\n" );*/
@ -1125,8 +918,7 @@ int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[],
return ind; return ind;
} }
if ( itask < 1 ) if (itask < 1) {
{
/*fprintf ( stderr, "\n" ); /*fprintf ( stderr, "\n" );
fprintf ( stderr, "DQRLS - Fatal error!\n" ); fprintf ( stderr, "DQRLS - Fatal error!\n" );
fprintf ( stderr, " ITASK < 1.\n" );*/ fprintf ( stderr, " ITASK < 1.\n" );*/
@ -1139,14 +931,11 @@ int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[],
Factor the matrix. Factor the matrix.
*/ */
if (itask == 1) if (itask == 1)
{
dqrank(a, lda, m, n, tol, kr, jpvt, qraux); dqrank(a, lda, m, n, tol, kr, jpvt, qraux);
}
/* /*
Solve the least-squares problem. Solve the least-squares problem.
*/ */
dqrlss(a, lda, m, n, *kr, b, x, rsd, jpvt, qraux); dqrlss(a, lda, m, n, *kr, b, x, rsd, jpvt, qraux);
return ind; return ind;
} }
/******************************************************************************/ /******************************************************************************/
@ -1232,31 +1021,23 @@ void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[],
int k; int k;
double t; double t;
if ( kr != 0 ) if (kr != 0) {
{
job = 110; job = 110;
info = dqrsl(a, lda, m, kr, qraux, b, rsd, rsd, x, rsd, rsd, job); info = dqrsl(a, lda, m, kr, qraux, b, rsd, rsd, x, rsd, rsd, job);
} }
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{
jpvt[i] = - jpvt[i]; jpvt[i] = - jpvt[i];
}
for (i = kr; i < n; i++) for (i = kr; i < n; i++)
{
x[i] = 0.0; x[i] = 0.0;
}
for ( j = 1; j <= n; j++ ) for (j = 1; j <= n; j++) {
{ if (jpvt[j - 1] <= 0) {
if ( jpvt[j-1] <= 0 )
{
k = - jpvt[j - 1]; k = - jpvt[j - 1];
jpvt[j - 1] = k; jpvt[j - 1] = k;
while ( k != j ) while (k != j) {
{
t = x[j - 1]; t = x[j - 1];
x[j - 1] = x[k - 1]; x[j - 1] = x[k - 1];
x[k - 1] = t; x[k - 1] = t;
@ -1265,7 +1046,6 @@ void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[],
} }
} }
} }
return;
} }
/******************************************************************************/ /******************************************************************************/
@ -1424,6 +1204,7 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[],
Set INFO flag. Set INFO flag.
*/ */
info = 0; info = 0;
/* /*
Determine what is to be computed. Determine what is to be computed.
*/ */
@ -1432,75 +1213,46 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[],
cb = ((job % 1000) / 100 != 0); cb = ((job % 1000) / 100 != 0);
cr = ((job % 100) / 10 != 0); cr = ((job % 100) / 10 != 0);
cab = ((job % 10) != 0); cab = ((job % 10) != 0);
ju = i4_min(k, n - 1); ju = i4_min(k, n - 1);
/* /*
Special action when N = 1. Special action when N = 1.
*/ */
if ( ju == 0 ) if (ju == 0) {
{
if (cqy) if (cqy)
{
qy[0] = y[0]; qy[0] = y[0];
}
if (cqty) if (cqty)
{
qty[0] = y[0]; qty[0] = y[0];
}
if (cab) if (cab)
{
ab[0] = y[0]; ab[0] = y[0];
} if (cb) {
if ( cb )
{
if (a[0 + 0 * lda] == 0.0) if (a[0 + 0 * lda] == 0.0)
{
info = 1; info = 1;
}
else else
{
b[0] = y[0] / a[0 + 0 * lda]; b[0] = y[0] / a[0 + 0 * lda];
} }
}
if (cr) if (cr)
{
rsd[0] = 0.0; rsd[0] = 0.0;
}
return info; return info;
} }
/* /*
Set up to compute QY or QTY. Set up to compute QY or QTY.
*/ */
if ( cqy ) if (cqy) {
{
for (i = 1; i <= n; i++) for (i = 1; i <= n; i++)
{
qy[i - 1] = y[i - 1]; qy[i - 1] = y[i - 1];
} }
} if (cqty) {
if ( cqty )
{
for (i = 1; i <= n; i++) for (i = 1; i <= n; i++)
{
qty[i - 1] = y[i - 1]; qty[i - 1] = y[i - 1];
} }
}
/* /*
Compute QY. Compute QY.
*/ */
if ( cqy ) if (cqy) {
{ for (jj = 1; jj <= ju; jj++) {
for ( jj = 1; jj <= ju; jj++ )
{
j = ju - jj + 1; j = ju - jj + 1;
if (qraux[j - 1] != 0.0) {
if ( qraux[j-1] != 0.0 )
{
temp = a[j - 1 + (j - 1) * lda]; temp = a[j - 1 + (j - 1) * lda];
a[j - 1 + (j - 1)*lda] = qraux[j - 1]; a[j - 1 + (j - 1)*lda] = qraux[j - 1];
t = -ddot(n - j + 1, a + j - 1 + (j - 1) * lda, 1, qy + j - 1, 1) / a[j - 1 + (j - 1) * lda]; t = -ddot(n - j + 1, a + j - 1 + (j - 1) * lda, 1, qy + j - 1, 1) / a[j - 1 + (j - 1) * lda];
@ -1512,12 +1264,9 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[],
/* /*
Compute Q'*Y. Compute Q'*Y.
*/ */
if ( cqty ) if (cqty) {
{ for (j = 1; j <= ju; j++) {
for ( j = 1; j <= ju; j++ ) if (qraux[j - 1] != 0.0) {
{
if ( qraux[j-1] != 0.0 )
{
temp = a[j - 1 + (j - 1) * lda]; temp = a[j - 1 + (j - 1) * lda];
a[j - 1 + (j - 1)*lda] = qraux[j - 1]; a[j - 1 + (j - 1)*lda] = qraux[j - 1];
t = -ddot(n - j + 1, a + j - 1 + (j - 1) * lda, 1, qty + j - 1, 1) / a[j - 1 + (j - 1) * lda]; t = -ddot(n - j + 1, a + j - 1 + (j - 1) * lda, 1, qty + j - 1, 1) / a[j - 1 + (j - 1) * lda];
@ -1529,64 +1278,38 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[],
/* /*
Set up to compute B, RSD, or AB. Set up to compute B, RSD, or AB.
*/ */
if ( cb ) if (cb) {
{
for (i = 1; i <= k; i++) for (i = 1; i <= k; i++)
{
b[i - 1] = qty[i - 1]; b[i - 1] = qty[i - 1];
} }
} if (cab) {
if ( cab )
{
for (i = 1; i <= k; i++) for (i = 1; i <= k; i++)
{
ab[i - 1] = qty[i - 1]; ab[i - 1] = qty[i - 1];
} }
} if (cr && k < n) {
if ( cr && k < n )
{
for (i = k + 1; i <= n; i++) for (i = k + 1; i <= n; i++)
{
rsd[i - 1] = qty[i - 1]; rsd[i - 1] = qty[i - 1];
} }
} if (cab && k + 1 <= n) {
if ( cab && k+1 <= n )
{
for (i = k + 1; i <= n; i++) for (i = k + 1; i <= n; i++)
{
ab[i - 1] = 0.0; ab[i - 1] = 0.0;
} }
} if (cr) {
if ( cr )
{
for (i = 1; i <= k; i++) for (i = 1; i <= k; i++)
{
rsd[i - 1] = 0.0; rsd[i - 1] = 0.0;
} }
}
/* /*
Compute B. Compute B.
*/ */
if ( cb ) if (cb) {
{ for (jj = 1; jj <= k; jj++) {
for ( jj = 1; jj <= k; jj++ )
{
j = k - jj + 1; j = k - jj + 1;
if (a[j - 1 + (j - 1)*lda] == 0.0) {
if ( a[j-1+(j-1)*lda] == 0.0 )
{
info = j; info = j;
break; break;
} }
b[j - 1] = b[j - 1] / a[j - 1 + (j - 1) * lda]; b[j - 1] = b[j - 1] / a[j - 1 + (j - 1) * lda];
if (j != 1) {
if ( j != 1 )
{
t = -b[j - 1]; t = -b[j - 1];
daxpy(j - 1, t, a + 0 + (j - 1)*lda, 1, b, 1); daxpy(j - 1, t, a + 0 + (j - 1)*lda, 1, b, 1);
} }
@ -1595,26 +1318,18 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[],
/* /*
Compute RSD or AB as required. Compute RSD or AB as required.
*/ */
if ( cr || cab ) if (cr || cab) {
{ for (jj = 1; jj <= ju; jj++) {
for ( jj = 1; jj <= ju; jj++ )
{
j = ju - jj + 1; j = ju - jj + 1;
if (qraux[j - 1] != 0.0) {
if ( qraux[j-1] != 0.0 )
{
temp = a[j - 1 + (j - 1) * lda]; temp = a[j - 1 + (j - 1) * lda];
a[j - 1 + (j - 1)*lda] = qraux[j - 1]; a[j - 1 + (j - 1)*lda] = qraux[j - 1];
if (cr) {
if ( cr )
{
t = -ddot(n - j + 1, a + j - 1 + (j - 1) * lda, 1, rsd + j - 1, 1) t = -ddot(n - j + 1, a + j - 1 + (j - 1) * lda, 1, rsd + j - 1, 1)
/ a[j - 1 + (j - 1) * lda]; / a[j - 1 + (j - 1) * lda];
daxpy(n - j + 1, t, a + j - 1 + (j - 1)*lda, 1, rsd + j - 1, 1); daxpy(n - j + 1, t, a + j - 1 + (j - 1)*lda, 1, rsd + j - 1, 1);
} }
if (cab) {
if ( cab )
{
t = -ddot(n - j + 1, a + j - 1 + (j - 1) * lda, 1, ab + j - 1, 1) t = -ddot(n - j + 1, a + j - 1 + (j - 1) * lda, 1, ab + j - 1, 1)
/ a[j - 1 + (j - 1) * lda]; / a[j - 1 + (j - 1) * lda];
daxpy(n - j + 1, t, a + j - 1 + (j - 1)*lda, 1, ab + j - 1, 1); daxpy(n - j + 1, t, a + j - 1 + (j - 1)*lda, 1, ab + j - 1, 1);
@ -1623,7 +1338,6 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[],
} }
} }
} }
return info; return info;
} }
/******************************************************************************/ /******************************************************************************/
@ -1677,45 +1391,29 @@ void dscal ( int n, double sa, double x[], int incx )
int ix; int ix;
int m; int m;
if ( n <= 0 ) if (n <= 0) return;
{
} if (incx == 1) {
else if ( incx == 1 )
{
m = n % 5; m = n % 5;
for (i = 0; i < m; i++) for (i = 0; i < m; i++)
{
x[i] = sa * x[i]; x[i] = sa * x[i];
} for (i = m; i < n; i = i + 5) {
for ( i = m; i < n; i = i + 5 )
{
x[i] = sa * x[i]; x[i] = sa * x[i];
x[i + 1] = sa * x[i + 1]; x[i + 1] = sa * x[i + 1];
x[i + 2] = sa * x[i + 2]; x[i + 2] = sa * x[i + 2];
x[i + 3] = sa * x[i + 3]; x[i + 3] = sa * x[i + 3];
x[i + 4] = sa * x[i + 4]; x[i + 4] = sa * x[i + 4];
} }
} } else {
else
{
if (0 <= incx) if (0 <= incx)
{
ix = 0; ix = 0;
}
else else
{
ix = (- n + 1) * incx; ix = (- n + 1) * incx;
} for (i = 0; i < n; i++) {
for ( i = 0; i < n; i++ )
{
x[ix] = sa * x[ix]; x[ix] = sa * x[ix];
ix = ix + incx; ix = ix + incx;
} }
} }
return;
} }
/******************************************************************************/ /******************************************************************************/
@ -1765,73 +1463,46 @@ void dswap ( int n, double x[], int incx, double y[], int incy )
Input, int INCY, the increment between successive elements of Y. Input, int INCY, the increment between successive elements of Y.
*/ */
{ {
int i; if (n <= 0) return;
int ix;
int iy; int i, ix, iy, m;
int m;
double temp; double temp;
if ( n <= 0 ) if (incx == 1 && incy == 1) {
{
}
else if ( incx == 1 && incy == 1 )
{
m = n % 3; m = n % 3;
for (i = 0; i < m; i++) {
for ( i = 0; i < m; i++ )
{
temp = x[i]; temp = x[i];
x[i] = y[i]; x[i] = y[i];
y[i] = temp; y[i] = temp;
} }
for (i = m; i < n; i = i + 3) {
for ( i = m; i < n; i = i + 3 )
{
temp = x[i]; temp = x[i];
x[i] = y[i]; x[i] = y[i];
y[i] = temp; y[i] = temp;
temp = x[i + 1]; temp = x[i + 1];
x[i + 1] = y[i + 1]; x[i + 1] = y[i + 1];
y[i + 1] = temp; y[i + 1] = temp;
temp = x[i + 2]; temp = x[i + 2];
x[i + 2] = y[i + 2]; x[i + 2] = y[i + 2];
y[i + 2] = temp; y[i + 2] = temp;
} }
} } else {
else
{
if (0 <= incx) if (0 <= incx)
{
ix = 0; ix = 0;
}
else else
{
ix = (- n + 1) * incx; ix = (- n + 1) * incx;
}
if (0 <= incy) if (0 <= incy)
{
iy = 0; iy = 0;
}
else else
{
iy = (- n + 1) * incy; iy = (- n + 1) * incy;
} for (i = 0; i < n; i++) {
for ( i = 0; i < n; i++ )
{
temp = x[ix]; temp = x[ix];
x[ix] = y[iy]; x[ix] = y[iy];
y[iy] = temp; y[iy] = temp;
ix = ix + incx; ix = ix + incx;
iy = iy + incy; iy = iy + incy;
} }
} }
return;
} }
/******************************************************************************/ /******************************************************************************/
@ -1887,15 +1558,8 @@ void qr_solve ( double x[], int m, int n, double a[], double b[] )
Output, double QR_SOLVE[N], the least squares solution. Output, double QR_SOLVE[N], the least squares solution.
*/ */
{ {
double a_qr[n*m]; double a_qr[n * m], qraux[n], r[m], tol;
int ind; int ind, itask, jpvt[n], kr, lda;
int itask;
int jpvt[n];
int kr;
int lda;
double qraux[n];
double r[m];
double tol;
r8mat_copy(a_qr, m, n, a); r8mat_copy(a_qr, m, n, a);
lda = m; lda = m;

View file

@ -408,14 +408,14 @@ inline void update_endstops() {
#else // !Z_DUAL_ENDSTOPS #else // !Z_DUAL_ENDSTOPS
UPDATE_ENDSTOP(Z, MIN); UPDATE_ENDSTOP(Z, MIN);
#endif // !Z_DUAL_ENDSTOPS #endif // !Z_DUAL_ENDSTOPS
#endif // Z_MIN_PIN #endif // Z_MIN_PIN
#if ENABLED(Z_MIN_PROBE_ENDSTOP) #if ENABLED(Z_MIN_PROBE_ENDSTOP)
UPDATE_ENDSTOP(Z, MIN_PROBE); UPDATE_ENDSTOP(Z, MIN_PROBE);
if (TEST_ENDSTOP(Z_MIN_PROBE)) if (TEST_ENDSTOP(Z_MIN_PROBE)) {
{
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS]; endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
endstop_hit_bits |= BIT(Z_MIN_PROBE); endstop_hit_bits |= BIT(Z_MIN_PROBE);
} }
@ -704,7 +704,9 @@ ISR(TIMER1_COMPA_vect) {
timer = calc_timer(acc_step_rate); timer = calc_timer(acc_step_rate);
OCR1A = timer; OCR1A = timer;
acceleration_time += timer; acceleration_time += timer;
#if ENABLED(ADVANCE) #if ENABLED(ADVANCE)
for (int8_t i = 0; i < step_loops; i++) { for (int8_t i = 0; i < step_loops; i++) {
advance += advance_rate; advance += advance_rate;
} }
@ -713,7 +715,7 @@ ISR(TIMER1_COMPA_vect) {
e_steps[current_block->active_extruder] += ((advance >> 8) - old_advance); e_steps[current_block->active_extruder] += ((advance >> 8) - old_advance);
old_advance = advance >> 8; old_advance = advance >> 8;
#endif #endif //ADVANCE
} }
else if (step_events_completed > (unsigned long)current_block->decelerate_after) { else if (step_events_completed > (unsigned long)current_block->decelerate_after) {
MultiU24X32toH16(step_rate, deceleration_time, current_block->acceleration_rate); MultiU24X32toH16(step_rate, deceleration_time, current_block->acceleration_rate);
@ -763,8 +765,7 @@ ISR(TIMER1_COMPA_vect) {
unsigned char old_OCR0A; unsigned char old_OCR0A;
// Timer interrupt for E. e_steps is set in the main routine; // Timer interrupt for E. e_steps is set in the main routine;
// Timer 0 is shared with millies // Timer 0 is shared with millies
ISR(TIMER0_COMPA_vect) ISR(TIMER0_COMPA_vect) {
{
old_OCR0A += 52; // ~10kHz interrupt (250000 / 26 = 9615kHz) old_OCR0A += 52; // ~10kHz interrupt (250000 / 26 = 9615kHz)
OCR0A = old_OCR0A; OCR0A = old_OCR0A;
// Set E direction (Depends on E direction + advance) // Set E direction (Depends on E direction + advance)
@ -827,7 +828,6 @@ ISR(TIMER1_COMPA_vect) {
} }
} }
#endif #endif
} }
} }
#endif // ADVANCE #endif // ADVANCE
@ -1034,7 +1034,6 @@ void st_init() {
// output mode = 00 (disconnected) // output mode = 00 (disconnected)
TCCR1A &= ~(3 << COM1A0); TCCR1A &= ~(3 << COM1A0);
TCCR1A &= ~(3 << COM1B0); TCCR1A &= ~(3 << COM1B0);
// Set the timer pre-scaler // Set the timer pre-scaler
// Generally we use a divider of 8, resulting in a 2MHz timer // Generally we use a divider of 8, resulting in a 2MHz timer
// frequency on a 16MHz MCU. If you are going to change this, be // frequency on a 16MHz MCU. If you are going to change this, be

View file

@ -60,8 +60,7 @@
#endif #endif
#if ENABLED(HAVE_TMCDRIVER) #if ENABLED(HAVE_TMCDRIVER)
void tmc_init() void tmc_init() {
{
#if ENABLED(X_IS_TMC) #if ENABLED(X_IS_TMC)
stepperX.setMicrosteps(X_MICROSTEPS); stepperX.setMicrosteps(X_MICROSTEPS);
stepperX.start(); stepperX.start();
@ -147,8 +146,7 @@ void tmc_init()
// init routine // init routine
#if ENABLED(HAVE_L6470DRIVER) #if ENABLED(HAVE_L6470DRIVER)
void L6470_init() void L6470_init() {
{
#if ENABLED(X_IS_L6470) #if ENABLED(X_IS_L6470)
stepperX.init(X_K_VAL); stepperX.init(X_K_VAL);
stepperX.softFree(); stepperX.softFree();

View file

@ -395,8 +395,7 @@ void checkExtruderAutoFans() {
fanState |= 1; fanState |= 1;
#endif #endif
#if HAS_AUTO_FAN_1 #if HAS_AUTO_FAN_1
if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE) if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE) {
{
if (EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) if (EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN)
fanState |= 1; fanState |= 1;
else else
@ -404,8 +403,7 @@ void checkExtruderAutoFans() {
} }
#endif #endif
#if HAS_AUTO_FAN_2 #if HAS_AUTO_FAN_2
if (current_temperature[2] > EXTRUDER_AUTO_FAN_TEMPERATURE) if (current_temperature[2] > EXTRUDER_AUTO_FAN_TEMPERATURE) {
{
if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN)
fanState |= 1; fanState |= 1;
else if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN) else if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN)
@ -415,8 +413,7 @@ void checkExtruderAutoFans() {
} }
#endif #endif
#if HAS_AUTO_FAN_3 #if HAS_AUTO_FAN_3
if (current_temperature[3] > EXTRUDER_AUTO_FAN_TEMPERATURE) if (current_temperature[3] > EXTRUDER_AUTO_FAN_TEMPERATURE) {
{
if (EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) if (EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN)
fanState |= 1; fanState |= 1;
else if (EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN) else if (EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN)
@ -792,10 +789,15 @@ static float analog2tempBed(int raw) {
if (i == BEDTEMPTABLE_LEN) celsius = PGM_RD_W(BEDTEMPTABLE[i - 1][1]); if (i == BEDTEMPTABLE_LEN) celsius = PGM_RD_W(BEDTEMPTABLE[i - 1][1]);
return celsius; return celsius;
#elif defined BED_USES_AD595
#elif defined(BED_USES_AD595)
return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET; return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET;
#else #else
return 0; return 0;
#endif #endif
} }
@ -1320,7 +1322,7 @@ ISR(TIMER0_COMPB_vect) {
#endif #endif
} }
if (soft_pwm_0 < pwm_count) { WRITE_HEATER_0(0); } if (soft_pwm_0 < pwm_count) WRITE_HEATER_0(0);
#if EXTRUDERS > 1 #if EXTRUDERS > 1
if (soft_pwm_1 < pwm_count) WRITE_HEATER_1(0); if (soft_pwm_1 < pwm_count) WRITE_HEATER_1(0);
#if EXTRUDERS > 2 #if EXTRUDERS > 2
@ -1343,6 +1345,7 @@ ISR(TIMER0_COMPB_vect) {
pwm_count &= 0x7f; pwm_count &= 0x7f;
#else // SLOW_PWM_HEATERS #else // SLOW_PWM_HEATERS
/* /*
* SLOW PWM HEATERS * SLOW PWM HEATERS
* *

View file

@ -1497,6 +1497,7 @@ static void menu_action_setting_edit_callback_bool(const char* pstr, bool* ptr,
/** LCD API **/ /** LCD API **/
void lcd_init() { void lcd_init() {
lcd_implementation_init(); lcd_implementation_init();
#if ENABLED(NEWPANEL) #if ENABLED(NEWPANEL)
@ -1505,10 +1506,12 @@ void lcd_init() {
SET_INPUT(BTN_EN2); SET_INPUT(BTN_EN2);
WRITE(BTN_EN1, HIGH); WRITE(BTN_EN1, HIGH);
WRITE(BTN_EN2, HIGH); WRITE(BTN_EN2, HIGH);
#if BTN_ENC > 0 #if BTN_ENC > 0
SET_INPUT(BTN_ENC); SET_INPUT(BTN_ENC);
WRITE(BTN_ENC, HIGH); WRITE(BTN_ENC, HIGH);
#endif #endif
#if ENABLED(REPRAPWORLD_KEYPAD) #if ENABLED(REPRAPWORLD_KEYPAD)
pinMode(SHIFT_CLK, OUTPUT); pinMode(SHIFT_CLK, OUTPUT);
pinMode(SHIFT_LD, OUTPUT); pinMode(SHIFT_LD, OUTPUT);
@ -1516,7 +1519,9 @@ void lcd_init() {
WRITE(SHIFT_OUT, HIGH); WRITE(SHIFT_OUT, HIGH);
WRITE(SHIFT_LD, HIGH); WRITE(SHIFT_LD, HIGH);
#endif #endif
#else // Not NEWPANEL #else // Not NEWPANEL
#if ENABLED(SR_LCD_2W_NL) // Non latching 2 wire shift register #if ENABLED(SR_LCD_2W_NL) // Non latching 2 wire shift register
pinMode(SR_DATA_PIN, OUTPUT); pinMode(SR_DATA_PIN, OUTPUT);
pinMode(SR_CLK_PIN, OUTPUT); pinMode(SR_CLK_PIN, OUTPUT);
@ -1529,6 +1534,7 @@ void lcd_init() {
WRITE(SHIFT_LD, HIGH); WRITE(SHIFT_LD, HIGH);
WRITE(SHIFT_EN, LOW); WRITE(SHIFT_EN, LOW);
#endif // SR_LCD_2W_NL #endif // SR_LCD_2W_NL
#endif//!NEWPANEL #endif//!NEWPANEL
#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT) #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
@ -1967,7 +1973,6 @@ char *ftostr43(const float &x) {
// Convert float to string with 1.23 format // Convert float to string with 1.23 format
char* ftostr12ns(const float& x) { char* ftostr12ns(const float& x) {
long xx = x * 100; long xx = x * 100;
xx = abs(xx); xx = abs(xx);
conv[0] = (xx / 100) % 10 + '0'; conv[0] = (xx / 100) % 10 + '0';
conv[1] = '.'; conv[1] = '.';
@ -1981,7 +1986,6 @@ char *ftostr12ns(const float &x) {
char* ftostr32sp(const float& x) { char* ftostr32sp(const float& x) {
long xx = abs(x * 100); long xx = abs(x * 100);
uint8_t dig; uint8_t dig;
if (x < 0) { // negative val = -_0 if (x < 0) { // negative val = -_0
conv[0] = '-'; conv[0] = '-';
dig = (xx / 1000) % 10; dig = (xx / 1000) % 10;

View file

@ -420,7 +420,7 @@ unsigned lcd_print(char c) { return charset_mapper(c); }
lcd_print(' '); lcd_print(' ');
} }
// scrol the PSTR'text' in a 'len' wide field for 'time' milliseconds at position col,line // Scroll the PSTR 'text' in a 'len' wide field for 'time' milliseconds at position col,line
void lcd_scroll(int col, int line, const char* text, int len, int time) { void lcd_scroll(int col, int line, const char* text, int len, int time) {
char tmp[LCD_WIDTH + 1] = {0}; char tmp[LCD_WIDTH + 1] = {0};
int n = max(lcd_strlen_P(text) - len, 0); int n = max(lcd_strlen_P(text) - len, 0);

View file

@ -21,11 +21,9 @@
#include <U8glib.h> #include <U8glib.h>
static void ST7920_SWSPI_SND_8BIT(uint8_t val) static void ST7920_SWSPI_SND_8BIT(uint8_t val) {
{
uint8_t i; uint8_t i;
for( i=0; i<8; i++ ) for (i = 0; i < 8; i++) {
{
WRITE(ST7920_CLK_PIN,0); WRITE(ST7920_CLK_PIN,0);
#if F_CPU == 20000000 #if F_CPU == 20000000
__asm__("nop\n\t"); __asm__("nop\n\t");
@ -46,13 +44,10 @@ static void ST7920_SWSPI_SND_8BIT(uint8_t val)
#define ST7920_WRITE_BYTE(a) {ST7920_SWSPI_SND_8BIT((uint8_t)((a)&0xf0u));ST7920_SWSPI_SND_8BIT((uint8_t)((a)<<4u));u8g_10MicroDelay();} #define ST7920_WRITE_BYTE(a) {ST7920_SWSPI_SND_8BIT((uint8_t)((a)&0xf0u));ST7920_SWSPI_SND_8BIT((uint8_t)((a)<<4u));u8g_10MicroDelay();}
#define ST7920_WRITE_BYTES(p,l) {uint8_t i;for(i=0;i<l;i++){ST7920_SWSPI_SND_8BIT(*p&0xf0);ST7920_SWSPI_SND_8BIT(*p<<4);p++;}u8g_10MicroDelay();} #define ST7920_WRITE_BYTES(p,l) {uint8_t i;for(i=0;i<l;i++){ST7920_SWSPI_SND_8BIT(*p&0xf0);ST7920_SWSPI_SND_8BIT(*p<<4);p++;}u8g_10MicroDelay();}
uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) {
{
uint8_t i, y; uint8_t i, y;
switch(msg) switch (msg) {
{ case U8G_DEV_MSG_INIT: {
case U8G_DEV_MSG_INIT:
{
OUT_WRITE(ST7920_CS_PIN, LOW); OUT_WRITE(ST7920_CS_PIN, LOW);
OUT_WRITE(ST7920_DAT_PIN, LOW); OUT_WRITE(ST7920_DAT_PIN, LOW);
OUT_WRITE(ST7920_CLK_PIN, HIGH); OUT_WRITE(ST7920_CLK_PIN, HIGH);
@ -64,8 +59,7 @@ uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo
ST7920_WRITE_BYTE(0x01); //clear CGRAM ram ST7920_WRITE_BYTE(0x01); //clear CGRAM ram
u8g_Delay(15); //delay for CGRAM clear u8g_Delay(15); //delay for CGRAM clear
ST7920_WRITE_BYTE(0x3E); //extended mode + GDRAM active ST7920_WRITE_BYTE(0x3E); //extended mode + GDRAM active
for(y=0;y<LCD_PIXEL_HEIGHT/2;y++) //clear GDRAM for (y = 0; y < LCD_PIXEL_HEIGHT / 2; y++) { //clear GDRAM
{
ST7920_WRITE_BYTE(0x80 | y); //set y ST7920_WRITE_BYTE(0x80 | y); //set y
ST7920_WRITE_BYTE(0x80); //set x = 0 ST7920_WRITE_BYTE(0x80); //set x = 0
ST7920_SET_DAT(); ST7920_SET_DAT();
@ -77,31 +71,25 @@ uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo
ST7920_NCS(); ST7920_NCS();
} }
break; break;
case U8G_DEV_MSG_STOP: case U8G_DEV_MSG_STOP:
break; break;
case U8G_DEV_MSG_PAGE_NEXT: case U8G_DEV_MSG_PAGE_NEXT: {
{
uint8_t* ptr; uint8_t* ptr;
u8g_pb_t* pb = (u8g_pb_t*)(dev->dev_mem); u8g_pb_t* pb = (u8g_pb_t*)(dev->dev_mem);
y = pb->p.page_y0; y = pb->p.page_y0;
ptr = (uint8_t*)pb->buf; ptr = (uint8_t*)pb->buf;
ST7920_CS(); ST7920_CS();
for( i = 0; i < PAGE_HEIGHT; i ++ ) for (i = 0; i < PAGE_HEIGHT; i ++) {
{
ST7920_SET_CMD(); ST7920_SET_CMD();
if ( y < 32 ) if (y < 32) {
{
ST7920_WRITE_BYTE(0x80 | y); //y ST7920_WRITE_BYTE(0x80 | y); //y
ST7920_WRITE_BYTE(0x80); //x=0 ST7920_WRITE_BYTE(0x80); //x=0
} }
else else {
{
ST7920_WRITE_BYTE(0x80 | (y - 32)); //y ST7920_WRITE_BYTE(0x80 | (y - 32)); //y
ST7920_WRITE_BYTE(0x80 | 8); //x=64 ST7920_WRITE_BYTE(0x80 | 8); //x=64
} }
ST7920_SET_DAT(); ST7920_SET_DAT();
ST7920_WRITE_BYTES(ptr, LCD_PIXEL_WIDTH / 8); //ptr is incremented inside of macro ST7920_WRITE_BYTES(ptr, LCD_PIXEL_WIDTH / 8); //ptr is incremented inside of macro
y++; y++;
@ -123,8 +111,7 @@ uint8_t u8g_dev_st7920_128x64_rrd_buf[LCD_PIXEL_WIDTH*(PAGE_HEIGHT/8)] U8G_NOC
u8g_pb_t u8g_dev_st7920_128x64_rrd_pb = {{PAGE_HEIGHT, LCD_PIXEL_HEIGHT, 0, 0, 0}, LCD_PIXEL_WIDTH, u8g_dev_st7920_128x64_rrd_buf}; u8g_pb_t u8g_dev_st7920_128x64_rrd_pb = {{PAGE_HEIGHT, LCD_PIXEL_HEIGHT, 0, 0, 0}, LCD_PIXEL_WIDTH, u8g_dev_st7920_128x64_rrd_buf};
u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi = {u8g_dev_rrd_st7920_128x64_fn, &u8g_dev_st7920_128x64_rrd_pb, &u8g_com_null_fn}; u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi = {u8g_dev_rrd_st7920_128x64_fn, &u8g_dev_st7920_128x64_rrd_pb, &u8g_com_null_fn};
class U8GLIB_ST7920_128X64_RRD : public U8GLIB class U8GLIB_ST7920_128X64_RRD : public U8GLIB {
{
public: public:
U8GLIB_ST7920_128X64_RRD(uint8_t dummy) : U8GLIB(&u8g_dev_st7920_128x64_rrd_sw_spi) {} U8GLIB_ST7920_128X64_RRD(uint8_t dummy) : U8GLIB(&u8g_dev_st7920_128x64_rrd_sw_spi) {}
}; };

View file

@ -22,8 +22,7 @@
#if ENABLED(AUTO_BED_LEVELING_FEATURE) #if ENABLED(AUTO_BED_LEVELING_FEATURE)
class matrix_3x3; class matrix_3x3;
struct vector_3 struct vector_3 {
{
float x, y, z; float x, y, z;
vector_3(); vector_3();
@ -42,8 +41,7 @@ struct vector_3
void apply_rotation(matrix_3x3 matrix); void apply_rotation(matrix_3x3 matrix);
}; };
struct matrix_3x3 struct matrix_3x3 {
{
float matrix[9]; float matrix[9];
static matrix_3x3 create_from_rows(vector_3 row_0, vector_3 row_1, vector_3 row_2); static matrix_3x3 create_from_rows(vector_3 row_0, vector_3 row_1, vector_3 row_2);

View file

@ -16,8 +16,7 @@
/// intialise watch dog with a 4 sec interrupt time /// intialise watch dog with a 4 sec interrupt time
void watchdog_init() void watchdog_init() {
{
#if ENABLED(WATCHDOG_RESET_MANUAL) #if ENABLED(WATCHDOG_RESET_MANUAL)
//We enable the watchdog timer, but only for the interrupt. //We enable the watchdog timer, but only for the interrupt.
//Take care, as this requires the correct order of operation, with interrupts disabled. See the datasheet of any AVR chip for details. //Take care, as this requires the correct order of operation, with interrupts disabled. See the datasheet of any AVR chip for details.
@ -30,8 +29,7 @@ void watchdog_init()
} }
/// reset watchdog. MUST be called every 1s after init or avr will reset. /// reset watchdog. MUST be called every 1s after init or avr will reset.
void watchdog_reset() void watchdog_reset() {
{
wdt_reset(); wdt_reset();
} }
@ -41,8 +39,7 @@ void watchdog_reset()
//Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled. //Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled.
#if ENABLED(WATCHDOG_RESET_MANUAL) #if ENABLED(WATCHDOG_RESET_MANUAL)
ISR(WDT_vect) ISR(WDT_vect) {
{
SERIAL_ERROR_START; SERIAL_ERROR_START;
SERIAL_ERRORLNPGM("Something is wrong, please turn off the printer."); SERIAL_ERRORLNPGM("Something is wrong, please turn off the printer.");
kill(PSTR("ERR:Please Reset")); //kill blocks //16 characters so it fits on a 16x2 display kill(PSTR("ERR:Please Reset")); //kill blocks //16 characters so it fits on a 16x2 display