Skip to content

Commit 04e3abf

Browse files
committed
Automatic code formatting
Also fix small typo in SerialLCD::createChar()
1 parent 29a6663 commit 04e3abf

File tree

5 files changed

+51
-45
lines changed

5 files changed

+51
-45
lines changed

Arduino_Pedelec_Controller/Arduino_Pedelec_Controller.ino

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ void setup()
263263
digitalWrite(switch_disp_2, HIGH); // turn on pullup resistors on display-switch 2
264264
#endif
265265
#ifdef SUPPORT_SWITCH_ON_POTI_PIN
266-
digitalWrite(poti_in, HIGH);
266+
digitalWrite(poti_in, HIGH);
267267
#endif
268268

269269
#ifdef SUPPORT_LIGHTS_SWITCH
@@ -317,7 +317,7 @@ void setup()
317317
hrmi_open();
318318
#endif
319319
#ifdef SUPPORT_RTC
320-
Wire.begin();
320+
Wire.begin();
321321
#endif
322322
#ifndef SUPPORT_PAS
323323
pedaling=true;
@@ -433,7 +433,8 @@ void loop()
433433
wh=variable.wh;
434434
km=variable.kilometers;
435435
mah=variable.mah;
436-
} else
436+
}
437+
else
437438
display_show_important_info(FROM_FLASH(msg_battery_charged), 5);
438439
#endif
439440
if (voltage<6.0) //do not write new data to eeprom when on USB Power
@@ -668,13 +669,13 @@ void loop()
668669
#endif
669670

670671
#ifdef SUPPORT_RTC
671-
now=rtc.get_time(); //read current time
672-
//Serial.print(now.hh, DEC);
673-
//Serial.print(':');
674-
//Serial.print(now.mm, DEC);
675-
//Serial.print(':');
676-
//Serial.print(now.ss, DEC);
677-
//Serial.println();
672+
now=rtc.get_time(); //read current time
673+
//Serial.print(now.hh, DEC);
674+
//Serial.print(':');
675+
//Serial.print(now.mm, DEC);
676+
//Serial.print(':');
677+
//Serial.print(now.ss, DEC);
678+
//Serial.println();
678679
#endif
679680

680681
last_writetime=millis();

Arduino_Pedelec_Controller/ds1307.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,16 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2525
#define DS1307_ADDRESS 0x68
2626

2727
#if (ARDUINO >= 100)
28-
#include <Arduino.h> // capital A so it is error prone on case-sensitive filesystems
28+
#include <Arduino.h> // capital A so it is error prone on case-sensitive filesystems
2929
#else
30-
#include <WProgram.h>
30+
#include <WProgram.h>
3131
#endif
3232

3333
static uint8_t bcd2bin (uint8_t val) { return val - 6 * (val >> 4); }
3434
static uint8_t bin2bcd (uint8_t val) { return val + 6 * (val / 10); }
3535

36-
void RTC_DS1307::adjust_time(uint8_t hh, uint8_t mm, uint8_t ss) {
36+
void RTC_DS1307::adjust_time(uint8_t hh, uint8_t mm, uint8_t ss)
37+
{
3738
WIRE.beginTransmission(DS1307_ADDRESS);
3839
WIRE.write(0);
3940
WIRE.write(bin2bcd(ss));
@@ -42,14 +43,15 @@ void RTC_DS1307::adjust_time(uint8_t hh, uint8_t mm, uint8_t ss) {
4243
WIRE.endTransmission();
4344
}
4445

45-
Time RTC_DS1307::get_time() {
46-
WIRE.beginTransmission(DS1307_ADDRESS);
47-
WIRE.write(0);
48-
WIRE.endTransmission();
49-
WIRE.requestFrom(DS1307_ADDRESS, 7);
50-
uint8_t ss = bcd2bin(WIRE.read() & 0x7F);
51-
uint8_t mm = bcd2bin(WIRE.read());
52-
uint8_t hh = bcd2bin(WIRE.read());
53-
return (Time){hh,mm,ss};
46+
Time RTC_DS1307::get_time()
47+
{
48+
WIRE.beginTransmission(DS1307_ADDRESS);
49+
WIRE.write(0);
50+
WIRE.endTransmission();
51+
WIRE.requestFrom(DS1307_ADDRESS, 7);
52+
uint8_t ss = bcd2bin(WIRE.read() & 0x7F);
53+
uint8_t mm = bcd2bin(WIRE.read());
54+
uint8_t hh = bcd2bin(WIRE.read());
55+
return (Time) {hh,mm,ss};
5456
}
5557

Arduino_Pedelec_Controller/ds1307.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2121
#ifndef _ds1307_H_
2222
#define _ds1307_H_
2323

24-
struct Time
24+
struct Time
2525
{
26-
uint8_t hh; //hours
26+
uint8_t hh; //hours
2727
uint8_t mm; //minutes
2828
uint8_t ss; //seconds
2929
};
3030

31-
class RTC_DS1307 {
31+
class RTC_DS1307
32+
{
3233
public:
3334
static void adjust_time(uint8_t hh, uint8_t mm, uint8_t ss);
3435
Time get_time(void);

Arduino_Pedelec_Controller/serial_command.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ serial_command serial_commands[] =
3636
{{"hh"}}, //4: set/get hours
3737
{{"mm"}}, //5: set/get minutes
3838
{{"ss"}}, //6: set/get seconds
39-
39+
4040
};
4141
const byte n_commands = sizeof(serial_commands)/sizeof(serial_command); //number of commands that we have
4242

@@ -97,19 +97,19 @@ static void handle_command()
9797
Serial.println(odo/1000.0*wheel_circumference,0);
9898
break;
9999
case 4: //hours read
100-
#ifdef SUPPORT_RTC
100+
#ifdef SUPPORT_RTC
101101
Serial.println(now.hh);
102-
#endif
103-
break;
102+
#endif
103+
break;
104104
case 5: //minutes read
105-
#ifdef SUPPORT_RTC
105+
#ifdef SUPPORT_RTC
106106
Serial.println(now.mm);
107-
#endif
107+
#endif
108108
break;
109109
case 6: //seconds read
110-
#ifdef SUPPORT_RTC
110+
#ifdef SUPPORT_RTC
111111
Serial.println(now.ss);
112-
#endif
112+
#endif
113113
break;
114114
}
115115

@@ -134,19 +134,19 @@ static void handle_command()
134134
handle_switch(static_cast<switch_name>(atoi(numberstring)), 0, PRESSED_LONG);
135135
break;
136136
case 4: //hours write
137-
#ifdef SUPPORT_RTC
137+
#ifdef SUPPORT_RTC
138138
rtc.adjust_time(atoi(numberstring),now.mm,now.ss);
139-
#endif
139+
#endif
140140
break;
141141
case 5: //minutes write
142-
#ifdef SUPPORT_RTC
142+
#ifdef SUPPORT_RTC
143143
rtc.adjust_time(now.hh,atoi(numberstring),now.ss);
144-
#endif
144+
#endif
145145
break;
146146
case 6: //seconds write
147-
#ifdef SUPPORT_RTC
147+
#ifdef SUPPORT_RTC
148148
rtc.adjust_time(now.hh,now.mm,atoi(numberstring));
149-
#endif
149+
#endif
150150
break;
151151
}
152152
Serial.println(MY_F("OK"));
@@ -179,7 +179,8 @@ void parse_serial(const char &read_c)
179179
{
180180
// store first character
181181
cmdbuf[0] = read_c;
182-
} else
182+
}
183+
else
183184
{
184185
cmdbuf[1] = read_c;
185186

@@ -197,7 +198,8 @@ void parse_serial(const char &read_c)
197198
// User input is done
198199
handle_command();
199200
parse_state = Reset;
200-
} else
201+
}
202+
else
201203
{
202204
// Store character
203205
if (number_pos < sizeof(numberstring)-1) // reserve one byte for the terminating zero (atoi())

Arduino_Pedelec_Controller/serial_lcd.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void SerialLCD::home()
8686

8787
/**
8888
* @brief Set display contrast
89-
*
89+
*
9090
* @param contrast Value between 1 and 50
9191
*/
9292
void SerialLCD::setContrast(const byte &contrast)
@@ -98,7 +98,7 @@ void SerialLCD::setContrast(const byte &contrast)
9898

9999
/**
100100
* @brief Set backlight brightness
101-
*
101+
*
102102
* @param brightness Backlight brightness. Value between 1 and 8. '1' is off.
103103
*/
104104
void SerialLCD::setBacklight(const byte& brightness)
@@ -110,7 +110,7 @@ void SerialLCD::setBacklight(const byte& brightness)
110110

111111
/**
112112
* @brief Set cursor x/y position. Use an out-of-screen position to hide the cursor
113-
*
113+
*
114114
* @param x Horizontal position, starting at 0
115115
* @param y Line, starting at 0
116116
*/
@@ -151,7 +151,7 @@ void SerialLCD::createChar(byte address, const byte data[])
151151
address = address & 0x7;
152152

153153
write(0xFE);
154-
write(0x54),
154+
write(0x54);
155155
write(address);
156156

157157
for (byte i = 0; i < 8; ++i)

0 commit comments

Comments
 (0)