Commit 44830a3f authored by MagoKimbra's avatar MagoKimbra

Same fix and clear code

parent 4e9b158c
This diff is collapsed.
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
blinkm.cpp - Library for controlling a BlinkM over i2c blinkm.cpp - Library for controlling a BlinkM over i2c
Created by Tim Koster, August 21 2013. Created by Tim Koster, August 21 2013.
*/ */
#include "base.h" #include "base.h"
#if ENABLED(BLINKM) #if ENABLED(BLINKM)
#include "blinkm.h" #include "blinkm.h"
void SendColors(byte red, byte grn, byte blu) { void SendColors(byte red, byte grn, byte blu) {
...@@ -19,4 +19,5 @@ void SendColors(byte red, byte grn, byte blu) { ...@@ -19,4 +19,5 @@ void SendColors(byte red, byte grn, byte blu) {
Wire.endTransmission(); Wire.endTransmission();
} }
#endif #endif // BLINKM
#include "base.h" #include "base.h"
#if HAS(BUZZER) #if HAS(BUZZER)
#include "buzzer.h" #include "buzzer.h"
#include "ultralcd.h" #include "ultralcd.h"
void buzz(long duration, uint16_t freq) { void buzz(long duration, uint16_t freq) {
if (freq > 0) { if (freq > 0) {
#if ENABLED(LCD_USE_I2C_BUZZER) #if ENABLED(LCD_USE_I2C_BUZZER)
lcd_buzz(duration, freq); lcd_buzz(duration, freq);
#elif PIN_EXISTS(BEEPER) // on-board buzzers have no further condition #elif PIN_EXISTS(BEEPER) // on-board buzzers have no further condition
SET_OUTPUT(BEEPER_PIN); SET_OUTPUT(BEEPER_PIN);
#if ENABLED(SPEAKER) // a speaker needs a AC ore a pulsed DC #if ENABLED(SPEAKER) // a speaker needs a AC ore a pulsed DC
//tone(BEEPER_PIN, freq, duration); // needs a PWMable pin //tone(BEEPER_PIN, freq, duration); // needs a PWMable pin
unsigned int delay = 1000000 / freq / 2; unsigned int delay = 1000000 / freq / 2;
int i = duration * freq / 1000; int i = duration * freq / 1000;
...@@ -21,17 +19,15 @@ void buzz(long duration, uint16_t freq) { ...@@ -21,17 +19,15 @@ void buzz(long duration, uint16_t freq) {
WRITE(BEEPER_PIN, LOW); WRITE(BEEPER_PIN, LOW);
delayMicroseconds(delay); delayMicroseconds(delay);
} }
#else // buzzer has its own resonator - needs a DC #else // buzzer has its own resonator - needs a DC
WRITE(BEEPER_PIN, HIGH); WRITE(BEEPER_PIN, HIGH);
delay(duration); delay(duration);
WRITE(BEEPER_PIN, LOW); WRITE(BEEPER_PIN, LOW);
#endif #endif
#else #else
delay(duration); delay(duration);
#endif #endif
} } else
else {
delay(duration); delay(duration);
}
} }
#endif #endif
This diff is collapsed.
...@@ -9,38 +9,38 @@ ...@@ -9,38 +9,38 @@
enum LsAction { LS_SerialPrint, LS_Count, LS_GetFilename }; enum LsAction { LS_SerialPrint, LS_Count, LS_GetFilename };
class CardReader { class CardReader {
public: public:
CardReader(); CardReader();
void initsd(); void initsd();
void write_command(char *buf); void write_command(char* buf);
//files auto[0-9].g on the sd card are performed in a row //files auto[0-9].g on the sd card are performed in a row
//this is to delay autostart and hence the initialisaiton of the sd card to some seconds after the normal init, so the device is available quick after a reset //this is to delay autostart and hence the initialisaiton of the sd card to some seconds after the normal init, so the device is available quick after a reset
void checkautostart(bool x); void checkautostart(bool x);
void openFile(char* name,bool read,bool replace_current=true,bool lcd_status=true); void openFile(char* name, bool read, bool replace_current = true, bool lcd_status = true);
void openLogFile(char* name); void openLogFile(char* name);
void removeFile(char* name); void removeFile(char* name);
void closeFile(bool store_location = false); void closeFile(bool store_location = false);
void parseKeyLine(char *key, char *value, int &len_k, int &len_v); void parseKeyLine(char* key, char* value, int &len_k, int &len_v);
void unparseKeyLine(const char *key, char *value); void unparseKeyLine(const char* key, char* value);
void release(); void release();
void startFileprint(); void startFileprint();
void pauseSDPrint(); void pauseSDPrint();
void getStatus(); void getStatus();
void printingHasFinished(); void printingHasFinished();
#if ENABLED(LONG_FILENAME_HOST_SUPPORT) #if ENABLED(LONG_FILENAME_HOST_SUPPORT)
void printLongPath(char *path); void printLongPath(char* path);
#endif #endif
void getfilename(uint16_t nr, const char* const match=NULL); void getfilename(uint16_t nr, const char* const match = NULL);
uint16_t getnrfilenames(); uint16_t getnrfilenames();
void getAbsFilename(char *t); void getAbsFilename(char* t);
void ls(); void ls();
void chdir(const char * relpath); void chdir(const char* relpath);
void updir(); void updir();
void setroot(bool temporary = false); void setroot(bool temporary = false);
void setlast(); void setlast();
...@@ -53,18 +53,18 @@ public: ...@@ -53,18 +53,18 @@ public:
FORCE_INLINE uint8_t percentDone() { return (isFileOpen() && filesize) ? sdpos / ((filesize + 99) / 100) : 0; } FORCE_INLINE uint8_t percentDone() { return (isFileOpen() && filesize) ? sdpos / ((filesize + 99) / 100) : 0; }
FORCE_INLINE char* getWorkDirName() { workDir.getFilename(filename); return filename; } FORCE_INLINE char* getWorkDirName() { workDir.getFilename(filename); return filename; }
public: public:
bool saving, logging, sdprinting, cardOK, filenameIsDir; bool saving, logging, sdprinting, cardOK, filenameIsDir;
char filename[FILENAME_LENGTH], longFilename[LONG_FILENAME_LENGTH]; char filename[FILENAME_LENGTH], longFilename[LONG_FILENAME_LENGTH];
int autostart_index; int autostart_index;
private: private:
SdFile root, *curDir, workDir, lastDir, workDirParents[MAX_DIR_DEPTH]; SdFile root, *curDir, workDir, lastDir, workDirParents[MAX_DIR_DEPTH];
uint16_t workDirDepth; uint16_t workDirDepth;
Sd2Card card; Sd2Card card;
SdVolume volume; SdVolume volume;
SdFile file; SdFile file;
#define SD_PROCEDURE_DEPTH 1 #define SD_PROCEDURE_DEPTH 1
#define MAXPATHNAMELENGTH (FILENAME_LENGTH*MAX_DIR_DEPTH + MAX_DIR_DEPTH + 1) #define MAXPATHNAMELENGTH (FILENAME_LENGTH*MAX_DIR_DEPTH + MAX_DIR_DEPTH + 1)
uint8_t file_subcall_ctr; uint8_t file_subcall_ctr;
uint32_t filespos[SD_PROCEDURE_DEPTH]; uint32_t filespos[SD_PROCEDURE_DEPTH];
char filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH]; char filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];
...@@ -77,7 +77,7 @@ private: ...@@ -77,7 +77,7 @@ private:
LsAction lsAction; //stored for recursion. LsAction lsAction; //stored for recursion.
uint16_t nrFiles; //counter for the files in the current directory and recycled as position counter for getting the nrFiles'th name in the directory. uint16_t nrFiles; //counter for the files in the current directory and recycled as position counter for getting the nrFiles'th name in the directory.
char* diveDirName; char* diveDirName;
void lsDive(const char *prepend, SdFile parent, const char * const match=NULL); void lsDive(const char* prepend, SdFile parent, const char* const match = NULL);
}; };
extern CardReader card; extern CardReader card;
......
...@@ -372,11 +372,6 @@ ...@@ -372,11 +372,6 @@
#endif #endif
#endif #endif
/**
* Servo Leveling
*/
//#define SERVO_LEVELING (ENABLED(SERVO_ENDSTOPS) && ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE))
/** /**
* Sled Options * Sled Options
*/ */
......
...@@ -112,7 +112,7 @@ ...@@ -112,7 +112,7 @@
* *
*/ */
void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size) { void _EEPROM_writeData(int& pos, uint8_t* value, uint8_t size) {
uint8_t c; uint8_t c;
while(size--) { while(size--) {
eeprom_write_byte((unsigned char*)pos, *value); eeprom_write_byte((unsigned char*)pos, *value);
...@@ -125,7 +125,7 @@ void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size) { ...@@ -125,7 +125,7 @@ void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size) {
}; };
} }
void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) { void _EEPROM_readData(int& pos, uint8_t* value, uint8_t size) {
do { do {
*value = eeprom_read_byte((unsigned char*)pos); *value = eeprom_read_byte((unsigned char*)pos);
pos++; pos++;
......
...@@ -7,42 +7,42 @@ void Config_ResetDefault(); ...@@ -7,42 +7,42 @@ void Config_ResetDefault();
void ConfigSD_ResetDefault(); void ConfigSD_ResetDefault();
#if DISABLED(DISABLE_M503) #if DISABLED(DISABLE_M503)
void Config_PrintSettings(bool forReplay = false); void Config_PrintSettings(bool forReplay = false);
void ConfigSD_PrintSettings(bool forReplay = false); void ConfigSD_PrintSettings(bool forReplay = false);
#else #else
FORCE_INLINE void Config_PrintSettings(bool forReplay=false) {} FORCE_INLINE void Config_PrintSettings(bool forReplay = false) {}
FORCE_INLINE void ConfigSD_PrintSettings(bool forReplay = false) {} FORCE_INLINE void ConfigSD_PrintSettings(bool forReplay = false) {}
#endif #endif
#if ENABLED(EEPROM_SETTINGS) #if ENABLED(EEPROM_SETTINGS)
void Config_StoreSettings(); void Config_StoreSettings();
void Config_RetrieveSettings(); void Config_RetrieveSettings();
#else #else
FORCE_INLINE void Config_StoreSettings() {} FORCE_INLINE void Config_StoreSettings() {}
FORCE_INLINE void Config_RetrieveSettings() { Config_ResetDefault(); Config_PrintSettings(); } FORCE_INLINE void Config_RetrieveSettings() { Config_ResetDefault(); Config_PrintSettings(); }
#endif #endif
#if ENABLED(SDSUPPORT) && ENABLED(SD_SETTINGS) #if ENABLED(SDSUPPORT) && ENABLED(SD_SETTINGS)
static const char *cfgSD_KEY[] = { //Keep this in lexicographical order for better search performance(O(Nlog2(N)) insted of O(N*N)) (if you don't keep this sorted, the algorithm for find the key index won't work, keep attention.) static const char *cfgSD_KEY[] = { //Keep this in lexicographical order for better search performance(O(Nlog2(N)) insted of O(N*N)) (if you don't keep this sorted, the algorithm for find the key index won't work, keep attention.)
#if HAS(POWER_CONSUMPTION_SENSOR) #if HAS(POWER_CONSUMPTION_SENSOR)
"PWR", "PWR",
#endif #endif
"TME", "TME",
}; };
enum cfgSD_ENUM { //This need to be in the same order as cfgSD_KEY enum cfgSD_ENUM { //This need to be in the same order as cfgSD_KEY
#if HAS(POWER_CONSUMPTION_SENSOR) #if HAS(POWER_CONSUMPTION_SENSOR)
SD_CFG_PWR, SD_CFG_PWR,
#endif #endif
SD_CFG_TME, SD_CFG_TME,
SD_CFG_END //Leave this always as the last SD_CFG_END //Leave this always as the last
}; };
void ConfigSD_StoreSettings(); void ConfigSD_StoreSettings();
void ConfigSD_RetrieveSettings(bool addValue = false); void ConfigSD_RetrieveSettings(bool addValue = false);
int ConfigSD_KeyIndex(char *key); int ConfigSD_KeyIndex(char *key);
#else #else
FORCE_INLINE void ConfigSD_RetrieveSettings() { ConfigSD_ResetDefault(); } FORCE_INLINE void ConfigSD_RetrieveSettings() { ConfigSD_ResetDefault(); }
#endif #endif
#endif //CONFIGURATION_STORE_H #endif //CONFIGURATION_STORE_H
#include "base.h" #include "base.h"
#if ENABLED(DIGIPOT_I2C) #if ENABLED(DIGIPOT_I2C)
...@@ -10,7 +9,7 @@ ...@@ -10,7 +9,7 @@
#include "digipot_mcp4451.h" #include "digipot_mcp4451.h"
static byte current_to_wiper(float current) { static byte current_to_wiper(float current) {
return byte(ceil(float((DIGIPOT_I2C_FACTOR*current)))); return byte(ceil(float((DIGIPOT_I2C_FACTOR * current))));
} }
static void i2c_send(byte addr, byte a, byte b) { static void i2c_send(byte addr, byte a, byte b) {
...@@ -22,7 +21,7 @@ static void i2c_send(byte addr, byte a, byte b) { ...@@ -22,7 +21,7 @@ static void i2c_send(byte addr, byte a, byte b) {
// This is for the MCP4451 I2C based digipot // This is for the MCP4451 I2C based digipot
void digipot_i2c_set_current(int channel, float current) { void digipot_i2c_set_current(int channel, float current) {
current = min( (float) max( current, 0.0f ), DIGIPOT_I2C_MAX_CURRENT); current = min((float) max(current, 0.0f), DIGIPOT_I2C_MAX_CURRENT);
// these addresses are specific to Azteeg X3 Pro, can be set to others, // these addresses are specific to Azteeg X3 Pro, can be set to others,
// In this case first digipot is at address A0=0, A1= 0, second one is at A0=0, A1= 1 // In this case first digipot is at address A0=0, A1= 0, second one is at A0=0, A1= 1
byte addr = 0x2C; // channel 0-3 byte addr = 0x2C; // channel 0-3
...@@ -30,11 +29,9 @@ void digipot_i2c_set_current(int channel, float current) { ...@@ -30,11 +29,9 @@ void digipot_i2c_set_current(int channel, float current) {
addr = 0x2E; // channel 4-7 addr = 0x2E; // channel 4-7
channel -= 4; channel -= 4;
} }
// Initial setup // Initial setup
i2c_send(addr, 0x40, 0xff); i2c_send(addr, 0x40, 0xff);
i2c_send(addr, 0xA0, 0xff); i2c_send(addr, 0xA0, 0xff);
// Set actual wiper value // Set actual wiper value
byte addresses[4] = { 0x00, 0x10, 0x60, 0x70 }; byte addresses[4] = { 0x00, 0x10, 0x60, 0x70 };
i2c_send(addr, addresses[channel], current_to_wiper(current)); i2c_send(addr, addresses[channel], current_to_wiper(current));
...@@ -44,9 +41,8 @@ void digipot_i2c_init() { ...@@ -44,9 +41,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
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -9,14 +9,15 @@ ...@@ -9,14 +9,15 @@
X Font ascent = 0 descent= 0 X Font ascent = 0 descent= 0
Max Font ascent = 8 descent=-2 Max Font ascent = 8 descent=-2
*/ */
#include <utility/u8g.h> #include <U8glib.h>
const u8g_fntpgm_uint8_t Marlin_symbols[140] U8G_SECTION(".progmem.Marlin_symbols") = { const u8g_fntpgm_uint8_t Marlin_symbols[140] U8G_SECTION(".progmem.Marlin_symbols") = {
0,6,9,0,254,0,0,0,0,0,1,9,0,8,254,0, 0, 6, 9, 0, 254, 0, 0, 0, 0, 0, 1, 9, 0, 8, 254, 0,
0,5,8,8,6,0,0,64,240,200,136,136,152,120,16,5, 0, 5, 8, 8, 6, 0, 0, 64, 240, 200, 136, 136, 152, 120, 16, 5,
8,8,6,0,0,192,248,136,136,136,136,136,248,5,5,5, 8, 8, 6, 0, 0, 192, 248, 136, 136, 136, 136, 136, 248, 5, 5, 5,
6,0,1,32,48,248,48,32,5,8,8,6,0,0,32,112, 6, 0, 1, 32, 48, 248, 48, 32, 5, 8, 8, 6, 0, 0, 32, 112,
248,32,32,32,32,224,5,9,9,6,0,255,32,112,168,168, 248, 32, 32, 32, 32, 224, 5, 9, 9, 6, 0, 255, 32, 112, 168, 168,
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
};
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment