I2Cwrapper v0.4.0
Generic framework for Arduino I2C target devices
ESP32sensorsI2C_firmware.h File Reference

Firmware module for the I2Cwrapper firmare. More...

Detailed Description

Firmware module for the I2Cwrapper firmare.

Allows I2C-control of touch buttons and hall sensorsof an ESP32. Meant mostly as a simple demo for user contributed modules using the interrupt mechanism. Will not compile for platforms other than ESP32.

Author

Copyright (c) 2022 juh

License

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.

Todo:
touchAttachInterruptArg() is available since May 2022 with esp32 release 2.0.3. Implement it for a much easier and cleaner solution. Also implement touchInterruptSetThresholdDirection() Also adapt for SOC_TOUCH_SENSOR_NUM no. of sensors (I think newer ESP32 variants have more than 10)

Functions

void touchDetected0 ()
 
void touchDetected1 ()
 
void touchDetected2 ()
 
void touchDetected3 ()
 
void touchDetected4 ()
 
void touchDetected5 ()
 
void touchDetected6 ()
 
void touchDetected7 ()
 
void touchDetected8 ()
 
void touchDetected9 ()
 
 log ("ESP32sensorsI2C module enabled.\n")
 
bufferIn read (measure)
 
bufferIn read (sleep)
 
 if (!ESP32sensorsTouchSetCyclesChanged)
 
 touchSetCycles (measure, sleep)
 
bufferIn read (pin)
 
bufferOut write ((uint16_t) touchRead(pin))
 
bufferIn read (threshold)
 
bufferIn read (falling)
 
 log (" enabling int for touch pin #")
 
 log (pin)
 
 log (" (=touch")
 
 switch (digitalPinToTouchChannel(pin))
 
 log (") with threshold=")
 
 log (threshold)
 
 log ("\n")
 
 if (ESP32sensorsTouchSetCyclesChanged)
 
 for (uint8_t i=0;i< SOC_TOUCH_SENSOR_NUM;i++)
 

Variables

uint16_t isAttached = 0
 
uint16_t ESP32sensorsTouchSetCycles_old_sleep_cycle
 
uint16_t ESP32sensorsTouchSetCycles_old_meas_cycle
 
bool ESP32sensorsTouchSetCyclesChanged = false
 
case ESP32sensorsTouchSetCyclesCmd
 
uint16_t sleep
 
 break
 
case ESP32sensorsTouchReadCmd
 
case ESP32sensorsEnableInterruptsCmd
 
uint16_t threshold
 
bool falling
 
case ESP32sensorsHallReadCmd
 
case ESP32sensorsTemperatureReadCmd
 

Function Documentation

◆ for()

for ( )

◆ if() [1/2]

if ( ESP32sensorsTouchSetCyclesChanged)

◆ if() [2/2]

◆ log() [1/7]

log ( " enabling int for touch pin #"  )

◆ log() [2/7]

log ( )

◆ log() [3/7]

log ( )

◆ log() [4/7]

log ( "\n"  )

◆ log() [5/7]

log ( "ESP32sensorsI2C module enabled.\n"  )

◆ log() [6/7]

log ( pin  )

◆ log() [7/7]

log ( threshold  )

◆ read() [1/5]

bufferIn read ( falling  )

◆ read() [2/5]

bufferIn read ( measure  )

◆ read() [3/5]

bufferIn read ( pin  )

◆ read() [4/5]

bufferIn read ( sleep  )

◆ read() [5/5]

bufferIn read ( threshold  )

◆ switch()

switch ( digitalPinToTouchChannel(pin)  )

◆ touchDetected0()

void touchDetected0 ( )

◆ touchDetected1()

void touchDetected1 ( )

◆ touchDetected2()

void touchDetected2 ( )

◆ touchDetected3()

void touchDetected3 ( )

◆ touchDetected4()

void touchDetected4 ( )

◆ touchDetected5()

void touchDetected5 ( )

◆ touchDetected6()

void touchDetected6 ( )

◆ touchDetected7()

void touchDetected7 ( )

◆ touchDetected8()

void touchDetected8 ( )

◆ touchDetected9()

void touchDetected9 ( )

◆ touchSetCycles()

touchSetCycles ( measure  ,
sleep   
)

◆ write()

bufferOut write ( (uint16_t) touchRead(pin)  )

Variable Documentation

◆ break

break

◆ ESP32sensorsEnableInterruptsCmd

case ESP32sensorsEnableInterruptsCmd

◆ ESP32sensorsHallReadCmd

case ESP32sensorsHallReadCmd

◆ ESP32sensorsTemperatureReadCmd

case ESP32sensorsTemperatureReadCmd

◆ ESP32sensorsTouchReadCmd

case ESP32sensorsTouchReadCmd

◆ ESP32sensorsTouchSetCycles_old_meas_cycle

uint16_t ESP32sensorsTouchSetCycles_old_meas_cycle

◆ ESP32sensorsTouchSetCycles_old_sleep_cycle

uint16_t ESP32sensorsTouchSetCycles_old_sleep_cycle

◆ ESP32sensorsTouchSetCyclesChanged

bool ESP32sensorsTouchSetCyclesChanged = false

◆ ESP32sensorsTouchSetCyclesCmd

case ESP32sensorsTouchSetCyclesCmd

◆ falling

bool falling

◆ isAttached

uint16_t isAttached = 0

◆ sleep

uint16_t sleep

◆ threshold

uint16_t threshold