Skip to content

Commit

Permalink
Fix compilation warnings and fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisxhe committed Oct 17, 2023
1 parent d0f26c3 commit 113a497
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 34 deletions.
2 changes: 1 addition & 1 deletion examples/LTR553ALS_Sensor/LTR553ALS_Sensor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void loop()
* It will be flagged when the IC has reached saturation
* and not able to perform any further PS measurement
* */
bool saturated;
bool saturated = false;
if (canRead()) {
Serial.print(" ALS: CH1:"); Serial.print(als.getLightSensor(1));
Serial.print(" - CH0:"); Serial.print(als.getLightSensor(0));
Expand Down
7 changes: 5 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
; src_dir = examples/BHI260AP_Orientation
; src_dir = examples/BHI260AP_StepCounter
; src_dir = examples/BHI260AP_DebugInfo
src_dir = examples/BMM150_GetDataExample
; src_dir = examples/BMM150_GetDataExample

; Touch devices support list
; src_dir = examples/TouchDrv_FT3267_LilyGo_T_RGB
src_dir = examples/TouchDrv_FT3267_LilyGo_T_RGB
; src_dir = examples/TouchDrv_GT911_LilyGo_T_RGB
; src_dir = examples/TouchDrv_FT6232_GetPoint
; src_dir = examples/TouchDrv_GT911_GetPoint
Expand Down Expand Up @@ -91,6 +91,9 @@ build_flags =
; -DSENSOR_RST=13

-DCORE_DEBUG_LEVEL=4
-Wtype-limits
-Werror
-Wall

[env:esp32dev]
extends = env
Expand Down
3 changes: 1 addition & 2 deletions src/SensorBHI260AP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ class SensorBHI260AP
if (__error_code != BHY2_OK) {
return false;
}
return boot_status & BHY2_BST_HOST_INTERFACE_READY == false;
return (boot_status & BHY2_BST_HOST_INTERFACE_READY) == false;
}

uint16_t getKernelVersion()
Expand Down Expand Up @@ -534,7 +534,6 @@ class SensorBHI260AP

bool initImpl()
{
int8_t rslt;
uint8_t product_id = 0;

if (__handler.rst != SENSOR_PIN_NONE) {
Expand Down
8 changes: 3 additions & 5 deletions src/SensorBMA423.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ class SensorBMA423 :
used with delay of 1 ms */
writeRegister(BMA4_ACCEL_CONFIG_ADDR, buffer[0]);
delay(2);
writeRegister(BMA4_ACCEL_CONFIG_ADDR + 1, buffer[2]);
writeRegister(BMA4_ACCEL_CONFIG_ADDR + 1, buffer[1]);
return true;
}

Expand Down Expand Up @@ -332,7 +332,7 @@ class SensorBMA423 :

uint8_t direction()
{
int16_t x, y, z;
int16_t x = 0, y = 0, z = 0;
getAccelerometer(x, y, z);
uint16_t absX = abs(x);
uint16_t absY = abs(y);
Expand Down Expand Up @@ -417,7 +417,7 @@ class SensorBMA423 :

bool disablePedometer()
{
return enablePedometer(false) != DEV_WIRE_ERR;
return enablePedometer(false);
}

bool enablePedometer(bool enable = true)
Expand Down Expand Up @@ -655,7 +655,6 @@ class SensorBMA423 :
bool feature_disable(uint8_t feature, uint8_t len, uint8_t *buffer)
{
uint8_t index = 0;
int rslt;

/* Disable step counter */
if ((feature & FEATURE_STEP_CNTR) > 0) {
Expand Down Expand Up @@ -711,7 +710,6 @@ class SensorBMA423 :
int feature_enable(uint8_t feature, uint8_t len, uint8_t *buffer)
{
uint8_t index = 0;
uint16_t rslt;

/* Enable step counter */
if ((feature & FEATURE_STEP_CNTR) > 0) {
Expand Down
3 changes: 0 additions & 3 deletions src/SensorBMM150.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,6 @@ class SensorBMM150

bool initImpl()
{
int8_t rslt;
uint8_t product_id = 0;

memset(&settings, 0, sizeof(settings));

if (__handler.rst != SENSOR_PIN_NONE) {
Expand Down
2 changes: 0 additions & 2 deletions src/SensorCommon.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,6 @@ protected:
return (__wire->endTransmission() == 0) ? DEV_WIRE_NONE : DEV_WIRE_ERR;
}
if (__spi) {
uint8_t msb = reg >> 8;
uint8_t lsb = reg & 0xFF;
__spi->beginTransaction(*__spiSetting);
digitalWrite(__cs, LOW);
if (__reg_addr_len == 1) {
Expand Down
15 changes: 12 additions & 3 deletions src/SensorPCF8563.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,20 @@ class SensorPCF8563 :
{
uint8_t buffer[4] = {0};
if (minute != PCF8563_NO_ALARM) {
buffer[0] = DEC2BCD(constrain(minute, 0, 59));
if (minute > 59) {
minute = 59;
}
buffer[0] = DEC2BCD(minute);
buffer[0] &= ~PCF8563_ALARM_ENABLE;
} else {
buffer[0] = PCF8563_ALARM_ENABLE;
}

if (hour != PCF8563_NO_ALARM) {
buffer[1] = DEC2BCD(constrain(hour, 0, 23));
if (hour > 23) {
hour = 23;
}
buffer[1] = DEC2BCD(hour);
buffer[1] &= ~PCF8563_ALARM_ENABLE;
} else {
buffer[1] = PCF8563_ALARM_ENABLE;
Expand All @@ -209,7 +215,10 @@ class SensorPCF8563 :
buffer[2] = PCF8563_ALARM_ENABLE;
}
if (week != PCF8563_NO_ALARM) {
buffer[3] = DEC2BCD(constrain(week, 0, 6));
if (week > 6) {
week = 6;
}
buffer[3] = DEC2BCD(week);
buffer[3] &= ~PCF8563_ALARM_ENABLE;
} else {
buffer[3] = PCF8563_ALARM_ENABLE;
Expand Down
6 changes: 3 additions & 3 deletions src/SensorQMC6310.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,15 @@ class SensorQMC6310 :
y = (int16_t)(buffer[3] << 8) | (buffer[2]);
z = (int16_t)(buffer[5] << 8) | (buffer[4]);

if (x >= 0x8000) {
if (x == 32767) {
x = -((65535 - x) + 1);
}
x = (x - x_offset);
if (y >= 0x8000) {
if (y == 32767) {
y = -((65535 - y) + 1);
}
y = (y - y_offset);
if (z >= 0x8000) {
if (z == 32767) {
z = -((65535 - z) + 1);
}
z = (z - z_offset);
Expand Down
9 changes: 8 additions & 1 deletion src/SensorRTC.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,15 @@ class RTC_DateTime
uint8_t hour,
uint8_t minute,
uint8_t second
) : year(year), month(month), day(day), hour(hour), minute(minute), second(second), week(week)
)
{
this->year = year;
this->month = month;
this->day = day;
this->hour = hour;
this->minute = minute;
this->second = second;
this->week = week;
};
uint16_t year;
uint8_t month;
Expand Down
7 changes: 3 additions & 4 deletions src/TouchDrvFT6X36.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ class TouchDrvFT6X36 :

uint8_t getPoint(int16_t *x_array, int16_t *y_array, uint8_t size = 1)
{
uint8_t touchedID;
uint8_t buffer[16];

if (!x_array || !y_array || !size)
Expand All @@ -208,14 +207,14 @@ class TouchDrvFT6X36 :
return 0;
}

uint8_t mode = buffer[0];
// uint8_t mode = buffer[0];
//REG 0x01
uint8_t gestrue = buffer[1];
// uint8_t gestrue = buffer[1];
//REG 0x02
uint8_t point = buffer[2] & 0x0F;

//REG 0x03 ~ 0x04
uint8_t eventFlag = (buffer[3] & 0xC0) >> 6;
// uint8_t eventFlag = (buffer[3] & 0xC0) >> 6;
uint16_t posX = ((buffer[3] & 0x0F) << 8) | buffer[4];
//REG 0x05 ~ 0x06
uint16_t posY = ((buffer[5] & 0x0F) << 8) | buffer[6] ;
Expand Down
2 changes: 0 additions & 2 deletions src/TouchDrvGT911.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ class TouchDrvGT911 :

uint8_t getPoint(int16_t *x_array, int16_t *y_array, uint8_t size = 1)
{
uint8_t touchedID;
uint8_t buffer[39];

if (!x_array || !y_array || size == 0)
Expand Down Expand Up @@ -303,7 +302,6 @@ class TouchDrvGT911 :

void inline clearBuffer()
{
uint8_t val = 0x00;
writeRegister(GT911_POINT_INFO, 0x00);
}

Expand Down
19 changes: 15 additions & 4 deletions src/TouchDrvInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,28 @@
#include <Arduino.h>
#include "TouchDrvInterface.hpp"

TouchDrvInterface::TouchDrvInterface() : __swapXY(false),
__mirrorX(false), __mirrorY(false),
__resX(0), __resY(0),
__irq(-1), __rst(-1),
TouchDrvInterface::TouchDrvInterface() :
__resX(0),
__resY(0),
__xMax(0),
__yMax(0),
__swapXY(false),
__mirrorX(false),
__mirrorY(false),
__rst(-1),
__irq(-1),
__chipID(0x00),
__homeButtonCb(NULL),
__userData(NULL)
{

}

TouchDrvInterface::~TouchDrvInterface()
{

}

uint32_t TouchDrvInterface::getChipID()
{
return __chipID;
Expand Down
4 changes: 3 additions & 1 deletion src/TouchDrvInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class TouchData
{
public:
TouchData() {}
~TouchData() {}
~TouchData() {};
uint8_t available;
uint8_t id[5];
int16_t x[5];
Expand Down Expand Up @@ -71,6 +71,8 @@ class TouchDrvInterface
public:
TouchDrvInterface();

virtual ~TouchDrvInterface();

virtual bool init() = 0;

virtual void reset() = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/bosch/SensorBhy2Define.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ typedef struct ParseCallBackList {
static uint8_t current_id;
uint8_t id;
BhyParseDataCallback cb;
uint8_t *data;
uint32_t data_length;
uint8_t *data;
ParseCallBackList() : id(current_id++), cb(NULL), data_length(0), data(NULL)
{
}
Expand Down

0 comments on commit 113a497

Please sign in to comment.