mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-27 21:26:43 +00:00
Fix ESP8266 compiler error
This commit is contained in:
parent
51c9af9086
commit
6b0150a624
@ -22,39 +22,44 @@
|
|||||||
|
|
||||||
#define NUMSAMPLES 2
|
#define NUMSAMPLES 2
|
||||||
|
|
||||||
TSPoint::TSPoint(void) {
|
TSPoint::TSPoint(void)
|
||||||
|
{
|
||||||
x = y = 0;
|
x = y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TSPoint::TSPoint(int16_t x0, int16_t y0, int16_t z0) {
|
TSPoint::TSPoint(int16_t x0, int16_t y0, int16_t z0)
|
||||||
|
{
|
||||||
x = x0;
|
x = x0;
|
||||||
y = y0;
|
y = y0;
|
||||||
z = z0;
|
z = z0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TSPoint::operator==(TSPoint p1) {
|
bool TSPoint::operator==(TSPoint p1)
|
||||||
|
{
|
||||||
return ((p1.x == x) && (p1.y == y) && (p1.z == z));
|
return ((p1.x == x) && (p1.y == y) && (p1.z == z));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TSPoint::operator!=(TSPoint p1) {
|
bool TSPoint::operator!=(TSPoint p1)
|
||||||
|
{
|
||||||
return ((p1.x != x) || (p1.y != y) || (p1.z != z));
|
return ((p1.x != x) || (p1.y != y) || (p1.z != z));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if(NUMSAMPLES > 2)
|
#if(NUMSAMPLES > 2)
|
||||||
static void insert_sort(int array[], uint8_t size) {
|
static void insert_sort(int array[], uint8_t size)
|
||||||
|
{
|
||||||
uint8_t j;
|
uint8_t j;
|
||||||
int save;
|
int save;
|
||||||
|
|
||||||
for(int i = 1; i < size; i++) {
|
for(int i = 1; i < size; i++) {
|
||||||
save = array[i];
|
save = array[i];
|
||||||
for (j = i; j >= 1 && save < array[j - 1]; j--)
|
for(j = i; j >= 1 && save < array[j - 1]; j--) array[j] = array[j - 1];
|
||||||
array[j] = array[j - 1];
|
|
||||||
array[j] = save;
|
array[j] = save;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TSPoint TouchScreen::getPoint(void) {
|
TSPoint TouchScreen::getPoint(void)
|
||||||
|
{
|
||||||
int x, y, z;
|
int x, y, z;
|
||||||
int samples[NUMSAMPLES];
|
int samples[NUMSAMPLES];
|
||||||
uint8_t i, valid;
|
uint8_t i, valid;
|
||||||
@ -114,7 +119,6 @@ TSPoint TouchScreen::getPoint(void) {
|
|||||||
digitalWrite(_yp, HIGH);
|
digitalWrite(_yp, HIGH);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef __arm__
|
#ifdef __arm__
|
||||||
delayMicroseconds(20); // Fast ARM chips need to allow voltages to settle
|
delayMicroseconds(20); // Fast ARM chips need to allow voltages to settle
|
||||||
#endif
|
#endif
|
||||||
@ -156,7 +160,6 @@ TSPoint TouchScreen::getPoint(void) {
|
|||||||
digitalWrite(_ym, HIGH);
|
digitalWrite(_ym, HIGH);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(ESP32_WIFI_TOUCH) && defined(ESP32)
|
#if defined(ESP32_WIFI_TOUCH) && defined(ESP32)
|
||||||
int z1 = analogRead(aXM);
|
int z1 = analogRead(aXM);
|
||||||
int z2 = analogRead(aYP);
|
int z2 = analogRead(aYP);
|
||||||
@ -187,8 +190,8 @@ TSPoint TouchScreen::getPoint(void) {
|
|||||||
return TSPoint(x, y, z);
|
return TSPoint(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
TouchScreen::TouchScreen(uint8_t xp, uint8_t yp, uint8_t xm, uint8_t ym,
|
TouchScreen::TouchScreen(uint8_t xp, uint8_t yp, uint8_t xm, uint8_t ym, uint16_t rxplate = 0)
|
||||||
uint16_t rxplate=0) {
|
{
|
||||||
_yp = yp;
|
_yp = yp;
|
||||||
_xm = xm;
|
_xm = xm;
|
||||||
_ym = ym;
|
_ym = ym;
|
||||||
@ -210,7 +213,8 @@ TouchScreen::TouchScreen(uint8_t xp, uint8_t yp, uint8_t xm, uint8_t ym,
|
|||||||
pressureThreshhold = 10;
|
pressureThreshhold = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TouchScreen::readTouchX(void) {
|
int TouchScreen::readTouchX(void)
|
||||||
|
{
|
||||||
pinMode(_yp, INPUT);
|
pinMode(_yp, INPUT);
|
||||||
pinMode(_ym, INPUT);
|
pinMode(_ym, INPUT);
|
||||||
digitalWrite(_yp, LOW);
|
digitalWrite(_yp, LOW);
|
||||||
@ -228,8 +232,8 @@ int TouchScreen::readTouchX(void) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TouchScreen::readTouchY(void)
|
||||||
int TouchScreen::readTouchY(void) {
|
{
|
||||||
pinMode(_xp, INPUT);
|
pinMode(_xp, INPUT);
|
||||||
pinMode(_xm, INPUT);
|
pinMode(_xm, INPUT);
|
||||||
digitalWrite(_xp, LOW);
|
digitalWrite(_xp, LOW);
|
||||||
@ -247,8 +251,8 @@ int TouchScreen::readTouchY(void) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t TouchScreen::pressure(void)
|
||||||
uint16_t TouchScreen::pressure(void) {
|
{
|
||||||
// Set X+ to ground
|
// Set X+ to ground
|
||||||
pinMode(_xp, OUTPUT);
|
pinMode(_xp, OUTPUT);
|
||||||
digitalWrite(_xp, LOW);
|
digitalWrite(_xp, LOW);
|
||||||
@ -271,7 +275,6 @@ uint16_t TouchScreen::pressure(void) {
|
|||||||
int z2 = analogRead(_yp);
|
int z2 = analogRead(_yp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
if(_rxplate != 0) {
|
if(_rxplate != 0) {
|
||||||
// now read the x
|
// now read the x
|
||||||
float rtouch;
|
float rtouch;
|
||||||
|
@ -24,7 +24,7 @@ typedef volatile uint8_t RwReg;
|
|||||||
#if defined(ARDUINO_STM32_FEATHER)
|
#if defined(ARDUINO_STM32_FEATHER)
|
||||||
typedef volatile uint32 RwReg;
|
typedef volatile uint32 RwReg;
|
||||||
#endif
|
#endif
|
||||||
#if defined(ARDUINO_FEATHER52) || defined(ESP32)
|
#if defined(ARDUINO_FEATHER52) || defined(ESP32) || defined(ESP8266)
|
||||||
typedef volatile uint32_t RwReg;
|
typedef volatile uint32_t RwReg;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user