Commit 44830a3f authored by MagoKimbra's avatar MagoKimbra

Same fix and clear code

parent 4e9b158c
This diff is collapsed.
......@@ -2,10 +2,10 @@
blinkm.cpp - Library for controlling a BlinkM over i2c
Created by Tim Koster, August 21 2013.
*/
#include "base.h"
#if ENABLED(BLINKM)
#include "blinkm.h"
void SendColors(byte red, byte grn, byte blu) {
......@@ -19,4 +19,5 @@ void SendColors(byte red, byte grn, byte blu) {
Wire.endTransmission();
}
#endif
#endif // BLINKM
#include "base.h"
#if HAS(BUZZER)
#include "buzzer.h"
#include "ultralcd.h"
void buzz(long duration, uint16_t freq) {
if (freq > 0) {
#if ENABLED(LCD_USE_I2C_BUZZER)
#if ENABLED(LCD_USE_I2C_BUZZER)
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);
#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
unsigned int delay = 1000000 / freq / 2;
int i = duration * freq / 1000;
......@@ -21,17 +19,15 @@ void buzz(long duration, uint16_t freq) {
WRITE(BEEPER_PIN, LOW);
delayMicroseconds(delay);
}
#else // buzzer has its own resonator - needs a DC
#else // buzzer has its own resonator - needs a DC
WRITE(BEEPER_PIN, HIGH);
delay(duration);
WRITE(BEEPER_PIN, LOW);
#endif
#else
#endif
#else
delay(duration);
#endif
}
else {
#endif
} else
delay(duration);
}
}
#endif
This diff is collapsed.
......@@ -9,38 +9,38 @@
enum LsAction { LS_SerialPrint, LS_Count, LS_GetFilename };
class CardReader {
public:
public:
CardReader();
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
//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 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 removeFile(char* name);
void closeFile(bool store_location = false);
void parseKeyLine(char *key, char *value, int &len_k, int &len_v);
void unparseKeyLine(const char *key, char *value);
void parseKeyLine(char* key, char* value, int &len_k, int &len_v);
void unparseKeyLine(const char* key, char* value);
void release();
void startFileprint();
void pauseSDPrint();
void getStatus();
void printingHasFinished();
#if ENABLED(LONG_FILENAME_HOST_SUPPORT)
void printLongPath(char *path);
#endif
#if ENABLED(LONG_FILENAME_HOST_SUPPORT)
void printLongPath(char* path);
#endif
void getfilename(uint16_t nr, const char* const match=NULL);
void getfilename(uint16_t nr, const char* const match = NULL);
uint16_t getnrfilenames();
void getAbsFilename(char *t);
void getAbsFilename(char* t);
void ls();
void chdir(const char * relpath);
void chdir(const char* relpath);
void updir();
void setroot(bool temporary = false);
void setlast();
......@@ -53,18 +53,18 @@ public:
FORCE_INLINE uint8_t percentDone() { return (isFileOpen() && filesize) ? sdpos / ((filesize + 99) / 100) : 0; }
FORCE_INLINE char* getWorkDirName() { workDir.getFilename(filename); return filename; }
public:
public:
bool saving, logging, sdprinting, cardOK, filenameIsDir;
char filename[FILENAME_LENGTH], longFilename[LONG_FILENAME_LENGTH];
int autostart_index;
private:
private:
SdFile root, *curDir, workDir, lastDir, workDirParents[MAX_DIR_DEPTH];
uint16_t workDirDepth;
Sd2Card card;
SdVolume volume;
SdFile file;
#define SD_PROCEDURE_DEPTH 1
#define MAXPATHNAMELENGTH (FILENAME_LENGTH*MAX_DIR_DEPTH + MAX_DIR_DEPTH + 1)
#define SD_PROCEDURE_DEPTH 1
#define MAXPATHNAMELENGTH (FILENAME_LENGTH*MAX_DIR_DEPTH + MAX_DIR_DEPTH + 1)
uint8_t file_subcall_ctr;
uint32_t filespos[SD_PROCEDURE_DEPTH];
char filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];
......@@ -77,7 +77,7 @@ private:
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.
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;
......
......@@ -372,11 +372,6 @@
#endif
#endif
/**
* Servo Leveling
*/
//#define SERVO_LEVELING (ENABLED(SERVO_ENDSTOPS) && ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE))
/**
* Sled Options
*/
......
......@@ -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;
while(size--) {
eeprom_write_byte((unsigned char*)pos, *value);
......@@ -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 {
*value = eeprom_read_byte((unsigned char*)pos);
pos++;
......
......@@ -7,42 +7,42 @@ void Config_ResetDefault();
void ConfigSD_ResetDefault();
#if DISABLED(DISABLE_M503)
void Config_PrintSettings(bool forReplay = false);
void ConfigSD_PrintSettings(bool forReplay = false);
void Config_PrintSettings(bool forReplay = false);
void ConfigSD_PrintSettings(bool forReplay = false);
#else
FORCE_INLINE void Config_PrintSettings(bool forReplay=false) {}
FORCE_INLINE void ConfigSD_PrintSettings(bool forReplay = false) {}
FORCE_INLINE void Config_PrintSettings(bool forReplay = false) {}
FORCE_INLINE void ConfigSD_PrintSettings(bool forReplay = false) {}
#endif
#if ENABLED(EEPROM_SETTINGS)
void Config_StoreSettings();
void Config_RetrieveSettings();
void Config_StoreSettings();
void Config_RetrieveSettings();
#else
FORCE_INLINE void Config_StoreSettings() {}
FORCE_INLINE void Config_RetrieveSettings() { Config_ResetDefault(); Config_PrintSettings(); }
FORCE_INLINE void Config_StoreSettings() {}
FORCE_INLINE void Config_RetrieveSettings() { Config_ResetDefault(); Config_PrintSettings(); }
#endif
#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.)
#if HAS(POWER_CONSUMPTION_SENSOR)
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)
"PWR",
#endif
#endif
"TME",
};
};
enum cfgSD_ENUM { //This need to be in the same order as cfgSD_KEY
#if HAS(POWER_CONSUMPTION_SENSOR)
enum cfgSD_ENUM { //This need to be in the same order as cfgSD_KEY
#if HAS(POWER_CONSUMPTION_SENSOR)
SD_CFG_PWR,
#endif
#endif
SD_CFG_TME,
SD_CFG_END //Leave this always as the last
};
};
void ConfigSD_StoreSettings();
void ConfigSD_RetrieveSettings(bool addValue = false);
int ConfigSD_KeyIndex(char *key);
void ConfigSD_StoreSettings();
void ConfigSD_RetrieveSettings(bool addValue = false);
int ConfigSD_KeyIndex(char *key);
#else
FORCE_INLINE void ConfigSD_RetrieveSettings() { ConfigSD_ResetDefault(); }
FORCE_INLINE void ConfigSD_RetrieveSettings() { ConfigSD_ResetDefault(); }
#endif
#endif //CONFIGURATION_STORE_H
#include "base.h"
#if ENABLED(DIGIPOT_I2C)
......@@ -10,7 +9,7 @@
#include "digipot_mcp4451.h"
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) {
......@@ -22,7 +21,7 @@ static void i2c_send(byte addr, byte a, byte b) {
// This is for the MCP4451 I2C based digipot
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,
// 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
......@@ -30,11 +29,9 @@ void digipot_i2c_set_current(int channel, float current) {
addr = 0x2E; // channel 4-7
channel -= 4;
}
// Initial setup
i2c_send(addr, 0x40, 0xff);
i2c_send(addr, 0xA0, 0xff);
// Set actual wiper value
byte addresses[4] = { 0x00, 0x10, 0x60, 0x70 };
i2c_send(addr, addresses[channel], current_to_wiper(current));
......@@ -44,9 +41,8 @@ void digipot_i2c_init() {
const float digipot_motor_current[] = DIGIPOT_I2C_MOTOR_CURRENTS;
Wire.begin();
// 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]);
}
}
#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 @@
X Font ascent = 0 descent= 0
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") = {
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,
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,
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,
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,
168,136,112,3,3,3,6,0,3,64,160,64};
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,
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,
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,
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,
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