Browse Source

clang-format everything

try-fix-comms-errors
Alex Mikhalev 6 years ago
parent
commit
ad1daa4ba3
  1. 115
      main/Print.h
  2. 14
      main/U8g2lib.hh
  3. 10
      main/ugv_io.cc
  4. 2
      main/ugv_io.hh
  5. 6
      main/ugv_main.cc

115
main/Print.h

@ -17,8 +17,8 @@
#ifndef Print_h #ifndef Print_h
#define Print_h #define Print_h
#include <stdint.h>
#include <stddef.h> #include <stddef.h>
#include <stdint.h>
#include <string> #include <string>
// #include "Printable.h" // #include "Printable.h"
@ -28,73 +28,60 @@
#define OCT 8 #define OCT 8
#define BIN 2 #define BIN 2
class Print class Print {
{ private:
private: int write_error;
int write_error; size_t printNumber(unsigned long, uint8_t);
size_t printNumber(unsigned long, uint8_t); size_t printFloat(double, uint8_t);
size_t printFloat(double, uint8_t);
protected:
void setWriteError(int err = 1)
{
write_error = err;
}
public:
Print() :
write_error(0)
{
}
virtual ~Print() {}
int getWriteError()
{
return write_error;
}
void clearWriteError()
{
setWriteError(0);
}
virtual size_t write(uint8_t) = 0; protected:
size_t write(const char *str) void setWriteError(int err = 1) { write_error = err; }
{
if(str == NULL) { public:
return 0; Print() : write_error(0) {}
} virtual ~Print() {}
return write((const uint8_t *) str, strlen(str)); int getWriteError() { return write_error; }
} void clearWriteError() { setWriteError(0); }
virtual size_t write(const uint8_t *buffer, size_t size);
size_t write(const char *buffer, size_t size) virtual size_t write(uint8_t) = 0;
{ size_t write(const char *str) {
return write((const uint8_t *) buffer, size); if (str == NULL) {
return 0;
} }
return write((const uint8_t *)str, strlen(str));
}
virtual size_t write(const uint8_t *buffer, size_t size);
size_t write(const char *buffer, size_t size) {
return write((const uint8_t *)buffer, size);
}
size_t printf(const char * format, ...) __attribute__ ((format (printf, 2, 3))); size_t printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
// size_t print(const String &); // size_t print(const String &);
size_t print(const std::string &); size_t print(const std::string &);
size_t print(const char[]); size_t print(const char[]);
size_t print(char); size_t print(char);
size_t print(unsigned char, int = DEC); size_t print(unsigned char, int = DEC);
size_t print(int, int = DEC); size_t print(int, int = DEC);
size_t print(unsigned int, int = DEC); size_t print(unsigned int, int = DEC);
size_t print(long, int = DEC); size_t print(long, int = DEC);
size_t print(unsigned long, int = DEC); size_t print(unsigned long, int = DEC);
size_t print(double, int = 2); size_t print(double, int = 2);
// size_t print(const Printable&); // size_t print(const Printable&);
size_t print(struct tm * timeinfo, const char * format = NULL); size_t print(struct tm *timeinfo, const char *format = NULL);
// size_t println(const String &s); // size_t println(const String &s);
size_t println(const std::string &s); size_t println(const std::string &s);
size_t println(const char[]); size_t println(const char[]);
size_t println(char); size_t println(char);
size_t println(unsigned char, int = DEC); size_t println(unsigned char, int = DEC);
size_t println(int, int = DEC); size_t println(int, int = DEC);
size_t println(unsigned int, int = DEC); size_t println(unsigned int, int = DEC);
size_t println(long, int = DEC); size_t println(long, int = DEC);
size_t println(unsigned long, int = DEC); size_t println(unsigned long, int = DEC);
size_t println(double, int = 2); size_t println(double, int = 2);
// size_t println(const Printable&); // size_t println(const Printable&);
size_t println(struct tm * timeinfo, const char * format = NULL); size_t println(struct tm *timeinfo, const char *format = NULL);
size_t println(void); size_t println(void);
}; };
#endif #endif

14
main/U8g2lib.hh

@ -348,16 +348,22 @@ class U8G2 : public Print {
u8g2_uint_t getWidth() { return u8g2_GetDisplayWidth(&u8g2); } u8g2_uint_t getWidth() { return u8g2_GetDisplayWidth(&u8g2); }
}; };
void u8x8_SetPin_HW_I2C(u8x8_t *u8x8, uint8_t reset, uint8_t clock, uint8_t data) void u8x8_SetPin_HW_I2C(u8x8_t *u8x8, uint8_t reset, uint8_t clock,
{ uint8_t data) {
u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset); u8x8_SetPin(u8x8, U8X8_PIN_RESET, reset);
u8x8_SetPin(u8x8, U8X8_PIN_I2C_CLOCK, clock); u8x8_SetPin(u8x8, U8X8_PIN_I2C_CLOCK, clock);
u8x8_SetPin(u8x8, U8X8_PIN_I2C_DATA, data); u8x8_SetPin(u8x8, U8X8_PIN_I2C_DATA, data);
} }
class U8G2_SSD1306_128X64_NONAME_F_HW_I2C : public U8G2 { class U8G2_SSD1306_128X64_NONAME_F_HW_I2C : public U8G2 {
public: U8G2_SSD1306_128X64_NONAME_F_HW_I2C(const u8g2_cb_t *rotation, uint8_t reset = U8X8_PIN_NONE, uint8_t clock = U8X8_PIN_NONE, uint8_t data = U8X8_PIN_NONE) : U8G2() { public:
u8g2_Setup_ssd1306_i2c_128x64_noname_f(&u8g2, rotation, u8g2_esp32_i2c_byte_cb, u8g2_esp32_gpio_and_delay_cb); U8G2_SSD1306_128X64_NONAME_F_HW_I2C(const u8g2_cb_t *rotation,
uint8_t reset = U8X8_PIN_NONE,
uint8_t clock = U8X8_PIN_NONE,
uint8_t data = U8X8_PIN_NONE)
: U8G2() {
u8g2_Setup_ssd1306_i2c_128x64_noname_f(
&u8g2, rotation, u8g2_esp32_i2c_byte_cb, u8g2_esp32_gpio_and_delay_cb);
u8x8_SetPin_HW_I2C(getU8x8(), reset, clock, data); u8x8_SetPin_HW_I2C(getU8x8(), reset, clock, data);
} }
}; };

10
main/ugv_io.cc

@ -12,11 +12,11 @@
namespace ugv { namespace ugv {
namespace io { namespace io {
static constexpr mcpwm_unit_t MCPWM_UNIT = MCPWM_UNIT_0; static constexpr mcpwm_unit_t MCPWM_UNIT = MCPWM_UNIT_0;
static constexpr gpio_num_t MOTOR_LEFT_PWM = GPIO_NUM_0; static constexpr gpio_num_t MOTOR_LEFT_PWM = GPIO_NUM_0;
static constexpr gpio_num_t MOTOR_LEFT_DIR = GPIO_NUM_0; static constexpr gpio_num_t MOTOR_LEFT_DIR = GPIO_NUM_0;
static constexpr gpio_num_t MOTOR_RIGHT_PWM = GPIO_NUM_0; static constexpr gpio_num_t MOTOR_RIGHT_PWM = GPIO_NUM_0;
static constexpr gpio_num_t MOTOR_RIGHT_DIR = GPIO_NUM_0; static constexpr gpio_num_t MOTOR_RIGHT_DIR = GPIO_NUM_0;
IOClass IO; IOClass IO;

2
main/ugv_io.hh

@ -30,7 +30,7 @@ class IOClass {
private: private:
UART_GPS gps_; UART_GPS gps_;
MPU mpu_; MPU mpu_;
void InitMotors(); void InitMotors();
}; };

6
main/ugv_main.cc

@ -9,8 +9,8 @@
namespace ugv { namespace ugv {
using ugv::io::IO;
using ugv::comms::Comms; using ugv::comms::Comms;
using ugv::io::IO;
static const char *TAG = "ugv_main"; static const char *TAG = "ugv_main";
@ -40,14 +40,14 @@ void loop(void) {
static int32_t last_packet_rssi; static int32_t last_packet_rssi;
static int8_t last_packet_snr; static int8_t last_packet_snr;
static char buf[BUF_SZ]; static char buf[BUF_SZ];
static io::Inputs inputs; static io::Inputs inputs;
IO.ReadInputs(inputs); IO.ReadInputs(inputs);
// ESP_LOGI(TAG, "inputs %s", inputs.ToString()); // ESP_LOGI(TAG, "inputs %s", inputs.ToString());
oled->firstPage(); oled->firstPage();
lora_rssi = Comms.ReadRssi(); lora_rssi = Comms.ReadRssi();
lora_lna_gain = Comms.ReadLnaGain(); lora_lna_gain = Comms.ReadLnaGain();
Comms.Lock(); Comms.Lock();

Loading…
Cancel
Save